Compare two Uint8Arrays for equality using constant-time comparison.
This function is designed to be resistant to timing attacks by always
comparing all bytes regardless of where a difference is found. The
comparison time depends only on the length of the arrays, not on where
they differ.
Security Note: If the arrays have different lengths, this function
returns false immediately, which does leak length information. For
cryptographic uses where length should also be secret, ensure both
arrays are the same length before comparison.
Parameters
a: Uint8Array
First byte array
b: Uint8Array
Second byte array
Returns boolean
true if both arrays have the same length and identical contents
Compare two Uint8Arrays for equality using constant-time comparison.
This function is designed to be resistant to timing attacks by always comparing all bytes regardless of where a difference is found. The comparison time depends only on the length of the arrays, not on where they differ.
Security Note: If the arrays have different lengths, this function returns
falseimmediately, which does leak length information. For cryptographic uses where length should also be secret, ensure both arrays are the same length before comparison.