Initializes the SparseMerkleTree attributes.
Hash function used to hash the child nodes.
BigInt type enabling.
Private
bigPrivate
entryPrivate
hashPrivate
nodesPrivate
zeroPrivate
addPrivate
calculatePrivate
checkChecks the parameter type.
The parameter to check.
Creates a proof to prove the membership or the non-membership of a tree entry.
A key of an existing or a non-existing entry.
The membership or the non-membership proof.
Deletes an entry in the tree. Also in this case all the hashes of the nodes in the path of the entry are updated with a bottom-up approach.
The key of the entry.
Private
deletePrivate
isChecks if a node is a leaf node.
A node of the tree.
True if the node is a leaf, false otherwise.
Private
retrieveSearches for an entry in the tree. If the key passed as parameter exists in the tree, the function returns the entry, otherwise it returns the entry with only the key, and when there is another existing entry in the same path it returns also this entry as 'matching entry'. In any case the function returns the siblings of the path.
The key of the entry to search for.
The entry response.
Verifies a membership or a non-membership proof.
The proof to verify.
True if the proof is valid, false otherwise.
SparseMerkleTree class provides all the functions to create a sparse Merkle tree and to take advantage of its features:
SMT.add
,SMT.get
,SMT.update
,SMT.delete
,SMT.createProof
,SMT.verifyProof
. To better understand the code below it may be useful to describe the terminology used:H(x, y)
);H(x, y, 1)
);H(0,0) = 0
;