Skip to content

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.

boolean

Uint8Array

Uint8Array

Uint8Array<ArrayBuffer>

When ifTrue and ifFalse differ in length.