Skip to main content

Uint

Struct Uint 

Source
pub struct Uint<const BITS: usize, const LIMBS: usize> {
    pub limbs: [u64; LIMBS],
}

Fields§

§limbs: [u64; LIMBS]

Implementations§

Source§

impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>

Source

pub const ZERO: Self

Source

pub const ONE: Self

Source

pub const MAX: Self

Source

pub const fn from_limbs(limbs: [u64; LIMBS]) -> Self

Source

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

Source

pub fn from_be_slice(bytes: &[u8]) -> Self

Source

pub fn from_le_slice(bytes: &[u8]) -> Self

Source

pub fn to_be_bytes(&self) -> Vec<u8>

Source

pub fn to_le_bytes(&self) -> Vec<u8>

Source

pub fn to_be_bytes_fixed<const N: usize>(&self) -> [u8; N]

Source

pub fn to_le_bytes_fixed<const N: usize>(&self) -> [u8; N]

Source

pub fn bit(&self, index: usize) -> bool

Source

pub fn is_zero(&self) -> bool

Source

pub fn is_odd(&self) -> bool

Source

pub fn ct_ge(&self, rhs: &Self) -> bool

Source

pub fn ct_eq(&self, rhs: &Self) -> bool

Source

pub fn ct_select(a: &Self, b: &Self, choice: bool) -> Self

Source

pub fn add_raw(&self, rhs: &Self) -> (Self, u64)

Source

pub fn sub_raw(&self, rhs: &Self) -> (Self, u64)

Source

pub fn add_mod(&self, rhs: &Self, modulus: &Self) -> Self

Source

pub fn sub_mod(&self, rhs: &Self, modulus: &Self) -> Self

Source

pub fn double_mod(&self, modulus: &Self) -> Self

Source

pub fn mul_mod(&self, rhs: &Self, modulus: &Self) -> Self

Source

pub fn reduce_wide_barrett<const MU_LIMBS: usize>( product: &[u64; 64], modulus: &Self, mu: &[u64; MU_LIMBS], ) -> Self

Barrett reduction of a 2*LIMBS-wide product modulo modulus.

mu must equal floor(2^(2*LIMBS*64) / modulus) and have LIMBS+1 limbs.

Source

pub fn mul_mod_barrett<const MU_LIMBS: usize>( &self, rhs: &Self, modulus: &Self, mu: &[u64; MU_LIMBS], ) -> Self

Modular multiplication using Barrett reduction.

mu must equal floor(2^(2*LIMBS*64) / modulus) and have LIMBS+1 limbs.

Source

pub fn add_word(&self, word: u64) -> (Self, u64)

Source

pub fn sub_word(&self, word: u64) -> (Self, u64)

Source

pub fn mul_word(&self, word: u64) -> (Self, u64)

Source

pub fn div_rem_word(&self, word: u64) -> (Self, u64)

Source

pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, Error>

Source

pub fn to_string_radix(&self, radix: u32) -> String

Trait Implementations§

Source§

impl<const BITS: usize, const LIMBS: usize> Add for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<i8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<i16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<i32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<i64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<i128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<u8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<u16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<u32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<u64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<u128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Clone for Uint<BITS, LIMBS>

Source§

fn clone(&self) -> Uint<BITS, LIMBS>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Copy for Uint<BITS, LIMBS>

Source§

impl<const BITS: usize, const LIMBS: usize> Debug for Uint<BITS, LIMBS>

Source§

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

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

impl<const BITS: usize, const LIMBS: usize> Display for Uint<BITS, LIMBS>

Available on crate feature alloc only.
Source§

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

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

impl<const BITS: usize, const LIMBS: usize> Div<i8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i8) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<i16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i16) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<i32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i32) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<i64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i64) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<i128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i128) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<u8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u8) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<u16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u16) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<u32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u32) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<u64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u64) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<u128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u128) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Eq for Uint<BITS, LIMBS>

Source§

impl<const BITS: usize, const LIMBS: usize> LowerHex for Uint<BITS, LIMBS>

Source§

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

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

impl<const BITS: usize, const LIMBS: usize> Mul for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<i8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<i16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<i32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<i64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<i128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<u8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<u16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<u32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<u64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<u128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> PartialEq for Uint<BITS, LIMBS>

Source§

fn eq(&self, other: &Uint<BITS, LIMBS>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<const BITS: usize, const LIMBS: usize> Rem<i8> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i8) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<i16> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i16) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<i32> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i32) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<i64> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i64) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<i128> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i128) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<u8> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u8) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<u16> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u16) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<u32> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u32) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<u64> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u64) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<u128> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u128) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> StructuralPartialEq for Uint<BITS, LIMBS>

Source§

impl<const BITS: usize, const LIMBS: usize> Sub for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<i8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<i16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<i32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<i64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<i128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<u8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<u16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<u32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<u64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<u128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> UpperHex for Uint<BITS, LIMBS>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const BITS: usize, const LIMBS: usize> Freeze for Uint<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> RefUnwindSafe for Uint<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> Send for Uint<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> Sync for Uint<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> Unpin for Uint<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> UnsafeUnpin for Uint<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> UnwindSafe for Uint<BITS, LIMBS>

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> 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> 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, 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.