Field

Trait Field 

Source
pub trait Field:
    Sized
    + Eq
    + Copy
    + Clone
    + Send
    + Sync
    + Debug {
    // Required methods
    fn random<R>(rng: &mut R) -> Self
       where R: RngCore + ?Sized;
    fn zero() -> Self;
    fn one() -> Self;
    fn is_zero(&self) -> bool;
    fn square(&mut self);
    fn double(&mut self);
    fn negate(&mut self);
    fn add_assign(&mut self, other: &Self);
    fn sub_assign(&mut self, other: &Self);
    fn mul_assign(&mut self, other: &Self);
    fn inverse(&self) -> Option<Self>;

    // Provided method
    fn pow<S>(&self, exp: S) -> Self
       where S: AsRef<[u64]> { ... }
}
Expand description

This trait represents an element of a field. The trait essentially copies ff::Field from v0.5.

Required Methods§

Source

fn random<R>(rng: &mut R) -> Self
where R: RngCore + ?Sized,

Returns an element chosen uniformly at random using a user-provided RNG.

Source

fn zero() -> Self

Returns the zero element of the field, the additive identity.

Source

fn one() -> Self

Returns the one element of the field, the multiplicative identity.

Source

fn is_zero(&self) -> bool

Returns true iff this element is zero.

Source

fn square(&mut self)

Squares this element.

Source

fn double(&mut self)

Doubles this element.

Source

fn negate(&mut self)

Negates this element.

Source

fn add_assign(&mut self, other: &Self)

Adds another element to this element.

Source

fn sub_assign(&mut self, other: &Self)

Subtracts another element from this element.

Source

fn mul_assign(&mut self, other: &Self)

Multiplies another element by this element.

Source

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

Computes the multiplicative inverse of this element, if nonzero.

Provided Methods§

Source

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

Exponentiates this element by a number represented with u64 limbs, least significant digit first. This operation is variable time with respect to self, for all exponent.

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§

Source§

impl<F> Field for ArkField<F>
where F: Field,

A blanket implementation of the Field trait using the functionality of ark_ff::Field. This gives an implementation of our Field trait for ArkField<F> for any F that implements ark_ff::Field.