Diffie–Hellman key exchange
Adapted from Wikipedia · Discoverer experience
Diffie–Hellman key exchange is a way for two people to create a secret code together even if they can only talk through a public channel, like the internet. Before this method was created, people needed to exchange secret codes in a safe way, such as using paper lists carried by a trusted courier. But with Diffie–Hellman, two people who have never met can create a secret key together over an insecure channel. They can then use this key to hide their messages using a symmetric-key cipher.
This 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 cryptography. Many internet services use Diffie–Hellman to keep information safe. However, some older ways of using it were found to be too weak by 2015.
It turns out that people in a British intelligence agency had come up with similar ideas even earlier, in 1969, but they were kept secret. 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 even if someone later figures out a secret key. The RSA cryptosystem, another important method for secure communication, came after Diffie–Hellman.
Name
In 2006, Martin Hellman suggested that the algorithm should be called Diffie–Hellman–Merkle key exchange to honor Ralph Merkle’s important work. Merkle helped develop the idea behind public-key cryptography, which makes it possible to securely share secrets over public channels. Hellman hoped this name would better show Merkle’s big role in creating this important technology.
The method is still commonly known as the Diffie–Hellman key exchange, named after Whitfield Diffie and Martin Hellman, who first described it in a paper in 1976. It was one of the first ways to safely create a shared secret key between two people over an insecure connection.
Main article: Public-key cryptography
Description
Diffie–Hellman key exchange is a way for two people to share a secret key over a public network. Imagine Alice and Bob want to share a secret color. They both agree on a common starting color, like yellow. Each of them picks a secret color they keep to themselves, say red for Alice and cyan for Bob. They mix their secret color with the common color and share these mixed colors with each other. After mixing the color they received from the other person with their own secret color, they both end up with the same final color, which becomes their shared secret.
In real life, this process uses very large numbers instead of colors. Alice and Bob 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. The safety of this method relies on the difficulty of solving certain math problems, even for very fast computers.
Main article: Diffie–Hellman key exchange
Ephemeral and/or static keys
The Diffie–Hellman key exchange can use different types of keys, called ephemeral (used once) or static (long-term). Using these keys in different ways changes how secure the exchange is. For example, using two ephemeral keys gives forward secrecy, but not always authenticity. Using two static keys gives long-term security but not forward secrecy.
There is also a method called triple Diffie–Hellman (3-DH), which mixes long-term and ephemeral keys to add more security. Another version, called Extended Triple Diffie–Hellman (X3DH), was created for use in the Signal Protocol. It uses several public keys and provides forward secrecy, meaning past messages stay safe even if future keys are discovered. This method works on special math curves called elliptic curves.
Main article: Double Ratchet Algorithm
| Alice ( A = g a {\displaystyle A=g^{a}} ) | Bob ( B = g b {\displaystyle B=g^{b}} ) | |
|---|---|---|
| X = g x {\displaystyle X=g^{x}} | X → {\displaystyle X\rightarrow {}} | |
| ← Y {\displaystyle {}\leftarrow Y} | Y = g y {\displaystyle Y=g^{y}} | |
| K = KDF ( Y x , B x , Y a , X , Y , A , B ) {\displaystyle K=\operatorname {KDF} \left(Y^{x},\,B^{x},\,Y^{a},\,X,\,Y,\,A,\,B\right)} | K = KDF ( X y , X b , A y , X , Y , A , B ) {\displaystyle K=\operatorname {KDF} \left(X^{y},\,X^{b},\,A^{y},\,X,\,Y,\,A,\,B\right)} |
Operation with more than two parties
Diffie–Hellman key exchange can involve more than just two people. Many users can work together to create a secret key by sharing information back and forth. For example, imagine three friends—Alice, Bob, and Carol—each following a set of steps to create a secret number that only they can know.
The process starts with everyone agreeing on two numbers, and each person picks their own private number. They then share certain values with each other. Through a series of calculations, each person can finally figure out the same secret number without ever revealing their private numbers. Even if someone watches all the shared values, it’s very hard for them to find the secret number. This way, groups can keep their information safe together.
Security and practical considerations
The Diffie-Hellman key exchange is secure when certain settings are used correctly. It relies on solving a hard math problem, which is tough for computers unless they have very special tools. To keep it safe, the numbers used must be large and carefully chosen.
There are some ways people tried to break this system, like using special math tricks or reusing common settings. Experts suggest using bigger numbers or different methods, like elliptic curve cryptography, to stay safe. Even very powerful computers, called quantum computers, could break some versions, but new ways are being developed to protect against those too.
Other uses
Public key encryption schemes can use the Diffie–Hellman key exchange. One example is the ElGamal encryption, and a newer version is the Integrated Encryption Scheme.
Diffie–Hellman helps create new secret keys for each conversation, which improves security. It is often used in protocols that need this feature, called forward secrecy.
When two people share a password, they can use a special version of Diffie–Hellman called password-authenticated key agreement to stay safe from attackers. This makes it harder for someone to trick them. An example of this is the Secure Remote Password protocol.
Diffie–Hellman can also be part of a public key infrastructure, letting one person send a private message to another without talking beforehand. However, RSA is more commonly used for this today.
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.
Safekipedia