#![allow(single_use_lifetimes)]
use crate::{AddInline, Inv, MulInline, NegInline, One, Pow, SquareInline, SubInline, Zero};
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
pub trait FieldOps<Rhs = Self, Output = Self>:
Add<Rhs, Output = Output>
+ Sub<Rhs, Output = Output>
+ Mul<Rhs, Output = Output>
+ Div<Rhs, Output = Output>
{
}
impl<T, Rhs, Output> FieldOps<Rhs, Output> for T where
T: Add<Rhs, Output = Output>
+ Sub<Rhs, Output = Output>
+ Mul<Rhs, Output = Output>
+ Div<Rhs, Output = Output>
{
}
pub trait FieldAssignOps<Rhs = Self>:
AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs>
{
}
impl<T, Rhs> FieldAssignOps<Rhs> for T where
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs>
{
}
pub trait FieldLike:
Sized
+ Clone
+ PartialEq
+ Eq
+ Zero
+ One
+ for<'a> AddInline<&'a Self>
+ for<'a> SubInline<&'a Self>
+ NegInline
+ SquareInline
+ for<'a> MulInline<&'a Self>
+ FieldOps
+ for<'a> FieldOps<&'a Self>
+ FieldAssignOps
+ for<'a> FieldAssignOps<&'a Self>
+ Root<usize>
{
}
impl<T> FieldLike for T where
Self: Sized
+ Clone
+ PartialEq
+ Eq
+ Zero
+ One
+ for<'a> AddInline<&'a Self>
+ for<'a> SubInline<&'a Self>
+ NegInline
+ SquareInline
+ for<'a> MulInline<&'a Self>
+ FieldOps
+ for<'a> FieldOps<&'a Self>
+ FieldAssignOps
+ for<'a> FieldAssignOps<&'a Self>
+ Root<usize>
{
}
pub trait RefFieldLike<Base>:
Inv<Output = Option<Base>>
+ Pow<usize, Output = Base>
+ FieldOps<Base, Base>
+ for<'r> FieldOps<&'r Base, Base>
{
}
impl<Base> RefFieldLike<Base> for &Base where
Self: Inv<Output = Option<Base>>
+ Pow<usize, Output = Base>
+ FieldOps<Base, Base>
+ for<'b> FieldOps<&'b Base, Base>
{
}
pub trait Root<Order>: Sized {
fn root(order: Order) -> Option<Self>;
}
pub trait SquareRoot: Sized {
fn is_quadratic_residue(&self) -> bool;
fn square_root(&self) -> Option<Self>;
}
pub trait Fft<T> {
fn fft(&mut self);
fn ifft(&mut self);
fn clone_shifted(&mut self, source: &[T], cofactor: &T);
fn fft_cofactor(&mut self, cofactor: &T);
fn ifft_cofactor(&mut self, cofactor: &T);
fn fft_root(&mut self, root: &T);
}