user662: Why does the length of a bitcoin key vary?  Why aren't they all the same length?

user9211: Private keys are 256 bit numbers
Public keys are a pair of X,Y coordinates.  Each coordinate is a 256 bit number.  BUT for every X coordinate there are only two possible Y coordinates (one positive, one negative) so you can store a public key as just the X coordinate (256 bits) and the sign of the Y coordinate (1 bit) and the proper Y coordinate can then be calculated from the X coordinate and the sign.
So private key = 256 bits, public key = 2*256=512 bits OR 256+1=257 bits
Then there is a small amount of formatting overhead of a few bits.
Then these are encoded.

user403: The length of a key doesn't vary. Private keys are always 32 bytes, and public keys are always 65 bytes (or 33 bytes for a compressed public key). Public key hashes are always 20 bytes.
The length of addresses vary because in Bitcoin's base58 encoding, leading zero bytes are expressed as a single "1". Other bytes require more than one character in order to be expressed in base58.

662: <p>Why does the length of a bitcoin key vary?  Why aren't they all the same length?</p>
 9211: <p>Private keys are 256 bit numbers</p>
<p>Public keys are a pair of X,Y coordinates.  Each coordinate is a 256 bit number.  BUT for every X coordinate there are only two possible Y coordinates (one positive, one negative) so you can store a public key as just the X coordinate (256 bits) and the sign of the Y coordinate (1 bit) and the proper Y coordinate can then be calculated from the X coordinate and the sign.</p>
<p>So private key = 256 bits, public key = 2*256=512 bits OR 256+1=257 bits</p>
<p>Then there is a small amount of formatting overhead of a few bits.</p>
<p>Then these are encoded.</p>
 403: <p>The length of a <em>key</em> doesn't vary. Private keys are always 32 bytes, and public keys are always 65 bytes (or 33 bytes for a compressed public key). Public key hashes are always 20 bytes.</p>

<p>The length of addresses vary because in Bitcoin's base58 encoding, leading zero bytes are expressed as a single "1". Other bytes require more than one character in order to be expressed in base58.</p>
