constant-time= ( a b -- ? )
Cryptographic utilities

Next:constant-time-zero? ( seq -- ? )


Vocabulary
crypto.utils

Inputs
aa sequence
ba sequence


Outputs
?t if equal, f otherwise


Word description
Compares two sequences for equality in constant time. Unlike = or sequence=, this function always examines all bytes of both sequences (when lengths match), preventing timing attacks that could reveal information about the contents.

Notes
If the sequences have different lengths, returns f immediately. This length check is not constant-time, but sequence lengths are typically not secret in cryptographic protocols.

Examples
USING: byte-arrays crypto.utils ; B{ 1 2 3 4 } B{ 1 2 3 4 } constant-time=
! => t


Definition