Type Alias BabyBear

Source
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>

Source

pub fn backward_fft( input: &mut [MontyField31<MP>], root_table: &[Vec<MontyField31<MP>>], )

Source§

impl<MP> MontyField31<MP>

Source

pub fn forward_fft( input: &mut [MontyField31<MP>], root_table: &[Vec<MontyField31<MP>>], )

Source§

impl<MP> MontyField31<MP>

Source

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,

Source

pub const fn new(value: u32) -> MontyField31<MP>

Source

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

Source

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

Source

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>

Source§

type Output = PackedMontyField31Neon<PMP>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: PackedMontyField31Neon<PMP>) -> PackedMontyField31Neon<PMP>

Performs the + operation. Read more
Source§

impl<FP> Add for MontyField31<FP>
where FP: MontyParameters,

Source§

type Output = MontyField31<FP>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: MontyField31<FP>) -> MontyField31<FP>

Performs the + operation. Read more
Source§

impl<FP> AddAssign for MontyField31<FP>
where FP: MontyParameters,

Source§

fn add_assign(&mut self, rhs: MontyField31<FP>)

Performs the += operation. Read more
Source§

impl<const WIDTH: usize, FP> BinomiallyExtendable<WIDTH> for MontyField31<FP>

Source§

const W: MontyField31<FP>

Source§

const DTH_ROOT: MontyField31<FP>

Source§

const EXT_GENERATOR: [MontyField31<FP>; WIDTH] = FP::EXT_GENERATOR

Source§

impl<MP> Clone for MontyField31<MP>
where MP: Clone + MontyParameters,

Source§

fn clone(&self) -> MontyField31<MP>

Returns a copy 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<FP> Debug for MontyField31<FP>
where FP: MontyParameters,

Source§

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

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

impl<MP> Default for MontyField31<MP>

Source§

fn default() -> MontyField31<MP>

Returns the “default value” for a type. Read more
Source§

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

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<FP> Display for MontyField31<FP>
where FP: MontyParameters,

Source§

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

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

impl<FP> Div for MontyField31<FP>
where FP: FieldParameters,

Source§

type Output = MontyField31<FP>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: MontyField31<FP>) -> MontyField31<FP>

Performs the / operation. Read more
Source§

impl<FP> Field for MontyField31<FP>
where FP: FieldParameters,

Source§

const GENERATOR: MontyField31<FP> = FP::MONTY_GEN

A generator of this field’s entire multiplicative group.
Source§

type Packing = PackedMontyField31Neon<FP>

Source§

fn exp_u64_generic<FA>(val: FA, power: u64) -> FA
where FA: FieldAlgebra<F = MontyField31<FP>>,

Exponentiation by a u64 power. This is similar to exp_u64, but more general in that it can be used with FieldAlgebras, not just this concrete field. Read more
Source§

fn try_inverse(&self) -> Option<MontyField31<FP>>

The multiplicative inverse of this field element, if it exists. Read more
Source§

fn halve(&self) -> MontyField31<FP>

Computes input/2. Should be overwritten by most field implementations to use bitshifts. Will error if the field characteristic is 2.
Source§

fn order() -> BigUint

Source§

fn is_zero(&self) -> bool

Source§

fn is_one(&self) -> bool

Source§

fn div_2exp_u64(&self, exp: u64) -> Self

self / 2^exp
Source§

fn inverse(&self) -> Self

Source§

fn multiplicative_group_factors() -> Vec<(BigUint, usize)>

A list of (factor, exponent) pairs.
Source§

fn bits() -> usize

Source§

impl<FP> FieldAlgebra for MontyField31<FP>
where FP: FieldParameters,

Source§

const ZERO: MontyField31<FP> = FP::MONTY_ZERO

The additive identity of the algebra. Read more
Source§

const ONE: MontyField31<FP> = FP::MONTY_ONE

The multiplicative identity of the Algebra Read more
Source§

const TWO: MontyField31<FP> = FP::MONTY_TWO

The element in the algebra given by ONE + ONE. Read more
Source§

const NEG_ONE: MontyField31<FP> = FP::MONTY_NEG_ONE

The element in the algebra given by -ONE. Read more
Source§

type F = MontyField31<FP>

Source§

fn from_f(f: <MontyField31<FP> as FieldAlgebra>::F) -> MontyField31<FP>

Interpret a field element as a commutative algebra element. Read more
Source§

fn from_canonical_u8(n: u8) -> MontyField31<FP>

Convert from a canonical u8. Read more
Source§

fn from_canonical_u16(n: u16) -> MontyField31<FP>

Convert from a canonical u16. Read more
Source§

fn from_canonical_u32(n: u32) -> MontyField31<FP>

Convert from a canonical u32. Read more
Source§

fn from_canonical_u64(n: u64) -> MontyField31<FP>

Convert from a canonical u64. Read more
Source§

fn from_canonical_usize(n: usize) -> MontyField31<FP>

Convert from a canonical usize. Read more
Source§

fn from_wrapped_u32(n: u32) -> MontyField31<FP>

Source§

fn from_wrapped_u64(n: u64) -> MontyField31<FP>

Source§

fn mul_2exp_u64(&self, exp: u64) -> MontyField31<FP>

self * 2^exp
Source§

fn zero_vec(len: usize) -> Vec<MontyField31<FP>>

Allocates a vector of zero elements of length 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 more
Source§

fn from_bool(b: bool) -> Self

Convert from a bool.
Source§

fn double(&self) -> Self

The elementary function double(a) = 2*a. Read more
Source§

fn square(&self) -> Self

The elementary function square(a) = a^2. Read more
Source§

fn cube(&self) -> Self

The elementary function cube(a) = a^3. Read more
Source§

fn exp_u64(&self, power: u64) -> Self

Exponentiation by a u64 power. Read more
Source§

fn exp_const_u64<const POWER: u64>(&self) -> Self

Exponentiation by a constant power. Read more
Source§

fn exp_power_of_2(&self, power_log: usize) -> Self

Compute self^{2^power_log} by repeated squaring.
Source§

fn powers(&self) -> Powers<Self>

Construct an iterator which returns powers of self: self^0, self^1, self^2, ....
Source§

fn shifted_powers(&self, start: Self) -> Powers<Self>

Construct an iterator which returns powers of self shifted by start: start, start*self^1, start*self^2, ....
Source§

fn powers_packed<P>(&self) -> Powers<P>
where P: PackedField<Scalar = Self>,

Construct an iterator which returns powers of self packed into PackedField elements. Read more
Source§

fn shifted_powers_packed<P>(&self, start: Self) -> Powers<P>
where P: PackedField<Scalar = Self>,

Construct an iterator which returns powers of self shifted by start and packed into PackedField elements. Read more
Source§

fn dot_product<const N: usize>(u: &[Self; N], v: &[Self; N]) -> Self

Compute the dot product of two vectors.
Source§

impl<const WIDTH: usize, FP> HasTwoAdicBinomialExtension<WIDTH> for MontyField31<FP>

Source§

const EXT_TWO_ADICITY: usize

Source§

fn ext_two_adic_generator(bits: usize) -> [MontyField31<FP>; WIDTH]

Assumes the multiplicative group size has at least bits powers of two, otherwise the behavior is undefined.
Source§

impl<MP> Hash for MontyField31<MP>
where MP: Hash + MontyParameters,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<PMP> Mul<PackedMontyField31Neon<PMP>> for MontyField31<PMP>

Source§

type Output = PackedMontyField31Neon<PMP>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: PackedMontyField31Neon<PMP>) -> PackedMontyField31Neon<PMP>

Performs the * operation. Read more
Source§

impl<FP> Mul for MontyField31<FP>
where FP: MontyParameters,

Source§

type Output = MontyField31<FP>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: MontyField31<FP>) -> MontyField31<FP>

Performs the * operation. Read more
Source§

impl<FP> MulAssign for MontyField31<FP>
where FP: MontyParameters,

Source§

fn mul_assign(&mut self, rhs: MontyField31<FP>)

Performs the *= operation. Read more
Source§

impl<FP> Neg for MontyField31<FP>
where FP: FieldParameters,

Source§

type Output = MontyField31<FP>

The resulting type after applying the - operator.
Source§

fn neg(self) -> <MontyField31<FP> as Neg>::Output

Performs the unary - operation. Read more
Source§

impl<FP> Ord for MontyField31<FP>
where FP: MontyParameters,

Source§

fn cmp(&self, other: &MontyField31<FP>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<MP> PartialEq for MontyField31<MP>

Source§

fn eq(&self, other: &MontyField31<MP>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<FP> PartialOrd for MontyField31<FP>
where FP: MontyParameters,

Source§

fn partial_cmp(&self, other: &MontyField31<FP>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<FP> PrimeField for MontyField31<FP>
where FP: FieldParameters,

Source§

impl<FP> PrimeField32 for MontyField31<FP>
where FP: FieldParameters,

Source§

const ORDER_U32: u32 = FP::PRIME

Source§

fn as_canonical_u32(&self) -> u32

Return the representative of value that is less than ORDER_U32.
Source§

fn to_unique_u32(&self) -> u32

Convert a field element to a u32 such that any two field elements are converted to the same u32 if and only if they represent the same value. Read more
Source§

impl<FP> PrimeField64 for MontyField31<FP>
where FP: FieldParameters,

Source§

const ORDER_U64: u64

Source§

fn as_canonical_u64(&self) -> u64

Return the representative of value that is less than ORDER_U64.
Source§

fn to_unique_u64(&self) -> u64

Convert a field element to a u64 such that any two field elements are converted to the same u64 if and only if they represent the same value. Read more
Source§

impl<FP> Product for MontyField31<FP>
where FP: FieldParameters,

Source§

fn product<I>(iter: I) -> MontyField31<FP>
where I: Iterator<Item = MontyField31<FP>>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

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,

Serialize this value into the given Serde serializer. Read more
Source§

impl<PMP> Sub<PackedMontyField31Neon<PMP>> for MontyField31<PMP>

Source§

type Output = PackedMontyField31Neon<PMP>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: PackedMontyField31Neon<PMP>) -> PackedMontyField31Neon<PMP>

Performs the - operation. Read more
Source§

impl<FP> Sub for MontyField31<FP>
where FP: MontyParameters,

Source§

type Output = MontyField31<FP>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: MontyField31<FP>) -> MontyField31<FP>

Performs the - operation. Read more
Source§

impl<FP> SubAssign for MontyField31<FP>
where FP: MontyParameters,

Source§

fn sub_assign(&mut self, rhs: MontyField31<FP>)

Performs the -= operation. Read more
Source§

impl<FP> Sum for MontyField31<FP>
where FP: MontyParameters,

Source§

fn sum<I>(iter: I) -> MontyField31<FP>
where I: Iterator<Item = MontyField31<FP>>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<FP> TwoAdicField for MontyField31<FP>

Source§

const TWO_ADICITY: usize = FP::TWO_ADICITY

The number of factors of two in this field’s multiplicative group.
Source§

fn two_adic_generator(bits: usize) -> MontyField31<FP>

Returns a generator of the multiplicative group of order 2^bits. Assumes bits <= TWO_ADICITY, otherwise the result is undefined.
Source§

impl<MP> Copy for MontyField31<MP>
where MP: Copy + MontyParameters,

Source§

impl<MP> Eq for MontyField31<MP>
where MP: Eq + MontyParameters,

Source§

impl<FP> Packable for MontyField31<FP>
where FP: FieldParameters,

Source§

impl<MP> StructuralPartialEq for MontyField31<MP>
where MP: MontyParameters,