Shor’s Algorithm

The quantum algorithm that factors integers exponentially faster than any known classical algorithm, threatening RSA encryption.


Shor’s algorithm, discovered by Peter Shor in 1994, efficiently factors large integers. This is devastating for RSA and similar cryptosystems that rely on factoring being hard.

The Impact

Classical factoring of an -bit number: (best known) Quantum factoring with Shor’s: or better

For a 2048-bit RSA key:

  • Classical: Millions of years
  • Quantum: Hours to days (with a large fault-tolerant quantum computer)

How It Works

Shor’s algorithm has two main parts:

1. Classical Reduction

Factoring is reduced to period finding:

  • Pick random (the number to factor)
  • Find the period of
  • Use to find factors via

2. Quantum Period Finding

This is the quantum part:

  1. Create superposition over all :
  2. Compute quantumly:
  3. Apply Quantum Fourier Transform to first register
  4. Measure to get information about the period

The QFT causes interference that reveals the period with high probability.

Circuit Overview

|0⟩^n ──H^⊗n──┬─── QFT ── Measure ──→ period info
              │
|0⟩^m ────────⊕── (modular exponentiation)

Resource Requirements

To factor an -bit number:

  • Qubits: (roughly qubits)
  • Gates: (dominated by modular exponentiation)
  • T-gates: Many millions for cryptographically relevant sizes

Current Status

MilestoneStatus
Factor 15Done (2001, with tricks)
Factor 21Done (2012)
Factor 2048-bitRequires ~4000 logical qubits, millions of physical qubits

We’re far from breaking real-world RSA. But it’s a matter of engineering, not fundamental obstacles.

Implications

  1. Cryptographic transition: Moving to post-quantum cryptography
  2. Security timeline: Data encrypted today could be decrypted later (“harvest now, decrypt later”)
  3. Motivation for quantum computing: Major driver of quantum research and funding

Variants

  • Simplified Shor’s: For specific numbers with known structure
  • Quantum resource estimation: Ongoing research to reduce requirements
  • Hybrid approaches: Some classical preprocessing

Historical Note

Shor’s algorithm was the “killer app” that launched serious interest in quantum computing. It showed quantum computers could solve a problem of real-world importance exponentially faster.


See also: Quantum Fourier Transform, Quantum Phase Estimation, Post-Quantum Cryptography, Quantum Advantage