Diffie Hellman Demo
Alice
Public
Bob
1. Decide on a Public Key
Public Key: (g = {g()}, n = {n()}){" "}
{!isPublicKeyHidden && ( )}2. Decide on a private key
A number between 1 and{" "} n = {n()}
3. Compute the public key
Alice' Public Key
A ={" "}
g
a mod{" "}
n
{/* "A" just for spacing */} A = {g()} {alicePrivateKey() || "a"} {" "} mod {n()}
{/* "A" just for spacing */} A ={" "} {alicePublicKey() ?? "?"} {" "} {!alicePublicKey() && ( {" "} (Please enter a private key{" "} a) )}
Bob's Public Key
B ={" "}
g
b mod{" "}
n
{/* "A" just for spacing */} B = {g()} {bobPrivateKey() || "b"} {" "} mod {n()}
{/* "A" just for spacing */} B ={" "} {bobPublicKey() ?? "?"}{" "} {!bobPublicKey() && ( {" "} (Please enter a private key{" "} b) )}
4. Exchange the public keys
5. Compute the shared secret
Shared Secret
s ={" "}
B
a mod{" "}
n
{/* "A" just for spacing */} B ={" "} {bobPublicKey() || "B"} {alicePrivateKey() || "a"} {" "} mod {n()}
{/* "A" just for spacing */} B ={" "} {function () { if (!alicePrivateKey()) return ( {" "} (Please enter Alice's private key{" "} a) ); if (!bobPublicKey()) return ( {" "} (Please enter Bob's public key{" "} B) ); return ( {sharedSecret()} ); }}
Shared Secret
s ={" "}
A
b mod{" "}
n
{/* "A" just for spacing */} A ={" "} {alicePublicKey() || "A"} {bobPrivateKey() || "b"} {" "} mod {n()}
{/* "A" just for spacing */} B ={" "} {function () { if (!bobPrivateKey()) return ( {" "} (Please enter Bob's private key{" "} b) ); if (!alicePublicKey()) return ( {" "} (Please enter Alice's public key{" "} B) ); return ( {sharedSecret()} ); }}