Attic › Computer science › Public-key cryptography

A digital signature uses the private key in reverse to prove who sent a message

About Digital signature

Because anyone can see a public key, anyone can use it to send an encrypted message. If Bob receives a message locked with his public key, he knows that no one else could read it—but he does not know if it really came from Alice or from an impostor. To prove who she is, Alice can use her own key pair in reverse to make a digital signature.

In many public-key systems, the mathematical link between the keys works in both directions: data locked with a public key can only be unlocked by its matching private key, and data locked with a private key can only be unlocked by its matching public key.

Locking a message with a private key does not hide the message, because anyone with the public key can unlock and read it. Instead, it proves who wrote it. If Alice's public key successfully unlocks a piece of data, her private key must have locked it. Because only Alice has her private key, the data must come from her.

A digital signature is a mathematical stamp created with a private key to prove that a message is authentic and unchanged. To sign a message, Alice's computer follows three steps:

1. It puts the message through a mathematical formula to create a short, fixed-length string of data called a hash. Every different message creates a completely different hash.

2. It encrypts this hash using Alice's private key. This encrypted hash is the digital signature.

3. It attaches the signature to the original message and sends both to Bob.

When Bob receives the message, his computer checks the signature:

1. It uses Alice's public key to decrypt the signature, which shows the original hash that Alice made.

2. It puts the message he received through the same formula to calculate a new hash for himself.

3. It compares the two hashes.

If the two hashes match, Bob knows two things for sure. First, Alice sent the message, because her public key unlocked the signature. In cryptography, this creates non-repudiation: Alice cannot later claim that she did not sign the message, unless someone stole her private key. Second, no one changed the message on its way to Bob. If an attacker changes even one letter of the message during a man-in-the-middle attack, Bob's calculated hash will not match the hash inside Alice's signature, and his computer will reject the message.

For this system to work, Bob must be certain that the public key he uses truly belongs to Alice, and not to an attacker pretending to be her. On the internet, trusted organisations called certificate authorities check the identity of website owners and issue a public key certificate—a digital document with the authority's own signature—to prove who owns each public key.

Fact-checked against Public-key cryptography on Wikipedia

Part of the Computer science syllabus: Cryptography and Computer Security

See it on the timeline of Computer science