Deterministic Nonce (RFC 6979)

Deriving the signing nonce from the key and message instead of a random source, removing a catastrophic failure mode.

Basically

Your wallet creates the one-time number for a signature from your private key and the message. The same inputs always give the same number, so signing does not depend on a random number generator that could fail.

Key Takeaways

  • A deterministic nonce is derived from the private key and message hash using HMAC-DRBG. It produces the same nonce for every identical (key, message) pair without relying on a random number generator.
  • RFC 6979 prevents nonce reuse caused by poor randomness, the weakness behind major key extraction attacks. These include the PlayStation 3 signing key compromise and the 2013 Android Bitcoin wallet thefts.
  • Bitcoin Core and most modern wallets use RFC 6979 by default for digital signatures. Synthetic nonces add protection against fault injection attacks.

What Is a Deterministic Nonce?

A deterministic nonce is a one-time number used in elliptic curve digital signature schemes, including ECDSA and related algorithms. It is computed from the signer's private key and the message being signed rather than generated randomly. The same inputs always produce the same nonce, so signing is reproducible and does not depend on the quality of the system's random number generator (RNG).

RFC 6979, authored by Thomas Pornin and published in August 2013, defines the standard method for generating deterministic nonces. It uses HMAC-DRBG, a pseudorandom number generator specified in NIST SP 800-90A, seeded with the private key and the message hash. Each unique (key, message) pair produces a unique nonce that is computationally indistinguishable from random output.

ECDSA implementations relied on the operating system's RNG to produce nonces before RFC 6979. A broken or biased RNG, or one that reused a value, could let an attacker extract the private key from published signatures. Deterministic nonces solved this problem by removing randomness from nonce generation.

How It Works

RFC 6979 replaces random nonce selection in ECDSA with deterministic derivation using HMAC-DRBG. The process uses the same hash function as the signature scheme, which is SHA-256 for Bitcoin's secp256k1 curve.

Pseudocode

The core HMAC-DRBG loop is simplified below for a 256-bit curve like secp256k1. It derives the nonce without using a random number generator.

The private key never leaves the signing device during this process. The HMAC construction ensures that an observer who sees the resulting signature cannot reverse-engineer the nonce or the key.

Why HMAC-DRBG?

HMAC-DRBG was chosen because it is a well-analysed, standards-compliant pseudorandom generator that accepts arbitrary seed material. Its output is indistinguishable from random to anyone who does not know the private key, yet it is deterministic given the same inputs. Signatures can therefore be verified and reproduced in testing without introducing a security weakness.

Why It Matters

Past ECDSA vulnerabilities show why deterministic nonces matter. Every major nonce-related attack traces back to the same root cause: poor randomness.

The PlayStation 3 Key Extraction

Researchers from fail0verflow revealed in December 2010 at the 27th Chaos Communication Congress that Sony had used a static nonce, the same k value, for all ECDSA signatures on PlayStation 3 firmware. With two signatures sharing the same nonce, the private key x can be recovered from signatures (r, s1) and (r, s2) with nonce k using x = (s1 * m2 - s2 * m1) / (r * (s1 - s2)). Anyone could then sign and run arbitrary code on PS3 consoles.

The Android Bitcoin Wallet Thefts

A flaw in Android's Java SecureRandom implementation caused nonce reuse in ECDSA signatures for Bitcoin transactions in August 2013. The broken RNG could produce identical nonces when a wallet signed multiple transaction inputs, exposing the private key. Over 55 BTC were stolen from affected wallets, including Bitcoin Wallet, Blockchain.info, BitcoinSpinner, and Mycelium, and the incident directly accelerated the adoption of RFC 6979 across the Bitcoin ecosystem.

Adoption in Bitcoin

Bitcoin Core adopted RFC 6979 deterministic signing in version 0.10.0, released on February 16, 2015. The switch was part of a broader effort to replace OpenSSL with libsecp256k1, a purpose-built elliptic curve library created by Pieter Wuille. Pull requests #5227 for deterministic signatures and #5506 for switching to libsecp256k1's built-in RFC 6979 made deterministic nonces the default for all Bitcoin Core signing operations.

Bitcoin Core also implements 'low-r grinding': after generating the deterministic nonce, it checks whether the resulting r value's first byte is below 0x80. If not, it adds extra entropy using RFC 6979's Section 3.6 mechanism and tries again. The optimisation reduces average transaction size by 1 byte, saving on fees over time.

RFC 6979 is now the standard across the ecosystem. Bitcoin Core and most modern wallets use it by default for digital signatures.

BIP-340 introduced a related but distinct approach with Schnorr signatures. It specifies its own deterministic nonce derivation using tagged hashes rather than HMAC-DRBG, optimised for the Schnorr scheme's algebraic structure, while retaining the principle of deriving the nonce from the private key and message to eliminate RNG dependence. The Taproot and Schnorr signatures explainer covers how Schnorr signatures improve on ECDSA.

Embedded and Constrained Devices

Hardware wallets and signing devices operate in environments where high-quality randomness is difficult to guarantee. Microcontrollers may lack dedicated hardware RNG circuits, and software entropy sources on embedded systems are notoriously weak, especially immediately after boot. RFC 6979 removes this class of risk by removing the need for runtime randomness during signing.

Reproducible and Testable Signatures

Identical inputs always produce the same nonce, so implementations can be tested against known test vectors. The RFC includes test vectors for multiple curves and hash functions. Reproducibility supports cryptographic library audits, compliance testing, and cross-platform verification, and two independent implementations that produce identical signatures for the same key and message are almost certainly correct.

Threshold and Multi-Party Signing

Threshold signature schemes like FROST and MuSig2 require careful nonce management because multiple parties must coordinate. These protocols define their own multi-round nonce generation, but they carry forward the principle of deterministic derivation from secret inputs rather than trusting each participant's RNG. Compromised randomness at any single participant could otherwise jeopardise the entire group key.

Fault Injection Attacks

Purely deterministic nonces have a tradeoff: the same (key, message) pair always produces the same signature. An attacker who can induce computational faults during signing can compare a faulty signature against the correct one for the same message, and the difference reveals information about the nonce and, by extension, the private key. Research presented at CT-RSA 2022 demonstrated that a 256-bit signing key can be recovered even with up to 250 faulty bits in a single faulted computation.

The attack vector is most relevant for hardware signing devices where an attacker has physical access. Voltage glitching, clock manipulation, and electromagnetic fault injection can all induce the targeted computational errors needed for this attack.

Fixed Signature Mapping

Deterministic nonces produce an identical signature when the same key signs the same message. An observer who sees the same signature twice therefore knows that the same key signed the same message twice. Most Bitcoin use cases are unaffected because transaction hashes are inherently unique, but protocols that sign repeated messages may need to consider this.

Synthetic Nonces as a Safeguard

Synthetic nonces, also called hedged nonces, mix additional random bytes into the HMAC-DRBG seeding step alongside the private key and message hash. RFC 6979 Section 3.6 explicitly supports this through an optional 'additional data' parameter.

A functioning RNG gives each signature a unique nonce, defeating fault injection attacks because an attacker can never obtain two signatures with the same nonce for comparison. A broken or unavailable RNG causes the scheme to fall back to standard RFC 6979 determinism, still preventing nonce reuse.

An IETF draft, draft-irtf-cfrg-det-sigs-with-noise, updated March 2025, formalises this pattern as the recommended default for all new implementations. Go's standard library crypto/ecdsa package has implemented hedged nonces since Go 1.20, seeding an AES-CTR CSPRNG with the private key, system entropy, and message hash. The libsecp256k1 library accepts 32 bytes of optional extra data in its signing function for the same purpose.

Deterministic Nonces and Spark

Systems that handle Bitcoin digital signatures benefit from deterministic nonce generation. Layer 2 protocols like Spark involve frequent signing operations for state transitions and transfers. RFC 6979 keeps these signing operations safe regardless of the underlying platform's RNG quality, which matters especially for the mobile and embedded wallet environments where Spark's SDK operates.

The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.

0

← All 1876 glossary terms