We want to continue exploring different methods of factorization, as methods like Pollard's ρ and p−1 have very restrictive constraints that if not met will cause the problem to become degenerate and be as bad as naïve factorization.
In context of RSA, we want to find asymptotically fast methods of factorization to determine the viability of RSA.
If n is a composite with two prime factors, then we can use Fermat's difference of squares method to find the two prime factors.
Fermat's Difference of Two Squares
Given an odd composite integer of the form n=ab, then
ab=(21(a+b))2−(21(a−b))2.
Factorization by Difference of Squares
Sps. n=26217, we have that n≈159. We then notice that n+64=1592.
n=1592−82=(159+8)(159−8)=(167)(151)
It is trivial to check that 167 and 151 satisfies the equality given in the definition of Fermat's difference of two squares.
If a and b are close to n, then Fermat's method is faster than trial division.
However, this is not the case for most odd composites.
Kraitchik realized that we can find more readily find values that satisfy the difference of squares by working in Zn.
Fermat-Kraitchik Method
Find integers u,v satisfying u2≡nv2. Then, for values satisfying u≡n±v we have that (u−v,n) is a non-trivial divisor of n.
If n odd and divisible by at least two unique primes, then the about half of the solutions satisfying u2≡nv2 and (uv,n)=1 will be of the non-trivial form u≡n±v.
An integer is B-smooth if all of its prime factors are less than or equal to B.
de Bruijn Function
Let ψ(x,B) denote the number of B-smooth integers less than or equal to x.
The function can be well approximated as
Ψ(x,B)∼π(B)!1p∈P≤B∏logplogx,
where π(B) is the number of primes less than or equal to B.
The exact definition of the prime counting function π(x) relies on understanding some functions relating to the Riemann hypothesis, which is much outside the current scope.
Another formulation of the de Bruijn function is shown in the following theorem.
de Bruijn Function
Fix an ε∈(0,21), and let x,B→∞ while satisfying
(logx)ε<logB<(logx)1−ε
Let u=logx/logB, then the number of B-smooth numbers less than x satisfies
In Pomerance's Tale of Two Sieves he uses the 3-step method in an example demonstrating Kraitchik's observation[1].
In class, we referred to this method as the 3-step method, but I've found resources referring to the steps done in the 3-step method as the Fermat-Kraitchik method.
Let L(x)=elogxloglogx and let n be a large integer; setting B=L(n)21.
We expect to check approximately L(n)2 random numbers modulo n in order to find π(B)∼B/logB numbers that are B-smooth.
We expect to check approximately L(n)2 random numbers of the form a2(modn) in order to find enough B-smooth numbers to factor n.
Then, we can infer that the 3-step method should have a sub-exponential time complexity and have a high probability of factoring n.
3-step Method
Let n be an integer we aim to find a non-trivial factor of.
Find a1,…,ar such that ci≡nai2
Take a product ∏n=1scin of some ci's such that evey prime appearing in the product appears an even number of times.
∃b,n=1∏scin≡b2(modn)
Let a=∏n=1sain and compute d=(n,a−b).
Since a2≡∏n=1sain≡∏n=1scin≡b2(modn), the value d is likely a non-trivial factor of n.
Generally, the values of ai are chosen randomly and above n to avoid most of the trivial cases in Kraitchik's observation where u≡n±v. As we will see below, the quadratic sieve chooses values of ai by using a quadratic in the form F(t)=t2+n, where t is larger than n.
The Quadratic Sieve is the fastest factorization algorithm we know of for integers of around ∼2350.
Asymptotically, it is faster than Lenstra's elliptic curve factorization but slower than the General Number Field sieve.
We will demonstrate the Quadratic Sieve by way of example rather than precise definition.
Quadratic Sieve
Say we wanted to use the quadratic sieve on n=493.
We will sieve the values of the quadratic function F(t)=t2−493 for t∈[23…38] for 11-smooth numbers.