🔑 Diffie-Hellman Key Exchange 2D
A flat 2D Diffie-Hellman simulator: real BigInt modular exponentiation lets Alice and Bob derive the same shared secret independently, while an eavesdropper panel literally brute-forces the discrete logarithm on small primes, benchmarks your device's real cracking speed, and extrapolates that measured rate to show why 2048-bit keys are computationally out of reach.
A flat 2D companion to the 3D Diffie-Hellman colour-mixing simulator, built around the same real BigInt modular exponentiation but focused on the attacker's side: Eve genuinely brute-forces the discrete logarithm, and a live benchmark shows exactly why that attack cannot scale to real key sizes.
🔬 What It Demonstrates
Alice and Bob each raise a shared base g to their own secret exponent modulo a prime p, exchange only the results (A and B), and each raises the value they received to their own secret to land on the identical shared value g^(ab) mod p — without either ever transmitting a or b.
🎮 How to Use
Pick a preset prime/generator pair and Alice's and Bob's secret exponents to watch the shared secret update live. Then switch to Eve: run the real brute-force search on the small demo prime, and run the benchmark to see your own device's guesses-per-second projected out to 2048-bit keys.
💡 Did You Know?
Brute force and the smarter baby-step giant-step algorithm both scale with the square root of the key space at best for classical computers — doubling the bit-length roughly squares the work, which is why key sizes grow in whole multiples rather than small increments.
Frequently Asked Questions
Is the brute-force attack in this simulation real?
Yes — it performs actual modular multiplications one guess at a time, exactly like a real naive attacker, and stops the instant it finds an exponent that reproduces A. There is no shortcut or lookup table.
Why does the benchmark matter?
Instead of quoting a textbook number, it measures how fast your browser actually performs the same operation the brute-force search uses, then multiplies that real rate out to the size of the search space for larger keys — so the "computationally infeasible" claim for 2048-bit primes is backed by your own device's measured speed, not an assumption.
Why can't Eve just combine A and B directly?
A = g^a mod p and B = g^b mod p are both public, but there is no known efficient way to combine them into g^(ab) mod p without first recovering a or b — that combination problem is the Diffie-Hellman Problem, and every known method for solving it reduces to solving discrete logarithms.
A flat 2D Diffie-Hellman simulator: real BigInt modular exponentiation lets Alice and Bob derive the same shared secret independently, while an eavesdropper panel literally brute-forces the discrete logarithm on small primes, benchmarks your device's real cracking speed, and extrapolates that measured rate to show why 2048-bit keys are computationally out of reach.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install