Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: bitcoinsarefun on March 26, 2012, 01:33:12 PM



Title: question about address generation
Post by: bitcoinsarefun on March 26, 2012, 01:33:12 PM
why it 0x04 appended to the public key before beginning other functions on it?


Title: Re: question about address generation
Post by: DeathAndTaxes on March 26, 2012, 01:49:07 PM
My understanding is it is to identify the underlying encryption protocol.  All keys today have the prefix 0x04 because they all use ECDSA (w/ secp256k1 curve).   It is possible for Bitcoin to support future algorithms (if ECDSA became compromised or degraded).  The 0x04 allows the client to "check" the algorithm being used.  If it finds a key w/ anything other than 0x04 it will fail but future clients could be extended.

You have to imagine if ECDSA was "partially compromised" existing keys will remain for a long time.  Having a encryption identifier would allow a client to handle both encryption methods at the same time.  Old clients would be ECDSA only and new clients would support the old & new algorithms.

If you mean why 0x04 not 0x03 or 0x99?  I don't think it has any specific meaning other than an identifier.


Title: Re: question about address generation
Post by: Pieter Wuille on March 26, 2012, 06:08:36 PM
There are several ways to serialize EC public keys, as specified by the SEC specification (http://www.secg.org/index.php?action=secg,docs_secg). A summary:
* 0x00: The point at infinity
* 0x02 + x_coord: Compressed representation of a point with an even y_coord
* 0x03 + x_coord: Compressed representation of a point with an odd y_coord
* 0x04 + x_coord + y_coord: Uncompressed representation of a point

Up to 0.5.x, bitcoin always used uncompressed EC points (=public keys). Starting with 0.6.0, compressed public keys will be used for new or upgraded wallets.


Title: Re: question about address generation
Post by: DeathAndTaxes on March 26, 2012, 06:31:32 PM
Thanks Pieter I learned something today (I knew it would be a good idea to get out of bed).


Title: Re: question about address generation
Post by: Red Emerald on March 26, 2012, 06:34:43 PM
There are several ways to serialize EC public keys, as specified by the SEC specification (http://www.secg.org/index.php?action=secg,docs_secg). A summary:
* 0x00: The point at infinity
* 0x02 + x_coord: Compressed representation of a point with an even y_coord
* 0x03 + x_coord: Compressed representation of a point with an odd y_coord
* 0x04 + x_coord + y_coord: Uncompressed representation of a point

Up to 0.5.x, bitcoin always used uncompressed EC points (=public keys). Starting with 0.6.0, compressed public keys will be used for new or upgraded wallets.
Thanks for this.  I was trying to figure out how bitcoin was doing compressed public keys just last night.