the key down and then loses the paper? You don’t want to have to meet everytime you
want to change the key. With the advent of the internet, we need a new way encrypt
information. You shouldn’t have to go meet someone in person everytime you want to
send them a message online. This gave birth to the idea of Public Key Cryptography.
Let’s identify three individuals, Alice, Bob and Carl. Alice and Bob want to
communicate over the internet and Carl wants to eavesdrop on their conversation!
Alice and Bob need to create a key that -
1. Only they know
2. Can be decided over an unsecure network
At first, this seems impossible but there are many sophisticated techniques using some
very simple Math, that can help Bob and Alice out. They will essentially need to decide
their own personal keys that they keep private and a public key that everyone will have
access to but do something clever so that only they can read the messages. One such
technique is called the “Diffie-Hellman Key Exchange
”.
Diffie-Hellman Key Exchange
Here is how it works -
1. Alice and Bob publicly agree on two prime numbers, M and B.
2. Now, they both choose their own numbers called their private key, a and b
respectively, and raise the base number B to the power of their respective
private key modulo P, K
a
and K
b
respectively. They now publicly exchange these
numbers. Note: So far, only a
and b
are unknown to Carl.
(mod P ) K
a
= B
a
(mod P )K
b
= B
b
3. Now, they both raise the key they received to the power of their own private
exponents.
Bob does : B mod P ) B (mod P )K
= (
a b
=
ab
Alice does: mod P ) B (mod P )K
= (B
b a
=
ab
4. Bob and Alice now have the same number K
and Carl has no way of creating the
key because he does not have access to a
or b
! Thus, K
is a completely secret key
that only Bob and Alice can know and Carl has no way of reproducing this key.
5. Alice and Bob can now begin encrypting their messages with this key and Carl
can no longer eavesdrop!
Warning!
The Diffie-Hellman approach is not perfect and has weaknesses that a
hacker could take advantage of.