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 p {\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, G {\displaystyle G} must be replaced by the subgroup ⟨ g ⟩ {\displaystyle \langle g\rangle } generated by g {\displaystyle g} , which is always cyclic.)
The algorithm computes discrete logarithms in time complexity O ( e p ) {\displaystyle O(e{\sqrt {p}})} , far better than the baby-step giant-step algorithm's O ( p e ) {\displaystyle O({\sqrt {p^{e}}})} when e {\displaystyle e} is large.
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.)
The correctness of this algorithm can be verified via the classification of finite abelian groups: Raising g {\displaystyle g} and h {\displaystyle h} to the power of n / p i e i {\displaystyle n/p_{i}^{e_{i}}} can be understood as the projection to the factor group of order p i e i {\displaystyle p_{i}^{e_{i}}} .
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 O ( n ) {\displaystyle {\mathcal {O}}({\sqrt {n}})} . However, it is much more efficient if the order is smooth: Specifically, if ∏ i p i e i {\displaystyle \prod _{i}p_{i}^{e_{i}}} is the prime factorization of n {\displaystyle n} , then the algorithm's complexity is O ( ∑ i e i ( log n + p i ) ) {\displaystyle {\mathcal {O}}\left(\sum _{i}{e_{i}(\log n+{\sqrt {p_{i}}})}\right)} group operations.3
Mollin 2006, pg. 344 - Mollin, Richard (2006-09-18). An Introduction To Cryptography (2nd ed.). Chapman and Hall/CRC. p. 344. ISBN 978-1-58488-618-1. https://archive.org/details/An_Introduction_to_Cryptography_Second_Edition ↩
Pohlig & Hellman 1978. - Pohlig, S.; Hellman, M. (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. http://www-ee.stanford.edu/~hellman/publications/28.pdf ↩
Menezes, et al. 1997, pg. 108 - 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. http://www.cacr.math.uwaterloo.ca/hac/about/chap3.pdf ↩