use core::ops::Add;
use cryptix_bigint::ops::BigIntOpsExt;
use crate::{Modular, Element};
use super::*;
impl<I, M> Ring for Element<I, M>
where
M: Modular<I>,
Self: Mul<Output = Self> + AssociativeMul + DistributiveMul + AbelianGroup
{ }
impl<I, M> Mul for Element<I, M>
where
M: Modular<I>,
I: BigIntOpsExt
{
type Output = Self;
fn mul(self, rhs: Self) -> Self::Output {
let res = self.0 * rhs.0;
Self::new_unchecked(M::P.wrap(res))
}
}
impl<I, M> AssociativeMul for Element<I, M>
where
M: Modular<I>,
Self: Mul<Output = Self>
{ }
impl<I, M> DistributiveMul for Element<I, M>
where
M: Modular<I>,
Self: Mul<Output = Self> + Add<Output = Self>
{ }