Two strangers, shouting across a crowded room where everyone hears every word, end up knowing a secret number that no eavesdropper can compute. That is public-key cryptography’s founding trick — and thanks to the % and the modexp this campaign put into I-13 last turn, it runs in real I-13 now.
THE TECHNIQUE mix public + private, one-way
Agree on a base g and prime p in public. Each picks a secret (Alice a, Bob b), sends gsecret mod p across the open channel, then raises what they received to their own secret. Both land on gab mod p — the eavesdropper, seeing only g, p, ga, gb, cannot get there (the discrete-log problem). live demo
HISTORY & CREDIT two names on it, and two more left off
It is “Diffie–Hellman” — but Hellman himself asked that it be called Diffie–HellmanDiffie–Hellman–Merkle, and a fourth man had done it years earlier in secret. cited
1974 · Malcolm Williamson at Britain’s GCHQ works out the same key exchange — classified, unpublished until 1997. (His colleagues James Ellis and Clifford Cocks had already done non-secret encryption and RSA in secret.) 1976 · Whitfield Diffie & Martin Hellman publish New Directions in Cryptography — the public birth of public-key crypto. the missing name · Ralph Merkle’s puzzle work (1974, published 1978) was the parallel invention; Hellman later insisted the scheme “ought to be called Diffie–Hellman–Merkle.” This dart uses that name.
Two independent public inventors, a third who shares the credit by the second’s own request, and a fourth silenced by secrecy. Credit where it is due. restored
RECOMMEND FOR I-13 the integration paid off — it runs
The entire exchange is modular exponentiation, which I-13 gained when the campaign’s % merged and the stdlib modexp landed. Both sides derive the same secret, for real:
$ i13 run dh.i13 # std/modexp, on main
A = 8 # 5^6 mod 23 (Alice public)
B = 19 # 5^15 mod 23 (Bob public)
shared_from_A = 2 # 19^6 mod 23
shared_from_B = 2 # 8^15 mod 23 -> they MATCH
Recommend: the one remaining wall is the deliberately withheld one — arbitrary-precision integers. Toy primes (p=23) work exactly; real Diffie–Hellman uses 2048-bit primes, far past f64’s 2⁵³, so exactness dies. That is the honest boundary: I-13 demonstrates the protocol perfectly and cannot reach cryptographic sizes without a new value kind — the author’s call, recorded in std/README.md, not smuggled in as a library. The loop, visible: a wall in an earlier dart → the % recommend → integrated → this dart runs. Third time (after Collatz and Rabin–Miller).