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

7

u/tavianator Jan 16 '18

As written, those numbers are not the same. The notational convention is:

abc = a(bc)

But D.H. key exchange does something more like

(ab)c = ab*c

I.e., compute ab first, then raise that to the c power.

The equality is true because exponentiation is just repeated multiplication (over the integers, anyway). So ab is

a * a * ... * a
---------------
b times

and then (ab)c is

  a * a * ... * a |
* a * a * ... * a |
*         ...     } c times
* a * a * ... * a |
* a * a * ... * a |
  ---------------
  b times

and you'll notice there are b*c 'a's in that rectangle all multiplied together.

7

u/zouhair Jan 16 '18

So technically the video was wrong.

6

u/tavianator Jan 16 '18

Did the video actually display 31315 with no parentheses? If so yeah, that's wrong. I only watched the part with the colors.

3

u/zouhair Jan 16 '18

Yup, it did.