1

My understanding is that the public key can start with 04 if it's uncompressed, or 02 or 03 if it's compressed.

What's the purpose of this?

It appears that you'd have greater entropy if it's uncompressed.

And if this is indeed the case, why would you want a compressed public key?

Wouldn't it be safer to use the larger one?

3

My understanding is that the public key can start with 04 if it's uncompressed, or 02(x-coor) or 03(y-coor) if it's compressed.

That's not exactly right. There are two encodings:

  • Uncompressed encoding: (0x04, X coordinate, Y coordinate)
  • Compressed encoding:
    • (0x02, X coordinate) if Y is even
    • (0x03, X coordinate) if Y is odd

What's the purpose of this?

And if this is indeed the case, why would you want a compressed public key?

If you're asking about intent, you need to be aware that these standards for encoding aren't specific to Bitcoin. They're defined by SEC1, and adopted by many other systems. Presumably their goal for having both is:

  • Compressed encoding is smaller, and thus desirable when space/bandwidth considerations matter more.
  • Uncompressed encoding is slightly more efficient to work with, so if space/bandwidth isn't a concern it's faster to choose this.

If Bitcoin was designed today, it would probably only have compressed keys.

Greater entropy as we can have a larger public key if it's uncompressed?

Wouldn't it be safer to use the larger one?

No, there is a one-to-one conversion between compressed and uncompressed keys, in both direction. There is no difference in entropy (both have 256 bits of entropy) and thus equally secure.

8
  • There's five encodings if you want to parse all of the ones in the Bitcoin blockchain, though I guess that's not valid to be used today. – Anonymous Apr 5 at 17:50
  • 1
    You mean the hybrid encoding? Yeah, that exists too. Its reason for existence is a pure mystery to me (it has the disadvantages of both...). – Pieter Wuille Apr 5 at 17:53
  • That's the one, I'd forgotten the name, 0x05 and 0x06. I would love to be able to find the any justification for its existence, surely someone somewhere had a use-case, surely. – Anonymous Apr 5 at 17:55
  • 1
    There is no 0x05 as far as I know. The idea I think is that the top 7 bits encode the mechanism (0 = infinity, 1 = compressed, 2 = uncompressed, 3 = hybrid), and the bottom bit encodes Y's parity (but only for compressed and hybrid modes where it matters). – Pieter Wuille Apr 5 at 19:58
  • 1
    Yes, though "times" isn't your normal multiplication here. It's the number of times the elliptic curve group operation is applied to the generator point ("adding" it to itself). – Pieter Wuille Apr 6 at 3:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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