Skip to content
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

feat(merkle_tree): initial batch membership proof implementation #740

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

crStiv
Copy link

@crStiv crStiv commented Jan 20, 2025

This PR provides an initial implementation of batch membership proof functionality that was marked as TODO.
Current implementation includes:

  • Basic BatchMembershipProof type
  • batch_lookup and batch_verify methods
  • Basic iterative approach for batch operations

Next steps (will be discussed in a separate issue):

  • Optimization of batch verification
  • Adding tests
  • Adding documentation
  • Possible algorithmic improvements

Related TODO: merkle_tree/src/macros.rs:43

@mrain
Copy link
Contributor

mrain commented Jan 21, 2025

Thank you for your contribution!
However, we are seeking a more compact version of the batch proof. The basic implementation of Vec<MerkleTreeProof<T>> can be easily achieved externally, making its impact rather limited.

@alxiong
Copy link
Contributor

alxiong commented Jan 21, 2025

Agree, we'd be happy to see a non-trival batched proof that's shorter than concatenation of n original proofs. Through internal nodes reuse or whatnot.

@crStiv
Copy link
Author

crStiv commented Jan 21, 2025

@mrain
@alxiong

Hey! I've improved the batch proof to make it more compact by sharing common nodes between proofs instead of storing duplicates. Added proper error checks and tests to make sure everything works correctly. This should address the concerns about proof size from the previous comments.

  • Implemented CompactBatchProof that reduces memory usage by:

    • Storing shared nodes only once
    • Keeping only differing nodes for individual proofs
    • Reusing common paths during verification
  • Added error handling for invalid inputs

  • Included comprehensive test coverage

  • Added full documentation

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.

3 participants