Trait binius_field::field::Field

source ·
pub trait Field: Sized + Eq + Copy + Clone + Default + Send + Sync + Debug + '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 + WithUnderlier<Underlier: PackScalar<Self>> {
    const ZERO: Self;
    const ONE: Self;

    // Required methods
    fn random(rng: impl RngCore) -> Self;
    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.

Required Methods§

source

fn random(rng: impl RngCore) -> Self

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

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.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Field for AESTowerField8b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for AESTowerField16b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for AESTowerField32b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for AESTowerField64b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for AESTowerField128b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for BinaryField1b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for BinaryField2b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for BinaryField4b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for BinaryField8b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for BinaryField16b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for BinaryField32b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for BinaryField64b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for BinaryField128b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl Field for BinaryField128bPolyval

source§

const ZERO: Self = _

source§

const ONE: Self = _