Struct winter_math::fields::f64::BaseElement
source · pub struct BaseElement(_);
Expand description
Represents base field element in the field.
Internal values are stored in the range [0, 2^64). The backing type is u64
.
Implementations
sourceimpl BaseElement
impl BaseElement
sourcepub const fn new(value: u64) -> BaseElement
pub const fn new(value: u64) -> BaseElement
Creates a new field element from the provided value
; the value is converted into
Montgomery representation.
sourcepub const fn from_mont(value: u64) -> BaseElement
pub const fn from_mont(value: u64) -> BaseElement
Returns a new field element from the provided ‘value’. Assumes that ‘value’ is already in canonical Montgomery form.
Trait Implementations
sourceimpl Add<BaseElement> for BaseElement
impl Add<BaseElement> for BaseElement
type Output = BaseElement
type Output = BaseElement
+
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)
+=
operation. Read moresourceimpl AsBytes for BaseElement
impl AsBytes for BaseElement
sourceimpl Clone for BaseElement
impl Clone for BaseElement
sourcefn clone(&self) -> BaseElement
fn clone(&self) -> BaseElement
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for BaseElement
impl Debug for BaseElement
sourceimpl Default for BaseElement
impl Default for BaseElement
sourcefn default() -> BaseElement
fn default() -> BaseElement
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>
source
, attempts to deserialize these bytes
into Self
, and returns the result. Read moresourcefn 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,
source
, attempts to deserialize these bytes
into a vector with the specified number of Self
elements, and returns the result. Read moresourceimpl Display for BaseElement
impl Display for BaseElement
sourceimpl Div<BaseElement> for BaseElement
impl Div<BaseElement> for BaseElement
type Output = BaseElement
type Output = BaseElement
/
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)
/=
operation. Read moresourceimpl ExtensibleField<2> for BaseElement
impl ExtensibleField<2> for BaseElement
Defines a quadratic extension of the base field over an irreducible polynomial x2 - x + 2. 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]
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]
a
and b
in the field defined by this extension. b
represents
an element in the base field. Read moresourcefn frobenius(x: [Self; 2]) -> [Self; 2]
fn frobenius(x: [Self; 2]) -> [Self; 2]
x
in the field defined by this extension.sourcefn is_supported() -> bool
fn is_supported() -> bool
sourceimpl ExtensibleField<3> for BaseElement
impl ExtensibleField<3> for BaseElement
Defines a cubic extension of the base field over an irreducible polynomial x3 - x - 1. Thus, an extension element is defined as α + β * φ + γ * φ^2, where φ is a root of this polynomial, and α, β and γ are base field elements.
sourcefn mul(a: [Self; 3], b: [Self; 3]) -> [Self; 3]
fn mul(a: [Self; 3], b: [Self; 3]) -> [Self; 3]
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]
a
and b
in the field defined by this extension. b
represents
an element in the base field. Read moresourcefn frobenius(x: [Self; 3]) -> [Self; 3]
fn frobenius(x: [Self; 3]) -> [Self; 3]
x
in the field defined by this extension.sourcefn is_supported() -> bool
fn is_supported() -> bool
sourceimpl FieldElement for BaseElement
impl FieldElement for BaseElement
type PositiveInteger = u64
type PositiveInteger = u64
Self::BaseField
with no loss of precision. Read moretype BaseField = BaseElement
type BaseField = BaseElement
sourceconst ELEMENT_BYTES: usize = 8usize
const ELEMENT_BYTES: usize = 8usize
sourceconst IS_CANONICAL: bool = false
const IS_CANONICAL: bool = false
sourcefn exp(self, power: Self::PositiveInteger) -> Self
fn exp(self, power: Self::PositiveInteger) -> Self
power
parameter.sourcefn inv(self) -> Self
fn inv(self) -> Self
sourcefn elements_as_bytes(elements: &[Self]) -> &[u8] ⓘ
fn elements_as_bytes(elements: &[Self]) -> &[u8] ⓘ
sourceunsafe fn bytes_as_elements(
bytes: &[u8]
) -> Result<&[Self], DeserializationError>
unsafe fn bytes_as_elements(
bytes: &[u8]
) -> Result<&[Self], DeserializationError>
sourcefn zeroed_vector(n: usize) -> Vec<Self>
fn zeroed_vector(n: usize) -> Vec<Self>
n
initialized with all ZERO elements. Read moresourcefn as_base_elements(elements: &[Self]) -> &[Self::BaseField]
fn as_base_elements(elements: &[Self]) -> &[Self::BaseField]
sourceimpl From<[u8; 8]> for BaseElement
impl From<[u8; 8]> for BaseElement
sourcefn from(bytes: [u8; 8]) -> Self
fn from(bytes: [u8; 8]) -> Self
Converts the value encoded in an array of 8 bytes into a field element. The bytes are assumed to encode the element in the canonical representation in little-endian byte order. If the value is greater than or equal to the field modulus, modular reduction is silently performed.
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
*
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)
*=
operation. Read moresourceimpl Neg for BaseElement
impl Neg for BaseElement
type Output = BaseElement
type Output = BaseElement
-
operator.sourceimpl PartialEq<BaseElement> for BaseElement
impl PartialEq<BaseElement> for BaseElement
sourceimpl Randomizable for BaseElement
impl Randomizable for BaseElement
sourceconst VALUE_SIZE: usize = 8usize
const VALUE_SIZE: usize = 8usize
Self
in bytes. Read moresourcefn from_random_bytes(bytes: &[u8]) -> Option<Self>
fn from_random_bytes(bytes: &[u8]) -> Option<Self>
Self
if the set of bytes forms a valid value, otherwise returns None.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)
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,
sourcefn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
sourceimpl StarkField for BaseElement
impl StarkField for BaseElement
sourceconst MODULUS: Self::PositiveInteger = {transmute(0xffffffff00000001): <field::f64::BaseElement as field::traits::FieldElement>::PositiveInteger}
const MODULUS: Self::PositiveInteger = {transmute(0xffffffff00000001): <field::f64::BaseElement as field::traits::FieldElement>::PositiveInteger}
sage: MODULUS = 2^64 - 2^32 + 1
sage: GF(MODULUS).is_prime_field()
True
sage: GF(MODULUS).order()
18446744069414584321
sourceconst TWO_ADICITY: u32 = 32u32
const TWO_ADICITY: u32 = 32u32
sage: is_odd((MODULUS - 1) / 2^32)
True
sourceconst TWO_ADIC_ROOT_OF_UNITY: Self = _
const TWO_ADIC_ROOT_OF_UNITY: Self = _
sage: k = (MODULUS - 1) / 2^32
sage: GF(MODULUS).primitive_element()^k
1753635133440165772
sourceconst MODULUS_BITS: u32 = 64u32
const MODULUS_BITS: u32 = 64u32
Self::MODULUS
.sourcefn get_modulus_le_bytes() -> Vec<u8>
fn get_modulus_le_bytes() -> Vec<u8>
sourcefn as_int(&self) -> Self::PositiveInteger
fn as_int(&self) -> Self::PositiveInteger
sourcefn get_root_of_unity(n: u32) -> Self
fn get_root_of_unity(n: u32) -> Self
n
. Read moresourceimpl Sub<BaseElement> for BaseElement
impl Sub<BaseElement> for BaseElement
type Output = BaseElement
type Output = BaseElement
-
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)
-=
operation. Read moresourceimpl<'a> TryFrom<&'a [u8]> for BaseElement
impl<'a> TryFrom<&'a [u8]> for BaseElement
sourcefn try_from(bytes: &[u8]) -> Result<Self, Self::Error>
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 encode the element in the canonical representation in little-endian byte order.