Elem

Trait Elem 

Source
pub trait Elem:
    Sized
    + 'static
    + Clone
    + Copy
    + Send
    + Sync
    + Debug
    + Neg<Output = Self>
    + SubAssign
    + PartialEq
    + Eq
    + Clone
    + Copy
    + NoUninit
    + CheckedBitPattern
    + Default
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + AddAssign
    + SubAssign
    + MulAssign {
    const INVALID: Self;
    const ZERO: Self;
    const ONE: Self;
    const WORDS: usize;
Show 14 methods // Required methods fn inv(self) -> Self; fn random(rng: &mut impl RngCore) -> Self; fn from_u64(val: u64) -> Self; fn to_u32_words(&self) -> Vec<u32>; fn from_u32_words(val: &[u32]) -> Self; fn is_valid(&self) -> bool; fn is_reduced(&self) -> bool; // Provided methods fn pow(self, exp: usize) -> Self { ... } fn valid_or_zero(&self) -> Self { ... } fn ensure_valid(&self) -> &Self { ... } fn ensure_reduced(&self) -> &Self { ... } fn as_u32_slice(elems: &[Self]) -> &[u32] { ... } fn as_u32_slice_unchecked(elems: &[Self]) -> &[u32] { ... } fn from_u32_slice(u32s: &[u32]) -> &[Self] { ... }
}
Expand description

Subfield elements that can be compared, copied, and operated on via multiplication, addition, and subtraction

Required Associated Constants§

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

How many u32 words are required to hold a single element

Required Methods§

Source

fn inv(self) -> Self

Compute the multiplicative inverse of x (or 1 / x in finite field terms).

Source

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

Returns a random valid field element.

Source

fn from_u64(val: 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 is_reduced(&self) -> bool

Returns true if this element is represented in reduced/normalized form. Every element has exactly one reduced form. For a field of prime order P, this typically means the underlying data is < P, and for an extension field, this typically means every component is in reduced form.

Provided Methods§

Source

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

Return an element raised to the given power.

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 ensure_reduced(&self) -> &Self

Returns this element, but checks to make sure it’s in reduced form.

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§