Skip to main content

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

Trait Implementations§

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> Add<&'a F> for F

Source§

type Output = F

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

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

Source§

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

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 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for F

Source§

impl Debug for F

Source§

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

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

impl Eq for F

Source§

impl Field for F

Source§

fn inv(&self) -> Self

The multiplicative inverse of an element. Read more
Source§

impl FieldNTT for F

Source§

const MAX_LG_ROOT_ORDER: u8 = 32

The maximum (lg) of the power of two root of unity this fields supports.
Source§

fn root_of_unity(lg: u8) -> Option<Self>

A root of unity of order 2^lg. Read more
Source§

fn coset_shift() -> Self

An element which is not a power of a root of unity. Read more
Source§

fn coset_shift_inv() -> Self

Source§

fn div_2(&self) -> Self

Return the result of dividing this element by 2. Read more
Source§

impl FixedSize for F

Source§

const SIZE: usize = u64::SIZE

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 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> Mul<&'a F> for F

Source§

type Output = F

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

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

Source§

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

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

Source§

impl PartialEq for F

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Random for F

Source§

fn random(rng: impl CryptoRng) -> Self

Sample an object uniformly at random.
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 StructuralPartialEq for F

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> Sub<&'a F> for F

Source§

type Output = F

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

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

Source§

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

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§

fn write_bufs(&self, buf: &mut impl BufsMut)

Writes to a BufsMut, allowing existing Bytes chunks to be appended via BufsMut::push instead of written inline. Must encode to the same format as Write::write. Defaults to Write::write.

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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> Codec for T
where T: Encode + Decode,

Source§

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

Source§

impl<T> CodecFixedShared for T
where T: CodecFixed<Cfg = ()> + Send + Sync,

Source§

impl<T> CodecShared for T
where T: Codec + Send + Sync,

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> DecodeFixed for T
where T: Read<Cfg = ()> + FixedSize,

Source§

fn decode_fixed<const N: usize>(bytes: [u8; N]) -> Result<Self, Error>

Decodes a value from a fixed-size byte array [u8; N], ensuring all bytes are consumed. Read more
Source§

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

Source§

fn encode(&self) -> Bytes

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

fn encode_mut(&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> EncodeShared for T
where T: Encode + Send + Sync,

Source§

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

Source§

fn encode_size(&self) -> usize

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

fn encode_size_slice(values: &[T]) -> usize
where T: Sized,

Source§

fn encode_inline_size_slice(values: &[T]) -> usize
where T: Sized,

Source§

fn encode_inline_size(&self) -> usize

Returns the encoded size excluding bytes passed to BufsMut::push during Write::write_bufs. Used to size the working buffer for inline writes. Override alongside Write::write_bufs for types where large Bytes fields go via push; failing to do so will over-allocate.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

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], _strategy: &impl ParStrategy) -> Self

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

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more