F

Struct F 

Source
pub struct F(/* private fields */);
Expand description

An element of the Goldilocks field.

Implementations§

Source§

impl F

Source

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.

Source

pub const NOT_ROOT_OF_UNITY: Self

An element guaranteed not to be any power of Self::ROOT_OF_UNITY.

Source

pub const NOT_ROOT_OF_UNITY_INV: Self

The inverse of Self::NOT_ROOT_OF_UNITY.

Source

pub fn inv(self) -> Self

Return the multiplicative inverse of a field element.

Self::zero will return Self::zero.

Source

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.

Source

pub fn div_2(self) -> Self

Return self / 2.

Source

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.

Source

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.

Source

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.

Source

pub const fn to_le_bytes(&self) -> [u8; 8]

Convert this element to little-endian bytes.

Source

pub fn rand(rng: impl CryptoRngCore) -> Self

Create a random field element.

This will be uniformly distributed.

Trait Implementations§

Source§

impl<'a> Add<&'a F> for F

Source§

type Output = F

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'a F) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for F

Source§

type Output = F

The resulting type after applying the + operator.
Source§

fn add(self, b: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> AddAssign<&'a F> for F

Source§

fn add_assign(&mut self, rhs: &'a F)

Performs the += operation. Read more
Source§

impl Additive for F

Source§

fn zero() -> Self

The neutral element for addition.
Source§

fn double(&mut self)

Add an element to itself. Read more
Source§

fn scale(&self, bits_le: &[u64]) -> Self

Scale this number by a positive integer. Read more
Source§

impl Clone for F

Source§

fn clone(&self) -> F

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for F

Source§

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

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

impl Field for F

Source§

fn inv(&self) -> Self

The multiplicative inverse of an element. Read more
Source§

impl FixedSize for F

Source§

const SIZE: usize = 8usize

The size of the encoded value (in bytes).
Source§

impl From<u64> for F

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl<'a> Mul<&'a F> for F

Source§

type Output = F

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'a F) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for F

Source§

type Output = F

The resulting type after applying the * operator.
Source§

fn mul(self, b: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> MulAssign<&'a F> for F

Source§

fn mul_assign(&mut self, rhs: &'a F)

Performs the *= operation. Read more
Source§

impl Multiplicative for F

Source§

fn square(&mut self)

Multiply an element with itself. Read more
Source§

impl Neg for F

Source§

type Output = F

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for F

Source§

fn eq(&self, other: &F) -> bool

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

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 Read for F

Source§

type Cfg = <u64 as Read>::Cfg

The Cfg type parameter allows passing configuration during the read process. This is crucial for safely decoding untrusted data, for example, by providing size limits for collections or strings. Read more
Source§

fn read_cfg(buf: &mut impl Buf, cfg: &Self::Cfg) -> Result<Self, Error>

Reads a value from the buffer using the provided configuration cfg. Read more
Source§

impl Ring for F

Source§

fn one() -> Self

The neutral element for multiplication. Read more
Source§

fn exp(&self, bits_le: &[u64]) -> Self

Exponentiate this number by a positive integer. Read more
Source§

impl<'a> Sub<&'a F> for F

Source§

type Output = F

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'a F) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for F

Source§

type Output = F

The resulting type after applying the - operator.
Source§

fn sub(self, b: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> SubAssign<&'a F> for F

Source§

fn sub_assign(&mut self, rhs: &'a F)

Performs the -= operation. Read more
Source§

impl Write for F

Source§

fn write(&self, buf: &mut impl BufMut)

Writes the binary representation of self to the provided buffer buf. Read more
Source§

impl Copy for F

Source§

impl Eq for F

Source§

impl Object for F

Source§

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> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Decode for T
where T: Read,

Source§

fn decode_cfg(buf: impl Buf, cfg: &Self::Cfg) -> Result<Self, Error>

Decodes a value from buf using cfg, ensuring the entire buffer is consumed. Read more
Source§

impl<X, T> DecodeExt<X> for T
where X: IsUnit, T: Decode<Cfg = X>,

Source§

fn decode(buf: impl Buf) -> Result<Self, Error>

Decodes a value using the default () config.
Source§

impl<T> Encode for T
where T: Write + EncodeSize,

Source§

fn encode(&self) -> BytesMut

Encodes self into a new BytesMut buffer. Read more
Source§

impl<T> EncodeFixed for T
where T: Write + FixedSize,

Source§

fn encode_fixed<const N: usize>(&self) -> [u8; N]

Encodes self into a fixed-size byte array [u8; N]. Read more
Source§

impl<T> EncodeSize for T
where T: FixedSize,

Source§

fn encode_size(&self) -> usize

Returns the encoded size of this value (in bytes).
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ReadExt for T
where T: Read<Cfg = ()>,

Source§

fn read(buf: &mut impl Buf) -> Result<Self, Error>

Reads a value using the default () config.
Source§

impl<R> Space<R> for R

Source§

fn msm(points: &[Self], scalars: &[R], _concurrency: usize) -> Self

Calculate sum_i points[i] * scalars[i]. Read more
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Codec for T
where T: Encode + Decode,

Source§

impl<T> CodecFixed for T
where T: Codec + FixedSize,