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

nrfutil keys generated in X Y K params

I am using nrfutil to generate ECC private keys and public keys. However on an apple device the keys ANSI X9.63 it is represented in X,Y, K parameters. How do i match the parameters.

  • I found this online: developer.apple.com/.../1643698-seckeycopyexternalrepresentation which is what I'm assuming you are looking at

    I am not familiar with this way of formatting the raw key for an elliptic curve. This looks like definitions from the document SEC1 (Elliptic Curve Cryptography) where the form of encoding is 04 || X || Y. The first parameter (04) is a value to tell that the public key (X and Y) is uncompressed. I can't find the explicit link to a combination of X, Y and K in ANSI X9.63.

    From the context I would assume that you are trying to do ECDSA using a deterministic K tools.ietf.org/.../rfc6979 (Deterministic Usage of the Digital Signature Algorithm (DSA) and Elliptic Curve Digital Signature Algorithm (ECDSA)). Normally K is a random number that gets replaced each time you do a signing. What the RFC explains is a way to get the signature the same every time (given that K is generated from some other source that work in a deterministic manner).

    I would assume that you need to implement a call to generate K using HMAC, and provide this to the python ECDSA interface in nrfutil code. Note that K can be generated both from the private key or some other external source of entropy (according to the RFC)

    The public key that we export in nrfutil in code is just a buffer with X,Y (without the 04 tag in Where we export the public key you need to make a buffer and add 04, X, Y and K sequentially.

    Note that there might be alignment restrictions on X and Y in some elliptic curve APIs

Related