Two strangers, shouting across a crowded room, agree on a secret nobody else can learn. That’s Diffie–Hellman (1976), the trick that broke the ancient rule that you must first meet to share a key. Each mixes a public number with a private one; they swap the results publicly; and mixing again lands them on the SAME secret — while the eavesdropper, missing either private key, cannot. Slide the private keys.
Diffie–Hellman key exchange: publicly agree on a prime p and generator g. Alice picks secret a and sends A=g^a mod p; Bob picks secret b and sends B=g^b mod p. Alice computes B^a = g^(ab), Bob computes A^b = g^(ab) — the SAME shared secret — over a fully public channel. An eavesdropper sees g, p, g^a, g^b but recovering g^(ab) requires the discrete-logarithm problem, believed hard. It launched public-key cryptography and underlies TLS session keys. A fail-loud self-check throws unless both parties derive the identical shared secret. ◆ real cryptography, node-verified.
Security rests on the (unproven but well-tested) hardness of discrete logs — a quantum computer running Shor’s algorithm would break it. Basic DH is also vulnerable to a man-in-the-middle without authentication. The shared-secret arithmetic is exact.