The Diffie–Hellman protocol, formally [01F7]
In this protocol, Alice and Bob will agree upon a shared secret key by communicating in public.
- In public, Alice and Bob agree upon an integer c and a prime p.
- Privately, Alice chooses her own prive key \mathsf {priv}_{A} and Bob separately decides upon his own private key \mathsf {priv}_{B}.
- Individually, Alice and Bob define public keys as follows by modular exponentiation using their private keys: \begin {aligned} \mathsf {pub}_{X} \coloneqq {\mathopen {}\left [c^{\mathsf {priv}_{X}}\right ]\mathclose {}}_p \quad {\mathopen {}\left (X\in {\mathopen {}\left \{A,B\right \}\mathclose {}}\right )\mathclose {}} \end {aligned}
- In public, Alice and Bob then transmit to each other their public keys.
- In private, Alice and Bob both compute their own copies of the shared secret key as follows: \begin {aligned} K_A&\coloneqq {\mathopen {}\left [\mathsf {pub}_{B}^{\mathsf {priv}_{A}}\right ]\mathclose {}}_p \\ K_B&\coloneqq {\mathopen {}\left [\mathsf {pub}_{A}^{\mathsf {priv}_{B}}\right ]\mathclose {}}_p \end {aligned}
Finally, we show that Alice’s and Bob’s computations of the shared secret agree in the sense that K_A=K_B\text {.}