Algorithm Search⌘K

Proofs: Pohlig-Hellman algorithm

These are the human proofs of Pohlig-Hellman algorithm, at full length.

Correctness of the Pohlig-Hellman algorithm full

This proof shows: correctness, termination, minimality.

Let GG be a finite abelian group, g,h∈Gg, h \in G, and N=∏(l,e)∈FleN = \prod_{(l, e) \in F} l^e a multiple of ord⁡(g)\operatorname{ord}(g), with each ll prime.

Lemma 1 (exact order). After lines L1 to L3, r=ord⁡(g)r = \operatorname{ord}(g).

Proof. Let o=ord⁡(g)o = \operatorname{ord}(g). Throughout, o∣ro \mid r: this holds for r=Nr = N, and rr is replaced by r/lr/l only if gr/l=1g^{r/l} = 1, that is, only if o∣r/lo \mid r/l. When the loop for ll ends, either l∤rl \nmid r, or gr/l≠1g^{r/l} \ne 1, so o∤r/lo \nmid r/l. In both cases the exponent of ll in rr equals the exponent of ll in oo: it is at least that, since o∣ro \mid r, and if it were larger then o∣r/lo \mid r/l. Later rounds only remove other primes, so they keep this exponent and keep o∣ro \mid r. At the end every prime has the same exponent in rr and in oo, and r∣Nr \mid N has no other primes, so r=or = o. □\square

Lemma 2 (membership in a cyclic group). If GG is cyclic, then h∈⟨g⟩h \in \langle g \rangle if and only if hr=1h^r = 1.

Proof. If h=gxh = g^x then hr=(gr)x=1h^r = (g^r)^x = 1. A cyclic group has exactly one subgroup of each order dividing #G\#G, and the elements yy with yr=1y^r = 1 form a subgroup of order rr (in a cyclic group of order MM with generator cc, ctc^t satisfies ctr=1c^{tr} = 1 exactly when M/gcd⁡(M,r)∣tM/\gcd(M, r) \mid t, which gives gcd⁡(M,r)=r\gcd(M, r) = r elements, as r∣Mr \mid M). This subgroup contains ⟨g⟩\langle g \rangle, of order rr, so the two are equal. □\square

So if line L4 returns NONE, then h∉⟨g⟩h \notin \langle g \rangle, in any group. For the rest of the proof, suppose first that h=gx∗h = g^{x^*}, where x∗x^* is the least non-negative solution; then 0≤x∗<r0 \le x^* < r.

Lemma 3 (projection). Let lf∥rl^f \parallel r and c=r/lfc = r/l^f. Then gl=gcg_l = g^c has order lfl^f, hl=hc=glx∗h_l = h^c = g_l^{x^*}, and for an integer yy, gly=hlg_l^y = h_l if and only if y≡x∗(modlf)y \equiv x^* \pmod{l^f}.

Proof. gg has order rr, so gcg^c has order r/gcd⁡(r,c)=lfr/\gcd(r, c) = l^f. Then hl=(gx∗)c=glx∗h_l = (g^{x^*})^c = g_l^{x^*}, and gly=glx∗g_l^y = g_l^{x^*} holds exactly when lf∣y−x∗l^f \mid y - x^*. □\square

Lemma 4 (digits). Write x∗ mod lf=∑k=0f−1dklkx^* \bmod l^f = \sum_{k=0}^{f-1} d_k l^k with 0≤dk<l0 \le d_k < l. Before round kk of lines L11 to L15, xl=∑t<kdtltx_l = \sum_{t < k} d_t l^t. In round kk, baby-step giant-step returns d=dkd = d_k.

Proof. By induction on kk; for k=0k = 0, xl=0x_l = 0 by line L10. Assume the claim before round kk. By Lemma 3, hlgl−xl=glyh_l g_l^{-x_l} = g_l^{y} with y≡x∗−xl(modlf)y \equiv x^* - x_l \pmod{l^f}, and y≡∑t≥kdtlt(modlf)y \equiv \sum_{t \ge k} d_t l^t \pmod{l^f}. Raising to lf−1−kl^{f-1-k} gives glylf−1−kg_l^{y l^{f-1-k}}, and

y lf−1−k≡dklf−1+lf∑t>kdtlt−k−1≡dklf−1(modlf).y \, l^{f-1-k} \equiv d_k l^{f-1} + l^{f} \textstyle\sum_{t > k} d_t l^{t-k-1} \equiv d_k l^{f-1} \pmod{l^f}.

So δ=gldklf−1=γdk\delta = g_l^{d_k l^{f-1}} = \gamma^{d_k}, with γ=gllf−1\gamma = g_l^{l^{f-1}} of order ll. Baby-step giant-step with the bound l≥ord⁡(γ)l \ge \operatorname{ord}(\gamma) returns the least d≥0d \ge 0 with γd=δ\gamma^d = \delta, which is dkd_k since 0≤dk<l=ord⁡(γ)0 \le d_k < l = \operatorname{ord}(\gamma). Line L15 then gives xl=∑t≤kdtltx_l = \sum_{t \le k} d_t l^t. □\square

Correctness for h∈⟨g⟩h \in \langle g \rangle. By Lemma 2 and the first direction of its proof, line L4 does not return. By Lemma 4, line L14 never returns, and after the loop for ll, xl=x∗ mod lfx_l = x^* \bmod l^f. The moduli lfl^f for the distinct primes l∣rl \mid r are pairwise coprime with product rr, so line L17 returns the unique x∈[0,r)x \in [0, r) with x≡x∗(modlf)x \equiv x^* \pmod{l^f} for all ll, by the Chinese remainder theorem. Since 0≤x∗<r0 \le x^* < r, x=x∗x = x^*. Line L18 finds gx=hg^x = h, and line L19 returns the least solution.

Correctness for h∉⟨g⟩h \notin \langle g \rangle. Any value that reaches line L19 has passed the test of line L18, so gx=hg^x = h and h∈⟨g⟩h \in \langle g \rangle. Hence for h∉⟨g⟩h \notin \langle g \rangle the algorithm returns NONE at line L4, L14 or L18. If GG is cyclic, Lemma 2 shows that line L4 already returns NONE.

Termination. The loop of lines L2 and L3 divides rr by ll at each round and so runs at most ee rounds for each (l,e)(l, e). The digit loop runs ff rounds per prime, and baby-step giant-step terminates. So the algorithm stops after finitely many group operations, bounded as in the Complexity section. ■\blacksquare

Back to Pohlig-Hellman algorithm