# What is the length of the extended public key?

I'm reading the Master Bitcoin book and I'm a bit confused. The confusion is related to the length of the extended keys.

The book says that extended keys are 512 or 513 bits long. It is clear to me that the length of the extended private key is 512 bits (chain code (256 bits) || private key (256 bits)). Confusion arises in the length of the extended public key. In the book they say that it is 513 bits. How is it possible? Isn't it 520 bits (chain code (256 bits) || public key (264 bits = 0x02/0x03 || X coordinate))?

I found a similar question already asked (link), but the answer by `miketery` confused me a bit. He said the following:

The book says 512 or 513 bits because the extended private key is `256 chain code bits || 256 private key bits` (512), and the extended public key is `256 chain code bits || 1 evenness bit || 256 public key bits` (513).

Since computers storage works in bytes, the 1 bit for evenness is represented as a whole byte.

How can this be true when `evenness` is defined by setting 0x02 or 0x03 so it has to be more than just one bit (at least 2 bits). So it would make more sense to me, if not say 520 bits, then at least say 514 bits?

• `0x02` and `0x03` are only two values, so nothing prevents you from encoding them as `0x00` and `0x01` - single bit is sufficient. In practice you'll need a whole byte anyway just to store it somehow, unless you want to store a collection of such keys and can afford bit manipulation (e.g. 8 keys can be stored as three entities - array of 8 32-byte sequences, 1 byte with every bit encoding the parity of one key, and 8x32 again). Commented Apr 9, 2023 at 11:01