MASTERING-BITCOIN ยท Interactive Practice | Unit 9 ยท Video 4
| Formula | Name | Description |
|---|---|---|
| ECDSA signing equation | = priv key, = nonce, = msg hash, = x-coord of | |
| Nonce recovery (reused ) | If two signatures share , anyone can recover it | |
| Private key recovery | Once is known, falls out | |
| RFC 6979 deterministic nonce | Same โ same , different โ different |
Conceptual question: How does the signing equation transform inputs into a signature?
Use the sliders below to vary the private key , the nonce , and the message hash . We use the toy modulus from the video so the arithmetic is easy to follow. The pretend value of is also a small slider (in real ECDSA, is the x-coordinate of , but for this exercise we treat it as an independent input).
โ interactive visualization โ coming to this page format soon
Notice: Each different produces a different . In real Bitcoin, is roughly , but the structure is identical. The signature pair is what gets DER-encoded and broadcast on the network.
Conceptual question: What exactly leaks when the same is used to sign two different messages?
Below, a fixed private key signs two messages and using the same nonce . The slider lets you change . Watch the recovered private key (computed using only the two public signatures) match exactly โ proving that anyone observing the two signatures can drain the wallet.
โ interactive visualization โ coming to this page format soon
Reflect: Notice that the attacker never sees or โ only the two signatures and . The fact that is identical in both is the public tell-tale sign of nonce reuse. This is exactly the bug that drained Android wallets in 2013 and cracked the Sony PS3.
Conceptual question: How badly does legacy sighash scale, and how much does BIP143 improve it?
The slider below sets the number of inputs in a transaction. The plot compares legacy sighash work () against BIP143 sighash work (). Watch the gap explode as grows.
โ interactive visualization โ coming to this page format soon
Notice: At , legacy sighash performs roughly a million hashing
operations while BIP143 performs about a thousand. That 1000ร gap is exactly
the denial-of-service vector SegWit closed by precomputing hashPrevouts,
hashSequence, and hashOutputs once per transaction.
Question 1
Why did Satoshi ship Bitcoin with ECDSA instead of the cleaner Schnorr signature scheme?
โ Correct! Patent timing forced the choice.
โ Not quite. The reason was not technical superiority โ Schnorr is actually cleaner. Think about timing.
Solution:
The Schnorr signature scheme was filed as a patent in 1989 and only expired in 2008. By the time Bitcoin launched in 2009, every cryptographic library shipped ECDSA and almost none shipped Schnorr โ so Satoshi made the pragmatic choice. Ironically, Schnorr has the cleaner math (linear, with a complete security proof), and Taproot finally activated Schnorr in 2021, closing a loop that opened in 1989.
Question 2
A signer uses the same nonce to produce two ECDSA signatures and on different message hashes . Which statement is true?
โ Correct! Reused nonce โ full key compromise.
โ Not quite. Look at what cancels when you subtract the two signing equations.
Solution:
Subtracting the two signing equations: gives the attacker:
Once is known, plug it back into either signing equation:
Two signatures, four lines of algebra, total compromise. This is exactly the
bug that hit Sony PS3 (2010), Android SecureRandom (2013), and Blockchain.info's
RNG (2014).
Question 3
True or False: RFC 6979 defends against bad randomness by mixing in more entropy from the operating system.
โ Correct! RFC 6979 eliminates randomness rather than adding more.
โ Not quite. The RFC 6979 fix is structural, not statistical.
Solution: False.
RFC 6979 does the opposite: it removes randomness entirely. The nonce is derived deterministically as so the same private key signing the same message always produces the same , and different transactions automatically produce different values because the message hash differs.
Optional extra entropy can be mixed in for side-channel resistance, but it is no longer load-bearing โ a broken RNG can no longer leak your private key. The deeper lesson: the signing math doesn't care whether is random, it cares that is unique and unpredictable. Determinism gives you both.
Question 4
Before SegWit, computing the legacy sighash for a transaction with inputs cost roughly work. BIP143 restructured the sighash to scale linearly. What was the key engineering trick?
โ Correct! Precomputed midstates turn quadratic work into linear work.
โ Not quite. The hash function and the SIGHASH flags didn't change โ the trick is structural reuse.
Solution:
BIP143 (shipped with SegWit in 2017) precomputes three midstate hashes once per transaction:
hashPrevouts โ commits to all input outpointshashSequence โ commits to all sequence numbershashOutputs โ commits to every outputEach input's sighash now references those three precomputed values plus its own small per-input data, so total work is instead of . A 1000-input transaction validates roughly 1000ร faster, closing the denial-of-service vector that lurked in legacy consensus rules. People remember SegWit for fixing malleability and effectively raising the block size โ the sighash redesign is the equally important third win.
Solved: 0 / 4