1. What a key promises
Draft
Two jobs, six functions
A browser and a server that have never met must end up holding the same secret number, even though every byte they exchange can be read along the way. At the same time, the server must prove to a stranger that it is who it claims to be, without handing over anything the stranger could reuse to impersonate it. Those are the two jobs of public-key cryptography: agreeing on a key, and signing. Both rely on a pair of keys, one published and one kept secret, built around a single promise: publishing the public key does not give away the private one. Behind that promise stands, in every scheme of this series, a mathematical operation that is cheap to run forward and, as far as anyone knows, prohibitively expensive to invert unless you hold the private key.
Modern standards package each job as an interface of three functions:
key-encapsulation mechanism (KEM)
keygen() -> (ek, dk) encapsulation key, decapsulation key
encapsulate(ek) -> (c, K) ciphertext, shared secret
decapsulate(dk, c) -> K the same shared secret
signature scheme
keygen() -> (pk, sk) public key, private key
sign(sk, m) -> s signature of the message m
verify(pk, m, s) -> accept or reject
The first interface is a key-encapsulation mechanism, or KEM. Its encapsulation key is the public key of the pair and its decapsulation key is the private one.FIPS 203, the United States federal standard that specifies ML-KEM (Section 6), introduces the terms encapsulation key and decapsulation key; this series uses them for every mechanism. Anyone holding the encapsulation key ek can call encapsulate, which draws fresh random bits and outputs a shared secret \(K\) together with a ciphertext \(c\) that carries \(K\) to the holder of dk and looks useless to everyone else. The owner calls decapsulate(dk, c) and recovers the exact same \(K\). Notice that encapsulate takes no plaintext message as input: public-key arithmetic is too bulky for streaming data, so the mechanism's sole job is to generate and deliver a fresh random key. Once both sides hold \(K\), they feed it into a fast symmetric cipher such as AES, where the same key encrypts and decrypts, and the public-key work is done. The handshake at the top of the introduction executes these three calls using ML-KEM (Kyber), the lattice mechanism of Section 6.
A signature scheme reverses the order of play so that the private key acts first. Only its holder can call sign(sk, m), while anyone holding pk can call verify(pk, m, s), which accepts only if s was produced for that exact message m with the matching private key. A secure connection needs both interfaces together, because agreeing on a secret says nothing about who stands at the far end of the wire: without authentication, an active eavesdropper could sit in the middle and agree on separate keys with each side. To bind the key to an identity, the server signs its half of the exchange, and further signatures inside digital certificates vouch for the server's public key (Section 11).
Two interfaces, three functions eachtwo ladders, read down: who runs each function, and with which key
KEY ENCAPSULATION
keygen the owner · Makes the pair: an encapsulation key to publish and a decapsulation key to keep.
encapsulate anyone, with the encapsulation key · Draws a fresh shared secret and a ciphertext that carries it to the owner of the key. No message goes in.
decapsulate the owner, with the decapsulation key · Opens the ciphertext and holds the same shared secret.
SIGNATURE
keygen the owner · Makes the pair: a public key to publish and a private key to keep.
sign the owner, with the private key · Makes a signature for one message. Here the private key acts first.
verify anyone, with the public key · Accepts a message and a signature only if the signature was made for exactly that message with the matching private key.
green: the one function of each interface that needs the private key
Later Sections fill in these six functions with concrete problems: Diffie-Hellman key agreement and the RSA trapdoor in Sections 1.3 and 1.4, ML-KEM in Section 6, the lattice signature ML-DSA (Dilithium) in Section 7, and the hash-based signature SLH-DSA (SPHINCS+) in Section 8. What changes from one scheme to the next is the asymmetric problem inside: which direction is cheap, which direction is hard, and what private knowledge makes the hard direction cheap for its holder.
Both jobs, and the promise, stand in the opening lines of a 1978 paper whose method is the subject of Section 1.4:
An encryption method is presented with the novel property that publicly revealing an encryption key does not thereby reveal the corresponding decryption key. This has two important consequences: 1. Couriers or other secure means are not needed to transmit keys, since a message can be enciphered using an encryption key publicly revealed by the intended recipient. Only he can decipher the message, since only he knows the corresponding decryption key. 2. A message can be “signed” using a privately held decryption key. Anyone can verify this signature using the corresponding publicly revealed encryption key. Signatures cannot be forged, and a signer cannot later deny the validity of his signature. This has obvious applications in “electronic mail” and “electronic funds transfer” systems.
—R. L. Rivest, A. Shamir and L. Adleman, "A method for obtaining digital signatures and public-key cryptosystems" (1978).Communications of the ACM 21(2), pp. 120 to 126. The passage is the opening of the abstract, quoted from the authors' copy of the paper; the abstract goes on to describe the method.
Easy one way, hard the other
Take a clock with a prime number \(p\) of hours and pick an hour \(g\). Multiplying by \(g\) on this clock means multiplying as usual and keeping only the remainder after division by \(p\); repeat that step \(x\) times starting from \(1\), and the hand lands on \(g^x \bmod p\). Over ordinary numbers, \(g^x\) grows smoothly with \(x\), so recovering \(x\) from \(g^x\) is an easy logarithm. Wrapping around a prime clock scrambles that order: each remainder discards how many full revolutions the hand has made, scattering consecutive powers across the dial. Going forward to \(g^x \bmod p\) stays cheap even when \(x\) has hundreds of digits, because each squaring doubles the exponent reached so far, making the work grow only with the number of bits of \(x\). Going backward from the final hour to the exponent \(x\) that produced it turns into a search.
clock 23 hours, g = 5, x = 13
forward: 5^13 mod 23 by square-and-multiply, a line to a bit of 13 = 1101
1 5
1 5^2 -> 2, x5 -> 10
0 10^2 -> 8
1 8^2 -> 18, x5 -> 21 5 multiplications: 5^13 = 21
back: which x gives 21? (baby-step giant-step)
stored 5^0 .. 5^4: 1, 5, 2, 10, 4
tried, dividing by 5^5 each time: 21 -> 16 -> 10, and 10 = 5^3 is stored
x = 2 x 5 + 3 = 13 5 stored + 3 tried = 8 steps
chart both counts against the size of p, logarithmic scales
forward about 1.5 log2 p multiplications the search about 1.5 sqrt p steps
a prime of 40 bits, both counted in the page: 55 multiplications; 1,518,899 steps
255 bits, the prime 2^255 - 19: 384 multiplications, a fraction of a millisecond
the search in the group X25519 uses over it: about 2^126 steps, not run
(the live figure needs JavaScript; it loads no data)
On a clock of 23 hours the two directions cost nearly the same: five multiplications forward against eight search steps back. At 40 bits the gap widens to 55 multiplications against a million and a half search steps, where the browser stops searching. At production key sizes, the forward path takes 384 multiplications, a fraction of a millisecond in the page, while the corresponding search in the elliptic-curve group used by real key agreement takes roughly \(2^{126}\) steps, which nobody has run.
The forward shortcut, square-and-multiply, reads the binary bits of \(x\) from top to bottom. Each bit after the leading 1 squares the running value modulo \(m\), doubling its exponent in one step, and whenever that bit is 1 an extra multiplication by \(g\) adds one to the exponent. To reach \(g^{13}\) (binary 1101), the algorithm starts at \(g^1\), squares and multiplies to reach \(g^3\), squares to \(g^6\), and squares and multiplies once more to land on \(g^{13}\) in five multiplications rather than twelve, using at most \(2 \log_2 x\) multiplications in general. Here is the loop that computes \(g^x \bmod m\) in the page and records each hop as a chord on the clock:
for (var i = 0; i < bits.length; i++) {
var bit = bits.charCodeAt(i) - 48;
if (i > 0) { // square: the exponent read so far doubles
var before = x; x = (x * x) % m; squarings++;
if (steps) steps.push({ bit: i, op: 'square', before: before, after: x });
}
if (bit === 1) { // multiply: the exponent read so far gains one
var was = x; x = i === 0 ? base : (x * base) % m;
if (i > 0) multiplications++;
if (steps) steps.push({ bit: i, op: 'multiply', before: was, after: x });
}
}
Going backward from a target hour \(y = g^x \bmod p\) has no bit-by-bit shortcut, because nothing in the remainder \(y\) reveals whether \(x\) is even or odd. On the clock, the figure searches for \(x\) using baby-step giant-step, the simplest method that beats checking every exponent one by one: write \(x = qm + r\) with stride \(m \approx \sqrt{p}\), store a lookup table of the first \(m\) "baby steps" \(g^0, g^1, \dots, g^{m-1}\), and then step backward from \(y\) by "giant steps" of \(g^{-m}\) until the walk hits a stored value, revealing \(q\) and \(r\) at once. That trade-off takes roughly \(\sqrt{p}\) multiplications and \(\sqrt{p}\) entries of memory. Adding one bit to \(p\) adds only a multiplication or two to the way forward, whereas every two extra bits double the work of the search.Diffie and Hellman's own example in 1976 was a prime of 200 bits: at most 400 multiplications forward against about \(2^{100}\) operations back, by the best algorithm they knew, which was of this square-root kind.
Diffie and Hellman isolated that computational lopsidedness in 1976 as the foundation of public-key cryptography.
Definition 1.2.1 (one-way function; Diffie and Hellman, 1976). A function \(f\) is one-way if \(f(x)\) is easy to compute for every argument \(x\), while for almost every value \(y\) in its range it is computationally infeasible to find any \(x\) with \(f(x) = y\).
Their paper describes the reverse direction as making it "computationally infeasible to solve the equation y = f(x) for any suitable argument x",W. Diffie and M. E. Hellman, "New directions in cryptography", IEEE Transactions on Information Theory IT-22(6), 1976, pp. 644 to 654 (the paper); the definition stands on p. 650, in the section on one-way authentication. distinguishing computational hardness from ordinary mathematical non-invertibility where several inputs collapse onto one output. Nothing collapses on the prime clock. Choose \(g\) to be a primitive root modulo \(p\), an hour whose powers \(g^0, g^1, \dots, g^{p-2}\) visit every nonzero hour \(1, \dots, p - 1\) exactly once, as \(5\) does modulo \(23\). Every nonzero hour then has a unique exponent below \(p - 1\); recovering that exponent in a finite group is the discrete counterpart of taking an ordinary base-\(g\) logarithm.
Definition 1.2.2 (the discrete logarithm problem). Let \(g\) generate a finite cyclic group of \(N\) elements, written multiplicatively. Given \(g\) and \(y = g^x\), find \(x \in \{0, \dots, N - 1\}\). On the clock, the group is the set of hours \(1, \dots, p - 1\) under multiplication modulo \(p\), \(N = p - 1\) and \(g\) is a primitive root.
Calling modular exponentiation one-way immediately raises the question of whether anyone has proved that no fast discrete-logarithm algorithm exists.
Remark 1.2.3 (hard means that nobody knows how). Showing that a function is easy forward is constructive: exhibit the algorithm and count its steps. Showing that the reverse direction is infeasible is a claim about every conceivable algorithm, including ones nobody has thought of, and no function has ever been proved one-way unconditionally; proving one would settle, in passing, whether \(\text{P}\) equals \(\text{NP}\). Every hardness claim in this series therefore takes a narrower empirical form: the fastest published method costs this much work, and decades of cryptanalysis have failed to find a faster one. Section 10 examines how far that kind of evidence carries.
Two caveats qualify the \(2^{126}\)-step figure on the chart. First, that count applies to X25519 (Section 1.3), which works not on the multiplicative clock modulo \(2^{255} - 19\) itself, but in an elliptic-curve group over that prime containing roughly \(2^{252}\) points (Section 1.5). Second, on an ordinary prime clock, generic search is far from the best classical attack. Clock hours are ordinary integers that factor into small primes, and sieve methods built on prime factorization compute logarithms modulo a prime much faster than \(\sqrt{p}\) steps; a discrete logarithm modulo a 795-bit prime was computed in 2019 (Section 1.6). The \(\sqrt{N}\) bound governs groups without extra arithmetic shortcuts, whereas Diffie-Hellman on a prime clock must use primes of 2,048 bits or more.
A shared secret over an open wire
A one-way function becomes a key agreement as soon as two secret operations commute, giving the same result regardless of which party goes first. Modular exponentiation has that property because \((g^a)^b = g^{ab} = (g^b)^a\). Each side picks a private exponent and sends the resulting power of \(g\) across the wire; each then raises what it received to its own private exponent. Both arrive at the exact same clock hour, and that hour never crossed the wire.
lanes you the wire the server an eavesdropper has seen
known to all: p = 23, g = 5 p = 23, g = 5
private a = 6, kept
private b = 15, kept
A = 5^6 mod 23 ------------ 8 ------------> A = 8
<----------- 19 ------------ B = 5^15 mod 23 B = 19
shared: 19^6 mod 23 = 2 shared: 8^15 mod 23 = 2
both are 5^90 mod 23 = 2: the wire carried 8 and 19, never 6, 15 or 2
from the wire alone no way is known but to find a from 8 = 5^a: a search, 7 steps on this clock
X25519 the same with the real function on 32-byte values (the example of RFC 7748, Section 6.1)
A = X25519(a, 9) = 85 20 f0 09 ... B = X25519(b, 9) = de 9e db 7d ...
X25519(a, B) = X25519(b, A) = 4a 5d 9d 5b ...: 4 calls; that search here: about 2^126 steps, not run
(the live figure needs JavaScript; it loads no data)
You hold 2 and the server holds 2, even though the wire carried only 8 and 19. An eavesdropper trying to recover 2 has, as far as anyone knows, no better route than solving a discrete logarithm (Definition 1.2.2) to find one of the private exponents. On a 23-hour clock the search of Section 1.2 finds it in seven steps, so the toy modulus shows the mechanism with none of the safety. With X25519 the same four operations finish in a few milliseconds in the browser on 32-byte values, while the corresponding search costs the \(2^{126}\) steps of Section 1.2.
With the prime \(p\) and base \(g\) public, your private exponent \(a\) and the server's private exponent \(b\) determine two public shares \(A\) and \(B\) and a common secret \(K\):
\[A = g^{a} \bmod p, \qquad B = g^{b} \bmod p, \qquad K = B^{a} \bmod p = A^{b} \bmod p = g^{ab} \bmod p. \tag{1.1}\]In the page's code, the exchange is four calls to the modular-exponentiation loop powMod from Section 1.2, naming the two sides Alice and Bob as in the literature and recording each hop for the drawing:
var A = powMod(g, a, p, tA); // Alice sends A = g^a
var B = powMod(g, b, p, tB); // Bob sends B = g^b
var aliceShared = powMod(B, a, p, tSA); // Alice computes B^a = g^(ab)
var bobShared = powMod(A, b, p, tSB); // Bob computes A^b = g^(ab)
Strictly speaking, an eavesdropper does not need \(a\) or \(b\) itself, only \(g^{ab} \bmod p\) computed from \(g^a \bmod p\) and \(g^b \bmod p\). Diffie and Hellman's 1976 paper was exact about the distinction: "if logs mod q are easily computed the system can be broken", whereas for the reverse direction, "we do not currently have a proof of the converse".Diffie and Hellman (1976), p. 649, in the section on public-key cryptography; their \(q\) is the \(p\) of this section. That no general shortcut to \(g^{ab}\) is known short of recovering \(a\) or \(b\) remains an empirical fact rather than a theorem.
Cast into the first interface of Section 1.1, Diffie-Hellman acts as a KEM: keygen outputs the server's decapsulation key \(b\) and encapsulation key \(B = g^b \bmod p\); encapsulate(B) draws a fresh \(a\) and returns the ciphertext \(A = g^a \bmod p\) alongside the secret \(B^a \bmod p\); and decapsulate(b, A) computes \(A^b \bmod p\). Diffie-Hellman looks more symmetrical than the KEM interface requires, because \(A\) and \(B\) have the exact same form and either party could speak first. Post-quantum mechanisms lose that symmetry: in ML-KEM the public key and the ciphertext are different objects of different sizes, and creating the ciphertext requires the recipient's public key first (Section 6), which is why the standards speak of encapsulation rather than exchange.
One thing Diffie-Hellman cannot tell you is who sent \(B\). An active attacker on the wire can run one exchange with you and a separate exchange with the server, decrypting and re-encrypting everything that passes between. Closing that gap requires the second interface of Section 1.1: the server signs what it sent.
A trapdoor
Diffie-Hellman produces a random secret that neither side chose, so it cannot sign a chosen message directly. RSA, introduced in 1978 by Rivest, Shamir, and Adleman, builds a more versatile primitive: a one-way function equipped with a secret trapdoor that lets only the key's owner invert it, yielding both encryption and digital signatures from one formula. Where Diffie-Hellman raises a public base to a secret exponent, RSA raises a secret message \(m\) to a fixed public exponent \(e\) modulo the public product \(n = pq\) of two large secret primes. Anyone can compute \(m^e \bmod n\). Inverting that operation, taking an \(e\)-th root modulo \(n\), reduces to one more modular exponentiation for whoever knows \(p\) and \(q\), while for everyone else no method is known that beats factoring \(n\).
key RSA at 64 bits, made in the page (the slider goes from 40 to 2,048 bits)
p = 3,954,261,611 q = 4,135,234,069 both prime, both kept
n = p x q = 16,351,797,331,546,025,159 public, with e = 65,537
m = 26,729 ("hi") c = m^e mod n c^d mod n = 26,729 again; d is made from p and q
at 2,048 bits, on one core of a server: key 294 ms, encrypt 0.078 ms, decrypt 3.9 ms
chart 1 what ran: the steps Pollard's rho takes to find p and q from n; 7 moduli a size, 30 to 98 bits
30 bits 308 steps (median)
98 bits 52,742,782 steps (median), 12 s on that core
the fit twice the steps for every 4.0 more bits
chart 2 what the records say, on an axis of core-years: only the two records counted in core-years are on it
795 bits, 2019: 900 core-years 829 bits, 2020: 2,700 core-years
the curve the sieve's asymptotic law, scaled through the 829-bit record: an extrapolation
2,048 bits: about 10^15 core-years 3,072 bits: about 10^21
off it 862 bits, 2026: 13.5 GPU-years 896 bits, 2026: 30 GPU-years
13 records marked at their sizes, 1994 to 2026; the largest RSA modulus factored in public has 896 bits
(the live figure needs JavaScript and loads about 0.1 MB of data)
A key of 2,048 bits is made in a fraction of a second and used in milliseconds. The method the page runs to undo a key needs twice the steps for every four more bits and gives up near 100 bits; with the best method known, the largest RSA modulus factored in public by November 2026 has 896 bits, at a cost counted in years of machine time.
The secret that opens the hard direction has a name, which the paper of 1978 explains:
A function E satisfying (a)-(c) is a “trap-door one-way function;” if it also satisfies (d) it is a “trap-door one-way permutation.” Diffie and Hellman [1] introduced the concept of trap-door one-way functions but did not present any examples. These functions are called “one-way” because they are easy to compute in one direction but (apparently) very difficult to compute in the other direction. They are called “trap-door” functions since the inverse functions are in fact easy to compute once certain private “trap-door” information is known. A trap-door one-way function which also satisfies (d) must be a permutation: every message is the cipertext for some other message and every ciphertext is itself a permissible message. (The mapping is “one-to-one” and “onto”). Property (d) is needed only to implement “signatures.”
—R. L. Rivest, A. Shamir and L. Adleman, "A method for obtaining digital signatures and public-key cryptosystems" (1978).A paragraph of Section II, on public-key cryptosystems. Its letters are the four properties that the section asks of a user's public encryption procedure E and private decryption procedure D: (a) deciphering an enciphered message returns it, (b) both procedures are easy to compute, (c) revealing E does not reveal an easy way to compute D, and (d) enciphering a deciphered message returns it too. Reference [1] is the paper of Diffie and Hellman, and the spelling “cipertext” is that of the authors' copy.
Fermat's little theorem supplies the arithmetic behind the trapdoor: for any prime \(p\) and any integer \(m\) not divisible by \(p\), \(m^{p-1} \equiv 1 \pmod p\). When \(n = pq\) is a product of two distinct primes, raising \(m\) to any common multiple of \(p - 1\) and \(q - 1\), and in particular to their least common multiple \(\lambda = \operatorname{lcm}(p - 1, q - 1)\), wraps \(m^{\lambda}\) back to \(1\) modulo both primes at once. Knowing \(p\) and \(q\) reveals \(\lambda\), which lets the key's creator compute a private exponent \(d\) that cancels \(e\) modulo \(\lambda\).
Definition 1.4.1 (the RSA function). Let \(p \ne q\) be primes, \(n = pq\) and \(\lambda = \operatorname{lcm}(p - 1, q - 1)\). Choose \(e\) with \(\gcd(e, \lambda) = 1\) and let \(d\) be its inverse modulo \(\lambda\), so that \(ed \equiv 1 \pmod{\lambda}\). The public key is \((n, e)\), the private key is \(d\), and for \(0 \le m < n\) and \(0 \le c < n\)
\[E(m) = m^{e} \bmod n, \qquad D(c) = c^{d} \bmod n. \tag{1.2}\]Because \(ed\) leaves remainder \(1\) upon division by \(\lambda\), raising the ciphertext \(m^e\) to the private power \(d\) restores \(m\) across the full range \(0 \le m < n\), including the edge cases where \(p\) or \(q\) divides \(m\).
Proposition 1.4.2 (the private exponent undoes the public one). \(D(E(m)) = m\) for every \(0 \le m < n\).
Proof. Write \(ed = 1 + k\lambda\). If \(p\) does not divide \(m\), then \(m^{p-1} \equiv 1 \pmod p\) by Fermat's little theorem, and since \(p - 1\) divides \(\lambda\), \(m^{ed} = m \cdot (m^{\lambda})^{k} \equiv m \pmod p\); if \(p\) divides \(m\), both sides are \(0\) modulo \(p\). The same holds modulo \(q\), so \(pq\) divides \(m^{ed} - m\). ∎
Example 1.4.3 (the function by hand). Take a key small enough to check on paper, with primes \(p = 5\) and \(q = 11\). Their product is \(n = 55\) and the cycle modulus is \(\lambda = \operatorname{lcm}(4, 10) = 20\); choosing \(e = 3\) gives the private inverse \(d = 7\), since \(3 \cdot 7 = 21 \equiv 1 \pmod{20}\). Encrypting the message \(2\) gives \(2^3 = 8\), and decrypting computes \(8^7 = 2{,}097{,}152 = 55 \cdot 38{,}130 + 2\), returning \(2\). An observer who sees only the public key \((55, 3)\) needs the hidden modulus \(20\) to find \(d\), and finding \(20\) requires splitting \(55\) into \(5\) and \(11\). ◁
Comparing \(n = pq\) with a prime clock pinpoints where the trapdoor hides. On a prime clock, everyone knows the cycle length \(p - 1\) of the exponents, so undoing a fixed power \(m^e \bmod p\) is just as cheap as computing it; Section 1.2 therefore had to hide the exponent rather than the base. Modulo \(n = pq\), the cycle modulus \(\lambda\) follows from \(p\) and \(q\) and, as far as anyone knows, from nothing short of factoring \(n\):
You first compute n as the product of two primes p and q: n = p·q . These primes are very large, “random” primes. Although you will make n public, the factors p and q will be effectively hidden from everyone else due to the enormous difficulty of factoring n. This also hides the way d can be derived from e.
—R. L. Rivest, A. Shamir and L. Adleman, "A method for obtaining digital signatures and public-key cryptosystems" (1978).Section V, where the method is set out; the authors' copy sets the formula on a line of its own and begins a new paragraph after it. The paper draws \(d\) first and computes \(e\) as its inverse modulo \((p - 1)(q - 1)\), a multiple of the \(\lambda\) used here; the key made in the page fixes \(e = 65{,}537\) and computes \(d\). Finding the primes is cheap: about one number in 710 near \(2^{1024}\) is prime, and a candidate is tested with at most a few dozen exponentiations.
The one function serves both interfaces of Section 1.1. To encapsulate, draw a random \(m\) below \(n\), send \(c = E(m)\) and derive the shared secret from \(m\); the owner recovers \(m = D(c)\). To sign, the owner applies the private direction to a digest \(h\) of the message, a short fingerprint computed by a public hash function (Section 8), and publishes \(s = D(h)\); anyone can check that \(E(s) = h\). This is the textbook function, which is what the page runs, and not how RSA is applied to a message.
As with Diffie-Hellman, the claim of security runs in one direction only. Whoever factors \(n\) can compute \(d\); that there is no way to take \(e\)-th roots modulo \(n\) without factoring has not been proved, and the paper's "(apparently)" says as much.
Breaking the trapdoor therefore comes down, as far as anyone knows, to factoring \(n\). The factoring method that runs in the page, Pollard's rho, iterates a simple polynomial modulo \(n\) to generate a pseudorandom walk. Unseen by the walker, the sequence of remainders modulo the smaller prime factor \(p\) collides with itself after roughly \(\sqrt{p}\) steps (by the birthday paradox); once two walk values \(x\) and \(y\) agree modulo \(p\) without agreeing modulo \(n\), \(\gcd(\lvert x - y \rvert, n)\) exposes \(p\) immediately. When \(p\) and \(q\) have equal bit lengths, \(\sqrt{p} \approx n^{1/4}\) steps, doubling for every four extra bits of \(n\), and the measurements match: across 7 moduli at each of 18 sizes from 30 to 98 bits, the fitted doubling interval is 4.0 bits, reaching a median of 52,742,782 steps at 98 bits.
At cryptographic sizes, the fastest classical algorithm works completely differently. Instead of walking until two remainders collide, the general number field sieve gathers millions of auxiliary numbers that split into small primes and combines a subset of them by linear algebra into two squares \(x^2 \equiv y^2 \pmod n\), from which \(\gcd(x - y, n)\) yields a factor. In February 2020 the sieve factored an 829-bit RSA challenge modulus in about 2,700 core-years (one processor core working for 2,700 years). Nothing larger fell in public for six and a half years; then, in September 2026, GPU implementations of the same sieve factored an 862-bit modulus in about 13.5 GPU-years and an 896-bit modulus in about 30 GPU-years (a GPU-year is one graphics processor working for a year, and is not directly comparable to a core-year).829 bits: F. Boudot and others, "Factorization of RSA-250", announcement of 28 February 2020, which splits the 2,700 core-years into 2,450 of sieving and 250 for the matrix, the two stages just described. 862 bits: E. Lu, "Factoring RSA-260", 9 September 2026. 896 bits: S. A. Weis, "RSA-896", on a computation of 19 September 2026.
Heuristically rather than by proof, the sieve's runtime on a modulus \(n\) grows as
\[L_n = \exp\Bigl( (64/9)^{1/3} \, (\ln n)^{1/3} \, (\ln \ln n)^{2/3} \, \bigl(1 + o(1)\bigr) \Bigr), \tag{1.3}\]a growth rate called sub-exponential: because the exponent scales roughly with the cube root of the bit length \(\ln n\) rather than linearly, \(L_n\) outgrows every polynomial in the bit length while staying far below \(n^{1/4}\) at large sizes. At 2,048 bits, evaluating (1.3) without its \(o(1)\) term gives about \(2^{117}\), compared with \(2^{512}\) for \(n^{1/4}\). That \(o(1)\) term is not mere decoration: the team behind the 829-bit record writes that its presence "reveals a significant lack of accuracy in this complexity estimate",F. Boudot, P. Gaudry, A. Guillevic, N. Heninger, E. Thomé and P. Zimmermann, "Comparing the difficulty of factorization and discrete logarithm: a 240-digit experiment", CRYPTO 2020 (arXiv 2006.06197), in its section on the background of the number field sieve, which also states (1.3). making the formula useful mainly for comparing relative difficulty across bit sizes. By that ratio, a 2,048-bit modulus requires roughly \(2^{35}\) times the work of an 896-bit one, and by their authors' own accounts neither 2026 record threatens 2,048-bit keys. Scaled through the 829-bit record, (1.3) places 2,048 bits near \(10^{15}\) core-years, an extrapolation across 38 doublings that is labeled accordingly on the chart.
The same step on a curve
Prime clocks and RSA moduli have to stretch to thousands of bits only because integers split into small prime factors, giving number-field sieves a shortcut past generic \(\sqrt{N}\) search. Neither the Diffie-Hellman exchange of Section 1.3 nor the baby-step giant-step search of Section 1.2 ever used prime factorization: all Diffie-Hellman needs is a finite group, a set with an associative, reversible operation in which repeating the operation \(k\) times is fast by doubling while recovering \(k\) is hard. Replacing clock integers with a group whose elements have no notion of splitting into small primes shuts down the sieve and lets much shorter keys achieve the same strength. Plane geometry supplies such groups through elliptic curves: solutions \((x, y)\) to a cubic equation \(y^2 = x^3 + ax + b\). To add two points on the curve, draw the straight line through them, find the third point where that line meets the cubic, and reflect that third point across the \(x\)-axis. Carrying out the exact same algebraic formulas on integers modulo a prime \(p\) instead of real numbers produces a finite group of points.
curve y^2 = x^3 - 5x + 1 over the real numbers: a line through P and Q meets the curve in a third point;
that point mirrored in the x-axis is P + Q (when P = Q the line is the tangent)
scatter the same equation modulo 23: 28 points and the point at infinity, 29 in all, each a multiple of G = (0, 1)
step 12G + G = 13G, the same three lines in both over the reals modulo 23
P = (x1, y1) (3.007, 3.628) (21, 16)
Q = (x2, y2) (0, 1) (0, 1)
s = (y2 - y1) / (x2 - x1) 0.874 4
x3 = s^2 - x1 - x2 -2.244 18
y3 = s (x1 - x3) - y1 0.961 19
forward 13 G by double-and-add, a bit of 13 = 1101 at a time: G, 2G, 3G, 6G, 12G, 13G: 5 hops
back which k gives (18, 19)? baby-step giant-step: 6 points stored, 3 tried: 9 steps
on a curve of 1,000,669 points, run in the page: 28 hops forward, 1,996 steps back
on a curve of 256 bits: about 2^128 steps back, not run
sizes bits of a curve key and of an RSA modulus of equal strength (NIST SP 800-57 Part 1, Rev. 5, Table 2)
112-bit strength 224 and 2,048 128-bit 256 and 3,072
192-bit 384 and 7,680 256-bit 512 and 15,360
(the live figure needs JavaScript; it loads no data)
The finite scatter is an arithmetic shadow of the smooth curve: add two rational points on the real curve, reduce their fractions modulo 23, and you land on the sum of their shadows. Doubling \(G = (0, 1)\) on \(y^2 = x^3 - 5x + 1\) over the rationals gives \((25/4, 117/8)\); modulo 23, where \(1/4 \equiv 6\) and \(1/8 \equiv 3\), that reduces to \((12, 6)\), which is \(2G\) in the scatter. Computing \(13G\) by double-and-add takes five hops, while recovering \(13\) from \(13G\) requires a search: nine steps on this 29-point curve, 1,996 search steps against 28 forward hops on a curve of 1,000,669 points, and roughly \(2^{128}\) steps on a 256-bit curve, which nobody has run.
Making the chord-and-tangent recipe airtight requires two small provisions: a non-zero discriminant \(4a^3 + 27b^2 \not\equiv 0 \pmod p\) so that the cubic has well-defined tangents everywhere without cusps or self-intersections, and a single extra element \(O\), the point at infinity, to serve as the additive zero where vertical lines through opposite points \((x, y)\) and \((x, -y)\) meet.
Definition 1.5.1 (the group of an elliptic curve). Let \(p > 3\) be a prime and \(a, b\) integers with \(4a^3 + 27b^2 \not\equiv 0 \pmod p\). The elements are the pairs \((x, y)\) modulo \(p\) with \(y^2 \equiv x^3 + ax + b\), and one more, the point at infinity \(O\). The mirror image \((x, -y)\) of a point \(P = (x, y)\) is written \(-P\). The sum is defined by \(P + O = O + P = P\), \(P + (-P) = O\), and otherwise \(P + Q = -R\), where \(R\) is the third point, counted with multiplicity, at which the line through \(P\) and \(Q\) meets the curve; when \(Q = P\) the line is the tangent at \(P\).
With this sum the points form a commutative group. Only associativity is not plain from the picture; it is a theorem, and the tests of the code that draws these curves check it for every triple of points on four small ones. By a theorem of Hasse the number of points differs from \(p + 1\) by at most \(2\sqrt{p}\), so a curve has about as many points as its clock has hours: 29 for \(p = 23\). In this notation the power \(g^x\) of the clock becomes the multiple \(kG = G + \dots + G\), squaring becomes doubling, and Definition 1.2.2 asks for \(k\) given \(G\) and \(kG\).
What sets curves apart is what they lack. The sieve of Section 1.4 feeds on the splitting of integers into small primes. For the curves in use nothing comparable is known, and the best attacks known are the generic ones, which work in any group and cost about the square root of its number of elements (of the largest prime dividing that number, to be exact, which is why the groups in use have prime or nearly prime size). A group of \(2^{256}\) points therefore costs about \(2^{128}\) steps to attack by the best method known, a level that RSA and the clock reach only at 3,072 bits (Section 1.6).
X25519 is the exchange of Section 1.3 in such a group. Its curve is \(v^2 = u^3 + 486662\,u^2 + u\) over the numbers modulo \(2^{255} - 19\), the same kind of cubic written in another form; the point with \(u = 9\) generates a group of about \(2^{252}\) elements; and a public value is the \(u\)-coordinate of a point, 32 bytes. The memo that specifies it states its aim in two sentences:
This memo specifies two elliptic curves over prime fields that offer a high level of practical security in cryptographic applications, including Transport Layer Security (TLS). These curves are intended to operate at the ~128-bit and ~224-bit security level, respectively, and are generated deterministically based on a list of required properties.
—A. Langley, M. Hamburg and S. Turner, "Elliptic Curves for Security", RFC 7748 (2016).The abstract of the memo; RFCs are the numbered memos in which the internet's protocols and their building blocks are written down. The first of the two curves is the one X25519 works on; the function on the second, X448, has values of 56 bytes.
Those 32 bytes a side are the baseline for the rest of the series. For the same job ML-KEM-768 sends 1,184 bytes one way and 1,088 the other, and the handshakes captured for Section 6, the opening exchanges of real connections, carry both, the old exchange beside the new mechanism, with the two secrets combined (Section 11).
What 128-bit security means
RFC 7748's "~128-bit" is a statement about an attacker's bill. For a 128-bit symmetric cipher with no known shortcut past brute force, such as AES-128, recovering the key takes at most \(2^{128}\) trials. A public-key scheme is said to offer 128-bit security when the fastest known attack against it costs roughly that much work; for comparison, the longest computations behind the figures in Section 1 run for about \(2^{26}\) steps. Security bits therefore measure the cost of the best attack known, and each family of keys has its own cost curve:
Three steps that are easy one waya row to a step: its easy direction, its hard one and, in ink, the best attack known on the hard one, its cost, and the key size that leaves at 128-bit strength
1.2powers modulo a prime Diffie-Hellman on a clock
Forward: g and x give g^x mod p, by squaring and multiplying. Back: the discrete logarithm. The hours are integers, which split into small primes, and the sieve feeds on that.
best attack known: the number field sieve, of sub-exponential cost
128-bit strength: a prime of 3,072 bits
1.4the product of two primes RSA
Forward: p and q give n = p q. Back: factoring n. Whoever holds p and q can undo m^e mod n, and that is the trapdoor.
best attack known: the number field sieve, of sub-exponential cost
128-bit strength: a modulus of 3,072 bits
1.5multiples of a point on a curve Diffie-Hellman on a curve
Forward: k and G give k times G, by doubling and adding. Back: the discrete logarithm on the curve, for which nothing better is known than a search of about the square root of the number of points.
best attack known: a generic search, of square-root cost
128-bit strength: a curve of 256 bits
green: the step with no known shortcut, and so the shortest key
A generic search costs the square root of the group's size, so a curve needs twice as many bits as the strength it aims at. The sieve's cost (1.3) grows so much more slowly than a search's that a modulus has to grow much faster than its strength. NIST, the United States institute whose standards this series follows, sets the resulting sizes side by side:
| security strength | symmetric cipher | Diffie-Hellman modulo a prime | RSA | elliptic curve |
|---|---|---|---|---|
| 112 bits | 3TDEA | \(L\) = 2,048, \(N\) = 224 | \(k\) = 2,048 | \(f\) = 224 to 255 |
| 128 bits | AES-128 | \(L\) = 3,072, \(N\) = 256 | \(k\) = 3,072 | \(f\) = 256 to 383 |
| 192 bits | AES-192 | \(L\) = 7,680, \(N\) = 384 | \(k\) = 7,680 | \(f\) = 384 to 511 |
| 256 bits | AES-256 | \(L\) = 15,360, \(N\) = 512 | \(k\) = 15,360 | \(f\) = 512 and more |
The RSA column and the prime of Diffie-Hellman carry the same numbers, because the same sieve attacks both at nearly the same cost. The team that set both 795-bit records in 2019 reports:
We report on two new records: the factorization of RSA-240, a 795-bit number, and a discrete logarithm computation over a 795-bit prime field. Previous records were the factorization of RSA-768 in 2009 and a 768-bit discrete logarithm computation in 2016. Our two computations at the 795-bit level were done using the same hardware and software, and show that computing a discrete logarithm is not much harder than a factorization of the same size. Moreover, thanks to algorithmic variants and well-chosen parameters, our computations were significantly less expensive than anticipated based on previous records. The last page of this paper also reports on the factorization of RSA-250.
—F. Boudot, P. Gaudry, A. Guillevic, N. Heninger, E. Thomé and P. Zimmermann, "Comparing the difficulty of factorization and discrete logarithm: a 240-digit experiment" (2020).CRYPTO 2020 (arXiv 2006.06197), the abstract. RSA-240 and RSA-250 are challenge numbers of 240 and 250 decimal digits, that is, of 795 and 829 bits.
The clock's second size, \(N\), the length of the private exponent, is twice the strength, exactly as the curve's \(f\) is: both are set by the square-root search.
Remark 1.6.1 (what the number does not say). A security-strength bit count summarizes known attacks rather than any intrinsic property of the problem. The numbers are approximate: at 2,048 and 3,072 bits, evaluating (1.3) without its \(o(1)\) term gives \(2^{117}\) and \(2^{139}\) where NIST's table lists 112 and 128; likewise X25519, whose subgroup has a 253-bit prime order and costs roughly \(2^{126}\) search steps, sits just below 256 bits while RFC 7748 calls it the "~128-bit" level. Those estimates also shift over time, as when the two 795-bit records came in significantly cheaper than prior records had led their authors to expect. Above all, the table counts classical attacks alone, as its footnote warns; what a quantum computer does to those columns is the subject of Section 2.
For the post-quantum schemes of Sections 3 to 9, NIST avoids single bit-security numbers altogether. Because future quantum cryptanalysis and physical quantum gate speeds both carry wide uncertainty, NIST defined five security categories pegged to familiar symmetric primitives: breaking a scheme in category 1, 3, or 5 must cost at least as much as a key search on AES-128, AES-192, or AES-256, and breaking category 2 or 4 must cost at least as much as finding a collision (two distinct inputs with the same digest) in a 256-bit or 384-bit hash function.NIST, "Submission Requirements and Evaluation Criteria for the Post-Quantum Cryptography Standardization Process" (the call for proposals, December 2016), Section 4.A.5. The same five categories stand in Table 1 of NIST IR 8547, "Transition to Post-Quantum Cryptography Standards" (final, October 2026). Section 10 examines how concrete parameter sets are mapped to those categories.
A public key is a promise about cost: one direction of a computation is cheap for everyone, and the other is beyond anyone who lacks the private key. Nobody has proved the second half, and a key is as long as the best attack found so far demands. The schemes of Sections 3 to 9 keep the six functions of Section 1.1 and make the same promise on top of new mathematical problems.
New problems are needed because integer factoring and discrete logarithms share a hidden vulnerability: both conceal a repeating period. Modulo \(n = pq\), the successive powers \(m, m^2, m^3, \dots\) of any integer \(m\) coprime to \(n\) cycle back to \(m\) with a period dividing \(\lambda\) from Definition 1.4.1 (powers of \(2\) modulo \(55\) repeat every \(20\) steps), and knowing such periods splits \(n\) immediately. On a prime clock or an elliptic curve, a public key \(A = g^a\) lets anyone evaluate the two-exponent function
\[(u, v) \mapsto g^{u} A^{-v}, \qquad A = g^{a}, \tag{1.4}\]which equals \(g^{u - av}\) and therefore repeats its value whenever \(u\) increases by \(a\) and \(v\) increases by \(1\) (shifting by \((6, 1)\) on the 23-hour clock where \(A = 8 = 5^6\)). The secret exponent \(a\) is the hidden period of a function that anyone can compute. No efficient classical algorithm can spot a period across an exponentially long cycle, whereas a quantum computer finds periods directly, and Section 2 shows how.