pub struct F(/* private fields */);Expand description
An element of the Goldilocks field.
Implementations§
Source§impl F
impl F
Sourcepub const ROOT_OF_UNITY: Self
pub const ROOT_OF_UNITY: Self
An element of order 2^32.
This is specifically chosen such that ROOT_OF_UNITY^(2^26) = 8.
That enables optimizations when doing NTTs, and things like that.
Sourcepub const NOT_ROOT_OF_UNITY: Self
pub const NOT_ROOT_OF_UNITY: Self
An element guaranteed not to be any power of Self::ROOT_OF_UNITY.
Sourcepub const NOT_ROOT_OF_UNITY_INV: Self
pub const NOT_ROOT_OF_UNITY_INV: Self
The inverse of Self::NOT_ROOT_OF_UNITY.
Sourcepub fn inv(self) -> Self
pub fn inv(self) -> Self
Return the multiplicative inverse of a field element.
Self::zero will return Self::zero.
Sourcepub fn stream_from_u64s(
inner: impl Iterator<Item = u64>,
) -> impl Iterator<Item = Self>
pub fn stream_from_u64s( inner: impl Iterator<Item = u64>, ) -> impl Iterator<Item = Self>
Convert a stream of u64s into a stream of field elements.
Sourcepub fn stream_to_u64s(
inner: impl Iterator<Item = Self>,
) -> impl Iterator<Item = u64>
pub fn stream_to_u64s( inner: impl Iterator<Item = Self>, ) -> impl Iterator<Item = u64>
Convert a stream produced by F::stream_from_u64s back to the original stream.
This may produce a single extra 0 element.
Sourcepub const fn bits_to_elements(bits: usize) -> usize
pub const fn bits_to_elements(bits: usize) -> usize
How many elements are used to encode a given number of bits?
This is based on what F::stream_from_u64s does.
Sourcepub const fn to_le_bytes(&self) -> [u8; 8]
pub const fn to_le_bytes(&self) -> [u8; 8]
Convert this element to little-endian bytes.
Trait Implementations§
Source§impl<'a> AddAssign<&'a F> for F
impl<'a> AddAssign<&'a F> for F
Source§fn add_assign(&mut self, rhs: &'a Self)
fn add_assign(&mut self, rhs: &'a Self)
Performs the
+= operation. Read moreSource§impl FieldNTT for F
impl FieldNTT for F
Source§const MAX_LG_ROOT_ORDER: u8 = 32
const MAX_LG_ROOT_ORDER: u8 = 32
The maximum (lg) of the power of two root of unity this fields supports.
Source§fn coset_shift() -> Self
fn coset_shift() -> Self
An element which is not a power of a root of unity. Read more
fn coset_shift_inv() -> Self
Source§impl<'a> MulAssign<&'a F> for F
impl<'a> MulAssign<&'a F> for F
Source§fn mul_assign(&mut self, rhs: &'a Self)
fn mul_assign(&mut self, rhs: &'a Self)
Performs the
*= operation. Read moreSource§impl Multiplicative for F
impl Multiplicative for F
Source§impl Random for F
impl Random for F
Source§fn random(rng: impl CryptoRngCore) -> Self
fn random(rng: impl CryptoRngCore) -> Self
Sample an object uniformly at random.
Source§impl Read for F
impl Read for F
Source§impl<'a> SubAssign<&'a F> for F
impl<'a> SubAssign<&'a F> for F
Source§fn sub_assign(&mut self, rhs: &'a Self)
fn sub_assign(&mut self, rhs: &'a Self)
Performs the
-= operation. Read moreimpl Copy for F
impl Eq for F
impl Object for F
impl StructuralPartialEq for F
Auto Trait Implementations§
impl Freeze for F
impl RefUnwindSafe for F
impl Send for F
impl Sync for F
impl Unpin for F
impl UnsafeUnpin for F
impl UnwindSafe for F
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Encode for Twhere
T: Write + EncodeSize,
impl<T> Encode for Twhere
T: Write + EncodeSize,
Source§impl<T> EncodeFixed for T
impl<T> EncodeFixed for T
Source§impl<T> EncodeSize for Twhere
T: FixedSize,
impl<T> EncodeSize for Twhere
T: FixedSize,
Source§fn encode_size(&self) -> usize
fn encode_size(&self) -> usize
Returns the encoded size of this value (in bytes).
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