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?
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It only takes a minute to sign up.Sign up to join this community
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