Pohlig–Hellman algorithm

From HandWiki
Short description: Algorithm for computing logarithms
Pohlig Hellman Algorithm
Steps of the Pohlig–Hellman algorithm.

In group theory, the Pohlig–Hellman algorithm, sometimes credited as the Silver–Pohlig–Hellman algorithm,[1] is a special-purpose algorithm for computing discrete logarithms in a finite abelian group whose order is a smooth integer.

The algorithm was introduced by Roland Silver, but first published by Stephen Pohlig and Martin Hellman (independent of Silver).[citation needed]

Groups of prime-power order

As an important special case, which is used as a subroutine in the general algorithm (see below), the Pohlig–Hellman algorithm applies to groups whose order is a prime power. The basic idea of this algorithm is to iteratively compute the [math]\displaystyle{ p }[/math]-adic digits of the logarithm by repeatedly "shifting out" all but one unknown digit in the exponent, and computing that digit by elementary methods.

(Note that for readability, the algorithm is stated for cyclic groups — in general, [math]\displaystyle{ G }[/math] must be replaced by the subgroup [math]\displaystyle{ \langle g\rangle }[/math] generated by [math]\displaystyle{ g }[/math], which is always cyclic.)

Input. A cyclic group [math]\displaystyle{ G }[/math] of order [math]\displaystyle{ n=p^e }[/math] with generator [math]\displaystyle{ g }[/math] and an element [math]\displaystyle{ h\in G }[/math].
Output. The unique integer [math]\displaystyle{ x\in\{0,\dots,n-1\} }[/math] such that [math]\displaystyle{ g^x=h }[/math].
  1. Initialize [math]\displaystyle{ x_0:=0. }[/math]
  2. Compute [math]\displaystyle{ \gamma:=g^{p^{e-1}} }[/math]. By Lagrange's theorem, this element has order [math]\displaystyle{ p }[/math].
  3. For all [math]\displaystyle{ k\in\{0,\dots,e-1\} }[/math], do:
    1. Compute [math]\displaystyle{ h_k:=(g^{-x_k}h)^{p^{e-1-k}} }[/math]. By construction, the order of this element must divide [math]\displaystyle{ p }[/math], hence [math]\displaystyle{ h_k\in\langle\gamma\rangle }[/math].
    2. Using the baby-step giant-step algorithm, compute [math]\displaystyle{ d_k\in\{0,\dots,p-1\} }[/math] such that [math]\displaystyle{ \gamma^{d_k}=h_k }[/math]. It takes time [math]\displaystyle{ O(\sqrt p) }[/math].
    3. Set [math]\displaystyle{ x_{k+1}:=x_k+p^kd_k }[/math].
  4. Return [math]\displaystyle{ x_e }[/math].

The algorithm computes discrete logarithms in time complexity [math]\displaystyle{ O(e\sqrt p) }[/math], far better than the baby-step giant-step algorithm's [math]\displaystyle{ O(\sqrt{p^e}) }[/math] when [math]\displaystyle{ e }[/math] is large.

The general algorithm

In this section, we present the general case of the Pohlig–Hellman algorithm. The core ingredients are the algorithm from the previous section (to compute a logarithm modulo each prime power in the group order) and the Chinese remainder theorem (to combine these to a logarithm in the full group).

(Again, we assume the group to be cyclic, with the understanding that a non-cyclic group must be replaced by the subgroup generated by the logarithm's base element.)

Input. A cyclic group [math]\displaystyle{ G }[/math] of order [math]\displaystyle{ n }[/math] with generator [math]\displaystyle{ g }[/math], an element [math]\displaystyle{ h\in G }[/math], and a prime factorization [math]\displaystyle{ n=\prod_{i=1}^rp_i^{e_i} }[/math].
Output. The unique integer [math]\displaystyle{ x\in\{0,\dots,n-1\} }[/math] such that [math]\displaystyle{ g^x=h }[/math].
  1. For each [math]\displaystyle{ i\in\{1,\dots,r\} }[/math], do:
    1. Compute [math]\displaystyle{ g_i:=g^{n/p_i^{e_i}} }[/math]. By Lagrange's theorem, this element has order [math]\displaystyle{ p_i^{e_i} }[/math].
    2. Compute [math]\displaystyle{ h_i:=h^{n/p_i^{e_i}} }[/math]. By construction, [math]\displaystyle{ h_i\in\langle g_i\rangle }[/math].
    3. Using the algorithm above in the group [math]\displaystyle{ \langle g_i\rangle }[/math], compute [math]\displaystyle{ x_i\in\{0,\dots,p_i^{e_i}-1\} }[/math] such that [math]\displaystyle{ g_i^{x_i}=h_i }[/math].
  2. Solve the simultaneous congruence [math]\displaystyle{ x\equiv x_i\pmod{p_i^{e_i}} \quad\forall i\in\{1,\dots,r\} \text{.} }[/math]The Chinese remainder theorem guarantees there exists a unique solution [math]\displaystyle{ x\in\{0,\dots,n-1\} }[/math].
  3. Return [math]\displaystyle{ x }[/math].

The correctness of this algorithm can be verified via the classification of finite abelian groups: Raising [math]\displaystyle{ g }[/math] and [math]\displaystyle{ h }[/math] to the power of [math]\displaystyle{ n/p_i^{e_i} }[/math] can be understood as the projection to the factor group of order [math]\displaystyle{ p_i^{e_i} }[/math].

Complexity

The worst-case input for the Pohlig–Hellman algorithm is a group of prime order: In that case, it degrades to the baby-step giant-step algorithm, hence the worst-case time complexity is [math]\displaystyle{ \mathcal O(\sqrt n) }[/math]. However, it is much more efficient if the order is smooth: Specifically, if [math]\displaystyle{ \prod_i p_i^{e_i} }[/math] is the prime factorization of [math]\displaystyle{ n }[/math], then the algorithm's complexity is [math]\displaystyle{ \mathcal O\left(\sum_i {e_i(\log n+\sqrt {p_i})}\right) }[/math] group operations.[2]

Notes

  1. Mollin 2006, pg. 344
  2. Menezes, et al. 1997, pg. 108

References