Fix range proof verification cache keying (asset + scriptPubKey) - #1591
Open
delta1 wants to merge 3 commits into
Open
Fix range proof verification cache keying (asset + scriptPubKey)#1591delta1 wants to merge 3 commits into
delta1 wants to merge 3 commits into
Conversation
Member
Author
|
CI note: all checks pass (lint, ASan+LSan+UBSan+integer, macOS arm64 x2, Win64 x2) except the This failure is a pre-existing flaky master test, unrelated to this PR (which touches only src/script/sigcache.cpp/.h and two new test files). It reproduces identically on unrelated PRs today against the same master (e.g. fix_multi_commit run 33401378879) and passes intermittently on others (e.g. run 33410277643). The ZMQ test compares confidential output values (CTxOutValue) to int in the test framework and is not affected by the range-proof cache change. |
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.
Summary
Fix the range-proof verification cache in
CachingRangeProofCheckerso a false cache hit can no longer validate a rangeproof under a different asset generator or scriptPubKey, and can no longer bypass themin_value == 0anti-zero-token guard for spendable outputs.Background / issue
liquid/elements #211: the rangeproof verification cache (
SignatureCache::ComputeEntryRangeProof) was keyed only on(proof, value_commitment). Butsecp256k1_rangeproof_verifyalso binds the asset generator and the scriptPubKey (the proof's extra commitment). A cache keyed on the proof + value commitment alone would:(proof, commitment)pair under any script via a cache hit (validating a tx under a script it was never committed to), andmin_value == 0guard for spendable outputs on a cache hit, letting a zero-minimum-value (spendable) output pass where it should be rejected.Fix
ComputeEntryRangeProofnow hashesproof + value_commitment + asset_commitment + scriptPubKey. Non-cached paths are unchanged; the fix only widens the cache key to everything the proof actually binds.Tests
test: unit test for range proof cache fix— newrangeproof_cache_binding_testinsrc/test/blind_tests.cpp. Fails on all 3 assertions (different script, different asset generator,min_value == 0guard) when the cache-key change is reverted; passes with the fix.blind_tests,script_tests,validation_tests,coins_testsall pass with the fix.test: functional test for range proof cache fix— newfeature_rangeproof_cache.py. Rejects the poisoned (cache-hit) transaction on a warm cache and, after restart, on a cold cache; passes with the fix and fails on unfixed code.feature_confidential_transactions,feature_issuance,feature_sighash_rangeproofall pass.