Trait halo2_proofs::arithmetic::Field
[−]pub trait Field: 'static + Sized + Eq + Copy + Clone + Default + Send + Sync + Debug + ConditionallySelectable + ConstantTimeEq + for<'a> Add<Self, Output = Self, Output = Self> + for<'a> Sub<Self, Output = Self, Output = Self> + for<'a> Mul<Self, Output = Self, Output = Self> + Neg<Output = Self> + for<'a> Add<&'a Self> + for<'a> Mul<&'a Self> + for<'a> Sub<&'a Self> + MulAssign<Self> + AddAssign<Self> + SubAssign<Self> + for<'a> MulAssign<&'a Self> + for<'a> AddAssign<&'a Self> + for<'a> SubAssign<&'a Self> {
fn random(rng: impl RngCore) -> Self;
fn zero() -> Self;
fn one() -> Self;
fn square(&self) -> Self;
fn double(&self) -> Self;
fn invert(&self) -> CtOption<Self>;
fn sqrt(&self) -> CtOption<Self>;
fn is_zero(&self) -> Choice { ... }
fn is_zero_vartime(&self) -> bool { ... }
fn cube(&self) -> Self { ... }
fn pow_vartime<S>(&self, exp: S) -> Self
where
S: AsRef<[u64]>,
{ ... }
}
Expand description
This trait represents an element of a field.
Required Methods
fn random(rng: impl RngCore) -> Self
fn random(rng: impl RngCore) -> Self
Returns an element chosen uniformly at random using a user-provided RNG.
fn zero() -> Self
fn zero() -> Self
Returns the zero element of the field, the additive identity.
fn one() -> Self
fn one() -> Self
Returns the one element of the field, the multiplicative identity.
fn square(&self) -> Self
fn square(&self) -> Self
Squares this element.
fn double(&self) -> Self
fn double(&self) -> Self
Doubles this element.
Provided Methods
fn is_zero_vartime(&self) -> bool
fn is_zero_vartime(&self) -> bool
Returns true iff this element is zero.
Security
This method provides no constant-time guarantees. Implementors of the
Field
trait may optimise this method using non-constant-time logic.
fn cube(&self) -> Self
fn cube(&self) -> Self
Cubes this element.
fn pow_vartime<S>(&self, exp: S) -> Selfwhere
S: AsRef<[u64]>,
fn pow_vartime<S>(&self, exp: S) -> Selfwhere
S: AsRef<[u64]>,
Exponentiates self
by exp
, where exp
is a little-endian order
integer exponent.
This operation is variable time with respect to the exponent. If the exponent is fixed, this operation is effectively constant time.
Implementations on Foreign Types
sourceimpl Field for Fp
impl Field for Fp
sourcefn invert(&self) -> CtOption<Fp>
fn invert(&self) -> CtOption<Fp>
Computes the multiplicative inverse of this element, failing if the element is zero.
fn random(rng: impl RngCore) -> Fp
fn zero() -> Fp
fn one() -> Fp
fn double(&self) -> Fp
fn square(&self) -> Fp
fn pow_vartime<S>(&self, exp: S) -> Fpwhere
S: AsRef<[u64]>,
sourceimpl Field for Fq
impl Field for Fq
sourceimpl Field for Fr
impl Field for Fr
sourceimpl Field for Fq
impl Field for Fq
sourcefn invert(&self) -> CtOption<Fq>
fn invert(&self) -> CtOption<Fq>
Computes the multiplicative inverse of this element, failing if the element is zero.