pub struct ExtElem(/* private fields */);
Expand description

Instances of ExtElem are elements of a finite field F_p^2. They are represented as elements of F_p[X] / (X^2 - 11). This large finite field (about 2^128 elements) is used when the security of operations depends on the size of the field. The field extension ExtElem has Elem as a subfield, so operations on elements of each are compatible. The irreducible polynomial x^2 - 11 was chosen because 11 is the simplest choice of BETA for x^2 - BETA that makes this polynomial irreducible.

Implementations§

source§

impl ExtElem

source

pub const fn new(x0: Elem, x1: Elem) -> Self

Explicitly construct an ExtElem from parts.

source

pub fn from_fp(x: Elem) -> Self

Create a ExtElem from an Elem.

source

pub const fn from_u64(x0: u64) -> Self

Create a ExtElem from a raw integer.

source

pub fn const_part(self) -> Elem

Return the base field term of an Elem.

source

pub fn elems(&self) -> &[Elem]

Return Elem as a vector of base field values.

Trait Implementations§

source§

impl Add for ExtElem

source§

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

Addition for Goldilocks ExtElem

§

type Output = ExtElem

The resulting type after applying the + operator.
source§

impl AddAssign for ExtElem

source§

fn add_assign(&mut self, rhs: Self)

Simple addition case for Goldilocks ExtElem

source§

impl Clone for ExtElem

source§

fn clone(&self) -> ExtElem

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 ExtElem

source§

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

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

impl Default for ExtElem

source§

fn default() -> Self

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

impl Elem for ExtElem

source§

fn random(rng: &mut impl RngCore) -> Self

Generate a random ExtElem uniformly.

source§

fn pow(self, n: usize) -> Self

Raise an ExtElem to a power of n.

source§

fn inv(self) -> Self

Compute the multiplicative inverse of a field element ExtElem.

source§

const INVALID: Self = _

Invalid, a value that is not a member of the field. This should only be used with the “is_valid” or “unwrap_or_zero” methods.
source§

const ZERO: Self = _

Zero, the additive identity.
source§

const ONE: Self = _

One, the multiplicative identity.
source§

const WORDS: usize = 4usize

How many u32 words are required to hold a single element
source§

fn from_u64(x0: u64) -> Self

Import a number into the field from the natural numbers.
source§

fn to_u32_words(&self) -> Vec<u32>

Represent a field element as a sequence of u32s
source§

fn from_u32_words(val: &[u32]) -> Self

Interpret a sequence of u32s as a field element
source§

fn is_valid(&self) -> bool

Returns true if this element is not INVALID. Unlike most methods, this may be called on an INVALID element.
source§

fn valid_or_zero(&self) -> Self

Returns 0 if this element is INVALID, else the value of this element. Unlike most methods, this may be called on an INVALID element.
source§

fn ensure_valid(&self) -> &Self

Returns this element, but checks to make sure it’s valid.
source§

fn as_u32_slice(elems: &[Self]) -> &[u32]

Interprets a slice of these elements as u32s. These elements may not be INVALID.
source§

fn as_u32_slice_unchecked(elems: &[Self]) -> &[u32]

Interprets a slice of these elements as u32s. These elements may potentially be INVALID.
source§

fn from_u32_slice(u32s: &[u32]) -> &[Self]

Interprets a slice of u32s as a slice of these elements. These elements may not be INVALID.
source§

fn from_u32_slice_unchecked(u32s: &[u32]) -> &[Self]

Interprets a slice of u32s as a slice of these elements. These elements may be INVALID.
source§

impl ExtElem for ExtElem

source§

fn subelems(&self) -> &[Elem]

Returns the subelements of a Elem.

source§

const EXT_SIZE: usize = 2usize

The degree of the field extension Read more
§

type SubElem = Elem

An element of the base field Read more
source§

fn from_subfield(elem: &Elem) -> Self

Interpret a base field element as an extension field element Read more
source§

fn from_subelems(elems: impl IntoIterator<Item = Self::SubElem>) -> Self

Construct an extension field element Read more
source§

impl From<[Elem; 2]> for ExtElem

source§

fn from(val: [Elem; 2]) -> Self

Create field element from subfield element

source§

impl From<Elem> for ExtElem

source§

fn from(x: Elem) -> Self

Converts to this type from the input type.
source§

impl From<u64> for ExtElem

source§

fn from(x: u64) -> Self

Converts to this type from the input type.
source§

impl Mul<Elem> for ExtElem

source§

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

Multiplication for ExtElem

§

type Output = ExtElem

The resulting type after applying the * operator.
source§

impl Mul<ExtElem> for Elem

source§

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

Multiplication of Elem by Goldilocks ExtElem

§

type Output = ExtElem

The resulting type after applying the * operator.
source§

impl Mul for ExtElem

source§

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

Multiplication for Goldilocks ExtElem

§

type Output = ExtElem

The resulting type after applying the * operator.
source§

impl MulAssign<Elem> for ExtElem

source§

fn mul_assign(&mut self, rhs: Elem)

Simple multiplication case for Goldilocks ExtElem

source§

impl MulAssign for ExtElem

source§

fn mul_assign(&mut self, rhs: Self)

Simple multiplication case for Goldilocks ExtElem

source§

impl Neg for ExtElem

source§

fn neg(self) -> Self

Unary negation for Goldilocks ExtElem

§

type Output = ExtElem

The resulting type after applying the - operator.
source§

impl PartialEq for ExtElem

source§

fn eq(&self, other: &ExtElem) -> 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 Sub for ExtElem

source§

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

Subtraction for Goldilocks ExtElem

§

type Output = ExtElem

The resulting type after applying the - operator.
source§

impl SubAssign for ExtElem

source§

fn sub_assign(&mut self, rhs: Self)

Simple subtraction case for Goldilocks ExtElem

source§

impl Zeroable for ExtElem

source§

fn zeroed() -> Self

source§

impl Copy for ExtElem

source§

impl Eq for ExtElem

source§

impl Pod for ExtElem

source§

impl StructuralEq for ExtElem

source§

impl StructuralPartialEq for ExtElem

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedBitPattern for Twhere T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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<T> ToOwned for Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.
source§

impl<T> AnyBitPattern for Twhere T: Pod,

source§

impl<T> NoUninit for Twhere T: Pod,