Digital Signatures

Proving who wrote something — sign and verify, hash-then-sign, RSA-PSS, ECDSA and its nonce pitfalls, Ed25519, what signatures do and don't prove, and real uses — code signing, software supply chains, JWTs, Git commits, passkeys and blockchains.

Intermediate 4 min readLesson 9 of 12

A digital signature is the public-key equivalent of a handwritten signature — but far stronger: it's bound to the exact content of the message, and anyone can verify it, while only the holder of the private key can create it.

PropertyMeaning
AuthenticityThe message was signed by the holder of a specific private key
IntegrityNot a single bit has changed since signing
Non-repudiationThe signer can't plausibly deny signing (unlike a MAC, where both parties share the key)
Public verifiabilityAnyone with the public key can check it

Sign and verify

sign(private_key, message)            → signature
verify(public_key, message, signature) → true / false

In practice, schemes hash the message first (Hash functions) and sign the digest — efficient for large files, and the hash's collision resistance becomes part of the signature's security (which is why MD5- and SHA-1-based signatures were forged).

PublisherDownload mirrorUsersig = sign(priv, SHA-256(app.zip))app.zip + sigapp.zip + sig (mirror is untrusted)verify(pub, app.zip, sig) → ✓ or reject

The mirror (or CDN, or package registry) can't tamper with the file without invalidating the signature. Trust shifts from "the server I downloaded from" to "the key that signed it".

Signature algorithms

AlgorithmBased onSignature sizeNotes
RSA-PSS / RSA PKCS#1 v1.5Factoring (RSA)256–512 bytesFast verification, slow signing; common in certificates and code signing
ECDSA (P-256, secp256k1)Elliptic-curve discrete log64–72 bytesTLS, WebAuthn, Bitcoin; fragile nonce handling
Ed25519 (EdDSA)Twisted Edwards curve64 bytesFast, deterministic, hard to misuse — the modern default
ML-DSA, SLH-DSALattices, hashes2.4–50 KBPost-quantum standards (2024)

ECDSA's nonce problem

ECDSA needs a fresh secret random number k (the nonce) for every signature. If k is ever reused — or even slightly biased or partially predictable — the private key can be computed from the signatures:

  • Sony PlayStation 3 (2010): used the same k for every signature; the master signing key was extracted and published.
  • Android's flawed random number generator (2013) led to Bitcoin wallets being drained.
  • Small biases in k across many signatures enable lattice attacks (e.g. Minerva, TPM-Fail).

Mitigation: deterministic nonces (RFC 6979) derive k from the private key and message hash. Ed25519 builds this in — no randomness needed at signing time — which is one reason it's preferred.

Python
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from cryptography.exceptions import InvalidSignature

priv = Ed25519PrivateKey.generate()
pub = priv.public_key()

msg = b'{"release": "1.4.2", "sha256": "9f2c…"}'
sig = priv.sign(msg)                       # 64 bytes, deterministic

try:
    pub.verify(sig, msg)
    print("valid")
except InvalidSignature:
    print("forged or modified")

What a signature proves — and doesn't

A valid signature proves someone with this private key signed these exact bytes. It does not prove:

  • Who owns the key — binding keys to identities is the job of PKI and certificates, key servers, or out-of-band checks.
  • When it was signed — add a trusted timestamp (RFC 3161 timestamping authority) so signatures stay valid after the certificate expires.
  • That the key wasn't stolen — protect signing keys in HSMs, KMS or hardware tokens, and support revocation.
  • That the content is safe — signed malware exists (stolen code-signing certificates; the SolarWinds attack compromised the build itself, so malicious code was legitimately signed).
  • Freshness — an old signed message can be replayed; include timestamps, nonces or expiry claims.

Also beware of what is signed: verify the signature over the exact bytes you then use. Bugs where a system verifies one field but trusts another (or parses differently after verification) have broken many JWT and SAML implementations.

Where signatures are used

UseDetail
TLS certificatesCAs sign certificates; servers sign handshakes to prove they hold the certificate's key (HTTPS and TLS)
Code signingWindows Authenticode, Apple notarisation, Android APK signing, driver signing
Software updates and packagesapt/rpm repository signatures, npm provenance, PyPI attestations; Sigstore (cosign) offers keyless signing with short-lived certificates and a public transparency log
Container imagesSigned image digests verified at deploy time (Docker)
GitSigned commits and tags (GPG or SSH keys)
JWTsRS256/ES256/EdDSA-signed tokens — any service with the public key can verify (Authentication)
Passkeys / WebAuthnThe device signs a server challenge with a per-site private key — phishing-resistant login
DocumentsPDF signatures, e-signature laws (eIDAS, India's IT Act / Aadhaar eSign)
BlockchainsEvery transaction is signed with the owner's key (ECDSA on secp256k1, Ed25519)
Secure bootFirmware verifies the signature of each boot stage before running it

Software supply-chain security

Modern frameworks extend signatures to the whole build:

  • SLSA levels describe how trustworthy a build's provenance is.
  • In-toto attestations and provenance record which source commit, builder and steps produced an artefact — all signed.
  • SBOMs (software bills of materials) list dependencies, signed and attached to releases.
  • Transparency logs (Rekor, Certificate Transparency) publish signatures so misuse of a key is detectable.
Key takeaways
  • Signatures provide authenticity, integrity and non-repudiation, verifiable by anyone with the public key.
  • Schemes sign a hash of the message; the hash must be collision-resistant.
  • RSA-PSS, ECDSA and Ed25519 are the main classical algorithms; ML-DSA is the post-quantum standard.
  • ECDSA nonce reuse or bias leaks the private key (PS3, Bitcoin); Ed25519 and RFC 6979 use deterministic nonces.
  • A signature proves possession of a key, not identity, time, safety or freshness — add PKI, timestamps and key protection.
  • Used everywhere: TLS, code signing, packages, containers, Git, JWTs, passkeys, blockchains, secure boot.