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.
Macrosยง
- bitborrow ๐
- Outgoing borrow bit for a wrapping
x - y - borrow_inresult. - bitle ๐
- Bitwise less-than-or equal: returns
1ifx <= y, and otherwise returns0. - bitlt ๐
- Bitwise less-than: returns
1ifx < y, and otherwise returns0. - bitnz ๐
- Bitwise non-zero: returns
1ifx != 0, and otherwise returns0. - borrowing_
sub_ ๐primitives - comparison_
primitives ๐
Functionsยง
- borrowing_
sub_ ๐inner_ u32 - borrowing_
sub_ ๐inner_ u64 - borrowing_
sub_ mask_ u32 - Subtract
rhsand an incoming borrow fromlhs, using word-sized borrow masks. - borrowing_
sub_ mask_ u64 - Subtract
rhsand an incoming borrow fromlhs, using word-sized borrow masks. - borrowing_
sub_ u32 - Subtract
rhsand an incoming borrow fromlhs. - borrowing_
sub_ u64 - Subtract
rhsand an incoming borrow fromlhs. - le_u32 ๐
- le_u64 ๐
- leading_
zeros_ u32 - Count leading zero bits, returning 32 if
valueis zero. - leading_
zeros_ u64 - Count leading zero bits, returning 64 if
valueis zero. - lt_u32 ๐
- lt_u64 ๐
- nz_u32 ๐
- nz_u64 ๐
- overflowing_
add_ u64 - Add two integers, returning the wrapping sum and
Choice::TRUEon overflow. - overflowing_
add_ u128 - Add two integers, returning the wrapping sum and
Choice::TRUEon overflow. - trailing_
zeros_ u32 - Count trailing zero bits, returning 32 if
valueis zero. - trailing_
zeros_ u64 - Count trailing zero bits, returning 64 if
valueis zero.