Compressed vs. Uncompressed Public Keys
Compressed vs. Uncompressed Public Keys
On the blockchain, every byte costs money. To optimize transaction weights and lower mining fees, Bitcoin developers transitioned from using large uncompressed public keys to highly efficient compressed public keys.
Understanding compression requires looking at the algebraic symmetry of elliptic curves.
🔵 What is an Uncompressed Public Key?
A raw public key point $(K)$ on the secp256k1 curve consists of an $x$-coordinate and a $y$-coordinate. Both coordinates are 256-bit (32-byte) integers.
In early versions of Bitcoin, public keys were serialized and stored on the blockchain in their full, uncompressed format:
$$\text{Uncompressed Public Key} = \text{0x04} \parallel x \parallel y$$
0x04: A standard 1-byte prefix signaling that this is an uncompressed key.x: The 32-byte $x$-coordinate.y: The 32-byte $y$-coordinate.- Total Size: $1 + 32 + 32 = \mathbf{65 \text{ bytes}}$.
📐 The Mathematics of Compression
Because the elliptic curve equation is symmetric across the x-axis, we do not actually need to transmit the entire $y$-coordinate.
The secp256k1 curve is defined as:
$$y^2 = x^3 + 7 \pmod p$$
If we know the $x$-coordinate, we can solve for $y$ using a modular square root:
$$y = \pm \sqrt{x^3 + 7} \pmod p$$
In modular arithmetic over our prime field $p$, solving this equation yields exactly two values for $y$: 1. One coordinate is even ($y \pmod 2 = 0$). 2. One coordinate is odd ($y \pmod 2 \neq 0$).
Therefore, as long as we know the $x$-coordinate, we only need 1 bit of extra information (whether $y$ is even or odd) to reconstruct the exact coordinate of the $y$-point.
🟢 What is a Compressed Public Key?
A compressed public key stores only the $x$-coordinate and a single prefix byte representing the parity (evenness) of the $y$-coordinate:
$$\text{Compressed Public Key} = \text{Prefix} \parallel x$$
Where the prefix byte is:
* 0x02 if the $y$-coordinate is even.
* 0x03 if the $y$-coordinate is odd.
- Total Size: $1 + 32 = \mathbf{33 \text{ bytes}}$.
PUBLIC KEY BYTE OVERHEAD COMPARISON
┌────────────────────────────────────────────────────────┐
│ UNCOMPRESSED (65 Bytes) │
├─────┬────────────────────────────────┬─────────────────┤
│0x04 │ x (32 Bytes) │ y (32 Bytes) │
└─────┴────────────────────────────────┴─────────────────┘
▲
└── [Discarded in Compression]
┌──────────────────────────────────────┐
│ COMPRESSED (33 Bytes) │
├─────┬────────────────────────────────┤
│0x02 │ x (32 Bytes) │ (Reconstructs y algebraically)
└─────┴────────────────────────────────┘
📈 Real-World Performance Benefits
By transitioning to compressed public keys, the byte footprint of a public key is nearly cut in half:
$$\text{Data Savings} = 65 \text{ bytes} - 33 \text{ bytes} = \mathbf{32 \text{ bytes}}$$
- For Users: Because transaction fees are paid per byte of serialized data (sats/vB), compressing your public key directly reduces your transaction size, saving you money on every spend.
- For Nodes: Halving the size of public keys dramatically reduces the storage, bandwidth, and CPU validation overhead on full nodes, keeping the Bitcoin network scalable and decentralized.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: