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 root_of_unity(lg_k: u8) -> Option<Self>
pub fn root_of_unity(lg_k: u8) -> Option<Self>
Construct a 2^lg_k root of unity.
This will fail for lg_k > 32.
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.
Sourcepub fn rand(rng: impl CryptoRngCore) -> Self
pub fn rand(rng: impl CryptoRngCore) -> Self
Create a random field element.
This will be uniformly distributed.
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 F)
fn add_assign(&mut self, rhs: &'a F)
+= operation. Read moreSource§impl<'a> MulAssign<&'a F> for F
impl<'a> MulAssign<&'a F> for F
Source§fn mul_assign(&mut self, rhs: &'a F)
fn mul_assign(&mut self, rhs: &'a F)
*= operation. Read moreSource§impl Multiplicative for F
impl Multiplicative for F
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 F)
fn sub_assign(&mut self, rhs: &'a F)
-= 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 UnwindSafe for F
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)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
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