MerkleTree class
Class representing a Merkle Tree
Constructors
-
MerkleTree({required List<
Uint8List> leaves, required HashAlgo hashAlgo, bool isBitcoinTree = false}) - Constructs a Merkle Tree. All nodes and leaves are stored as Uint8List. Lonely leaf nodes are promoted to the next level up without being hashed again.
-
MerkleTree.fromTree({required List<
List< layers, required HashAlgo hashAlgo, bool isBitcoinTree = false})Uint8List> >
Properties
- hashAlgo → HashAlgo
-
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- isBitcoinTree → bool
-
final
-
layers
→ List<
List< Uint8List> > -
Returns array of all layers of Merkle Tree, including leaves and root.
no setter
-
layersAsHex
→ List<
List< String> > -
no setter
- root → Uint8List
-
Returns the Merkle root hash as a Buffer.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getProof(
{required Uint8List leaf, int index = -1}) → List< MerkleProof> -
Returns the proof for a target leaf.
leaf
is the target leaf for this proof.index
is the target leaf index in leaves array. Use only if there are leaves containing duplicate data in order to distinguish it. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
verify(
{required List< MerkleProof> proof, required Uint8List targetNode, required Uint8List root}) → bool -
Returns true if the proof path (array of hashes) can connect the target node to the Merkle root.
proof
is a list of MerkleProof objects that should connect target node to Merkle root.targetNode
is the target node buffer.root
is the Merkle root Buffer.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override