Two Signatures, One Nonce, Zero Security: How ECDSA and secp256k1 Actually Work

In December 2010 fail0verflow showed Sony had signed every PlayStation 3 firmware with the same nonce, and the root signing key fell out of high-school algebra. In August 2013 a broken SecureRandom on Android did the same thing to bitcoin wallets. The curve was never the weak part.

THE CURVE, THE KEY, AND THE ONE NUMBER THAT MUST NEVER REPEAT

y² = x³ + 7   (mod p)  ·  p = 2²⁵⁶ − 2³² − 977  ·  Q = d · G

For years I treated the private key as the secret that mattered and everything around it as plumbing. Then somebody showed me two ordinary signatures over two different messages, and three lines of schoolbook algebra handed me the key that produced them. This is about what ECDSA actually promises and the one disposable number it depends on.

The private key was never the fragile part

I used to keep secrets badly and worry about the wrong one.

My model was comfortable: the private key is the secret, so protect the secret, done. I read plenty about keeping a seed phrase off the screen and out of someone else’s clipboard, and I stopped there. What happened between “I approve this transfer” and “here is a valid signature” I never inspected, because that part was mathematics.

Then somebody showed me two signatures.

Ordinary ones. Same key, two different messages, numbers I would have published anywhere. A few lines of rearrangement later, the private key fell out onto the table. Not guessed, not brute forced, not pried off a chip with a power probe. Solved for, the way you solve for x, in milliseconds.

ECDSA does not hang its security on how hard the private key is to guess. It hangs its security on every single signature burning a fresh, unpredictable nonce.

The key is a constant. It can sit in a drawer for a decade and lose nothing. The nonce is the consumable — minted once, spent once, never reissued. Invert that relationship and you weld the door while the window stays open.

I have argued with the curve about this more than once. It always goes the same way.

Me: Let me get this exactly right. You have never once leaked a private key.

The curve: Never once. Nobody has walked from Q back to d, and not for lack of trying — every coin on every chain is a bet that they cannot.

Me: People lose coins every year.

The curve: Coins are not keys, and keys are not me. You keep filing the burglary report against the lock manufacturer.

Me: That feels like a dodge.

The curve: It is a scope statement. I will tell you exactly what I guarantee, and then you will notice the guarantee has never been the part that failed.

secp256k1, read backwards

Read the name as a spec sheet instead of a word.

  • sec — Standards for Efficient Cryptography, the SECG document set this curve is published in.
  • p — a prime field, not a binary one.
  • 256 — scalars and coordinates are 256 bits wide.
  • k — Koblitz, a curve family with structure you can exploit for faster arithmetic.
  • 1 — it was the first entry in that table. That is the whole mystery.

The equation is almost rude in its plainness: y² = x³ + 7, with a = 0 and b = 7. There is nowhere to hide anything.

2²⁵⁶ − 2³² − 977the prime p that every coordinate on the curve is reduced mod

Written out it is FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE FFFFFC2F. Beside it sits n, the order of G: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141, cofactor 1. G is fixed too — x is 79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798, y is 483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8, and since y is even the compressed form carries the prefix 02.

The trust argument here is about provenance, not strength. The popular NIST curves ship coefficients that look like noise, and nobody outside the room can say why those digits. secp256k1’s parameters were selected to look inevitable rather than random, which leaves a designer dramatically less room to bury anything. Being a Koblitz curve also admits efficient endomorphism optimizations — exactly what libsecp256k1, the library Bitcoin Core relies on, uses alongside precomputed tables.

SEC 2 puts the classical security level here at roughly 128 bits. Read that carefully, because this is where mental models rot: 128 bits is the cost of attacking the curve. It says nothing about whether your nonce was unique.

Q = d · G — d is the private scalar, Q is the public point

A private key is a scalar d drawn from the interval [1, n−1] — which is close to the whole story of what a private key is. Going from d to Q is a short computation. Going backwards is the elliptic curve discrete logarithm problem, the one assumption the entire ecosystem rents its security from.

Me: So the private side is safe because nobody can reverse you.

The curve: Nobody can reverse me. Say it until it bores you, because you are about to spend the rest of this article being tempted to forget it.

Anatomy of one signature

Two Signatures, One Nonce, Zero Security: How ECDSA and secp256k1 Actually Work
Technopop.tattoo, Public domain, via Wikimedia Commons

Take z, the hash of the message. Pick a nonce k. Compute R = k·G, reduce its x coordinate mod n, call that r. Then compute the second half from the nonce inverse, the hash, r and d.

s = k⁻¹ · (z + r · d) mod n

The signature is the pair (r, s). Two numbers.

sign(z, d):
    k = nonce()                    # fresh per signature. the ONLY disposable input
    R = k * G
    r = R.x  mod n                 # if r == 0, discard and take another k
    s = k^-1 * (z + r * d)  mod n  # if s == 0, same
    return (r, s)
verify(z, Q, r, s):
    u1 = z * s^-1  mod n
    u2 = r * s^-1  mod n
    R' = u1 * G + u2 * Q           #  d appears nowhere
    return R'.x  mod n == r

The private scalar never appears in verification. It is used once, inside the multiplication that produces s, then goes back to sleep. Meanwhile r comes from k alone, before d ever enters the picture — and then gets published permanently into a ledger nobody can edit.

k is not a salt and not a hardening parameter. It is load-bearing. Reuse it and the evidence is not hidden on your disk where a careful engineer might notice; it is public, global and sortable by anyone with a full node.

Me: Slowly, one more time. What do you need from me per signature?

The curve: A number I have never seen you use before. Not once in that key’s lifetime. Not for a message you consider trivial, not in a test fixture you forgot to delete.

Me: And if I reuse one from March?

The curve: Then I will be correct. Both signatures verify, every wallet accepts them. Together they are a receipt that prints your private key for anyone holding a calculator.

Me: That is a strange definition of correct.

The curve: I guaranteed that d·G is hard to invert. I did not guarantee your habits.

Two signatures are enough

k = (z₁ − z₂) · (s₁ − s₂)⁻¹ mod n → d = (s₁ · k − z₁) · r⁻¹ mod n

Walk it instead of admiring it. Same key, same nonce, two messages z₁ and z₂ means the same R, means the same r. Subtract one s from the other: the (r·d) terms cancel and k⁻¹ is left multiplying (z₁ − z₂). Every other quantity there is public. One inverse later you hold k.

2signatures sharing one nonce — that is all it takes to print the private key

Substitute it back into either original equation and everything except d is known.

# same d, same k  =>  same r  =>  everything is solvable
k = (z1 - z2)      * inverse(s1 - s2)  mod n
d = (s1 * k - z1)  * inverse(r)        mod n
# no guessing. no key space to walk. no probability. just arithmetic.

There is no brute force here and nothing probabilistic about it. It is deterministic algebraic recovery, and its cost does not rise when you lengthen the key. A million-bit scalar comes out through the same two divisions. Every intuition people carry about “stronger keys” aims at the wrong variable.

What actually kills a key, and what does not

What destroys a keyWhat does not
Two signatures sharing one noncePublishing your public point Q to the entire internet
A nonce that is a hardcoded constantMaking the private key longer — algebra does not care about length
An RNG whose seeds repeat across devicesSigning the same message twice under RFC 6979
Having ever signed once with a reused nonce, even years agoMoving that key offline afterwards; the evidence is already public
A sufficiently large quantum computer running Shor, eventuallyMigrating to Schnorr as a way to patch nonce handling

There is no remediation step for “my nonce was weak in 2013” — you cannot rotate your way out of history. And the final pair is the one people merge into a single mistake: quantum ends this family of cryptography, while Schnorr addresses none of this. Different problems, different clocks.

A constant at Sony, loaded dice at Google

In December 2010, fail0verflow showed that Sony’s ECDSA signatures over PS3 firmware used a fixed nonce, not a weak random one. Same k forever, therefore the same r forever, therefore two signed firmware images plus the arithmetic above yields Sony’s root signing key. Homebrew followed.

The part worth sitting with is why Sony could not fix it. A root-of-trust key cannot be rotated by shipping an update, because every console already sitting in a living room trusts the compromised root. Discovering the leak and being unable to act on it were the same event.

Two Signatures, One Nonce, Zero Security: How ECDSA and secp256k1 Actually Work
Marion Harris, Public domain, via Wikimedia Commons

August 2013 brought the same failure in different clothes. Android’s java.security.SecureRandom had a seeding defect: on some devices, used before proper initialization, it produced predictable and sometimes outright repeating output. Bitcoin Wallet for Android, Bitcoin Spinner, blockchain.info’s mobile site and Mycelium were drawing ECDSA’s k from it.

The symptom on chain was exactly the fingerprint derived above: two transactions from one address bearing an identical r. No phones needed, no cooperation from the victim — scan the chain, collect every (r, s), sort for duplicate r within one key, apply two lines of arithmetic. Bitcoin Magazine reported the stolen funds funnelled into a single address that held 55.8 BTC at one point.

Andreas Schildbach, who maintains Bitcoin Wallet for Android, did not soften his assessment of the component at fault:

has multiple severe bugs that render it useless for cryptographic purposes

Wallets switched to reading entropy straight from /dev/urandom and mixing in more sources. Necessary, and useless to anyone who had already signed. Every transaction those wallets produced with a duplicate nonce is a permanent private-key disclosure. The bug got patched; the exposure did not.

A constant nonce and a broken RNG are one failure in two engineering cultures. Neither touched the discrete logarithm problem, neither touched the curve, and both handed out a second equation for a system with only one unknown.

Me: Sony. Android. Same story, years apart.

The curve: Same story, and I will be here for the next one. I computed R = k·G correctly every single time. I am not capable of computing it incorrectly.

Me: You are calm for something everyone leans on.

The curve: I am a geometric object. Ask me whether I am safe and I say yes. Ask me whether you are, and I have nothing to offer.

Stop asking the operating system for randomness

The fix that addresses the root cause is a refusal.

RFC 6979 says: do not generate k randomly at all. Derive it deterministically with HMAC from the private key and the message hash. Same key plus same message gives the same k, so signatures are reproducible; different messages derive different k, so they never collide. There is no RNG in the loop, so there is no RNG to seed badly, initialize badly, or ship defective.

This beats “use a good random number generator”, because it deletes the requirement instead of raising the bar.

It is not free, though. The nonce is now a pure function of your secrets, which makes the HMAC producing it one more place where implementation quality decides everything. That is why libsecp256k1, the library Bitcoin Core uses, runs secret-touching operations in constant time, resists side channels, validates that points are genuinely on the curve, and parses encodings strictly rather than hopefully. “The curve is secure” was never a claim about your software. It is a mathematical object. It does not read C.

Schnorr changed the shape, not the floor

BIP 340, the Schnorr scheme that arrived with Taproot, runs over this same curve. Public keys become 32 bytes, x-only. Signatures become 64 bytes. Nonce generation is specified deterministically for compatible signers, so the incident class above is designed out rather than discouraged, and aggregation becomes possible — Multisig, read from the source covers where that gets interesting.

What it is not is a rescue. Nobody found a hole in ECDSA’s mathematics, and existing ECDSA outputs are exactly as safe as they ever were — safe by virtue of the discrete logarithm problem, unsafe only in the ways they always were. The reason to migrate is smaller signatures and aggregation, not a discovered break. Anyone telling you Taproot happened because ECDSA failed read a headline and skipped the specification.

One honest endpoint, stated once and dropped. A sufficiently large quantum computer running Shor solves discrete logarithms and ends elliptic curve cryptography generally — not a defect peculiar to secp256k1, not a verdict about this curve alone. Every curve in the family shares that finish line, and I am not attaching a timeline to it.

Me: So you are mortal too, eventually.

The curve: Eventually, as will be every construction you migrate to, on a horizon you cannot see from here. Ask me whether I am broken today and the answer is no, which beats confidence about a date.

Three things I now insist on

  • Application code must never pick its own nonce. Use a signing library with RFC 6979-style deterministic derivation and confirm it is actually enabled, not compiled in and switched off. Any line that reads “get me a random number for this signature” is a bug by inspection.
  • Never hand-roll the curve arithmetic. Use a maintained library of the libsecp256k1 class: constant-time for anything touching secrets, strict point-on-curve validation, strict encoding parsing. This wheel has already been reinvented badly by people smarter than both of us.
  • If your keys ever signed under a weak or repeating RNG, sweep the funds — do not merely stop using the device. Not “review exposure”, not “monitor the address”. Move it. Sony could not rotate its root because of shipped hardware; you are not Sony, and your window closes the moment you stop deferring it.
  • Spread signing authority so one leaked scalar is not terminal, and teach people about the nonce rather than the key length. Everyone I have met who took custody seriously and still got hurt was guarding the constant while improvising around the consumable.

(The End)

Blockchain

Multisig Wallets, Read From the Source: How 2-of-3 Fails and What It Still Buys You

2026-10-17 13:25:32

Blockchain

Two Signatures, One Contract Nobody Broadcasts: How the Lightning Network Works

2026-10-18 7:54:01

❯
Profile
Cart
Coupons
Search