The Pohlig-Hellman algorithm is useful in finding the discrete logarithm
of a number and modulus. In other words, we wish to solve the following expression for
.
We'll use the
notation to represent this solution. Given the prime factorization of
,
We can solve
for each
(in other words, calculate
for each factor) and then recombine them using the Chinese remainder theorem to find
. Let's start by finding the base-
expansion of
:
where each
is an integer digit between 0 and
. We can find the digits
through
successively to find
. Let's multiply both sides of the equation above by
:
Where
is some integer. Let's raise each side of our original problem statement
to the same
power:
Now we just have to try possible values for
until the following congruence works out:
Now that we know
, we can find remaining digits (up to
) in succession. Notice by our original problem and our base expansion for
that we have
Now similar to what we did above, we can raise both sides to the
power (notice
in the first step) for
up to
(as
is the highest prime power that divides
). In this case, we'll take
:
Once again, we reduced by Fermat's little theorem, and now we can try values for
until we find the one that makes the equivalence work.
Continue this process until we have all base
digits
for
.
Now we know
mod
.
Repeat this process for all prime factors
dividing
, and then combine them with the Chinese remainder theorem.