Feedback — Week 5 - Programming Assignment [optional: extra credit] You submitted this homework on Tue 8 Jan 2013 2:10 AM GMT +0000. You got a score of 1.00 out of 1.00.
Question 1 Your goal this week is to write a program to compute discrete log modulo a prime p. ∗
Let g be some element in h = g
x
where
Z
p
and suppose you are given
40
1 ≤ x ≤ 2
. Your goal is to find
x.
h
in
∗
such that
Z
p
More precisely, the input to
your program is p, g, h and the output is x.
40
The trivial algorithm for this problem is to try all 2 correct one is found, that is until we find an
x
possible values of x until the
satisfying
h = g
x
in
Zp .
This
requires 240 multiplications. In this project you will implement an algorithm that runs −− − 40
20
in time roughly √2
Let B
20
= 2
. Since
x = x0 B + x1
h = g
x
= g
= 2
using a meet in the middle attack.
is less than
x
where
x0 , x1
x0 B+x1
= (g
B
2
we can write the unknown
are in the range
B
x0
)
⋅ g
x1
in
[0, B − 1].
x
base
B
as
Then
Zp .
By moving the term g x to the other side we obtain 1
h/g
x1
= (g
B
x0
in
)
Zp .
The variables in this equation are given
g, h
and
20
B = 2
x0 , x1
and everything else is known: you are
. Since the variables x0 and
x1
are now on different sides
of the equation we can find a solution using meet in the middle (Lecture 3.3): First build a hash table of all possible values of the left hand side 20
Each of these three numbers is about 153 digits. Find
x
such that h
= g
x
in
Zp .
To solve this assignment it is best to use an environment that supports multiprecision and modular arithmetic. In Python you could use the gmpy2 or numbthy modules. Both can be used for modular inversion and exponentiation. In C you can use GMP. In Java use a BigInteger class which can perform mod, modPow and modInverse operations. You entered: 375374217830