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.
In this chapter
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
together with one extra point , “at infinity”. The condition rules out cusps and self-crossings. The curve is symmetric about the -axis. Points can be added: draw the line through and ; it meets the curve in exactly one more point ; reflect it across the -axis to get . To double a point, use the tangent. A vertical line meets the curve at infinity, so , where is the reflection of .
In coordinates, for and with , let be the slope of the line, , or for the tangent. Then
With this addition and as identity, the points of form an abelian group. The same formulas, computed in any field , make , the points with coordinates in , a group.
About the proof
Commutativity is clear (the line through and is the line through and ), 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 with its own Picard group.
Curves over a finite field
Cryptography needs exact, finite arithmetic, so the coordinates live in , the integers modulo a prime . The “curve” becomes a scatter of points with no visible shape, but the formulas, and the group, are the same.
The number of points of over (counting ) satisfies .
So a curve over a 256-bit prime field has about 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 discrete logarithm on a curve
Multiplying a point by a scalar, , is fast by double-and-add (the additive version of square-and-multiply). Undoing it is the elliptic-curve discrete logarithm problem (ECDLP): given and , find .
In a cyclic group of prime order , Pollard's rho algorithm finds discrete logarithms in about group operations and constant memory. Conversely, any algorithm that uses the group only through its operations (a generic algorithm) needs about of them.
Pollard's rho is the birthday paradox again: a pseudorandom walk on the group eventually repeats a point, and a repetition reveals . 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:
| Security | Symmetric | RSA / finite-field DH | Elliptic curve |
|---|---|---|---|
| 112 bits | 3DES | 2,048 bits | 224 bits |
| 128 bits | AES-128 | 3,072 bits | 256 bits |
| 192 bits | AES-192 | 7,680 bits | 384 bits |
| 256 bits | AES-256 | 15,360 bits | 512 bits |
ECDH and X25519
Elliptic-curve Diffie–Hellman is the protocol of chapter 08 with the new group: Alice sends , Bob sends , both compute . In 2006 Daniel J. Bernstein published Curve25519, the curve over the prime , 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 of a message with the private key (public key ) on a curve whose base point has prime order :
- choose a random nonce and let ;
- let ; the signature is .
The verifier computes , and accepts if . ECDSA over the NIST curve P-256 signs most TLS certificates, passkeys and bank cards. Its weak point is the nonce.
If two messages with hashes are signed with the same nonce (visible because is the same), then
Proof
and . Subtracting, , which gives ; then the first equation gives . Even a few biased bits of across many signatures are enough to recover with lattice techniques.
In 2010 the fail0verflow group showed that Sony signed PlayStation 3 software with the same 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 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
- Neal Koblitz, “Elliptic Curve Cryptosystems”, Mathematics of Computation 48, 1987; Victor Miller, “Use of Elliptic Curves in Cryptography”, CRYPTO 1985.
- Joseph Silverman and John Tate, Rational Points on Elliptic Curves (1992; 2nd ed. 2015).
- Daniel J. Bernstein, “Curve25519: new Diffie-Hellman speed records”, PKC 2006; Bernstein et al., “High-speed high-security signatures”, CHES 2011.
- fail0verflow, “Console Hacking 2010: PS3 Epic Fail”, 27th Chaos Communication Congress.