Back to Learn
Advanced
AlgorithmsShor's Algorithm: Factoring in Polynomial Time
15 min read 11 views 0
Shor's algorithm, proposed by Peter Shor in 1994, can factor integers in polynomial time on a quantum computer — exponentially faster than the best known classical algorithms.
The Key Insight
Factoring reduces to finding the period of a function. Quantum computers can find periods efficiently using the Quantum Fourier Transform (QFT).
Algorithm Steps
- ▸Choose a random number a < N (the number to factor)
- ▸Compute gcd(a, N); if > 1, we found a factor
- ▸Use quantum period-finding to find the period r of f(x) = aˣ mod N
- ▸If r is even, compute gcd(a^(r/2) ± 1, N) to find factors
The QFT
The Quantum Fourier Transform maps a periodic state to its frequency domain. It runs in O((log N)²) gates — exponentially faster than the classical FFT.
Impact on Cryptography
Shor's algorithm breaks RSA, ECC, and Diffie-Hellman. This motivates the development of post-quantum cryptography.
shor
factoring
QFT
cryptography
RSA