MerkleTree<T> class
Production-ready Merkle Tree implementation
Constructors
- MerkleTree({String hashFunction(T)?, String salt = ''})
- Creates an empty Merkle tree
-
MerkleTree.fromJson(Map<
String, dynamic> json, String hashFunction(T)) -
Creates tree from JSON representation
factory
-
MerkleTree.fromList(List<
T> items, {String hashFunction(T)?, String salt = ''}) -
Creates a Merkle tree from a list of data items
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hashFunction → String Function(T)
-
final
- height → int
-
final
- leafCount → int
-
final
-
leafHashes
→ List<
String> -
Gets all leaf hashes
no setter
-
root
→ MerkleNode<
T> ? -
final
- rootHash → String?
-
Gets the root hash of the tree
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
generateProof(
int leafIndex) → MerkleProof< T> - Generates a Merkle proof for a specific leaf
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Serializes the tree structure for storage/transmission
-
toString(
) → String -
A string representation of this object.
override
-
updateLeaf(
int index, T newData) → MerkleTree< T> - Updates a leaf and recalculates affected hashes
-
updateLeavesBatch(
Map< int, T> updates) → MerkleTree<T> - Updates multiple leaves in batch for efficiency
-
verifyProof(
T data, MerkleProof< T> proof) → bool - Verifies a Merkle proof
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited