pub struct FpElement<I, M: PrimeModular<I>>(pub Element<I, M>);
Expand description

Element in field F_p

Tuple Fields§

§0: Element<I, M>

Implementations§

source§

impl<I, M: PrimeModular<I>> FpElement<I, M>

source

pub fn new_unchecked(value: I) -> Self

Safety

The safey is the same as Element::new_unchecked

source§

impl<I: Copy, M: PrimeModular<I>> FpElement<I, M>

source

pub fn repr(self) -> I

Trait Implementations§

source§

impl<I, M> Add<FpElement<I, M>> for FpElement<I, M>where M: PrimeModular<I>, I: BigIntOps,

§

type Output = FpElement<I, M>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<I, M> AddIdentity for FpElement<I, M>where M: PrimeModular<I>, I: BigIntOps + IsBigInt,

source§

const ADD_IDENTITY: Self = _

the identity of mod add operation, typically zero
source§

const ZERO: Self = Self::ADD_IDENTITY

source§

impl<I: Copy, M: PrimeModular<I>> Clone for FpElement<I, M>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<I: Debug, M: PrimeModular<I>> Debug for FpElement<I, M>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<I, M> Field for FpElement<I, M>where I: BigIntOpsExt, M: Montgomery<I>,

source§

fn hlv(self) -> Self

calculate self / 2 in field Read more
source§

fn is_zero(&self) -> bool

check if self is zero
source§

impl<I: IsBigInt, M: PrimeModular<I>> From<FpElement<I, M>> for [u8; I::BYTE_LEN]

source§

fn from(val: FpElement<I, M>) -> Self

Converts to this type from the input type.
source§

impl<I, M: PrimeModular<I>> From<FpElement<I, M>> for Element<I, M>

source§

fn from(value: FpElement<I, M>) -> Self

Converts to this type from the input type.
source§

impl<I, M: PrimeModular<I>> From<I> for FpElement<I, M>where I: Rem<Output = I>,

source§

fn from(value: I) -> Self

convert a integer to a mod p field element, this value will be converted into the canonical representative

source§

impl<I, M> MontgomeryOps<I, M> for FpElement<I, M>where I: BigIntOpsExt, M: Montgomery<I>,

source§

fn mont_mul(self, rhs: Self) -> Self

lhs * rhs * R^(-1) mod P
source§

fn mont_rdc(self) -> Self

a * R^(-1) mod P
source§

fn mont_inv(self) -> Self

input: aoutput: a^(-1) * RR mod P Read more
source§

fn mont_mul_fp(self, rhs: FpElement<I, M>) -> Self

source§

fn mont_sqr(self) -> Self

a^2 * R^(-1) mod P
source§

fn mont_form(self) -> Self

a * R mod P
source§

fn mont_exp(self, exp: I) -> Self

base^exp mod P
source§

impl<I, M> Mul<FpElement<I, M>> for FpElement<I, M>where M: Montgomery<I>, I: BigIntOpsExt,

source§

fn mul(self, rhs: Self) -> Self::Output

calculate a * b mod m this can be achieved more efficiently with montgomery multiplication

§

type Output = FpElement<I, M>

The resulting type after applying the * operator.
source§

impl<I, M> MulIdentity for FpElement<I, M>where I: BigIntOpsExt + IsBigInt, M: Montgomery<I>,

Safety

1 is the multiplicative ideneity for biguint

source§

const MUL_IDENTITY: Self = _

source§

const ONE: Self = Self::MUL_IDENTITY

source§

impl<I, M> MulInverse for FpElement<I, M>where I: BigIntOpsExt, M: Montgomery<I>,

The montgomery trait bound restricts the modular to odd prime

source§

fn mul_inv(self) -> Self

source§

impl<I, M> Neg for FpElement<I, M>where M: PrimeModular<I>, I: BigIntOps,

§

type Output = FpElement<I, M>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<I: Ord, M: Ord + PrimeModular<I>> Ord for FpElement<I, M>

source§

fn cmp(&self, other: &FpElement<I, M>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<I: PartialEq, M: PartialEq + PrimeModular<I>> PartialEq<FpElement<I, M>> for FpElement<I, M>

source§

fn eq(&self, other: &FpElement<I, M>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<I: PartialOrd, M: PartialOrd + PrimeModular<I>> PartialOrd<FpElement<I, M>> for FpElement<I, M>

source§

fn partial_cmp(&self, other: &FpElement<I, M>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<I, M> Sub<FpElement<I, M>> for FpElement<I, M>where M: PrimeModular<I>, I: BigIntOps,

§

type Output = FpElement<I, M>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl<I, M> AbelianGroup for FpElement<I, M>where M: PrimeModular<I>, Self: Group + CommunicativeAdd,

source§

impl<I, M> AssociativeAdd for FpElement<I, M>where M: PrimeModular<I>, Self: Add<Output = Self>,

Safety

Element is backed by biguint, which is associative under addition

source§

impl<I, M> AssociativeMul for FpElement<I, M>where M: Montgomery<I>, I: BigIntOpsExt,

Safety

our element type is backed by biguint, so mod mul is associative

source§

impl<I, M> CommunicativeAdd for FpElement<I, M>where M: PrimeModular<I>, Self: Add<Output = Self>,

Safety

Element is backed by biguint, which is communicative under addition

source§

impl<I, M> CommunicativeMul for FpElement<I, M>where M: Montgomery<I>, I: BigIntOpsExt,

Safety

BigUInt mod mul is communicative

source§

impl<I: Copy, M: PrimeModular<I>> Copy for FpElement<I, M>

source§

impl<I, M> DistributiveMul for FpElement<I, M>where M: Montgomery<I>, I: BigIntOpsExt,

Safety

our element type is backed by biguint, so mod mul is distributive over add

source§

impl<I: Eq, M: Eq + PrimeModular<I>> Eq for FpElement<I, M>

source§

impl<I, M> Group for FpElement<I, M>where M: PrimeModular<I>, I: BigIntOps,

source§

impl<I, M> Ring for FpElement<I, M>where M: PrimeModular<I>, Self: Mul<Output = Self> + AssociativeMul + DistributiveMul + AbelianGroup,

source§

impl<I, M: PrimeModular<I>> StructuralEq for FpElement<I, M>

source§

impl<I, M: PrimeModular<I>> StructuralPartialEq for FpElement<I, M>

Auto Trait Implementations§

§

impl<I, M> RefUnwindSafe for FpElement<I, M>where I: RefUnwindSafe, M: RefUnwindSafe,

§

impl<I, M> Send for FpElement<I, M>where I: Send, M: Send,

§

impl<I, M> Sync for FpElement<I, M>where I: Sync, M: Sync,

§

impl<I, M> Unpin for FpElement<I, M>where I: Unpin, M: Unpin,

§

impl<I, M> UnwindSafe for FpElement<I, M>where I: UnwindSafe, M: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.