-
Notifications
You must be signed in to change notification settings - Fork 43
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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 { |
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.
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.
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.
Can you document this public function? I don't actually know what [][]byte
is just by looking at it.
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.
sure thing d40c9b5
Can you note in the PR description that this is a breaking API change? |
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" |
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.
We should switch to the go-internal fuzzer soon.
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.
// 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 { |
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.
An additional convenience method VerifyNamespaceRange
or sth alike does not make sense?
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.
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
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