mpt: add support for prefix scans and proofs - #87
Open
rsc wants to merge 1 commit into
Open
Conversation
Replace Tree.Prove with a single Tree.Path method that returns the raw path proof for a key or prefix lookup, plus top-level ProveLookup and ProvePrefix functions that reduce a path to a key or prefix claim and its proof, verified by VerifyLookup (renamed from Verify) and the new VerifyPrefix, which share a verifyPath helper. This keeps the derivation logic in one place instead of duplicating it across the mem and disk Tree implementations. Implement Scan for both implementations. Extend testdata/mkverify.go and testdata/verify.txt with prefix proof test vectors, and add testdata/mkprefix.go, which generates testdata/prefix.txt: the full matrix of prefixes tried against a range of trees (empty, every prefix of a set of keys chosen to exercise the key padding rules, and 200 SHA256-derived keys), so that other implementations can check Scan, ProvePrefix, and VerifyPrefix against the same vectors. TestPrefix now reads that file instead of generating the matrix itself, and TestMalformedPath is new.
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.
Replace Tree.Prove with a single Tree.Path method that returns the raw path proof for a key or prefix lookup, plus top-level ProveLookup and ProvePrefix functions that reduce a path to a key or prefix claim and its proof, verified by VerifyLookup (renamed from Verify) and the new VerifyPrefix, which share a verifyPath helper. This keeps the derivation logic in one place instead of duplicating it across the mem and disk Tree implementations.
Implement Scan for both implementations.
Extend testdata/mkverify.go and testdata/verify.txt with prefix proof test vectors, and add testdata/mkprefix.go, which generates testdata/prefix.txt: the full matrix of prefixes tried against a range of trees (empty, every prefix of a set of keys chosen to exercise the key padding rules, and 200 SHA256-derived keys), so that other implementations can check Scan, ProvePrefix, and VerifyPrefix against the same vectors. TestPrefix now reads that file instead of generating the matrix itself, and TestMalformedPath is new.