TeachMeBitcoin

The Even/Odd Y-Coordinate

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

The Even/Odd Y-Coordinate

In order to reconstruct the full public key from a compressed version, we need a "Tie-Breaker" to tell us which of the two possible Y-coordinates to use. This is the role of the 02 and 03 prefixes.

1. Symmetry of the Curve

The Elliptic Curve is symmetric across the X-axis. This means that if $(x, y)$ is a point on the curve, then $(x, -y)$ is also a point on the curve.

2. Choosing the Prefix

When a wallet compresses a public key, it looks at the Y-coordinate:

3. Reconstructing Y

When a node receives a transaction, it performs the following steps:

  1. Read the X-coordinate.

  2. Calculate $y^2 = x^3 + 7 \pmod p$.

  3. Calculate the Square Root of $y^2$. This gives two results ($y_1$ and $y_2$).

  4. Check the prefix:

    • If prefix is 02, pick the Even result.
    • If prefix is 03, pick the Odd result.

4. Why it matters for Addresses

Because the Public Key Hash (PKH) is a hash of the serialized public key, hashing 04... (uncompressed) results in a completely different hash than hashing 02... (compressed).

Parity Prefix Math Logic
Even 0x02 $y \pmod 2 == 0$
Odd 0x03 $y \pmod 2 == 1$

In the final section, we will build a Python Public Key Auditor.

☕ Help support TeachMeBitcoin

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:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!