Fingerprints and signatures

About 9 minutesCrash course

In one sentence

A hash is a short fingerprint of any data; a digital signature made with a private key proves the data is unchanged and was signed by whoever holds that key.

The situation

A supplier emails a PDF with new bank details for their invoices. The logo is right, the tone is right, the contact name is right. Your accounts team is about to update the payment record.

How could anyone know that this document really came from the supplier, and that nobody changed a single digit on the way?

What is going on

Fingerprints: hashes

A hash function turns any data, a word or a whole film, into a short fixed-size value called a hash. People also call it a fingerprint. SHA-256, the most common one today, always produces 256 bits, usually shown as 64 hexadecimal characters.

Three properties make hashes useful:

  • Same input, same hash. Anyone can recompute it and compare.
  • Any change gives a completely different hash. Change one comma in a 50-page contract and the hash looks unrelated to the old one.
  • One way. You cannot work back from the hash to the data, and finding two different inputs with the same hash must be infeasible. Older hashes such as MD5 and SHA-1 lost that last property, which is why they are retired for signatures.

A hash uses no key, so it is not encryption, and there is nothing to “decrypt”. It also proves nothing about who sent the data: anyone who changes the document can simply compute a new hash for it.

Signatures: proof with a private key

A digital signature adds the “who”. It builds on the key pair from lesson 2:

  1. The document is hashed. Most signature algorithms do this as their first step.
  2. A signature algorithm, such as ECDSA, combines that hash with the signer’s private key to produce the signature.
  3. Anyone with the matching public key runs the verification algorithm on the document and the signature.

Verification passes only if the document is unchanged and the signature was made with the private key that matches that public key. Change one byte and it fails.

Signing with the private key, verifying with the public key Signing: the sender Document Hash SHA-256 Sign private key Signature sent with the document Verifying: anyone Document as received Hash SHA-256 Verify public key ✓ valid ✗ invalid A signature adds proof, not secrecy: the document stays readable.
Sign with the private key, verify with the public key. The document itself stays readable.

What a signature proves, and what it does not

A valid signature proves two things: the data has not changed since it was signed, and it was signed with one particular private key. It does not prove who owns that key. If a fraudster sends you their own public key labelled with your supplier’s name, their signatures will verify perfectly. Lesson 4 closes that gap with certificates.

For the invoice email in the situation, that means a signature would only help if you already had the supplier’s genuine public key. Until then, the safe check is a call to a phone number you already knew, not one in the email.

Try it

Try it: Certificate decoderOpen the full tool

Runs in your browser. Nothing you paste is sent anywhere.

PEM text, several PEM blocks, or a .pem, .crt, .cer or .der file (drop it on the box). Certificates are public, so they are safe to paste.

A certificate is itself a signed document. Find its signature algorithm (a hash plus a signature method, for example ECDSA with SHA-256) and the signature value at the end, then find the certificate’s fingerprint: one short hash that identifies the whole certificate.

Check

Check yourself

You change one comma in a 50-page contract and compute its SHA-256 hash again. What happens to the hash?

  1. One or two characters change
  2. It stays the same, because the meaning did not change
  3. It becomes completely different
Show answer

Answer C It becomes completely different

Check yourself

A document carries a valid digital signature. What does that prove?

  1. That it was signed with the private key matching the public key you used, and has not changed since
  2. That the document is secret
  3. That the signer is honest and the content is true
Show answer

Answer A That it was signed with the private key matching the public key you used, and has not changed since

Check yourself

A colleague says: 'Signing just means encrypting the document with your private key.' What is the best correction?

  1. That is right for all signature algorithms
  2. Signing runs a signature algorithm with the private key that produces proof, not secrecy; anyone with the public key can verify, and the document stays readable
  3. Signing uses the public key and verifying uses the private key
Show answer

Answer B Signing runs a signature algorithm with the private key that produces proof, not secrecy; anyone with the public key can verify, and the document stays readable

Takeaways

  • A hash is a fixed-size fingerprint: any change gives a new hash, and with no key involved it is not encryption.
  • Sign with the private key, verify with the public key. A valid signature means “made with that key and unchanged since”.
  • A signature proves which key signed, not who owns the key. That is the next lesson.

Go further

In the gameLevel 5: FingerprintsScribes' Hall, Keystone. In development

Early edition. Checked against the standards; an independent expert review is in progress. Found a mistake? Tell us.

Last reviewed Edition 0.9