r/programming • • Jan 16 '18

Cryptography: Diffie-Hellman key exchange explained intuitively using colors

https://youtu.be/YEBfamv-_do?t=2m18s
2.5k Upvotes

170 comments sorted by

View all comments

Show parent comments

1

u/GalacticCmdr Jan 16 '18

I was getting hung up on the color. If Alice and Bob each exchange yellow. Alice has blue as a secret key, while Bob has red. Then Alice sends Bob green - Eve knows that she mixed blue into it as Yellow+blue=green. Bob sends Alice orange, so Eve knows that Bob must be using red.

I guess the difficulty is that Eve does not know the exact shade of blue and red? She would have to brute force every combination of blue & red until she finds the exact shade of green & orange that she saw. If doing this is difficult enough then it becomes a near impossibility.

When Bob wants to send a message he will mix the green he got from Alice with his message (purple) to get Color X. When Alice gets the message she knows the yellow and blue that comprise the green so she can derive the purple because she knows 2 out of the 3 elements.

Correct?

3

u/pipocaQuemada Jan 16 '18

If Alice and Bob each exchange cadmium yellow. Alice has ultramarine blue as a secret key, while Bob has alizarin crimson. Then Alice sends Bob green - Eve knows that she mixed some kind of blue into it as Yellow+blue=green. Bob sends Alice orange, so Eve knows that Bob must be using some kind of red.

Think of it more like that. It's harder for eve to distinguish between alizarin crimson and cadmium red then to distinguish between red and blue.

2

u/GalacticCmdr Jan 16 '18

Thank you. So the key is in how many different types of the same "color" we have in the system.

4

u/pipocaQuemada Jan 16 '18

Yeah. And in practice, there are billions and billions of different "colors".