Diffie-Hellman Key Exchange: Square-and-Multiply Ladder (2D)
A 2D companion to the 3D Diffie-Hellman ring walk: instead of a repeated-multiplication spiral, this simulator computes the same modular exponentiation with the real square-and-multiply (binary exponentiation) algorithm real crypto libraries use, plotting each squaring/multiply bit-step as a ladder and each landing value on a residue strip, and cross-checks that both sides still converge on one shared secret.
This 2D companion to the 3D Diffie-Hellman ring walk keeps the same public prime p, generator g and private exponents a and b, but computes the modular exponentiation with the algorithm real cryptographic libraries actually use: square-and-multiply (binary exponentiation), which needs only about log₂(a) steps instead of a linear walk of a multiplications. A bit-ladder chart climbs one rung per exponent bit — always squaring the running value, and additionally multiplying by g on every 1-bit — while a residue strip beneath it drops a marker at each rung's landing value along a single line spanning 0..p−1, showing the same unpredictable scattering of nearby exponents that makes the discrete logarithm problem hard, this time read off a line instead of a spiral. Running the exchange climbs both ladders independently and verifies that Alice's B^a mod p and Bob's A^b mod p converge on one identical shared secret, exactly as they do in the 3D version — the algorithm is different, the mathematics and the result are not.
A 2D companion to the 3D Diffie-Hellman ring walk: instead of a repeated-multiplication spiral, this simulator computes the same modular exponentiation with the real square-and-multiply (binary exponentiation) algorithm production crypto libraries use, plotting each bit's squaring/multiply step as a ladder and each landing value on a residue strip, then verifies both sides still converge on one identical shared secret.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install