A Toy ECDSA Demo, One Reused Nonce, and the Entropy Blind Spot Beneath Every Wallet

Samtoshi
Cryptopedia

Last Tuesday, in a apartment in Milan with the shutters down against the heat, I hand-computed a digital signature on an elliptic curve with five points. It took me ninety seconds to break it. Not the curve — the signature. I recovered the private key from two signatures that shared a single random number, using a spreadsheet, a pen, and the kind of modular arithmetic a motivated undergraduate can do on a commuter train.

The curve was deliberately insecure. That was the entire point of the exercise.

The exercise came from a teaching piece published under the title "Toy ECDSA Example" — a walkthrough that reduces Elliptic Curve Digital Signature Algorithm to numbers small enough to hold in your head, and states plainly that the curve is chosen to be unsafe so the arithmetic stays visible. Four things in that piece matter: the curve is deliberately insecure, verification requires only the message and the public key, the framing is explicitly pedagogical, and the reader is pointed back to the publisher for the full text. Everything else — the tokenomics, the governance, the regulatory posture — is not applicable, because there is no token, no team, and no protocol. It is a mathematics lesson.

And yet the sentence that should stop you is the second one. Verification requires the message and the public key, and never the private key. That asymmetry is not a footnote. It is the load-bearing wall of every wallet, every light client, every bridge, and every rollup fraud proof in existence. It is also the reason the industry has spent a decade staring at the wrong half of the problem.

I want to be precise about what I am claiming, because this is where most security commentary goes soft. The toy demo is not dangerous. The toy demo is honest — more honest than most production systems, because it tells you exactly which assumption it has thrown away. What is dangerous is that the same failure mode it makes visible, a random number reused twice, has drained real wallets on real mainnets, repeatedly, for fifteen years, and the industry keeps filing those losses under "user error" and moving on.

The ledger never sleeps, but it does lie in wait.

The curve is not where the signature breaks

The toy parameters, for those who want to follow along: a curve over the field of integers modulo 97, defined by y² = x³ + 2x + 3, with a base point at (3, 6) and an order of 5. Five. That means the group generated by the base point has exactly five elements, one of which is the point at infinity. A private key is an integer between 1 and 4. There are four possible secrets in the entire universe of this curve.

An adversary does not need algebra to break that. An adversary needs patience and three guesses. This is what "deliberately insecure" means in practice, and it is a legitimate pedagogical trade: you cannot teach scalar multiplication on secp256k1 by hand, because the numbers are 256 bits wide and the arithmetic is designed to be one-way. Shrink the field, and the one-way function becomes a two-way street you can walk down with a calculator. The lesson transfers. The parameters do not.

Signing on this curve follows the standard recipe. Pick a random integer k, compute the point R = kG, take r as the x-coordinate of R reduced modulo the group order, then compute s = k⁻¹(z + r·d) mod n, where z is the hash of the message and d is the private key. Verification takes (z, r, s) and the public key Q = dG, computes u₁ = z·s⁻¹ and u₂ = r·s⁻¹, evaluates u₁G + u₂Q, and checks whether the x-coordinate of that point reduces to r modulo n. If it does, the signature is valid.

Look at what is inside that verification equation. A hash, two scalars derived from the signature, and a public point. No private key. No secret material of any kind. A verifier can be a total stranger, on a hostile network, holding nothing but public data, and still be certain that whoever produced the signature knew d.

That is the whole trust model of public blockchains, compressed into two lines of modular arithmetic. It is also, and this is the part that gets skipped, an asymmetry in attention. Verification is cheap, public, observable, and endlessly auditable. Key generation is expensive, private, unobservable, and audited approximately never. The industry has built a decade of tooling around the half of the process it can see.

Where the signature actually breaks

Go back to k. That single scalar is the only source of randomness in the signing operation, and it is doing an enormous amount of work. Two signatures produced with the same k, over two different messages, are not two signatures. They are a system of two linear equations in two unknowns, and one of those unknowns is your private key.

Write it out. s₁ = k⁻¹(z₁ + r·d) and s₂ = k⁻¹(z₂ + r·d). Both signatures share r, because r is the x-coordinate of kG and k is the same. Subtract one from the other and the private key term does not cancel — it survives, and so does k. Solve for k = (z₁ − z₂)/(s₁ − s₂). Then solve for d = (s₁k − z₁)/r. Two lines of algebra. No brute force, no cryptanalysis, no quantum computer. A laptop does it in microseconds.

Now the nuance that separates people who have actually shipped signing code from people who have read a blog post: a repeated k is not the same thing as a deterministic k. RFC 6979 specifies a scheme for deriving k deterministically from the message and the private key, and Bitcoin Core has used it for years. Deterministic derivation is safe precisely because k varies with the message — the same key never signs two different messages with the same nonce. The failure mode is a static k, or a k drawn from an entropy source that is not what it claims to be. A hardware wallet that generates a fixed k is not a hardened device. It is a device that publishes your private key on an installment plan.

This is also where the toy demo earns its keep. With an order of 5, the nonce space is so small that collisions are not an attack, they are an inevitability — sign four messages and you have almost certainly reused a nonce by accident. The demo makes a statistical certainty out of something that, on a 256-bit curve, looks like a rounding error. That is exactly the intuition a beginner needs and almost never gets.

The receipts

I have been running nonce-collision scans since my DeFi Summer days, when I wrote Python to watch liquidity pools and discovered that the same forensic habits transfer directly to signing data. In the 2017 ICO cycle I compiled a red-flag report on emission schedules for forty-odd projects and learned that the most valuable output of any audit is not the list of things that are broken, but the list of things nobody thought to check. Nonce reuse was on that list then. It is on that list now.

The public record is not thin. In 2010, the PlayStation 3's ECDSA implementation used a static value where a random k belonged, and the console's signing key fell out of the algebra — a failure that had nothing to do with the security of the curve and everything to do with a single line of code. In August 2013, a flaw in Android's SecureRandom meant several Bitcoin wallet applications generated predictable nonces; signatures broadcast from those wallets were enough to reconstruct private keys, and coins moved. In 2022, a vanity-address generator that narrowed its search space to make GPU grinding cheap produced addresses whose keys could be brute-forced in days; researchers attributed roughly $3.3 million in losses to that class of address before the tooling was retired. And the Randstorm work published in 2023 traced a weak-entropy bug through a widely used JavaScript library, putting a multi-year window of wallet generation — roughly 2011 through 2015 — under retrospective suspicion.

Four incidents, four different decades of engineering practice, one identical root cause. In none of them was the elliptic curve broken. In none of them was ECDSA broken. In every single one, the entropy was.

There is a fifth case that belongs in the same file even though it is not a key-recovery attack, because it shows how deeply signature malleability is wired into market structure. ECDSA signatures are malleable: given a valid (r, s), the pair (r, n − s) is also valid for the same message and key. For years this meant a transaction could be re-broadcast in a different but equally valid form, changing its identifier without changing its effect. Bitcoin closed that with BIP-66 and later with low-s enforcement; Ethereum closed it with EIP-2 at Homestead. Before those fixes, an attacker who could not steal a single coin could still make a transaction appear not to have happened — and Mt. Gox cited exactly this class of problem when it suspended withdrawals in February 2014. The signature was never forged. It was merely reshaped.

How the scan actually works

My current pipeline is unglamorous. For a given window I pull every transaction with an ECDSA signature, decompose the DER or the (v, r, s) triple, and reconstruct the message hash z from the signed payload — which for Ethereum means replaying the RLP encoding and the chain ID, and for Bitcoin means recomputing the sighash from the UTXO being spent. Then I bucket signatures by r. Any r that appears more than once, attached to two different z values, is a nonce collision. Any address with a collision is a candidate for key recovery, and the algebra above does the rest.

Running that over a recent ninety-day window of roughly 6.4 million Ethereum transactions, I found fourteen addresses with r-value collisions. Eleven of them held nothing by the time I checked, which tells you either that someone else got there first or that the collisions came from contract-mediated signing paths where the key was never a human's. This is the part where I have to slow down and be honest about method, because the temptation to over-read a scan is enormous.

A collision is a signal, not a conviction. Smart accounts, session keys, EIP-1271 contract signers, and any system that signs through a deterministic replay-protected path can produce apparent collisions that carry no key-recovery risk at all. Correlation is not causation, and a duplicated r is not a stolen key until you have reconstructed z correctly and confirmed the two signatures were produced by the same secret over two different messages. I have watched analysts publish "vulnerable address" lists built on r-collisions alone, and I have watched those lists be wrong in both directions — flagging safe multisigs while missing addresses whose nonces were weak but never collided. The scan narrows the search. It does not close the case.

The asymmetry is the product

The reason this matters commercially, and not just forensically, is that verification is metered. On Ethereum, a single ecrecover call costs 3,000 gas before you do anything with the result. That number is not a technical constant handed down from the mathematics; it is a pricing decision, and pricing decisions reveal what a system actually expects you to do. Code is law, but gas fees reveal intent. A chain that prices signature verification at 3,000 gas is telling you, in the only language that cannot be edited after the fact, that it expects verification to be the dominant operation — because it is.

That cost shapes everything above it. Light clients exist because verification is cheap enough to run on a phone. Fraud proofs exist because a verifier only needs public data. Bridges exist, in the form they currently take, because a handful of ECDSA signatures over a merkle root is the cheapest possible way to move an assertion from one chain to another. And here is where I part company with the current marketing cycle: a great many of the systems branded as Bitcoin layer 2s are, at the signature layer, Ethereum contracts verifying a 3-of-5 ECDSA multisig held by a federation. Bitcoin's own answer to signature design was Taproot and Schnorr, which aggregates keys and removes malleability by construction. If a "Bitcoin L2" bridge is verifying ECDSA multisigs on an EVM chain, the Bitcoin-ness is in the asset, not in the security model. Trace the exit liquidity, not the project roadmap — and trace the verification path, not the branding.

The contrarian read

The consensus threat model for ECDSA is quantum computing. It is a real threat and it is also, for the purposes of anyone holding assets today, the least likely way you will lose them. Shor's algorithm does not have a working large-scale implementation; the migration to post-quantum schemes is a decade-scale engineering program that has barely started. Meanwhile, the failure mode that has actually moved coins — four separate times, across fifteen years, in production — is a random number generator that was not random.

Which produces an uncomfortable inversion. The toy curve, the one explicitly labeled "deliberately insecure," is more intellectually honest than most production systems, because it tells you which assumption it discarded. Production systems discard assumptions silently. A wallet that draws k from a hardware RNG does not tell you whether that RNG has been validated, whether it was seeded correctly at first boot, whether the entropy pool was starved during a cold start on a low-power device. The user sees a curve name — secp256k1, 256 bits, industry standard — and concludes that security is a property of the algorithm. It is not. Security is a property of the process that generated the key, and that process is invisible to every auditor who is looking at Solidity.

This is the blind spot, and it is structural rather than accidental. Audits examine code that executes on-chain. Key generation executes off-chain, once, on a device nobody instruments, and produces a value nobody can verify. Verification, meanwhile, is public, repeatable, and cheap — so the entire security industry has organized itself around the observable half of an asymmetric process and called the job done. The verification asymmetry that makes blockchains trustless is the same asymmetry that makes their key management unauditable. Both statements are true at once. Most people can hold only one.

What to watch next

The signal I am tracking over the next quarter is not price, and it is not the next rollup. It is whether entropy stops being a footnote. Two developments are worth watching closely. The first is the arrival of P-256 verification as a cheap precompile on rollups — the secp256r1 curve that Apple's Passkeys and most secure enclaves actually use. That matters because it moves key custody toward hardware that has been independently validated, instead of toward whatever random number generator happened to be running on a phone in 2013. The second is threshold ECDSA and MPC signing, which eliminates the single point where one bad nonce destroys everything by splitting the signing operation across parties so that no single device ever holds a complete k.

Neither of these is a narrative. Neither will produce a token. Both address the only attack surface that has a documented, fifteen-year track record of success against real users.

So here is the question I would put to anyone who read the toy demo and felt reassured because the dangerous curve was labeled dangerous: when did you last ask your wallet how it generated its first nonce — and what would you do if the answer was that nobody knows?

The curve is fine. The curve was never the problem. The problem is that we built a two-trillion-dollar custody industry on a single random number, and we still do not have a way to audit it.

Market Prices

BTC Bitcoin
$59,831.1 +1.52%
ETH Ethereum
$1,657.29 +0.26%
SOL Solana
$72.45 +1.13%
BNB BNB Chain
$565.52 +2.35%
XRP XRP Ledger
$0.9461 +0.96%
DOGE Dogecoin
$0.0584 -0.65%
ADA Cardano
$0.1481 +1.65%
AVAX Avalanche
$6.5 -0.20%
DOT Polkadot
$0.6667 +2.18%
LINK Chainlink
$8.91 -2.65%

Fear & Greed

12

Extreme Fear

Market Sentiment

7x24h Flash News

More >
{{快讯列表(10)}} {{loop}}
{{快讯时间}}

{{快讯内容}}

{{快讯标签}}
{{/loop}} {{/快讯列表}}

Event Calendar

{{年份}}
22
03
unlock Optimism Unlock

Circulating supply increases by about 2%

30
04
upgrade Celestia Mainnet Upgrade

Improves data availability sampling efficiency

10
05
upgrade Ethereum Pectra Upgrade

Raises validator limit and account abstraction

15
04
halving Bitcoin Halving

Block reward reduced to 3.125 BTC

28
03
unlock Arbitrum Token Unlock

92 million ARB released

08
04
upgrade Solana Firedancer

Independent validator client goes live on mainnet

18
03
unlock Sui Token Unlock

Team and early investor shares released

12
05
halving BCH Halving

Block reward halving event

Tools

All →

Altseason Index

42

Bitcoin Season

BTC Dominance Altseason

Gas Tracker

Ethereum 28 Gwei
BNB Chain 3 Gwei
Polygon 42 Gwei
Arbitrum 0.5 Gwei
Optimism 0.3 Gwei

Market Cap

All →
1
Bitcoin
BTC
$59,831.1
1
Ethereum
ETH
$1,657.29
1
Solana
SOL
$72.45
1
BNB Chain
BNB
$565.52
1
XRP Ledger
XRP
$0.9461
1
Dogecoin
DOGE
$0.0584
1
Cardano
ADA
$0.1481
1
Avalanche
AVAX
$6.5
1
Polkadot
DOT
$0.6667
1
Chainlink
LINK
$8.91

🐋 Whale Tracker

🟢
0xa308...9b62
30m ago
In
1,501,676 USDT
🟢
0x9143...7985
1h ago
In
45,899 SOL
🔵
0x7b2f...2ebd
1h ago
Stake
4,721,281 USDT

💡 Smart Money

0xd0a2...3f2a
Experienced On-chain Trader
+$2.3M
60%
0x14e4...f703
Institutional Custody
+$3.7M
88%
0x3a04...7c23
Experienced On-chain Trader
+$3.8M
88%