pub mod fan_paar;
pub mod gf2;
pub mod gf8;
pub mod goldilocks;
pub mod mersenne31;
pub mod quad_mersenne31;
pub mod tower;
#[allow(dead_code)]
pub(crate) mod wiedemann;
pub use fan_paar::{FanPaar8, FanPaar16, FanPaar32, FanPaar64};
pub use gf2::Gf2;
pub use gf8::{gf8b, gf8d};
pub use gf8b::Gf8B;
pub use gf8d::Gf8D;
pub use gf16::Gf16;
pub use gf32::Gf32;
pub use gf64::Gf64;
pub use goldilocks::Goldilocks;
pub use mersenne31::Mersenne31;
pub use quad_mersenne31::QuadMersenne31;
pub use tower::{gf16, gf32, gf64};
pub trait Elem:
Copy + Clone + PartialEq + Eq + core::fmt::Debug + core::hash::Hash + Default + 'static
{
const ZERO: Self;
const ONE: Self;
#[must_use]
fn add(self, rhs: Self) -> Self;
#[must_use]
fn sub(self, rhs: Self) -> Self;
#[inline]
#[must_use]
fn neg(self) -> Self {
self
}
#[must_use]
fn mul(self, rhs: Self) -> Self;
#[must_use]
fn inv(self) -> Self;
#[must_use]
fn div(self, rhs: Self) -> Self;
#[inline]
#[must_use]
fn square(self) -> Self {
self.mul(self)
}
#[must_use]
fn pow(self, exponent: u64) -> Self {
let mut base = self;
let mut exponent = exponent;
let mut result = Self::ONE;
while exponent != 0 {
if exponent & 1 != 0 {
result = result.mul(base);
}
base = base.mul(base);
exponent >>= 1;
}
result
}
#[inline]
fn is_zero(self) -> bool {
self == Self::ZERO
}
#[inline]
fn is_one(self) -> bool {
self == Self::ONE
}
}
pub trait Field: Copy + Clone + core::fmt::Debug + 'static {
type Elem: Elem;
const NAME: &'static str;
const BITS: u32;
const BYTES: usize;
const ORDER: u128;
const CHARACTERISTIC: u64;
const GENERATOR: Self::Elem;
fn decode(bytes: &[u8]) -> Self::Elem;
fn encode(bytes: &mut [u8], value: Self::Elem);
#[inline]
#[must_use]
fn elem_count(bytes: usize) -> usize {
bytes / Self::BYTES
}
}