Skip to content

Commit

Permalink
Add GetNode() to the merkle tree interface
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Zhang <[email protected]>
  • Loading branch information
jimthematrix committed Jul 30, 2024
1 parent bc40deb commit f7024cc
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions zkp/golang/pkg/core/merkletree.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ import "math/big"
//
// The tree is built from the root node, at level 0, down to the leaf nodes.
//
// root level 0
// / \
// e f level 1
// / \ / \
// a b c d level 2
// / \ / \ / \ / \
// 1 2 3 4 5 - - - level 3
// root level 0
// / \
// e f level 1
// / \ / \
// a b c d level 2
// / \ / \ / \ / \
// 1 2 3 4 5 - - - level 3
type SparseMerkleTree interface {
// Root returns the root hash of the tree
Root() NodeIndex
// AddLeaf adds a key-value pair to the tree
AddLeaf(Node) error
// GetNode returns the node at the given reference hash
GetNode(NodeIndex) (Node, error)
// GetnerateProof generates a proof of existence (or non-existence) of a leaf node
GenerateProof(*big.Int, NodeIndex) (Proof, *big.Int, error)
}

0 comments on commit f7024cc

Please sign in to comment.