use crate::decode::g2poly::G2Poly;
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
pub trait GaloisField:
Add<Output = Self>
+ AddAssign
+ Sub<Output = Self>
+ SubAssign
+ Mul<Output = Self>
+ MulAssign
+ Div<Output = Self>
+ DivAssign
+ Copy
+ PartialEq
+ Eq
{
const SIZE: usize;
const ZERO: Self;
const ONE: Self;
const GENERATOR: Self;
const MODULUS: G2Poly;
fn pow(self, p: usize) -> Self {
let mut val = Self::ONE;
let mut pow_pos = 1 << (::std::mem::size_of::<usize>() * 8 - 1);
assert_eq!(pow_pos << 1, 0);
while pow_pos > 0 {
val *= val;
if (pow_pos & p) > 0 {
val *= self;
}
pow_pos >>= 1;
}
val
}
}