Diffie-Hellman Key Exchange

A visual simulator of establishing a shared secret.

1. Publicly Agreed Numbers

Alice and Bob agree on a prime modulus (p) and a generator (g). These are public and can be seen by anyone, including eavesdroppers.

The "Common Paint"

Alice

2. Alice's Private Key (a)

Alice chooses a secret number 'a'. Only she knows this.

a = 15

3. Alice's Public Key (A)

She mixes her secret color with the common paint and sends it publicly to Bob.

A = ga mod p

5. The Shared Secret

Alice mixes her secret color with Bob's public key to get the final secret.

Secret = Ba mod p

Bob

2. Bob's Private Key (b)

Bob chooses a secret number 'b'. Only he knows this.

b = 23

4. Bob's Public Key (B)

He mixes his secret color with the common paint and sends it publicly to Alice.

B = gb mod p

5. The Shared Secret

Bob mixes his secret color with Alice's public key to get the final secret.

Secret = Ab mod p

6. Result