Skip to content

mpt: add support for prefix scans and proofs - #87

Open
rsc wants to merge 1 commit into
FiloSottile:mainfrom
rsc:prefix
Open

mpt: add support for prefix scans and proofs#87
rsc wants to merge 1 commit into
FiloSottile:mainfrom
rsc:prefix

Conversation

@rsc

@rsc rsc commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant