Zq

Struct Zq 

Source
pub struct Zq<const N: usize, B: ArithmeticBackend<N>> {
    pub val: Uint<N>,
    /* private fields */
}
Expand description

A ring of integers mod q.

Fields§

§val: Uint<N>

The value of the Zq stored in its backend-specific representation. For example, using the BarrettBackend, which is the standard representation but with a Montgomery backend, this will be stored in Montgomery form.

Implementations§

Source§

impl<const N: usize, B: ArithmeticBackend<N>> Zq<N, B>

Source

pub fn into_bigint(self) -> Uint<N>

Converts the element in Zq over the range [0, q) to a canonical integer with the same number of limbs in the same range.

Trait Implementations§

Source§

impl<const N: usize, B> Add<&Zq<N, B>> for &Zq<N, B>
where B: ArithmeticBackend<N>,

Source§

type Output = Zq<N, B>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Zq<N, B>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, B> Add<&Zq<N, B>> for Zq<N, B>
where B: ArithmeticBackend<N>,

Source§

type Output = Zq<N, B>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Zq<N, B>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, B> Add<Zq<N, B>> for &Zq<N, B>
where B: ArithmeticBackend<N>,

Source§

type Output = Zq<N, B>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Zq<N, B>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, B> Add for Zq<N, B>
where B: ArithmeticBackend<N>,

Source§

type Output = Zq<N, B>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Zq<N, B>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, B: ArithmeticBackend<N>> Clone for Zq<N, B>

Source§

fn clone(&self) -> Self

Returns a duplicate 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<const N: usize, B: ArithmeticBackend<N>> Debug for Zq<N, B>

Source§

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

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

impl<'de, const N: usize, B: ArithmeticBackend<N>> Deserialize<'de> for Zq<N, B>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<const N: usize, B: FieldBackend + ArithmeticBackend<N>> Field for Zq<N, B>

Source§

fn inverse(&self) -> Self

Compute the inverse of self
Source§

impl<const N: usize, B: ArithmeticBackend<N>> From<i32> for Zq<N, B>

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize, B: ArithmeticBackend<N>> From<i64> for Zq<N, B>

Source§

fn from(value: i64) -> Self

Returns value over the range [-q/2, q/2].

§Remarks

Calling this over Zq where |value| > q /2 may result in incorrect results

§Panics

If value is i64::MIN.

Source§

impl<const N: usize, B: ArithmeticBackend<N>> From<u32> for Zq<N, B>

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize, B: ArithmeticBackend<N>> From<u64> for Zq<N, B>

Source§

fn from(value: u64) -> Self

Returns value % q.

Source§

impl<const N: usize, B: ArithmeticBackend<N>> Mul<&Zq<N, B>> for &Zq<N, B>

Source§

type Output = Zq<N, B>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Zq<N, B>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, B: ArithmeticBackend<N>> Mul<&Zq<N, B>> for Zq<N, B>

Source§

type Output = Zq<N, B>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Zq<N, B>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, B: ArithmeticBackend<N>> Mul<Zq<N, B>> for &Zq<N, B>

Source§

type Output = Zq<N, B>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Zq<N, B>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, B: ArithmeticBackend<N>> Mul for Zq<N, B>

Source§

type Output = Zq<N, B>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Zq<N, B>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, B: ArithmeticBackend<N>> Neg for &Zq<N, B>

Source§

type Output = Zq<N, B>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<const N: usize, B: ArithmeticBackend<N>> Neg for Zq<N, B>

Source§

type Output = Zq<N, B>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<const N: usize, B: ArithmeticBackend<N>> One for Zq<N, B>

Source§

fn one() -> Self

The multiplicative identity.
Source§

impl<const N: usize, B: ArithmeticBackend<N>> Ord for Zq<N, B>

Source§

fn cmp(&self, other: &Self) -> Ordering

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

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

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

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

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

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

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

impl<const N: usize, B: ArithmeticBackend<N>> PartialEq for Zq<N, B>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N: usize, B: ArithmeticBackend<N>> PartialOrd for Zq<N, B>

Source§

fn partial_cmp(&self, other: &Self) -> 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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<B: ArithmeticBackend<M>, const M: usize, const N: usize> RingModulus<N> for Zq<M, B>

Source§

fn field_modulus() -> Uint<N>

The modulus of the field.
Source§

fn field_modulus_div_2() -> Uint<N>

The modulus of the field divided by 2.
Source§

impl<const N: usize, B: ArithmeticBackend<N>> Serialize for Zq<N, B>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<const N: usize, B> Sub<&Zq<N, B>> for &Zq<N, B>
where B: ArithmeticBackend<N>,

Source§

type Output = Zq<N, B>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Zq<N, B>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const N: usize, B> Sub<&Zq<N, B>> for Zq<N, B>
where B: ArithmeticBackend<N>,

Source§

type Output = Zq<N, B>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Zq<N, B>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const N: usize, B> Sub<Zq<N, B>> for &Zq<N, B>
where B: ArithmeticBackend<N>,

Source§

type Output = Zq<N, B>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Zq<N, B>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const N: usize, B> Sub for Zq<N, B>
where B: ArithmeticBackend<N>,

Source§

type Output = Zq<N, B>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Zq<N, B>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const N: usize, B: ArithmeticBackend<N>> TryFrom<Uint<N>> for Zq<N, B>

Source§

fn try_from(value: Uint<N>) -> Result<Self, Self::Error>

Fails if value >= C::MODULUS.

Source§

type Error = Error

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

impl<const N: usize, B: ArithmeticBackend<N>> Zero for Zq<N, B>

Source§

fn zero() -> Self

The additive identity.
Source§

fn vartime_is_zero(&self) -> bool

Whether or not this item is zero.
Source§

impl<const N: usize, B: ArithmeticBackend<N>> Copy for Zq<N, B>

Source§

impl<const N: usize, B: ArithmeticBackend<N>> Eq for Zq<N, B>

Source§

impl<const N: usize, B: ArithmeticBackend<N>> Ring for Zq<N, B>

Auto Trait Implementations§

§

impl<const N: usize, B> Freeze for Zq<N, B>

§

impl<const N: usize, B> RefUnwindSafe for Zq<N, B>
where B: RefUnwindSafe,

§

impl<const N: usize, B> Send for Zq<N, B>

§

impl<const N: usize, B> Sync for Zq<N, B>

§

impl<const N: usize, B> Unpin for Zq<N, B>
where B: Unpin,

§

impl<const N: usize, B> UnwindSafe for Zq<N, B>
where B: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ClosedNeg for T
where T: Neg<Output = T>,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,