]> Cryptography - Factoring and Discrete Logarithms

The most obvious approach to breaking modern cryptosystems is to attack the underlying mathematical problem.

  1. Factoring: given N=pq,p<q,pq, find p,q.

  2. Discrete logarithm: Given p,g,g xmodp, find x.

Classical Algorithms

  1. Brute force, e.g. trial division, which has running time O(p)=O(N 1 /2 ).

  2. Baby-step-giant-step, Pollard-Rho, Pollard kangaroo. All have running time O(p 1 /2 )=O(N 1 /4 ). (Also, these are the best known methods for solving discrete log on a general cyclic groups.)

Example: For factoring: it is known that using FFT, given f N[x] of degree d, and given x 1 ,...,x d N, computing f(x 1 ),...,f(x d) can be done in time O(dlogd) and space O(d), which implies the existence of a simple O(N 1 /4 ) factoring algorithm.

Modern Algorithms

Define a function

L a,b(N)=e b(logN) a(loglogN) 1 a

Then note that

L 0 ,b(N)=(logN) b

which is polynomial in the number of bits in N, and

L 1 ,b(N)=N b

which is exponential in the number of bits in N. For values of a in between we get subexponential functions, i.e. functions that grow faster than polynomials but slower than exponentials.

Here is a list of some factoring algorithms and their running times. With the exception of Dixon's algorithm, these running times are all obtained using heuristic arguments. We shall see that discrete logarithm algorithms for finite fields are similar.

  1. Dixon's Algorithm: L 1 /2 ,2 (N)=e 2 logNloglogN

  2. Continued Fractions: L 1 /2 ,2 (N)=e 2 logNloglogN

  3. Quadratic Sieve: L 1 /2 ,1 (N)=e logNloglogN. RSA-129 was solved using this method.

  4. Elliptic Curve: L 1 /2 ,2 (p)=L 1 /2 ,1 (N). Unlike the other algorithms this one takes only polynomial space; the other algorithms have space bounds that are on par with their time bounds.

  5. Number Field Sieve ['88]: L 1 /3 ,1.902 (N)e 3 logN. RSA-512 was solved with this method.

The approach these algorithms take is to find random solutions to x 2 =y 2 modN. Given such a solution, with probability 1 /2 , we have that gcd(xy,N) or gcd(x+y,N) is a prime factor of N.

Dixon's Algorithm

The first part of the algorithm, known as the sieving step, finds many relations of a certain form. The second part, known as the linear algebra step, uses the relations to find a solution to x 2 =y 2 modN.

  1. Pick a random x[1 ,N] and compute z=x 2 modN

  2. Test if z is S-smooth, for some smoothness bound S, i.e. if all prime factors of z are less than S. If so, then z= i=1 kl i α i where k is the number of primes less than S, and record z

  3. Repeat until r relations are found, where r is a number like 10 k.

  4. We have r relations (modulo N), for example:

x 1 2 = 2 2 3 4 5 1 ...l k 0 x 2 2 = 2 0 3 1 5 3 ...l k 1 x r 2 = 2 0 3 2 5 0 ...l k 2

We wish to find a subset of these relations such that the product of the right-hand sides is a square, that is, all the exponents are even: let A be a k×r exponent matrix, where A ij=α i in the jth relation. Then find a nonzero vector y 2 r such that Ay=0 modulo 2. Then y describes a subset of relations that will multiply to give a perfect square on the right-hand side.

It remains to optimize S. Define Dixon's function as follows:

ψ(x,s)={a1 ,...,SaisS-smooth}

Then if use the heuristic that the proportion of S-smooth numbers amongst the possible values of z is the same as the proportion of S-smooth numbers amongst all numbers less than N, then

ψ(x,s)/x=Pr x{1 ,...,N}[xisS-smooth]u u

where u=x/s, a result due to de Bruijn.

The sieving step is faster when S is larger, and the linear algebra step is faster when S is smaller, so S must be chosen carefully. It turns out the optimum value for S is

S=L 1 /2,2 (N)

which is also the algorithm's running time. (In fact, because of the simplicity of Dixon's algorithm, it is possible to derive these bounds non-heuristically.)

The matrix involved in the linear algebra step is sparse, and to speed up the algorithm, many specialized optimizations have been developed. Note also that it is easy to distribute the sieving step amongst many machines, and furthermore, verifying that the computed relations are correct is cheap (i.e. robustness is free unlike other distributed computation problems, e.g. SETI@home).

Quadratic Sieve

Define f a(x)=(x+aN 2 )aN. Then since yy 2 y, we have f a(x)x 2 +2 xaNaN. When x<N we have f a(x)aN.

Then pick a small random a{1 ,...,k}. Find all x[B,B] (we shall describe how to do this later) such that f a(x) is S-smooth, where S,B,k will be determined later. For such x we have a relation

(x+aN 2 )= i=1 kl i α i

modulo N, and as before with enough of these we can proceed to the linear algebra step.

Note that f a(x)<aN which means it is more probable that it is S-smooth than an integer on the order of N (which is what is required in Dixon's algorithm).

To find all suitable x[B,B]: initialize an array of integers v indexed from B to B with zero. For each small prime l i, increment v[x] if f a(x)=0 modl i. Doing this requires a simple linear scan: if β 1 ,β 2 are the roots of f a(x) in l i then for every y, we increment v[y] if y=β 1 or y=β 2 modulo l i.

With optimal B,S,k, we have that the running time is L 1 /2,1 (N) if we use the heuristic that f a(x) is uniformly distributed.

Number Field Sieve

In this method, sieving is done in number fields. Define d=(logN/loglogN) 1 /3 , and let m=N 1 /d. Write N=m d+f d1 m d1 +...+f 0 , i.e. N in base m, and define the polynomial f(x)=x d+f d1 x d1 +...+f 0 , so by construction f(m)=0 (modN).

With overwhelming probability, f is irreducible, so define the field K=[x]/f(x). Then find many pairs (a,b) where 0 a,bL 1 /3,0.901 (N) such that

  1. abm is L 1 /3,0.901 (N)-smooth.

  2. N K(abx) is L 1 /3,0.901 (N)-smooth, where N K is the norm on K.

It turns out each pair yields a relation modulo N that can be used in the linear algebra step.

Discrete Logarithm

Suppose our input is y=g α(modp). Then pick a smoothness bound S, and proceed with index calculus:

  1. Pick random r,a p and set z=y rg amodp.

  2. Test if z is S-smooth. If so then

    y rg a= i=1 kl i α i
  3. Repeat until many (e.g. 10 k) relations are obtained.

4. We have many relations of the form rlog gy+a= i=1 ka ilog gl i(modp1 )

Use linear algebra to solve for log gy=α and each log gl i.