Struct winter_math::fields::f128::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

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Returns a byte representation of self. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

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

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

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

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 an element can be redundant - i.e., multiple internal representations map to the same canonical representation. Read more

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.

Returns a cryptographically-secure random element drawn uniformly from the entire field.

Returns a field element if the set of bytes forms a valid field element, otherwise returns None. The element is expected to be in canonical representation. This function is primarily intended for sampling random field elements from a hash function output. Read more

Converts a vector of field elements into a vector of bytes. The elements may be in the internal representation rather than in the canonical representation. This conversion is intended to be zero-copy (i.e. by re-interpreting the underlying memory). Read more

Converts a list of elements into a list of bytes. The elements may be in the internal representation rather than in the canonical representation. This conversion is intended to be zero-copy (i.e. by re-interpreting the underlying memory). Read more

Converts a list of bytes into a list of field elements. The elements are assumed to encoded in the internal representation rather than in the canonical representation. The conversion is intended to be zero-copy (i.e. by re-interpreting the underlying memory). Read more

Returns a vector of length n initialized with all ZERO elements. Read more

Returns a vector of n pseudo-random elements drawn uniformly from the entire field based on the provided seed. Read more

Normalizes internal representation of this element. Read more

Returns this field element added to itself.

Returns this field element raised to power 2.

Returns this field element raised to power 3.

Exponentiates this field element by power parameter.

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.

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.

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

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 !=.

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

Serializes self into a vector of bytes.

Serializes all elements of the source and writes these bytes into the target. Read more

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

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

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.

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.