Algorithm Search⌘K

Proofs: Baby-step giant-step

These are the human proofs of Baby-step giant-step, at full length.

Correctness of baby-step giant-step full

This proof shows: correctness, termination, minimality.

Let GG be a group, g,h∈Gg, h \in G, r=ord⁡(g)r = \operatorname{ord}(g) and n≥rn \ge r. Let m=⌈n⌉m = \lceil \sqrt n \rceil, so m≥1m \ge 1 and m2≥n≥rm^2 \ge n \ge r.

Lemma 1 (baby steps). After the loop of lines L4 to L6, the table TT contains exactly the elements g0,…,gm−1g^0, \dots, g^{m-1}, and for each such element ee, T[e]T[e] is the least j∈{0,…,m−1}j \in \{0, \dots, m-1\} with gj=eg^j = e.

Proof. By induction on jj, at the start of round jj we have e=gje = g^j (line L3 gives e=1=g0e = 1 = g^0, and line L6 multiplies by gg). Line L5 inserts ee with the value jj only if ee is not yet in TT, and never changes an entry already present. So each element enters with the first, least index at which it occurs, and every gjg^j with j<mj < m is present after round jj. □\square

Lemma 2 (giant steps). At the test of line L10 in round ii of the loop of lines L9 to L11, γ=hg−im\gamma = h g^{-im}.

Proof. Line L8 gives γ=h\gamma = h for i=0i = 0, and line L11 multiplies by u=g−mu = g^{-m} from line L7. □\square

Soundness. If line L10 returns x=im+jx = im + j with j=T[γ]j = T[\gamma], then by the lemmas hg−im=γ=gjh g^{-im} = \gamma = g^j, so h=gim+j=gxh = g^{im + j} = g^x, and x≥0x \ge 0.

Completeness. Suppose h∈⟨g⟩h \in \langle g \rangle and let x∗x^* be the least x≥0x \ge 0 with gx=hg^x = h. Then x∗<rx^* < r, because gx∗−r=hg^{x^* - r} = h would otherwise give a smaller solution. Write x∗=i∗m+j∗x^* = i^* m + j^* with 0≤j∗<m0 \le j^* < m. Since x∗<r≤m2x^* < r \le m^2, also i∗<mi^* < m, so round i∗i^* is executed unless the algorithm returned earlier. In round i∗i^*, γ=hg−i∗m=gj∗\gamma = h g^{-i^* m} = g^{j^*}, which is in TT by Lemma 1. So the algorithm returns in some round i≤i∗i \le i^*.

Minimality. Let the algorithm return in round ii with j=T[γ]j = T[\gamma]. If i<i∗i < i^*, the returned x=im+j≤im+m−1<i∗m≤x∗x = im + j \le im + m - 1 < i^* m \le x^* is a solution by soundness, smaller than the least solution, which is impossible. So i=i∗i = i^*. In this round gj∗=γ=gjg^{j^*} = \gamma = g^{j} with jj the least exponent below mm for γ\gamma (Lemma 1), so j≤j∗j \le j^*, and x=i∗m+j≤x∗x = i^* m + j \le x^* is a solution; by the choice of x∗x^*, x=x∗x = x^*.

Non-membership. If h∉⟨g⟩h \notin \langle g \rangle, no round can return, since a return gives h=gxh = g^x by soundness. The loops are bounded, so the algorithm stops at line L12 with NONE. Conversely, by completeness, NONE is returned only when h∉⟨g⟩h \notin \langle g \rangle.

Termination and cost. Both loops run at most mm rounds, and line L7 uses O(log⁡m)O(\log m) multiplications by square and multiply, so the algorithm stops after at most 2m+O(log⁡m)2m + O(\log m) group operations, mm insertions and mm lookups. ■\blacksquare

Back to Baby-step giant-step