Skip to main content

Limb

Struct Limb 

Source
#[repr(transparent)]
pub struct Limb(pub Word);
Expand description

Big integers are represented as an array/vector of smaller CPU word-size integers called “limbs”.

The Limb type uses a 32-bit or 64-bit saturated representation, depending on the target. All bits of an inner Word are used to represent larger big integer types.

Tuple Fields§

§0: Word

Implementations§

Source§

impl Limb

Source

pub const fn adc(self, rhs: Limb, carry: Limb) -> (Limb, Limb)

👎Deprecated since 0.7.0: please use carrying_add instead

Computes self + rhs + carry, returning the result along with the new carry.

Source

pub const fn carrying_add(self, rhs: Limb, carry: Limb) -> (Limb, Limb)

Computes self + rhs + carry, returning the result along with the new carry.

Source

pub const fn overflowing_add(self, rhs: Limb) -> (Limb, Limb)

Computes self + rhs, returning the result along with the carry.

Source

pub const fn saturating_add(&self, rhs: Self) -> Self

Perform saturating addition.

Source

pub const fn wrapping_add(&self, rhs: Self) -> Self

Perform wrapping addition, discarding overflow.

Source§

impl Limb

Source

pub const fn bitand(self, rhs: Self) -> Self

Calculates a & b.

Source§

impl Limb

Source

pub const fn not(self) -> Self

Calculates !a.

Source§

impl Limb

Source

pub const fn bitor(self, rhs: Self) -> Self

Calculates a | b.

Source§

impl Limb

Source

pub const fn bitxor(self, rhs: Self) -> Self

Calculates a ^ b.

Source§

impl Limb

Source

pub const fn bit(self, index: u32) -> Choice

Get the value of the bit at position index, as a truthy or falsy Choice. Returns the falsy value for indices out of range.

Source

pub const fn bit_vartime(self, index: u32) -> bool

Returns true if the bit at position index is set, false for an unset bit or for indices out of range.

§Remarks

This operation is variable time with respect to index only.

Source

pub const fn bits(self) -> u32

Calculate the number of bits needed to represent this number.

Source

pub const fn leading_zeros(self) -> u32

Calculate the number of leading zeros in the binary representation of this number.

Source

pub const fn trailing_zeros(self) -> u32

Calculate the number of trailing zeros in the binary representation of this number.

Source

pub const fn trailing_ones(self) -> u32

Calculate the number of trailing ones the binary representation of this number.

Source

pub const fn restrict_bits(self, len: u32) -> Self

Clear bits at or above the given bit position.

Source§

impl Limb

Source

pub fn is_odd(self) -> Choice

Is this limb an odd number?

Source

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.

Source

pub const fn eq_vartime(self, other: Self) -> bool

Performs an equality check in variable-time.

Source§

impl Limb

Source

pub const fn div_rem(self, rhs: NonZero<Self>) -> (Limb, Limb)

Computes self / rhs, returning the quotient and remainder.

Source

pub const fn div_rem_with_reciprocal(self, recip: &Reciprocal) -> (Limb, Limb)

Computes self / rhs where recip is a Reciprocal created from a non-zero Limb rhs. Returns the quotient and remainder.

Source

pub const fn checked_div(self, rhs: Self) -> CtOption<Limb>

Computes the checked division self / rhs, returning the quotient if the divisor is non-zero, and CtOption::none() otherwise.

Source

pub const fn checked_rem(self, rhs: Self) -> CtOption<Limb>

Computes the checked division self / rhs, returning the remainder if the divisor is non-zero, and CtOption::none() otherwise.

Source§

impl Limb

Source

pub const fn from_u8(n: u8) -> Self

Create a Limb from a u8 integer (const-friendly)

Source

pub const fn from_u16(n: u16) -> Self

Create a Limb from a u16 integer (const-friendly)

Source

pub const fn from_u32(n: u32) -> Self

Create a Limb from a u32 integer (const-friendly)

Source

pub const fn from_u64(n: u64) -> Self

Create a Limb from a u64 integer (const-friendly)

Source§

impl Limb

Source

pub const fn mac(self, b: Limb, c: Limb, carry: Limb) -> (Limb, Limb)

👎Deprecated since 0.7.0: please use carrying_mul_add instead (ordering of arguments changes)

Computes self + (b * c) + carry, returning the result along with the new carry.

Source

pub const fn carrying_mul_add( self, rhs: Limb, addend: Limb, carry: Limb, ) -> (Limb, Limb)

Computes (self * rhs) + addend + carry, returning the result along with the new carry.

Source

pub const fn saturating_mul(self, rhs: Self) -> Self

Perform saturating multiplication.

Source

pub const fn wrapping_mul(self, rhs: Self) -> Self

Perform wrapping multiplication, discarding overflow.

Source§

impl Limb

Source

pub const fn wrapping_neg(self) -> Self

Perform wrapping negation.

Source§

impl Limb

Source

pub const fn shl(self, shift: u32) -> Self

Computes self << shift.

§Panics
  • if shift overflows Limb::BITS.
Source

pub const fn overflowing_shl(self, shift: u32) -> CtOption<Self>

Computes self << shift, returning CtOption::none() if the shift exceeds the capacity.

Source

pub const fn overflowing_shl_vartime(self, shift: u32) -> Option<Self>

Computes self << shift, returning None if the shift exceeds the capacity.

This method is variable time in shift only.

Source

pub const fn unbounded_shl(self, shift: u32) -> Self

Computes self << shift, returning Limb::ZERO if the shift exceeds the capacity.

Source

pub const fn unbounded_shl_vartime(self, shift: u32) -> Self

Computes self << shift, returning Limb::ZERO if the shift exceeds the capacity.

This method is variable time in shift only.

Source

pub const fn wrapping_shl(self, shift: u32) -> Self

Computes self << shift in a panic-free manner, masking off bits of shift which would cause the shift to exceed the type’s width.

Source§

impl Limb

Source

pub const fn shr(self, shift: u32) -> Self

Computes self >> shift.

§Panics
  • if shift overflows Limb::BITS.
Source

pub const fn overflowing_shr(self, shift: u32) -> CtOption<Self>

Computes self >> shift, returning CtOption::none() if the shift exceeds the capacity.

Source

pub const fn overflowing_shr_vartime(self, shift: u32) -> Option<Self>

Computes self >> shift, returning None if the shift exceeds the capacity.

This method is variable time in shift only.

Source

pub const fn unbounded_shr(self, shift: u32) -> Self

Computes self >> shift, returning Limb::ZERO if the shift exceeds the capacity.

Source

pub const fn unbounded_shr_vartime(self, shift: u32) -> Self

Computes self >> shift, returning Limb::ZERO if the shift exceeds the capacity.

This method is variable time in shift only.

Source

pub const fn wrapping_shr(self, shift: u32) -> Self

Computes self >> shift in a panic-free manner, masking off bits of shift which would cause the shift to exceed the type’s width.

Source§

impl Limb

Source

pub const fn sbb(self, rhs: Limb, borrow: Limb) -> (Limb, Limb)

👎Deprecated since 0.7.0: please use borrowing_sub instead

Computes self - (rhs + borrow), returning the result along with the new borrow.

Source

pub const fn borrowing_sub(self, rhs: Limb, borrow: Limb) -> (Limb, Limb)

Computes self - (rhs + borrow), returning the result along with the new borrow.

Source

pub const fn saturating_sub(&self, rhs: Self) -> Self

Perform saturating subtraction.

Source

pub const fn wrapping_sub(&self, rhs: Self) -> Self

Perform wrapping subtraction, discarding underflow and wrapping around the boundary of the type.

Source§

impl Limb

Source

pub const ZERO: Self

The value 0.

Source

pub const ONE: Self

The value 1.

Source

pub const MAX: Self

Maximum value this Limb can express.

Source

pub const BITS: u32 = 64

Size of the inner integer in bits.

Source

pub const BYTES: usize = 8

Size of the inner integer in bytes.

Source

pub const LOG2_BITS: u32

floor(log2(Self::BITS)).

Source

pub const fn is_zero(&self) -> Choice

Is this limb equal to Limb::ZERO?

Source

pub const fn to_nz(self) -> CtOption<NonZero<Self>>

Convert to a NonZero<Limb>.

Returns some if the original value is non-zero, and false otherwise.

Source

pub const fn lsb_to_choice(self) -> Choice

Convert the least significant bit of this Limb to a Choice.

Source

pub const fn array_as_words<const N: usize>(array: &[Self; N]) -> &[Word; N]

Convert a shared reference to an array of Limbs into a shared reference to their inner Words for each limb.

Source

pub const fn array_as_mut_words<const N: usize>( array: &mut [Self; N], ) -> &mut [Word; N]

Convert a mutable reference to an array of Limbs into a mutable reference to their inner Words for each limb.

Source

pub const fn slice_as_words(slice: &[Self]) -> &[Word]

Convert a shared reference to an array of Limbs into a shared reference to their inner Words for each limb.

Source

pub const fn slice_as_mut_words(slice: &mut [Self]) -> &mut [Word]

Convert a mutable reference to an array of Limbs into a mutable reference to their inner Words for each limb.

Trait Implementations§

Source§

impl Add<&Limb> for Limb

Source§

type Output = Limb

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Self) -> Self

Performs the + operation. Read more
Source§

impl Add for Limb

Source§

type Output = Limb

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl AddAssign<&Limb> for Limb

Source§

fn add_assign(&mut self, other: &Self)

Performs the += operation. Read more
Source§

impl AddAssign for Limb

Source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
Source§

impl AddMod for Limb

Source§

type Output = Limb

Output type.
Source§

fn add_mod(&self, rhs: &Self, p: &NonZero<Self>) -> Self::Output

Compute self + rhs mod p. Read more
Source§

impl AsMut<[Limb]> for Limb

Source§

fn as_mut(&mut self) -> &mut [Limb]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsMut<UintRef> for Limb

Source§

fn as_mut(&mut self) -> &mut UintRef

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[Limb]> for Limb

Source§

fn as_ref(&self) -> &[Limb]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<UintRef> for Limb

Source§

fn as_ref(&self) -> &UintRef

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Binary for Limb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl BitAnd<&Limb> for Limb

Source§

type Output = Limb

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAnd for Limb

Source§

type Output = Limb

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAndAssign<&Limb> for Limb

Source§

fn bitand_assign(&mut self, rhs: &Limb)

Performs the &= operation. Read more
Source§

impl BitAndAssign for Limb

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOps for Limb

Source§

fn bit(&self, index: u32) -> Choice

Get the value of the bit at position index, as a truthy or falsy Choice. Returns the falsy value for indices out of range.
Source§

fn bit_vartime(&self, index: u32) -> bool

Returns true if the bit at position index is set, false otherwise. Read more
Source§

fn bits_precision(&self) -> u32

Precision of this integer in bits.
Source§

fn bits(&self) -> u32

Calculate the number of bits required to represent a given number.
Source§

fn bytes_precision(&self) -> usize

Precision of this integer in bytes.
Source§

fn leading_zeros(&self) -> u32

Calculate the number of leading zeros in the binary representation of this number.
Source§

fn log2_bits(&self) -> u32

floor(log2(self.bits_precision())).
Source§

fn set_bit(&mut self, index: u32, bit_value: Choice)

Sets the bit at index to 0 or 1 depending on the value of bit_value.
Source§

fn set_bit_vartime(&mut self, index: u32, bit_value: bool)

Sets the bit at index to 0 or 1 depending on the value of bit_value, variable time in self.
Source§

fn trailing_ones(&self) -> u32

Calculate the number of trailing ones in the binary representation of this number.
Source§

fn trailing_zeros(&self) -> u32

Calculate the number of trailing zeros in the binary representation of this number.
Source§

fn bits_vartime(&self) -> u32

Calculate the number of bits required to represent a given number in variable-time with respect to self.
Source§

fn leading_zeros_vartime(&self) -> u32

Calculate the number of leading zeros in the binary representation of this number.
Source§

fn trailing_zeros_vartime(&self) -> u32

Calculate the number of trailing zeros in the binary representation of this number in variable-time with respect to self.
Source§

fn trailing_ones_vartime(&self) -> u32

Calculate the number of trailing ones in the binary representation of this number, variable time in self.
Source§

impl BitOr<&Limb> for Limb

Source§

type Output = Limb

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOr for Limb

Source§

type Output = Limb

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOrAssign<&Limb> for Limb

Source§

fn bitor_assign(&mut self, other: &Self)

Performs the |= operation. Read more
Source§

impl BitOrAssign for Limb

Source§

fn bitor_assign(&mut self, other: Self)

Performs the |= operation. Read more
Source§

impl BitXor<&Limb> for Limb

Source§

type Output = Limb

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXor for Limb

Source§

type Output = Limb

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXorAssign<&Limb> for Limb

Source§

fn bitxor_assign(&mut self, rhs: &Self)

Performs the ^= operation. Read more
Source§

impl BitXorAssign for Limb

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Bounded for Limb

Source§

const BITS: u32 = Self::BITS

Size of this integer in bits.
Source§

const BYTES: usize = Self::BYTES

Size of this integer in bytes.
Source§

impl CheckedAdd for Limb

Source§

fn checked_add(&self, rhs: &Self) -> CtOption<Self>

Perform checked addition, returning a CtOption which is_some only if the operation did not overflow.
Source§

impl CheckedDiv for Limb

Source§

fn checked_div(&self, rhs: &Self) -> CtOption<Self>

Perform checked division, returning a CtOption which is_some only if the divisor is non-zero.
Source§

impl CheckedMul for Limb

Source§

fn checked_mul(&self, rhs: &Self) -> CtOption<Self>

Perform checked multiplication, returning a CtOption which is_some only if the operation did not overflow.
Source§

impl CheckedSquareRoot for Limb

Source§

type Output = Limb

Output of the square root operation.
Source§

fn checked_sqrt(&self) -> CtOption<Self::Output>

Computes sqrt(self), returning none if no root exists.
Source§

fn checked_sqrt_vartime(&self) -> Option<Self::Output>

Computes sqrt(self), returning none if no root exists. Read more
Source§

impl CheckedSub for Limb

Source§

fn checked_sub(&self, rhs: &Self) -> CtOption<Self>

Perform checked subtraction, returning a CtOption which is_some only if the operation did not underflow.
Source§

impl Clone for Limb

Source§

fn clone(&self) -> Limb

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConditionallySelectable for Limb

Available on crate feature subtle only.
Source§

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

Select a or b according to choice. Read more
Source§

fn conditional_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign other to self, according to choice. Read more
Source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
Source§

impl ConstOne for Limb

Source§

const ONE: Self = Self::ONE

The multiplicative identity element of Self, 1.
Source§

impl ConstZero for Limb

Source§

const ZERO: Self = Self::ZERO

The additive identity element of Self, 0.
Source§

impl ConstantTimeEq for Limb

Available on crate feature subtle only.
Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
Source§

impl ConstantTimeGreater for Limb

Available on crate feature subtle only.
Source§

fn ct_gt(&self, other: &Self) -> Choice

Determine whether self > other. Read more
Source§

impl ConstantTimeLess for Limb

Available on crate feature subtle only.
Source§

fn ct_lt(&self, other: &Self) -> Choice

Determine whether self < other. Read more
Source§

impl Constants for Limb

Source§

const MAX: Self = Self::MAX

Maximum value this integer can express.
Source§

impl CtAssign for Limb

Source§

fn ct_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign src to self if choice is Choice::TRUE.
Source§

impl CtAssignSlice for Limb

Source§

fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice)

Conditionally assign src to dst if choice is Choice::TRUE, or leave it unchanged for Choice::FALSE.
Source§

impl CtEq for Limb

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if self is equal to other in constant-time.
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if self is NOT equal to other in constant-time.
Source§

impl CtEqSlice for Limb

Source§

fn ct_eq_slice(a: &[Self], b: &[Self]) -> Choice

Determine if a is equal to b in constant-time.
Source§

fn ct_ne_slice(a: &[Self], b: &[Self]) -> Choice

Determine if a is NOT equal to b in constant-time.
Source§

impl CtGt for Limb

Source§

fn ct_gt(&self, other: &Self) -> Choice

Compute whether self > other in constant time.
Source§

impl CtLt for Limb

Source§

fn ct_lt(&self, other: &Self) -> Choice

Compute whether self < other in constant time.
Source§

impl CtSelect for Limb

Source§

fn ct_select(&self, other: &Self, choice: Choice) -> Self

Select between self and other based on choice, returning a copy of the value. Read more
Source§

fn ct_swap(&mut self, other: &mut Self, choice: Choice)

Conditionally swap self and other if choice is Choice::TRUE.
Source§

impl Debug for Limb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Limb

Source§

fn default() -> Limb

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Limb

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Limb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Div<&Limb> for &Limb

Source§

type Output = Limb

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Limb) -> Limb

Performs the / operation. Read more
Source§

impl Div<&Limb> for Limb

Source§

type Output = Limb

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Limb) -> Self

Performs the / operation. Read more
Source§

impl Div<&NonZero<Limb>> for &Limb

Source§

type Output = Limb

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NonZero<Limb>) -> Limb

Performs the / operation. Read more
Source§

impl Div<&NonZero<Limb>> for Limb

Source§

type Output = Limb

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NonZero<Limb>) -> Self

Performs the / operation. Read more
Source§

impl Div<Limb> for &Limb

Source§

type Output = Limb

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Limb) -> Limb

Performs the / operation. Read more
Source§

impl Div<NonZero<Limb>> for &Limb

Source§

type Output = Limb

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NonZero<Limb>) -> Limb

Performs the / operation. Read more
Source§

impl Div<NonZero<Limb>> for Limb

Source§

type Output = Limb

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NonZero<Limb>) -> Self

Performs the / operation. Read more
Source§

impl Div for Limb

Source§

type Output = Limb

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Limb) -> Self

Performs the / operation. Read more
Source§

impl DivAssign<&Limb> for Limb

Source§

fn div_assign(&mut self, rhs: &Limb)

Performs the /= operation. Read more
Source§

impl DivAssign<&NonZero<Limb>> for Limb

Source§

fn div_assign(&mut self, rhs: &NonZero<Limb>)

Performs the /= operation. Read more
Source§

impl DivAssign<NonZero<Limb>> for Limb

Source§

fn div_assign(&mut self, rhs: NonZero<Limb>)

Performs the /= operation. Read more
Source§

impl DivAssign for Limb

Source§

fn div_assign(&mut self, rhs: Limb)

Performs the /= operation. Read more
Source§

impl DivRemLimb for Limb

Source§

fn div_rem_limb(&self, rhs: NonZero<Limb>) -> (Self, Limb)

Computes self / rhs using a pre-made reciprocal, returns the quotient (q) and remainder (r).
Source§

fn div_rem_limb_with_reciprocal(&self, rhs: &Reciprocal) -> (Self, Limb)

Computes self / rhs, returns the quotient (q) and remainder (r).
Source§

impl Encoding for Limb

Source§

type Repr = [u8; 8]

Byte array representation.
Source§

fn from_be_bytes(bytes: Self::Repr) -> Self

Decode from big endian bytes.
Source§

fn from_le_bytes(bytes: Self::Repr) -> Self

Decode from little endian bytes.
Source§

fn to_be_bytes(&self) -> Self::Repr

Encode to big endian bytes.
Source§

fn to_le_bytes(&self) -> Self::Repr

Encode to little endian bytes.
Source§

impl FloorSquareRoot for Limb

Source§

fn floor_sqrt(&self) -> Self::Output

Computes floor(sqrt(self)).
Source§

fn floor_sqrt_vartime(&self) -> Self::Output

Computes floor(sqrt(self)). Read more
Source§

impl From<Limb> for BoxedUint

Available on crate feature alloc only.
Source§

fn from(limb: Limb) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<Limb> for Uint<LIMBS>

Source§

fn from(limb: Limb) -> Self

Converts to this type from the input type.
Source§

impl From<Limb> for WideWord

Source§

fn from(limb: Limb) -> WideWord

Converts to this type from the input type.
Source§

impl From<Limb> for Word

Source§

fn from(limb: Limb) -> Word

Converts to this type from the input type.
Source§

impl From<u16> for Limb

Source§

fn from(n: u16) -> Limb

Converts to this type from the input type.
Source§

impl From<u32> for Limb

Source§

fn from(n: u32) -> Limb

Converts to this type from the input type.
Source§

impl From<u64> for Limb

Source§

fn from(n: u64) -> Limb

Converts to this type from the input type.
Source§

impl From<u8> for Limb

Source§

fn from(n: u8) -> Limb

Converts to this type from the input type.
Source§

impl Hash for Limb

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Integer for Limb

Source§

fn as_limbs(&self) -> &[Limb]

Borrow the raw limbs used to represent this integer.
Source§

fn as_mut_limbs(&mut self) -> &mut [Limb]

Mutably borrow the raw limbs used to represent this integer.
Source§

fn nlimbs(&self) -> usize

Number of limbs in this integer.
Source§

fn is_even(&self) -> Choice

Is this integer value an even number? Read more
Source§

fn is_odd(&self) -> Choice

Is this integer value an odd number? Read more
Source§

impl LowerHex for Limb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Mul<&Limb> for &Limb

Source§

type Output = Limb

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Limb) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&Limb> for Limb

Source§

type Output = Limb

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Limb) -> Self

Performs the * operation. Read more
Source§

impl Mul<Limb> for &Limb

Source§

type Output = Limb

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Limb) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for Limb

Source§

type Output = Limb

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Limb) -> Self

Performs the * operation. Read more
Source§

impl MulAssign<&Limb> for Limb

Source§

fn mul_assign(&mut self, other: &Self)

Performs the *= operation. Read more
Source§

impl MulAssign for Limb

Source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
Source§

impl MulMod for Limb

Source§

type Output = Limb

Output type.
Source§

fn mul_mod(&self, rhs: &Self, p: &NonZero<Self>) -> Self::Output

Compute self * rhs mod p.
Source§

impl NegMod for Limb

Source§

type Output = Limb

Output type.
Source§

fn neg_mod(&self, p: &NonZero<Self>) -> Self::Output

Compute -self mod p.
Source§

impl Not for Limb

Source§

type Output = Limb

The resulting type after applying the ! operator.
Source§

fn not(self) -> <Self as Not>::Output

Performs the unary ! operation. Read more
Source§

impl Octal for Limb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl One for Limb

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> Choice

Determine if this value is equal to 1. Read more
Source§

fn set_one(&mut self)

Set self to its multiplicative identity, i.e. Self::one.
Source§

fn one_like(_other: &Self) -> Self

Return the value 0 with the same precision as other.
Source§

impl One for Limb

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn is_one(&self) -> bool

Returns true if self is equal to the multiplicative identity. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

impl Ord for Limb

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Limb

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Limb

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Random for Limb

Available on crate feature rand_core only.
Source§

fn try_random_from_rng<R: TryRng + ?Sized>( rng: &mut R, ) -> Result<Self, R::Error>

Generate a random value. Read more
Source§

fn random_from_rng<R: Rng + ?Sized>(rng: &mut R) -> Self

Generate a random value. Read more
Source§

fn try_random() -> Result<Self, Error>

Available on crate feature getrandom only.
Randomly generate a value of this type using the system’s ambient cryptographically secure random number generator. Read more
Source§

fn random() -> Self

Available on crate feature getrandom only.
Randomly generate a value of this type using the system’s ambient cryptographically secure random number generator. Read more
Source§

impl RandomMod for Limb

Available on crate feature rand_core only.
Source§

fn try_random_mod_vartime<R: TryRng + ?Sized>( rng: &mut R, modulus: &NonZero<Self>, ) -> Result<Self, R::Error>

Generate a random number which is less than a given modulus. Read more
Source§

fn random_mod_vartime<R: Rng + ?Sized>( rng: &mut R, modulus: &NonZero<Self>, ) -> Self

Generate a random number which is less than a given modulus. Read more
Source§

fn random_mod<R: Rng + ?Sized>(rng: &mut R, modulus: &NonZero<Self>) -> Self

👎Deprecated since 0.7.0: please use random_mod_vartime instead
Generate a random number which is less than a given modulus. Read more
Source§

fn try_random_mod<R: TryRng + ?Sized>( rng: &mut R, modulus: &NonZero<Self>, ) -> Result<Self, R::Error>

👎Deprecated since 0.7.0: please use try_random_mod_vartime instead
Generate a random number which is less than a given modulus. Read more
Source§

impl Rem<&Limb> for &Limb

Source§

type Output = Limb

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &Limb) -> Limb

Performs the % operation. Read more
Source§

impl Rem<&Limb> for Limb

Source§

type Output = Limb

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &Limb) -> Self

Performs the % operation. Read more
Source§

impl Rem<&NonZero<Limb>> for &Limb

Source§

type Output = Limb

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &NonZero<Limb>) -> Limb

Performs the % operation. Read more
Source§

impl Rem<&NonZero<Limb>> for Limb

Source§

type Output = Limb

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &NonZero<Limb>) -> Self

Performs the % operation. Read more
Source§

impl Rem<Limb> for &Limb

Source§

type Output = Limb

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Limb) -> Limb

Performs the % operation. Read more
Source§

impl Rem<NonZero<Limb>> for &Limb

Source§

type Output = Limb

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: NonZero<Limb>) -> Limb

Performs the % operation. Read more
Source§

impl Rem<NonZero<Limb>> for Limb

Source§

type Output = Limb

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: NonZero<Limb>) -> Self

Performs the % operation. Read more
Source§

impl Rem for Limb

Source§

type Output = Limb

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Limb) -> Self

Performs the % operation. Read more
Source§

impl RemAssign<&Limb> for Limb

Source§

fn rem_assign(&mut self, rhs: &Limb)

Performs the %= operation. Read more
Source§

impl RemAssign<&NonZero<Limb>> for Limb

Source§

fn rem_assign(&mut self, rhs: &NonZero<Limb>)

Performs the %= operation. Read more
Source§

impl RemAssign<NonZero<Limb>> for Limb

Source§

fn rem_assign(&mut self, rhs: NonZero<Limb>)

Performs the %= operation. Read more
Source§

impl RemAssign for Limb

Source§

fn rem_assign(&mut self, rhs: Limb)

Performs the %= operation. Read more
Source§

impl RemLimb for Limb

Source§

fn rem_limb(&self, rhs: NonZero<Limb>) -> Limb

Computes self % rhs using a pre-made reciprocal.
Source§

fn rem_limb_with_reciprocal(&self, rhs: &Reciprocal) -> Limb

Computes self % rhs.
Source§

impl Serialize for Limb

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Shl<i32> for &Limb

Source§

type Output = Limb

The resulting type after applying the << operator.
Source§

fn shl(self, shift: i32) -> Limb

Performs the << operation. Read more
Source§

impl Shl<i32> for Limb

Source§

type Output = Limb

The resulting type after applying the << operator.
Source§

fn shl(self, shift: i32) -> Limb

Performs the << operation. Read more
Source§

impl Shl<u32> for &Limb

Source§

type Output = Limb

The resulting type after applying the << operator.
Source§

fn shl(self, shift: u32) -> Limb

Performs the << operation. Read more
Source§

impl Shl<u32> for Limb

Source§

type Output = Limb

The resulting type after applying the << operator.
Source§

fn shl(self, shift: u32) -> Limb

Performs the << operation. Read more
Source§

impl Shl<usize> for &Limb

Source§

type Output = Limb

The resulting type after applying the << operator.
Source§

fn shl(self, shift: usize) -> Limb

Performs the << operation. Read more
Source§

impl Shl<usize> for Limb

Source§

type Output = Limb

The resulting type after applying the << operator.
Source§

fn shl(self, shift: usize) -> Limb

Performs the << operation. Read more
Source§

impl ShlAssign<i32> for Limb

Source§

fn shl_assign(&mut self, shift: i32)

Performs the <<= operation. Read more
Source§

impl ShlAssign<u32> for Limb

Source§

fn shl_assign(&mut self, shift: u32)

Performs the <<= operation. Read more
Source§

impl ShlAssign<usize> for Limb

Source§

fn shl_assign(&mut self, shift: usize)

Performs the <<= operation. Read more
Source§

impl ShlVartime for Limb

Source§

fn overflowing_shl_vartime(&self, shift: u32) -> Option<Self>

Computes self << shift. Read more
Source§

fn unbounded_shl_vartime(&self, shift: u32) -> Self

Computes self << shift. Read more
Source§

fn wrapping_shl_vartime(&self, shift: u32) -> Self

Computes self << shift in a panic-free manner, masking off bits of shift which would cause the shift to exceed the type’s width.
Source§

impl Shr<i32> for &Limb

Source§

type Output = Limb

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: i32) -> Limb

Performs the >> operation. Read more
Source§

impl Shr<i32> for Limb

Source§

type Output = Limb

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: i32) -> Limb

Performs the >> operation. Read more
Source§

impl Shr<u32> for &Limb

Source§

type Output = Limb

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: u32) -> Limb

Performs the >> operation. Read more
Source§

impl Shr<u32> for Limb

Source§

type Output = Limb

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: u32) -> Limb

Performs the >> operation. Read more
Source§

impl Shr<usize> for &Limb

Source§

type Output = Limb

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: usize) -> Limb

Performs the >> operation. Read more
Source§

impl Shr<usize> for Limb

Source§

type Output = Limb

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: usize) -> Limb

Performs the >> operation. Read more
Source§

impl ShrAssign<i32> for Limb

Source§

fn shr_assign(&mut self, shift: i32)

Performs the >>= operation. Read more
Source§

impl ShrAssign<u32> for Limb

Source§

fn shr_assign(&mut self, shift: u32)

Performs the >>= operation. Read more
Source§

impl ShrAssign<usize> for Limb

Source§

fn shr_assign(&mut self, shift: usize)

Performs the >>= operation. Read more
Source§

impl ShrVartime for Limb

Source§

fn overflowing_shr_vartime(&self, shift: u32) -> Option<Self>

Computes self >> shift. Read more
Source§

fn unbounded_shr_vartime(&self, shift: u32) -> Self

Computes self >> shift. Read more
Source§

fn wrapping_shr_vartime(&self, shift: u32) -> Self

Computes self >> shift in a panic-free manner, masking off bits of shift which would cause the shift to exceed the type’s width.
Source§

impl SquareMod for Limb

Source§

type Output = Limb

Output type.
Source§

fn square_mod(&self, p: &NonZero<Self>) -> Self::Output

Compute self * self mod p.
Source§

impl Sub<&Limb> for Limb

Source§

type Output = Limb

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Self) -> Self

Performs the - operation. Read more
Source§

impl Sub for Limb

Source§

type Output = Limb

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl SubAssign<&Limb> for Limb

Source§

fn sub_assign(&mut self, rhs: &Self)

Performs the -= operation. Read more
Source§

impl SubAssign for Limb

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl SubMod for Limb

Source§

type Output = Limb

Output type.
Source§

fn sub_mod(&self, rhs: &Self, p: &NonZero<Self>) -> Self::Output

Compute self - rhs mod p. Read more
Source§

impl Unsigned for Limb

Source§

fn as_uint_ref(&self) -> &UintRef

Borrow the limbs of this unsigned integer as a UintRef.
Source§

fn as_mut_uint_ref(&mut self) -> &mut UintRef

Mutably borrow the limbs of this unsigned integer as a UintRef.
Source§

fn from_limb_like(limb: Limb, _other: &Self) -> Self

Returns an integer with the first limb set to limb, and the same precision as other.
Source§

impl UpperHex for Limb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl WrappingAdd for Limb

Source§

fn wrapping_add(&self, v: &Self) -> Self

Wrapping (modular) addition. Computes self + other, wrapping around at the boundary of the type.
Source§

impl WrappingMul for Limb

Source§

fn wrapping_mul(&self, v: &Self) -> Self

Wrapping (modular) multiplication. Computes self * other, wrapping around at the boundary of the type.
Source§

impl WrappingNeg for Limb

Source§

fn wrapping_neg(&self) -> Self

Wrapping (modular) negation. Computes -self, wrapping around at the boundary of the type. Read more
Source§

impl WrappingShl for Limb

Source§

fn wrapping_shl(&self, shift: u32) -> Limb

Panic-free bitwise shift-left; yields self << mask(rhs), where mask removes any high order bits of rhs that would cause the shift to exceed the bitwidth of the type. Read more
Source§

impl WrappingShr for Limb

Source§

fn wrapping_shr(&self, shift: u32) -> Limb

Panic-free bitwise shift-right; yields self >> mask(rhs), where mask removes any high order bits of rhs that would cause the shift to exceed the bitwidth of the type. Read more
Source§

impl WrappingSub for Limb

Source§

fn wrapping_sub(&self, v: &Self) -> Self

Wrapping (modular) subtraction. Computes self - other, wrapping around at the boundary of the type.
Source§

impl Zero for Limb

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0.
Source§

fn is_zero(&self) -> Choice

Determine if this value is equal to 0. Read more
Source§

fn set_zero(&mut self)

Set self to its additive identity, i.e. Self::zero.
Source§

fn zero_like(other: &Self) -> Self
where Self: Clone,

Return the value 0 with the same precision as other.
Source§

impl Zero for Limb

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl Copy for Limb

Source§

impl DefaultIsZeroes for Limb

Available on crate feature zeroize only.
Source§

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 UnsafeUnpin for Limb

§

impl UnwindSafe for Limb

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, const N: usize> CtSelectArray<N> for T

Source§

fn ct_select_array(a: &[T; N], b: &[T; N], choice: Choice) -> [T; N]

Select between a and b in constant-time based on choice.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToUnsigned for T
where T: Unsigned,

Source§

type Unsigned = T

The corresponding owned Unsigned type.
Source§

fn to_unsigned(&self) -> <T as ToUnsigned>::Unsigned

Convert from a reference into an owned instance.
Source§

fn to_unsigned_zero(&self) -> <T as ToUnsigned>::Unsigned

Convert from a reference into an owned instance representing zero.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<Z> Zeroize for Z
where Z: DefaultIsZeroes,

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,