1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-12-23 15:18:11 +00:00

A public key should be 520 bits / 65 bytes; reported by Issue #39

This commit is contained in:
Minh T. Nguyen 2014-06-05 23:04:48 -07:00 committed by Andreas M. Antonopoulos
parent a213cb0350
commit e2a9bb27be

View File

@ -320,7 +320,7 @@ x = F028892BAD...DC341A
y = 07CF33DA18...505BDB
----
Here's the same public key shown as a 512-bit number (130 hex digits) with the prefix +04+ followed by +x+ and then +y+ coordinates, as +04 x y+:
Here's the same public key shown as a 520-bit number (130 hex digits) with the prefix +04+ followed by +x+ and then +y+ coordinates, as +04 x y+:
.Uncompressed Public Key K shown in hex (130 hex digits) as +04xy+
----
@ -330,7 +330,7 @@ K = 04F028892BAD...505BDB
[[comp_pub]]
===== Compressed Public Keys
Compressed public keys were introduced to bitcoin to reduce the size of transactions and conserve disk space on nodes that store the bitcoin blockchain database. Most transactions include the public key, required to validate the owner's credentials and spend the bitcoin. Each public key requires 513 bits (prefix \+ x \+ y), which when multiplied by several hundred transactions per block, or tens of thousands of transactions per day, adds a significant amount of data to the blockchain.
Compressed public keys were introduced to bitcoin to reduce the size of transactions and conserve disk space on nodes that store the bitcoin blockchain database. Most transactions include the public key, required to validate the owner's credentials and spend the bitcoin. Each public key requires 520 bits (prefix \+ x \+ y), which when multiplied by several hundred transactions per block, or tens of thousands of transactions per day, adds a significant amount of data to the blockchain.
As we saw in the section <<pubkey>> above, a public key is a point (x,y) on an elliptic curve. Since the curve expresses a mathematical function, a point on the curve represents a solution to the equation and therefore if we know the x-coordinate we can calculate the y-coordinate by solving the equation y^2^ mod p = (x^3^ + 7) mod p. That allows us to store only the x-coordinate of the public key point, omitting the y-coordinate and reducing the size of the key and the space required to store it by 256 bits. A 50% reduction in size in every transaction adds up to a lot of data saved over time!
@ -342,7 +342,7 @@ image::images/pubkey_compression.png["pubkey_compression"]
Here's the same public key generated previously, shown as a +compressed public key+ stored in 264-bits (66 hex digits) with the prefix +03+ indicating the +y+ coordinate is odd:
.Compressed Public Key K shown in hex (66 hex digits) as +K = {02 or 03} x+
.Compressed Public Key K shown in hex (66 hex digits) as +K = {02 or 03} x+
----
K = 03F028892BAD...DC341A
----