paulmillr / noble-curves

Audited & minimal JS implementation of elliptic curve cryptography.
https://paulmillr.com/noble
MIT License
664 stars 62 forks source link

why secp256k1.utils.randomPrivateKey() produce a 32 bytes key? #88

Closed zzzh closed 12 months ago

zzzh commented 12 months ago

And so do the secp256k1.getPublicKey(). Shouldn't they produce keys of 64 bytes?

nflatrea commented 12 months ago

nope public keys in Elliptic curve cryptography is just point coordinates, You can encode it in PEM or usually SEC format,

66 bytes for uncompressed public key

You can also compress it to produce 33 bytes public keys, only using one coordinate and parity

33 bytes for compressed public key

https://www.secg.org/sec1-v2.pdf