1. Substitution
  2. Enigma
  3. Shannon
  4. DES & AES
  5. Modes
  6. Hashes
  7. Passwords
  8. RSA & DH
  9. ECC
  10. Post-quantum

Chapter 09 · Elliptic curves

The arithmetic of curves: ECDH, ECDSA, Ed25519

Points on a cubic curve can be added with a ruler: draw the line, find the third point, reflect it. Over a finite field this geometry becomes a group in which logarithms are even harder than in RSA's numbers, so a 256-bit key does the work of a 3,072-bit one. It is the cryptography inside every phone, passkey and TLS connection today.

Diffie–Hellman and RSA need numbers of thousands of bits, because sub-exponential algorithms (the number field sieve and its cousins for discrete logarithms) attack the multiplicative structure of the integers. In 1985 Neal Koblitz and Victor Miller, independently, proposed doing the same cryptography in a different group, where no such shortcut was known: the points of an elliptic curve over a finite field. Forty years later there is still none, and elliptic-curve cryptography (ECC) has replaced RSA almost everywhere.

Adding points with a ruler

An elliptic curve, in the form cryptographers use, is the set of solutions of

E:y2=x3+ax+b,4a3+27b2≠0,

together with one extra point 𝒪, “at infinity”. The condition rules out cusps and self-crossings. The curve is symmetric about the x-axis. Points can be added: draw the line through P and Q; it meets the curve in exactly one more point R′; reflect it across the x-axis to get P+Q. To double a point, use the tangent. A vertical line meets the curve at infinity, so P+(−P)=𝒪, where −P is the reflection of P.

The chord-and-tangent law over the real numbers. Change the curve with a and b and move P and Q along it. The line through them cuts the curve at a third point −(P+Q); its reflection is P+Q. When P=Q the line is the tangent. With a=−2 and b small, the curve splits into two pieces, and the law still works.

In coordinates, for P=(x1,y1) and Q=(x2,y2) with P≠−Q, let λ be the slope of the line, λ=(y2−y1)/(x2−x1), or λ=(3x12+a)/(2y1) for the tangent. Then

x3=λ2−x1−x2,y3=λ(x1−x3)−y1.
Theorem (the group law)

With this addition and 𝒪 as identity, the points of E form an abelian group. The same formulas, computed in any field K, make E(K), the points with coordinates in K, a group.

About the proof

Commutativity is clear (the line through P and Q is the line through Q and P), the identity and inverses come from vertical lines, and closure from the fact that a line meets a cubic in three points counted with multiplicity. Associativity is the hard part: it can be checked by brute-force algebra on the formulas, or proved elegantly with the Cayley–Bacharach theorem on cubics through eight common points, or via the Riemann–Roch theorem, which identifies E with its own Picard group.

Curves over a finite field

Cryptography needs exact, finite arithmetic, so the coordinates live in 𝔽p, the integers modulo a prime p. The “curve” becomes a scatter of points with no visible shape, but the formulas, and the group, are the same.

Theorem (Hasse, 1933)

The number of points of E over 𝔽p (counting 𝒪) satisfies |#E(𝔽p)−(p+1)|≤2p.

So a curve over a 256-bit prime field has about 2256 points; Schoof's algorithm (1985) counts them exactly, and curves are chosen whose number of points is a large prime (or a small multiple of one), so that the group is cyclic and has no small subgroups to hide in.

The curve y2=x3+2x+3 over 𝔽97: every point of it, and the multiples G,2G,3G,… of a generator G. Press play: the multiples jump around the grid with no pattern you could follow backwards. Given only the final point, recovering k is the elliptic-curve discrete logarithm problem. Here a computer finds it instantly by trying all k; with 256-bit numbers, no computer can.

The discrete logarithm on a curve

Multiplying a point by a scalar, kP=P+P+…+P, is fast by double-and-add (the additive version of square-and-multiply). Undoing it is the elliptic-curve discrete logarithm problem (ECDLP): given P and Q=kP, find k.

Theorem (generic algorithms, Pollard 1978; Shoup 1997)

In a cyclic group of prime order n, Pollard's rho algorithm finds discrete logarithms in about πn/2 group operations and constant memory. Conversely, any algorithm that uses the group only through its operations (a generic algorithm) needs about n of them.

Pollard's rho is the birthday paradox again: a pseudorandom walk on the group eventually repeats a point, and a repetition reveals k. For good elliptic curves, nothing better than these generic attacks is known. So security grows with half the bit size of the group order, and the keys are short:

SecuritySymmetricRSA / finite-field DHElliptic curve
112 bits3DES2,048 bits224 bits
128 bitsAES-1283,072 bits256 bits
192 bitsAES-1927,680 bits384 bits
256 bitsAES-25615,360 bits512 bits

ECDH and X25519

Elliptic-curve Diffie–Hellman is the protocol of chapter 08 with the new group: Alice sends aG, Bob sends bG, both compute abG. In 2006 Daniel J. Bernstein published Curve25519, the curve y2=x3+486662x2+x over the prime 2255−19, designed so that the fast, simple implementation is also the safe one: every 32-byte string is a valid public key, the computation (the Montgomery ladder) runs in constant time, and there are no special cases to forget. Its key agreement, X25519, is now the default of TLS 1.3, SSH, Signal and WireGuard. The desktop app's “X25519 + AES-GCM” makes a fresh ephemeral key pair for every message, agrees a secret with the recipient's public key and encrypts with AES-GCM: the ECIES pattern.

ECDSA and the nonce

The Elliptic Curve Digital Signature Algorithm, proposed by Scott Vanstone in 1992 and standardised by ANSI (1999) and NIST (2000), signs the hash h of a message with the private key d (public key Q=dG) on a curve whose base point G has prime order n:

  1. choose a random nonce k∈[1,n−1] and let r=(kG)xmodn;
  2. let s=k−1(h+rd)modn; the signature is (r,s).

The verifier computes u1=hs−1, u2=rs−1 and accepts if (u1G+u2Q)x≡r. ECDSA over the NIST curve P-256 signs most TLS certificates, passkeys and bank cards. Its weak point is the nonce.

Proposition (a reused nonce leaks the key)

If two messages with hashes h1≠h2 are signed with the same nonce k (visible because r is the same), then

k=h1−h2s1−s2modn,d=s1k−h1rmodn.
Proof

s1k=h1+rd and s2k=h2+rd. Subtracting, (s1−s2)k=h1−h2, which gives k; then the first equation gives d. Even a few biased bits of k across many signatures are enough to recover d with lattice techniques.

In 2010 the fail0verflow group showed that Sony signed PlayStation 3 software with the same k every time, recovered Sony's private key, and could sign anything. In 2013 a bug in Android's random number generator made Bitcoin wallets reuse nonces, and their coins were stolen. The fix is to never draw k at random: derive it from the key and the message (RFC 6979, 2013).

Ed25519

Bernstein, Niels Duif, Tanja Lange, Peter Schwabe and Bo-Yin Yang designed Ed25519 (2011) on an Edwards-form version of Curve25519, with complete addition formulas (no exceptional cases) and a nonce derived deterministically from a hash of the private key and the message. It is fast, its keys are 32 bytes and its signatures 64, and there is no random nonce to get wrong. SSH, Signal, Tor, Git and the Linux kernel's module signing use it; RFC 8032 (2017) and FIPS 186-5 (2023) standardise it.

Which curves to trust

The NIST curves P-256 and P-384 were generated in 1999 from seeds that were never explained. In 2013 the Snowden documents confirmed that the NSA had backdoored Dual_EC_DRBG, an elliptic-curve random number generator standardised by NIST in 2006: whoever knew the secret relation between its two points could predict its output. No weakness has been found in P-256 itself, but the episode made “rigid”, explainable parameters, like Curve25519's, a design requirement (Bernstein and Lange's SafeCurves project). The desktop app offers both families: ECDSA P-256 for compatibility, Ed25519 and X25519 as first choices. All of them, like RSA, fall to Shor's algorithm.

Further reading

  1. Neal Koblitz, “Elliptic Curve Cryptosystems”, Mathematics of Computation 48, 1987; Victor Miller, “Use of Elliptic Curves in Cryptography”, CRYPTO 1985.
  2. Joseph Silverman and John Tate, Rational Points on Elliptic Curves (1992; 2nd ed. 2015).
  3. Daniel J. Bernstein, “Curve25519: new Diffie-Hellman speed records”, PKC 2006; Bernstein et al., “High-speed high-security signatures”, CHES 2011.
  4. fail0verflow, “Console Hacking 2010: PS3 Epic Fail”, 27th Chaos Communication Congress.