#[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§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
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 moreSource§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 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 PartialOrd for Limb
impl PartialOrd for Limb
Source§impl Random for Limb
impl Random for Limb
Source§fn random(rng: &mut impl CryptoRngCore) -> Self
fn random(rng: &mut impl CryptoRngCore) -> Self
Source§impl RandomMod for Limb
impl RandomMod for Limb
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
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,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)