Digital Signatures
Imagine downloading a software update. How do you know it really came from the vendor? How do you know it's not from an attacker on the network? A hash checksum only tells you the file was not accidentally corrupted. It does not tell you who produced it. What you need is a cryptographic mechanism that binds a message to a specific private key. Anyone holding the matching public key can then check authorship. Yet nobody without the private key could have produced that binding. This is exactly the problem digital signatures solve. Digital signatures are the public-key analogue of a handwritten signature. But they come with much stronger guarantees. A handwritten signature can be forged by copying the shape. A digital signature is bound mathematically to both the signer's secret key and the exact bits of the message. Altering even one bit invalidates it. Digital signatures give three properties simultaneously: authenticity (the message came from the claimed signer), integrity (the message was not altered), and non-repudiation (the signer cannot later credibly deny having signed it). These properties make digital signatures foundational infrastructure. Every TLS-secured website presents a certificate signed by a certificate authority. Every piece of signed code relies on a signature check before execution. This includes everything from operating system kernels to mobile apps. Cryptocurrencies authorize every transaction with a signature over the transaction data. Software supply-chain security, DNSSEC, and secure email (S/MIME, PGP) all depend on the same core primitive. This article builds the concept from first principles. It covers the syntax of a signature scheme, and the security definition that captures "unforgeability." It also covers the two dominant real-world constructions, RSA-based signatures (RSA-PSS/PKCS#1) and ECDSA. We derive why each works, and analyze their complexity. We trace a worked numerical example. We also catalog the pitfalls that have caused real-world breaks — from Sony's PS3 signing-key leak to nonce-reuse disasters in ECDSA.
- A digital signature scheme has three algorithms: `KeyGen`, `Sign`, `Verify`, giving authenticity, integrity, and non-repudiation.
- Security is defined as existential unforgeability under chosen-message attack (EUF-CMA): no efficient forger can produce a valid signature on a new message even after seeing signatures on messages of its choice.
- RSA signatures sign a hash of the message raised to the private exponent; security needs padding schemes like PSS to avoid structural attacks.
- ECDSA signs using elliptic-curve scalar multiplication and modular arithmetic on the curve order; it needs a fresh, secret, unpredictable nonce for every signature.
- Nonce reuse or bias in ECDSA (or DSA) leaks the private key completely — this has broken real systems (Sony PS3, Android Bitcoin wallets).
- Digital signatures underpin Public-Key Infrastructure and Certificates and are the authentication backbone of The TLS Handshake.
A digital signature cryptographically binds a message to a private key so that anyone with the public key can verify authorship, but forging one requires solving a computationally hard problem.
The idea
A digital signature scheme is a triple of efficient algorithms . `KeyGen` outputs a key pair : a private signing key kept secret by the signer, and a public verification key published to the world. `Sign(sk, m)` takes the private key and a message and outputs a signature . `Verify(pk, m, \sigma)` takes the public key, the message, and a purported signature, and outputs accept or reject. Correctness requires that a signature honestly produced always verifies: for every valid key pair and message. This is structurally the mirror image of public-key encryption: encryption uses the public key to protect confidentiality, so only the private-key holder can undo it; signing uses the private key to produce a proof of authorship, so anyone with the public key can check it. The security goal is existential unforgeability under chosen-message attack (EUF-CMA): an adversary who can query a signing oracle on messages of its choosing should still be unable to output a valid pair for any message it did not explicitly obtain a signature for — even a nonsensical or garbled message. This is a stronger requirement than "can't forge a signature on a specific message"; it rules out forging any new message-signature pair whatsoever. In practice, one never signs a raw message directly. Instead, the message is first passed through a cryptographic hash function (e.g., SHA-256), and the signature is computed over the fixed-length digest . This serves two purposes: it makes signing efficient regardless of message length, and — critically for RSA — it destroys the multiplicative algebraic structure of the raw RSA function that would otherwise enable forgery attacks. The combination of hashing plus a specific algebraic signing operation, together with (for RSA) a randomized padding transform, constitutes a concrete scheme like RSA-PSS or ECDSA.
How it works
RSA signatures (textbook, then hardened). Recall RSA key generation: choose primes , set , choose public exponent coprime to , and compute private exponent . The public key is , the private key is (equivalently ). The naive ("textbook") RSA signature is , verified by checking . This works because RSA encryption and decryption are inverse permutations: whenever , by Euler's theorem. But textbook RSA signing is insecure on its own: it is multiplicative, meaning , allowing an attacker to combine signatures on chosen messages to forge a signature on a related, unrequested message. RSA-PSS (Probabilistic Signature Scheme) fixes this by applying a randomized, structured encoding function to before the modular exponentiation, using a fresh random salt each time, which destroys the exploitable algebraic relationship and — crucially — makes the scheme provably secure in the random oracle model.
ECDSA (Elliptic Curve Digital Signature Algorithm). Given a curve with base point of prime order , the signer's private key is a random scalar , and the public key is the point . Signing requires a fresh, secret, unpredictable per-signature nonce ; verification uses only public data. ```pseudocode // ===== ECDSA over a curve with base point G, order q ===== function KeyGen(): d ← random integer in [1, q-1] // private key Q ← d · G // public key (point) return (d, Q) function Sign(d, m): e ← H(m) mod q // hash, truncated/reduced mod q repeat: k ← random integer in [1, q-1] // MUST be fresh, secret, unpredictable (x1, y1) ← k · G r ← x1 mod q until r ≠ 0 s ← k^{-1} · (e + r·d) mod q until s ≠ 0 // (re-pick k if s = 0; probability ~0) return (r, s) function Verify(Q, m, (r, s)): if r ∉ [1, q-1] or s ∉ [1, q-1]: return reject e ← H(m) mod q w ← s^{-1} mod q u1 ← e·w mod q u2 ← r·w mod q (x1, y1) ← u1·G + u2·Q if (x1, y1) = O (point at infinity): return reject if r ≡ x1 (mod q): return accept else: return reject ```
RSA-PSS, side by side for comparison: ```pseudocode // ===== RSA-PSS (simplified) over modulus n, exponent e, private exponent d ===== function Sign(d, n, m): mHash ← H(m) salt ← random bytes of fixed length EM ← PSS_Encode(mHash, salt) // MGF-based padding, deterministic given salt σ ← EM^d mod n return σ function Verify(e, n, m, σ): EM' ← σ^e mod n mHash ← H(m) return PSS_Verify(EM', mHash) // recovers salt, recomputes MGF, compares ``` The public-key pair for RSA is and the private key is ; for ECDSA it is public and private, with the curve and as shared system parameters. In both schemes, signing uses the secret and verification uses only public quantities — the essential asymmetry that gives non-repudiation.
Complexity & correctness
Time complexity. For RSA signing (with an -bit modulus), the dominant cost is modular exponentiation , done via square-and-multiply in modular multiplications, each costing with schoolbook multiplication (or with FFT-based methods) — giving naive total, dramatically reduced in practice using the Chinese Remainder Theorem (CRT), which performs two exponentiations modulo the half-size primes instead of one modulo the full , yielding roughly a speedup. Verification uses the small public exponent (commonly ), needing only about 17 modular multiplications, so RSA verification is much faster than RSA signing — an important asymmetry: browsers verify certificates far more often than CAs sign them. For ECDSA over a curve with an -bit order, signing and verification both cost one or two scalar multiplications , each computable via double-and-add in point additions, each point addition costing field operations on -bit numbers. Concretely, ECDSA signatures are far smaller (a 256-bit curve gives ~64-byte signatures) than RSA's (256-byte for RSA-2048) for comparable security levels, because elliptic-curve discrete log currently has no known sub-exponential attack, whereas RSA's security rests on integer factorization, which is broken by the sub-exponential general number field sieve, forcing RSA to use much larger moduli for equivalent hardness.
Space complexity. RSA public keys are bits (– typically); ECDSA public keys are bits with – typically, giving roughly an order-of-magnitude space savings for equivalent conjectured security.
Correctness (why verification accepts honest signatures). RSA: by Euler's theorem, for any coprime to , whenever , which holds by construction of as the modular inverse of . So , matching what `Verify` recomputes. ECDSA: substitute into the verifier's computation. We have
but since , we get , so . Therefore
whose -coordinate is exactly by definition — so the check succeeds for any honestly generated signature. This is an algebraic identity, not a heuristic; it holds with certainty (not just high probability) whenever the arithmetic is done correctly.
Security (why forgery is hard — the honest tradeoffs). RSA-PSS is provably EUF-CMA secure in the random oracle model, assuming the RSA problem (inverting without ) is hard; hardness of the RSA problem is widely believed but not proven equivalent to factoring. ECDSA's security proof is comparatively weaker in general — no proof from a clean standard assumption is known for the "raw" DSA/ECDSA construction, though it is secure in idealized models (generic group model plus random oracle) and it has withstood decades of cryptanalysis when correctly implemented. Both schemes' security completely collapses if implementation details are violated: RSA signing must use structured padding (never sign raw hashes without PSS or a properly implemented PKCS#1v1.5), and ECDSA/DSA must never reuse or leak information about the nonce — a single repeated or partially known nonce across two signatures directly yields the private key via simple linear algebra (shown below).
Worked example
We trace a full ECDSA signature and verification over a small illustrative curve (small parameters are used purely for hand-computable arithmetic; real deployments use 256-bit+ curves like secp256k1 or P-256). Suppose (toy parameters, not cryptographically secure — for illustration only):
- Curve group with base point of prime order .
- Private key , so public key (a specific point, computed by the curve's group law — treated here as an opaque point since our focus is the signature arithmetic, not curve arithmetic itself).
- Message digest .
- Signer picks fresh random nonce .
- Suppose has -coordinate (a concrete value the curve's group law would produce).
Signing:
| Step | Computation | Result |
|---|---|---|
| 1 | ||
| 2 | (inverse of 3 mod 17: ) | |
| 3 | ||
| 4 |
Signature: .
Verification (verifier knows only , , ; recomputes ):
| Step | Computation | Result |
|---|---|---|
| 1 | (inverse of 4 mod 17: ) | |
| 2 | ||
| 3 | ||
| 4 | Compute point | equals ✓ |
| 5 | Take -coordinate of , compare to | matches accept |
The verifier recovers , exactly reconstructing the signer's secret nonce's scalar multiple , without ever learning or — confirming the algebraic identity derived above.
Now, the classic catastrophic failure — nonce reuse. Suppose the signer, careless or using a broken RNG, signs two different messages (digests ) using the same nonce . Then:
Since both use the same , they also share the same (as depends only on ). Subtracting:
Once is recovered, the private key falls out immediately:
This is not a theoretical curiosity — it is precisely the bug that exposed Sony's PlayStation 3 code-signing private key in 2010 (a fixed, non-random was used for every signature) and has recovered private keys from real Bitcoin wallets with buggy random number generators.
Common pitfalls & traps
| Pitfall | Why it happens | Consequence |
|---|---|---|
| Signing raw hash with textbook RSA (no PSS/OAEP-style padding) | Assuming RSA "just works" like modular exponentiation in a math class | Multiplicative structure allows existential forgery |
| Reusing or predicting the ECDSA/DSA nonce | Broken/seeded RNG, deterministic-but-wrong nonce, or hardware entropy failure | Full private-key recovery from two signatures (or even one, with partial nonce bias) |
| Confusing signing with encryption | Both use a "private/public key" pair, easy to mix mentally | Using the wrong key direction breaks confidentiality or authenticity entirely |
| Not verifying the entire certificate chain / trusting unpinned keys | Treating "signature verifies" as "identity is correct" without checking who the key belongs to | Valid signature from the wrong (attacker-controlled) key still passes `Verify` |
| Small or malleable exponent / signature malleability | Some schemes admit a second valid for the same message | Transaction malleability bugs (notably early Bitcoin) |
| Truncating or mis-hashing the message before signing | Off-by-one or incorrect digest length reduction mod | Signature verifies against a different intended message |
Pioneers & history
Digital signatures emerged directly from the invention of public-key cryptography, and RSA's own paper already proposed signing as well as encryption.
Origins · 1 minWhitfield Diffie and how this was discovered
Diffie, together with Martin Hellman, published the concept of public-key cryptography in 1976, explicitly proposing that a "digital signature" — asymmetric authentication using a key pair — should be achievable, before any concrete construction existed. Their paper framed the goal that RSA and later schemes would fulfill.
Rivest, Shamir, and Adleman's 1978 paper introducing RSA presented it as both an encryption scheme and a signature scheme in one stroke, using the same trapdoor permutation in reverse — the first concrete, practical realization of Diffie and Hellman's vision.
Elgamal's 1985 discrete-logarithm-based signature scheme introduced the algebraic template — a randomized nonce, a linear congruence tying message, nonce, and key together — that the U.S. government's Digital Signature Algorithm (DSA) and later ECDSA directly descend from.
Where this matters
Digital signatures are the authentication backbone of the modern internet and beyond. Every TLS certificate is a signature by a certificate authority binding a domain name to a public key, the foundation of Public-Key Infrastructure and Certificates; the server then proves possession of the corresponding private key during The TLS Handshake via a fresh signature over the handshake transcript. Code signing (Windows Authenticode, Apple's codesigning, Android APK signing) uses RSA or ECDSA signatures to let operating systems verify that an app or update genuinely came from its claimed publisher before executing it. DNSSEC signs DNS records to prevent cache-poisoning attacks. Cryptocurrencies like Bitcoin and Ethereum authorize every transaction with an ECDSA (or, increasingly, Schnorr/EdDSA) signature proving control of the spending key. Secure email standards (S/MIME, PGP) and document-signing platforms rely on the same primitives to provide legally recognized non-repudiation.
Ask the tutor: How does RSA-PSS's randomized padding formally prevent the multiplicative forgery attack that breaks textbook RSA signatures?
Is a digital signature the same thing as encryption?
No. Encryption protects confidentiality: data is transformed so only the holder of a decryption key can read it. A digital signature protects authenticity and integrity: it lets anyone with the public key confirm that a specific private-key holder produced this exact message, without hiding the message's content at all. In fact, signatures are typically sent alongside the plaintext message, not instead of it. The two are often combined — for instance, TLS both encrypts traffic and separately signs the handshake — but they solve different problems and use the key pair in opposite directions (encryption uses the public key to protect the sender's input; signing uses the private key to protect the signer's output claim).
Why do RSA and ECDSA both need a hash function, and does the choice of hash matter?
Signing schemes operate on fixed-size algebraic inputs (a residue mod n for RSA, a scalar mod q for ECDSA), but real messages can be arbitrarily long. Hashing first compresses the message to a fixed-length digest, letting one signing algorithm handle messages of any size efficiently. The hash choice matters enormously: if the hash function is not collision-resistant, an attacker can find two distinct messages with the same digest, get one signed, and present the signature as valid for the other. This is exactly why standards mandate strong, current hash functions such as SHA-256 or SHA-3, and why deprecated hashes like MD5 or SHA-1 are barred from new signature deployments.
What happens if a signer's private key is stolen?
The thief can forge signatures indistinguishable from the legitimate signer's for any message, completely defeating both authenticity and non-repudiation until the compromise is detected and the key revoked. This is why real systems build in revocation: certificate authorities publish certificate revocation lists (CRLs) or use the Online Certificate Status Protocol (OCSP) so relying parties can check that a public key has not been marked compromised, a mechanism central to Public-Key Infrastructure and Certificates. Hardware security modules (HSMs) and secure enclaves are widely used specifically to make private-key extraction extremely difficult even for attackers with system access.
Why does ECDSA need a random nonce at all — why not just make it deterministic from the start?
Early DSA/ECDSA specified a random nonce because it was believed simplicity and provable-security arguments favored fresh randomness per signature. In practice, however, weak or predictable random number generators repeatedly caused catastrophic key leaks (Sony PS3, Android Bitcoin wallets). The community's answer was RFC 6979: derive the nonce deterministically from the private key and the message digest via HMAC, so the same message always produces the same nonce, but no two distinct messages ever reuse it, and no external randomness source is needed at all. This eliminates the entire class of nonce-reuse bugs while preserving the same verification algorithm unchanged.
Can a digital signature scheme be broken by quantum computers?
Yes, both RSA and ECDSA are vulnerable to a sufficiently large fault-tolerant quantum computer running Shor's algorithm, which solves integer factorization and discrete logarithms (including elliptic-curve discrete logs) in polynomial time. This has driven active standardization of post-quantum signature schemes — such as lattice-based Dilithium and hash-based SPHINCS+ — selected by NIST to eventually replace RSA and ECDSA in signature applications. Today's systems remain safe because large-scale fault-tolerant quantum computers do not yet exist, but the migration is being planned proactively given the long lifetimes of signed root certificates and firmware.
Why do different signature schemes produce different signature sizes for "equivalent" security?
Security level and signature size depend on the underlying hard problem's best-known attack complexity. RSA's security rests on integer factorization, breakable by the sub-exponential general number field sieve, so RSA needs very large moduli (2048–4096 bits) to reach a target security level, yielding correspondingly large signatures. Elliptic-curve discrete logarithm has no known sub-exponential attack, only the generic square-root-time Pollard's rho, so a much smaller curve (256–384 bits) achieves the same security, giving ECDSA signatures roughly a quarter to an eighth the size of comparable RSA signatures — a major reason ECDSA is preferred in bandwidth- or storage-constrained systems like blockchains and mobile devices.
What is signature malleability, and why did it matter for Bitcoin?
Some signature encodings admit more than one valid byte representation for the same logical signature — for ECDSA, both and satisfy the verification equation for the same message and key. Historically, Bitcoin computed transaction IDs by hashing the entire signed transaction, including the signature bytes, so an attacker could take a valid transaction, flip the malleable value to the other valid form, and produce a different transaction ID for what was semantically the identical transaction. This confused systems that tracked transactions by ID and contributed to disputes and exchange failures; the fix (canonical low- signature encoding, and later SegWit) removed the signature bytes from the malleable part of the transaction ID.