Sharing a key in secret
For two people to use the same lock, they need the same key. But how do you hand that key over? Mail it, and someone in the middle could copy it. Meet in person, but you are far apart. Surprisingly, there is a way for two people to end up holding the same key without ever sending the key itself. They build it together.
Share a fast key, safely
Earlier we saw two keys, a public key and a private key.
Lock with the public key and only the private key opens it, very safe.
But there is one weakness.
The public key method is heavy to compute, so it is slow.
Trading a whole long letter this way takes far too long.
So in practice we use a separate, fast lock.
A lock where the locking key and the opening key are the same,
this is called a symmetric key.
A symmetric key is fast, but both sides must hold the very same key.
How to share that same key safely is today's problem.
Tap to compare the two methods. The public key is safe but slow, the symmetric key is fast but both must share the same key.
The wish to use a fast symmetric key is clear.
The problem is that simply sending that key is risky.
If someone in the middle copies that key,
no matter how strong the lock, it is useless.
Whoever holds the key can open everything.
So we need a way for two people to hold the same key
without ever putting the key itself out on the road.
Let me draw that way as mixing colors.
Blend a private color into a public color
Call the two people Garam and Narae.
First they agree on one public color both know.
Anyone may see this color. It is not hidden.
Next each picks one private color in their own mind.
This private color is never shown to anyone.
Garam blends a new color from the public color and a private color,
and Narae blends a new color from the public color and a private color too.
Then they send only this blended color to each other.
Not the private color, only the blended one.
Once colors are mixed, it is hard to undo which two went in.
Tap to blend each private color into the public color. Only the two blended colors are sent across. The private colors are not sent.
Now Garam holds the blended color Narae sent,
and Narae holds the blended color Garam sent.
Both also know the public color.
But for now they hold different colors each.
To become the same key, one step remains.
Here a small bit of magic happens.
If each blends their own private color into the color they received,
the two people arrive at the very same color.
Let's check why it becomes the same next.
Both reach the same final color
What Garam holds is a color blended with Narae's secret.
Into this Garam blends their own private color again.
Now it is the public color with both people's private colors blended in.
Narae does the same.
What Narae holds is a color blended with Garam's secret,
into which Narae blends their own private color again.
The result is again the public color with both private colors blended in.
Even if the blending order differs, the same colors in give the same result.
So the two arrive at the very same final color.
This final color is the shared secret only they know, the symmetric key.
The final colors of the two boxes became the same.
The key itself never went out on the road even once.
What passed by was only the public color and each blended color.
Yet both got the same key in hand.
This is the heart of key exchange.
Not sending the same secret, but building it together.
Naturally a worry comes up.
What if someone watches all the colors that pass by?
Is it still safe?
Even watching, the final color cannot be made
Think of someone who watches every color passing on the road.
This person knows the public color, since anyone does.
They saw the blended color Garam sent,
and the blended color Narae sent.
So can they make the final color?
No.
Making the final color needs someone's private color,
but the private color never came out on the road.
Pulling a private color back out of a blended color is very hard too.
So the watcher cannot reach the same final color.
This is the heart of the defense that key exchange provides.
Tap to mark what the watcher has. The public color and the blended colors are visible, but without a private color the final color cannot be made.
The watcher's hands were left with a blank.
Because the last piece, a private color, is missing.
Public information alone cannot fill in the final color.
So Garam and Narae can rest easy
and use this final color as a symmetric key just for them.
A fast symmetric key, gained without dropping the key on the road.
Now let's note one thing and wrap up.
Key exchange is not the same as encrypting content with a public key.
It is a point often confused, so let's separate it clearly at the end.
Let's wrap up
Gathered on one line, it is this.
Public keys are safe but slow,
so the real content travels with a fast symmetric key.
That symmetric key is not sent but built together.
Blend each private color into the public color and exchange,
then blend your own private color back into what you received,
and both reach the same final color, the shared secret.
A watcher has no private color, so cannot make that color.
Finally, key exchange is not the same as public key encryption.
Key exchange is the procedure of building the same secret together, and after it the symmetric key trades content quickly.
Tap to separate the two ideas. Key exchange builds a shared secret together, public key encryption locks content with a public key.
Now you know that two people far apart
can hold the same secret together
without dropping the key on the road.
Blend a private color into the public color, exchange only the blended color,
then blend each private color back to reach the same final color.
This simple color mixing
is the ground on which we use the internet safely.
Next, on the safe channel built this way,
how do we check that the other side
really is who they claim? Let's explore together.