Diffie-Hellman Key Exchange: Modular Exponentiation Walk
Interactive 3D visualization of the Diffie-Hellman key exchange: watch modular exponentiation scramble positions on a ring of residues mod p, showing why the discrete logarithm problem makes reversing the walk computationally hard even though both sides land on the same shared secret.
This simulator visualizes the Diffie-Hellman key exchange — the modular-arithmetic handshake that lets two parties agree on a shared secret over a public channel — as a 3D walk around a ring of residues modulo a prime p. Each step multiplies the current value by the generator g and reduces mod p, spiralling upward one exponent at a time; Alice's and Bob's independent walks, driven by their private exponents a and b, land on completely different-looking public values A and B, yet raising each other's public value to one's own private exponent always converges on the identical shared secret K = g^(ab) mod p. Live readouts track both public values, the shared secret from each side, and the current exponent step, while a collapsible section spells out the actual governing formula and why the discrete logarithm problem — inverting the walk to recover a private exponent from a public value — has no known efficient classical solution, which is exactly what keeps this exchange secure in real-world TLS connections.
A 3D visualization of the Diffie-Hellman key exchange: watch modular exponentiation spiral two independent walks around a ring of residues mod p, converging on the same shared secret while the discrete logarithm problem keeps the walk irreversible.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install