Skip to main content

PrimeParams

Struct PrimeParams 

Source
pub struct PrimeParams<const LIMBS: usize> { /* private fields */ }
Expand description

Parameters for supporting efficient computations on integers in Montgomery form with a prime modulus.

Implementations§

Source§

impl<const LIMBS: usize> PrimeParams<LIMBS>

Source

pub const fn new_vartime( params: &FixedMontyParams<LIMBS>, generator: u32, ) -> Self

Instantiates a new set of PrimeParams given FixedMontyParams for a prime modulus.

The value generator must be a multiplicative generator (ie. primitive element) of the finite field, having order modulus-1. Its powers generate all nonzero elements of the field: generator^0, generator^1, ..., generator^(modulus-2) enumerate [1, modulus-1].

Source

pub const fn generator(&self) -> NonZeroU32

Get the constant ‘generator’ used in modular square root calculation.

Source

pub const fn s(&self) -> NonZeroU32

Get the constant ‘s’ used in modular square root calculation.

Source

pub const fn t(&self) -> OddUint<LIMBS>

Get the constant ‘t’ used in modular square root calculation.

Trait Implementations§

Source§

impl<const LIMBS: usize> Clone for PrimeParams<LIMBS>

Source§

fn clone(&self) -> PrimeParams<LIMBS>

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<const LIMBS: usize> ConditionallySelectable for PrimeParams<LIMBS>

Available on crate feature subtle only.
Source§

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

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

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

Select a or b 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<const LIMBS: usize> ConstantTimeEq for PrimeParams<LIMBS>

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<const LIMBS: usize> CtAssign for PrimeParams<LIMBS>

Source§

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

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

impl<const LIMBS: usize> CtAssignSlice for PrimeParams<LIMBS>

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<const LIMBS: usize> CtEq for PrimeParams<LIMBS>

Source§

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

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

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

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

impl<const LIMBS: usize> CtEqSlice for PrimeParams<LIMBS>

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<const LIMBS: usize> Debug for PrimeParams<LIMBS>

Source§

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

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

impl<const LIMBS: usize> Copy for PrimeParams<LIMBS>

Source§

impl<const LIMBS: usize> CtSelectUsingCtAssign for PrimeParams<LIMBS>

Auto Trait Implementations§

§

impl<const LIMBS: usize> Freeze for PrimeParams<LIMBS>

§

impl<const LIMBS: usize> RefUnwindSafe for PrimeParams<LIMBS>

§

impl<const LIMBS: usize> Send for PrimeParams<LIMBS>

§

impl<const LIMBS: usize> Sync for PrimeParams<LIMBS>

§

impl<const LIMBS: usize> Unpin for PrimeParams<LIMBS>

§

impl<const LIMBS: usize> UnsafeUnpin for PrimeParams<LIMBS>

§

impl<const LIMBS: usize> UnwindSafe for PrimeParams<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> CtSelect for T

Source§

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

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