I am implementing pollard kangaroo to compute the discrete logarithm of a group element $G$ of generator $g$. $G$ is a$\mod p$ multiplicative group ($p$ a prime number). So, I want to solve $g^a=h$ knowing $a\in[[0,w]]$.
What I am basically doing:
- Define $w=2^{58}$
- I define $k$.
- Split $G$ into $k$ subset $S_i$.
- I define $f(x)=xg^{2 ^ {x \mod k}}$
- From here I make two kangaroo walk alternatively...
The first wild kangaroo : $y_0=h$ and $y_{i+1}=f(y_i)$. I store the values in a Hash map.
The second tame kangaroo : $x_0=int(w/2)$ and $x_{i+1}=f(x_i)$. I store the values in another Hash map.
Whenever a kangaroo value at an iteration is in the other kangaroo hash map, I can easily retrieve the discrete log.
My implementation works if $w$ is very close to $2h$. Otherwise it take a lot of time and memory.
What I think I might have done wrong:
- The distinguisher: I was not able to define a good distinguisher. I am storing all my values of $y_i$ and $x_i$
- The value of $k$ and how I split $G$. I defined the exponents as $e_i = 2^i$ (affecting my definition of $f$). Was that bad?
Any help will be much appreciated. I can even give the code if you are interested but it is really a long code...