Diffie-Hellman key exchange: client and server each pick a private random number, and publicly send only g^a mod p / g^b mod p. Both then compute (g^b)^a mod p = (g^a)^b mod p = g^(ab) mod p — the same shared secret, without either private number or the secret itself ever crossing the wire.
client: A = g^a mod p → server
server: B = g^b mod p → client
shared = B^a mod p = A^b mod p
Host key verification (TOFU): on first connect, the client sees the server's public host-key fingerprint and must trust it. On every later connect it compares the fresh fingerprint against the one it saved. If an attacker sits in the middle with their own key pair, the fingerprint the client receives no longer matches the saved one — the client refuses the connection with a loud warning instead of silently proceeding.
- Connect (normal) — animates the real client ↔ server DH exchange; both sides converge on the same shared-secret value and the fingerprint matches the saved one.
- Simulate MITM attack — inserts an attacker node between client and server with its own key pair; the client detects the mismatched fingerprint and blocks the connection.
- DH parameters — pick a bigger or smaller modulus p to see the same algorithm work at different key sizes.
- Reset — clears the saved host key and all connection state so you can replay either scenario from scratch.
Real-world relevance: this is exactly what OpenSSH does on every ssh connection — the "WARNING: HOST KEY HAS CHANGED" message is the client-side detector for precisely this attack.