Hello, I’,m implementing a cryptographic keys management library for kagome. And I don’t get what spec means by “We use the standard Bitcoin EC encoding for Secp256k1 public and private keys”.
Does it mean simply 32 bytes for private key and 32+32 = 64 bytes for public key?
Should it be octets sequence or raw bytes?
Thanks in advance.
Thanks for bringing this up - it’s something I ought to add to the spec.
I just did some digging through the go code, which uses the btcec
module from https://github.com/btcsuite/btcd.
Private keys are serialized to 32 bytes. Public keys use the SerializeCompressed method which compresses to 33 bytes.
JavaScript also uses the compressed form for public keys.
Thank you, it is what I needed.
I made an issue to improve the spec: https://github.com/libp2p/specs/issues/190 - hopefully I will have time to fix the spec soon.
1 Like