Diffie Hellman Key Exchange

How do two people who’ve never met exchange a shared key? How do we agree on a shared key without Eve finding out what the key is?

The Diffie-Hellman Key Exchange.

Alice and Bob agree upon the below prime modulus and a generator (modulus: 17, generator: 3).

// Agreed upon function:
function e(randomNum){
return (3**randomNum)%17;
}

Eve can see this function too. But here’s where it gets interesting: Alice and Bob both choose private numbers.

Alice's private number: 15
Bob's private number: 13

Then Alice and Bob run their private numbers through the function, and exchange the results.

Alice: e(Alice's Private Number) = e(15) = 6
Bob: e(Bob's Private Number) = e(13) = 12

They exchange these numbers:

Alice — 6 —> <— 12 — Bob

Alice now knows:

  • The agreed upon function e()
  • Her private number (15)
  • Her processed number (6)
  • Bob’s processed number (12)
Alice now runs her private number and Bob's processed number through the function. She raises Bob's processed number by her private number.
     Alice's private
v
(12**15)%17 = 10
^
Bob's processed number

Bob now knows:

  • The agreed upon function e()
  • His private number (13)
  • His processed number (12)
  • Alice’s processed number (6)
Bob now runs his private number and Alice's processed number through the function. He raises Alice's processed number by his private number.
Bob's private
v
(6**13)%17 = 10
^
Alice's processed number

Now they have securely exchanged a shared key!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.