Shor’s algorithm (1994) factors integers and computes discrete logarithms in polynomial time on a quantum computer. Factoring splits a number into its prime building blocks (15 = 3 x 5); a discrete logarithm is the exponent x hidden in an equation like g^x = h mod p. Polynomial time means the work grows with the digit count of the input rather than exponentially with it.
Both problems reduce to one move, period finding, and a quantum computer finds periods that the best classical algorithms cannot. Deployed public-key cryptography sits on exactly these two problems: RSA on factoring, finite-field Diffie-Hellman and elliptic-curve cryptography on discrete logarithms. Symmetric cryptography survives; the quantum threat guide carries the full what-breaks picture.
Factoring becomes period finding.
Pick a random g with 1 < g < N and write its powers mod N (mod is the remainder after dividing by N): g, g², g³, ... The remainders repeat, and the repeat length r is g’s order. When r is even and g^(r/2) does not leave remainder N − 1, two gcds (greatest common divisors, computable classically by the Euclidean algorithm) expose a factor of N:
gcd(g^(r/2) − 1, N) and gcd(g^(r/2) + 1, N).
For a random g the checks pass with probability at least 1 − 1/2^(k−1), where k is the number of distinct odd prime factors of N (Miller 1976; Shor 1996, section 5). A failed draw retries with a fresh g. Writing out powers to find r is infeasible at RSA size: the sequence can run nearly N steps before repeating, and closing exactly that gap is the quantum computer’s job.
The quantum primitives.
A quantum register can hold a superposition: many values at once, each carrying anamplitude, a number whose squared size is the probability that the value appears when the register is measured. Amplitudes have direction, so contributions to the same outcome can reinforce or cancel (interference). Measurement samples one value; the rest are gone. The algorithm is built so that the useful values are the ones whose amplitudes line up.
The quantum core of one run.
The machine puts a first register into a superposition over all exponents x = 0 ... q−1, where q is a power of two chosen between N² and 2N², and computes g^x mod N into a second register by repeated squaring. That step, modular exponentiation, is the bottleneck of the whole algorithm, and it runs on quantum registers because it is built reversible. The quantum Fourier transform(the quantum version of the classical tool for reading frequencies out of a repeated signal) then acts on the first register, and interference does the work: amplitudes near multiples of q/r reinforce each other and cancel everywhere else. Measuring the first register returns a value c that, with high probability, sits near a multiple of q/r.
Classical post-processing.
c/q approximates d/r (d is an unknown constant) within 1/(2q). With q above N² that fraction is unique, and the continued-fraction expansion of c/q, a short classical algorithm that reads the best rational approximations out of a number, recovers r. One run yields r with probability at least φ(r)/(3r), where φ(r) (Euler’s totient) counts the numbers below r sharing no factor with r; the bound shrinks only like 1/log log r, so repeating the run a modest number of times makes failure rare, and classical tricks that also try 2r, 3r, ... for each candidate cut the expected run count to a handful.
One run’s numbers, small enough to check by hand. On RSA-size moduli the sequence can run nearly N steps before repeating; finding the repeat length without writing the sequence out is what the quantum core does.
| Step | N = 15, g = 7 |
|---|---|
| Powers of g mod N | 7, 4, 13, 1, 7, 4, ... : the sequence repeats every r = 4 steps |
| Parity checks | r = 4 is even; g^(r/2) = 7² = 4, and 4 ≠ 15 − 1, so the gcds may split N |
| First gcd | gcd(7² − 1, 15) = gcd(48, 15) = 3 |
| Second gcd | gcd(7² + 1, 15) = gcd(50, 15) = 5 |
| Factors | 15 = 3 x 5 |
Every widely deployed public-key system sits on one of the two problems the algorithm solves. The same 1994 paper that factors integers computes discrete logarithms with the same period-finding core, so the two hard problems fall together.
| System | Rests on | Shor’s algorithm |
|---|---|---|
| RSA | factoring | falls: polynomial-time factoring removes the key-length margin |
| Finite-field Diffie-Hellman | discrete logarithm mod p | falls: the same period-finding core solves discrete logarithms |
| ECC (ECDSA, ECDH, Ed25519) | elliptic-curve discrete logarithm | falls: same core, different group |
| AES, ChaCha20, SHA-2/3 | no factoring or discrete-log structure | unaffected by Shor; Grover’s quadratic speedup is answered by longer keys |
The speedup against symmetric cryptography is different in kind. Grover’s algorithm (1996) searches an unstructured space of N keys in about √N steps, so an n-bit key works at roughly 2^(n/2) strength; doubling the key length restores it, which is why AES-256 and SHA-384/512 remain the symmetric answer. The threat guide carries the full break/survive picture.
A polynomial-time factoring algorithm removes the margin that long RSA moduli buy. RSA-2048 and RSA-4096 sit in the same complexity class: the runtime still grows only polynomially with the digit count, so the larger modulus raises the work by a modest factor while the needed machine stays the same kind. There is no RSA key length that answers the algorithm.
The deployed answer is replacement, not enlargement: ML-KEM, ML-DSA, and SLH-DSA rest on lattice and hash problems rather than factoring or discrete logarithms. Their byte costs are the price, and the standards guide’s size section carries the numbers.
| Claim | Primary source | Status |
|---|---|---|
| Factoring and discrete logarithms have polynomial-time randomized algorithms on a quantum computer (1994) | Shor, FOCS 1994; SIAM J. Comput. 26, 1484 (1997); arXiv:quant-ph/9508027 | verified (abstract) |
| Factoring reduces to order finding: gcd(x^(r/2) - 1, n) yields a factor unless r is odd or x^(r/2) leaves remainder n-1; a random x works with probability at least 1 - 1/2^(k-1), k = distinct odd prime factors | Shor 1996, section 5 (the reduction goes back to Miller 1976) | verified (paper text) |
| One run: superposition over a, reversible modular exponentiation by repeated squaring, Fourier transform A_q, measurement; q is the power of two with N² ≤ q < 2N² | Shor 1996, sections 3-5 | verified (paper text) |
| Measured c lands near a multiple of q/r; |c/q - d/r| ≤ 1/(2q); continued fractions recover d/r, unique once q > N² | Shor 1996, section 5 (Figure 5.1 plots q = 256, r = 10) | verified (paper text) |
| One run yields r with probability at least φ(r)/(3r) ≥ δ/log log r; repeating O(log log r) times gives high probability | Shor 1996, section 5 | verified (paper text) |
| Modular exponentiation is the algorithm’s bottleneck: O(l) squarings and multiplications mod n for an l-bit modulus | Shor 1996, section 3 | verified (paper text) |
| Grover’s algorithm searches N unstructured keys in O(√N) steps: quadratic, not exponential | Grover, STOC 1996; arXiv:quant-ph/9605043 | verified (abstract) |
| Worked example: powers of 7 mod 15 run 7, 4, 13, 1 (r = 4); gcd(48, 15) = 3; gcd(50, 15) = 5 | this page’s arithmetic, checkable by hand | checked |
Textbook depth: Nielsen & Chuang, Quantum Computation and Quantum Information, the order-finding and quantum Fourier transform chapters. A compact companion exposition without the kets: Scott Aaronson, “Shor, I’ll do it” (2007).
The run count stays polynomial, so the reason no cryptographically relevant quantum computer exists yet is not the arithmetic but the machine. The factoring circuit is specified overlogical qubits, each one held accurate by error correction spread across many noisy physical qubits, and that overhead is the gap no lab has closed yet. The threat guide’s estimates carry the qubit counts and how widely they diverge by assumption.
The quantum threat guide turns this mechanism into the migration picture: which deployed systems it breaks, why recorded traffic is at risk before any such machine exists, and what the standards and deadlines answer.