Given a public key on the P-256 Curve is it correct to say that the public key is 64 bytes long ie. (x,y)?

Secondly is the private key 32 bytes long? if so, how is the private key generated and why is it shorter than the public key?

  • 4
    $\begingroup$ Possible duplicate of ECDSA: Why is SigningKey shorter than VerifyingKey, compression technique. $\endgroup$ – kelalaka Aug 5 '19 at 19:22
  • $\begingroup$ @kelalaka actually to hit 64B public keys you don't need compression and neither do you for 32B private keys. $\endgroup$ – SEJPM Aug 6 '19 at 6:10
  • $\begingroup$ I don't mean for verifying or compression. I mean in ithe simplest form. The private key is 32B long and the public key is 64B long. Why is this? $\endgroup$ – err Aug 6 '19 at 9:47

The private key can be anything within the group order, if you take the key more than 32 bytes, then your key will work, but due to the cyclic nature of the group, your public key will be equal to the remainder of the key from the group order (modulo the group order).

As for the public key, it will not necessarily be 64 bytes (two numbers are the x and y coordinates, modulo the final field p), because, for example, the x or y coordinate can be less than 32 bytes, which ultimately will give public key less than 64 bytes.

The private key is generated using complex random cryptographic functions. You can also flip a coin 256 times and write 0 or 1 when an eagle or tails falls out, so you get a 256 bit (32 byte) random number, or you can use the random number generation functions that many cryptography protocols have.

Here my answer for private key more 32 byte for secp256k1, but the meaning is the same

| improve this answer | |

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