-
Notifications
You must be signed in to change notification settings - Fork 45
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,10 +206,18 @@ func (proof Proof) verifyLeafHashes(nth *Hasher, verifyCompleteness bool, nID na | |
return bytes.Equal(tree.Root(), root) | ||
} | ||
|
||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you document this public function? I don't actually know what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure thing d40c9b5 |
||
nth := NewNmtHasher(h, nid.Size(), proof.isMaxNamespaceIDIgnored) | ||
leafData := append(nid, data...) | ||
return proof.verifyLeafHashes(nth, false, nid, [][]byte{nth.HashLeaf(leafData)}, root) | ||
hashes := make([][]byte, len(data)) | ||
for i, d := range data { | ||
leafData := append(append( | ||
make([]byte, 0, len(d)+len(nid)), | ||
nid...), | ||
d...) | ||
adlerjohn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
hashes[i] = nth.HashLeaf(leafData) | ||
} | ||
|
||
return proof.verifyLeafHashes(nth, false, nid, hashes, root) | ||
} | ||
|
||
// nextSubtreeSize returns the size of the subtree adjacent to start that does | ||
|
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.
#60