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

Instances of ExtElem are elements of a finite field F_p^4. They are represented as elements of F_p[X] / (X^4 + 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^4 + 11 was chosen because 11 is the simplest choice of BETA for x^4 + BETA that makes this polynomial irreducible.

Implementations§

source§

impl ExtElem

source

pub const fn new(x0: Elem, x1: Elem, x2: Elem, x3: Elem) -> ExtElem

Explicitly construct an ExtElem from parts.

source

pub fn from_fp(x: Elem) -> ExtElem

Create an ExtElem from an Elem.

source

pub const fn from_u32(x0: u32) -> ExtElem

Create an 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: ExtElem) -> ExtElem

Addition for Baby Bear ExtElem

§

type Output = ExtElem

The resulting type after applying the + operator.
source§

impl AddAssign for ExtElem

source§

fn add_assign(&mut self, rhs: ExtElem)

Simple addition case for Baby Bear 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<(), Error>

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

impl Default for ExtElem

source§

fn default() -> ExtElem

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

impl Elem for ExtElem

source§

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

Generate a random field element uniformly.

source§

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

Raise a ExtElem to a power of n.

source§

fn inv(self) -> ExtElem

Compute the multiplicative inverse of an ExtElem.

source§

const INVALID: ExtElem = _

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: ExtElem = _

Zero, the additive identity.
source§

const ONE: ExtElem = _

One, the multiplicative identity.
source§

const WORDS: usize = 4usize

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

fn from_u64(val: u64) -> ExtElem

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]) -> ExtElem

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 = 4usize

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

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

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

Construct an extension field element Read more
source§

impl From<[Elem; 4]> for ExtElem

source§

fn from(val: [Elem; 4]) -> ExtElem

Converts to this type from the input type.
source§

impl From<Elem> for ExtElem

source§

fn from(x: Elem) -> ExtElem

Converts to this type from the input type.
source§

impl From<u32> for ExtElem

source§

fn from(x: u32) -> ExtElem

Converts to this type from the input type.
source§

impl Mul<Elem> for ExtElem

source§

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

Multiplication by a Baby Bear Elem

§

type Output = ExtElem

The resulting type after applying the * operator.
source§

impl Mul<ExtElem> for Elem

source§

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

Multiplication for a subfield Elem by an ExtElem

§

type Output = ExtElem

The resulting type after applying the * operator.
source§

impl Mul for ExtElem

§

type Output = ExtElem

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl MulAssign<Elem> for ExtElem

source§

fn mul_assign(&mut self, rhs: Elem)

Simple multiplication case by a Baby Bear Elem

source§

impl MulAssign for ExtElem

source§

fn mul_assign(&mut self, rhs: ExtElem)

Performs the *= operation. Read more
source§

impl Neg for ExtElem

§

type Output = ExtElem

The resulting type after applying the - operator.
source§

fn neg(self) -> ExtElem

Performs the unary - operation. Read more
source§

impl PartialEq for ExtElem

source§

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

Subtraction for Baby Bear ExtElem

§

type Output = ExtElem

The resulting type after applying the - operator.
source§

impl SubAssign for ExtElem

source§

fn sub_assign(&mut self, rhs: ExtElem)

Simple subtraction case for Baby Bear 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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedBitPattern for T
where 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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 T
where 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 T
where 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> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> AnyBitPattern for T
where T: Pod,

source§

impl<T> NoUninit for T
where T: Pod,