# Pohlig–Hellman algorithm

(Redirected from 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 ${\displaystyle p}$-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, ${\displaystyle G}$ must be replaced by the subgroup ${\displaystyle \langle g\rangle }$ generated by ${\displaystyle g}$, which is always cyclic.)

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

The algorithm computes discrete logarithms in time complexity ${\displaystyle O(e{\sqrt {p}})}$, far better than the baby-step giant-step algorithm's ${\displaystyle O({\sqrt {p^{e}}})}$ when ${\displaystyle e}$ 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 ${\displaystyle G}$ of order ${\displaystyle n}$ with generator ${\displaystyle g}$, an element ${\displaystyle h\in G}$, and a prime factorization ${\textstyle n=\prod _{i=1}^{r}p_{i}^{e_{i}}}$.
Output. The unique integer ${\displaystyle x\in \{0,\dots ,n-1\}}$ such that ${\displaystyle g^{x}=h}$.
1. For each ${\displaystyle i\in \{1,\dots ,r\}}$, do:
1. Compute ${\displaystyle g_{i}:=g^{n/p_{i}^{e_{i}}}}$. By Lagrange's theorem, this element has order ${\displaystyle p_{i}^{e_{i}}}$.
2. Compute ${\displaystyle h_{i}:=h^{n/p_{i}^{e_{i}}}}$. By construction, ${\displaystyle h_{i}\in \langle g_{i}\rangle }$.
3. Using the algorithm above in the group ${\displaystyle \langle g_{i}\rangle }$, compute ${\displaystyle x_{i}\in \{0,\dots ,p_{i}^{e_{i}}-1\}}$ such that ${\displaystyle g_{i}^{x_{i}}=h_{i}}$.
2. Solve the simultaneous congruence
${\displaystyle x\equiv x_{i}{\pmod {p_{i}^{e_{i}}}}\quad \forall i\in \{1,\dots ,r\}{\text{.}}}$
The Chinese remainder theorem guarantees there exists a unique solution ${\displaystyle x\in \{0,\dots ,n-1\}}$.
3. Return ${\displaystyle x}$.

The correctness of this algorithm can be verified via the classification of finite abelian groups: Raising ${\displaystyle g}$ and ${\displaystyle h}$ to the power of ${\displaystyle n/p_{i}^{e_{i}}}$ can be understood as the projection to the factor group of order ${\displaystyle p_{i}^{e_{i}}}$.

## 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 ${\displaystyle {\mathcal {O}}({\sqrt {n}})}$. However, it is much more efficient if the order is smooth: Specifically, if ${\displaystyle \prod _{i}p_{i}^{e_{i}}}$ is the prime factorization of ${\displaystyle n}$, then the algorithm's complexity is

${\displaystyle {\mathcal {O}}\left(\sum _{i}{e_{i}(\log n+{\sqrt {p_{i}}})}\right)}$
group operations.[2]

## Notes

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

## References

• Mollin, Richard (2006-09-18). An Introduction To Cryptography (2nd ed.). Chapman and Hall/CRC. p. 344. ISBN 978-1-58488-618-1.
• S. Pohlig; M. Hellman (1978). "An Improved Algorithm for Computing Logarithms over GF(p) and its Cryptographic Significance" (PDF). IEEE Transactions on Information Theory (24): 106–110. doi:10.1109/TIT.1978.1055817.
• Menezes, Alfred J.; van Oorschot, Paul C.; Vanstone, Scott A. (1997). "Number-Theoretic Reference Problems" (PDF). Handbook of Applied Cryptography. CRC Press. pp. 107–109. ISBN 0-8493-8523-7.