Pohlig-Hellman Algorithm
- •
What it is
- •
An algorithm that solves the discrete logarithm problem efficiently whenever the group's order (or the order of the base element being used) is smooth — factors entirely into small primes. Rather than attacking the full-size discrete log directly, Pohlig-Hellman uses Lagrange's theorem to "project" the problem down into each small prime-power subgroup separately, solves each much-smaller discrete log there (typically via Baby-Step Giant-Step), and recombines the results via the Chinese Remainder Theorem into the discrete log modulo the full group order. Since each individual subproblem only costs roughly for its prime-power factor — far cheaper than against the whole order — this makes DLP dramatically easier whenever is smooth, no matter how large itself is.
- •
- •
When to apply
- •
You need to solve a discrete log in a group whose order (or the relevant base element's order) you can factor into entirely small primes — this is precisely why safe primes () are used defensively, and precisely why constructing a deliberately smooth-order group is such a powerful offensive move against a target who accepts attacker-chosen parameters.
- •
- •
Symbols and assumptions
- •
is the factored base order. We solve , first modulo each prime power, then modulo .
- •
- •
Math — step by step
- •
- Raise both sides to . The new base has order , and depends only on .
- •
- Solve each smaller DLP. Basic projection can use BSGS on the whole prime power; full Pohlig-Hellman recovers base- digits one at a time, reducing each digit to an order- problem.
- •
- For digit after partial exponent , raise to . It equals , so only possible digits remain.
- •
- CRT recombines the prime-power residues. Factor the actual base order, and verify the final exponent. Large prime factors remain the expensive part.
- •
- •
- •
Python
- •
def pohlig_hellman(g, h, p, order, factors): # factors: dict of {prime: exponent} for `order`'s factorization residues, moduli = [], [] for q, e in factors.items(): qe = q**e gi = pow(g, order // qe, p) hi = pow(h, order // qe, p) xi = bsgs(gi, hi, p, qe) residues.append(xi) moduli.append(qe) from sympy.ntheory.modular import crt x, _ = crt(moduli, residues) return int(x)
- •
- •
- •
- •
Cards
- •
What property of a group's order does Pohlig-Hellman specifically exploit?
- •
Smoothness — the order factoring entirely into small primes, letting the DLP be solved piecewise in each small prime-power subgroup instead of all at once.
- •
- •
What two techniques does Pohlig-Hellman combine internally?
- •
Baby-Step Giant-Step (to solve each small prime-power subproblem) and the Chinese Remainder Theorem (to recombine the pieces into the full answer).
- •
- •