Point Compression (Elliptic Curve X-Coordinate + Parity Bit)
- •
What it is
- •
For any valid -coordinate on a curve , there are at most two valid values — and (since ) — so transmitting a full point sends one redundant bit of information: given alone, a receiver can recover up to that two-way ambiguity, and only needs one extra bit (which of the two roots) to pin it down exactly. This "point compression" roughly halves the data needed to transmit a public key. When , recovering a square root of is especially cheap (the same Tonelli-Shanks shortcut used elsewhere: ), no general square-root algorithm needed.
- •
- •
When to apply
- •
A protocol only sends an -coordinate (plus, optionally, a sign/parity bit) instead of a full pair — recover the missing via a modular square root before proceeding with any point arithmetic.
- •
- •
Symbols and assumptions
- •
For with odd prime , a compressed non-infinite point records plus one bit selecting a square root .
- •
- •
Math — step by step
- •
- Compute . A point with that x-coordinate exists only if is a quadratic residue or zero.
- •
- Find a root using the applicable modular square-root algorithm. The possible roots are and ; for nonzero , one is even and the other odd because is odd.
- •
- Pick the root whose integer representative in matches the encoded parity. Verify curve membership and protocol-specific validity after decoding. At there is only the root 0.
- •
- •
- •
Python
- •
def lift_x(x, a, b, p): rhs = (x**3 + a*x + b) % p y = pow(rhs, (p + 1) // 4, p) # valid when p % 4 == 3 assert (y * y) % p == rhs return y, p - y
- •
- •
SageMath
- •
E = EllipticCurve(GF(p), [a, b]) P = E.lift_x(GF(p)(x)) # picks one of the two valid y values automatically
- •
- •
- •
Cards
- •
Why does sending only an x-coordinate (plus one bit) fully specify a curve point?
- •
Any valid x has at most two matching y values (y and p−y), so a single extra bit disambiguates between them completely.
- •
- •
Why doesn't it matter, for a Diffie-Hellman-style shared secret, which of the two y roots gets chosen?
- •
Because only the x-coordinate of the final shared point is used to derive the key, and that x-coordinate comes out identical regardless of which y value was used in the intermediate scalar multiplication.
- •
- •