Module 1 · Lesson 1.5

Digital signatures

How a private key seals data so that anyone with the public key can check where it came from and that it hasn’t changed.

  • 4-minute video
  • 8-minute read
  • Builds on lessons 1.2 and 1.4

A software update arrives on your computer. It says it comes from the company that made your software. How can your computer be sure, before it installs a single byte?

A seal that anyone can check

A digital signature is a value computed from some data and a private key. Anyone who has the matching public key can check it. If the check passes, it tells them two things:

  • The signed data hasn't changed. Verification covers exactly the bytes the signing format specifies. Changing any of them makes verification fail, with overwhelming probability.
  • It was signed with the private key that matches this public key. Without that private key, nobody can produce a signature that verifies.

Think of a wax seal pressed with a unique ring. Anyone can see whether the seal is intact and matches the ring's pattern, but only the ring's owner can make a new one. Unlike a wax seal, a digital signature is tied to the exact contents: it can't be lifted off one document and stuck on another.

Sign with the private key, verify with the public key On the left, the signer uses a private key to sign a document, producing a signature. On the right, anyone uses the matching public key to check the document and its signature. If both match, verification passes. Data Private key signs Data + signature Public key verifies Only the private key can sign. Anyone with the public key can check.
The signer keeps the private key. Verifiers only ever need the public key.

Signing is not encryption

Signatures are sometimes described as "encrypting with the private key". That's misleading. A signature doesn't hide anything: the data stays readable, and the signature sits alongside it. Its job is to show that the data was signed with a particular private key and hasn't changed since, not to keep it secret.

Signature schemes are their own kind of public-key scheme, as lesson 1.4 explained. Most of them start by running the data through a hash function such as SHA-256 as part of signing, which lets them sign large files quickly. The details differ between schemes, but every one of them binds the signature to the exact data.

Try it: sign and verify

Your browser makes a real signing key pair (ECDSA on the P-256 curve, with SHA-256) and signs the message. Then check the signature, change the message, or try a different public key. Nothing is sent or stored.

Signer's public key (anyone can have it)

…

Signature (64 bytes)

…

Edit the received message, even one character, and verification fails. Here, Sign again gives a different signature for the same message, because your browser's ECDSA mixes in a fresh random value each time; both still verify. Deterministic ECDSA would give the same signature for the same key and message, which is expected too.

What a signature does and doesn't tell you

Verification establishes that a signature is valid for particular data and a particular public key. It doesn't, on its own, name the signer. Naming the signer also requires a trusted link between that public key and the claimed identity. A validated certificate is one way to establish it: a statement, signed by a certificate authority, that binds the public key to a name, as Module 2 explains. Another is a publisher's verification key installed through a trusted software distribution channel, which is how many devices check their updates.

It also only proves what the private key did. If someone else gets hold of the private key, they can sign anything, and their signatures will verify perfectly. That's why private keys belong in protected hardware, and why there are ways to withdraw trust in a key, covered in lesson 2.5.

Where signatures are used

  • Software updates. Your device checks an update's signature with the publisher's verification key, which it received through a channel it already trusts, before installing it.
  • Certificates. Every certificate carries the issuer's signature, which is how a verifier knows it wasn't forged or altered.
  • Documents and messages. Signed PDFs and email let the recipient check that the signed content hasn't changed and, with a valid certificate, whose key signed it. A signature only covers what was signed: a PDF, for example, can keep a valid signature over an earlier revision after later content is appended.
  • Smart cards. A card proves it holds its private key by signing a fresh challenge from the reader. Lesson 1.6 shows how.
Go deeperOptional technical detail for readers who want more

Common signature schemes

FIPS 186-5, NIST's Digital Signature Standard, covers RSA signatures, ECDSA and EdDSA. RSA signatures need padding, and RSA-PSS is the recommended modern form. ML-DSA, standardised in FIPS 204, is a newer scheme designed to resist quantum computers; Module 6 covers it.

Why ECDSA signatures may or may not repeat

Every ECDSA signature uses a secret per-signature value, called a nonce. In randomized ECDSA, as in the demo, the nonce is fresh and random, so signing the same message twice usually gives two different signatures. In deterministic ECDSA, described in RFC 6979, the nonce is derived from the private key and the message hash, so the same key and message always give the same signature, which is expected and safe. The dangerous case is using the same nonce with the same private key for two different message hashes: anyone with those two signatures can calculate the private key. Deterministic derivation removes the dependence on good randomness at signing time; EdDSA works this way by design.

Signatures and changed data

Verification checks the exact bytes that the signing format specifies. A different line ending, an extra space or a changed number all make it fail. That's useful for security, but it means systems have to agree precisely on what gets signed, and users need to know what a signature covers: a signed PDF, for example, can keep a valid signature over an earlier revision after later content is appended, and good viewers show which revision was signed.

Try it yourself

With OpenSSL installed, these commands create a small sample file and a new P-256 key pair used only for signing, then sign the file and verify the signature with the public key:

$ printf 'Release 4.2 is safe to install\n' > file.txt
$ openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out signing-key.pem
$ openssl pkey -in signing-key.pem -pubout -out signing-pub.pem
$ openssl dgst -sha256 -sign signing-key.pem -out file.sig file.txt
$ openssl dgst -sha256 -verify signing-pub.pem -signature file.sig file.txt

The last command prints Verified OK. Change one character in file.txt and run it again: it reports a verification failure. The key is a separate one for signing; it's good practice not to reuse a key across signing and key agreement. Delete signing-key.pem when you're done.

Sources

Draft lesson, awaiting technical review · Last updated 19 November 2026

Search

Press / to search from any page