Skip to main content

LimbType

Type Alias LimbType 

Source
pub type LimbType = u64;
Expand description

The basic unit used by the multiprecision integer arithmetic implementation.

The LimbType is mostly an internal implementation detail and users must make no assumption about it representation, the only guarantee is that it’s a type alias to one of Rust’s native unsigned integer types.

§Notes on constant-time

The following arithmetic on a LimbType is assumed to be constant-time:

  • Binary operations: not, or, and, xor.
  • Wrapping addition and subtraction of two LimbType words.
  • Multiplication of two LimbType words where the result also fits a LimbType.

Wider LimbType type defines would improve multiprecision arithmetic performance, but it must be made sure that all of the operations from above map to (constant-time) CPU instructions and are not implemented by e.g. some architecture support runtime library. In the generic case, the (supposedly) smallest common denominator of u32 is chosen, but it might be overriden for specific architectures.