Skip to main content

Module primitives

Module primitives 

Source
Expand description

Constant-time integer primitives for cryptographic arithmetic.

Core integer methods can lower to branches or table lookups on targets without the corresponding instructions. These helpers provide alternatives if value is zero-bit counting and carry propagation.

Like Choice, they use optimization barriers where needed. Their generated code should still be checked for the target and compiler in use.

Native zero counts are used when supported and advertised by the target configuration.

Functionsยง

borrowing_sub_u32
Subtract rhs and an incoming borrow from lhs.
borrowing_sub_u64
Subtract rhs and an incoming borrow from lhs.
leading_zeros_u32
Count leading zero bits, returning 32 if value is zero.
leading_zeros_u64
Count leading zero bits, returning 64 if value is zero.
overflowing_add_u64
Add two integers, returning the wrapping sum and Choice::TRUE on overflow.
overflowing_add_u128
Add two integers, returning the wrapping sum and Choice::TRUE on overflow.
trailing_zeros_u32
Count trailing zero bits, returning 32 if value is zero.
trailing_zeros_u64
Count trailing zero bits, returning 64 if value is zero.