1use crate::num::arithmetic::Arithmetic;
3use std::ops::Neg;
4
5#[allow(clippy::wrong_self_convention)]
7pub trait FF: Clone {
8 type Element: FFElem;
10 fn from_u64(&self, a: u64) -> Self::Element;
12 fn from_i64(&self, a: i64) -> Self::Element;
14 fn frac(&self, a: i64, b: i64) -> Self::Element {
16 self.from_i64(a) / self.from_i64(b)
17 }
18 fn modulo(&self) -> u32;
19}
20
21pub trait FFElem: Sized + Copy + Neg<Output = Self> + PartialEq + Arithmetic {
23 fn value(self) -> u32;
25 fn modulo(self) -> u32;
27 fn pow(self, p: u64) -> Self;
29 fn inv(self) -> Self {
31 self.pow(self.modulo() as u64 - 2)
32 }
33}