validate method Null safety
- Uint8List hash,
- Uint8List proof,
- Uint8List root
Validates the inclusion of the hash
in root
by renuilding it using proof
Implementation
static bool validate(Uint8List hash, Uint8List proof, Uint8List root) {
int pos = proof[0];
Uint8List hashPair = proof.sublist(1, 33);
if (pos == 0) {
hash = Digest("SHA3-256").process((BytesBuilder()
..add(hashPair)
..add(hash))
.toBytes());
} else {
hash = Digest("SHA3-256").process((BytesBuilder()
..add(hash)
..add(hashPair))
.toBytes());
}
if (proof.length > 33) return validate(hash, proof.sublist(33), root);
return memEquals(hash, root);
}