Path: blob/main/foundations/06-elliptic-curves/break/ecdsa-nonce-reuse.ipynb
483 views
Break: ECDSA Nonce Reuse (The PlayStation 3 Hack)
Module 06 | Breaking Weak Parameters
When the same nonce is used for two ECDSA signatures, the private key falls out with simple algebra.
Why This Matters
In 2010, the hacker group fail0verflow revealed that Sony used the same nonce for every ECDSA signature on PlayStation 3 firmware updates. This single mistake allowed them to recover Sony's master private signing key, enabling anyone to sign and run arbitrary code on the PS3.
The mathematics behind the attack is shockingly simple: two equations, two unknowns, basic algebra. If you understood ECDSA signing from Notebook 06f, you already have everything you need to break it.
This attack also hit Android Bitcoin wallets in 2013 (a faulty random number generator repeated nonces) and continues to appear in poorly implemented systems.
The Scenario
Alice signs two different messages and using ECDSA with the same nonce . The attacker (Eve) intercepts both signatures.
Recall ECDSA signing (from Notebook 06f):
Pick nonce , compute , set .
Compute , where and is the private key.
Output signature .
If the same is used for both signatures, both share the same (since is identical). This is the telltale sign an attacker looks for.
Let's set up the scene.
Step 1: Alice Signs Two Messages with the Same Nonce
Alice commits the fatal error: she uses the same nonce for two different messages.
Signature 1:
Signature 2:
Both signatures share the same because is identical.
Step 2: The Algebra of the Attack
Eve sees two signatures with the same . She writes down the two signing equations:
Subtract the second from the first:
The private key cancels out! Solve for :
Once Eve has , she recovers the private key from either signing equation:
The Fix: RFC 6979 Deterministic Nonces
The root cause is that ECDSA requires a fresh, unpredictable, never-repeated nonce for every signature. This is a dangerous requirement: one failure is catastrophic.
RFC 6979 (2013) eliminates this risk by deriving deterministically:
This means:
The same pair always produces the same (and thus the same signature).
Different messages produce different values (since differs).
No randomness is needed at signing time, so there is no RNG to fail.
EdDSA (Ed25519) takes this further: the nonce is derived as where the prefix is derived from the private key. Deterministic nonces are baked into the design, not bolted on as an afterthought.
Exercises
Known offset: Suppose instead of reusing exactly, the attacker knows that for a known offset . Modify the attack to recover . Hint: subtract the two signing equations and solve the resulting system.
Detection: Given a list of 100 ECDSA signatures, write code to check whether any two share the same value (indicating nonce reuse). How many comparisons are needed?
Partial nonce leakage: If an attacker learns just the top 8 bits of (not the full value), can they still recover ? Research the lattice-based nonce recovery attack (Howgrave-Graham and Smart, 2001).
Summary
| Aspect | Detail |
|---|---|
| Vulnerability | Reusing nonce in two ECDSA signatures |
| Telltale sign | Two signatures with the same value |
| Attack | , then |
| Consequence | Full private key recovery; attacker can forge any signature |
| Real-world victims | PlayStation 3 (2010), Android Bitcoin wallets (2013) |
| Fix | RFC 6979 deterministic nonces, or use EdDSA |
The nonce-reuse attack is a reminder that cryptographic protocols can be mathematically sound but operationally fragile. A single implementation mistake (reusing a random value) collapses all security. This is why modern designs like EdDSA eliminate randomness from the signing process entirely.
Back to Module 06: Elliptic Curves