Diffie-Hellman Key-Exchange Animator

Alice, Bob, and Eve at tiny parameters. Watch what travels on the wire and what never does.

What this is for

Alice and Bob agree on a shared secret over a channel Eve is reading, without ever sending the secret. Each keeps a private value; each sends a public value; both combine to the same shared secret. Eve sees the public values but cannot reverse them. Step through it, then move the sliders and watch the shared secret track.

Public parameters: p = 23 g = 5 (g is a generator mod p)
Press Step to begin: first the public parameters, then each private pick, then the public exchange, then the shared secret.

Alice

Bob

Public curve: y² = x³ + 2x + 2 mod 17 G = (5, 1) (order 19)
Press Step: same protocol, but the one-way function is scalar multiplication on the curve instead of modular exponentiation. A · G is easy; recovering a from A · G is the elliptic-curve discrete log.

Alice

Bob