Struct Limb
#[repr(transparent)]pub struct Limb(pub u64);Expand description
Big integers are represented as an array of smaller CPU word-size integers called “limbs”.
Tuple Fields§
§0: u64Implementations§
§impl Limb
impl Limb
pub const fn adc(self, rhs: Limb, carry: Limb) -> (Limb, Limb)
pub const fn adc(self, rhs: Limb, carry: Limb) -> (Limb, Limb)
Computes self + rhs + carry, returning the result along with the new carry.
pub const fn saturating_add(&self, rhs: Limb) -> Limb
pub const fn saturating_add(&self, rhs: Limb) -> Limb
Perform saturating addition.
pub const fn wrapping_add(&self, rhs: Limb) -> Limb
pub const fn wrapping_add(&self, rhs: Limb) -> Limb
Perform wrapping addition, discarding overflow.
§impl Limb
impl Limb
pub const fn leading_zeros(self) -> usize
pub const fn leading_zeros(self) -> usize
Calculate the number of leading zeros in the binary representation of this number.
pub const fn trailing_zeros(self) -> usize
pub const fn trailing_zeros(self) -> usize
Calculate the number of trailing zeros in the binary representation of this number.
pub const fn trailing_ones(self) -> usize
pub const fn trailing_ones(self) -> usize
Calculate the number of trailing ones the binary representation of this number.
§impl Limb
impl Limb
pub fn cmp_vartime(&self, other: &Limb) -> Ordering
pub fn cmp_vartime(&self, other: &Limb) -> Ordering
Perform a comparison of the inner value in variable-time.
Note that the PartialOrd and Ord impls wrap constant-time
comparisons using the subtle crate.
pub const fn eq_vartime(&self, other: &Limb) -> bool
pub const fn eq_vartime(&self, other: &Limb) -> bool
Performs an equality check in variable-time.
§impl Limb
impl Limb
pub const fn mac(self, b: Limb, c: Limb, carry: Limb) -> (Limb, Limb)
pub const fn mac(self, b: Limb, c: Limb, carry: Limb) -> (Limb, Limb)
Computes self + (b * c) + carry, returning the result along with the new carry.
pub const fn saturating_mul(&self, rhs: Limb) -> Limb
pub const fn saturating_mul(&self, rhs: Limb) -> Limb
Perform saturating multiplication.
pub const fn wrapping_mul(&self, rhs: Limb) -> Limb
pub const fn wrapping_mul(&self, rhs: Limb) -> Limb
Perform wrapping multiplication, discarding overflow.
§impl Limb
impl Limb
pub const fn wrapping_neg(self) -> Limb
pub const fn wrapping_neg(self) -> Limb
Perform wrapping negation.
§impl Limb
impl Limb
pub const fn sbb(self, rhs: Limb, borrow: Limb) -> (Limb, Limb)
pub const fn sbb(self, rhs: Limb, borrow: Limb) -> (Limb, Limb)
Computes self - (rhs + borrow), returning the result along with the new borrow.
pub const fn saturating_sub(&self, rhs: Limb) -> Limb
pub const fn saturating_sub(&self, rhs: Limb) -> Limb
Perform saturating subtraction.
pub const fn wrapping_sub(&self, rhs: Limb) -> Limb
pub const fn wrapping_sub(&self, rhs: Limb) -> Limb
Perform wrapping subtraction, discarding underflow and wrapping around the boundary of the type.
Trait Implementations§
§impl CheckedAdd for Limb
impl CheckedAdd for Limb
§impl CheckedMul for Limb
impl CheckedMul for Limb
§impl CheckedSub for Limb
impl CheckedSub for Limb
§impl ConditionallySelectable for Limb
impl ConditionallySelectable for Limb
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
self and other if choice == 1; otherwise,
reassign both unto themselves. Read more§impl ConstantTimeEq for Limb
impl ConstantTimeEq for Limb
§impl ConstantTimeGreater for Limb
impl ConstantTimeGreater for Limb
§impl ConstantTimeLess for Limb
impl ConstantTimeLess for Limb
§impl Encoding for Limb
impl Encoding for Limb
§fn to_be_bytes(&self) -> <Limb as Encoding>::Repr
fn to_be_bytes(&self) -> <Limb as Encoding>::Repr
§fn to_le_bytes(&self) -> <Limb as Encoding>::Repr
fn to_le_bytes(&self) -> <Limb as Encoding>::Repr
§impl Ord for Limb
impl Ord for Limb
§impl PartialOrd for Limb
impl PartialOrd for Limb
§impl Random for Limb
impl Random for Limb
§fn random(rng: &mut impl CryptoRngCore) -> Limb
fn random(rng: &mut impl CryptoRngCore) -> Limb
§impl RandomMod for Limb
impl RandomMod for Limb
§fn random_mod(rng: &mut impl CryptoRngCore, modulus: &NonZero<Limb>) -> Limb
fn random_mod(rng: &mut impl CryptoRngCore, modulus: &NonZero<Limb>) -> Limb
modulus. Read more§impl ShlAssign<usize> for Limb
impl ShlAssign<usize> for Limb
§fn shl_assign(&mut self, other: usize)
fn shl_assign(&mut self, other: usize)
<<= operation. Read more§impl ShrAssign<usize> for Limb
impl ShrAssign<usize> for Limb
§fn shr_assign(&mut self, other: usize)
fn shr_assign(&mut self, other: usize)
>>= operation. Read moreimpl Copy for Limb
impl DefaultIsZeroes for Limb
zeroize only.impl Eq for Limb
Auto Trait Implementations§
impl Freeze for Limb
impl RefUnwindSafe for Limb
impl Send for Limb
impl Sync for Limb
impl Unpin for Limb
impl UnwindSafe for Limb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more