The constructor is not meant to be used directly, use create or from methods instead.
Constructor parameters
Uint8Array big enough to hold all nodes in the tree
Hash function for internal nodes. Must follow the InplaceMerkleHashFn signature
Size of each node in bytes. Must be at least 1 byte
StaticcreateCreate a new MerkleTree instance with the given parameters, allocating memory to contain all nodes. Initializes the tree with the zero element. Returns an instance to use
Creation parameters
Depth of the tree, excluding the root node. Must be at least 1
Hash function to use for internal nodes. Must follow the InplaceMerkleHashFn signature
Zero element to use for leaf nodes. Internal nodes are calculated up to the root. Must be at least 1 byte
Instance of MerkleTree
StaticfromCreate a new MerkleTree instance from a serialized object and global parameters
Serialized object of the merkle tree
Additional system parameters
Instance
Protected_Internal method to get a reference to the buffer slice for a node at a given index
element-wise index
subarray of bytesPerElement aligned to a multiple of the node size
Protected_Internal method to set a node at a given
element-wise index
bytesPerElement-sized buffer to copy
Get a reference to the leaf node at a given index
Zero-based index of the leaf node. Out of bounds indices will throw an error
Read-only zero-copy leaf node
Insert nodes at a given index of the tree. Supports either a single node or an array of nodes,
efficiently updating parents. Note only up to size elements can be filled, overfilling will
cause an assertion error.
start index of first element
single element or sequence of consecutive elements
index after last element inserted. Useful for chaining inserts
Return the root element of the tree
Read-only zero-copy root element
Generate an inclusion proof for a given index. Returns an object with the index, root and path elements, where path elements are the first sibling and uncles of the node up to the root.
Leaf index to prove
Merkle proof for the given leaf index
Zero-copy a serialisable representation of the current tree into a plain object
Serializable object representation of the tree
StaticLEAF_Level of leaf nodes in the tree. All leaf nodes are at this level, while all internal nodes are at higher levels.
ReadonlybufUnderlying buffer holding all tree nodes
Readonlyhash3-arity hash function deriving parents. First argument is output buffer to be populated with the hash digest
ReadonlybytesBytes per node
ReadonlycapacityTotal number of nodes in the tree
Protected Readonly_Cached index of root node
ReadonlysizeTotal number of leaf nodes in the tree
ReadonlydepthDepth of the tree
General base Merkle Tree implementation.