Diffie–Hellman (DH) lets two parties establish the same secret across an insecure channel without sending that secret directly. They can then use it as a key for symmetric encryption. section 1.4.1
A basic DH exchange follows these steps:
- Agree on public parameters: a large prime p and a generator g. section 5.2.2
- Generate a random private value: Alice chooses x and Bob chooses y. section 1.4.1 section 5.2.2
- Derive and exchange public values: Alice sends gˣ mod p and Bob sends gʸ mod p. section 5.2.2
- Combine the received public value with the local private value; both sides arrive at the same shared secret. section 1.4.1
DH relies on the discrete logarithm problem: deriving a public value is efficient, while recovering the private value from that public value is intended to be impractical with sufficiently large parameters. section 5.2.2
The shape analogy
Alice and Bob agree on a square, privately choose a triangle and a star, and combine each secret with the square to create public shapes. Each then combines the other public shape with their own private shape, producing the same star–square–triangle secret. Observers see only the public shapes. section 1.4.1
Unauthenticated DH protects the shared secret from passive observation but does not stop an active attacker from impersonating a participant. Authentication, often involving public keys or signatures, is needed for that threat. section 5.5



