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 comment

0

u/[deleted] Jan 16 '18

[deleted] — view deleted comment

36

u/Double_A_92 Jan 16 '18

You can only see the unfinished mixes and the third color which is public anyway.

From them you can't get to secret colors.

Heres a good image: https://upload.wikimedia.org/wikipedia/commons/3/35/Diffie-Hellman_Key_Exchange-modified.png

3

u/[deleted] Jan 17 '18

yeah the analogy sort of breaks down in reality, since if you know one color in a mixture of two colors, you can fairly easily figure out the other color. but it asks us to make the assumption that you can't.

1

u/Double_A_92 Jan 17 '18

I thought so too... But I couldn't come up with a simple way to actually do that, that ensures that you get the exact color.

You would have to mix the 2 exchanged mixes, and then subtract one part the common color...But how to you subtract a color? With some complicated centrifuge maybe ._.

4

u/[deleted] Jan 17 '18 edited Jan 17 '18

physically separating the colors in a mixed paint is difficult. but mathematically subtracting is easy, assuming you know the ratio of paints being used. which you would, since you could observe the paint before and after the secret color is added.

0

u/[deleted] Jan 16 '18

[deleted] — view deleted comment

1

u/[deleted] Jan 16 '18

Yeah but one is correct and the other one isnt.

14

u/odnish Jan 16 '18

No, you can find one of the three.

5

u/browner87 Jan 16 '18

Not exactly. The public part is 2 random numbers (the extra color in this case), but the secret part (my color and your color) are never ever sent somewhere the attacker can see them without being mixed up with the public colors, which the attacker can't extract my secret color from despite knowing the public colors I mixed them with. So the original secret colors are always safe, and in fact I never even let you know my secret color, but in the end we arrive at a common color that we can use that the attacker can't create from the two pre-mixed colors he observed.