BIP-374: treat challenge hash result e as scalar - #2262
Open
theStack wants to merge 2 commits into
Open
Conversation
….3.0 Note that the purpose of this change is primarily to improve clarity for implementers and consistency with existing BIPs like BIP-340 and BIP-327. Under the assumption that reaching a challenge hash with `e >= n` is negligible, the newly introduced test vectors in the next commit would also fail without the new rejection branch.
Contributor
Author
|
pinging the BIP-374 co-authors and some "friendly cryptographers from next-door" :-) @andrewtoth @jonasnick @real-or-random @RubenSomsen @sipa |
theStack
commented
Aug 19, 2026
| ), | ||
| "big", | ||
| ) | ||
| ) % GE.ORDER |
Contributor
Author
There was a problem hiding this comment.
leaving a note for reviewers that we could also take better use of secp256k1lab's types in the reference implementation (e.g. directly return a Scalar here instead of working with ints), but that's out of scope for this PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The purpose of this change is primarily to improve clarity for implementers (e.g. in libsecp [1]) and for consistency with existing BIPs like e.g. BIP-340 and BIP-327, where the challenge hash result is reduced modulo the curve order as well:
bips/bip-0340.mediawiki
Line 156 in 857a7de
bips/bip-0327.mediawiki
Line 434 in 857a7de
It seems not strictly needed from a pure specification point of view, but I think it makes sense to treat$s = (k + e \cdot a) \bmod n$ , so implementers would need to do a conversion (and hence decide whether to wrap-around or not) anyways.
eas scalar throughout, given that we perform scalar operations at the proof generation side for calculatingUnder the assumption that reaching a challenge hash with
e >= nis negligible, I think this change can be treated as logically equivalent and thus backwards compatible (but maybe there is more subtlety to it that I don't see); note that the newly introduced test vectors would also fail without the new early rejection branch, but at a later point due to not fulfilling the verification equation.Thanks to @macgyver13 for making me aware that e is currently not specified to be in the scalar range.
[1] see PRs bitcoin-core/secp256k1#1651 and bitcoin-core/secp256k1#1802