Shor's algorithm and the hidden subgroup problem
Shor's 1994 algorithm factors integers and computes discrete logarithms in polynomial time by finding periods with the quantum Fourier transform; it is the abelian case of the hidden subgroup problem.
On this page13 sections
Shor's algorithm would break RSA, Diffie–Hellman and elliptic-curve cryptography on a large error-corrected machine, which is why public-key standards are moving to post-quantum schemes; the hidden subgroup framework organises most known exponential quantum speedups.
A quantum method that finds the prime factors of huge numbers quickly, which would break much of today's encryption.
- 1Factoring hides a repeating pattern
- 2Quantum superposition holds all exponents
- 3Fourier transform reveals the period
- 4Period gives the prime factors
- 5Needs a large error-corrected machine
Reduction to period finding. To factor an odd number , pick a random that shares no factor with and look at the sequence taken modulo (the remainder after dividing by ). It repeats with some period , called the order of . If is even, then usually shares a factor with , and the greatest common divisor, computed with Euclid's algorithm in first-year time, gives a factor. So factoring reduces to finding .
The quantum step. A register of qubits is put in a superposition of all exponents at once, and is computed into a second register. The first register then holds a periodic pattern with period . The quantum Fourier transform works like a discrete Fourier transform from signals courses: it turns a signal with period into sharp peaks at multiples of . Measuring gives one of those peaks, and a short classical calculation (continued fractions) recovers . The cost is dominated by the modular arithmetic, roughly gates for an -bit number, versus the best classical method, the number field sieve, whose time grows faster than any polynomial in .
How big a machine? Running Shor on a 2048-bit RSA key needs error-corrected logical qubits. Estimates: 20 million noisy qubits for 8 hours (2019), under a million for under a week (2025), and preprints in 2026 claiming around 100,000 or fewer with newer error-correcting codes. None of these machines exists yet.
Go deeper
The full technical text.
From factoring to period finding
Factoring an -bit odd integer with at least two distinct prime factors reduces, with a randomised classical argument, to order finding: pick a random coprime to and find the smallest with . If is even and , then is a nontrivial factor, which happens for at least half of the choices of .
The quantum part finds . A register is put in a uniform superposition over exponents , the value is computed into a second register, and the quantum Fourier transform (QFT) is applied to the first register. Measuring gives a value close to a multiple of , and the continued-fraction expansion recovers with good probability. The cost is dominated by modular exponentiation: gates with schoolbook arithmetic and with fast multiplication. Discrete logarithms are a two-dimensional period-finding problem and fall to the same method, including in elliptic-curve groups.
The hidden subgroup problem
A function on a group hides a subgroup if it is constant on the cosets of and takes different values on different cosets; the task is to find . For abelian groups this is solved efficiently by Fourier sampling (Kitaev's abelian stabilizer algorithm, 1995), with Simon's problem, factoring and discrete logarithms as special cases. Ettinger, Høyer and Knill (2004) showed that polynomially many queries determine for every finite group, but extracting from those queries may take exponential time.
The open cases are non-abelian. The dihedral group is linked to lattices: Regev (2002) showed that an algorithm for the dihedral coset problem that tolerates faulty samples gives a quantum algorithm for the unique shortest vector problem, and Kuperberg (2003) gave a subexponential algorithm with running time . The symmetric group would give graph isomorphism, but Moore, Russell and Schulman (2005) showed that strong Fourier sampling on coset states cannot distinguish the relevant subgroups, and Babai's quasipolynomial classical algorithm (2015) reduced the stakes. Childs and van Dam (2010) review the area.
Resource estimates
Experiments so far have factored only small numbers, often with circuits simplified using knowledge of the answer (Smolin, Smith and Vargo, 2013). For RSA-2048, Gidney and Ekerå (2019) estimated 20 million noisy qubits for 8 hours; Gidney (2025) lowered this to under a million qubits for under a week, assuming a 0.1% gate error rate, a nearest-neighbour square grid, a 1 microsecond surface-code cycle and a 10 microsecond reaction time. Preprints in 2026 go further by replacing the surface code with high-rate codes: Webster et al. (the "Pinnacle" architecture, qLDPC codes) estimate fewer than 100,000 physical qubits under the same error rate and timing, and Cain et al. argue that as few as 10,000 reconfigurable neutral-atom qubits could run Shor's algorithm at cryptographic scale, with RSA-2048 taking one to two orders of magnitude longer than a few-day P-256 discrete logarithm on 26,000 qubits. Regev (2023) gave a different factoring circuit with gates run about times, under a number-theoretic heuristic. All of these are paper estimates for machines that do not exist.
Limits
Shor's algorithm does not break symmetric ciphers or hash functions (Grover search gives only a quadratic speedup against them) and gives no known speedup for NP-complete problems. Lattice-based schemes such as ML-KEM (FIPS 203, 2024) were standardised because no efficient quantum algorithm for their underlying problems is known; the dihedral hidden subgroup problem is the main known quantum route towards them.
Words on this page (9)
- prime factorization
- Writing a whole number as a product of primes, such as 15 = 3 × 5.
- RSA
- A widely used public-key encryption scheme whose security relies on factoring being hard.
- modular arithmetic
- Arithmetic with remainders, like a clock where 13 o'clock is 1 o'clock.
- quantum Fourier transform
- A quantum version of the discrete Fourier transform that reveals periods in a superposition.
- discrete logarithm
- Finding x from a^x in modular arithmetic; Shor's method solves it too.
- hidden subgroup problem
- Finding an unknown subgroup from a function that is constant on its cosets; covers factoring and more.
- logical qubit
- A reliable qubit built from many noisy physical qubits by error correction.
- post-quantum cryptography
- Encryption designed to resist attacks by quantum computers, such as lattice-based schemes.
- dihedral group
- The symmetries of a regular polygon: rotations and reflections.
New to this? Read first (3)
- Shor's algorithm (Wikipedia)Step-by-step account with the classical and quantum parts separated.
- Shor, I'll do it (Scott Aaronson's blog)A famous plain-language explanation of how Shor's algorithm uses interference.
- Post-quantum cryptography (Wikipedia)Why encryption is being replaced before large quantum computers exist.
Understanding map
map of the whole wiki →What to read before Shor's algorithm and the hidden subgroup problem (left), and what builds on it: entries that depend on it and its open problems (right). Every box links to its page.
- Start with
- Step 2
- Step 3
- Quantum algorithmsAlgorithm
- Step 4
- Shor's algorithm and the hidden subgroup problemYou are here
- Then
Open problems & questions
Progress timeline
- Sep 30, 2026No-go theorem for the templateRelated to: A polynomial-time quantum algorithm for the dihedral hidden subgroup problemsource
Gupte, Ragavan and Zhandry posted a barrier for Fourier-label-discarding algorithms, with Lean code, applying it to Simon's algorithm; a preprint.
- Aug 11, 2026Polynomial-time claim (disputed)Related to: A polynomial-time quantum algorithm for the dihedral hidden subgroup problemsource
Simon posted a claimed polynomial-time DCP algorithm on IACR ePrint.
- Feb 12, 2026qLDPC estimate under 100,000 qubits (preprint)source
The Pinnacle architecture preprint estimated RSA-2048 with fewer than 100,000 physical qubits using qLDPC codes.
- May 21, 2025Under a million qubits (estimate)source
Gidney estimated under a week on under a million noisy qubits, with the same hardware assumptions; a preprint.
- May 23, 2019RSA-2048 with 20 million qubits (estimate)source
Gidney and Ekerå estimated 8 hours on 20 million noisy qubits.
- Oct 23, 2017LWE equals extrapolated DCPRelated to: A polynomial-time quantum algorithm for the dihedral hidden subgroup problemsource
Brakerski, Kirshanova, Stehlé and Wen showed LWE is equivalent to extrapolated DCP.
- Apr 1, 2003Dihedral cosets and latticesRelated to: A polynomial-time quantum algorithm for the dihedral hidden subgroup problemsource
Regev's reduction from unique-SVP to the dihedral coset problem appeared on arXiv (FOCS 2002).
- Feb 14, 2003Kuperberg's sieveRelated to: A polynomial-time quantum algorithm for the dihedral hidden subgroup problemsource
Kuperberg gave the first subexponential algorithm.
- Feb 14, 2003Subexponential dihedral algorithmsource
Kuperberg gave a quantum algorithm for the dihedral hidden subgroup problem.
- Nov 20, 1995Abelian stabilizer problemsource
Kitaev's phase-estimation approach solved the abelian stabilizer problem, the general abelian hidden subgroup setting.
- Nov 1, 1994Shor's algorithm at FOCSsource
Shor presented polynomial-time quantum algorithms for factoring and discrete logarithms at FOCS 1994 (month only).