When I was a newbie in the secure communication world, the one thing which bothered me, was how to securely exchange the secret through the internet. I didn’t understand how is it possible to exchange information publically and not enable anyone else to generate the same secret key. It was up to the point when someone showed me the below graphics which explain how the Diffie-Hellman algorithm works on colors and makes secret key sharing possible.
Let’s imagine two parties who want to agree on some secret color.
- It starts with agreeing on starting color (yellow) through a public network.
- Then both parties choose some random color (red/blue) in this case.
3/4. Mixing the colors is the next step - Such colors (orange/green) could be exchanged by insecure communication
- Adding once again a previously chosen color is the next step.
7/8. And we and up with the same brown color.
Please notice that based on publically shared information (yellow, orange, green) it could be quite hard to figure out the randomly chosen colors. There is a wide range of colors/shades/amounts of it and it’s really hard to reverse the process of mixing. The only way to figure out the secret colors is through the trial and error method. And only knowing this it is possible to recreate the final one.
The Diffie-Hellman algorithm works pretty much the same but instead of colors, it operates on big numbers. Yellow is a big prime number and the operation of mixing is modular exponentiation. For such assumptions similarly, it is relatively easy to mix the numbers and very hard to figure out secret numbers (red/blue) even knowing starting and the middle point of the algorithm outcome.
Is secret key sharing still a mystery now for you?