An Efﬁcient Collision Detection Method for Computing Discrete Logarithms with Pollard’s Rho

Pollard’s rho method and its parallelized variant are at present known as the best generic algorithms for computing discrete logarithms. However, when we compute discrete logarithms in cyclic groups of large orders using Pollard’s rho method, collision detection is always a high time and space consumer. In this paper, we present a new e ﬃ cient collision detection algorithm for Pollard’s rho method. The new algorithm is more e ﬃ cient than the previous distinguished point method and can be easily adapted to other applications. However, the new algorithm does not work with the parallelized rho method, but it can be parallelized with Pollard’s lambda method. Besides the theoretical analysis, we also compare the performances of the new algorithm with the distinguished point method in experiments with elliptic curve groups. The experiments show that the new algorithm can reduce the expected number of iterations before reaching a match from 1.309 (cid:2) | G | to 1.295 (cid:2) | G | under the same space requirements for the single rho method.


Introduction
One of the most important assumptions in modern cryptography is the hardness of the discrete logarithm problem DLP .Many popular cryptosystems base their security on DLP.Such cryptosystems are, for example, the Diffie-Hellman key agreement protocol 1 , the ElGamal signature and encryption schemes 2 , the US Government Digital Signature Algorithm DSA 3 , and the Schnorr signature scheme 4 .Originally, they worked with multiplicative groups of finite prime fields.Once elliptic curve cryptosystems were proposed by Koblitz 5 and Miller 6 , analogous practical systems based on the DLP in groups of points of elliptic curves over finite fields were designed 7 .Recall the following two definitions.
Definition 1.1 discrete logarithm problem, DLP .Let G be a cyclic group of prime order p, and let g ∈ G be generator of G. Given g, h ∈ G, determine the integer 0 ≤ k < p such that h g k .

Preliminary
In this section, we describe Pollard's rho method for discrete logarithm computation and then discuss several collision detection algorithms and their performances.Pollard 8 proposed an elegant algorithm for the discrete logarithms based on a Monte Carlo idea and called it the rho method.The rho method works by first defining a sequence of elements that will be periodically recurrent, then looking for a match in the sequence.The match will lead to a solution of the discrete logarithm problem with high probability.The two key ideas involved are the iteration function for generating the sequence and the cycle-finding algorithm for detecting a match.

Pollard's Rho Method
If D is any finite set and F : D → D is a mapping and the sequence X i in D is defined by the rule: this sequence is ultimately periodic.Hence, there exist unique integers μ ≥ 0 and λ ≥ 1 such that X 0 , . . ., X μ λ−1 are all distinct, but X i X i λ for all i ≥ μ.A pair X i , X j of two elements of the sequence is called a match if X i X j where, i / j.For the expected values of μ and λ, we have the following theorem.
Theorem 2.1 see 17 .Under the assumption that an iteration function F : D → D behaves like a truly random mapping and the initial value X 0 is a randomly chosen group element, the expected values for μ and λ are π|D|/8.The expected number of evaluations before a match appears is E μ λ π|D|/2 ≈ 1.25 |D|.
Now we explain how the rho method for computing discrete logarithms works.Let G be a cyclic group of prime order p, and let g ∈ G be generator of G and h ∈ G.The discrete logarithm problem is to compute x satisfying g x ≡ h.Pollard defined the iteration function F : G → G as follows:

2.2
Let the initial value Y 0 1.In each iteration of Y i 1 F Y i , the function uses one of three rules depending on the value of Y i .The group G is partitioned into three subsets S 1 , S 2 , S 3 of roughly equal size.Each Y i has the form g a i h b i .The sequence a i and similarly for b i can be computed as follows:

2.3
As soon as we have a match Y i , Y j , we have the equation g a i * h b i g a j * h b j .Since h g x , this gives Due to the method of Pohlig and Hellman 18 , in practice applications the group order p is prime, so that it is very unlikely that gcd b i − b j , p > 1 if p is large.Theorem 2.1 makes the assumption of true randomness.However, it has been shown empirically that this assumption does not hold exactly for Pollard's iteration function 19 .The actual performance is worse than the expected value given in Theorem 2.1.
Teske 19 proposed better iteration functions by applying more arbitrary multipliers.Assume that we are using r partitions multipliers .We generate 2r random numbers, 2.5 Then we precompute r multipliers M 1 , M 2 , . . ., M r , where M i g m i • h n i , for i 1, 2, . . ., r. Define a hash function, Then the iteration function where v Y ∈ {1, 2, . . ., r}.

2.7
The indices are update by The difference in performance between Pollard's original walk and Teske's r-adding walk has been studied in 19, 20 .We summarize the results as follows.In prime order subgroups of Z * p , the value of E μ λ for Pollard's original walk and Teske's r-adding walk is 1.55 |G| and 1.27 |G|, while in groups of points of elliptic curves over finite fields, the value is 1.60 |G| and 1.29 |G|, respectively.

Previous Methods for Collision Detection
To find the collision in the pseudo-random walk, it always needs much storage.In order to minimize the storage requirements, a collision detection algorithm can be applied with a small penalty in the running time.The best running time requires μ iterations and the worst takes μ λ iterations.Under the assumption that F : G → G behaves like a truly random mapping, the expected number of iterations before reaching a match is π 5 |G|/288 ≈ 1.03 |G| 20 .The key point for this algorithm is that we need three group operations and one comparison for each iteration, which makes it inefficient.

Brent's Algorithm
Brent proposed an algorithm 12 which is generally 25% faster than Floyd's method.It uses an auxiliary variable, say w, which at each stage of the algorithm holds Y l i −1 , where l i 2 log i .w is compared with Y i for each iteration and is updated by w Y i when i 2 k − 1 for k 1, 2, . ... The correctness of this algorithm depends on the following fact.
Under the assumption that F : G → G is a random mapping, with Brent's algorithm the first match is expected to occur after 1.98 |G| iterations 12 .The algorithm needs one group operation and one comparison for each iteration, which makes it 25%-30% faster than Floyd's algorithm.Variations of Brent's algorithm requiring slightly more storage and comparisons but less iterations can be found in 21, 22 .

Stack Algorithm
In 2004, Nivasch proposed an interesting algorithm that uses logarithmic storage space and can be adapted with tradeoff for storage space versus speed.This algorithm requires that a total ordering < be defined on the set G, and it works as follows.Keep a stack of pairs Y i , i , where, at all times, both the i's and the Y i 's in the stack form strictly increasing sequences.The stack is initially empty.At each step j, pop from the stack all entries Y i , i , where Y i > Y j .If a match Y i Y j is found with an element in the stack, the algorithm terminates successfully.Otherwise, push Y j , j on top of the stack and continue.The stack algorithm depends on the following fact.Theorem 2.4 see 13 .The stack algorithm always halts on the smallest value of the sequence's cycle, at some time in μ λ, μ 2λ .
Under the assumption that F : G → G is a random mapping, the expected number of iterations before finding a match is 5/2 π|G|/8 ≈ 1.57 |G| 13 .The algorithm needs a little bit more than one group operation and one comparison for each iteration.Under the same assumption, Nivasch proves also that the expected size of the stack is ln h O 1 .Therefore, the algorithm only requires a logarithmic amount of memory.

Distinguished Point
The idea of the distinguished point method is to search for a match not among all terms of the sequence, but only among a small subset of terms that satisfy a certain distinguishing property.It works as follows.One defines a set D, a subset of G, that consists of all group elements that satisfy a certain distinguishing property.During the pseudo-random walk, points that satisfy the distinguishing property are stored.Collision can be detected when a distinguished point is encountered a second time.
Currently, the distinguished point method is the most efficient algorithm to detect collisions in pseudo-random walk when |G| is large.A popular way of defining D is to fix an integer k and to define that w ∈ D if and only if the k least significant bits in the representation of w as a binary string are zero.To break ECC2K-130, it 23 defines the distinguishing property as the Hamming weight of normal-basis representation of x-coordinate of the point less than or equal to 34.Notice that this kind of definitions allows a fast check for the distinguishing property to hold, and the size of D can be easily monitored as well.Obviously, we have the following theorem.
Theorem 2.5 see 11 .Let θ be the proportion of points in G which satisfy the distinguishing property, that is, θ |D|/|G|.Under the assumption that F : G → G is a random mapping and D is a uniform distribution in G, the expected number of iterations before finding a match is π|G|/2 1/θ.

The New Algorithm
We are motivated by the fact that, in distinguished point method, the distinguished points may be not uniformly distributed in the pseudo-random walk, also the points in subset D may be not uniformly distributed in G, which always results in more iteration requirements.We are trying to design an algorithm which leads to a uniform distribution and also to provide a better way for time-space tradeoff rather than distinguishing property.

The Basic Algorithm
To find a collision in pseudo-random walk, which is produced by the iteration function F : G → G, assuming F is a random mapping on G, our basic algorithm works as follows.We fix an integer N and use an auxiliary variable, say w, which at each N iterations keep the minimum value of N successive values produced by the iteration function F. Once getting the minimum value w from N successive values, we check whether this value has occurred before in the stored sequence, if so, we find the match and we are done.Otherwise, store this value w to the sequence.Then continue to compute the next N new values and repeat the previous procedures.Choose the integer N properly, we will find the match among the newly generated minimum value and stored minimum values.
More precisely, to find a collision in pseudo-random sequence Y 0 , Y 1 , Y 2 , . .., which is produced by the iteration function F : G → G, we have Algorithm 1.
It is obvious that the algorithm can be considered as two parts.In the first part, that is from step 3 to step 11 , we seek the minimum value w from N successive values in the pseudo-random walk.The operation is very simple; if the current value Y j is smaller than w, then just update w with the current value and continue the next iteration.Notice that steps 7 , 8 , and 9 can be omitted, since it is unlikely that there is a match within N iterations.Even if it happened, the algorithm ensures that we can find a match within the next N iterations.As a result, there is only one group operation and one comparison in the first part, which consist the main operations of the algorithm.
In the second part, that is from step 13 to step 19 , once we get a minimum value w, we check whether w has appeared before in the previous stored values u k , which is empty at the beginning.If this is the case, the algorithm will return the corresponding indices and we are done.Otherwise, save the value w to the sequence u k of the minimum values, and the second part is finished, continue the next N iterations.It is clear that the second part can be speeded up by using a hash table.And, more important, the second part can be independent to the first part, which means the stored sequence of minimum values can be off line; that is, the first part is response for generating minimum values along the random walk, while the second part searches the collision among stored minimum values independently.

Analysis
For further analysis of the algorithm, we assume that the iteration function F : G → G behaves like a truly random mapping.According to Theorem 2.1, the expected number of iterations before reaching a match is π|G|/2.Let us look at some simple cases for the new algorithm.For N 1, which means we store all the values in the sequence before reaching a match, and the match can be found once it appears.For N 2, we need to store half of the values in the sequence before reaching a match, and always the match can be found once it appears.Obviously, the bigger the integer N, the less values we need to store.As a result, with the integer N increasing, there is a probability that we cannot detect the collision immediately when it happens.So, the new algorithm is a probabilistic algorithm.However, Journal of Applied Mathematics with high probability, the algorithm will halt close to the beginning of the second loop.More precisely, we have the following theorem.Theorem 3.1.Under the assumption that an iteration function F : G → G behaves like a truly random mapping and the initial value Y 0 is a randomly chosen group element, for Algorithm 1, the expected number of iterations before finding a match is π|G|/2 k 1/2 N with probability 1 − 2/3 k−1 /2, where k 0, 1, 2, . ... Proof.Let I i be the set that consists of the ith N successive values generated by iteration function F; that is, For finite group G, the sequence produced by F is eventually period; that is, for any fixed F and Y 0 , there exist certain integers m and n, such that and also To prove the theorem, we divide it into two cases, that is, k 0 and k 1, 2, . ... For k 0, let min m and min n be the minimum values of I m and I n , then Pr min that is, the probability of successfully detecting the collision within the first two intersection sets is 1/4.For each of k 1, 2, . .., we notice that, for two intersected sets I i and I j , let min i and min j be the minimum values of I i and I j , respectively, we have Pr min i min j I i I j 2 N 2 , where I i I j denotes the cardinality of I i I j . 3.5 Therefore, we have Pr min

3.6
Under the assumption that the iteration function F : G → G is a random mapping, according to Theorem 2.1, the expected number of evaluations before a match appears is π|D|/2.
Combining the above two cases, using Algorithm 1, the expected number of iterations before reaching a match among minimum values is π|G|/2 k 1/2 N with probability 1 − 2/3 k−1 /2, where k 0, 1, 2, . ... Remark 3.2.According to the above theorem, we need to store π|G|/2/N k terms to find the match with the probability 1 − 2/3 k−1 /2, where k can be 0, 1, 2, . ..; that is, by setting parameter N, we can balance the expected number of iterations and the expected space requirements.Therefore, Algorithm 1 is a time-space trade-off algorithm.
Remark 3.3.Algorithm 1 is a probabilistic algorithm.There is a probability that we cannot detect the collision immediately when it happens.However, with high probability, the algorithm will halt close to the beginning of the second loop.For example, the probability of successfully detecting the collision 1 − 2/3 k−1 /2 is 0.90 with k 5.
Notice that, compared to the distinguished point method, the new algorithm has two advantages.First, the distinguished point method depends on the assumption that the distinguished points are uniformly distributed in the pseudo-random walk, and also the points in subset D are uniformly distributed in G.However, in practice this may not be the case, which generally results in more iterations requirement, while, for the new algorithm, each stored minimum value represents N successive values and the performance of the new algorithm independent of such assumption.Because the distinguished point method is currently the most efficient algorithm, we compare the actual performances of the new algorithm with the distinguished point method under the same expected storage requirement in experiments with elliptic curve groups in Section 5.
Second, using distinguished point method, it is possible for a random walk to fall into a loop which contains no distinguished point 11 .Then, the processor cannot find new distinguished point any more on the path.Left undetected, the processor would cease to contribute to the collision search.In this case, we can restart the random walk by choosing a different initial point.However, those points calculated by previous walk do not help for the collision search, while the new algorithm can avoid such problem, because it can always find the collision among minimum values whenever it falls into a loop.

Applications
The new algorithm can be combined with other algorithms, such as Pollard's lambda method, and can be adapted to a wide range of problems which can be reduced to finding collisions, Journal of Applied Mathematics such as in Pollard's rho method for factorization 24 and in studying the behavior of random number generators 25 .In this section, we will address some of these issues.

Pollard's Lambda Method
It is clear that the new algorithm can be applied to Pollard's lambda method also called the kangaroo method .The lambda method computes a discrete logarithm in an arbitrary cyclic group, given that the value is known to lie in a certain interval, that is, h g k , where k ∈ a, b but unknown.
Generally, we have two kangaroos, one tame and one wild.Their positions are represented by group elements, the tame kangaroo T with starting point t 0 g a b /2 and the wild kangaroo W with starting point w 0 h, and they travel in the cyclic group G g .In terms of the exponents of g, T starts at the middle of the interval a, b , while W starts at x. Since we do not know k, we do not know the exact location of the wild kangaroo, and that is why it is called wild.The two kangaroos produce two different pseudo-random walks with the same walking rules.It is obvious that, at all times, the point of tame kangaroo has the form g i and the point of wild kangaroo has the form h * g j for some known integers i and j.The purpose is to provoke a collision between the tame and the wild kangaroos, from which we can deduce the wild kangaroo's starting point, that is, k i − j mod |G|.Similar to the case of Pollard's rho method, the new algorithm can be applied in this case to efficiently detect the collision.The advantage of the new algorithm is that we can achieve uniform distributions of minimum values in the pseudo-random walks both for the tame kangaroos and the wild kangaroos.The different performances of the new algorithm and distinguished point method in this case can refer to the case of Pollard's rho method.

Parallelization
As we have mentioned above, during the random walk, finding the minimum value from N iterations and comparing the minimum value w to all previously stored values can be separated.This feature makes the new algorithm suit for distributed computation.
However, Pollard's rho method is inherently serial in nature; one must wait for the current iteration of the function F to complete before the next can begin.Each value in the sequence totally depends on the previous value and the iteration rules.In discussing the rho method for factorization, Brent considered running many processors in parallel each producing an independent sequence and noted that "Unfortunately, parallel implementation of the "rho" method does not give linear speedup" 26 .Analogous comments apply to the rho method for computing logarithms and the generalized rho method for collision search.Notice that here each parallel processor is producing its own sequence of points independently of the others and each particular processor does not increase the probability of success of any other processor.For the corresponding picture, with high probability, each processor draws a different "rho" that never intersect with each other.There is a little chance that different processors may intersect with each other.
van Oorschot and Wiener 11 showed that the expected speedup of the direct parallelization of Pollard's rho method, using m processors, is only a factor of √ m.This is a very inefficient use of parallelization.They provided a modified version of Pollard's rho method and claimed that it can be linearly parallelized with the distinguished point method; that is, the expected running time of the modified version, using m processors, is roughly π|G|/2/m group operations.
In the modified version, to perform a parallel collision search each processor proceeds as follows.Select a random starting point Y 0 ∈ G, and produce the trail of points Y i 1 F Y i , for i 0, 1, 2, . .., until a distinguished point Y d is reached based on some easily testable distinguished property.Store distinguished point, and start producing a new trail from a new random starting point.Unfortunately, the new algorithm is not efficient for the parallelized modified version of Pollard's rho method.The key point is that there is a probability that the new algorithm fails to detect the collision while it actually happened, which cannot be efficiently solved like the serial version.
However, for Pollard's lambda method, the new algorithm can be efficiently parallelized with linear speedup.We present here a modified version of parallelized Pollard's lambda method from 11 .Assume we have m processors with m even.Then, instead of one tame and one wild kangaroo, we work with two herds of kangaroos, one herd of m/2 tame kangaroos and one herd of m/2 wild kangaroos, with one kangaroo on each processor.Each kangaroo starts from a different point, stores a minimum value every N iterations, just like the serial version.A center server collects all the minimums, and tries to find a collision between the tame kangaroo minimums and the wild kangaroo minimums By choosing a reasonable integer N, the new algorithm provides an optimal time-space trade-off method for collision detection.

Experiments
We implemented Pollard's rho method with elliptic curve groups over prime fields using SAGE 27 , which is an open source computer algebra software.Obviously, such experiments can also be done for DLP on a multiplicative subgroup G of finite field F q .We compared the different performances between distinguished point method and the new algorithm.In this section, we describe these experiments and analyse the results.
For our experiments, we briefly introduce the elliptic curve groups over prime fields and the notation we use in the following.Let q be a prime, and let F q denote the field Z q of integers modulo q.Let a, b ∈ F q such that 4a 3 27b 2 / 0. Then the elliptic curve E a,b over F q is defined through the equation E a,b : y 2 x 3 ax b.

5.1
The set of all solutions x, y ∈ F q × F q of this equation, together with the element O called the "point at infinity," forms a finite abelian group which we denote by E a,b F q .Usually, this group is written additively.Let P ∈ E a,b F q be a point of prime order n, and let G denote the subgroup of E generated by P .Given Q ∈ G, determine the integer 0 ≤ k < n such that Q kP .For the iteration function, we use Teske's r-adding walk and set r 20; that is, we divide the group G into 20 subsets: S 1 , S 2 , . . ., S 20 .Define the iteration function as follows: where m i and n i randomly chosen from 0, n − 1 and m i P n i Q can be precomputed for i 1, 2, . . ., 20.This means it only needs one group operation for each iteration.
Let W x, y be any point of G; we define the partition of G into r subsets S 1 , S 2 , . . ., S r as follows.First we compute a rational approximation A of the golden ratio √ 5 − 1 /2, with a precision of 2 log 10 qr decimal places.Let where Ax − Ax is the nonnegative fraction part of Ax.Then let This method is originally from Knuth's multiplicative hash function 28 and suggested by Teske 29 .From the theory of multiplicative hash functions, we know that, among all numbers between 0 and 1, choosing A as a rational approximation of √ 5−1 /2 with a sufficiently large precision leads to the most uniformly distributed hash values, even for nonrandom inputs.
The purpose of our experiments is to evaluate the expected numbers of steps until a match is found with different collision detection methods, that is, distinguished point method and the new algorithm, under the same expected space requirement.Generally, we randomly choose a big prime number q, where q is in certain range.Then we randomly choose the parameters a and b, where a, b ∈ F q , which determine the unique elliptic curve E a,b over F q .We will check whether the order of group E a,b F q has large prime factor n in certain range.If not, repeat the above procedures until we get a prime order subgroup G of E a,b F q .Then we set the generator P of G and choose a random point Q of G.When using Pollard's rho method to compute this discrete logarithm, we count the number of steps we performed until a match is found with different collision detection methods on the same case.Then we determine the ratio R of the number of steps and √ n.We repeat it a couple of times with the same P but several randomly chosen Q s.Furthermore, for practical reasons, we do the above procedures with a couple of groups, where the group order p is between 2 31 and 2 36 .We have Algorithm 2.
More precisely, for each i ∈ 31, 36 , we generate 20 elliptic curves, where each of them has a subgroup G of prime order n, such that n ∈ 2 i , 2 i 1 .Then for, each group G, we generate 100 to 3200 DLPs with the same generator P but randomly generated Q.The number of elliptic curves and instances of DLPs computed is given in Table 1.For each DLP, we use Teske's r-adding walk for iteration function and find the match using distinguished point method and the new algorithm simultaneously.Once reaching a match, we compute the ratio R l as the number of steps until match is found / √ n.Then we compute the average ratio R j of all DLPs over the same elliptic curve.Finally, we count the average ratio R i of all DLPs with the same i, where i ∈ 31, 36 and n ∈ 2 i , 2 i 1 .Now, let us explain the parameters for distinguishing property and the new algorithm in more detail.In our experiments, we compute the average ratio of number of steps until match is found / √ n under the same space requirement.To do this, generally we first define the distinguishing property and then compute the expected storage requirements.With the same storage requirements, we can deduce the parameter N for the new algorithm.For example, if i 36, which means n, the order of G is a 36-bit prime number.According to 19 , we are expected to take 1.292 √ n iterations before reaching a match.We define the distinguishing property as the Hamming weight of normal-basis representation of xcoordinate of the point less than or equal to 9. Each point has probability almost exactly 36 9 36 8 36 7 • • • /2 36 ≈ 2 −8.99 of being a distinguished point, that is, θ 2 −8.99 ; that is, to find a collision it is expected to compute 1.292 * 2 −8.99 √ n distinguished points.To keep the same storage requirements, we set N 1/θ 2 8.99 ≈ 508 for the new algorithm.
The experimental results are given in Table 2.It shows that on average using the new algorithm for collision detection can reduce the number of iterations until a match is found from 1.309 |G| to 1.295 |G| under the same space requirements for the single rho method.
Under the same expected storage requirements, the main reason for the different performances of the distinguished point method and the new algorithm is that the distinguished points may be not uniformly distributed in the pseudo-random walk, also the points in subset D may be not uniformly distributed in G, which always results in more iterations requirement.while, for the new algorithm, each stored minimum value represents N successive values, which leads to an equal-interval distribution.

Conclusion
In this paper, we proposed an optimal time-space trade-off method for collision detection in the pseudo-random walk when computing discrete logarithms with Pollard's rho method.We discussed the new algorithm both in theoretical analysis and in practical experiments.By comparison to other methods, it shows that the new algorithm is more efficient than previous methods.Unfortunately, the only practical application of the new idea is with the parallelized lambda method and it does not work with the parallelized rho method.As a further work, we would like to explore the performances of the new algorithm in other applications.
2i , which means that this algorithm requires negligible storage.Floyd's algorithm is based on the following idea.
In Pollard's paper, Floyd's algorithm is applied.To find Y i Y j , the algorithm calculatesY i , a i , b i , Y 2i , a 2i , b 2i until Y i Y 2i .For each iteration, we compute Y i 1 F Y i and Y 2 i 1 F F Y

end for Algorithm 2: Experiments
for distinguished point method and the new algorithm.

Table 1 :
Number of elliptic curves and instances of DLPs.

Table 2 :
Different performance for distinguished point method and the new algorithm.