Trait Field

Source
pub trait Field:
    Sized
    + Eq
    + Copy
    + Clone
    + Default
    + Send
    + Sync
    + Debug
    + Display
    + Hash
    + 'static
    + Neg<Output = Self>
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Sum
    + Product
    + for<'a> Add<&'a Self, Output = Self>
    + for<'a> Sub<&'a Self, Output = Self>
    + for<'a> Mul<&'a Self, Output = Self>
    + for<'a> Sum<&'a Self>
    + for<'a> Product<&'a Self>
    + AddAssign
    + SubAssign
    + MulAssign
    + for<'a> AddAssign<&'a Self>
    + for<'a> SubAssign<&'a Self>
    + for<'a> MulAssign<&'a Self>
    + Square
    + InvertOrZero
    + Random
    + WithUnderlier<Underlier: PackScalar<Self>>
    + SerializeBytes
    + DeserializeBytes {
    const ZERO: Self;
    const ONE: Self;
    const CHARACTERISTIC: usize;

    // Required method
    fn double(&self) -> Self;

    // Provided methods
    fn is_zero(&self) -> bool { ... }
    fn invert(&self) -> Option<Self> { ... }
    fn pow<S: AsRef<[u64]>>(&self, exp: S) -> Self { ... }
    fn pow_vartime<S: AsRef<[u64]>>(&self, exp: S) -> Self { ... }
}
Expand description

This trait is based on ff::Field with some unused functionality removed.

Required Associated Constants§

Source

const ZERO: Self

The zero element of the field, the additive identity.

Source

const ONE: Self

The one element of the field, the multiplicative identity.

Source

const CHARACTERISTIC: usize

The characteristic of the field.

Required Methods§

Source

fn double(&self) -> Self

Doubles this element.

Provided Methods§

Source

fn is_zero(&self) -> bool

Returns true iff this element is zero.

Source

fn invert(&self) -> Option<Self>

Computes the multiplicative inverse of this element, failing if the element is zero.

Source

fn pow<S: AsRef<[u64]>>(&self, exp: S) -> Self

Exponentiates self by exp, where exp is a little-endian order integer exponent.

§Guarantees

This operation is constant time with respect to self, for all exponents with the same number of digits (exp.as_ref().len()). It is variable time with respect to the number of digits in the exponent.

Source

fn pow_vartime<S: AsRef<[u64]>>(&self, exp: S) -> Self

Exponentiates self by exp, where exp is a little-endian order integer exponent.

§Guarantees

This operation is variable time with respect to self, for all exponent. If the exponent is fixed, this operation is effectively constant time. However, for stronger constant-time guarantees, Field::pow should be used.

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§