constantTimeSelect
constantTimeSelect(
condition,ifTrue,ifFalse):Uint8Array<ArrayBuffer>
Defined in: select.ts:13
Selects every byte of ifTrue or every byte of ifFalse, combined via an
arithmetic mask rather than a per-byte or top-level conditional on
condition.
Note: “Constant-time” is best-effort, not proven: JS gives no such guarantee. Function avoid branching on secret byte values — the only branch either takes is on input length, which is a public property of the call (fixed by the algorithm, e.g. a MAC tag size), never secret content.
Parameters
Section titled “Parameters”condition
Section titled “condition”boolean
ifTrue
Section titled “ifTrue”Uint8Array
ifFalse
Section titled “ifFalse”Uint8Array
Returns
Section titled “Returns”Uint8Array<ArrayBuffer>
Throws
Section titled “Throws”When ifTrue and ifFalse differ in length.