Initializes the SMT attributes.
Hash function used to hash the child nodes.
BigInt type enabling.
Adds a new entry in the tree. It retrieves a matching entry or a zero node with a top-down approach and then it updates all the hashes of the nodes in the path of the new entry with a bottom-up approach.
The key of the new entry.
The value of the new entry.
Adds new nodes in the tree with a bottom-up approach until it reaches the root node.
The node to start from.
The path of the key.
The side nodes of the path.
The index to start from.
The root node.
Calculates nodes with a bottom-up approach until it reaches the root node.
The node to start from.
The path of the key.
The side nodes of the path.
The root node.
Checks 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.
Deletes nodes in the tree with a bottom-up approach until it reaches the root node.
The node to start from.
The path of the key.
The side nodes of the path.
The index to start from.
Gets a key and if the key exists in the tree the function returns the value, otherwise it returns 'undefined'.
A key of a tree entry.
A value of a tree entry or 'undefined'.
Checks if a node is a leaf node.
A node of the tree.
True if the node is a leaf, false otherwise.
Searches 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 side nodes of the path.
The key of the entry to search for.
The entry response.
Updates a value of 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.
The value of the entry.
Verifies a membership or a non-membership proof.
The proof to verify.
True if the proof is valid, false otherwise.
Generated using TypeDoc
SMT 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
;