How do digital signatures work?

Before we get into the technical details of how digital signatures work, I wanted to help ease you in by sharing a funny story.

You might think that digital signatures may sound complicated, but if you pay close attention to this story, they’re really not.

Hello! I’m Batman!

Imagine Batman has a box.

How digital signatures work: Box with a lock

Check out my box!

This box has a lock…a very special kind of lock.

This lock has THREE states:

  1. Locked (A): When the key is turned all the way to the left, it is locked.
  2. Unlocked (B): When the key is in the middle, it’s unlocked.
  3. Locked (C): When the key is turned all the way to the right, it is locked.

Lock has 3 states

And the lock has TWO separate keys: a black key and a yellow key.

  1. The black key can only turn RIGHT, meaning it can only turn clockwise (from A to B to C)
  2. The yellow one can only turn LEFT, meaning it can only turn counter-clockwise (from C to B to A).

Lock has two separate keys

This means that if the box is locked and the lock is turned to position A, only the black key can unlock it by turning it right, to position B (unlocked).

If the box is locked in position C, only the yellow key can unlock it by turning the lock left, to position B.

So either key can lock the box, but once it is locked, only the other key can unlock it.

Because black is his favorite color, Batman picks the black key and keeps it to himself.

Let’s call this key his “private” key because now, only Batman has it.

Let’s call the second key, the yellow key, his “public” key:

Batman makes a million copies of it and whenever he’s driving through the streets of Gotham City in his Batmobile, he tosses them out the window to pedestrians.

Toss Public Keys

There are yellow keys everywhere. Eventually, everyone in Gotham City has a copy of the “public” key.

In this scenario, Batman has his private key that can turn clockwise from A to B to C.

And everyone else has his public key that can turn counterclockwise from C to B to A.

Batman Retires!

Let’s imagine that Bruce Wayne has a change of heart and decides he wants to retire as “Batman” and move to Kamar-Taj in Nepal to study and become a monk under the Ancient One.

I’m tired of this rich and famous superhero life.

He also decides to give all his money to Alfred, his butler.

So he writes on a piece of paper, “Give $1 trillion dollars to Alfred ASAP.”

Batman's letter

Batman puts this piece of paper in the box. Using his private key, he turns his private key to position C….locking the box.

Lock has 3 states

Box locked with private key (digital signature)

Then he takes another piece of paper and writes the same message, “Give $1 trillion dollars to Alfred ASAP.”

Batman's letter

He then hands Alfred this piece of paper and instructs him:

Give this to my banker.

And then adds:

If my banker doesn’t believe you, hand him the locked box.

So now there are two letters with the same message. One is locked in the box. And the other is Alfred’s pocket which technically is publicly viewable by anyone.

Later that evening, Batman tells Robin, his sidekick, that he’s retiring and giving all his money to Alfred.

Robin leaks the news to the press and the next day, it’s all over the TV news channels.

Batman News Flash!

Batman’s banker, Daime Jimon, at Gotham National Bank is finding out about the news from his television in his office. To his surprise, Alfred shows up asking for his money and hands him the piece of paper.

Daime Jimon does not believe the news and refuses.

Alfred whips out the locked box.

Alfred whips out the box acting as digital signature

Then drops the box on his desk.

So now the banker has both the message and box.

Message with public key and digital signatures

Just like everyone else in Gotham City, Daime Jimon has a yellow key that he picked up from the street below his office.

Daime Jimon takes the “public” key out of his pocket and sees if he can unlock the box.

He turns the “public” key counterclockwise to the left to position B and the box opens!

Lock has 3 states

Inside the box is the letter that Batman wrote. And it matches the first letter that Alfred showed him.

Batman letters match

Daime Jimon apologizes to Alfred and asks his assistant to prepare the money.

He realizes that the only way that the box was locked was by using Batman’s “private” key which only Batman is in possession of.

This means that nobody else could’ve put the letter in the box aside from Batman and proves that letter is, in fact, from Batman!

The use of the “pair of keys” is how Batman is able to prove that the message came from him, and him ONLY, without having to provide an actual physically handwritten signature.

And the use of the locked box implies that the message inside was always protected and remained untouched (once the box was locked).

It basically answers the question, “How can you prove to me that Batman actually wrote this message without him having to be present? And that this message wasn’t tampered with during transit?”

This is a crude example of how a “digital signature” works but hopefully, you’re starting to get the idea.

Now let’s go learn how a digital signature actually works in the crypto world!