Can you reverse Diffie-Hellman?

Short Tech Stories
HackerNoon.com
4 min readJun 22, 2017

--

Hi All , so in a previous article i tried to explain how D-H works , and i hope I did a good job of it and hopefully there’s no questions , but how hard would it be for the person eavesdropping to reverse the “secret exponents” and guess the key?

Initial communication

Remember that image ? let’s recap:

Jerry and Simon agreed a prime and a base number , while they were chatting about this there’s a third person “Random” that is listening to everything.

Next step Simon and Jerry will calculate a number and tell it each other, for example jerry will tell Simon:

which translates to:

So Jerry will tell Simon my Computed number is 2642.

So how hard is it for “Random” to obtain the “secret exponent” with all the values that she had right now? to clarify “Random” equation should be something like:

X is the value we want to know , if “Random” knows X , then she will be able to know the secret exponent.

This is called discrete logarithms , so to examplify this i will use smaller numbers:

So far there’s no easy way to solve this backwards , it’s easy with small numbers , for example we could make a list of all numbers smaller than prime:

So that would work in a way … but as you can tell it is sort of brute forcing , the catch is when you use a large prime number (+100 digits) , something in the range of:

you can see the complexity increases drastically , the other catch is once you build this table , and build it in time! , how do you search efficiently over it ? as you see not impossible but very very slow.

So long prime numbers would add a lot of complexity to the reversing this modulo.

One question that in a forum was how complex is to generate these numbers , and how fast is it ? specially power of something.

Well what i found is that if the a compute want’s to know:

The computer won’t do this: (it’s too slow)

Instead there’s an operation called repeated squaring , which simplifies this greatly , the idea is the following:

This is way faster than multiplying 3 , 17 times :)

So to wrap up , Some arithmetic operations are very easy/doable one way but very complex the other way around , hence D-H popularity .

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMI family. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!

--

--