Overview
Curated: · Written: · Reviewed:
Quantum Algorithms II: Shor's Algorithm & Cryptographic Implications
In one line
Shor's algorithm finds the period of a^x mod N on a fault-tolerant quantum computer, which breaks integer factorization and discrete log in polynomial time. Reach for it when asked which deployed primitives fall to a quantum adversary, and why.
Key definitions
- Order r: the least positive integer with a^r ≡ 1 (mod N).
- Abelian hidden subgroup problem: the problem class Shor solves. Factoring and discrete log are both instances.
- Logical vs physical qubit: an error-corrected qubit vs a device qubit. Any estimate must quote both.
- Continued fractions: the classical step that recovers a candidate r from the measured integer near s/r.
- CRQC: cryptographically relevant quantum computer, the threshold the migration clock is measured against.
Formulas and complexity
Where x is the confidentiality lifetime, y the migration time and z the years until a CRQC. A 25-year secrecy requirement plus a 7-year migration is exposed against any horizon under 32 years.
Classical comparison: the general number field sieve is heuristically L_N[1/3, 1.923]. The speedup is relative to the best known classical algorithm, not a proven lower bound.
How it works
Classical preprocessing: pick a with 1 < a < N. If gcd(a, N) ≠ 1, you already have a factor. Quantum step: phase estimation on multiplication by a mod N, then an inverse QFT, yields an integer close to s/r. Classical step: continued fractions give a candidate r, which you confirm by modular exponentiation. Factor extraction: if r is even and a^(r/2) ≢ ±1 (mod N), take gcd(a^(r/2) ∓ 1, N).
Worked trace, N = 15, a = 2: r = 4, a^2 = 4, gcd(3, 15) = 3, gcd(5, 15) = 5. Worked trace, N = 15, a = 14: r = 2, but a^1 ≡ -1, so both gcds are trivial. Discard the base.
When to use and when not to
| Primitive | Underlying problem | Broken by Shor? |
|---|---|---|
| RSA encryption and signatures | factoring | yes |
| ECDH (X25519), ECDSA (P-256), Ed25519 | discrete log in an elliptic curve group | yes |
| FFDH, DSA, ElGamal | discrete log in a cyclic group | yes |
| AES-256-GCM, SHA-384, HMAC | unstructured search | no; Grover gives only a quadratic speedup |
| ML-KEM (FIPS 203), ML-DSA (FIPS 204), SLH-DSA (FIPS 205) | lattice or hash-based | not affected by Shor |
Traps interviewers probe
- "Quantum breaks all encryption." Fix: name the assumption. Factoring and discrete log fall; symmetric primitives and hashes survive with parameter review.
- "Factoring 21 means RSA-2048 is close." Fix: small demonstrations often compile away the modular arithmetic that dominates cost at 2048 bits. Ask which of logical qubits, non-Clifford gate count, code distance and success probability was measured.
- "AES-128 is 64-bit after Grover." Fix: the arithmetic is right, but Grover's iterations are sequential, and parallelizing across k machines improves the count by only sqrt(k).
- "Two algorithms means double security." Fix: hybrid safety depends on the combiner, negotiation, key derivation and failure semantics.
- Accepting the first continued-fraction denominator. Fix: verify each candidate by modular exponentiation. For N = 15, a = 7, the fraction 2/3 gives candidate 3, but 7^3 mod 15 = 13, so reject it and test multiples.
Interview tips
Open with the assumption: "Shor solves period finding, which breaks factoring and discrete log, so RSA and elliptic-curve key exchange and signatures are broken, while AES-256 and SHA-384 survive."
Expected follow-ups: Why are ECC keys smaller but not safer against Shor? Why does RSA-8192 not help? Why does Grover not break AES-256? What is the logical-to-physical qubit ratio? What does Mosca's inequality say about your data?
30-second outline:
- Shor is period finding over an abelian group. Factoring and discrete log are instances.
- Order finding is quantum. Continued fractions and gcds are classical, and every candidate is verified.
- RSA, DH and ECC fall. AES-256 and SHA-384 remain, with Grover as a quadratic effect.
- Migration is sequenced by data lifetime: key exchange first, long-lived signatures next, symmetric parameters last.
- Name what is unknown: the CRQC arrival date, and the real physical qubit count.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.