(Private Key)
k = ?
(Public Key)
P = ?
(Shared Secret Key)
s = ?
P = 6k (mod 13) = ?
k =
s = Pk (mod 13) = ?
(partner's) P =
Plaintext
Ciphertext
The key principle behind the DHKE is DLP. It is a function that is easy to go one way, but very hard to go the other. You could think of it like trying to determine how much coffee and milk you have in a cup. Before mixing, you can easily measure the ingredients, but after mixing, it is hard to measure the ingredients.
Given,
g - generator
p - prime
Given x, it is easy to compute gx mod p
but difficult to find x given g and p
The reason behind using a generator and a prime, is that for any given input of x, from 1 to p - 1, a generator will produce all values from 1 to p - 1.
An example is the prime 5 and generator 2.
p = 5, g = 2
| gx mod p | |
|---|---|
| 21 mod 5 | 2 |
| 22 mod 5 | 4 |
| 23 mod 5 | 3 |
| 24 mod 5 | 1 |
As we have seen, it generates 2, 4, 3, 1, which are all the values from 1 to p - 1.
This means that the possible x's are equally distributed and to brute force would be O(p). Though this may seem linear, note that the complexity grows with the input size of n bits. So p = 2n, leading to an exponential complexity, O(2n).
Each key is denoted as belonging to Alice or Bob in this example. Such as kA or kB