Skip to main content

Module ct

Module ct 

Source
Expand description

A set of constant-time helper functions for the following:

  • Basic arithmetic operations such as less-than(x, y), is_zero(x), etc.
  • Conditional operations such as select and swap whose output depends on whether the condition is true or false.
  • Implementing boolean operators for Condition<T>: &, &=, |, |=, ^, ^=.

Structs§

Condition
Helper functions for checking some condition on some data using constant-time operations.

Functions§

conditional_copy_bytes
Copies either the contents of a or b into out according to take_a and it does it in a constant-time manner without branching.
ct_eq_bytes
Rust doesn’t guarantee that anything can truly be constant-time under all compilation targets and optimization levels. The following presents the standard constant-time shape.
ct_eq_zero_bytes
Rust doesn’t guarantee that anything can truly be constant-time under all compilation targets and optimization levels. The following presents the standard constant-time shape.