Trait Field

Source
pub trait Field:
    FieldAlgebra<F = Self>
    + Packable
    + 'static
    + Copy
    + Div<Self, Output = Self>
    + Eq
    + Hash
    + Send
    + Sync
    + Display
    + Serialize
    + DeserializeOwned {
    type Packing: PackedField<Scalar = Self>;

    const GENERATOR: Self;

    // Required methods
    fn try_inverse(&self) -> Option<Self>;
    fn order() -> BigUint;

    // Provided methods
    fn is_zero(&self) -> bool { ... }
    fn is_one(&self) -> bool { ... }
    fn div_2exp_u64(&self, exp: u64) -> Self { ... }
    fn exp_u64_generic<FA: FieldAlgebra<F = Self>>(val: FA, power: u64) -> FA { ... }
    fn inverse(&self) -> Self { ... }
    fn halve(&self) -> Self { ... }
    fn multiplicative_group_factors() -> Vec<(BigUint, usize)> { ... }
    fn bits() -> usize { ... }
}
Expand description

An element of a finite field.

Required Associated Constants§

Source

const GENERATOR: Self

A generator of this field’s entire multiplicative group.

Required Associated Types§

Source

type Packing: PackedField<Scalar = Self>

Required Methods§

Source

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

The multiplicative inverse of this field element, if it exists.

NOTE: The inverse of 0 is undefined and will return None.

Source

fn order() -> BigUint

Provided Methods§

Source

fn is_zero(&self) -> bool

Source

fn is_one(&self) -> bool

Source

fn div_2exp_u64(&self, exp: u64) -> Self

self / 2^exp

Source

fn exp_u64_generic<FA: FieldAlgebra<F = Self>>(val: FA, power: u64) -> FA

Exponentiation by a u64 power. This is similar to exp_u64, but more general in that it can be used with FieldAlgebras, not just this concrete field.

The default implementation uses naive square and multiply. Implementations may want to override this and handle certain powers with more optimal addition chains.

Source

fn inverse(&self) -> Self

Source

fn halve(&self) -> Self

Computes input/2. Should be overwritten by most field implementations to use bitshifts. Will error if the field characteristic is 2.

Source

fn multiplicative_group_factors() -> Vec<(BigUint, usize)>

A list of (factor, exponent) pairs.

Source

fn bits() -> usize

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§