pub struct Goldilocks { /* private fields */ }
Expand description
The prime field known as Goldilocks, defined as F_p
where p = 2^64 - 2^32 + 1
.
Note that the safety of deriving Serialize
and Deserialize
relies on the fact that the internal value can be any u64.
Trait Implementations§
Source§impl Add for Goldilocks
impl Add for Goldilocks
Source§impl AddAssign for Goldilocks
impl AddAssign for Goldilocks
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moreSource§impl BinomiallyExtendable<2> for Goldilocks
impl BinomiallyExtendable<2> for Goldilocks
Source§impl Clone for Goldilocks
impl Clone for Goldilocks
Source§fn clone(&self) -> Goldilocks
fn clone(&self) -> Goldilocks
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Convolve<Goldilocks, i128, i64, i128> for SmallConvolveGoldilocks
impl Convolve<Goldilocks, i128, i64, i128> for SmallConvolveGoldilocks
Source§fn read(input: Goldilocks) -> i128
fn read(input: Goldilocks) -> i128
Return the lift of a Goldilocks element, 0 <= input.value <= P < 2^64. We widen immediately, since some valid Goldilocks elements don’t fit in an i64, and since in any case overflow can occur for even the smallest convolutions.
Source§fn parity_dot<const N: usize>(u: [i128; N], v: [i64; N]) -> i128
fn parity_dot<const N: usize>(u: [i128; N], v: [i64; N]) -> i128
For a convolution of size N, |x| < N * 2^64 and (as per the
assumption above), |y| < 2^51. So the product is at most N *
2^115 which will not overflow for N <= 16. We widen y
at
this point to perform the multiplication.
Source§fn reduce(z: i128) -> Goldilocks
fn reduce(z: i128) -> Goldilocks
The assumptions above mean z < N^2 * 2^115, which is at most 2^123 when N <= 16.
NB: Even though intermediate values could be negative, the output must be non-negative since the inputs were non-negative.
fn conv3(lhs: [T; 3], rhs: [U; 3], output: &mut [V])
fn negacyclic_conv3(lhs: [T; 3], rhs: [U; 3], output: &mut [V])
fn conv4(lhs: [T; 4], rhs: [U; 4], output: &mut [V])
fn negacyclic_conv4(lhs: [T; 4], rhs: [U; 4], output: &mut [V])
fn conv6(lhs: [T; 6], rhs: [U; 6], output: &mut [V])
fn negacyclic_conv6(lhs: [T; 6], rhs: [U; 6], output: &mut [V])
fn conv8(lhs: [T; 8], rhs: [U; 8], output: &mut [V])
fn negacyclic_conv8(lhs: [T; 8], rhs: [U; 8], output: &mut [V])
fn conv12(lhs: [T; 12], rhs: [U; 12], output: &mut [V])
fn negacyclic_conv12(lhs: [T; 12], rhs: [U; 12], output: &mut [V])
fn conv16(lhs: [T; 16], rhs: [U; 16], output: &mut [V])
fn negacyclic_conv16(lhs: [T; 16], rhs: [U; 16], output: &mut [V])
fn conv24(lhs: [T; 24], rhs: [U; 24], output: &mut [V])
fn conv32(lhs: [T; 32], rhs: [U; 32], output: &mut [V])
fn negacyclic_conv32(lhs: [T; 32], rhs: [U; 32], output: &mut [V])
fn conv64(lhs: [T; 64], rhs: [U; 64], output: &mut [V])
Source§impl Debug for Goldilocks
impl Debug for Goldilocks
Source§impl Default for Goldilocks
impl Default for Goldilocks
Source§fn default() -> Goldilocks
fn default() -> Goldilocks
Source§impl<'de> Deserialize<'de> for Goldilocks
impl<'de> Deserialize<'de> for Goldilocks
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for Goldilocks
impl Display for Goldilocks
Source§impl Distribution<Goldilocks> for Standard
impl Distribution<Goldilocks> for Standard
Source§impl Div for Goldilocks
impl Div for Goldilocks
Source§impl Field for Goldilocks
impl Field for Goldilocks
type Packing = Goldilocks
fn is_zero(&self) -> bool
Source§fn exp_u64_generic<FA: FieldAlgebra<F = Self>>(val: FA, power: u64) -> FA
fn exp_u64_generic<FA: FieldAlgebra<F = Self>>(val: FA, power: u64) -> FA
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<Self>
fn try_inverse(&self) -> Option<Self>
Source§fn halve(&self) -> Self
fn halve(&self) -> Self
fn order() -> BigUint
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 FieldAlgebra for Goldilocks
impl FieldAlgebra for Goldilocks
type F = Goldilocks
Source§fn from_f(f: Self::F) -> Self
fn from_f(f: Self::F) -> Self
Source§fn from_canonical_u8(n: u8) -> Self
fn from_canonical_u8(n: u8) -> Self
u8
. Read moreSource§fn from_canonical_u16(n: u16) -> Self
fn from_canonical_u16(n: u16) -> Self
u16
. Read moreSource§fn from_canonical_u32(n: u32) -> Self
fn from_canonical_u32(n: u32) -> Self
u32
. Read moreSource§fn from_canonical_u64(n: u64) -> Self
fn from_canonical_u64(n: u64) -> Self
u64
. Read moreSource§fn from_canonical_usize(n: usize) -> Self
fn from_canonical_usize(n: usize) -> Self
usize
. Read morefn from_wrapped_u32(n: u32) -> Self
fn from_wrapped_u64(n: u64) -> Self
Source§fn zero_vec(len: usize) -> Vec<Self>
fn zero_vec(len: usize) -> Vec<Self>
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 mul_2exp_u64(&self, exp: u64) -> Self
fn mul_2exp_u64(&self, exp: u64) -> 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 HasTwoAdicBinomialExtension<2> for Goldilocks
impl HasTwoAdicBinomialExtension<2> for Goldilocks
const EXT_TWO_ADICITY: usize = 33usize
Source§fn ext_two_adic_generator(bits: usize) -> [Self; 2]
fn ext_two_adic_generator(bits: usize) -> [Self; 2]
bits
powers of two, otherwise the
behavior is undefined.Source§impl Hash for Goldilocks
impl Hash for Goldilocks
Source§impl Mul for Goldilocks
impl Mul for Goldilocks
Source§impl MulAssign for Goldilocks
impl MulAssign for Goldilocks
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*=
operation. Read moreSource§impl Neg for Goldilocks
impl Neg for Goldilocks
Source§impl Ord for Goldilocks
impl Ord for Goldilocks
Source§impl PartialEq for Goldilocks
impl PartialEq for Goldilocks
Source§impl PartialOrd for Goldilocks
impl PartialOrd for Goldilocks
Source§impl PrimeField for Goldilocks
impl PrimeField for Goldilocks
fn as_canonical_biguint(&self) -> BigUint
Source§impl PrimeField64 for Goldilocks
impl PrimeField64 for Goldilocks
const ORDER_U64: u64 = 18_446_744_069_414_584_321u64
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 Product for Goldilocks
impl Product for Goldilocks
Source§impl Serialize for Goldilocks
impl Serialize for Goldilocks
Source§impl Sub for Goldilocks
impl Sub for Goldilocks
Source§impl SubAssign for Goldilocks
impl SubAssign for Goldilocks
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read moreSource§impl Sum for Goldilocks
impl Sum for Goldilocks
Source§impl TwoAdicField for Goldilocks
impl TwoAdicField for Goldilocks
Source§const TWO_ADICITY: usize = 32usize
const TWO_ADICITY: usize = 32usize
Source§fn two_adic_generator(bits: usize) -> Self
fn two_adic_generator(bits: usize) -> Self
2^bits
.
Assumes bits <= TWO_ADICITY
, otherwise the result is undefined.impl Copy for Goldilocks
impl Eq for Goldilocks
impl MdsPermutation<Goldilocks, 12> for MdsMatrixGoldilocks
impl MdsPermutation<Goldilocks, 16> for MdsMatrixGoldilocks
impl MdsPermutation<Goldilocks, 24> for MdsMatrixGoldilocks
impl MdsPermutation<Goldilocks, 32> for MdsMatrixGoldilocks
impl MdsPermutation<Goldilocks, 64> for MdsMatrixGoldilocks
impl MdsPermutation<Goldilocks, 68> for MdsMatrixGoldilocks
impl MdsPermutation<Goldilocks, 8> for MdsMatrixGoldilocks
impl Packable for Goldilocks
Auto Trait Implementations§
impl Freeze for Goldilocks
impl RefUnwindSafe for Goldilocks
impl Send for Goldilocks
impl Sync for Goldilocks
impl Unpin for Goldilocks
impl UnwindSafe for Goldilocks
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F> ExtensionField<F> for Fwhere
F: Field,
impl<F> ExtensionField<F> for Fwhere
F: Field,
type ExtensionPacking = <F as Field>::Packing
fn is_in_basefield(&self) -> bool
fn as_base(&self) -> Option<Base>
Source§fn ext_powers_packed(&self) -> Powers<Self::ExtensionPacking>
fn ext_powers_packed(&self) -> Powers<Self::ExtensionPacking>
Source§impl<FA> FieldExtensionAlgebra<FA> for FAwhere
FA: FieldAlgebra,
impl<FA> FieldExtensionAlgebra<FA> for FAwhere
FA: FieldAlgebra,
const D: usize = 1usize
fn from_base(b: FA) -> FA
Source§fn from_base_slice(bs: &[FA]) -> FA
fn from_base_slice(bs: &[FA]) -> FA
Base
and f is an irreducible
polynomial of degree D
. This function takes a slice bs
of
length at exactly D, and constructs the field element
\sum_i bs[i] * X^i. Read morefn from_base_iter<I>(iter: I) -> FAwhere
I: Iterator<Item = FA>,
Source§fn from_base_fn<F>(f: F) -> FA
fn from_base_fn<F>(f: F) -> FA
core:array::from_fn
, with the same caveats as
from_base_slice
.Source§fn as_base_slice(&self) -> &[FA]
fn as_base_slice(&self) -> &[FA]
Base
and f is an irreducible
polynomial of degree D
. This function takes a field element
\sum_i bs[i] * X^i and returns the coefficients as a slice
bs
of length at most D containing, from lowest degree to
highest. Read moreSource§fn monomial(exponent: usize) -> Self
fn monomial(exponent: usize) -> Self
Base
and f is an irreducible
polynomial of degree D
. This function returns the field
element X^exponent
if exponent < D
and panics otherwise.
(The fact that f is not known at the point that this function
is defined prevents implementing exponentiation of higher
powers since the reduction cannot be performed.) Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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