Additional sighash cache index bit - #1581
Open
tomt1664 wants to merge 2 commits into
Open
Conversation
Member
|
utACK 0a0dd9b FWIW I think you could change the size of the |
…PROOF keying Backport of bitcoin/bitcoin#32473 as integrated on elements-23.x (eb64d24), reapplied against master's tree. The SIGHASH_RANGEPROOF (0x40) bit changes the sighash preimage: segwit v0 appends hashRangeproofs, and the legacy serializer appends each output's rangeproof and surjectionproof. It is therefore part of the cache key, and the table has 16 entries rather than upstream's 6. Dropping that term is a consensus split with deployed elements-23.x in both directions. Upstream added SigHashCache as a pure addition, so a merge of this file will auto-merge without prompting for the Elements adaptation. Hence the explicit markers.
tomt1664
force-pushed
the
sighashcache_rangeproof_update
branch
from
August 13, 2026 14:21
0a0dd9b to
1484750
Compare
apoelstra
reviewed
Aug 13, 2026
| // because no input can simultaneously use both. | ||
| // ELEMENTS: SIGHASH_RANGEPROOF changes the preimage (segwit v0 appends hashRangeproofs; the | ||
| // legacy serializer appends each output's rangeproof and surjectionproof), so it must be a | ||
| // dimension of the cache key. Removing this term is a consensus split with elements-23.x. |
Member
There was a problem hiding this comment.
In 903be1e:
This comment is a bit confusing. Removing this term would break the caching logic, but it wouldn't be a "consensus split with elements 23" in particular. It'd just be wrong.
apoelstra
reviewed
Aug 13, 2026
| * optionally store a scriptCode which the hash is for, plus a midstate for the SHA256 | ||
| * computation just before adding the hash_type itself. */ | ||
| // ELEMENTS: the SIGHASH_RANGEPROOF (0x40) bit changes the sighash preimage, so it is part of | ||
| // the cache key and the table has 16 entries rather than upstream's 6. Do not drop this when |
Member
There was a problem hiding this comment.
In 903be1e:
Fine to leave as-is, but the old table had 6 elements and we're adding 8 to it, so 14 is the correct number.
Member
Author
There was a problem hiding this comment.
Yes, you are right. I will leave as is though, as it is (again incorrectly) 16 in 23.x.
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.
Additional cache index bit added for sighash combination with SIGHASH_RANGEPROOF