This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Key pair generation with EDCSA (secp256k1)

Hi

We have a generated a key pair using ECDSA secp256k1

```

err_code = nrf_crypto_ecc_key_pair_generate(NULL, &g_nrf_crypto_ecc_secp256k1_curve_info, &private_key, &public_key);
    
  
        size = sizeof(raw_key_buffer);
        err_code = nrf_crypto_ecc_public_key_to_raw(&public_key, raw_key_buffer, &size);

```
and printing the hex like so
```

#if NRF_LOG_ENABLED
size_t i;
NRF_LOG_RAW_INFO(" ");
for(i = 0; i < size; i++)
{
NRF_LOG_RAW_INFO("%02x", p_string[i]);
}
#endif // NRF_LOG_ENABLED


```

the priv key and pubkey turns out to be 
```
3C9CCF1CD87C4FB6B378E65AB1476A5F272A981319AE09CA632B9002F4A4A90A
D6B08820245D30D34110C6B4DCFDD9AB0F6B80F646435A22A7F45679D0010C67754DEEBED6B8E56AD6E63B56AF7FDA09CC0164EB0DC17A00716F000752DD37A1
```

however when I use the priv key in another escdsa lib I know and trust it produces a different pubkey
```
043338c8ddb9d0e3894b2ae5f68e41e745c387afe8215b1e3e7750e98a1ef41cbdaac3e34d6c10e606e30894f0b73b7ccc0ea50ee64354bf7597c1ed8cc9d52174
```

Is there anything incorrect in your generation of the key pair and conversion to hex?

Thanks!

Parents Reply Children
No Data
Related