pub struct MontBackend<T, const N: usize>(/* private fields */)
where
T: MontConfig<N>;
Trait Implementations§
Source§impl<T, const N: usize> FpConfig<N> for MontBackend<T, N>where
T: MontConfig<N>,
impl<T, const N: usize> FpConfig<N> for MontBackend<T, N>where
T: MontConfig<N>,
Source§const GENERATOR: Fp<MontBackend<T, N>, N> = T::GENERATOR
const GENERATOR: Fp<MontBackend<T, N>, N> = T::GENERATOR
A multiplicative generator of the field.
Self::GENERATOR
is an element having multiplicative order
Self::MODULUS - 1
.
Source§const ZERO: Fp<MontBackend<T, N>, N> = _
const ZERO: Fp<MontBackend<T, N>, N> = _
Additive identity of the field, i.e. the element e
such that, for all elements f
of the field, e + f = f
.
Source§const ONE: Fp<MontBackend<T, N>, N> = _
const ONE: Fp<MontBackend<T, N>, N> = _
Multiplicative identity of the field, i.e. the element e
such that, for all elements f
of the field, e * f = f
.
Source§fn mul_assign(a: &mut Fp<MontBackend<T, N>, N>, b: &Fp<MontBackend<T, N>, N>)
fn mul_assign(a: &mut Fp<MontBackend<T, N>, N>, b: &Fp<MontBackend<T, N>, N>)
This modular multiplication algorithm uses Montgomery
reduction for efficient implementation. It also additionally
uses the “no-carry optimization” outlined
here if
P::MODULUS
has (a) a non-zero MSB, and (b) at least one
zero bit in the rest of the modulus.
Source§const TWO_ADICITY: u32 = _
const TWO_ADICITY: u32 = _
Let
N
be the size of the multiplicative group defined by the field.
Then TWO_ADICITY
is the two-adicity of N
, i.e. the integer s
such that N = 2^s * t
for some odd integer t
.Source§const TWO_ADIC_ROOT_OF_UNITY: Fp<MontBackend<T, N>, N> = T::TWO_ADIC_ROOT_OF_UNITY
const TWO_ADIC_ROOT_OF_UNITY: Fp<MontBackend<T, N>, N> = T::TWO_ADIC_ROOT_OF_UNITY
2^s root of unity computed by GENERATOR^t
Source§const SMALL_SUBGROUP_BASE: Option<u32> = T::SMALL_SUBGROUP_BASE
const SMALL_SUBGROUP_BASE: Option<u32> = T::SMALL_SUBGROUP_BASE
An integer
b
such that there exists a multiplicative subgroup
of size b^k
for some integer k
.Source§const SMALL_SUBGROUP_BASE_ADICITY: Option<u32> = T::SMALL_SUBGROUP_BASE_ADICITY
const SMALL_SUBGROUP_BASE_ADICITY: Option<u32> = T::SMALL_SUBGROUP_BASE_ADICITY
The integer
k
such that there exists a multiplicative subgroup
of size Self::SMALL_SUBGROUP_BASE^k
.Source§const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<Fp<MontBackend<T, N>, N>> = T::LARGE_SUBGROUP_ROOT_OF_UNITY
const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<Fp<MontBackend<T, N>, N>> = T::LARGE_SUBGROUP_ROOT_OF_UNITY
GENERATOR^((MODULUS-1) / (2^s *
SMALL_SUBGROUP_BASE^SMALL_SUBGROUP_BASE_ADICITY)) Used for mixed-radix
FFT.
Source§const SQRT_PRECOMP: Option<SqrtPrecomputation<Fp<MontBackend<T, N>, N>>> = T::SQRT_PRECOMP
const SQRT_PRECOMP: Option<SqrtPrecomputation<Fp<MontBackend<T, N>, N>>> = T::SQRT_PRECOMP
Precomputed material for use when computing square roots.
Currently uses the generic Tonelli-Shanks,
which works for every modulus.
Source§fn add_assign(a: &mut Fp<MontBackend<T, N>, N>, b: &Fp<MontBackend<T, N>, N>)
fn add_assign(a: &mut Fp<MontBackend<T, N>, N>, b: &Fp<MontBackend<T, N>, N>)
Set a += b.
Source§fn sub_assign(a: &mut Fp<MontBackend<T, N>, N>, b: &Fp<MontBackend<T, N>, N>)
fn sub_assign(a: &mut Fp<MontBackend<T, N>, N>, b: &Fp<MontBackend<T, N>, N>)
Set a -= b.
Source§fn double_in_place(a: &mut Fp<MontBackend<T, N>, N>)
fn double_in_place(a: &mut Fp<MontBackend<T, N>, N>)
Set a = a + a.
Source§fn neg_in_place(a: &mut Fp<MontBackend<T, N>, N>)
fn neg_in_place(a: &mut Fp<MontBackend<T, N>, N>)
Set a = -a;
Source§fn sum_of_products<const M: usize>(
a: &[Fp<MontBackend<T, N>, N>; M],
b: &[Fp<MontBackend<T, N>, N>; M],
) -> Fp<MontBackend<T, N>, N>
fn sum_of_products<const M: usize>( a: &[Fp<MontBackend<T, N>, N>; M], b: &[Fp<MontBackend<T, N>, N>; M], ) -> Fp<MontBackend<T, N>, N>
Compute the inner product
<a, b>
.Source§fn square_in_place(a: &mut Fp<MontBackend<T, N>, N>)
fn square_in_place(a: &mut Fp<MontBackend<T, N>, N>)
Set a *= a.
Source§fn inverse(a: &Fp<MontBackend<T, N>, N>) -> Option<Fp<MontBackend<T, N>, N>>
fn inverse(a: &Fp<MontBackend<T, N>, N>) -> Option<Fp<MontBackend<T, N>, N>>
Compute a^{-1} if
a
is not zero.Source§fn from_bigint(r: BigInt<N>) -> Option<Fp<MontBackend<T, N>, N>>
fn from_bigint(r: BigInt<N>) -> Option<Fp<MontBackend<T, N>, N>>
Construct a field element from an integer in the range
0..(Self::MODULUS - 1)
. Returns None
if the integer is outside
this range.Source§fn into_bigint(a: Fp<MontBackend<T, N>, N>) -> BigInt<N>
fn into_bigint(a: Fp<MontBackend<T, N>, N>) -> BigInt<N>
Convert a field element to an integer in the range
0..(Self::MODULUS - 1)
.Auto Trait Implementations§
impl<T, const N: usize> Freeze for MontBackend<T, N>
impl<T, const N: usize> RefUnwindSafe for MontBackend<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Send for MontBackend<T, N>
impl<T, const N: usize> Sync for MontBackend<T, N>
impl<T, const N: usize> Unpin for MontBackend<T, N>where
T: Unpin,
impl<T, const N: usize> UnwindSafe for MontBackend<T, N>where
T: 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more