From f7024ccc7192dfdfc230542deb361c3e09f77b07 Mon Sep 17 00:00:00 2001 From: Jim Zhang Date: Wed, 24 Jul 2024 11:05:16 -0400 Subject: [PATCH] Add GetNode() to the merkle tree interface Signed-off-by: Jim Zhang --- zkp/golang/pkg/core/merkletree.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/zkp/golang/pkg/core/merkletree.go b/zkp/golang/pkg/core/merkletree.go index 70d47af..de5447a 100644 --- a/zkp/golang/pkg/core/merkletree.go +++ b/zkp/golang/pkg/core/merkletree.go @@ -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) }