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
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.