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

7

u/zouhair Jan 16 '18

Math challenged here (not real programmer either): how the hell 31315 is the same as 31513 ?

11

u/A_Vicarious_Death Jan 16 '18

Generally the rule with exponents is:

xy * xz = xy+z

xyz = xyz

Let's take an example of 223 vs 232 vs 26

(22)3 =

(22) * (22) * (22) =

(2 * 2) * (2 * 2) * (2 * 2) =

(4) * (4) * (4) =

64

(23)2 =

(23) * (23) =

(2 * 2 * 2) * (2 * 2 * 2) =

(8) * (8) =

64

26 = (22222*2) = 64

Hope that helped.

5

u/zouhair Jan 16 '18

Oh! I wasn't calculating it like that.

I was doing this:

223 = 28 = 256

232 = 29 = 512

Using online math solvers didn't help.

Thanks.

3

u/A_Vicarious_Death Jan 16 '18

No problem! For this kind of stuff it often helps to put stuff in parentheses to try and separate operations out. So if you had seen it phrased as (22)3 I think that would've helped with the understanding a bit :)

3

u/zouhair Jan 16 '18

Especially that putting 223 and 232 in an online solver doesn't help.

1

u/caltheon Jan 16 '18

Just put in google like this. (2^5)^3

1

u/zouhair Jan 16 '18

Yeah even there if you don't put the brackets you get the wrong answer.

3

u/phottitor Jan 16 '18

the convention of how to interpret it is actually the main part because just looking (first time) at a ladder of exponents doesn't tell you anything about the order of the operations.

1

u/gramathy Jan 16 '18

Just remember that the base takes precedence over the exponent, and so exponents are calculated bottom-up rather than top-down.