Struct winter_math::fields::f128::BaseElement
source · [−]pub struct BaseElement(_);Expand description
Represents a base field element.
Internal values are stored in their canonical form in the range [0, M). The backing type is
u128.
Implementations
sourceimpl BaseElement
impl BaseElement
Trait Implementations
sourceimpl Add<BaseElement> for BaseElement
impl Add<BaseElement> for BaseElement
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the + operator.
sourceimpl AddAssign<BaseElement> for BaseElement
impl AddAssign<BaseElement> for BaseElement
sourcefn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the += operation. Read more
sourceimpl AsBytes for BaseElement
impl AsBytes for BaseElement
sourceimpl Clone for BaseElement
impl Clone for BaseElement
sourcefn clone(&self) -> BaseElement
fn clone(&self) -> BaseElement
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for BaseElement
impl Debug for BaseElement
sourceimpl Default for BaseElement
impl Default for BaseElement
sourcefn default() -> BaseElement
fn default() -> BaseElement
Returns the “default value” for a type. Read more
sourceimpl Deserializable for BaseElement
impl Deserializable for BaseElement
sourcefn read_from<R: ByteReader>(
source: &mut R
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>(
source: &mut R
) -> Result<Self, DeserializationError>
Reads a sequence of bytes from the provided source, attempts to deserialize these bytes
into Self, and returns the result. Read more
sourcefn read_batch_from<R>(
source: &mut R,
num_elements: usize
) -> Result<Vec<Self, Global>, DeserializationError> where
R: ByteReader,
fn read_batch_from<R>(
source: &mut R,
num_elements: usize
) -> Result<Vec<Self, Global>, DeserializationError> where
R: ByteReader,
Reads a sequence of bytes from the provided source, attempts to deserialize these bytes
into a vector with the specified number of Self elements, and returns the result. Read more
sourceimpl Display for BaseElement
impl Display for BaseElement
sourceimpl Div<BaseElement> for BaseElement
impl Div<BaseElement> for BaseElement
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the / operator.
sourceimpl DivAssign<BaseElement> for BaseElement
impl DivAssign<BaseElement> for BaseElement
sourcefn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the /= operation. Read more
sourceimpl ExtensibleField<2_usize> for BaseElement
impl ExtensibleField<2_usize> for BaseElement
Defines a quadratic extension of the base field over an irreducible polynomial x2 - x - 1. Thus, an extension element is defined as α + β * φ, where φ is a root of this polynomial, and α and β are base field elements.
sourcefn mul(a: [Self; 2], b: [Self; 2]) -> [Self; 2]
fn mul(a: [Self; 2], b: [Self; 2]) -> [Self; 2]
Returns a product of a and b in the field defined by this extension.
sourcefn mul_base(a: [Self; 2], b: Self) -> [Self; 2]
fn mul_base(a: [Self; 2], b: Self) -> [Self; 2]
Returns a product of a and b in the field defined by this extension. b represents
an element in the base field. Read more
sourcefn frobenius(x: [Self; 2]) -> [Self; 2]
fn frobenius(x: [Self; 2]) -> [Self; 2]
Returns Frobenius automorphisms for x in the field defined by this extension.
sourcefn is_supported() -> bool
fn is_supported() -> bool
Returns true if this extension is supported for the underlying base field.
sourceimpl ExtensibleField<3_usize> for BaseElement
impl ExtensibleField<3_usize> for BaseElement
Cubic extension for this field is not implemented as quadratic extension already provides sufficient security level.
sourcefn mul(_a: [Self; 3], _b: [Self; 3]) -> [Self; 3]
fn mul(_a: [Self; 3], _b: [Self; 3]) -> [Self; 3]
Returns a product of a and b in the field defined by this extension.
sourcefn mul_base(_a: [Self; 3], _b: Self) -> [Self; 3]
fn mul_base(_a: [Self; 3], _b: Self) -> [Self; 3]
Returns a product of a and b in the field defined by this extension. b represents
an element in the base field. Read more
sourcefn frobenius(_x: [Self; 3]) -> [Self; 3]
fn frobenius(_x: [Self; 3]) -> [Self; 3]
Returns Frobenius automorphisms for x in the field defined by this extension.
sourcefn is_supported() -> bool
fn is_supported() -> bool
Returns true if this extension is supported for the underlying base field.
sourceimpl FieldElement for BaseElement
impl FieldElement for BaseElement
type PositiveInteger = u128
type PositiveInteger = u128
A type defining positive integers big enough to describe a field modulus for
Self::BaseField with no loss of precision. Read more
type BaseField = BaseElement
type BaseField = BaseElement
Base field type for this finite field. For prime fields, BaseField should be set
to Self. Read more
sourceconst ELEMENT_BYTES: usize = 16usize
const ELEMENT_BYTES: usize = 16usize
Number of bytes needed to encode an element
sourceconst IS_CANONICAL: bool = true
const IS_CANONICAL: bool = true
True if internal representation of the element is the same as its canonical representation.
sourcefn inv(self) -> Self
fn inv(self) -> Self
Returns a multiplicative inverse of this field element. If this element is ZERO, ZERO is returned. Read more
sourcefn elements_as_bytes(elements: &[Self]) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
fn elements_as_bytes(elements: &[Self]) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Converts a list of elements into a list of bytes. Read more
sourceunsafe fn bytes_as_elements(
bytes: &[u8]
) -> Result<&[Self], DeserializationError>
unsafe fn bytes_as_elements(
bytes: &[u8]
) -> Result<&[Self], DeserializationError>
Converts a list of bytes into a list of field elements. Read more
sourcefn zeroed_vector(n: usize) -> Vec<Self>
fn zeroed_vector(n: usize) -> Vec<Self>
Returns a vector of length n initialized with all ZERO elements. Read more
sourcefn as_base_elements(elements: &[Self]) -> &[Self::BaseField]
fn as_base_elements(elements: &[Self]) -> &[Self::BaseField]
Converts a list of field elements into a list of elements in the underlying base field. Read more
sourcefn exp(self, power: Self::PositiveInteger) -> Self
fn exp(self, power: Self::PositiveInteger) -> Self
Exponentiates this field element by power parameter.
sourceimpl From<u128> for BaseElement
impl From<u128> for BaseElement
sourceimpl From<u16> for BaseElement
impl From<u16> for BaseElement
sourceimpl From<u32> for BaseElement
impl From<u32> for BaseElement
sourceimpl From<u64> for BaseElement
impl From<u64> for BaseElement
sourceimpl From<u8> for BaseElement
impl From<u8> for BaseElement
sourceimpl Mul<BaseElement> for BaseElement
impl Mul<BaseElement> for BaseElement
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the * operator.
sourceimpl MulAssign<BaseElement> for BaseElement
impl MulAssign<BaseElement> for BaseElement
sourcefn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the *= operation. Read more
sourceimpl Neg for BaseElement
impl Neg for BaseElement
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the - operator.
sourceimpl PartialEq<BaseElement> for BaseElement
impl PartialEq<BaseElement> for BaseElement
sourcefn eq(&self, other: &BaseElement) -> bool
fn eq(&self, other: &BaseElement) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &BaseElement) -> bool
fn ne(&self, other: &BaseElement) -> bool
This method tests for !=.
sourceimpl Randomizable for BaseElement
impl Randomizable for BaseElement
sourceconst VALUE_SIZE: usize = 16usize
const VALUE_SIZE: usize = 16usize
Size of Self in bytes. Read more
sourceimpl Serializable for BaseElement
impl Serializable for BaseElement
sourcefn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
Serializes self into bytes and writes these bytes into the target.
sourcefn write_batch_into<W>(source: &[Self], target: &mut W) where
W: ByteWriter,
fn write_batch_into<W>(source: &[Self], target: &mut W) where
W: ByteWriter,
Serializes all elements of the source and writes these bytes into the target. Read more
sourcefn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
Returns an estimate of how many bytes are needed to represent self. Read more
sourceimpl StarkField for BaseElement
impl StarkField for BaseElement
sourceconst MODULUS: Self::PositiveInteger = {transmute(0xffffffffffffffffffffd30000000001): ::PositiveInteger}
const MODULUS: Self::PositiveInteger = {transmute(0xffffffffffffffffffffd30000000001): ::PositiveInteger}
sage: MODULUS = 2^128 - 45 * 2^40 + 1
sage: GF(MODULUS).is_prime_field()
True
sage: GF(MODULUS).order()
340282366920938463463374557953744961537
sourceconst TWO_ADICITY: u32 = 40u32
const TWO_ADICITY: u32 = 40u32
sage: is_odd((MODULUS - 1) / 2^40)
True
sourceconst TWO_ADIC_ROOT_OF_UNITY: Self = BaseElement(G)
const TWO_ADIC_ROOT_OF_UNITY: Self = BaseElement(G)
sage: k = (MODULUS - 1) / 2^40
sage: GF(MODULUS).primitive_element()^k
23953097886125630542083529559205016746
sourceconst MODULUS_BITS: u32 = 128u32
const MODULUS_BITS: u32 = 128u32
The number of bits needed to represents Self::MODULUS.
sourcefn get_modulus_le_bytes() -> Vec<u8>
fn get_modulus_le_bytes() -> Vec<u8>
Returns byte representation of the field modulus in little-endian byte order.
sourcefn as_int(&self) -> Self::PositiveInteger
fn as_int(&self) -> Self::PositiveInteger
Returns a canonical integer representation of this field element.
sourcefn get_root_of_unity(n: u32) -> Self
fn get_root_of_unity(n: u32) -> Self
Returns the root of unity of order 2^n. Read more
sourceimpl Sub<BaseElement> for BaseElement
impl Sub<BaseElement> for BaseElement
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the - operator.
sourceimpl SubAssign<BaseElement> for BaseElement
impl SubAssign<BaseElement> for BaseElement
sourcefn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the -= operation. Read more
sourceimpl<'a> TryFrom<&'a [u8]> for BaseElement
impl<'a> TryFrom<&'a [u8]> for BaseElement
impl Copy for BaseElement
impl Eq for BaseElement
impl StructuralEq for BaseElement
impl StructuralPartialEq for BaseElement
Auto Trait Implementations
impl RefUnwindSafe for BaseElement
impl Send for BaseElement
impl Sync for BaseElement
impl Unpin for BaseElement
impl UnwindSafe for BaseElement
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more