When you send a message online, it often travels through places you don't control like Wi-Fi hotspots, servers or networks where anyone along the way could see it. That sounds scary, but modern cryptography has a neat solution: the Diffie-Hellman key exchange. At a high level, it solves a simple but crucial problem: How can two people agree on a shared secret if everyone can see the conversation? Imagine Alice and Bob want to communicate over the internet, but Eve is always listening. The trick is to agree on a secret numerical key without Eve ever knowing it. This key is like a password that only they share, and once they have it, they can encrypt their messages so that even if Eve intercepts them, she won’t be able to understand anything. Let's first think about it in colors: Mixing two colors is easy: you can combine them to create a third color. Undoing the mix is hard: given the resulting color, we cannot figure out the originals. This is what a one-way function lo...