Shor's Algorithm: Factoring Semi-Primes and Breaking RSA
Introduction to Shor's Algorithm
Purpose: Shor's algorithm is designed to factor numbers of the form , specifically semi-primes.
Significance: Semi-primes are critical for the security of the RSA cryptosystem, making Shor's algorithm a direct threat to current internet security if large-scale quantum computers are built.
Classical Factoring Limitations: Prior best-known classical algorithms (e.g., trial division, Pollard's Rho) for factorinlutg a large number (product of two primes) are exponential or at least super-polynomial in the size of (where size represents the number of bits of ).
Quantum Advantage: Shor's algorithm on a quantum computer can solve this factoring problem in approximately time. This stark difference means RSA is vulnerable to sufficiently large quantum computers.
Algorithmic Paradigm: Shor's algorithm implements concepts like divide and conquer on a quantum computer, with the core operation being the Quantum Fourier Transform (QFT).
Quantum Fourier Transform (QFT): This is the quantum analogue of the classical Fast Fourier Transform (FFT) and is central to Shor's algorithm. It was studied earlier in the course sequence (part of course three).
High-Level Steps of Shor's Algorithm
Conversion to Order Finding: Shor's algorithm transforms the factoring problem into an order finding problem, which is a version of the discrete logarithm problem.
Periodic Function: The algorithm relies on finding the unknown period of a periodic function. Quantum computers are particularly adept at this task.
Pioneering Work: While called Shor's algorithm, it incorporates contributions from other works, such as quantum phase estimation by Kitaev.
Impact: Shor's algorithm is the first known algorithm to demonstrate an exponential speedup on a quantum computer compared to classical computers for a significant problem, fueling immense interest and research in quantum computing.
Post-Quantum Cryptography: The potential threat to RSA has spurred development in post-quantum cryptography, with solutions already being explored as of 2024.
Number Theory Basis (Classical Component)
Goal: Given , where and are unknown primes, the objective is to find and .
Step 1: Choose a Random Integer :
Select a random integer such that and .
Note: If , then shares a factor with , meaning we would have already found a factor like or . However, the probability of this happening for a large is extremely low.
Step 2: Explore Powers of Modulo :
Examine the sequence: .
Periodicity: Since is relatively prime to , can never be . As there are only possible residues ( to ), the sequence must eventually repeat.
If , then due to (implying has a multiplicative inverse modulo ), it must be that . This signifies a periodic sequence.
Definition of Order ():
The order of modulo , denoted as , is the smallest positive integer () such that .
Examples with :
Example 1: Let .
The order of modulo is .
Example 2: Let .
The order of modulo is .
Example 3: Let .
The order of modulo is .
Factoring Using the Order (Classical Success Conditions)
Premise: If we can find the order of modulo (where ), we can potentially find a factor of .
Condition 1: must be an even number.
If is even, we can write for some integer .
Then , which implies .
Rewriting, we get , or .
Condition 2: .
This condition is crucial. It is guaranteed by the definition of as the smallest positive integer such that . If , then . Since and , this would contradict being the smallest order.
Factoring Step: If both conditions are met (i.e., is even AND ), then will yield a non-trivial factor of (either or ).
This works because is a multiple of , and neither nor is a multiple of . Thus, (or ) must divide one term, and (or ) must divide the other.
Probability of Success: For a randomly chosen coprime , the probability that is even AND is typically greater than . Repeated trials with different values significantly increase the chances of success.
Example with :
Order , which is even. .
. . So Condition 2 holds.
. . This is not . So holds.
. A factor (5) successfully pops out.
Example with :
Order , which is even. .
. .
. .
. A factor (3) successfully pops out.
The Quantum Advantage: Finding the Order
Classical Difficulty: Classically, finding the order of modulo is computationally hard. The best classical approach is to compute powers until is found, which can take up to steps. Since can be comparable in size to , this problem is as hard as factoring itself and is related to the discrete logarithm problem.
Quantum Solution: Shor's algorithm provides a quantum component specifically for order finding. Given and , the quantum algorithm can find with very high probability in polynomial time (in the number of bits of ).
Overall Efficiency: This efficient quantum order-finding step, combined with the successful classical steps, allows Shor's algorithm to factor in polynomial time on a quantum computer, making it exponentially faster than any known classical factoring algorithm.