Skip to main content

Field

Trait Field 

Source
pub trait Field:
    Copy
    + Default
    + Debug
    + PartialEq {
    type Int: PrimInt + Default + Debug + From<u8> + Into<u128> + Into<Self::Long> + Truncate<u128>;
    type Long: PrimInt + From<Self::Int>;
    type LongLong: PrimInt;

    const Q: Self::Int;
    const QL: Self::Long;
    const QLL: Self::LongLong;
    const BARRETT_SHIFT: usize;
    const BARRETT_MULTIPLIER: Self::LongLong;

    // Required methods
    fn small_reduce(x: Self::Int) -> Self::Int;
    fn barrett_reduce(x: Self::Long) -> Self::Int;
}
Expand description

Finite field with efficient modular reduction for lattice-based cryptography.

Required Associated Constants§

Source

const Q: Self::Int

Field modulus.

Source

const QL: Self::Long

Field modulus as Self::Long.

Source

const QLL: Self::LongLong

Field modulus as Self::LongLong.

Source

const BARRETT_SHIFT: usize

Bit shift used in Barrett reduction.

Source

const BARRETT_MULTIPLIER: Self::LongLong

Precomputed multiplier for Barrett reduction.

Required Associated Types§

Source

type Int: PrimInt + Default + Debug + From<u8> + Into<u128> + Into<Self::Long> + Truncate<u128>

Base integer type used to represent field elements

Source

type Long: PrimInt + From<Self::Int>

Double-width integer type used for intermediate computations.

Source

type LongLong: PrimInt

Quadruple-width integer type used for Barrett reduction.

Required Methods§

Source

fn small_reduce(x: Self::Int) -> Self::Int

Reduce a value that’s already close to the modulus range.

Source

fn barrett_reduce(x: Self::Long) -> Self::Int

Reduce a wider value to a field element using Barrett reduction.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§