Struct cryptix_field::Element
source · pub struct Element<I, M: Modular<I>>(pub I, _);
Expand description
An element in mod n ring, the type parameter I should be an integer the modular p is embedded in the type parameter M, it’s typically a ZST
Tuple Fields§
§0: I
Implementations§
source§impl<I, M: Modular<I>> Element<I, M>
impl<I, M: Modular<I>> Element<I, M>
sourcepub const fn new_unchecked(value: I) -> Self
pub const fn new_unchecked(value: I) -> Self
Safety
This function is designed to be used in const environment to directly convert
a canonical representative into mod p field element. So we made an assumption
that the parameter value
must lie between 0 to p - 1. Creating a field element
with non-canonical representative can lead to unexpected result when computing
Trait Implementations§
source§impl<I: Ord, M: Modular<I>> Ord for Element<I, M>
impl<I: Ord, M: Modular<I>> Ord for Element<I, M>
source§impl<I: PartialEq, M: Modular<I>> PartialEq<Element<I, M>> for Element<I, M>
impl<I: PartialEq, M: Modular<I>> PartialEq<Element<I, M>> for Element<I, M>
source§impl<I: PartialOrd, M: Modular<I>> PartialOrd<Element<I, M>> for Element<I, M>
impl<I: PartialOrd, M: Modular<I>> PartialOrd<Element<I, M>> for Element<I, M>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<I, M> AbelianGroup for Element<I, M>where M: Modular<I>, Self: Group + CommunicativeAdd,
impl<I, M> AssociativeAdd for Element<I, M>where M: Modular<I>, Self: Add<Output = Self>,
Safety
Element is backed by biguint, which is associative under addition
impl<I, M> AssociativeMul for Element<I, M>where M: Modular<I>, Self: Mul<Output = Self>,
Safety
our element type is backed by biguint, so mod mul is associative
impl<I, M> CommunicativeAdd for Element<I, M>where M: Modular<I>, Self: Add<Output = Self>,
Safety
Element is backed by biguint, which is communicative under addition
impl<I: Copy, M: Modular<I>> Copy for Element<I, M>
impl<I, M> DistributiveMul for Element<I, M>where M: Modular<I>, Self: Mul<Output = Self> + Add<Output = Self>,
Safety
our element type is backed by biguint, so mod mul is distributive over add
impl<I: Eq, M: Modular<I>> Eq for Element<I, M>
impl<I, M> Group for Element<I, M>where M: Modular<I>, I: BigIntOps,
impl<I, M> Ring for Element<I, M>where M: Modular<I>, Self: Mul<Output = Self> + AssociativeMul + DistributiveMul + AbelianGroup,
Auto Trait Implementations§
impl<I, M> RefUnwindSafe for Element<I, M>where I: RefUnwindSafe, M: RefUnwindSafe,
impl<I, M> Send for Element<I, M>where I: Send, M: Send,
impl<I, M> Sync for Element<I, M>where I: Sync, M: Sync,
impl<I, M> Unpin for Element<I, M>where I: Unpin, M: Unpin,
impl<I, M> UnwindSafe for Element<I, M>where I: UnwindSafe, M: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more