-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented Batched Proof for multiple openings and Path Pruning #130
Conversation
That's a great addition, thanks! I left minor comments for now, though haven't gone over the actual algorithm yet. |
Co-authored-by: Pratyush Mishra <[email protected]>
Co-authored-by: Pratyush Mishra <[email protected]>
Co-authored-by: Marcin <[email protected]>
Co-authored-by: Marcin <[email protected]>
Co-authored-by: Marcin <[email protected]>
Co-authored-by: Marcin <[email protected]>
Co-authored-by: Marcin <[email protected]>
@mmagician I fixed the code in EDIT: did a similar optimization for compression. I removed compress and pushed compression into generation. This speeds up things a lot (70%) |
…path to compute_auth_path
…his solves a bug where hashes were computed no matter what). This makes the lut optimization effective
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is very strange that batch verification is slower than naive - if anything, by using the lookup table I'd expect a speedup. Were you able to identify which part of the new batch verify
is causing this?
the PR has been updated, now in the single threaded case MultiProof Verification is faster (verification test runs in ~2.8s on my thinkpad X1 Gen10 against ~3.8s of single proof verification). For reference, multiproof is only slightly slower for creation of the proof (tests for generation run in ~600ms against ~400ms for single proof generation), but on the other size the proof size is smaller and verification is much faster. |
…zation Merkle multiproofs optimization
@mmagician the changes proposed by @Cesar199999 have been merged to the main branch of my fork |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmagician I followed @autquis commit to fix the tests, all good |
Description
This PR implements an optimized struct
MultiPath
which holds multiple proofs for multiple leaves. AMultiPath
is generated viaMerkleTree::generate_multi_proof(...)
which takes an iterable of leaf indexes.MultiPath
optimizes the proof size by compressing multiple paths using Front Encoding. To verify,MultiPath
exposes the same API asPath
, with averify(...)
method which takes an iterable of leaf hashes instead of a single hash. For verification,MultiPath
optimizes runtime by using a lookup table to avoid recomputing redundant hashes of nodes.The only caveat to
MultiPath
is that, when callinggenerate_multi_proof
, the provided array of indexes is internally sorted to maximize compression efficiency. The array of leaves hashes provided at verification time should then match this order. The documentation provides an example code snippet.Files affected:
src/merkle_tree/mod.rs
src/merkle_tree/tests/mod.rs
closes: #124
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Pending
section inCHANGELOG.md
Files changed
in the Github PR explorer