My pc server should send information to nrf52832 by ECDH, then I create a dll file from micro-ecc. However,the result in windows is not the same as the result in nrf52832. The following is some test code in VS2013.
// ecdhtest.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "uECC.h"
int _tmain(int argc, _TCHAR* argv[]) {
uint8_t privatekey[] = {
0x76, 0xA1, 0x3D, 0x5A, 0x97, 0xA4, 0x09, 0x2C,
0x29, 0xCF, 0x0F, 0xDA, 0xA7, 0x3C, 0x6F, 0xED,
0x92, 0x93, 0x62, 0xEE, 0x21, 0xF8, 0xA5, 0x40,
0x53, 0x33, 0x19, 0xB1, 0x82, 0xAE, 0xCE, 0x1C};
static uint8_t publicket52832[] = { //The result in nrf52832(10040)
0x80, 0x73, 0xC2, 0xA3, 0xB6, 0xC7, 0xF8, 0x61,
0xBC, 0x0D, 0xCB, 0x68, 0x3C, 0x83, 0xBD, 0xCE,
0x48, 0xB8, 0x07, 0x1C, 0x7E, 0xCC, 0x39, 0x38,
0x7C, 0x9C, 0xC7, 0xBF, 0x91, 0xC0, 0xCE, 0x25,
0xF1, 0xD2, 0xC2, 0x0F, 0x30, 0x4B, 0x98, 0xC4,
0x74, 0xCF, 0xDB, 0x01, 0x5C, 0xC6, 0xD4, 0x6D,
0x19, 0x90, 0x30, 0x0A, 0x40, 0xA0, 0xBD, 0xC2,
0x2E, 0x9C, 0xAA, 0x8E, 0x46, 0xC7, 0x92, 0x3D};
uint8_t publickey[64];
uECC_compute_public_key(privatekey, publickey, uECC_secp256r1());
for (int i = 0; i <64; i++)
{
printf(" %02X", publickey[i]);
if (i % 8 == 7)
printf("\r\n");
}
getchar();
return 0;
}
The result in windows:
7A 93 1E D8 1B 4A 32 29 88 7A A5 3C A2 F9 BA 3F B4 83 2A DB 0B EF E3 F3 2A E4 FA 9D B1 38 00 99 A4 4F 7D 1D F4 98 90 E4 9B 10 0C 4D D8 95 45 A9 90 34 F8 95 A3 A6 31 79 D2 BD 1A 19 FF E1 BB E0
The different result confused me, why?