Struct crypto_bigint::Limb
source · #[repr(transparent)]pub struct Limb(pub Word);
Expand description
Big integers are represented as an array of smaller CPU word-size integers called “limbs”.
Tuple Fields§
§0: Word
Implementations§
source§impl Limb
impl Limb
sourcepub 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.
sourcepub const fn saturating_add(&self, rhs: Self) -> Self
pub const fn saturating_add(&self, rhs: Self) -> Self
Perform saturating addition.
sourcepub const fn wrapping_add(&self, rhs: Self) -> Self
pub const fn wrapping_add(&self, rhs: Self) -> Self
Perform wrapping addition, discarding overflow.
source§impl Limb
impl Limb
sourcepub 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.
sourcepub 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.
sourcepub 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.
source§impl Limb
impl Limb
sourcepub fn cmp_vartime(&self, other: &Self) -> Ordering
pub fn cmp_vartime(&self, other: &Self) -> 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.
sourcepub const fn eq_vartime(&self, other: &Self) -> bool
pub const fn eq_vartime(&self, other: &Self) -> bool
Performs an equality check in variable-time.
source§impl Limb
impl Limb
sourcepub 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.
sourcepub const fn saturating_mul(&self, rhs: Self) -> Self
pub const fn saturating_mul(&self, rhs: Self) -> Self
Perform saturating multiplication.
sourcepub const fn wrapping_mul(&self, rhs: Self) -> Self
pub const fn wrapping_mul(&self, rhs: Self) -> Self
Perform wrapping multiplication, discarding overflow.
source§impl Limb
impl Limb
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Perform wrapping negation.
source§impl Limb
impl Limb
sourcepub 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.
sourcepub const fn saturating_sub(&self, rhs: Self) -> Self
pub const fn saturating_sub(&self, rhs: Self) -> Self
Perform saturating subtraction.
sourcepub const fn wrapping_sub(&self, rhs: Self) -> Self
pub const fn wrapping_sub(&self, rhs: Self) -> Self
Perform wrapping subtraction, discarding underflow and wrapping around the boundary of the type.
Trait Implementations§
source§impl CheckedAdd for Limb
impl CheckedAdd for Limb
source§impl CheckedMul for Limb
impl CheckedMul for Limb
source§impl CheckedSub for Limb
impl CheckedSub for Limb
source§impl ConditionallySelectable for Limb
impl ConditionallySelectable for Limb
source§impl ConstantTimeEq for Limb
impl ConstantTimeEq for Limb
source§impl ConstantTimeGreater for Limb
impl ConstantTimeGreater for Limb
source§impl ConstantTimeLess for Limb
impl ConstantTimeLess for Limb
source§impl<'de> Deserialize<'de> for Limb
Available on crate feature serde
only.
impl<'de> Deserialize<'de> for Limb
serde
only.source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
source§impl Encoding for Limb
impl Encoding for Limb
source§fn from_be_bytes(bytes: Self::Repr) -> Self
fn from_be_bytes(bytes: Self::Repr) -> Self
source§fn from_le_bytes(bytes: Self::Repr) -> Self
fn from_le_bytes(bytes: Self::Repr) -> Self
source§fn to_be_bytes(&self) -> Self::Repr
fn to_be_bytes(&self) -> Self::Repr
source§fn to_le_bytes(&self) -> Self::Repr
fn to_le_bytes(&self) -> Self::Repr
source§impl Ord for Limb
impl Ord for Limb
source§impl PartialEq for Limb
impl PartialEq for Limb
source§impl PartialOrd for Limb
impl PartialOrd for Limb
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Random for Limb
Available on crate feature rand_core
only.
impl Random for Limb
rand_core
only.source§fn random(rng: &mut impl CryptoRngCore) -> Self
fn random(rng: &mut impl CryptoRngCore) -> Self
source§impl RandomMod for Limb
Available on crate feature rand_core
only.
impl RandomMod for Limb
rand_core
only.source§fn random_mod(rng: &mut impl CryptoRngCore, modulus: &NonZero<Self>) -> Self
fn random_mod(rng: &mut impl CryptoRngCore, modulus: &NonZero<Self>) -> Self
modulus
. Read moresource§impl ShlAssign<usize> for Limb
impl ShlAssign<usize> for Limb
source§fn shl_assign(&mut self, other: usize)
fn shl_assign(&mut self, other: usize)
<<=
operation. Read moresource§impl ShlAssign for Limb
impl ShlAssign for Limb
source§fn shl_assign(&mut self, other: Self)
fn shl_assign(&mut self, other: Self)
<<=
operation. Read moresource§impl ShrAssign<usize> for Limb
impl ShrAssign<usize> for Limb
source§fn shr_assign(&mut self, other: usize)
fn shr_assign(&mut self, other: usize)
>>=
operation. Read moresource§impl ShrAssign for Limb
impl ShrAssign for Limb
source§fn shr_assign(&mut self, other: Self)
fn shr_assign(&mut self, other: Self)
>>=
operation. Read moreimpl Copy for Limb
impl DefaultIsZeroes for Limb
zeroize
only.