Read this lesson as text

Diffie-Hellman Exchange Example

Cryptography · Axiom Academy

EXAMPLE Diffie-Hellman Exchange Example Step-by-step walkthrough of secure key exchange using modular arithmetic Public Parameters (Known to Everyone) Excellent work! You've completed the Diffie-Hellman key exchange. Here's what we learned: Public vs. Private Information: The parameters p and g are public, as are the exchanged values A = 8 and B = 19 . However, the secrets a = 6 and b = 15 are never transmitted. Mathematical Security: Even though Eve can see p = 23 , g = 5 , A = 8 , and B = 19 , computing the shared secret s = 2 requires solving the discrete logarithm problem, which is computationally hard for large primes. Symmetric Result: The key insight is that (g^a)^b = (g^b)^a = g^(ab) mod p , which is why both Alice and Bob arrive at the same shared secret without ever directly sharing it. Real-World Applications: With much larger numbers (e.g., 2048-bit primes), this protocol secures everything from HTTPS connections to encrypted messaging apps. This elegant protocol revolutionized cryptography by solving the key distribution problem. Practice with different values to build confidence!

This is the written version of the interactive lesson above. See the full Cryptography course.