Ndovu elephant mark ndovu

NDOVU · AUDIO EXPLAINER · LISTEN

Grover's algorithm, explained

6:11·5 chapters·transcript
0:00 / 6:11

Keys: space/K play-pause · J/L jump 10s · arrows on the waveform nudge 5s

01 - Chapters

5 chapters

02 - Transcript

Read along

The full briefing transcript, timed to the audio. Click any line to jump there; the current line lights up while you listen.

Grover's algorithm is a quantum search algorithm, published by Lov Grover in 1996, that searches an unstructured space of N items in about the square root of N quantum steps. Unstructured is the operative word: the candidates carry no order to exploit, like a phone directory in completely random order, which is the paper's own picture. Any classical algorithm needs at least N over 2 looks to find one name with 50 percent probability; Grover's needs on the order of the square root of N steps, and the tight analysis published the same year places it within a small constant factor of the fastest possible quantum search. The speedup is quadratic, not exponential: the work shrinks to its square root, rather than dropping from exponential to polynomial the way factoring does under Shor's algorithm. That difference decides what survives the quantum threat. Shor's algorithm finds structure inside factoring and discrete logarithms, so RSA and elliptic-curve cryptography fall at any key length; Grover's loop exploits nothing about the keys it searches, so its quadratic dent is answered by doubling the key length. Symmetric cryptography survives, and the migration replaces public-key algorithms only. In the next few minutes: the two-move loop, a worked example on sixteen keys, what the dent touches, and the key-length arithmetic that answers it.

The setup is a space of N candidates with exactly one marked: a function that returns 1 for the answer and 0 for everything else, where one evaluation is the unit of work, the oracle call. Key search has exactly this shape: every AES key is a candidate until one decrypts the message, and nothing about the keyspace says which. Four quantum ideas carry the loop. A quantum register holds a superposition, many values at once, each carrying an amplitude, a number whose squared size is the probability that the value appears on measurement. Amplitudes have sign, so they add up or cancel out; arranging that addition and cancellation, interference, is the algorithm's entire job. Measurement samples one value, and the other candidates are gone. The loop then repeats two moves. Move one, the oracle flip: one circuit call marks the answer by flipping the sign of its amplitude. Move two, inversion about the mean: every amplitude a is replaced by twice the mean minus a. The flip puts the answer's amplitude just below the mean, so the inversion throws it above the mean while all the others dip. Each pass rotates the state by two theta toward the marked candidate, where sine theta is one over the square root of N. Measure near pi over four times the square root of N iterations: after k iterations the success probability is the square of sine of two k plus one times theta, and past the peak the rotation overshoots and the marked amplitude falls again, which is why the count stops there. The two moves together are called amplitude amplification, and the same loop runs wherever a predicate can be built into an oracle: key search, hash preimage, collision finding.

The small case can be followed exactly. Take sixteen keys with one marked, so sine theta is one quarter. Before any iteration, the marked amplitude is one quarter and the success probability is one sixteenth. After one iteration the marked amplitude is eleven sixteenths, an exact fraction, since the sine of three theta is three quarters minus one sixteenth, and the success probability reaches about 47 percent. After two iterations the marked amplitude is sixty-one sixty-fourths and the probability about 91 percent. After three it is two hundred fifty-one over two hundred fifty-six, and the probability is 96 percent. Pi over four times the square root of sixteen is about 3.14: three iterations, then measure. A fourth would overshoot, dropping the success probability back near 58 percent, because past the peak the marked amplitude falls again.

Grover's loop is generic: it needs a predicate and nothing else, so every construction whose security rests on the cost of trying candidates feels the same quadratic dent. Symmetric keys like AES are dented: the exponent halves, from two to the n keys down to two to the n over two oracle calls, and they survive at doubled lengths, where AES-256 puts two to the 128th back. Hash preimage search is dented the same way and survives at standard sizes: a SHA-256 preimage stays at two to the 128th against quantum search. Hash collisions are dented differently: the birthday bound of two to the n over two falls to about two to the n over three under the Brassard, Hoyer and Tapp algorithm, and a larger output size answers it. MACs carry no structural break for Grover to exploit; they are dented only through the hash and key inside. And public-key cryptography is not Grover's story at all: RSA and elliptic-curve schemes rest on problems Shor's algorithm solves in polynomial time, at any key length, so they get replaced rather than lengthened.

The exponent is what moves. Grover's runtime against an n-bit keyspace is on the order of two to the n over two oracle calls, one full cipher evaluation per call: AES-128's two to the 128th key search becomes about two to the 64th calls, and AES-256's two to the 256th key search becomes about two to the 128th calls. The exponent halves; doubling the key length puts it back. This is why CNSA 2.0, the NSA's requirements for national security systems, keeps AES and SHA and moves each up one size: AES-256 for all classification levels, SHA-384 or SHA-512, alongside the public-key replacements ML-KEM and ML-DSA. One calibration keeps this a paper decision rather than a hardware emergency: two to the 64th oracle calls, each a full AES circuit run on a quantum register, is a magnitude no built machine approaches, so the halved exponent is permanent but small next to the hardware gap. The doubling is decided on paper, once.

0:00