Safekipedia

Diffie–Hellman key exchange

Explorer · ages 7 and underAdapted from Wikipedia
Diagram showing how the Diffie-Hellman key exchange works in cryptography.

What Is Diffie–Hellman Key Exchange?

Diffie–Hellman key exchange is a special way for two people to create a secret code together, even if they can only talk through a public place, like the internet. Before this idea was made, people needed to share secret codes in a safe way, like using paper lists carried by a trusted courier. But with Diffie–Hellman, two people who have never met can make a secret key together over an insecure channel. They can then use this key to hide their messages using a symmetric-key cipher.

This smart idea was first shared in 1976 by Whitfield Diffie and Martin Hellman. It was one of the first ways to use public key exchange in something called cryptography. Many internet services use Diffie–Hellman to keep information safe.

Imagine you and a friend want to pick a secret color. You both agree on a common starting color, like yellow. Each of you picks a secret color you keep to yourself—one might pick red, and the other might pick cyan. You mix your secret color with the common color and share these mixed colors with each other. After mixing the color you received from your friend with your own secret color, you both end up with the same final color! This becomes your shared secret.

In real life, this process uses very large numbers instead of colors. Two people agree on two public numbers, and each picks a secret number. They exchange certain values based on these numbers, and through a special math trick, they both end up with the same secret number without revealing their individual secrets. This shared secret can then be used to encrypt messages they send to each other over the same public network.

Even though Diffie–Hellman by itself does not prove who is sending the message, it helps create strong security for many modern internet protocols. It also makes something called "forward secrecy" possible, which helps keep messages safe. Another important method for secure communication is the RSA cryptosystem.

Keep exploring

This article is a child-friendly adaptation of the Wikipedia article on Diffie–Hellman key exchange, available under CC BY-SA 4.0.

Images from Wikimedia Commons. Tap any image to view credits and license.