---
title: "Nonce Grinding — definition | Nuri Glossary"
description: "Searching nonce values to hit a desired property, useful in mining and dangerous in signature schemes."
lang: "en"
type: "glossary-term"
canonical: "https://nuri.com/glossary/nonce-grinding"
---

# Nonce Grinding

Searching nonce values to hit a desired property, useful in mining and dangerous in signature schemes.

## Basically

You try different numbers until one gives the result you want. Bitcoin uses this to find valid blocks and make some signatures smaller.

## Key Takeaways

- Nonce grinding means trying different nonce values until one meets a specific constraint. That constraint can be a block hash below the difficulty target in mining or a compact digital signature in transaction optimisation.
- Low-R grinding reduces ECDSA signature size by 1 byte per input, lowering transaction fee rates. Bitcoin Core has performed this optimisation by default since v0.17.0, released in October 2018.
- Schnorr signatures, defined in BIP 340, remove the need for R-value grinding entirely. They use fixed-length 64-byte signatures with x-only encoding.

## What Is Nonce Grinding?

Nonce grinding means repeatedly trying different nonce values until one produces an output that meets a desired criterion. The term appears in two distinct Bitcoin contexts: mining and transaction optimisation. In mining, grinding the block header nonce to find a valid hash is the fundamental act of proof of work.
Mining nonce grinding and signature nonce grinding share the same mechanism: try values, check the output and repeat. Mining nonce grinding secures the network. Signature nonce grinding iterates ECDSA signature nonces to produce smaller signatures, saving block space and fees for individual transactions.

## Mining: Block Header Nonce

Every block header contains a 32-bit nonce field of 4 bytes, which miners increment while searching for a hash below the current difficulty target. The header is 80 bytes in total and contains the version, previous block hash, merkle root, timestamp, difficulty bits and nonce. Miners double-SHA-256 hash this header, adjusting the nonce each time.
The 32-bit nonce provides approximately 4.3 billion possible values. Modern ASIC miners exhaust this range in a fraction of a second. When no value produces a valid hash, miners modify the extraNonce field inside the coinbase transaction's scriptSig.
The coinbase transaction change alters the merkle root and produces an entirely new header to hash, creating a two-level loop. Miners can also vary the timestamp within protocol-allowed bounds for additional search space. The combined effect is an effectively unlimited number of candidate hashes, constrained only by hardware speed and electricity cost.

## Signature Optimisation: Low-R Grinding

ECDSA signatures in Bitcoin use DER, or Distinguished Encoding Rules, where the R and S values are encoded as signed integers. When the high bit of R's first byte is set, meaning values ≥ 0x80, DER encoding requires a leading 0x00 byte to show that the value is positive. The R component can therefore be either 32 bytes for low-R or 33 bytes for high-R, directly affecting transaction size.
R values are approximately uniformly distributed 256-bit integers, so around 50% of signatures naturally produce a high-R value. Low-R grinding tries different signature nonces until R fits in 32 bytes. Each attempt checks the resulting R value and repeats if it needs the extra byte.
The algorithm needs roughly 2 tries on average because each attempt has a 50% success probability. Combined with low-S normalisation, which requires S ≤ curve order / 2 and has been standard since Bitcoin Core v0.9.0, every signature is guaranteed to be exactly 71 bytes. That total is 70 DER bytes plus 1 sighash byte, instead of potentially 72 or 73 bytes.

## Deterministic Nonces and Safety

Low-R grinding is safe because it builds on RFC 6979 deterministic nonce generation. Rather than using a random number generator, RFC 6979 derives the signature nonce deterministically from the private key and message hash using HMAC-DRBG. Section 3.6 of the RFC explicitly allows an additional data input to the derivation function.
A counter value is passed as this additional data for grinding. Each counter value produces a cryptographically independent nonce, while the same key, message and counter always produce the same nonce. The counter is non-secret and only controls which valid nonce is selected.
This approach sacrifices 1 bit of nonce entropy by constraining R to the lower half of the range. That reduction is negligible against the 256-bit security of the secp256k1 curve.

## Schnorr Signatures: No Grinding Needed

Schnorr signatures were activated with Taproot in November 2021 via BIP 340 and eliminate the need for R-value grinding entirely. Their design produces fixed-length 64-byte signatures with x-only encoding. No computational overhead from grinding is needed.
The result is a 7-byte saving per signature compared with ground ECDSA: 64 bytes versus 71 bytes. For wallets and protocols building on P2TR outputs, this translates directly to lower fees.

## Why It Matters

Signature size directly affects transaction fees, and every byte counts in a competitive fee market. For transactions with many inputs, low-R grinding can meaningfully reduce costs. The saving applies to each input.
Exchanges and payment processors that batch transactions with dozens of inputs save meaningful fee costs over time through low-R grinding. The optimisation is automatic in Bitcoin Core v0.17.0+, requiring no user configuration.
Layer 2 protocols like Spark and the Lightning Network benefit from compact on-chain transactions when opening and closing channels. Signature optimisation therefore improves settlement efficiency.

## Nonce Reuse Is Catastrophic

Reusing the same ECDSA nonce to sign two different messages with the same private key allows the key to be algebraically recovered. Two signatures, (r, s1) and (r, s2), that share the same r value indicate nonce reuse. The shared r value exposes the relationship needed for recovery.
These failures have happened in practice. In 2010, researchers demonstrated that Sony used a constant nonce for every ECDSA signature on the PlayStation 3, allowing anyone to recover Sony's code-signing key. In 2013, a bug in Android's SecureRandom caused Bitcoin wallet apps to reuse nonces, leading to the theft of funds as attackers scanned the blockchain for signatures sharing an r value. Deterministic nonces via RFC 6979 eliminate this class of vulnerability entirely.

## Entropy Cost

Low-R grinding constrains R to the lower half of the 256-bit range, sacrificing 1 bit of effective entropy. Against secp256k1's 128-bit security level, this reduction is negligible. An attacker still faces 2^127 operations to recover a key, which remains computationally infeasible.

## Computational Overhead

Grinding roughly doubles the average signing time because it takes two attempts on average. For wallet software signing a handful of transactions, this is imperceptible. For high-throughput signing servers processing thousands of transactions per second, the overhead may be relevant.

## Transition to Schnorr

Taproot adoption makes low-R grinding less relevant because Schnorr signatures are inherently fixed-length. The long-term trajectory is towards P2TR outputs, where signature optimisation is built into the cryptographic primitive itself. For a deeper comparison of signature schemes, see Taproot and Schnorr Signatures Explained.
This 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.
Part of the [Nuri glossary](https://nuri.com/glossary), which defines 1876 Bitcoin, Lightning, wallet, stablecoin and payment terms.
