ConstantTime.Choice
— TypeConstantTime.Selectable
— TypeConstantTime.Value
— TypeValue{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.get
— Methodget(array::Array{Value{V}, 1}, x::Value, default::Value{V}) where V <: Selectable
Constant-time array access.
ConstantTime.select
— Methodselect(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.swap
— MethodConstantTime.unwrap
— Methodunwrap(x)
unwrap(x::Value)
If x
is a Value
, returns the wrapped value. Otherwise, returns x
.
ConstantTime.unwrap_choice
— Methodunwrap(x::Choice)
Returns the wrapped boolean value.
Not constant-time.
ConstantTime.wrap
— Method