Research/Bitcoin

Nonce Reuse in ECDSA: How a Single Repeated Value Leaks Your Bitcoin Private Key

Reusing a nonce in ECDSA signing reveals the private key through simple algebra. Here's how it works and how Bitcoin wallets prevent it.

bcNeutronNov 21, 2026

Every Bitcoin transaction requires a digital signature to prove ownership of the funds being spent. The Elliptic Curve Digital Signature Algorithm (ECDSA) used in Bitcoin depends on a secret random value called a nonce for each signature. If that nonce is ever reused across two different signatures with the same private key, the key can be extracted through basic algebra. No brute force, no quantum computer, no exotic math: just division in a finite field.

This is not a theoretical risk. Researchers have found thousands of vulnerable signatures on the Bitcoin blockchain, and attackers have exploited them to steal funds. Understanding nonce reuse matters for anyone who holds Bitcoin, builds wallets, or works with cryptographic signing systems.

How ECDSA Signatures Work

ECDSA operates on the secp256k1 elliptic curve. A private key d is a large integer, and the corresponding public key is the point Q = d × G, where G is the curve's generator point. Signing a message involves three values: the private key d, the message hash z, and a randomly chosen nonce k.

The signing algorithm computes two values that form the signature:

  1. Compute the point R = k × G on the curve. The x-coordinate of R becomes the signature component r.
  2. Compute s = k⁻¹ × (z + r × d) mod n, where n is the order of the curve.

The final signature is the pair (r, s). The nonce k must remain secret and must never be reused. If either condition fails, the private key is exposed.

The Math Behind Nonce Reuse Exploitation

Suppose a signer uses the same nonce k to sign two different messages with hashes z₁ and z₂. Because R = k × G is the same in both cases, both signatures share the same r value. This is the red flag: identical r values in two signatures from the same public key signal nonce reuse.

Step 1: Recover the Nonce

The two signature equations are:

  • s₁ = k⁻¹ × (z₁ + r × d) mod n
  • s₂ = k⁻¹ × (z₂ + r × d) mod n

Subtracting the second from the first eliminates the private key term:

s₁ − s₂ = k⁻¹ × (z₁ − z₂) mod n

Solving for the nonce:

k = (z₁ − z₂) × (s₁ − s₂)⁻¹ mod n

Step 2: Recover the Private Key

With k known, substitute back into either signature equation:

d = (s₁ × k − z₁) × r⁻¹ mod n

Every value on the right side is now known. The nonce came from step 1, and s₁, z₁, and r are all public (they appear in the transaction on the blockchain). Computing r⁻¹ mod n is a standard modular inverse. The entire extraction takes microseconds on any computer.

Why this works: ECDSA's security rests on the discrete logarithm problem: given Q = d × G, finding d is computationally infeasible. But the nonce k acts as a one-time blinding factor. Reuse it, and the blinding cancels out, reducing key recovery to simple arithmetic.

Real-World Nonce Reuse Incidents

Nonce reuse has caused real losses across multiple systems. The most notable incidents demonstrate how a single implementation mistake can compromise an entire platform.

Sony PlayStation 3 (2010)

At the 27th Chaos Communication Congress in December 2010, the hacker group fail0verflow revealed that Sony had used the same nonce for every ECDSA signature on PS3 software updates. Because every signature shared the same r value, recovering Sony's private signing key was trivial. On January 3, 2011, security researcher geohot published the extracted key, enabling anyone to sign and run arbitrary code on the PS3. Sony sued but eventually settled, and the incident became a canonical example of nonce reuse in cryptography education.

Android SecureRandom Vulnerability (2013)

In August 2013, a flaw in Android's Java SecureRandom implementation was found to produce repeated nonce values for ECDSA signing in Bitcoin wallet apps. Affected wallets included Bitcoin Wallet, Blockchain.info, and Mycelium. Because blockchain transactions are public, attackers could scan for signatures sharing the same r value and extract the private keys directly. Wallet developers patched the issue by bypassing SecureRandom and reading directly from /dev/urandom. Users were urged to generate new keys and move funds immediately.

Blockchain-Scale Studies

In 2018, researchers Michael Brengel and Christian Rossow from CISPA published a systematic study of ECDSA key leakage on the Bitcoin blockchain at the RAID 2018 conference. They identified nonce reuse across the entire transaction history and estimated that an attacker could have stolen approximately 413 BTC (roughly $3.3 million at the time) from vulnerable addresses.

In 2023, researchers at Kudelski Security discovered the Polynonce attack, a generalization of nonce reuse that exploits polynomial relationships between consecutive nonces produced by weak pseudorandom number generators. Presented at DEF CON 31, the research showed that even nonces that appear random but share algebraic relationships can leak the signing key. The researchers found evidence that some vulnerable wallets had already been drained by other attackers.

Nonce Reuse Incidents and Impact

IncidentYearCauseImpact
Sony PS3 signing key2010Constant nonce across all signaturesPlatform signing key fully compromised
Android SecureRandom2013Broken PRNG producing duplicate outputsMultiple Bitcoin wallet apps vulnerable
Brengel & Rossow study2018Various nonce reuse across Bitcoin blockchain~413 BTC identified as stealable
Polynonce (Kudelski Security)2023Weak PRNG with polynomial nonce relationsWallets drained; attack presented at DEF CON 31

How RFC 6979 Prevents Nonce Reuse

The root cause of nonce reuse is reliance on a random number generator that can fail: producing duplicates, exhibiting bias, or being deliberately weakened. RFC 6979, authored by Thomas Pornin and published in August 2013, eliminates this dependency by deriving the nonce deterministically from the private key and the message being signed.

How It Works

Instead of calling an RNG, the signer computes:

k = HMAC-DRBG(private_key, message_hash)

This uses HMAC-SHA-256 as a deterministic random bit generator seeded with the private key and message hash. The output is unique per (key, message) pair, making accidental reuse impossible: the same message always produces the same nonce, and different messages always produce different nonces.

Critically, RFC 6979 signatures are fully compatible with standard ECDSA verification. The verifier does not need to know how the nonce was generated: it only checks that the signature satisfies the ECDSA equation. This made adoption straightforward, since wallets could switch to deterministic nonces without any protocol-level changes.

Limitations

Deterministic nonces solve the reuse problem but introduce a different risk: if an attacker can induce a fault during signing (flipping a bit in the hash computation, for example), the resulting corrupted nonce could leak key material. This is a concern primarily for hardware wallets and embedded signing devices, where physical side-channel attacks are part of the threat model.

Schnorr Signatures and BIP-340 Nonce Generation

Bitcoin's Taproot upgrade (activated November 2021) introduced Schnorr signatures via BIP-340. Schnorr signatures are vulnerable to the same nonce reuse attack as ECDSA: two Schnorr signatures sharing a nonce and private key also leak the key through simple algebra.

BIP-340 addresses this with a two-layer approach. The default signing algorithm is fully deterministic, requiring no RNG at signing time. The nonce is derived by hashing the private key together with the message, using tagged hashes to prevent cross-protocol collisions.

Synthetic Nonces

When an RNG is available, BIP-340 recommends mixing up to 32 bytes of random data into the nonce derivation. The result is called a synthetic nonce: deterministic at its core but with an additional randomness layer. This protects against fault injection attacks where an attacker manipulates the hash computation to produce a nonce that leaks key material.

BIP-340 also recommends verifying the generated signature before releasing it, as a final check against computation errors (whether accidental or attacker-induced). For software wallets, this verification adds negligible overhead. For constrained hardware signing devices, it may be omitted where the cost is too high.

Deterministic vs. synthetic: Pure deterministic nonces (RFC 6979, BIP-340 default) prevent accidental reuse but are vulnerable to fault attacks. Synthetic nonces add randomness to defeat fault injection while preserving the deterministic fallback if the RNG fails. Modern wallet implementations should use synthetic nonces whenever an RNG is available.

Wallet Nonce Generation Methods

Modern Bitcoin wallets universally use deterministic or synthetic nonce generation. The table below summarizes how major implementations handle nonce generation for both ECDSA and Schnorr signing.

Wallet / LibraryNonce MethodAnti-Exfil SupportNotes
Bitcoin Core (libsecp256k1)RFC 6979 + synthetic randomnessNoAuxiliary randomness mixed into nonce derivation since 2019
TrezorRFC 6979 deterministicNoOpen-source firmware; nonce output is verifiable against known seeds
BitBox02RFC 6979 + anti-kleptoYesHost contributes randomness; device proves it was included
Blockstream JadeRFC 6979 + anti-exfilYesImplements the same anti-klepto protocol as BitBox02
LedgerRFC 6979 deterministicNoClosed-source firmware; nonce derivation not externally verifiable
ElectrumRFC 6979 deterministicVia HWISupports anti-exfil when paired with compatible hardware

The Hardware Wallet Verification Problem

RFC 6979 makes nonces deterministic, but a verifier cannot tell from the signature alone whether the signer actually used RFC 6979. A malicious or compromised signing device could embed secret data in the nonce without the user detecting it. This is known as a covert channel attack.

The Anti-Klepto Protocol

Developed by the BitBox and Blockstream teams, the anti-klepto (also called anti-exfil) protocol adds a commitment-based verification step. The host computer generates random data and sends a commitment (hash) to the hardware wallet. The device incorporates this randomness into its nonce derivation. Before the transaction is broadcast, the host verifies that its randomness was actually used.

This prevents the device from choosing nonces that leak key material, because the device cannot predict the host's randomness when it commits to its portion of the nonce. As of 2026, only the BitBox02 and Blockstream Jade implement this protocol. The specification is open source, and both teams have encouraged broader adoption.

Dark Skippy (2024)

In 2024, researchers Lloyd Fournier, Nick Farrow, and Robin Linus disclosed Dark Skippy, an improved nonce exfiltration attack applicable to both ECDSA and Schnorr signatures. Malicious firmware generates low-entropy nonces derived from fragments of the user's seed phrase, embedding them in signatures published to the blockchain. An attacker monitoring the chain recovers the fragments using Pollard's kangaroo algorithm and reconstructs the full seed in as few as two signed transactions.

Dark Skippy requires compromised firmware, so it is a supply chain or physical access attack rather than a remote exploit. Mitigations include secure boot, reproducible firmware builds, and the anti-klepto protocol. The researchers notified major hardware wallet manufacturers before public disclosure.

FROST: Distributed Nonce Management in Threshold Signing

FROST (Flexible Round-Optimized Schnorr Threshold) is a threshold signing protocol formalized in RFC 9591. Unlike single-signer schemes where one party generates the nonce, FROST distributes nonce generation across multiple signing participants. This architectural difference provides structural protection against nonce reuse and nonce manipulation.

Why FROST Cannot Use Deterministic Nonces

In single-signer ECDSA or Schnorr, deterministic nonces (RFC 6979) are safe because one party controls both the key and the nonce. In a threshold setting, deterministic nonce derivation is dangerous: if a malicious coordinator can trigger a signer to produce two signatures on different messages using the same deterministic nonce share, the signer's key share leaks. RFC 9591 explicitly requires that FROST nonces be generated randomly, not deterministically.

How FROST Nonces Work

FROST signing proceeds in two rounds. In Round 1 (preprocessing), each participant generates a pair of random nonce values: a hiding nonce and a binding nonce. The participant publishes commitments (elliptic curve points) to these nonces but keeps the scalar values secret.

In Round 2 (signing), each participant uses their secret nonce values to compute a partial signature. The binding nonce is combined with a binding factor derived from all participants' commitments, preventing a malicious coordinator from selectively replaying nonce commitments from earlier sessions. Each nonce pair is strictly one-time use: the protocol zeroes nonce values after signing to enforce this.

Spark and FROST Nonce Safety

Spark uses FROST threshold signatures where key generation and nonce management are distributed across independent operators. No single operator holds a complete nonce or a complete private key. Even if one operator's random number generator is flawed, the combined nonce is protected by contributions from other participants. This is a structural advantage over single-signer schemes: a nonce reuse attack requires all participants to reuse their nonce shares simultaneously, which cannot happen by accident when signers are independent and geographically distributed.

Nonce reuse is the simplest attack, but it is not the only way flawed nonces compromise keys. The broader class of nonce-related vulnerabilities includes:

  • Nonce bias: if the nonce is not uniformly distributed across the full range, lattice-based attacks can recover the key from many signatures with biased nonces
  • Related nonces: the Polynonce attack shows that nonces with polynomial relationships leak the key even without exact reuse
  • Nonce exfiltration: malicious software or firmware can encode secret data in the nonce, leaking the key through public signatures
  • Fault attacks: inducing hardware faults during signing can corrupt the nonce computation and produce a signature that leaks key material

All of these attacks share a common structure: they exploit the fact that the nonce is the only ephemeral secret in the signature scheme. Any weakness in nonce generation directly translates to a weakness in key security.

How to Protect Yourself

For users, the most important defense is using wallet software that implements deterministic or synthetic nonce generation. All major Bitcoin wallets adopted RFC 6979 after the 2013 Android vulnerability, and BIP-340 Schnorr signing includes deterministic nonces by default. Beyond wallet choice:

  • Keep wallet firmware and software updated to receive security patches
  • For hardware wallets, prefer devices with anti-klepto protocol support (BitBox02, Blockstream Jade) or open-source, reproducible firmware
  • Avoid address reuse: while deterministic nonces prevent key extraction from same-address signatures, fresh addresses reduce exposure to any undiscovered nonce vulnerability
  • For developers building signing implementations, use established cryptographic libraries (libsecp256k1, the reference implementation for Bitcoin's curve) rather than writing nonce generation from scratch

For developers building on Bitcoin Layer 2 protocols, the Spark SDK handles FROST-based threshold signing internally, so wallet developers do not need to implement nonce management themselves. The distributed signing architecture means individual nonce generation failures do not compromise the system.

Looking Forward

Nonce security remains an active area of cryptographic research. The shift from ECDSA to Schnorr on Bitcoin improves signature efficiency through batch verification and key aggregation, but does not fundamentally change the nonce threat model. Schnorr signatures are equally vulnerable to nonce reuse as ECDSA signatures.

The frontier of nonce security is in threshold and multi-party settings. As protocols like FROST and MuSig2 see broader adoption, nonce management shifts from a single-device problem to a distributed coordination problem. This is architecturally harder but offers stronger guarantees: compromising the nonce requires compromising multiple independent parties rather than a single signing device.

For a hands-on look at how these protections work in practice, the General Bread wallet demonstrates Spark's FROST-based signing in a self-custodial mobile wallet, where nonce management is handled transparently behind a familiar payment experience.

This article is for educational purposes only. It does not constitute financial or investment advice. Bitcoin and Layer 2 protocols involve technical and financial risk. Always do your own research and understand the tradeoffs before using any protocol.