pub struct FpElement<MOD, const LIMBS: usize>where
MOD: ConstPrimeMontyParams<LIMBS>,{ /* private fields */ }Expand description
An element of the prime field $\mathbb{F}_p = \mathbb{Z}/p\mathbb{Z}$, stored in Montgomery form.
The internal value uses crypto-bigint’s ConstMontyForm, so arithmetic
is performed in Montgomery representation while the public constructors and
accessors accept and return canonical integers.
Implementations§
Source§impl<MOD, const LIMBS: usize> FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Sourcepub fn from_words(words: [u64; LIMBS]) -> Self
pub fn from_words(words: [u64; LIMBS]) -> Self
Sourcepub fn from_limbs(limbs: &[u64]) -> Self
pub fn from_limbs(limbs: &[u64]) -> Self
Sourcepub fn to_montgomery(&self) -> Uint<LIMBS>
pub fn to_montgomery(&self) -> Uint<LIMBS>
Sourcepub fn from_montgomery(mont: Uint<LIMBS>) -> Self
pub fn from_montgomery(mont: Uint<LIMBS>) -> Self
Trait Implementations§
Source§impl<MOD, const LIMBS: usize> Add for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> Add for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Source§impl<MOD, const LIMBS: usize> Clone for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS> + Clone,
impl<MOD, const LIMBS: usize> Clone for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS> + Clone,
Source§impl<MOD, const LIMBS: usize> ConditionallySelectable for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> ConditionallySelectable for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
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<MOD, const LIMBS: usize> ConstantTimeEq for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> ConstantTimeEq for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Source§impl<MOD, const LIMBS: usize> Debug for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS> + Debug,
impl<MOD, const LIMBS: usize> Debug for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS> + Debug,
Source§impl<MOD, const LIMBS: usize> Default for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> Default for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Source§impl<MOD, const LIMBS: usize> Display for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> Display for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Source§impl<MOD, const LIMBS: usize> FieldFromRepr for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> FieldFromRepr for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Source§impl<MOD, const LIMBS: usize> FieldOps for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> FieldOps for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Source§fn norm(&self) -> Self
fn norm(&self) -> Self
compute the norm of
self down to $\mathbb{F}_p$ (as an
element of type Self)Source§fn trace(&self) -> Self
fn trace(&self) -> Self
compute the trace of
self down to $\mathbb{F}_p$ (as an
element of type Self)Source§fn legendre(&self) -> i8
fn legendre(&self) -> i8
Computes the “Legendre symbol” i.e., if 0,1,-1 depending if
self is 0, a square or a nonsquare.Source§fn characteristic() -> Vec<u64>
fn characteristic() -> Vec<u64>
Returns the characteristic of the field.
Source§fn pow_vartime(&self, exp: &[u64]) -> Self
fn pow_vartime(&self, exp: &[u64]) -> Self
self^exp using square-and multiply (litte-endian bit order) Read moreSource§fn pow(&self, exp: &[u64]) -> Self
fn pow(&self, exp: &[u64]) -> Self
self^pow in constant time using a Montgomery ladder Read moreSource§fn frobenius_pow(&self, k: u32) -> Self
fn frobenius_pow(&self, k: u32) -> Self
Compute
self^{p^k} a power of the frobeniusSource§fn inverse_and_sqrt(&self) -> (CtOption<Self>, CtOption<Self>)
fn inverse_and_sqrt(&self) -> (CtOption<Self>, CtOption<Self>)
Computes the inverse and square root of
self Read moreSource§fn invertme_sqrtother(&self, rhs: &Self) -> (CtOption<Self>, CtOption<Self>)
fn invertme_sqrtother(&self, rhs: &Self) -> (CtOption<Self>, CtOption<Self>)
Source§fn sqrt_ratio(&self, rhs: &Self) -> CtOption<Self>
fn sqrt_ratio(&self, rhs: &Self) -> CtOption<Self>
Computes the squareroot of a ratio
self/rhs Read moreSource§impl<MOD, const LIMBS: usize> FieldRandom for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> FieldRandom for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Source§impl<MOD, const LIMBS: usize> Mul for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> Mul for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Source§impl<MOD, const LIMBS: usize> Neg for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> Neg for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Source§impl<MOD, const LIMBS: usize> PartialEq for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS> + PartialEq,
impl<MOD, const LIMBS: usize> PartialEq for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS> + PartialEq,
Source§impl<MOD, const LIMBS: usize> Sub for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> Sub for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
impl<MOD, const LIMBS: usize> Copy for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS> + Copy,
impl<MOD, const LIMBS: usize> Eq for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS> + Eq,
impl<MOD, const LIMBS: usize> StructuralPartialEq for FpElement<MOD, LIMBS>where
MOD: ConstPrimeMontyParams<LIMBS>,
Auto Trait Implementations§
impl<MOD, const LIMBS: usize> Freeze for FpElement<MOD, LIMBS>
impl<MOD, const LIMBS: usize> RefUnwindSafe for FpElement<MOD, LIMBS>where
MOD: RefUnwindSafe,
impl<MOD, const LIMBS: usize> Send for FpElement<MOD, LIMBS>
impl<MOD, const LIMBS: usize> Sync for FpElement<MOD, LIMBS>
impl<MOD, const LIMBS: usize> Unpin for FpElement<MOD, LIMBS>where
MOD: Unpin,
impl<MOD, const LIMBS: usize> UnsafeUnpin for FpElement<MOD, LIMBS>
impl<MOD, const LIMBS: usize> UnwindSafe for FpElement<MOD, LIMBS>where
MOD: UnwindSafe,
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