DHKE Attacks
Small prime
If the prime \(p\) is small enough, then the DLP is not hard enough and can thus be solved in little time with existing algorithms.
| |
Smooth prime
The public prime modulus \(p\) must be chosen such that \(p=2q+1\) where \(q\) is also a prime. If not, then \(p-1\) might be a smooth number (i.e a number having a lot of small factors).
If so, then the Pohlig–Hellman algorithm can be used to compute the discrete logarithm very quickly.
Sage uses this algorithm when necessary under the hood, so you can use the same function presented above.
Now, here is a simple script to generate such smooth primes
| |
Tip
In the case of \(p-1\) being a powersmooth number, you can use Pollard’s p-1 algorithm that is specifically designed for such numbers.
Small Subgroup Attack
This attack exploits the same vulnerability created by a smooth prime number. You can thus refer to the previous attacks to take advantage of it.
Nevertheless, here are some resources to read more about it.