This implementation demonstrates the Pohlig-Hellman algorithm for solving the discrete logarithm problem on elliptic curves. The algorithm is practical when the group order has small prime factors.
This attack is significantly more efficient than attempting to solve the discrete logarithm problem using a brute-force search. In the group used for our implementation, the logarithm can be recovered in under one second with the Pohlig-Hellman attack, whereas a brute-force approach would take longer. This highlights the importance of working with groups of large prime order in cryptographic applications. For example, the group of the BLS12-381 elliptic curve over
Given two points
Let
where
-
Factorization: Decompose the group order
$n$ into its prime power factors. -
Subgroup Resolution: For each prime power
$p_i^{e_i}$ :- Compute
$g_i = g^{n/p_i^{e_i}}$ . - Compute
$h_i = h^{n/p_i^{e_i}}$ . - Solve
$h_i = g_i^{x_i}$ in the subgroup of order$p_i^{e_i}$ , using the Baby Step Giant Step algorithm. This will give us$x_i$ such that$x \equiv x_i \text{ mod } p_i^{e_i}$ .
- Compute
-
Chinese Remainder Theorem: Combine the solutions
$x_i$ to find$x$ modulus$n$ .
Given a generator point
- Compute the step size
$m = \lceil \sqrt{n} \rceil$ . - Compute and store the list of points
${g^0, g^1, \ldots, g^{m-1} }$ - We compute each element of another list
${hg^{-0m}, hg^{-1m}, hg^{-2m}, \ldots, hg^{-m^2}}$ , and look for a coincedence between both lists. - If a match
$g^j = hg^{-im}$ is found then the descrete log is$x = im + j$ because: $$ \begin{aligned} g^j &= hg^{-im} \ g^{im + j} &= h \end{aligned} $$ - If no match is found after
$m$ iterations, then no solution exists within the given subgroup.
Once the subproblems are solved, the algorithm uses the Chinese Remainder Theorem to find a solution that satisfies all congruences:
The solution is given by:
You'll find two files in this folder. The file chinese_remainder_theorem
contains all the algorithms needed to compute the final step.
In the other file, called pohlig_hellman
, we define a group vulnerable to this attack and the algorithms that compute it.
We chose to use a subgroup
To find the generator
// Create the group
let group = PohligHellmanGroup::new();
let generator = &group.generator;
let order = &group.order;
// Define q = g^x.
let x = 7u64;
let q = generator.operate_with_self(x);
// Find x.
let x_found = group.pohlig_hellman_attack(&q).unwrap();
// Check the result.
assert_eq(generator.operate_with_self(x_found), q);