If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content
Current time:0:00Total duration:2:19

Video transcript

now this is our solution first Alice and Bob agree publicly on a prime modulus and a generator in this case 17 and 3 then Alice selects a private random number say 15 and calculates 3 to the power 15 mod 17 and sends this result publicly to Bob then Bob selects his private random number say 13 and calculates 3 to the power 13 mod 17 and sends this result publicly to Alice and now the heart of the trick Alice takes Bob's public result and raises it to the power of her private number to obtain the shared secret which in this case is 10 Bob takes Alice's public result and raises it to the power of his private number resulting in the same shared secret notice they did the same calculation though it may not look like it at first consider Alice the 12 she received from Bob was calculated as 3 to the power 13 mod 17 so her calculation was the same as 3 to the power 13 to the power 15 mod 17 now consider Bob the 6 he received from Alice was calculated as 3 to the power 15 mod 17 so his calculation was the same as 3 to the power 15 to the power 13 notice they did the same calculation with the exponents in a different order when you flip the exponent the result doesn't change so they both calculated 3 raised to the power of their private numbers without one of these private numbers 15 or 13 Eve will not be able to find the solution and this is how it's done while Eve is stuck grinding away at the discrete logarithm problem and with large enough numbers we can say it's practically impossible for her to break the encryption in a reasonable amount of time this solves the key exchange problem it can be used in conjunction with a pseudo random generator to encrypt messages between people who have never met