Trait risc0_zkp::field::Elem

source ·
pub trait Elem: Mul<Output = Self> + MulAssign + Add<Output = Self> + AddAssign + Neg + Sub<Output = Self> + SubAssign + PartialEq + Eq + Clone + Copy + Sized + Pod + Default + Clone + Copy + Send + Sync + Debug + 'static {
    const INVALID: Self;
    const ZERO: Self;
    const ONE: Self;
    const WORDS: usize;
Show 13 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 pow(self, exp: usize) -> Self { ... } fn valid_or_zero(&self) -> Self { ... } fn ensure_valid(&self) -> &Self { ... } fn as_u32_slice(elems: &[Self]) -> &[u32] { ... } fn as_u32_slice_unchecked(elems: &[Self]) -> &[u32] { ... } fn from_u32_slice(u32s: &[u32]) -> &[Self] { ... } fn from_u32_slice_unchecked(u32s: &[u32]) -> &[Self] { ... }
}
Expand description

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

Required Associated Constants§

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.

Zero, the additive identity.

One, the multiplicative identity.

How many u32 words are required to hold a single element

Required Methods§

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

Returns a random valid field element.

Import a number into the field from the natural numbers.

Represent a field element as a sequence of u32s

Interpret a sequence of u32s as a field element

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

Provided Methods§

Return an element raised to the given power.

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

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

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

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

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

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

Implementors§