Skip to content
DAH
Wiki/Quantum AlgorithmsAlgorithmMature

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
Why other work relies on it

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.

  1. 1Factoring hides a repeating pattern
  2. 2Quantum superposition holds all exponents
  3. 3Fourier transform reveals the period
  4. 4Period gives the prime factors
  5. 5Needs a large error-corrected machine

Reduction to period finding. To factor an odd number NN, pick a random aa that shares no factor with NN and look at the sequence a1,a2,a3,…a^1, a^2, a^3,\dots taken modulo NN (the remainder after dividing by NN). It repeats with some period rr, called the order of aa. If rr is even, then ar/2−1a^{r/2}-1 usually shares a factor with NN, and the greatest common divisor, computed with Euclid's algorithm in first-year time, gives a factor. So factoring reduces to finding rr.

The quantum step. A register of qubits is put in a superposition of all exponents xx at once, and ax mod Na^x \bmod N is computed into a second register. The first register then holds a periodic pattern with period rr. The quantum Fourier transform works like a discrete Fourier transform from signals courses: it turns a signal with period rr into sharp peaks at multiples of 1/r1/r. Measuring gives one of those peaks, and a short classical calculation (continued fractions) recovers rr. The cost is dominated by the modular arithmetic, roughly n3n^3 gates for an nn-bit number, versus the best classical method, the number field sieve, whose time grows faster than any polynomial in nn.

Hidden subgroups. Factoring, discrete logarithms and Simon's problem are all instances of the hidden subgroup problem: a function is constant on the cosets of an unknown subgroup and the task is to find it. For commutative (abelian) groups, quantum computers solve it efficiently. For the dihedral group (symmetries of a polygon) only a subexponential algorithm is known, and a fast one would threaten lattice-based encryption.

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 nn-bit odd integer NN with at least two distinct prime factors reduces, with a randomised classical argument, to order finding: pick a random aa coprime to NN and find the smallest r>0r>0 with ar≡1(modN)a^r\equiv 1 \pmod N. If rr is even and ar/2≢−1(modN)a^{r/2}\not\equiv -1 \pmod N, then gcd⁡(ar/2−1,N)\gcd(a^{r/2}-1,N) is a nontrivial factor, which happens for at least half of the choices of aa.

The quantum part finds rr. A register is put in a uniform superposition over exponents xx, the value ax mod Na^x \bmod N 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 2m/r2^m/r, and the continued-fraction expansion recovers rr with good probability. The cost is dominated by modular exponentiation: O(n3)O(n^3) gates with schoolbook arithmetic and O(n2log⁡nlog⁡log⁡n)O(n^2\log n\log\log n) 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 ff on a group GG hides a subgroup HH if it is constant on the cosets of HH and takes different values on different cosets; the task is to find HH. 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 HH for every finite group, but extracting HH 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 2O(log⁡N)2^{O(\sqrt{\log N})}. 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 O~(n3/2)\tilde O(n^{3/2}) gates run about n\sqrt n 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)
Words on this page
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)
New to this? Read first

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.

  1. Start with
  2. Step 2
  3. Step 3
  4. Step 4
  5. Then

Open problems & questions

Progress timeline

  1. Sep 30, 2026
    No-go theorem for the template
    Related to: A polynomial-time quantum algorithm for the dihedral hidden subgroup problem

    Gupte, Ragavan and Zhandry posted a barrier for Fourier-label-discarding algorithms, with Lean code, applying it to Simon's algorithm; a preprint.

    source
  2. Aug 11, 2026
    Polynomial-time claim (disputed)
    Related to: A polynomial-time quantum algorithm for the dihedral hidden subgroup problem

    Simon posted a claimed polynomial-time DCP algorithm on IACR ePrint.

    source
  3. Feb 12, 2026
    qLDPC estimate under 100,000 qubits (preprint)

    The Pinnacle architecture preprint estimated RSA-2048 with fewer than 100,000 physical qubits using qLDPC codes.

    source
  4. May 21, 2025
    Under a million qubits (estimate)

    Gidney estimated under a week on under a million noisy qubits, with the same hardware assumptions; a preprint.

    source
  5. May 23, 2019
    RSA-2048 with 20 million qubits (estimate)

    Gidney and Ekerå estimated 8 hours on 20 million noisy qubits.

    source
  6. Oct 23, 2017
    LWE equals extrapolated DCP
    Related to: A polynomial-time quantum algorithm for the dihedral hidden subgroup problem

    Brakerski, Kirshanova, Stehlé and Wen showed LWE is equivalent to extrapolated DCP.

    source
  7. Apr 1, 2003
    Dihedral cosets and lattices
    Related to: A polynomial-time quantum algorithm for the dihedral hidden subgroup problem

    Regev's reduction from unique-SVP to the dihedral coset problem appeared on arXiv (FOCS 2002).

    source
  8. Feb 14, 2003
    Kuperberg's sieve
    Related to: A polynomial-time quantum algorithm for the dihedral hidden subgroup problem

    Kuperberg gave the first subexponential algorithm.

    source
  9. Feb 14, 2003
    Subexponential dihedral algorithm

    Kuperberg gave a 2O(log⁡N)2^{O(\sqrt{\log N})} quantum algorithm for the dihedral hidden subgroup problem.

    source
  10. Nov 20, 1995
    Abelian stabilizer problem

    Kitaev's phase-estimation approach solved the abelian stabilizer problem, the general abelian hidden subgroup setting.

    source
  11. Nov 1, 1994
    Shor's algorithm at FOCS

    Shor presented polynomial-time quantum algorithms for factoring and discrete logarithms at FOCS 1994 (month only).

    source