Elliptic curve cryptography runs the same key exchange as Diffie-Hellman, but it replaces multiplication on a clock with a rule for adding points on a curve, and the result is a much smaller key for the same protection. This page needs only basic algebra and builds the idea in steps: the curve, adding two points, adding a point to itself, and then a key exchange with numbers you can check.
What we are trying to build
The clock exchange works because repeating an operation b times and then a times gives the same result as a times and then b times. A curve offers another operation that can be repeated, so the exchange keeps all its steps: a public starting point, two secret numbers, a swap and a shared result.
An elliptic curve
An elliptic curve is the set of points (x, y) that satisfy an equation of the form y2 = x3 + ax + b. The curve itself is not an ellipse; the name comes from older mathematics about ellipses. Take y2 = x3 − 3x + 5 as an example. At x = 2 it gives y2 = 8 − 6 + 5 = 7, so the points (2, 2.65) and (2, −2.65) lie on the curve.
The form is strict. The curve must not have a sharp point or a place where it crosses itself, which holds whenever 4a3 + 27b2 is not zero. Because y is squared, the curve is a mirror image across the horizontal axis, and the next steps rely on that. An equation such as y = x3 + 126 does not qualify.
Adding two points
We need a rule that turns two points on the curve into a third. It is a recipe and not arithmetic on the coordinates:
- Draw the straight line through P and Q.
- Find the one other point where that line meets the curve.
- Reflect that point across the horizontal axis. The result is called P + Q.
The name fits because the rule behaves like addition. Swapping P and Q gives the same line, so P + Q = Q + P, and it does not matter which pair you add first. The x-values are not added, though: with P at x = −1.4 and Q at x = 1.2, the result lands at x = 2.95, because the line decides where it goes.
The point at infinity
If Q is the mirror image of P, the line through them is vertical and never meets the curve a third time. To cover this case, mathematicians add one extra point called O, or the point at infinity, and define P + Q = O. It works like zero, since adding it to any point leaves that point unchanged, and mirror images act as negatives of each other.
Adding a point to itself
Repeated adding begins with adding a point to itself, because a × G means G added to itself a times. There is no second point to draw a line through, so the recipe uses the tangent line at P instead. At P = (−1, 2.65) the tangent is flat, it meets the curve again at (2, 2.65), and reflecting that point gives 2P = (2, −2.65). Adding P once more gives 3P = (2.11, 2.84), and continuing gives 4P, 5P and so on. The notation k × P means P added to itself k times.
The same key exchange, on a curve
Take a point G that everyone knows. Let Alice pick a = 3 and Bob pick b = 2. Each adds G to itself that many times and sends the result, then adds the point they received to itself their own number of times. Each has now added G a total of 3 × 2 = 6 times, so both reach 6 × G.
| Step | Clock version | Curve version |
|---|---|---|
| Public start | prime p and base g | curve and point G |
| Alice sends | ga mod p | a × G |
| Bob sends | gb mod p | b × G |
| Shared secret | gab mod p | (ab) × G |
Moving to whole numbers
The curve above uses real numbers such as 2.65, which a computer cannot store exactly, and tiny rounding errors would stop Alice's and Bob's points from matching. So cryptography keeps the same idea with whole numbers only. Every calculation is done mod a prime, which has about 77 digits in real systems, so after each step only the remainder is kept. The same formulas still work, and the points become a scattered cloud instead of a smooth curve.
A worked example mod 97
To follow every number, use the curve y2 = x3 + 2x + 3 with everything taken mod 97, and the starting point G = (0, 10). It lies on the curve because 102 = 100 and 100 mod 97 = 3, which equals 03 + 2 × 0 + 3. The multiples 2G = (65, 32) and 3G = (23, 24) already jump around with no visible pattern.
key exchange on the mod-97 curve
- Alice picks the secret a = 13 and publishes A = 13 × G = (87, 70).
- Bob picks the secret b = 29 and publishes B = 29 × G = (47, 18).
- Alice computes 13 × B and Bob computes 29 × A, and both land on the same point, (49, 63).
Mallory sees G, A and B. On this tiny curve she finds a = 13 after 13 tries. On a real curve the same search would never finish.
Fast forwards, hopeless backwards
To get 13 × G you do not have to add G twelve times. Double it to get 2G, 4G and 8G, then add 8G + 4G + G, so a 256-bit number needs only about 256 doublings. Going back from 13 × G to 13 has no known method much faster than searching through the multiples. Finding the number is called the elliptic-curve discrete logarithm problem, and it is the curve version of the discrete logarithm from the clock exchange.
X25519 and 32-byte key shares
X25519 is the exchange browsers use in TLS 1.3. It is computed modulo the prime 2255 − 19, which is where the 25519 in the name comes from, on a curve usually written in a different but equivalent form of the equation. Its starting point G has about 2252 multiples, so a search through them never finishes, and each key share is just 32 bytes.
Nobody has found a shortcut for a good curve, so a 256-bit key already needs about 2128 steps to break. The clock version needs a 3,072-bit key to reach the same 128 bits of protection, so the curve gives the same protection in keys twelve times smaller and with much faster arithmetic. It is the same protection, not a stronger promise.
Signatures and the quantum caveat
Curves are also used for signatures, where the scheme is called ECDSA. A quantum computer running Shor's algorithm can solve the elliptic-curve discrete logarithm just as it can the clock version, so this whole family would fall to a large enough machine. The post-quantum page explains what replaces it.