The Diffie-Hellman key exchange protocol allows two parties to establish a shared secret key over an unsecure channel. It works by having each party first choose a private key and then compute and share a public value. Each party can then use both public values to derive the same shared secret key, while an observer only knows the public values. For example, Alice and Bob agree on a prime number p and generator g. Alice picks a and Bob b as private keys. They compute public values A=ga mod p and B=gb mod p, which they share. They each use the other's public value and their private key to compute the same shared key s=gAa mod p=gBb mod p.