Skip to content

BIP Draft: Low-R Grinding for ECDSA Signatures - #2224

Open
liamgilligan wants to merge 1 commit into
bitcoin:masterfrom
liamgilligan:bip-low-r-grinding
Open

BIP Draft: Low-R Grinding for ECDSA Signatures#2224
liamgilligan wants to merge 1 commit into
bitcoin:masterfrom
liamgilligan:bip-low-r-grinding

Conversation

@liamgilligan

Copy link
Copy Markdown

Informational BIP describing low-R grinding: re-deriving the ECDSA nonce under a counter until r has its high bit unset, so the DER encoding needs no leading null byte.

This was discussed on the mailing list: https://groups.google.com/g/bitcoindev/c/boEZRlqczvw

Reference implementation and test vectors are TODO.

Feedback is very welcome.

@jonatack

Copy link
Copy Markdown
Member

@murchandamus murchandamus changed the title Add BIP bip-low-r-grinding: Low-R Grinding for ECDSA Signatures BIP Draft: Low-R Grinding for ECDSA Signatures Jul 28, 2026
@murchandamus

Copy link
Copy Markdown
Member

Thanks, adding this to my to-read list.

@craigraw

Copy link
Copy Markdown
Contributor

Another important motivation is that signatures produced according to a standardised approach will be byte-identical. This means signers can be compared to ensure they are not leaking secrets by embedding them in signatures (e.g. Dark Skippy).

@murchandamus murchandamus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good. I just have a couple nits for you.

Comment thread bip-low-r-grinding.md Outdated
Comment thread bip-low-r-grinding.md Outdated
@murchandamus

murchandamus commented Aug 3, 2026

Copy link
Copy Markdown
Member

The document should have a Rationale section. The Rationale should describe design decisions, compare to potential alternate designs and related work. You could mention the suggestion that Craig gave there. The explanation why incrementing a counter on top of RFC6979 is safe and recommend could also be located in that section. Some of the Footnotes would fit there as well, in fact, many BIPs use the Footnotes section as the Rationale.

@jeanpablojp

Copy link
Copy Markdown
Contributor

Since the reference implementation and test vectors are still marked TODO, I'd like to offer help there, if you aren't already deep into them.

What I have in mind is an independent Python implementation of the recommended instantiation: pure Python secp256k1, RFC 6979 with the grind counter in the additional data, the grinding loop, and DER encoding, plus a script that generates the vectors and a separate one that verifies them, everything checked byte for byte against Bitcoin Core's signer. I built the spend-path vectors for the BIP 360 draft recently (#2232), so this is familiar ground.

The reason I think an implementation that shares no code with libsecp is worth having: if it agrees with Core on the vectors, that's good evidence the text is unambiguous, and if it doesn't, the first diverging intermediate value shows exactly which part needs tightening.

If that sounds useful, two things worth deciding up front:

  1. Should the vectors carry intermediate values (additional data, nonce, r, s before low-s normalization, final DER), or only key, message hash, counter and signature? My preference is the full set: the keys are test-only so there's nothing to protect, and the intermediates are what lets two implementations find where they diverge. RFC 6979 publishes k in its own vectors.
  2. A JSON file next to the document, or vectors inline in the markdown?

Happy to open the result as a PR against your branch, or just post it here, whichever works better for you.

@liamgilligan

Copy link
Copy Markdown
Author

@jeanpablojp I appreciate the offer, but I've already written a test implementation, and waiting to push it until I resolve everything in the text. Once it is pushed, I would really appreciate a review of the code, if you have time.

@jeanpablojp

Copy link
Copy Markdown
Contributor

Will do, happy to review it when it's up.

@liamgilligan

Copy link
Copy Markdown
Author

@murchandamus made the changes you recommended. However, I'm wondering whether or not this BIP should be classified as "Informational". With the addition of the Rationale section, the BIP seems split across how Low-R Grinding can be done and how it should be done. Of course, a signer need not follow Core's implementation in order to produce low-r signatures, but BIP-3 does say the "distinguishing characteristic of a Specification BIP is that it can be implemented, and implementations can be compliant with it". What do you think?

@murchandamus murchandamus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m open to the idea to make it a Specification BIP, but in that case, you should specify one concrete approach. :)

Comment thread bip-low-r-grinding.md Outdated
Comment thread bip-low-r-grinding.md Outdated
Comment thread bip-low-r-grinding.md Outdated
Informational BIP describing low-R grinding: re-deriving the ECDSA
nonce under a counter until r has its high bit unset, so the DER
encoding needs no leading null byte.
@liamgilligan

Copy link
Copy Markdown
Author

@murchandamus made the changes you requested and turned it into a specification BIP, and included the pseudocode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants