Algorithm Search⌘K

Proofs: Pollard's kangaroo algorithm

These are the human proofs of Pollard's kangaroo algorithm, at full length.

Correctness of Pollard's kangaroo algorithm full

This proof shows: correctness, termination.

Let p≥2p \ge 2, g∈(Z/pZ)∗g \in (\mathbb{Z}/p\mathbb{Z})^*, h∈Z/pZh \in \mathbb{Z}/p\mathbb{Z} and 0≤a≤b0 \le a \le b. Put w=b−aw = b - a and h′=hg−ah' = h g^{-a}, as in line L1. For an integer y≥0y \ge 0, ga+y=hg^{a + y} = h if and only if gy=h′g^y = h', so the task is to return a+za + z for some z∈[0,w]z \in [0, w] with gz=h′g^z = h', or NONE if there is no such zz.

Lemma 1 (invariants). In every attempt, the tame kangaroo satisfies T=gtT = g^t and the wild kangaroo satisfies W=h′guW = h' g^u, where tt and uu are their distances.

Proof. Line L4 sets T=g⌊w/2⌋T = g^{\lfloor w/2 \rfloor} with t=⌊w/2⌋t = \lfloor w/2 \rfloor and W=h′W = h' with u=0u = 0. Line L13 multiplies a kangaroo by g2jg^{2^j} and adds 2j2^j to its distance, which keeps both relations. □\square

Lemma 2 (table entries). Every entry D[Y]=(κ,d)D[Y] = (\kappa, d) was written at line L12 by kangaroo κ\kappa while it stood at YY with distance dd.

Proof. Line L12 is the only line that writes to DD, and it writes the current point, kind and distance. Line L5 empties DD at the start of each attempt. □\square

Soundness of the kangaroo phase. Suppose line L11 returns a+za + z. Then 0≤z≤w0 \le z \le w and gz=h′g^z = h' were checked on that line, so a+z∈[a,b]a + z \in [a, b] and ga+z=h′ga=hg^{a + z} = h' g^a = h. (By Lemmas 1 and 2 the check always succeeds when z∈[0,w]z \in [0, w]: the point YY was visited by the tame kangaroo at distance tt and by the wild one at distance uu, so gt=Y=h′gug^t = Y = h' g^u and gt−u=h′g^{t - u} = h'; the check is kept because it costs one exponentiation and protects against mistakes in the bookkeeping.)

The certificate. Suppose line L15 is reached. Baby-step giant-step with bound n=w+1n = w + 1 uses m=⌈n⌉m = \lceil \sqrt n \rceil, stores gjg^j for 0≤j<m0 \le j < m with the least such jj for each element, and tests h′g−imh' g^{-im} for i=0,1,…,m−1i = 0, 1, \dots, m - 1. Let z∗z^* be the least integer z≥0z \ge 0 with gz=h′g^z = h', if any.

  • If z∗≤wz^* \le w, then z∗<m2z^* < m^2, so z∗=i∗m+j∗z^* = i^* m + j^* with 0≤i∗,j∗<m0 \le i^*, j^* < m, and the test at i∗i^* hits. Any hit at a round ii yields a solution im+j≥0i m + j \ge 0, and a hit at i<i∗i < i^* would give a solution smaller than i∗m≤z∗i^* m \le z^*, which is impossible. So the first hit is at i∗i^* and returns i∗m+T[gj∗]≤z∗i^* m + T[g^{j^*}] \le z^*, a solution, hence equal to z∗z^*. Line L15 returns a+z∗a + z^*.
  • If z∗z^* exists and z∗>wz^* > w, or no z∗z^* exists, then there is no solution in [0,w][0, w]. Every hit returns a solution z≥0z \ge 0, so z≥z∗>wz \ge z^* > w, and line L15 returns NONE; with no hit it also returns NONE.

Correctness. By the soundness of the kangaroo phase and the certificate, every value returned is in [a,b][a, b] and satisfies gx=hg^x = h, and NONE is returned only by line L15, which does so only when no z∈[0,w]z \in [0, w] satisfies gz=h′g^z = h', that is, when no x∈[a,b]x \in [a, b] satisfies gx=hg^x = h.

Termination. Each attempt runs at most Nmax⁡N_{\max} rounds of two jumps, there are RR attempts, and baby-step giant-step makes at most 2m+O(log⁡m)2m + O(\log m) group operations. So the algorithm stops after O(RNmax⁡+w)O(R N_{\max} + \sqrt w) group operations, which is O(w)O(\sqrt w) for RR constant and Nmax⁡=O(w)N_{\max} = O(\sqrt w). ■\blacksquare

Back to Pollard's kangaroo algorithm