verify function
Compares two byte arrays a
and b
in constant time.
Returns true
if they are identical, false
otherwise.
This function avoids early exits that could leak information.
Implementation
bool verify(Uint8List a, Uint8List b) {
if (a.length != b.length) return false;
int r = 0;
for (int i = 0; i < a.length; i++) {
r |= a[i] ^ b[i];
}
return r == 0;
}