1

I tried to generate pair key for ecdsa using openssl.

Why the public key length is 65 bytes and not 64?

Create private key

openssl ecparam -genkey -name secp256r1 -noout -out private.pem

Generate public key

openssl ec -in private.pem -text -noout

read EC key

Private-Key: (256 bit)

priv: 13:10:bc:9c:a8:3d:8b:fa:91:b2:a4:f8:e5:d1:5f: 53:56:eb:16:91:86:aa:6b:c5:16:8b:16:e9:04:4e: 03:a9

pub: 04:51:02:22:75:dd:3d:25:ee:b6:aa:a5:c6:c6:27: 5c:07:c5:e6:e9:75:40:4a:b3:e4:cd:22:e5:cc:9a: bd:1b:14:0e:53:6a:57:9a:26:98:d2:2f:6b:a4:9b: a4:47:fe:ab:76:99:59:26:39:ac:2b:2e:93:b3:ef: f0:8b:f5:3b:86

ASN1 OID: prime256v1

NIST CURVE: P-256

3

According to this page, the 65 byte public key is the uncompressed variant.

The first byte 0x04 is the prefix, then it is followed by two 32-byte numbers.

I cannot explain why this is the case, not an crypto expert. Maybe someone can elaborate on that.

1
  • spec256r1 is an elliptic curve (the EC in ECDSA). Public keys in ECDSA are expressed as a co-ordinate on the curve, i.e. an x and a y value. As you say 0x04 indicates the key is in uncompressed format, meaning the whole x and y values are given - each of which are 32 bits in length. – Matt Caswell Jul 30 '19 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.