views:

526

answers:

2

Hi Folks, I'm working on coding the Pohlig-Hellman Algorithm but I am having problem understand the steps in the algorithm based on the definition of the algorithm.

Going by the Wiki of the algorithm: http://en.wikipedia.org/wiki/Pohlig%E2%80%93Hellman_algorithm

I know the first part 1) is to calculate the prime factor of p-1 - which is fine.

However, I am not sure what I need to do in steps 2) where you calculate the co-efficents:

Let x2 = c0 + c1(2). 
125(180/2) = 12590 1 mod (181) so c0 = 0.
125(180/4) = 12545 1 mod (181) so c1 = 0.
Thus, x2 = 0 + 0 = 0.

and 3) put the coefficents together and solve in the chinese remainder theorem.

Can someone help with explaining this in plain english (i) - or pseudocode. I want to code the solution myself obviously but I cannot make any more progress unless i understand the algorithm.

Note: I have done a lot of searching for this and I read S. Pohlig and M. Hellman (1978). "An Improved Algorithm for Computing Logarithms over GF(p) and its Cryptographic Significance but its still not really making sense to me.

Thanks in advance

Update: how come q(125) stays constant in this example: http://www-math.cudenver.edu/~wcherowi/courses/m5410/mid02.html#ans3

Where as in this example is appears like he is calculating a new q each time:L http://www-math.cudenver.edu/~wcherowi/courses/m5410/phexam.html

To be more specific I don't understand how the following is computed: Now divide 7531 by a^c0 to get 7531(a^-2) = 6735 mod p.

+1  A: 

Hi,

I'm coding it up myself right now (JAVA). I'm using Pollard-Rho to find the small prime factors of p-1. Then using Pohlig-Hellman to solve a DSA private key. y = g^x. I am having the same problem..

UPDATE: "To be more specific I don't understand how the following is computed: Now divide 7531 by a^c0 to get 7531(a^-2) = 6735 mod p."

if you find the modInverse of a^c0 it will make sense

Regards

Si
Thanks - I'm really having problems understanding the algorithm - so I can't even start coding!!!I am trying to follow this example:http://www-math.cudenver.edu/~wcherowi/courses/m5410/phexam.htmland this:http://www-math.cudenver.edu/~wcherowi/courses/m5410/mid02.html#ans3You might find this useful if you finish your code and want to test your code:http://www.alpertron.com.ar/DILOG.HTM
David Relihan
+3  A: 

Let's start with the main idea behind Pohlig-Hellman. Assume that we are given y, g and p and that we want to find x, such that

y == gx (mod p).

(I'm using == to denote an equivalence relation). To simplify things, I'm also assuming that the order of g is p-1, i.e. the smallest positive k with 1==gk (mod p) is k=p-1.

An inefficient method to find x, would be to simply try all values in the range 1 .. p-1. Somewhat better is the "Baby-step giant-step" method that requires O(p0.5) arithmetic operations. Both methods are quite slow for large p. Pohlig-Hellman is a significant improvement when p-1 has many factors. I.e. assume that

p-1 = n r

Then what Pohlig and Hellman propose is to solve the equation

yn == (gn)z (mod p).

If we take logarithms to the basis g on both sides, this is the same as

n logg(y) == logg(yn) == nz (mod p-1).

n can be divided out, giving

logg(y) == z (mod r).

Hence x == z (mod r).

This is an improvement, since we only have to search a range 0 .. r-1 for a solution of z. And again "Baby-step giant-step" can be used to improve the search for z. Obviously, doing this once is not a complete solution yet. I.e. one has to repeat the algorithm above for every prime factor r of p-1 and then to use the Chinese remainder theorem to find x from the partial solutions. This works nicely if p-1 is square free.

If p-1 is divisible by a prime power then a similiar idea can be used. For example let's assume that p-1 = m qk. In the first step, we compute z such that x == z (mod q) as shown above. Next we want to extend this to a solution x == z' (mod q2). E.g. if p-1 = m q2 then this means that we have to find z' such that

ym == (gm)z' (mod p).

Since we already know that z' == z (mod q), z' must be in the set {z, z+q, z+2q, ..., z+(q-1)q }. Again we could either do an exhaustive search for z' or improve the search with "baby-step giant-step". This step is repeated for every exponent of q, this is from knowing x mod qi we iteratively derive x mod qi+1.

Accipitridae
Does that mean there's a quicker way when calculating the coeficients for 350377^4 that we don't have to go from 0..350377 calculating all the cofficients
David Relihan
Yup, you can always use Baby-step giant-step. I've added a link to the wikipedia article that explains this algorithm. With this algorithm the largest loop that you need should have about sqrt(350377) iterations.
Accipitridae