Skip to main content

NonZeroUint

Type Alias NonZeroUint 

Source
pub type NonZeroUint<const LIMBS: usize> = NonZero<Uint<LIMBS>>;
Expand description

Non-zero unsigned integer.

Aliased Type§

#[repr(transparent)]
pub struct NonZeroUint<const LIMBS: usize>(pub(crate) Uint<LIMBS>);

Tuple Fields§

§0: Uint<LIMBS>

Implementations§

Source§

impl<const LIMBS: usize> NonZeroUint<LIMBS>

Source

pub const fn new_unwrap(n: Uint<LIMBS>) -> Self

Creates a new non-zero integer in a const context.

In future versions of Rust it should be possible to replace this with NonZero::new(…).unwrap()

§Panics
  • if the value is zero.
Source

pub const fn from_be_hex(hex: &str) -> Self

Create a new NonZero<Uint> from the provided big endian hex string.

§Panics
  • if the hex is zero, malformed, or not zero-padded accordingly for the size.
Source

pub const fn from_le_hex(hex: &str) -> Self

Create a new NonZero<Uint> from the provided little endian hex string.

§Panics
  • if the hex is zero, malformed, or not zero-padded accordingly for the size.
Source

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

Create a NonZeroUint from a NonZeroU8 (const-friendly)

Source

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

Create a NonZeroUint from a NonZeroU16 (const-friendly)

Source

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

Create a NonZeroUint from a NonZeroU32 (const-friendly)

Source

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

Create a NonZeroUint from a NonZeroU64 (const-friendly)

Source

pub const fn from_u128(n: NonZeroU128) -> Self

Create a NonZeroUint from a NonZeroU128 (const-friendly)

Source

pub const fn as_uint_ref(&self) -> &NonZeroUintRef

Borrow this NonZero<Uint> as a &NonZeroUintRef.

Source§

impl<const LIMBS: usize> NonZeroUint<LIMBS>

Source

pub const fn gcd_unsigned(&self, rhs: &Uint<LIMBS>) -> Self

Compute the greatest common divisor of self and rhs.

Source

pub const fn gcd_unsigned_vartime(&self, rhs: &Uint<LIMBS>) -> Self

Compute the greatest common divisor of self and rhs.

Executes in variable time w.r.t. all input parameters.

Source

pub const fn xgcd(&self, rhs: &Self) -> XgcdOutput<LIMBS, NonZeroUint<LIMBS>>

Execute the Extended GCD algorithm.

Given (self, rhs), computes (g, x, y) s.t. self * x + rhs * y = g = gcd(self, rhs).

Trait Implementations§

Source§

impl<const LIMBS: usize> AsRef<NonZero<UintRef>> for NonZeroUint<LIMBS>

Source§

fn as_ref(&self) -> &NonZeroUintRef

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

impl<const LIMBS: usize> Gcd<Odd<Uint<LIMBS>>> for NonZeroUint<LIMBS>

Source§

type Output = Odd<Uint<LIMBS>>

Output type.
Source§

fn gcd(&self, rhs: &OddUint<LIMBS>) -> Self::Output

Compute the greatest common divisor of self and rhs.
Source§

fn gcd_vartime(&self, rhs: &OddUint<LIMBS>) -> Self::Output

Compute the greatest common divisor of self and rhs in variable time.
Source§

impl<const LIMBS: usize> Gcd<Uint<LIMBS>> for NonZeroUint<LIMBS>

Source§

type Output = NonZero<Uint<LIMBS>>

Output type.
Source§

fn gcd(&self, rhs: &Uint<LIMBS>) -> Self::Output

Compute the greatest common divisor of self and rhs.
Source§

fn gcd_vartime(&self, rhs: &Uint<LIMBS>) -> Self::Output

Compute the greatest common divisor of self and rhs in variable time.
Source§

impl<const LIMBS: usize> Gcd for NonZeroUint<LIMBS>

Source§

type Output = NonZero<Uint<LIMBS>>

Output type.
Source§

fn gcd(&self, rhs: &NonZeroUint<LIMBS>) -> Self::Output

Compute the greatest common divisor of self and rhs.
Source§

fn gcd_vartime(&self, rhs: &NonZeroUint<LIMBS>) -> Self::Output

Compute the greatest common divisor of self and rhs in variable time.
Source§

impl<const LIMBS: usize> Xgcd for NonZeroUint<LIMBS>

Source§

type Output = XgcdOutput<LIMBS, NonZero<Uint<LIMBS>>>

Output type.
Source§

fn xgcd(&self, rhs: &NonZeroUint<LIMBS>) -> Self::Output

Compute the extended greatest common divisor of self and rhs.
Source§

fn xgcd_vartime(&self, rhs: &NonZeroUint<LIMBS>) -> Self::Output

Compute the extended greatest common divisor of self and rhs in variable time.