[master] sigcache: harden range proof cache keys and add -norangeproofcache option - #1604
Open
delta1 wants to merge 3 commits into
Open
[master] sigcache: harden range proof cache keys and add -norangeproofcache option#1604delta1 wants to merge 3 commits into
delta1 wants to merge 3 commits into
Conversation
Switch range-proof and surjection-proof cache hashers from raw CSHA256 concatenation to CHashWriter (SER_GETHASH). This serializes each field with a length prefix, so distinct argument tuples with byte-identical raw concatenations no longer collide to the same cache key. A cache entry is a positive verification result; a collision would let an attacker bypass verification. The fix affects two caches: - ComputeEntryRangeProof: proof, commitment, asset_commitment, scriptPubKey - ComputeEntrySurjectionProof: add vTags to key (was missing entirely) Both caches retain the per-process 64-byte salted midstate (nonce || PADDING_RANGE_PROOF / PADDING_SURJECTION_PROOF) for domain separation between the two proof types. Expose thin test-only hooks (TestComputeEntryRangeProof / TestComputeEntrySurjectionProof) so unit tests can reach the anonymous-namespace cache internals. (cherry picked from commit 9400096)
Test the field-boundary, script-sensitivity, domain-separation, determinism, and vTags-sensitivity properties of the range-proof and surjection-proof cache entry computation. (cherry picked from commit 1513d63)
Add -norangeproofcache startup option. InitRangeproofCache() early-returns (allocating nothing) when the flag is set. VerifyRangeProof reads the flag on each call and bypasses both the Get and Set paths, so cache behaviour is fully skipped without restarting. (cherry picked from commit 19d7042)
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.
target is master branch, cherry-picked commits from #1600
Switch the range-proof and surjection-proof cache hashers from raw
CSHA256 concatenation to CHashWriter . This length-prefixes
every field, so distinct argument tuples with byte-identical raw
concatenations no longer collide to the same cache key.
Both caches retain per-process salted midstates with distinct domain
separators ('r' / 's').
Also adds a -norangeproofcache startup option to
disable the range proof cache without recompiling.