#[repr(transparent)]pub struct Odd<T>(T)
where
T: ?Sized;Expand description
Wrapper type for odd integers.
These are frequently used in cryptography, e.g. as a modulus.
Tuple Fields§
§0: TImplementations§
Source§impl<const LIMBS: usize> Odd<Int<LIMBS>>
impl<const LIMBS: usize> Odd<Int<LIMBS>>
Sourcepub const fn gcd_unsigned(&self, rhs: &Uint<LIMBS>) -> Odd<Uint<LIMBS>>
pub const fn gcd_unsigned(&self, rhs: &Uint<LIMBS>) -> Odd<Uint<LIMBS>>
Compute the greatest common divisor of self and rhs.
Sourcepub const fn gcd_unsigned_vartime(&self, rhs: &Uint<LIMBS>) -> Odd<Uint<LIMBS>>
pub const fn gcd_unsigned_vartime(&self, rhs: &Uint<LIMBS>) -> Odd<Uint<LIMBS>>
Compute the greatest common divisor of self and rhs.
Executes in variable time w.r.t. all input parameters.
Source§impl<T> Odd<T>
impl<T> Odd<T>
Source§impl<const LIMBS: usize> Odd<Uint<LIMBS>>
impl<const LIMBS: usize> Odd<Uint<LIMBS>>
Sourcepub const fn from_be_hex(hex: &str) -> Odd<Uint<LIMBS>>
pub const fn from_be_hex(hex: &str) -> Odd<Uint<LIMBS>>
Sourcepub const fn from_le_hex(hex: &str) -> Odd<Uint<LIMBS>>
pub const fn from_le_hex(hex: &str) -> Odd<Uint<LIMBS>>
Create a new Odd<Uint<LIMBS>> from the provided little endian hex string.
§Panics
- if the hex is malformed or not zero-padded accordingly for the size.
- if the value is even.
Sourcepub const fn as_uint_ref(&self) -> &Odd<UintRef>
pub const fn as_uint_ref(&self) -> &Odd<UintRef>
Borrow this OddUint as a &OddUintRef.
Source§impl Odd<UintRef>
impl Odd<UintRef>
Sourcepub const fn to_uint_resize<const T: usize>(&self) -> Odd<Uint<T>>
pub const fn to_uint_resize<const T: usize>(&self) -> Odd<Uint<T>>
Construct an Odd<Uint<T>> from the unsigned integer value,
truncating the upper bits if the value is too large to be
represented.
Source§impl<const LIMBS: usize> Odd<Uint<LIMBS>>
impl<const LIMBS: usize> Odd<Uint<LIMBS>>
Sourcepub const fn gcd_unsigned(&self, rhs: &Uint<LIMBS>) -> Odd<Uint<LIMBS>>
pub const fn gcd_unsigned(&self, rhs: &Uint<LIMBS>) -> Odd<Uint<LIMBS>>
Compute the greatest common divisor of self and rhs.
Sourcepub const fn gcd_unsigned_vartime(&self, rhs: &Uint<LIMBS>) -> Odd<Uint<LIMBS>>
pub const fn gcd_unsigned_vartime(&self, rhs: &Uint<LIMBS>) -> Odd<Uint<LIMBS>>
Compute the greatest common divisor of self and rhs.
Executes in variable time w.r.t. all input parameters.
Trait Implementations§
Source§impl<T> ConditionallySelectable for Odd<T>
Available on crate feature subtle only.
impl<T> ConditionallySelectable for Odd<T>
Available on crate feature
subtle only.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)
Conditionally swap
self and other if choice == 1; otherwise,
reassign both unto themselves. Read moreSource§impl<T> ConstantTimeEq for Odd<T>
Available on crate feature subtle only.
impl<T> ConstantTimeEq for Odd<T>
Available on crate feature
subtle only.Source§impl<T> CtAssignSlice for Odd<T>where
T: CtAssignSlice,
impl<T> CtAssignSlice for Odd<T>where
T: CtAssignSlice,
Source§fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice)
fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice)
Source§impl<T> CtEqSlice for Odd<T>where
T: CtEq,
impl<T> CtEqSlice for Odd<T>where
T: CtEq,
Source§fn ct_eq_slice(a: &[Self], b: &[Self]) -> Choice
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
fn ct_ne_slice(a: &[Self], b: &[Self]) -> Choice
Determine if
a is NOT equal to b in constant-time.Source§impl Gcd<BoxedUint> for Odd<BoxedUint>
impl Gcd<BoxedUint> for Odd<BoxedUint>
Source§impl<const LIMBS: usize> Gcd<Int<LIMBS>> for Odd<Int<LIMBS>>
impl<const LIMBS: usize> Gcd<Int<LIMBS>> for Odd<Int<LIMBS>>
Source§impl Gcd<Limb> for Odd<Limb>
impl Gcd<Limb> for Odd<Limb>
Source§impl<const LIMBS: usize> Gcd<NonZero<Uint<LIMBS>>> for Odd<Uint<LIMBS>>
impl<const LIMBS: usize> Gcd<NonZero<Uint<LIMBS>>> for Odd<Uint<LIMBS>>
Source§impl<const LIMBS: usize> Gcd<Odd<Int<LIMBS>>> for Uint<LIMBS>
impl<const LIMBS: usize> Gcd<Odd<Int<LIMBS>>> for Uint<LIMBS>
Source§impl<const LIMBS: usize> Gcd<Odd<Uint<LIMBS>>> for Uint<LIMBS>
impl<const LIMBS: usize> Gcd<Odd<Uint<LIMBS>>> for Uint<LIMBS>
Source§impl<const LIMBS: usize> Gcd<Uint<LIMBS>> for Odd<Int<LIMBS>>
impl<const LIMBS: usize> Gcd<Uint<LIMBS>> for Odd<Int<LIMBS>>
Source§impl<const LIMBS: usize> Gcd<Uint<LIMBS>> for Odd<Uint<LIMBS>>
impl<const LIMBS: usize> Gcd<Uint<LIMBS>> for Odd<Uint<LIMBS>>
Source§impl<const LIMBS: usize> Gcd for Odd<Int<LIMBS>>
impl<const LIMBS: usize> Gcd for Odd<Int<LIMBS>>
Source§impl<const LIMBS: usize> Gcd for Odd<Uint<LIMBS>>
impl<const LIMBS: usize> Gcd for Odd<Uint<LIMBS>>
Source§impl<T> Mul for Odd<T>where
T: Mul<Output = T>,
Any odd integer multiplied by another odd integer is definitionally odd.
impl<T> Mul for Odd<T>where
T: Mul<Output = T>,
Any odd integer multiplied by another odd integer is definitionally odd.
Source§impl<T> Ord for Odd<T>
impl<T> Ord for Odd<T>
Source§impl<const LIMBS: usize> PartialOrd<Odd<Uint<LIMBS>>> for Uint<LIMBS>
impl<const LIMBS: usize> PartialOrd<Odd<Uint<LIMBS>>> for Uint<LIMBS>
Source§impl<T> PartialOrd for Odd<T>where
T: PartialOrd + ?Sized,
impl<T> PartialOrd for Odd<T>where
T: PartialOrd + ?Sized,
Source§impl<const LIMBS: usize> Random for Odd<Uint<LIMBS>>
Available on crate feature rand_core only.
impl<const LIMBS: usize> Random for Odd<Uint<LIMBS>>
Available on crate feature
rand_core only.Source§fn try_random_from_rng<R>(
rng: &mut R,
) -> Result<Odd<Uint<LIMBS>>, <R as TryRng>::Error>
fn try_random_from_rng<R>( rng: &mut R, ) -> Result<Odd<Uint<LIMBS>>, <R as TryRng>::Error>
Generate a random Odd<Uint<T>>.
Source§fn random_from_rng<R>(rng: &mut R) -> Self
fn random_from_rng<R>(rng: &mut R) -> Self
Generate a random value. Read more
Source§impl Resize for &Odd<BoxedUint>
Available on crate feature alloc only.
impl Resize for &Odd<BoxedUint>
Available on crate feature
alloc only.Source§fn resize_unchecked(
self,
at_least_bits_precision: u32,
) -> <&Odd<BoxedUint> as Resize>::Output
fn resize_unchecked( self, at_least_bits_precision: u32, ) -> <&Odd<BoxedUint> as Resize>::Output
Resizes to the minimum storage that fits
at_least_bits_precision
without checking if the bit size of self is larger than at_least_bits_precision. Read moreSource§impl Resize for Odd<BoxedUint>
Available on crate feature alloc only.
impl Resize for Odd<BoxedUint>
Available on crate feature
alloc only.Source§fn resize_unchecked(
self,
at_least_bits_precision: u32,
) -> <Odd<BoxedUint> as Resize>::Output
fn resize_unchecked( self, at_least_bits_precision: u32, ) -> <Odd<BoxedUint> as Resize>::Output
Resizes to the minimum storage that fits
at_least_bits_precision
without checking if the bit size of self is larger than at_least_bits_precision. Read moreSource§impl<const LIMBS: usize> Xgcd for Odd<Int<LIMBS>>
impl<const LIMBS: usize> Xgcd for Odd<Int<LIMBS>>
Source§impl<const LIMBS: usize> Xgcd for Odd<Uint<LIMBS>>
impl<const LIMBS: usize> Xgcd for Odd<Uint<LIMBS>>
impl<T> Copy for Odd<T>
impl<T> Eq for Odd<T>
impl<T> StructuralPartialEq for Odd<T>where
T: ?Sized,
Auto Trait Implementations§
impl<T> Freeze for Odd<T>
impl<T> RefUnwindSafe for Odd<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for Odd<T>
impl<T> Sync for Odd<T>
impl<T> Unpin for Odd<T>
impl<T> UnsafeUnpin for Odd<T>where
T: UnsafeUnpin + ?Sized,
impl<T> UnwindSafe for Odd<T>where
T: UnwindSafe + ?Sized,
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
Mutably borrows from an owned value. Read more