How do digital signatures work?

Image of a man signing a document - Destination Certification

What do we use our handwritten signatures for?

To prove that a document is authentic and that it has integrity.

If we sign a document, it indicates that the document is accurate and either created or approved by us. Handwritten signatures give us a quick way to provide these protections because it’s relatively easy for us to sign a document, but forging takes skill and practice. Forgery is also highly illegal, which acts as a deterrent.

Handwritten signatures give us a way to bring trust to a range of important forms and other documents, from home loan applications to divorce settlements. While they are imperfect, they more or less work, and most of us don’t need to spend too much time worrying about how signature forgery could upend our lives.

Digital signatures are fairly similar: they give us a way to authenticate and prove the integrity of data. They work through the magic of hashing and public-key cryptography.

What is cryptographic hashing?

To keep things simple, cryptographic hashing functions like SHA-256 allow us to input a string of any length (from a single character to the life’s work of Charles Dickens) and output a fixed-length string, like:

ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb

As long as the cryptographic hash function we use is still considered secure, it’s essentially impossible to figure out what the input was from this output, nor is it feasible to find two different inputs that result in the same output. Even if you only make a subtle change to a given input, the output ends up completely different.

While these properties may not seem that exciting on their own, they open up a lot of doors when we combine them with public-key cryptography.

What is public-key cryptography?

Public-key cryptography, also known as asymmetric encryption, is a kind of encryption that uses two keys instead of one. One of the keys, the public key, is generally stored in a publicly available place. If you want to send someone an encrypted message, you seek out their public key (if they have one) and use it to encrypt the message. Once data has been encrypted with a public key, it can only be decrypted with the matching private key, which are keys that users keep secret.

To communicate securely through public-key encryptions, you find your recipient’s public key, use it to encrypt your message and then send it to them. Once they receive it, they decrypt it with their private key. As long as their private key hasn’t been compromised, they are the only person who can access the contents.

What happens when we put these techniques together?

One of the interesting things about public key encryption schemes like RSA is that we can also use them in reverse. When we combine them with cryptographic hashes, they give us digital signatures, which allow people to verify whether our messages are authentic and retain their integrity.

It looks like this:

  • Alice writes a message.
  • She runs a copy of the message through a hash function, which gives her a unique-ish, irreversible-ish string.
  • Alice then performs a computation on the resulting hash using her private key—we tend to describe this process as “signing” it. The result is known as the digital signature. Note that she is using her private key to digitally sign the hash. If she were intending to digitally encrypt something, she would use the recipient’s public key.
  • Alice then sends the message to Bob, alongside this digital signature.
  • When Bob receives the message and the digital signature, his first step is to find Alice’s public key, which she should either have previously shared with him, or have publicly available.
  • Bob then applies Alice’s public key to the digital signature, performing an inverted form of the computation that Alice used to sign the message. If the message Bob received is authentic and hasn’t been tampered with in transit, the result of this computation will be the exact same hash that Alice produced when she ran her initial message through the hash function.
  • Bob then takes the message he received from Alice and runs it through the very same hash function she used.
  • At this stage, Bob has the hash of the message he received, plus the value he produced by performing the computation on the digital signature that Alice sent. If the message is authentic and has not been tampered with, then these two values should be exactly the same. If they are, Bob knows that the message is truly from Alice, and no attacker has messed with it. If they do not match, then the message is either from an impostor, it has been altered at some stage, or something else has malfunctioned. Whatever the cause, Bob should not trust the message if the results don’t match.

Digital signatures involve some strange math, but ultimately they are a great way for us to verify the authenticity and integrity of data. If Bob wished to reply to Alice so that she could also verify the authenticity and integrity, he would just need to find her public key, and the two would have to perform the exact same steps with the roles reversed.

While digital signatures use encryption, they do not intend to provide the message with confidentiality. However, they are often combined with other encryption schemes to do so.

Image of the author

Cybersecurity and privacy writer.

Would you like to receive the DestCert Weekly via email?

Your information will remain 100% private. Unsubscribe with 1 click.

Page [tcb_pagination_current_page] of [tcb_pagination_total_pages]