r/programming • u/dominatrix-octopus • Jan 16 '18
Cryptography: Diffie-Hellman key exchange explained intuitively using colors
https://youtu.be/YEBfamv-_do?t=2m18s
2.5k
Upvotes
r/programming • u/dominatrix-octopus • Jan 16 '18
186
u/Carighan Jan 16 '18
That color mixture was a neat way of doing it, shows how the resulting key/color is always the same.
72
u/Zilexion Jan 16 '18
This is the explanation I've been looking for!
Very helpful to show how they end up with the same calculation at the end.
122
u/joltting Jan 16 '18
For awhile now, I've been trying to wrap my head around, how this algorithm works.. This video explained it in 5 mins and was better than the education I received for it (sigh).
15
u/pokeman7452 Jan 16 '18
This leads me to a somewhat related question. I never understood the purpose of the DH parameters (dh####.pem) that every OpenVPN guide says to generate. This video combined with this thread, it now makes sense. But, this file remains optional. My question now is what is used when there is no DH generated?
14
u/hartleybrody Jan 16 '18
The Wikipedia article on Diffie Hellman key exchange has a great image that summarizes the video a bit more concisely.
Wiki article link.
102
u/snarfy Jan 16 '18
Breaking encryption is like trying to take the pee out of the swimming pool. It's easy to add pee, hard to remove.
23
u/TheOddScientist Jan 16 '18
If anyone is interested Here are some mathematical attacks against RSA That can successfully reduce the number of possibilities by a factor of 2X/2 | x is the key size
10
u/nono-shap Jan 16 '18
One of the most interesting video I've seen in a while. Quiet impressive how something so hard can be understand by kids. Thanks for sharing!
14
u/irrri Jan 16 '18
This is a the best explanation of PKE I've ever seen.
5
u/TheOddScientist Jan 16 '18
I have some Java Code I did implementing DH and RSA if anyone needs an example to help understand what's going on in a practical client server application.
5
u/zouhair Jan 16 '18
Math challenged here (not real programmer either): how the hell 31315 is the same as 31513 ?
5
u/[deleted] Jan 16 '18
My preferred metaphor is a box with two locks. I have the key to one lock, and you have a key to the other lock. I want to send you my spare key:
Now you have my spare key and we can exchange secrets.
4
u/[deleted] Jan 16 '18
Amazing! What level of maths is displayed here?
7
u/hagamablabla Jan 16 '18
Why do I always see these videos the semester after I need them?
3
u/ythl Jan 16 '18
Easy. Eve just needs to take a picture of the mixed/public colors, and then sample the pixel RGB hex value and do a simple subtraction.
2
u/the_phet Jan 16 '18
I dont understand how the "heart of the problem" starting at minute 6:15.
So all A,B and E agree on 3 mod 17. (E sees it).
A selects a private random number, 15, calculates 315mod17=6. Sends 6 to B. E also reads 6.
B selects 13 as his private random number, 313mod17=12. Sends 12 to A. E also reads 12.
Then A takes the 12, and does 1215mod17=10 (10 is the actual message).
B does the same, 613mod17=10 (10 is the actual message).
Later on the author ignores the fact that E already knows "3 mod 17". So E knows that 3xmod17=6 and that 3ymod17=12
2
u/NordicSeeger Jan 16 '18
It doesn't go into detail about why they both get the same secret which stems from (xa )b mod c == (xa mod c)b mod c.
If you manually calculate a modulus it's effectively separating the number into the multiple kc where k is how many times c fully fits into x and the modulus y... so you calculate y = x-kc which means also that x = y+kc.
Now the trick is that (y+kc)n becomes n multiplies of (y+kc)*(y+kc)*...*(y+kc) where there is only one "path" with meaning for a modulus and that is yn. Everything with kc in it is "tainted" because it will be exactly divisible with c and always has zero contribution to the modulus.
So (y+kc)b mod c == yb mod c. If we think of the y+kc here as the result of xa it is possible to see that (xa )b mod c == (xa mod c)b mod c.
2
u/kybernetikos Jan 16 '18
I'm quite interested in cryptographic procedures that could reasonably be done manually. For standard Diffie Hellman to be secure, I think it needs to involve numbers much larger than could reasonably be done by humans. Does anyone know of a similar technique that theoretically could be done by humans with props that wouldn't draw attention (e.g. a deck of cards, a pen and paper, etc)
1
u/[deleted] Jan 16 '18
I refer to this video and the longer version every once in a while.
1
u/curiositor Jan 16 '18
The mathematical explanation is so simple and easy to understand also!
1
u/[deleted] Jan 16 '18
I'm confused. If Alice gives Bob her secret color and Bob gives Alice his secret color, then won't Eve be able to intercept those colors as well?
1
u/whaleboobs Jan 16 '18
I watched a similar Youtube video yesterday but the solution it came up with was different. There was a third-party trusted signer involved.. Why not just use colors?
1
u/[deleted] Jan 16 '18
Great find! Very educational.
1
u/[deleted] Jan 16 '18
Thanks OP for posting this. So many people assume that crypto requires a PhD to understand that they don’t even bother.
1
u/Griffolion Jan 16 '18
That was very useful, thanks for this.
1
u/gadelat Jan 16 '18
This is reposted here from time to time, but there is even simpler explanation video for this, highly recommended to use it instead of current for simple explanation https://youtu.be/U62S8SchxX4
1
u/evergladechris Jan 16 '18 edited Aug 27 '20
Something has gone missing...
1
u/HeyCanIBorrowThat Jan 16 '18
That was beautiful :')
1
u/knightmustard Jan 16 '18
What stops Eve from making two seperate connections and bridge them?
1
u/jale2ice Jan 16 '18
Awesome!
1
u/[deleted] Jan 17 '18
This is great, but how can you know that the "colour" you received wasn't from Eve?
(A rhetorical question that I would ask if I was teaching security).
1
u/[deleted] Jan 16 '18
Daaamn whaat a coincidence, I had an exam on this yesterday.
1
u/iamagupta Jan 16 '18
Frankly the math explanation was better...
-10
u/a_dog_and_his_gun Jan 16 '18
Combine it with for example this and we have understanding. https://www.youtube.com/watch?v=M-0qt6tdHzk
0
u/[deleted] Jan 16 '18
[deleted] — view deleted comment
3
u/[deleted] Jan 16 '18
[removed] — view removed comment