../../.cargo/katex-header.html

Struct winter_math::fields::f128::BaseElement

source ·
pub struct BaseElement(/* private fields */);
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§

source§

impl BaseElement

source

pub const fn new(value: u128) -> Self

Creates a new field element from a u128 value. If the value is greater than or equal to the field modulus, modular reduction is silently performed. This function can also be used to initialize constants.

Trait Implementations§

source§

impl Add for BaseElement

§

type Output = BaseElement

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
source§

impl AddAssign for BaseElement

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl AsBytes for BaseElement

source§

fn as_bytes(&self) -> &[u8]

Returns a byte representation of self. Read more
source§

impl Clone for BaseElement

source§

fn clone(&self) -> BaseElement

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for BaseElement

source§

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

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

impl Default for BaseElement

source§

fn default() -> BaseElement

Returns the “default value” for a type. Read more
source§

impl Deserializable for BaseElement

source§

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

fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result. Read more
source§

impl Display for BaseElement

source§

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

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

impl Div for BaseElement

§

type Output = BaseElement

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self

Performs the / operation. Read more
source§

impl DivAssign for BaseElement

source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
source§

impl ExtensibleField<2> 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.

source§

fn mul(a: [Self; 2], b: [Self; 2]) -> [Self; 2]

Returns a product of a and b in the field defined by this extension.
source§

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

fn frobenius(x: [Self; 2]) -> [Self; 2]

Returns Frobenius automorphisms for x in the field defined by this extension.
source§

fn square(a: [Self; N]) -> [Self; N]

Returns the square of a in the field defined by this extension.
source§

fn is_supported() -> bool

Returns true if this extension is supported for the underlying base field.
source§

impl ExtensibleField<3> for BaseElement

Cubic extension for this field is not implemented as quadratic extension already provides sufficient security level.

source§

fn mul(_a: [Self; 3], _b: [Self; 3]) -> [Self; 3]

Returns a product of a and b in the field defined by this extension.
source§

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

fn frobenius(_x: [Self; 3]) -> [Self; 3]

Returns Frobenius automorphisms for x in the field defined by this extension.
source§

fn is_supported() -> bool

Returns true if this extension is supported for the underlying base field.
source§

fn square(a: [Self; N]) -> [Self; N]

Returns the square of a in the field defined by this extension.
source§

impl FieldElement for BaseElement

§

type PositiveInteger = u128

A type defining positive integers big enough to describe a field modulus for Self::BaseField with no loss of precision.
§

type BaseField = BaseElement

Base field type for this finite field. For prime fields, BaseField should be set to Self.
source§

const EXTENSION_DEGREE: usize = 1usize

Extension degree of this field with respect to Self::BaseField. For prime fields, extension degree should be set to 1.
source§

const ZERO: Self = _

The additive identity.
source§

const ONE: Self = _

The multiplicative identity.
source§

const ELEMENT_BYTES: usize = 16usize

Number of bytes needed to encode an element
source§

const IS_CANONICAL: bool = true

True if internal representation of the element is the same as its canonical representation.
source§

fn inv(self) -> Self

Returns a multiplicative inverse of this field element. If this element is ZERO, ZERO is returned.
source§

fn conjugate(&self) -> Self

Returns a conjugate of this field element.
source§

fn base_element(&self, i: usize) -> Self::BaseField

Return base filed element component of this field element at the specified index i. Read more
source§

fn slice_as_base_elements(elements: &[Self]) -> &[Self::BaseField]

Converts a slice of field elements into a slice of elements in the underlying base field. Read more
source§

fn slice_from_base_elements(elements: &[Self::BaseField]) -> &[Self]

Convert a slice of base field elements into a slice of field elements. Read more
source§

fn elements_as_bytes(elements: &[Self]) -> &[u8]

Converts a list of elements into a list of bytes. Read more
source§

unsafe fn bytes_as_elements( bytes: &[u8] ) -> Result<&[Self], DeserializationError>

Converts a list of bytes into a list of field elements. Read more
source§

fn double(self) -> Self

Returns this field element added to itself.
source§

fn square(self) -> Self

Returns this field element raised to power 2.
source§

fn cube(self) -> Self

Returns this field element raised to power 3.
source§

fn exp(self, power: Self::PositiveInteger) -> Self

Exponentiates this field element by power parameter.
source§

fn exp_vartime(self, power: Self::PositiveInteger) -> Self

Exponentiates this field element by power parameter. This function is expressly variable time, to speed-up verifier computations.
source§

impl From<u16> for BaseElement

source§

fn from(value: u16) -> Self

Converts a 16-bit value into a field element.

source§

impl From<u32> for BaseElement

source§

fn from(value: u32) -> Self

Converts a 32-bit value into a field element.

source§

impl From<u64> for BaseElement

source§

fn from(value: u64) -> Self

Converts a 64-bit value into a field element.

source§

impl From<u8> for BaseElement

source§

fn from(value: u8) -> Self

Converts an 8-bit value into a field element.

source§

impl Mul for BaseElement

§

type Output = BaseElement

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
source§

impl MulAssign for BaseElement

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl Neg for BaseElement

§

type Output = BaseElement

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl PartialEq for BaseElement

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Randomizable for BaseElement

source§

const VALUE_SIZE: usize = 16usize

Size of Self in bytes. Read more
source§

fn from_random_bytes(bytes: &[u8]) -> Option<Self>

Returns Self if the set of bytes forms a valid value, otherwise returns None.
source§

impl Serializable for BaseElement

source§

fn write_into<W: ByteWriter>(&self, target: &mut W)

Serializes self into bytes and writes these bytes into the target.
source§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
source§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. Read more
source§

impl StarkField for BaseElement

source§

const MODULUS: Self::PositiveInteger = {transmute(0xffffffffffffffffffffd30000000001): <field::f128::BaseElement as field::traits::FieldElement>::PositiveInteger}

sage: MODULUS = 2^128 - 45 * 2^40 + 1
sage: GF(MODULUS).is_prime_field()
True
sage: GF(MODULUS).order()
340282366920938463463374557953744961537

source§

const GENERATOR: Self = _

sage: GF(MODULUS).primitive_element()
3

source§

const TWO_ADICITY: u32 = 40u32

sage: is_odd((MODULUS - 1) / 2^40)
True

source§

const TWO_ADIC_ROOT_OF_UNITY: Self = _

sage: k = (MODULUS - 1) / 2^40
sage: GF(MODULUS).primitive_element()^k
23953097886125630542083529559205016746

source§

const MODULUS_BITS: u32 = 128u32

The number of bits needed to represents Self::MODULUS.
source§

fn get_modulus_le_bytes() -> Vec<u8>

Returns byte representation of the field modulus in little-endian byte order.
source§

fn as_int(&self) -> Self::PositiveInteger

Returns a canonical integer representation of this field element.
source§

fn get_root_of_unity(n: u32) -> Self

Returns the root of unity of order 2^n. Read more
source§

fn from_bytes_with_padding(bytes: &[u8]) -> Self

Converts a slice of bytes into a field element. Pads the slice if it is smaller than the number of bytes needed to represent an element. Read more
source§

impl Sub for BaseElement

§

type Output = BaseElement

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
source§

impl SubAssign for BaseElement

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl<'a> TryFrom<&'a [u8]> for BaseElement

source§

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>

Converts a slice of bytes into a field element; returns error if the value encoded in bytes is not a valid field element. The bytes are assumed to be in little-endian byte order.

§

type Error = String

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

impl TryFrom<u128> for BaseElement

§

type Error = String

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

fn try_from(value: u128) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for BaseElement

source§

impl Eq for BaseElement

source§

impl StructuralPartialEq for BaseElement

Auto Trait Implementations§

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<E> ExtensionOf<E> for E
where E: FieldElement,

source§

fn mul_base(self, other: E) -> E

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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<E> ToElements<E> for E
where E: FieldElement,

source§

fn to_elements(&self) -> Vec<E>

source§

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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

§

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.