Now let’s see how asymmetric, or “public-key” cryptography works.

Anna has a box too. It’s a box with a very special lock.

Thanks to @leedykxhoorn for the illustration.

This lock has three states: A (locked), B (unlocked) and C (locked).

And it has two separate (yes, two) keys. The first one can only turn clockwise (from A to B to C) and the second one can only turn counterclockwise (from C to B to A).

Anna picks the first one of the keys and keeps it to herself. We will call this key, her “private” key -because only Anna has it.

We will call the second key, her “public” key: Anna makes a hundred copies of it, and she gives some to friends and family, she leaves a bunch on her desk at the office, she hangs a couple outside her door, etc. If someone asks her for a business card, she hands him a copy of the key too.

So. Anna has her private key that can turn from A to B to C. And everyone else has her public key that can turn from C to B to A.

We can do some very interesting things with these keys.

First of all, imagine you want to send Anna a very personal document. You put the document in the box and use a copy of her public key to lock it. Remember, Anna’s public key only turns counterclockwise, so you turn it to position A. Now the box is locked. The only key that can turn from A to B is Anna’s private key, the one she’s kept for herself.

That’s it! This is what we call public key encryption: Everyone who has Anna’s public key (and it’s easy to find a copy of it, she’s been giving them away, remember?), can put documents in her box, lock it, and know that the only person who can unlock it is Anna.

There is one more interesting use of this box.

Suppose Anna puts a document in it. And she uses her private key to lock the box, i.e. turn the key to position (C).

Why would she do this? After all, anyone with her public key, can unlock it! Wait.

Someone delivers me this box and he says it’s from Anna. I don’t believe him, but I pick Anna’s public key from the drawer where I keep all the public keys of my friends, and try it. I turn right, nothing. I turn left and the box opens! “Hmm”, I think. “This can only mean one thing: the box was locked using Anna’s private key, the one that only she has.”

So, I’m sure that Anna, and no one else, put the documents in the box. We call this, “digital signature”.