Pohlig-Hellman attack
The discrete logarithm problem is not always difficult. Pohlig and Hellman showed that if the group order p-1 consists only of small prime factors (such numbers are called smooth, or smooth in English), the problem is divided into several smaller problems and solved very quickly.
The logic of the algorithm: for each prime factor q of p-1, we move to a small subgroup — g_q = g^((p-1)/q) and h_q = h^((p-1)/q). In this subgroup, the order is only q, so we find x mod q instantly with BSGS. By collecting all the remainders x ≡ xᵢ (mod qᵢ), we reconstruct x using the Chinese Remainder Theorem.
Practical conclusion: when choosing a prime p for Diffie-Hellman, p-1 must have at least one large prime factor. Otherwise, the key will be cracked in a few seconds. In the following parameters, such a mistake was made on purpose.
Given:
p = 14535678376960620991810392603237704423
p - 1 = 2 * 1168477 * 1220239 * 1380721 * 1397101 * 1514659 * 1744583
g = 5
h = 8866673674646952960624718030003939734
Find x from the equation g^x ≡ h (mod p) and assemble the flag: BAYROQ{M4TH_pohlig_hellman_<x>}