Expand description

Constant time operations

This module exports traits to do basic checking operation in constant time, those operations are:

  • CtZero : constant time zero and non-zero checking
  • CtEqual : constant time equality and non-equality checking
  • CtLesser : constant time less (<) and opposite greater-equal (>=) checking
  • CtGreater : constant time greater (>) and opposite lesser-equal (<=) checking

And simple types to manipulate those capabilities in a safer way:

  • Choice : Constant time boolean and safe methods. this was initially called CtBool but aligned to other implementation.
  • CtOption : Constant time Option type.

Great care has been done to make operation constant so that it’s useful in cryptographic context, but we’re not protected from implementation bug, compiler optimisations, gamma rays and other Moon-Mars alignments.

The general functionality would be a great addition to the rust core library to have those type of things built-in and crucially more eyeballs.

Structs

Constant time boolean
Constant time equivalent to Option.

Traits

Check in constant time if the left object is equal to the right object
Check in constant time if the left object is greater than right object
Check in constant time if the left object is lesser than right object
Check in constant time if the object is zero or non-zero