Posts  / #POST-001279
REDDIT

Probability of randomly generating an EC public key

L
Feb 13, 2025 · 04:38

From what I understand the size of a secp256k1 EC public key is 65 bytes (out of which one is a prefix byte so lets ignore that). The private key is any 256-bit number in [0, N] where N is the order of the curve. So if I have a random 64-byte stream, the probability of it being a valid EC public key on the curve is `N / 2^512 = 2^256 / 2^512 = 2^{-256}`. Does this sound right?

Also from some shallow reading you can compress the public key to half the size (32-bytes) by only using one of the (x, y) coordinates due to "special properties of the curve". So then how would I find the probabilty of a random 32-byte stream being a valid EC public key on the (secp256k1) curve? Does the probability remain the same?