Module hacspec_lib::prelude::ct_util
source · [−]Functions
Function that is not part of the language but is offered as a helper for tests, etc.
Add two numerics if condition c is set (all bits 1).
Returns x if condition c is 0.
Note: Addition is always wrapping.
Function that is not part of the language but is offered as a helper for tests, etc.
Multiply two numerics if condition c is set (all bits 1).
Returns x if condition c is 0.
Note: Multiplication is always wrapping.
Function that is not part of the language but is offered as a helper for tests, etc.
Set bit at position i in x to b if c is all 1 and return the restult.
Returns x if c is 0.
Function that is not part of the language but is offered as a helper for tests, etc.
Subtract two numerics if condition c is set (all bits 1).
Returns x if condition c is 0.
Note: Addition is always wrapping.
Function that is not part of the language but is offered as a helper for tests, etc.
Conditional, constant-time swapping.
Returns (x, y) if c == 0 and (y, x) if c == T::max.
The return value is undefined if c has any other value.
Function that is not part of the language but is offered as a helper for tests, etc.
Conditional, constant-time swapping.
Returns (x, y) if c == 0 and (y, x) if c == 1.
Function that is not part of the language but is offered as a helper for tests, etc.
Constant time division for Numerics.
Note that this function is only constant time if T is a secret integer and
hence provides constant time implementations for the used functions.