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

Verify inclusion proofs with multiple leaves #58

Merged
merged 5 commits into from
May 30, 2022

Conversation

evan-forbes
Copy link
Member

@evan-forbes evan-forbes commented May 29, 2022

building on #57, we also need to be able to verify inclusion proofs for arbitrary ranges of leaves.

Note: this PR is API breaking and will require another version bump

@codecov
Copy link

codecov bot commented May 29, 2022

Codecov Report

Merging #58 (2a5e672) into master (9270813) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #58      +/-   ##
==========================================
+ Coverage   95.58%   95.60%   +0.02%     
==========================================
  Files           7        7              
  Lines         362      364       +2     
==========================================
+ Hits          346      348       +2     
  Misses         11       11              
  Partials        5        5              
Impacted Files Coverage Δ
proof.go 97.05% <100.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9270813...2a5e672. Read the comment docs.

proof.go Outdated
func (proof Proof) VerifyInclusion(h hash.Hash, nid namespace.ID, data []byte, root []byte) bool {
func (proof Proof) VerifyInclusion(h hash.Hash, nid namespace.ID, data [][]byte, root []byte) bool {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This api is arbitrarily restricting proofs to the same namespace. While that fits our use case for the rest of the repos, the api could be simplified to match tree.Push() where the namespace is included in the data. This would simplify some other things as well, but I felt that was outside the scope of this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document this public function? I don't actually know what [][]byte is just by looking at it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing d40c9b5

@adlerjohn
Copy link
Member

Can you note in the PR description that this is a breaking API change?

proof.go Outdated Show resolved Hide resolved
@evan-forbes evan-forbes requested a review from liamsi May 30, 2022 18:59
proof.go Outdated Show resolved Hide resolved
Co-authored-by: John Adler <[email protected]>
@@ -8,7 +8,7 @@ import (

"github.com/celestiaorg/nmt"
"github.com/celestiaorg/nmt/namespace"
"github.com/google/gofuzz"
fuzz "github.com/google/gofuzz"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should switch to the go-internal fuzzer soon.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#60

// and the provided proof to regenerate and compare the root. Note that the leaf
// data should not contain the prefixed namespace, unlike the tree.Push method,
// which takes prefixed data. All leaves implicitly have the same namespace ID: `nid`.
func (proof Proof) VerifyInclusion(h hash.Hash, nid namespace.ID, leaves [][]byte, root []byte) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An additional convenience method VerifyNamespaceRange or sth alike does not make sense?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that working as well, tbh I just didn't think about that and was just following the underlying library's API.

I want to merge to wrap this up, but I also don't want to lose this comment, so #59

@evan-forbes evan-forbes merged commit e679661 into master May 30, 2022
@evan-forbes evan-forbes deleted the evan/verify-multiple-leaves branch May 30, 2022 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants