ConstantTime.ChoiceType

An object representing a result of a constant-time comparison, used in select and swap.

Supports !.

Warning

Comparison of immutable objects with Value fields bypasses the custom ==, and the result is an unwrapped boolean.

ConstantTime.ValueType
Value{T}(value::T)
Value(value::T)

A wrapper for a type T that protects it from being used in non-constant-time operations.

This module defines some methods that are (most probably) constant-time. Namely, for built-in integer types (Int8...128 and UInt8...128), the following methods are defined: zero, one, ~, +, -, xor, &, |, % (with the second argument being a built-in integer type), signed, unsigned, iseven, isodd, iszero, ==. Also, >> and << are defined for the shift also being a built-in integer.

The functions that would otherwise return Bool will return Choice for Value objects.

Binary operations on one Value and one unwrapped value produce a Value.

Base.getMethod
get(array::Array{Value{V}, 1}, x::Value, default::Value{V}) where V <: Selectable

Constant-time array access.

ConstantTime.selectMethod
select(choice::Bool, x, y)
select(choice::Choice, x::Value{T}, y::Value{T})

An analogue of a ternary operator or ifelse (which, at the moment, cannot have methods added to them).

If choice is true, returns x, else y. For choice being a Choice object, and x and y being Value objects, the operation is constant-time.

ConstantTime.swapMethod
swap(choice::Bool, x, y)
swap(choice::Choice, x::Value{T}, y::Value{T})

If choice is true, returns (y, x), else (x, y). For choice being a Choice object, and x and y being Value objects, the operation is constant-time.

ConstantTime.unwrapMethod
unwrap(x)
unwrap(x::Value)

If x is a Value, returns the wrapped value. Otherwise, returns x.