Back to Applied Cryptography

Understanding Diffie-Hellman with Clocks

Visualize modular exponentiation and a toy Diffie-Hellman exchange.

12-Hour Clock (Composite: 2² × 3)

Generator g = 2

13-Hour Clock (Prime)

Generator g = 2

🔐 Diffie-Hellman Key Exchange Demo

Choose a clock (modulus) and generator, then Alice and Bob pick secret numbers. Note: don't forget that a finite field of prime order 13 is way too small for use in the real world, and that this is just a toy example. In real-world protocols, finite-field Diffie-Hellman uses prime numbers that are at least 2048 bits long.

👩 Alice

Public: g^a mod p = 8

Calculation: 2^3 mod 13 = 8

👨 Bob

Public: g^b mod p = 6

Calculation: 2^5 mod 13 = 6

🔑 Shared Secret: 10

Alice computes: Bob's public^a mod p = 6^3 mod 13 = 10
Bob computes: Alice's public^b mod p = 8^5 mod 13 = 10