Trait IsField

Source
pub trait IsField: Debug + Clone {
    type BaseType: Clone + Debug + Unpin + ByteConversion + Default;

Show 14 methods // Required methods fn add(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType; fn mul(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType; fn sub(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType; fn neg(a: &Self::BaseType) -> Self::BaseType; fn inv(a: &Self::BaseType) -> Result<Self::BaseType, FieldError>; fn div( a: &Self::BaseType, b: &Self::BaseType, ) -> Result<Self::BaseType, FieldError>; fn eq(a: &Self::BaseType, b: &Self::BaseType) -> bool; fn one() -> Self::BaseType; fn from_u64(x: u64) -> Self::BaseType; fn from_base_type(x: Self::BaseType) -> Self::BaseType; // Provided methods fn double(a: &Self::BaseType) -> Self::BaseType { ... } fn square(a: &Self::BaseType) -> Self::BaseType { ... } fn pow<T>(a: &Self::BaseType, exponent: T) -> Self::BaseType where T: IsUnsignedInteger { ... } fn zero() -> Self::BaseType { ... }
}
Expand description

Trait to add field behaviour to a struct.

Required Associated Types§

Source

type BaseType: Clone + Debug + Unpin + ByteConversion + Default

The underlying base type for representing elements from the field.

Required Methods§

Source

fn add(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType

Returns the sum of a and b.

Source

fn mul(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType

Returns the multiplication of a and b.

Source

fn sub(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType

Returns the subtraction of a and b.

Source

fn neg(a: &Self::BaseType) -> Self::BaseType

Returns the additive inverse of a.

Source

fn inv(a: &Self::BaseType) -> Result<Self::BaseType, FieldError>

Returns the multiplicative inverse of a.

Source

fn div( a: &Self::BaseType, b: &Self::BaseType, ) -> Result<Self::BaseType, FieldError>

Returns the division of a and b.

Source

fn eq(a: &Self::BaseType, b: &Self::BaseType) -> bool

Returns a boolean indicating whether a and b are equal or not.

Source

fn one() -> Self::BaseType

Returns the multiplicative neutral element.

Source

fn from_u64(x: u64) -> Self::BaseType

Returns the element x * 1 where 1 is the multiplicative neutral element.

Source

fn from_base_type(x: Self::BaseType) -> Self::BaseType

Takes as input an element of BaseType and returns the internal representation of that element in the field.

Provided Methods§

Source

fn double(a: &Self::BaseType) -> Self::BaseType

Returns the double of a.

Source

fn square(a: &Self::BaseType) -> Self::BaseType

Returns the multiplication of a and a.

Source

fn pow<T>(a: &Self::BaseType, exponent: T) -> Self::BaseType

Source

fn zero() -> Self::BaseType

Returns the additive neutral element.

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 IsField for lambdaworks_math::elliptic_curve::short_weierstrass::curves::bls12_377::field_extension::Degree2ExtensionField

Source§

impl IsField for lambdaworks_math::elliptic_curve::short_weierstrass::curves::bls12_381::field_extension::Degree2ExtensionField

Source§

impl IsField for lambdaworks_math::elliptic_curve::short_weierstrass::curves::bn_254::field_extension::Degree2ExtensionField

Source§

impl IsField for Degree4BabyBearExtensionField

Source§

impl IsField for Degree4BabyBearU32ExtensionField

Source§

impl IsField for lambdaworks_math::field::fields::mersenne31::extensions::Degree2ExtensionField

Source§

impl IsField for Degree4ExtensionField

Source§

impl IsField for Mersenne31Field

Source§

impl IsField for P448GoldilocksPrimeField

Source§

impl IsField for Goldilocks64Field

Source§

impl<F, Q> IsField for CubicExtensionField<F, Q>
where F: IsField, Q: Clone + Debug + HasCubicNonResidue<F>,

Source§

impl<F, Q> IsField for QuadraticExtensionField<F, Q>

Source§

impl<M, const NUM_LIMBS: usize> IsField for MontgomeryBackendPrimeField<M, NUM_LIMBS>
where M: IsModulus<UnsignedInteger<NUM_LIMBS>> + Clone + Debug,

Source§

impl<const MODULUS: u32> IsField for U32MontgomeryBackendPrimeField<MODULUS>

Source§

impl<const MODULUS: u32> IsField for U32Field<MODULUS>

Source§

impl<const MODULUS: u64> IsField for U64PrimeField<MODULUS>

Source§

impl<const MODULUS: u64> IsField for U64Field<MODULUS>