Asymmetric Cryptography · 3.5

✍️ Digital Signatures

Proving you wrote it and it wasn't changed — without a secret handshake⏱ ~3 min

🪪Digital signature = wax seal + DNA

A wax seal proves the letter came from someone with that seal stamp. A DNA test proves the stamp was held by a specific person. Digital signatures do both simultaneously and mathematically: they prove the message came from someone holding a specific private key, and that the message hasn't been altered since signing.

How Digital Signatures Work

  1. 1.Hash the message — compute H = SHA-256(message). This produces a fixed-length fingerprint.
  2. 2.Sign the hash — compute Signature = Sign(H, private_key). The signature is a large number.
  3. 3.Send both — transmit (message, signature) together. The message is NOT encrypted.
  4. 4.Verify — recipient computes H' = SHA-256(message), then checks: Verify(signature, H', public_key).
  5. 5.Accept if match — if H' matches what the signature decodes to, the message is authentic and unmodified.

Why Hash Before Signing?

Asymmetric operations (RSA, ECDSA) are slow and can only process data smaller than the key size. Hashing the message first reduces any message — whether 1 byte or 1 GB — to a fixed 256-bit fingerprint. Then you only sign the small fingerprint. If even one bit of the message changes, the hash changes completely (avalanche effect), and signature verification fails.

Common Digital Signature Algorithms

AlgorithmBased OnKey SizeStatus
RSA-PSSRSA factoring2048–4096 bits✓ Widely supported, secure with PSS padding
ECDSAElliptic curves256–521 bits✓ Fast, smaller signatures — used in TLS certs
Ed25519Edwards curve 25519256 bits (fixed)✓✓ Best choice for new systems — fast, safe, no nonce pitfall
DSADiscrete logarithm1024–3072 bits⚠️ Legacy; NIST deprecated for new use

Real-World Uses of Digital Signatures

  • TLS certificates — the CA digitally signs your certificate to vouch that your public key belongs to your domain
  • Code signing — Windows, macOS, and app stores require executables to be signed; unsigned code triggers warnings
  • Git commits — developers sign commits with GPG to prove authorship; GitHub shows a 'Verified' badge
  • Email (DKIM) — email servers sign outgoing mail; receiving servers verify to prevent spoofing
  • Software updates — OS update packages are signed; if the signature fails, the update is rejected
  • Cryptocurrency — every Bitcoin transaction is an ECDSA signature proving the spender owns the coins
🔒 SecurityDigital signatures provide authentication and integrity but NOT confidentiality — the message is sent in plaintext alongside the signature. If you also need confidentiality, encrypt the message after signing. The correct order is: Sign(plaintext) then Encrypt(signed message) — not the reverse.
🧠Quick Checkfirst try = +5 XP

A digital signature is created with…

0 XP🔥 0 days