Struct miden_core::BaseElement [−][src]
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
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
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the +
operator.
Performs the +
operation. Read more
Performs the +=
operation. Read more
Returns the “default value” for a type. Read more
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
fn 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
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the /
operator.
Performs the /
operation. Read more
Performs the /=
operation. Read more
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
The additive identity.
The multiplicative identity.
Number of bytes needed to encode an element
True if internal representation of the element is the same as its canonical representation.
Returns a multiplicative inverse of this field element. If this element is ZERO, ZERO is returned. Read more
Returns a conjugate of this field element.
Converts a list of elements into a list of bytes. Read more
Converts a list of bytes into a list of field elements. Read more
Returns a vector of length n
initialized with all ZERO elements. Read more
Converts a list of field elements into a list of elements in the underlying base field. Read more
Exponentiates this field element by power
parameter.
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.
Converts a 16-bit value into a filed element.
Converts a 32-bit value into a filed element.
Converts a 64-bit value into a filed element.
Converts an 8-bit value into a filed element.
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the *
operator.
Performs the *
operation. Read more
Performs the *=
operation. Read more
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the -
operator.
Performs the unary -
operation. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Size of Self
in bytes. Read more
Returns Self
if the set of bytes forms a valid value, otherwise returns None.
sage: MODULUS = 2^128 - 45 * 2^40 + 1
sage: GF(MODULUS).is_prime_field()
True
sage: GF(MODULUS).order()
340282366920938463463374557953744961537
sage: GF(MODULUS).primitive_element()
3
sage: is_odd((MODULUS - 1) / 2^40)
True
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.
The number of bits needed to represents Self::MODULUS
.
Returns byte representation of the field modulus in little-endian byte order.
Returns a canonical integer representation of the field element.
Returns the root of unity of order 2^n
. Read more
type Output = BaseElement
type Output = BaseElement
The resulting type after applying the -
operator.
Performs the -
operation. Read more
Performs the -=
operation. Read more
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.
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