pub type BabyBear = MontyField31<BabyBearParameters>;
Expand description
The prime field 2^31 - 2^27 + 1
, a.k.a. the Baby Bear field.
Aliased Type§
struct BabyBear { /* private fields */ }
Implementations
Source§impl<MP> MontyField31<MP>where
MP: FieldParameters + TwoAdicData,
impl<MP> MontyField31<MP>where
MP: FieldParameters + TwoAdicData,
pub fn backward_fft( input: &mut [MontyField31<MP>], root_table: &[Vec<MontyField31<MP>>], )
Source§impl<MP> MontyField31<MP>where
MP: FieldParameters + TwoAdicData,
impl<MP> MontyField31<MP>where
MP: FieldParameters + TwoAdicData,
pub fn forward_fft( input: &mut [MontyField31<MP>], root_table: &[Vec<MontyField31<MP>>], )
Source§impl<MP> MontyField31<MP>where
MP: FieldParameters + TwoAdicData,
impl<MP> MontyField31<MP>where
MP: FieldParameters + TwoAdicData,
Sourcepub fn roots_of_unity_table(n: usize) -> Vec<Vec<MontyField31<MP>>>
pub fn roots_of_unity_table(n: usize) -> Vec<Vec<MontyField31<MP>>>
Given a field element gen
of order n where n = 2^lg_n
,
return a vector of vectors table
where table[i] is the
vector of twiddle factors for an fft of length n/2^i. The
values g_i^k for k >= i/2 are skipped as these are just the
negatives of the other roots (using g_i^{i/2} = -1). The
value gen^0 = 1 is included to aid consistency between the
packed and non-packed variants.
Source§impl<MP> MontyField31<MP>where
MP: MontyParameters,
impl<MP> MontyField31<MP>where
MP: MontyParameters,
pub const fn new(value: u32) -> MontyField31<MP>
Sourcepub const fn new_array<const N: usize>(input: [u32; N]) -> [MontyField31<MP>; N]
pub const fn new_array<const N: usize>(input: [u32; N]) -> [MontyField31<MP>; N]
Convert a constant u32 array into a constant array of field elements. Constant version of array.map(MontyField31::new).
Sourcepub const fn new_2d_array<const N: usize, const M: usize>(
input: [[u32; N]; M],
) -> [[MontyField31<MP>; N]; M]
pub const fn new_2d_array<const N: usize, const M: usize>( input: [[u32; N]; M], ) -> [[MontyField31<MP>; N]; M]
Convert a constant 2d u32 array into a constant 2d array of field elements. Constant version of array.map(MontyField31::new_array).
Sourcepub const fn mul_2exp_neg_n(&self, n: u32) -> MontyField31<MP>
pub const fn mul_2exp_neg_n(&self, n: u32) -> MontyField31<MP>
Multiply the given MontyField31 element by 2^{-n}
.
This makes use of the fact that, as the monty constant is 2^32
,
the monty form of 2^{-n}
is 2^{32 - n}
. Monty reduction works
provided the input is < 2^32P
so this works for 0 <= n <= 32
.
Trait Implementations
Source§impl<PMP> Add<PackedMontyField31Neon<PMP>> for MontyField31<PMP>where
PMP: PackedMontyParameters,
impl<PMP> Add<PackedMontyField31Neon<PMP>> for MontyField31<PMP>where
PMP: PackedMontyParameters,
Source§type Output = PackedMontyField31Neon<PMP>
type Output = PackedMontyField31Neon<PMP>
+
operator.Source§fn add(self, rhs: PackedMontyField31Neon<PMP>) -> PackedMontyField31Neon<PMP>
fn add(self, rhs: PackedMontyField31Neon<PMP>) -> PackedMontyField31Neon<PMP>
+
operation. Read moreSource§impl<FP> Add for MontyField31<FP>where
FP: MontyParameters,
impl<FP> Add for MontyField31<FP>where
FP: MontyParameters,
Source§type Output = MontyField31<FP>
type Output = MontyField31<FP>
+
operator.Source§fn add(self, rhs: MontyField31<FP>) -> MontyField31<FP>
fn add(self, rhs: MontyField31<FP>) -> MontyField31<FP>
+
operation. Read moreSource§impl<FP> AddAssign for MontyField31<FP>where
FP: MontyParameters,
impl<FP> AddAssign for MontyField31<FP>where
FP: MontyParameters,
Source§fn add_assign(&mut self, rhs: MontyField31<FP>)
fn add_assign(&mut self, rhs: MontyField31<FP>)
+=
operation. Read moreSource§impl<const WIDTH: usize, FP> BinomiallyExtendable<WIDTH> for MontyField31<FP>where
FP: BinomialExtensionData<WIDTH> + FieldParameters,
impl<const WIDTH: usize, FP> BinomiallyExtendable<WIDTH> for MontyField31<FP>where
FP: BinomialExtensionData<WIDTH> + FieldParameters,
const W: MontyField31<FP>
const DTH_ROOT: MontyField31<FP>
const EXT_GENERATOR: [MontyField31<FP>; WIDTH] = FP::EXT_GENERATOR
Source§impl<MP> Clone for MontyField31<MP>where
MP: Clone + MontyParameters,
impl<MP> Clone for MontyField31<MP>where
MP: Clone + MontyParameters,
Source§fn clone(&self) -> MontyField31<MP>
fn clone(&self) -> MontyField31<MP>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<FP> Debug for MontyField31<FP>where
FP: MontyParameters,
impl<FP> Debug for MontyField31<FP>where
FP: MontyParameters,
Source§impl<MP> Default for MontyField31<MP>where
MP: Default + MontyParameters,
impl<MP> Default for MontyField31<MP>where
MP: Default + MontyParameters,
Source§fn default() -> MontyField31<MP>
fn default() -> MontyField31<MP>
Source§impl<'de, FP> Deserialize<'de> for MontyField31<FP>where
FP: FieldParameters,
impl<'de, FP> Deserialize<'de> for MontyField31<FP>where
FP: FieldParameters,
Source§fn deserialize<D>(
d: D,
) -> Result<MontyField31<FP>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
d: D,
) -> Result<MontyField31<FP>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<FP> Display for MontyField31<FP>where
FP: MontyParameters,
impl<FP> Display for MontyField31<FP>where
FP: MontyParameters,
Source§impl<FP> Div for MontyField31<FP>where
FP: FieldParameters,
impl<FP> Div for MontyField31<FP>where
FP: FieldParameters,
Source§type Output = MontyField31<FP>
type Output = MontyField31<FP>
/
operator.Source§fn div(self, rhs: MontyField31<FP>) -> MontyField31<FP>
fn div(self, rhs: MontyField31<FP>) -> MontyField31<FP>
/
operation. Read moreSource§impl<FP> Field for MontyField31<FP>where
FP: FieldParameters,
impl<FP> Field for MontyField31<FP>where
FP: FieldParameters,
Source§const GENERATOR: MontyField31<FP> = FP::MONTY_GEN
const GENERATOR: MontyField31<FP> = FP::MONTY_GEN
type Packing = PackedMontyField31Neon<FP>
Source§fn exp_u64_generic<FA>(val: FA, power: u64) -> FAwhere
FA: FieldAlgebra<F = MontyField31<FP>>,
fn exp_u64_generic<FA>(val: FA, power: u64) -> FAwhere
FA: FieldAlgebra<F = MontyField31<FP>>,
u64
power. This is similar to exp_u64
, but more general in that it
can be used with FieldAlgebra
s, not just this concrete field. Read moreSource§fn try_inverse(&self) -> Option<MontyField31<FP>>
fn try_inverse(&self) -> Option<MontyField31<FP>>
Source§fn halve(&self) -> MontyField31<FP>
fn halve(&self) -> MontyField31<FP>
fn order() -> BigUint
fn is_zero(&self) -> bool
fn is_one(&self) -> bool
Source§fn div_2exp_u64(&self, exp: u64) -> Self
fn div_2exp_u64(&self, exp: u64) -> Self
fn inverse(&self) -> Self
Source§fn multiplicative_group_factors() -> Vec<(BigUint, usize)>
fn multiplicative_group_factors() -> Vec<(BigUint, usize)>
fn bits() -> usize
Source§impl<FP> FieldAlgebra for MontyField31<FP>where
FP: FieldParameters,
impl<FP> FieldAlgebra for MontyField31<FP>where
FP: FieldParameters,
Source§const ZERO: MontyField31<FP> = FP::MONTY_ZERO
const ZERO: MontyField31<FP> = FP::MONTY_ZERO
Source§const ONE: MontyField31<FP> = FP::MONTY_ONE
const ONE: MontyField31<FP> = FP::MONTY_ONE
Source§const TWO: MontyField31<FP> = FP::MONTY_TWO
const TWO: MontyField31<FP> = FP::MONTY_TWO
ONE + ONE
. Read moreSource§const NEG_ONE: MontyField31<FP> = FP::MONTY_NEG_ONE
const NEG_ONE: MontyField31<FP> = FP::MONTY_NEG_ONE
-ONE
. Read moretype F = MontyField31<FP>
Source§fn from_f(f: <MontyField31<FP> as FieldAlgebra>::F) -> MontyField31<FP>
fn from_f(f: <MontyField31<FP> as FieldAlgebra>::F) -> MontyField31<FP>
Source§fn from_canonical_u8(n: u8) -> MontyField31<FP>
fn from_canonical_u8(n: u8) -> MontyField31<FP>
u8
. Read moreSource§fn from_canonical_u16(n: u16) -> MontyField31<FP>
fn from_canonical_u16(n: u16) -> MontyField31<FP>
u16
. Read moreSource§fn from_canonical_u32(n: u32) -> MontyField31<FP>
fn from_canonical_u32(n: u32) -> MontyField31<FP>
u32
. Read moreSource§fn from_canonical_u64(n: u64) -> MontyField31<FP>
fn from_canonical_u64(n: u64) -> MontyField31<FP>
u64
. Read moreSource§fn from_canonical_usize(n: usize) -> MontyField31<FP>
fn from_canonical_usize(n: usize) -> MontyField31<FP>
usize
. Read morefn from_wrapped_u32(n: u32) -> MontyField31<FP>
fn from_wrapped_u64(n: u64) -> MontyField31<FP>
Source§fn mul_2exp_u64(&self, exp: u64) -> MontyField31<FP>
fn mul_2exp_u64(&self, exp: u64) -> MontyField31<FP>
Source§fn zero_vec(len: usize) -> Vec<MontyField31<FP>>
fn zero_vec(len: usize) -> Vec<MontyField31<FP>>
len
. Many operating systems zero pages
before assigning them to a userspace process. In that case, our process should not need to
write zeros, which would be redundant. However, the compiler may not always recognize this. Read moreSource§fn exp_const_u64<const POWER: u64>(&self) -> Self
fn exp_const_u64<const POWER: u64>(&self) -> Self
Source§fn exp_power_of_2(&self, power_log: usize) -> Self
fn exp_power_of_2(&self, power_log: usize) -> Self
Source§fn powers(&self) -> Powers<Self>
fn powers(&self) -> Powers<Self>
self: self^0, self^1, self^2, ...
.Source§fn shifted_powers(&self, start: Self) -> Powers<Self>
fn shifted_powers(&self, start: Self) -> Powers<Self>
self
shifted by start: start, start*self^1, start*self^2, ...
.Source§fn powers_packed<P>(&self) -> Powers<P>where
P: PackedField<Scalar = Self>,
fn powers_packed<P>(&self) -> Powers<P>where
P: PackedField<Scalar = Self>,
Source§fn shifted_powers_packed<P>(&self, start: Self) -> Powers<P>where
P: PackedField<Scalar = Self>,
fn shifted_powers_packed<P>(&self, start: Self) -> Powers<P>where
P: PackedField<Scalar = Self>,
self
shifted by start
and packed into PackedField
elements. Read moreSource§impl<const WIDTH: usize, FP> HasTwoAdicBinomialExtension<WIDTH> for MontyField31<FP>
impl<const WIDTH: usize, FP> HasTwoAdicBinomialExtension<WIDTH> for MontyField31<FP>
const EXT_TWO_ADICITY: usize
Source§fn ext_two_adic_generator(bits: usize) -> [MontyField31<FP>; WIDTH]
fn ext_two_adic_generator(bits: usize) -> [MontyField31<FP>; WIDTH]
bits
powers of two, otherwise the
behavior is undefined.Source§impl<MP> Hash for MontyField31<MP>where
MP: Hash + MontyParameters,
impl<MP> Hash for MontyField31<MP>where
MP: Hash + MontyParameters,
Source§impl<PMP> Mul<PackedMontyField31Neon<PMP>> for MontyField31<PMP>where
PMP: PackedMontyParameters,
impl<PMP> Mul<PackedMontyField31Neon<PMP>> for MontyField31<PMP>where
PMP: PackedMontyParameters,
Source§type Output = PackedMontyField31Neon<PMP>
type Output = PackedMontyField31Neon<PMP>
*
operator.Source§fn mul(self, rhs: PackedMontyField31Neon<PMP>) -> PackedMontyField31Neon<PMP>
fn mul(self, rhs: PackedMontyField31Neon<PMP>) -> PackedMontyField31Neon<PMP>
*
operation. Read moreSource§impl<FP> Mul for MontyField31<FP>where
FP: MontyParameters,
impl<FP> Mul for MontyField31<FP>where
FP: MontyParameters,
Source§type Output = MontyField31<FP>
type Output = MontyField31<FP>
*
operator.Source§fn mul(self, rhs: MontyField31<FP>) -> MontyField31<FP>
fn mul(self, rhs: MontyField31<FP>) -> MontyField31<FP>
*
operation. Read moreSource§impl<FP> MulAssign for MontyField31<FP>where
FP: MontyParameters,
impl<FP> MulAssign for MontyField31<FP>where
FP: MontyParameters,
Source§fn mul_assign(&mut self, rhs: MontyField31<FP>)
fn mul_assign(&mut self, rhs: MontyField31<FP>)
*=
operation. Read moreSource§impl<FP> Neg for MontyField31<FP>where
FP: FieldParameters,
impl<FP> Neg for MontyField31<FP>where
FP: FieldParameters,
Source§impl<FP> Ord for MontyField31<FP>where
FP: MontyParameters,
impl<FP> Ord for MontyField31<FP>where
FP: MontyParameters,
Source§fn cmp(&self, other: &MontyField31<FP>) -> Ordering
fn cmp(&self, other: &MontyField31<FP>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<MP> PartialEq for MontyField31<MP>where
MP: PartialEq + MontyParameters,
impl<MP> PartialEq for MontyField31<MP>where
MP: PartialEq + MontyParameters,
Source§impl<FP> PartialOrd for MontyField31<FP>where
FP: MontyParameters,
impl<FP> PartialOrd for MontyField31<FP>where
FP: MontyParameters,
Source§impl<FP> PrimeField for MontyField31<FP>where
FP: FieldParameters,
impl<FP> PrimeField for MontyField31<FP>where
FP: FieldParameters,
fn as_canonical_biguint(&self) -> BigUint
Source§impl<FP> PrimeField32 for MontyField31<FP>where
FP: FieldParameters,
impl<FP> PrimeField32 for MontyField31<FP>where
FP: FieldParameters,
const ORDER_U32: u32 = FP::PRIME
Source§fn as_canonical_u32(&self) -> u32
fn as_canonical_u32(&self) -> u32
value
that is less than ORDER_U32
.Source§fn to_unique_u32(&self) -> u32
fn to_unique_u32(&self) -> u32
u32
such that any two field elements
are converted to the same u32
if and only if they represent the same value. Read moreSource§impl<FP> PrimeField64 for MontyField31<FP>where
FP: FieldParameters,
impl<FP> PrimeField64 for MontyField31<FP>where
FP: FieldParameters,
const ORDER_U64: u64
Source§fn as_canonical_u64(&self) -> u64
fn as_canonical_u64(&self) -> u64
value
that is less than ORDER_U64
.Source§fn to_unique_u64(&self) -> u64
fn to_unique_u64(&self) -> u64
u64
such that any two field elements
are converted to the same u64
if and only if they represent the same value. Read moreSource§impl<FP> Product for MontyField31<FP>where
FP: FieldParameters,
impl<FP> Product for MontyField31<FP>where
FP: FieldParameters,
Source§fn product<I>(iter: I) -> MontyField31<FP>where
I: Iterator<Item = MontyField31<FP>>,
fn product<I>(iter: I) -> MontyField31<FP>where
I: Iterator<Item = MontyField31<FP>>,
Self
from the elements by multiplying
the items.Source§impl<FP> Serialize for MontyField31<FP>where
FP: FieldParameters,
impl<FP> Serialize for MontyField31<FP>where
FP: FieldParameters,
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl<PMP> Sub<PackedMontyField31Neon<PMP>> for MontyField31<PMP>where
PMP: PackedMontyParameters,
impl<PMP> Sub<PackedMontyField31Neon<PMP>> for MontyField31<PMP>where
PMP: PackedMontyParameters,
Source§type Output = PackedMontyField31Neon<PMP>
type Output = PackedMontyField31Neon<PMP>
-
operator.Source§fn sub(self, rhs: PackedMontyField31Neon<PMP>) -> PackedMontyField31Neon<PMP>
fn sub(self, rhs: PackedMontyField31Neon<PMP>) -> PackedMontyField31Neon<PMP>
-
operation. Read moreSource§impl<FP> Sub for MontyField31<FP>where
FP: MontyParameters,
impl<FP> Sub for MontyField31<FP>where
FP: MontyParameters,
Source§type Output = MontyField31<FP>
type Output = MontyField31<FP>
-
operator.Source§fn sub(self, rhs: MontyField31<FP>) -> MontyField31<FP>
fn sub(self, rhs: MontyField31<FP>) -> MontyField31<FP>
-
operation. Read moreSource§impl<FP> SubAssign for MontyField31<FP>where
FP: MontyParameters,
impl<FP> SubAssign for MontyField31<FP>where
FP: MontyParameters,
Source§fn sub_assign(&mut self, rhs: MontyField31<FP>)
fn sub_assign(&mut self, rhs: MontyField31<FP>)
-=
operation. Read moreSource§impl<FP> Sum for MontyField31<FP>where
FP: MontyParameters,
impl<FP> Sum for MontyField31<FP>where
FP: MontyParameters,
Source§fn sum<I>(iter: I) -> MontyField31<FP>where
I: Iterator<Item = MontyField31<FP>>,
fn sum<I>(iter: I) -> MontyField31<FP>where
I: Iterator<Item = MontyField31<FP>>,
Self
from the elements by “summing up”
the items.Source§impl<FP> TwoAdicField for MontyField31<FP>where
FP: FieldParameters + TwoAdicData,
impl<FP> TwoAdicField for MontyField31<FP>where
FP: FieldParameters + TwoAdicData,
Source§const TWO_ADICITY: usize = FP::TWO_ADICITY
const TWO_ADICITY: usize = FP::TWO_ADICITY
Source§fn two_adic_generator(bits: usize) -> MontyField31<FP>
fn two_adic_generator(bits: usize) -> MontyField31<FP>
2^bits
.
Assumes bits <= TWO_ADICITY
, otherwise the result is undefined.