Skip to content
CryptoAcademy logo CryptoAcademy
Menu
Lesson Beginner · 15 min

Digital signatures

A digital signature binds a message to a private key. Anyone with the public key can verify it — instantly catching any modification.

In this lesson

  • Describe the sign and verify operations
  • Explain what a signature does and does not prove
  • Verify a signed file from the terminal

Sign with the private, verify with the public

To sign, the signer hashes the message and encrypts that hash with their private key. To verify, anyone hashes the message again, decrypts the signature with the public key, and compares. Match → authentic and unmodified.

How signatures are verified
A digital signature is created with a private key and checked with the public key Message "pay 1 BTC" Private key kept secret by the signer Signature 3045…f2ab Attach to transaction Signing proves: "I approved this exact message" verification by anyone Verify (no secrets needed) message signature public key verify() Valid ✓ Message unchanged Verification succeeds: only the holder of the private key could have produced this signature. Message tampered with Verification fails instantly — even a single changed byte invalidates the signature.
The same signature validates the original message and fails on any modification.

Example · Code signing in practice

When you install a signed macOS app, the OS checks the developer's signature against a trusted certificate chain. Malware authors cannot re-sign tampered code without the developer's private key — so the OS refuses to run it.

The same mechanism guards Windows drivers, npm packages and firmware.

sign and verify bash
openssl genpkey -algorithm ed25519 -out key.pem\nopenssl pkey -in key.pem -pubout -out key.pub\n\nopenssl pkeyutl -sign -inkey key.pem -rawin -in message.txt -out sig.bin\nopenssl pkeyutl -verify -pubin -inkey key.pub -rawin -in message.txt -in sig.bin\n# Verified OK

Signatures prove three things at once:

  • Authenticity — it came from the holder of the private key.
  • Integrity — not one byte changed since signing.
  • Non-repudiation — the signer cannot later deny it (they alone hold the key).

A signature is not encryption

Signing does not hide the message. Everyone who has the file can read it — they can only verify who produced it. If you also need secrecy, encrypt separately.

Sign, verify, tamper

Sign a message in the lab, verify it, then alter one character and verify again.

Try it yourself
How long does verification take?

Milliseconds — verification is much cheaper than signing, which is why signatures scale to billions of certificates.

What if my private key leaks?

You revoke the certificate and re-issue. Signature schemes have no "undo": anyone can forge signatures for messages signed while the key was valid.

Share this page

Send this link to a friend, or scan the QR code to open it on your phone.