November 25, 2026
Weak Key Generation: Crypto’s Invisible Failure Mode
Nonce reuse leaves a scar you can read off the chain. A bad random number at key generation leaves nothing at all.

By 0xRadar
7 min read
TL;DR
- In our previous post we read all 1,646,869,607 legacy Bitcoin signatures for reused nonces and found that every recoverable key was empty. The risk had moved one step earlier, to key generation, so we went there.
- A weak nonce is visible: it writes a repeated r into the ledger forever. A weak key is invisible: it leaves no on-chain artifact at all. The only way to detect it is to rebuild the faulty generator and enumerate its entire output.
- We did that for every publicly known weak-keygen class: Milk Sad (mt19937-from-time, 2³² seeds), Trust Wallet browser extension (CVE-2023–31290) and iOS (CVE-2024–23660), Coldcard-Mk3 Yasmarang, Profanity, Randstorm/BitcoinJS, and the firmware RNG-fallback paths in Specter / BitBox / Keystone / Jade / Passport, plus Arduino/glibc small-seed and uBitcoin.
- Example scale: the Milk Sad full-2³² sweep across four chains ran in 4.91 hours at 243,000 seeds/second against funded sets of 457K BTC / 4.37M LTC / 8.05M DOGE / 843K ZEC addresses. Result: zero reachable funded keys.
- Every class came back the same way: reference-verified, enumerated, clean or already swept. A negative result is still a result, and this is the most complete negative map of the class we know of.
- The thesis: because keygen failure is invisible, "no public reports of losses" tells you nothing. Detection is an act of reconstruction, not observation.
Two ways randomness fails, and why only one of them is visible
Every private key and every signature a wallet produces leans on the same fragile input: randomness.
There are two distinct places it is consumed, and they fail very differently.
At signing, a wallet needs a one-time nonce k. If that number ever repeats, the private key is recoverable with grade-school modular arithmetic, and crucially, the repeat is permanently visible in the two signatures' shared r value. That is the subject of our previous post: we read all 1.65 billion legacy Bitcoin signatures, and the failure, where it existed, was sitting right there on the chain to be read.
At key generation, a wallet needs entropy to seed a key or a BIP39 mnemonic. If that entropy is weak, a 32-bit seed, a timestamp, Math.random(), an uninitialized RNG that fell back to a default, the resulting key is drawn from a tiny set instead of a 256-bit one. And here is the asymmetry that defines this entire problem:
A weak key leaves no artifact. The key looks exactly like a strong one. The address looks exactly like any other address. Nothing on the chain distinguishes a key drawn from 2³² possibilities from one drawn from 2²⁵⁶.
You cannot scan for it. There is no repeated value to group by, no structural tell in the transaction. The only way to know whether a generator was weak is to rebuild the generator, enumerate every key it could ever have produced, derive the addresses, and check them against the chain. Detection is reconstruction.
This is why the class stays under-measured. Nonce reuse you can find by reading. Keygen weakness you can only find by rebuilding, one wallet, one firmware, one library at a time.
So we rebuilt them.
The method, once, in general
For every known class the pipeline is the same shape:
- Recover the construction from primary sources, the CVE, the vendor commit, the disclosure writeup, until we can state the generator exactly: which PRNG, seeded with what, reduced how, feeding which derivation path.
- Build a CPU reference and prove it against ground truth. This is the step that separates measurement from guessing. If researchers have published victim addresses or test vectors, our reconstruction must reproduce them exactly before we trust it for anything. We call this the golden gate. No golden gate, no result.
- Enumerate the full seed space, on GPU where the space is 2³², deriving the standard address paths for each candidate.
- Membership-test each derived address against a local set of funded addresses, so a hit is a funded hit, not just a valid key.
Everything runs against public chain data with a from-scratch cryptographic core, so no result depends on the same library that generated it. Where a check touched anything live, it went through responsible disclosure and is not detailed here.
The classes, and where each one stands
Milk Sad (CVE-2023–39910). A widely copied tool seeded Mersenne Twister (mt19937) from a 32-bit time value and read a BIP39 mnemonic out of it. The entire key space is 2³², fully enumerable. We rebuilt the construction (confirmed against the canonical seed-0 mnemonic), passed a 4-chain golden gate 16/16, and swept the complete 2³² space across Bitcoin, Litecoin, Dogecoin and Zcash in 4.91 hours at 243,000 seeds/second, testing against funded sets of 457K / 4.37M / 8.05M / 843K addresses respectively. Zero reachable funded keys in the scanned configuration. The known-victim coins were swept long ago.
Trust Wallet browser extension (CVE-2023–31290). We reproduced the reference construction 100% and confirmed the affected keyspace is swept.
Trust Wallet iOS (CVE-2024–23660). A separate, iOS-only bug: a minstd 16807 linear congruential generator, seeded once from time(), producing a 12-word mnemonic, two reduction variants, a combined space under 2³². We verified the construction the hard way: our CPU reference regenerated 528 published victim addresses inside a single day's worth of seeds, which pinned down the exact multiplier, convention and byte reduction. Ground truth was 6,572 known victim mnemonics (4,455 + 2,117 across the two variants). We then checked current balances of the known victim addresses: a few hundred still hold anything at all, and all of it is dust, the largest around 0.00000076 of a coin. Published, then swept to the gas floor.
Coldcard-Mk3 Yasmarang. A 2³² space from the Yasmarang generator. We ran the full enumeration across a 6-shard job to completion. Clean.
Profanity. The vanity-address generator whose 32-bit seed famously cost several large thefts. We checked both the forward enumeration and the man-in-the-middle refinement. The reachable space is swept.
Randstorm / BitcoinJS. The 2011–2015 SecureRandom weakness in a foundational JS library. We stood up the reconstruction framework and confirmed the lesson that makes this one treacherous: a blind scan without a ground-truth anchor is a trap, because the realistic per-key probability is too low to distinguish from noise without one. The recoverable altcoin surface here was already covered by prior published work.
Firmware RNG-fallback. Hardware wallets that, under some fault condition, could fall back from the secure element's RNG to a weaker software path: Specter, BitBox, Keystone, Jade, Passport. We walked each fallback path. All clean.
Small-seed and embedded. Arduino/glibc random() with a small seed (917K addresses derived and checked) and uBitcoin's fixed-Yasmarang path (58K addresses), alongside a sweep of the obvious code-hunt targets, java.util.Random, Math.random, go math/rand seeded from constants or time. Every hit was a demo, a dead coin, or an attack tool, never a funded, undiscovered wallet.
The pattern in the negatives
Put the whole table in one place and a single shape emerges. Every class is in one of two states:
- Swept: the construction is weak, it was disclosed, and automated collectors drained the funded keys years ago (Milk Sad victims, Trust Wallet, Profanity).
- Clean: the construction we feared turns out to be fail-safe. The fallback never triggers, the RNG throws instead of degrading, or the "weak" code path is not on the keygen path at all.
There is no third state in the public set. Nobody is sitting on a known-weak construction with funded, un-swept keys waiting to be enumerated, because the moment a construction is both known and weak, enumeration is cheap, and someone already did it.
Why this result was inevitable
The economics here are even more lopsided than for nonce reuse.
A known weak generator is a fully enumerable, public target. The seed space is small by definition, that is what "weak" means. Rebuilding it is a weekend of work, and enumerating 2³² addresses is now hours on commodity hardware, as our own Milk Sad timing shows. The payoff is instant and the barrier to entry is nearly zero.
So the same equilibrium from our last post applies, harder:
If a weak construction is publicly known, its funded keys are already gone. What survives in a known-weak class is only dust, the amounts not worth a sweeper's transaction fee.
Which means the valuable keygen failures, if any remain, are precisely the ones that are not yet public, a construction nobody has reconstructed, in software whose weakness has not been disclosed. And those are invisible by exactly the mechanism in the first section. You cannot scan for them. You can only find them by rebuilding a generator you do not yet know is broken.
That is a genuinely hard problem, and it is a different kind of hard from nonce reuse. Nonce reuse was a reading problem. Weak keygen is a reconstruction problem with no map.
What this means if you build or hold
If you build wallets: the single most important property your key generator can have is fail-safe, not fail-degraded. The Trust Wallet iOS and the firmware-fallback cases are the whole lesson. A generator that throws an error when the OS CSPRNG is unavailable is safe. A generator that silently falls back to Math.random(), a timestamp, or a default-seeded PRNG produces keys that are catastrophically weak and indistinguishable from good ones. There is no telemetry that will ever catch it. Pull the RNG decision to compile time: call the OS CSPRNG (getrandom, SecRandomCopyBytes, crypto.getRandomValues) and treat its absence as a fatal error, never as a reason to improvise.
If you hold coins: a key generated on a known-weak wallet during its vulnerable window should be considered public, regardless of whether it was ever touched. Move the funds to a key generated by a current, audited wallet. A remaining balance is not evidence the key is safe; it may simply be below a collector's fee threshold.
Reproducibility
- Constructions were recovered from published CVEs, vendor commits, and disclosure writeups, then frozen as CPU reference implementations.
- Each reconstruction had to pass a golden gate, regenerating researcher-published victim addresses or canonical test vectors exactly, before any sweep was trusted.
- Enumeration ran on commodity GPU for the 2³² spaces; membership testing used locally held funded-address sets derived from public chain snapshots.
- Key verification used a from-scratch cryptographic core, independent of the generation code.
- We publish no keys, seeds, addresses, or recovery artifacts. The aggregate status of each class is the result.
What's next
If nonce reuse is a graveyard and the known weak-keygen classes are swept or clean, a fair question is whether the whole nonce side of ECDSA is simply finished. In the next post we make that case directly: why RFC 6979 structurally ended nonce failure on every modern chain, and why every attempt to squeeze value out of a biased nonce, lattice attacks, Bleichenbacher, returns provably nothing on today's data.
Read the first post in this series, the 1.65-billion-signature nonce-reuse scan, here: https://medium.com/@0xradarapp/we-recovered-306-bitcoin-private-keys-all-were-empty-724de27bdfcd
Disclaimer
This research was conducted with AI assistance (large language models used for code generation, data analysis, and drafting). All findings were independently verified against reference implementations and public blockchain data; no result is reported on the basis of a model's assertion alone. The analysis is keyless and based entirely on public information. Nothing in this article is financial or legal advice. We do not publish private keys, target addresses, or anything intended to enable unauthorized access to funds.