verify function
Verify Proof
Implementation
verify(List<Uint8List?> proof, DigestFn digestFn) {
Uint8List root = proof[proof.length - 1]!;
Uint8List hash = root;
for (int i = 0; i < proof.length - 1; i += 2) {
Uint8List left = proof[i] ?? hash;
Uint8List right = proof[i + 1] ?? hash;
Uint8List data = Uint8List(left.length + right.length)
..setAll(0, left)
..setAll(left.length, right);
hash = digestFn(data);
}
return hash.toString() == root.toString();
}