An Overview of Integer Factoring Algorithms
Manindra Agrawal IITK / NUS
The Problem
Given an integer n, find all its prime
divisors as efficiently as possible.
A Difficult Problem …
• No efficient algorithm (= taking time (log n)
c) is know for the problem.
• The fastest known algorithm takes time exp( c (log n)
1/3(loglog n)
2/3) with c ≈ 1.9.
• With this, we can factor 140 digit numbers in reasonable time.
• It is believed that no efficient algorithm exists.
… Useful in Cryptography
• RSA cryptosystem’s security is based on hardness of factoring.
• Several other cryptosystems rely on
this problem as well.
We present an overview of the known factoring algorithms.
#1: Trial Division
Divide n with all primes up to √ n starting from 2 and collect all divisors.
• A very simple algorithm.
• Takes time exp(½ log n) = L(1, ½).
Notation: Denote exp(c(log n)
ε(loglog n)
1-ε)
#2: Pollard’s Rho Method
1. Randomly select x
0∈ {1, 2, …, n-1}, and compute x
i= x
i-12+ 1 (mod n) for i = 1, 2, … 2. Compute gcd(x
i– x
2i, n) until a factor is
found.
• Discovered by J. Pollard in 1975.
• Takes time L(1, ¼).
• Used to factorize eighth Fermat number 2
28+ 1, a 78 digit number.
x0
Pollard’s “Rho” Shape
x1
x2
xt = xm
xt+1
xt+2
xm-1 xm-2
Analysis
• Let p be the smallest prime factor of n, so p
< √n.
• Number sequence x
0, x
1, x
2, … behaves randomly modulo p.
• So the probability that x
t= x
m(mod p) for t
< m is roughly 1/√p.
• Notice that if x
t= x
m(mod p), then x
t+k= x
m+k(mod p) for all k > 0.
• Therefore, there exists a s < 2t with x
s= x
2s(mod p).
• Again using randomness of the
sequence, with probability at least ½, x
s≠ x
2s(mod n).
• Therefore, p | gcd(x
s– x
2s, n) < n.
• For good probability of success, we need to generate roughly √ p = n
1/4x
i’s.
• So the time complexity is exp(¼log n).
#3: Pollard’s p-1 Method
1. Fix a factor base = set of all primes ≤ B.
2. Compute m = ∏
q prime, q ≤Bq
log n.
3. Compute gcd(a
m-1, n) for a random a.
• Discovered by J. Pollard in 1974.
• Takes time O(B (log n)
2).
• Works if prime p | n and p-1 has no prime divisor greater than B.
Fermat’s Little Theorem
If p is prime then for all a with gcd(a, p) = 1, a
p-1= 1 (mod p).
• In other words, the set of numbers { a | 0 < a < p }
forms a group of size p-1 under
multiplication modulo p.
Analysis
• Suppose prime p | n and p-1 has no factor greater than B.
• This implies that p-1 | m.
• So, by Fermat’s Little Theorem, p divides a
m-1.
• So it might be found when computing gcd(a
m-1, n).
Useful only for a subset of numbers n.
#4: Elliptic Curve Method
• Previous method works only for n’s with a prime divisor p such that p-1 is a product of small primes.
• It is always true that a number m
“close” to p will have this property.
• So if we can work with a group of size
m, instead of p-1, the method will work
for all numbers.
Elliptic Curves
• Elliptic curve E(a,b) has the following form:
y
2= 4x
3- ax – b; a
3– 27 b
2≠ 0
• The set of points on an elliptic curve form a group under “addition.”
• We consider elliptic curves modulo n.
• The number of points on an elliptic curve modulo prime p (= #E
p(a,b)) is between p+1- 2√p and p+1+2√p.
Curve y
2= 4x
3- 4x
A
B
-C
C
Addition on curve: A + B = C; E + F = O, point at infinity
E F