Create a new Merkle tree.
The array of Uint8Array data values that the tree will be constructed from.
The hash function that will be used to create the tree. Defaults to 'sha256'.
The options to use when creating the tree.
Get the Merkle tree height, which is the number of hashing layers that resulted after building the tree not including the Merkle root. Should be Math.ceil(Math.log2(data.length))
.
The tree height value.
Get the Merkle inclusion proof for specific data in raw form.
The single data item, already added to the tree, to get the proof for.
The Merkle inclusion proof value.
Get the Merkle inclusion proof for specified data as a single Hex encoded string.
The single data item, already added to the tree, to get the proof for.
The Merkle inclusion proof value.
Get the Merkle inclusion proof for specified data as a JavaScript Object with Hex encoded hash values.
The single data item, already added to the tree, to get the proof for.
The Merkle inclusion proof value.
Get the Merkle root of the tree.
The Merkle root value.
Verify a proof against the Merkle root
, data
, and hashFunction
generated at Tree creation time.
The Merkle root
value of a tree.
The Merkle inclusion proof
that allows traversal from the data
to the root
. The proof
can be provided in any of the supported encodings.
A single data item, exactly as added to the original tree, that the proof
was generated for.
The hash function name, must be the same as that used to create the tree originally. Optional if providing an object encoded proof which already has the hash function name embedded.
A boolean to indicate verification success or failure.
Class representing a Merkle tree.