Struct miden_processor::BaseElement [−]
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
impl BaseElement
impl BaseElement
pub const fn new(value: u128) -> BaseElement
pub const fn new(value: u128) -> BaseElement
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 preformed. This function can also be used to initialize constants.
Trait Implementations
impl Add<BaseElement> for BaseElement
impl Add<BaseElement> for BaseElement
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the + operator.
pub fn add(self, rhs: BaseElement) -> BaseElement
pub fn add(self, rhs: BaseElement) -> BaseElement
Performs the + operation. Read more
impl AddAssign<BaseElement> for BaseElement
impl AddAssign<BaseElement> for BaseElement
pub fn add_assign(&mut self, rhs: BaseElement)
pub fn add_assign(&mut self, rhs: BaseElement)
Performs the += operation. Read more
impl AsBytes for BaseElement
impl AsBytes for BaseElement
impl Clone for BaseElement
impl Clone for BaseElement
pub fn clone(&self) -> BaseElement
pub fn clone(&self) -> BaseElement
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
impl Debug for BaseElement
impl Debug for BaseElement
impl Default for BaseElement
impl Default for BaseElement
pub fn default() -> BaseElement
pub fn default() -> BaseElement
Returns the “default value” for a type. Read more
impl Deserializable for BaseElement
impl Deserializable for BaseElement
pub fn read_from<R>(source: &mut R) -> Result<BaseElement, DeserializationError> where
R: ByteReader,
pub fn read_from<R>(source: &mut R) -> Result<BaseElement, DeserializationError> where
R: ByteReader,
Reads a sequence of bytes from the provided source, attempts to deserialize these bytes
into Self, and returns the result. Read more
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
impl Display for BaseElement
impl Display for BaseElement
impl Div<BaseElement> for BaseElement
impl Div<BaseElement> for BaseElement
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the / operator.
pub fn div(self, rhs: BaseElement) -> BaseElement
pub fn div(self, rhs: BaseElement) -> BaseElement
Performs the / operation. Read more
impl DivAssign<BaseElement> for BaseElement
impl DivAssign<BaseElement> for BaseElement
pub fn div_assign(&mut self, rhs: BaseElement)
pub fn div_assign(&mut self, rhs: BaseElement)
Performs the /= operation. Read more
impl 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
pub const ZERO: BaseElement
pub const ZERO: BaseElement
The additive identity.
pub const ONE: BaseElement
pub const ONE: BaseElement
The multiplicative identity.
pub const ELEMENT_BYTES: usize
pub const ELEMENT_BYTES: usize
Number of bytes needed to encode an element
pub const IS_CANONICAL: bool
pub const IS_CANONICAL: bool
True if internal representation of the element is the same as its canonical representation.
pub fn inv(self) -> BaseElement
pub fn inv(self) -> BaseElement
Returns a multiplicative inverse of this field element. If this element is ZERO, ZERO is returned. Read more
pub fn conjugate(&self) -> BaseElement
pub fn conjugate(&self) -> BaseElement
Returns a conjugate of this field element.
Converts a list of elements into a list of bytes. Read more
pub unsafe fn bytes_as_elements(
bytes: &[u8]
) -> Result<&[BaseElement], DeserializationError>
pub unsafe fn bytes_as_elements(
bytes: &[u8]
) -> Result<&[BaseElement], DeserializationError>
Converts a list of bytes into a list of field elements. Read more
pub fn zeroed_vector(n: usize) -> Vec<BaseElement, Global>
pub fn zeroed_vector(n: usize) -> Vec<BaseElement, Global>
Returns a vector of length n initialized with all ZERO elements. Read more
pub fn as_base_elements(
elements: &[BaseElement]
) -> &[<BaseElement as FieldElement>::BaseField]ⓘ
pub fn as_base_elements(
elements: &[BaseElement]
) -> &[<BaseElement as FieldElement>::BaseField]ⓘ
Converts a list of field elements into a list of elements in the underlying base field. Read more
fn double(self) -> Self
fn double(self) -> Self
Returns this field element added to itself.
fn square(self) -> Self
fn square(self) -> Self
Returns this field element raised to power 2.
fn cube(self) -> Self
fn cube(self) -> Self
Returns this field element raised to power 3.
fn exp(self, power: Self::PositiveInteger) -> Self
fn exp(self, power: Self::PositiveInteger) -> Self
Exponentiates this field element by power parameter.
impl From<[u8; 16]> for BaseElement
impl From<[u8; 16]> for BaseElement
pub fn from(bytes: [u8; 16]) -> BaseElement
pub fn from(bytes: [u8; 16]) -> BaseElement
Converts the value encoded in an array of 16 bytes into a field element. The bytes are assumed to be in little-endian byte order. If the value is greater than or equal to the field modulus, modular reduction is silently preformed.
impl From<u128> for BaseElement
impl From<u128> for BaseElement
pub fn from(value: u128) -> BaseElement
pub fn from(value: u128) -> BaseElement
Converts a 128-bit value into a filed element. If the value is greater than or equal to the field modulus, modular reduction is silently preformed.
impl From<u16> for BaseElement
impl From<u16> for BaseElement
pub fn from(value: u16) -> BaseElement
pub fn from(value: u16) -> BaseElement
Converts a 16-bit value into a filed element.
impl From<u32> for BaseElement
impl From<u32> for BaseElement
pub fn from(value: u32) -> BaseElement
pub fn from(value: u32) -> BaseElement
Converts a 32-bit value into a filed element.
impl From<u64> for BaseElement
impl From<u64> for BaseElement
pub fn from(value: u64) -> BaseElement
pub fn from(value: u64) -> BaseElement
Converts a 64-bit value into a filed element.
impl From<u8> for BaseElement
impl From<u8> for BaseElement
pub fn from(value: u8) -> BaseElement
pub fn from(value: u8) -> BaseElement
Converts an 8-bit value into a filed element.
impl Mul<BaseElement> for BaseElement
impl Mul<BaseElement> for BaseElement
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the * operator.
pub fn mul(self, rhs: BaseElement) -> BaseElement
pub fn mul(self, rhs: BaseElement) -> BaseElement
Performs the * operation. Read more
impl MulAssign<BaseElement> for BaseElement
impl MulAssign<BaseElement> for BaseElement
pub fn mul_assign(&mut self, rhs: BaseElement)
pub fn mul_assign(&mut self, rhs: BaseElement)
Performs the *= operation. Read more
impl Neg for BaseElement
impl Neg for BaseElement
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the - operator.
pub fn neg(self) -> BaseElement
pub fn neg(self) -> BaseElement
Performs the unary - operation. Read more
impl PartialEq<BaseElement> for BaseElement
impl PartialEq<BaseElement> for BaseElement
pub fn eq(&self, other: &BaseElement) -> bool
pub fn eq(&self, other: &BaseElement) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
pub fn ne(&self, other: &BaseElement) -> bool
pub fn ne(&self, other: &BaseElement) -> bool
This method tests for !=.
impl Randomizable for BaseElement
impl Randomizable for BaseElement
pub const VALUE_SIZE: usize
pub const VALUE_SIZE: usize
Size of Self in bytes. Read more
pub fn from_random_bytes(bytes: &[u8]) -> Option<BaseElement>
pub fn from_random_bytes(bytes: &[u8]) -> Option<BaseElement>
Returns Self if the set of bytes forms a valid value, otherwise returns None.
impl Serializable for BaseElement
impl Serializable for BaseElement
pub fn write_into<W>(&self, target: &mut W) where
W: ByteWriter,
pub fn write_into<W>(&self, target: &mut W) where
W: ByteWriter,
Serializes self into bytes and writes these bytes into the target.
fn 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
fn 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
impl StarkField for BaseElement
impl StarkField for BaseElement
pub const MODULUS: <BaseElement as FieldElement>::PositiveInteger
pub const MODULUS: <BaseElement as FieldElement>::PositiveInteger
sage: MODULUS = 2^128 - 45 * 2^40 + 1
sage: GF(MODULUS).is_prime_field()
True
sage: GF(MODULUS).order()
340282366920938463463374557953744961537
pub const GENERATOR: BaseElement
pub const GENERATOR: BaseElement
sage: GF(MODULUS).primitive_element()
3
pub const TWO_ADICITY: u32
pub const TWO_ADICITY: u32
sage: is_odd((MODULUS - 1) / 2^40)
True
pub const TWO_ADIC_ROOT_OF_UNITY: BaseElement
pub const TWO_ADIC_ROOT_OF_UNITY: BaseElement
sage: k = (MODULUS - 1) / 2^40
sage: GF(MODULUS).primitive_element()^k
23953097886125630542083529559205016746
type QuadExtension = QuadExtensionA<BaseElement>
type QuadExtension = QuadExtensionA<BaseElement>
Type describing quadratic extension of this StarkField.
pub const MODULUS_BITS: u32
pub const MODULUS_BITS: u32
The number of bits needed to represents Self::MODULUS.
pub fn get_modulus_le_bytes() -> Vec<u8, Global>
pub fn get_modulus_le_bytes() -> Vec<u8, Global>
Returns byte representation of the field modulus in little-endian byte order.
pub fn as_int(&self) -> <BaseElement as FieldElement>::PositiveInteger
pub fn as_int(&self) -> <BaseElement as FieldElement>::PositiveInteger
Returns a canonical integer representation of the field element.
fn 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
impl Sub<BaseElement> for BaseElement
impl Sub<BaseElement> for BaseElement
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the - operator.
pub fn sub(self, rhs: BaseElement) -> BaseElement
pub fn sub(self, rhs: BaseElement) -> BaseElement
Performs the - operation. Read more
impl SubAssign<BaseElement> for BaseElement
impl SubAssign<BaseElement> for BaseElement
pub fn sub_assign(&mut self, rhs: BaseElement)
pub fn sub_assign(&mut self, rhs: BaseElement)
Performs the -= operation. Read more
impl<'a> TryFrom<&'a [u8]> for BaseElement
impl<'a> TryFrom<&'a [u8]> for BaseElement
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.
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
Mutably borrows from an owned value. Read more