Elliptic curves, hands on

An elliptic curve is the set of points satisfying y² = x³ + ax + b. Its points can be added to each other, and repeating that addition is easy to do but practically impossible to undo. That one-way step protects HTTPS, Bitcoin, Signal and SSH.

Small keysFast & low powerUsed everywhereStrong security per bit

1 · Adding points on the curve

To add P and Q: draw the line through them, find where it hits the curve a third time, then flip that point over the x-axis. The flipped point is P + Q. To double a point (P + P), use the tangent line at P. Click on the curve to move P and Q.

2 · The same curve over a finite field

Cryptography uses whole numbers modulo a prime p instead of real numbers. The smooth curve becomes a scatter of dots, but the addition formulas stay exactly the same, just done mod p. Click any dot to make it the base point G, then slide k to watch k·G jump around.

Notice how G, 2G, 3G, … land in no visible pattern. Knowing the result k·G gives no clue about k. That is the whole security idea.

3 · Key exchange (ECDH)

Alice and Bob agree on the curve and G in public. Each picks a secret number, multiplies G by it, and sends the result. Each then multiplies the other's point by their own secret, and both land on the same point. Eve sees everything sent but not the secrets.

Alice sends A = α·G
Public. Anyone can see it.
Bob sends B = β·G
Public. Anyone can see it.
Alice computes α·B
Uses her secret α =
Bob computes β·A
Uses his secret β =
Show how A = α·G is computed (double-and-add)

Adding G to itself α times would be slow for huge α. Instead, write α in binary and keep doubling G, adding in the doublings where the bit is 1. Even a 256-bit secret takes only about 256 doublings.

4 · Be the attacker

Eve knows the curve, G, A and B. To find the shared secret she must recover α from A = α·G. This is the elliptic-curve discrete logarithm problem. On this toy curve she can simply try every k.