Asymmetric advantage in cryptography is basically the idea that it’s way easier (and cheaper) to lock your secrets up tight than it is for someone else to crack them open without the key. It’s a big deal for keeping our digital chats and info safe.
Think of it like this: You’ve got a medieval castle, complete with high walls, a moat, and a drawbridge. This castle is your personal vault, keeping your treasures (or texts) safe. The person running the show, let’s call them the castle lord, has the key (or in our case, the encryption key) to let friends in easily.
Building the Castle (Encryption): Putting up the castle takes some work, but once it’s up, it’s a solid defense against any would-be attackers. Same goes for encrypting your data. It might take a bit to set up the right algorithms and keys, but once you do, your data’s safe and sound from uninvited guests.
Laying Siege to the Castle (Cracking the Code without a Key): If someone wants to break in and they don’t have the key, they’re in for a tough time. They’d need a whole army (or a ton of computer power) and a lot of patience, likely without much to show for it. This is what we call a ‘brute-force’ attack in the crypto world, and it’s pretty much trying every possible key until they (maybe) hit jackpot.
Here’s the kicker: attacking the castle (or decrypting data without permission) is a lot harder and requires way more resources than just defending it.
To give you an idea, encrypting a message with something like an RSA 2048-bit key (pretty standard stuff) could take less than a second on a smartphone. But trying to break that encryption without the key? You’d need more computing power than thousands of computers working together for years could provide.
Now, for encryption to work, both people in a conversation need the same secret key. But how do you share a secret key safely if someone might be listening in?
That’s where the genius of Whitfield Diffie and Martin Hellman comes in. Back in the 1970s, they figured out a way (Diffie-Hellman key exchange) for two people to come up with a shared secret key, even over a line that might be tapped. It’s pretty much the magic behind secure sites (the ‘S’ in HTTPS) and lets you and a website agree on a secret key every time you visit, all without anyone else catching on.
The trick? While we call it a ‘key exchange’ the key actually isn’t exchanged. Instead, the results of separate calculations are shared, allowing both parties to arrive at the same secret key. So, it’s more acurate to call it ‘secure common key generation,’ but nobody does.
Doing it is a great experience. The math isn’t hard, and actually doing it with someone will really help you get a feel for how cryptography works.
Setup: This is best if you call a friend quickly and do this together. It’ll take 5-10 minutes. In the end, you’ll produce the same secret key, both coming to it with different inputs!
Since most phone calculators don’t have a ‘mod’ function anymore, you’ll probably find Wolfram Alpha is a better calculator. Just type
[number] mod [number].
a =Write down your answers using a pen and paper for each step.
pis always a prime number (why we called it p), which has special properties that make it harder for eavesdroppers.
Compute your public value (X) X = g^a mod p. X =
Exchange public values. Their X =
Calculate your shared secret (S) using S = their X^a mod p
Now you should both have the same shared secret. Check!
BONUS Step: Try to brute force!
Pretend to be an eavesdropper, who has listened in to this and wants to know your secret key. You know X, g and p. To work out S, you know S = X^a mod p but you don’t know the value of a for either person. So you have to just try all possible values of a until you guess the key. Try a few to see how hard it is (then consider in real life, a could be any number into the billions.)
TODO: Describe how this extends from 23 possibilities to infeasible computation, and why we need to divide by a prime.
The Discrete Logarithm Problem (DLP) is a mathematical challenge that underpins the security of many cryptographic systems, including the Diffie-Hellman (DH) key exchange. It involves finding the exponent (x) in the equation (g^x = h) within a finite group, where (g) and (h) are known elements of the group, and (x) is unknown.
The “discrete” nature of the problem refers to the fact that the variables are integers, making the problem significantly harder as the group’s size increases. In the context of DH, the security of exchanging keys over an insecure channel relies on the difficulty of solving the DLP for an eavesdropper, even if they know (g) and (h), ensuring that only the parties involved can compute the shared secret key.
While effective, DH exchanges using traditional algebraic groups can be cumbersome, requiring large keys for adequate security.
While Diffie-Hellman was a game-changer, it didn’t solve everything, like making sure you’re actually talking to who you think you are. Enter Public Key Infrastructure (PKI), which uses two related keys instead of just one (called key-pairs). You get a public key, which you can tell anyone, and a private key, which you keep to yourself. Anyone can use your public key to send you a message that only you can decrypt with your private key. This setup is behind the secure messaging apps we use, like Signal, Matrix, Whatsapp and Protonmail. It’s also how crypto wallets work. Behind the scenes, your address generates your public key, and your seed phrase generates your private key.
TODO: Exercise actually doing a keygen, encrypt and decrypt with a calculator, and separate PKI into its own page
And there’s more: with PKI, you can also ‘sign’ messages with your private key. Think of it like sealing a letter with wax. Anyone with your public key can check the seal and know the message really came from you, untouched. This seal is done with something called a hash, which we’ll cover next.
So, that’s the scoop on keeping digital secrets safe. It’s all about making sure only the right people can unlock your messages, all while keeping the nosy ones out.