-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fix proof generation handling of empty sibilings #72
Conversation
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
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.
A minor comment on the description of the function
@@ -104,14 +104,29 @@ func (mt *sparseMerkleTree) GetNode(key core.NodeIndex) (core.Node, error) { | |||
// GenerateProof generates the proof of existence (or non-existence) of a leaf node | |||
// for a Merkle Tree given the root. It uses the node's index to represent the node. | |||
// If the rootKey is nil, the current merkletree root is used | |||
func (mt *sparseMerkleTree) GenerateProof(k *big.Int, rootKey core.NodeIndex) (core.Proof, *big.Int, error) { | |||
func (mt *sparseMerkleTree) GenerateProofs(keys []*big.Int, rootKey core.NodeIndex) ([]core.Proof, []*big.Int, error) { |
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 read this code several times trying to understand how this could relate to the problem described. then realized it's a just a refactor for code convenience. the description of the methods is not updated.
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.
yeah sorry this was a necessary improvement so that multiple proofs can be generated against the same root inside the sync'ed routine
Co-authored-by: Chengxuan Xing <[email protected]> Signed-off-by: jimthematrix <[email protected]>
The Proof object usually contains empty nodes, for efficiency we don't lug the empty node around but instead use a byte array of length 32, so that there are 256 bits one for each level, to indicate which levels are empty/non-empty.
This fixes some bugs in the handling of the array with both marking the bits and reading the bits