validate method Null safety

bool validate(
  1. Uint8List hash,
  2. Uint8List proof,
  3. 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);
}