Diffie-Hellman lets two parties who have never met agree on a shared secret key, even though everything they send each other is visible to anyone listening. It is the reason your browser can set up an encrypted connection to a website over a network it has no reason to trust.
The problem it solves
Symmetric ciphers such as AES are fast and strong, but both ends need the same key before they can use one. Sending that key in the clear defeats the point, and meeting in person to swap keys doesn't scale to the web. Until Whitfield Diffie and Martin Hellman published their method in 1976, there was no practical public answer.
Their answer is that the key never travels at all. Each side sends a value that is safe to publish, then combines what it received with a secret it kept to itself. Both arrive at the same result independently. Someone who records the whole conversation has the public values but not the secrets, and without a secret they can't do the final step.
How the maths works
In the video, a public bowl and a private seasoning stand in for numbers. The classic version uses arithmetic modulo a prime, where 'mod p' means 'the remainder after dividing by p':
- Both sides agree on a large prime
pand a baseg. These are public, and are usually standard values that everyone uses. - Alice picks a secret number
a. Bob picks a secret numberb. Neither is ever sent. - Alice sends
A = g^a mod p. Bob sendsB = g^b mod p. - Alice computes . Bob computes .
Wondering how this was made? How we make these