pub struct DynResidue<const LIMBS: usize> { /* private fields */ }
Expand description
A residue represented using LIMBS
limbs. The odd modulus of this residue is set at runtime.
Implementations§
Source§impl<const LIMBS: usize> DynResidue<LIMBS>
impl<const LIMBS: usize> DynResidue<LIMBS>
Source§impl<const LIMBS: usize> DynResidue<LIMBS>
impl<const LIMBS: usize> DynResidue<LIMBS>
Sourcepub const fn invert(&self) -> (Self, CtChoice)
pub const fn invert(&self) -> (Self, CtChoice)
Computes the residue self^-1
representing the multiplicative inverse of self
.
I.e. self * self^-1 = 1
.
If the number was invertible, the second element of the tuple is the truthy value,
otherwise it is the falsy value (in which case the first element’s value is unspecified).
Source§impl<const LIMBS: usize> DynResidue<LIMBS>
impl<const LIMBS: usize> DynResidue<LIMBS>
Source§impl<const LIMBS: usize> DynResidue<LIMBS>
impl<const LIMBS: usize> DynResidue<LIMBS>
Source§impl<const LIMBS: usize> DynResidue<LIMBS>
impl<const LIMBS: usize> DynResidue<LIMBS>
Sourcepub const fn pow<const RHS_LIMBS: usize>(
&self,
exponent: &Uint<RHS_LIMBS>,
) -> DynResidue<LIMBS>
pub const fn pow<const RHS_LIMBS: usize>( &self, exponent: &Uint<RHS_LIMBS>, ) -> DynResidue<LIMBS>
Raises to the exponent
power.
Sourcepub const fn pow_bounded_exp<const RHS_LIMBS: usize>(
&self,
exponent: &Uint<RHS_LIMBS>,
exponent_bits: usize,
) -> Self
pub const fn pow_bounded_exp<const RHS_LIMBS: usize>( &self, exponent: &Uint<RHS_LIMBS>, exponent_bits: usize, ) -> Self
Raises to the exponent
power,
with exponent_bits
representing the number of (least significant) bits
to take into account for the exponent.
NOTE: exponent_bits
may be leaked in the time pattern.
Source§impl<const LIMBS: usize> DynResidue<LIMBS>
impl<const LIMBS: usize> DynResidue<LIMBS>
Source§impl<const LIMBS: usize> DynResidue<LIMBS>
impl<const LIMBS: usize> DynResidue<LIMBS>
Sourcepub const fn new(
integer: &Uint<LIMBS>,
residue_params: DynResidueParams<LIMBS>,
) -> Self
pub const fn new( integer: &Uint<LIMBS>, residue_params: DynResidueParams<LIMBS>, ) -> Self
Instantiates a new Residue
that represents this integer
mod MOD
.
Sourcepub const fn retrieve(&self) -> Uint<LIMBS>
pub const fn retrieve(&self) -> Uint<LIMBS>
Retrieves the integer currently encoded in this Residue
, guaranteed to be reduced.
Sourcepub const fn zero(residue_params: DynResidueParams<LIMBS>) -> Self
pub const fn zero(residue_params: DynResidueParams<LIMBS>) -> Self
Instantiates a new Residue
that represents zero.
Sourcepub const fn one(residue_params: DynResidueParams<LIMBS>) -> Self
pub const fn one(residue_params: DynResidueParams<LIMBS>) -> Self
Instantiates a new Residue
that represents 1.
Sourcepub const fn params(&self) -> &DynResidueParams<LIMBS>
pub const fn params(&self) -> &DynResidueParams<LIMBS>
Returns the parameter struct used to initialize this residue.
Sourcepub const fn as_montgomery(&self) -> &Uint<LIMBS>
pub const fn as_montgomery(&self) -> &Uint<LIMBS>
Access the DynResidue
value in Montgomery form.
Sourcepub fn as_montgomery_mut(&mut self) -> &mut Uint<LIMBS>
pub fn as_montgomery_mut(&mut self) -> &mut Uint<LIMBS>
Mutably access the DynResidue
value in Montgomery form.
Sourcepub const fn from_montgomery(
integer: Uint<LIMBS>,
residue_params: DynResidueParams<LIMBS>,
) -> Self
pub const fn from_montgomery( integer: Uint<LIMBS>, residue_params: DynResidueParams<LIMBS>, ) -> Self
Create a DynResidue
from a value in Montgomery form.
Sourcepub const fn to_montgomery(&self) -> Uint<LIMBS>
pub const fn to_montgomery(&self) -> Uint<LIMBS>
Extract the value from the DynResidue
in Montgomery form.
Trait Implementations§
Source§impl<const LIMBS: usize> Add<&DynResidue<LIMBS>> for &DynResidue<LIMBS>
impl<const LIMBS: usize> Add<&DynResidue<LIMBS>> for &DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
+
operator.Source§fn add(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn add(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
+
operation. Read moreSource§impl<const LIMBS: usize> Add<&DynResidue<LIMBS>> for DynResidue<LIMBS>
impl<const LIMBS: usize> Add<&DynResidue<LIMBS>> for DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
+
operator.Source§fn add(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn add(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
+
operation. Read moreSource§impl<const LIMBS: usize> Add<DynResidue<LIMBS>> for &DynResidue<LIMBS>
impl<const LIMBS: usize> Add<DynResidue<LIMBS>> for &DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
+
operator.Source§fn add(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn add(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
+
operation. Read moreSource§impl<const LIMBS: usize> Add for DynResidue<LIMBS>
impl<const LIMBS: usize> Add for DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
+
operator.Source§fn add(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn add(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
+
operation. Read moreSource§impl<const LIMBS: usize> AddAssign<&DynResidue<LIMBS>> for DynResidue<LIMBS>
impl<const LIMBS: usize> AddAssign<&DynResidue<LIMBS>> for DynResidue<LIMBS>
Source§fn add_assign(&mut self, rhs: &DynResidue<LIMBS>)
fn add_assign(&mut self, rhs: &DynResidue<LIMBS>)
+=
operation. Read moreSource§impl<const LIMBS: usize> AddAssign for DynResidue<LIMBS>
impl<const LIMBS: usize> AddAssign for DynResidue<LIMBS>
Source§fn add_assign(&mut self, rhs: DynResidue<LIMBS>)
fn add_assign(&mut self, rhs: DynResidue<LIMBS>)
+=
operation. Read moreSource§impl<const LIMBS: usize> Clone for DynResidue<LIMBS>
impl<const LIMBS: usize> Clone for DynResidue<LIMBS>
Source§fn clone(&self) -> DynResidue<LIMBS>
fn clone(&self) -> DynResidue<LIMBS>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<const LIMBS: usize> ConditionallySelectable for DynResidue<LIMBS>
impl<const LIMBS: usize> ConditionallySelectable for DynResidue<LIMBS>
Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
self
and other
if choice == 1
; otherwise,
reassign both unto themselves. Read moreSource§impl<const LIMBS: usize> ConstantTimeEq for DynResidue<LIMBS>
impl<const LIMBS: usize> ConstantTimeEq for DynResidue<LIMBS>
Source§impl<const LIMBS: usize> Debug for DynResidue<LIMBS>
impl<const LIMBS: usize> Debug for DynResidue<LIMBS>
Source§impl<const LIMBS: usize, P: ResidueParams<LIMBS>> From<&Residue<P, LIMBS>> for DynResidue<LIMBS>
impl<const LIMBS: usize, P: ResidueParams<LIMBS>> From<&Residue<P, LIMBS>> for DynResidue<LIMBS>
Source§impl<const LIMBS: usize> Invert for DynResidue<LIMBS>
impl<const LIMBS: usize> Invert for DynResidue<LIMBS>
Source§impl<const LIMBS: usize> Mul<&DynResidue<LIMBS>> for &DynResidue<LIMBS>
impl<const LIMBS: usize> Mul<&DynResidue<LIMBS>> for &DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
*
operator.Source§fn mul(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn mul(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
*
operation. Read moreSource§impl<const LIMBS: usize> Mul<&DynResidue<LIMBS>> for DynResidue<LIMBS>
impl<const LIMBS: usize> Mul<&DynResidue<LIMBS>> for DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
*
operator.Source§fn mul(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn mul(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
*
operation. Read moreSource§impl<const LIMBS: usize> Mul<DynResidue<LIMBS>> for &DynResidue<LIMBS>
impl<const LIMBS: usize> Mul<DynResidue<LIMBS>> for &DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
*
operator.Source§fn mul(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn mul(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
*
operation. Read moreSource§impl<const LIMBS: usize> Mul for DynResidue<LIMBS>
impl<const LIMBS: usize> Mul for DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
*
operator.Source§fn mul(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn mul(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
*
operation. Read moreSource§impl<const LIMBS: usize> MulAssign<&DynResidue<LIMBS>> for DynResidue<LIMBS>
impl<const LIMBS: usize> MulAssign<&DynResidue<LIMBS>> for DynResidue<LIMBS>
Source§fn mul_assign(&mut self, rhs: &DynResidue<LIMBS>)
fn mul_assign(&mut self, rhs: &DynResidue<LIMBS>)
*=
operation. Read moreSource§impl<const LIMBS: usize> MulAssign for DynResidue<LIMBS>
impl<const LIMBS: usize> MulAssign for DynResidue<LIMBS>
Source§fn mul_assign(&mut self, rhs: DynResidue<LIMBS>)
fn mul_assign(&mut self, rhs: DynResidue<LIMBS>)
*=
operation. Read moreSource§impl<const N: usize, const LIMBS: usize, const RHS_LIMBS: usize> MultiExponentiateBoundedExp<Uint<RHS_LIMBS>, [(DynResidue<LIMBS>, Uint<RHS_LIMBS>); N]> for DynResidue<LIMBS>
impl<const N: usize, const LIMBS: usize, const RHS_LIMBS: usize> MultiExponentiateBoundedExp<Uint<RHS_LIMBS>, [(DynResidue<LIMBS>, Uint<RHS_LIMBS>); N]> for DynResidue<LIMBS>
Source§impl<const LIMBS: usize> Neg for &DynResidue<LIMBS>
impl<const LIMBS: usize> Neg for &DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
-
operator.Source§fn neg(self) -> DynResidue<LIMBS>
fn neg(self) -> DynResidue<LIMBS>
-
operation. Read moreSource§impl<const LIMBS: usize> Neg for DynResidue<LIMBS>
impl<const LIMBS: usize> Neg for DynResidue<LIMBS>
Source§impl<const LIMBS: usize> PartialEq for DynResidue<LIMBS>
impl<const LIMBS: usize> PartialEq for DynResidue<LIMBS>
Source§impl<const LIMBS: usize, const RHS_LIMBS: usize> PowBoundedExp<Uint<RHS_LIMBS>> for DynResidue<LIMBS>
impl<const LIMBS: usize, const RHS_LIMBS: usize> PowBoundedExp<Uint<RHS_LIMBS>> for DynResidue<LIMBS>
Source§impl<const LIMBS: usize> Retrieve for DynResidue<LIMBS>
impl<const LIMBS: usize> Retrieve for DynResidue<LIMBS>
Source§impl<const LIMBS: usize> Square for DynResidue<LIMBS>
impl<const LIMBS: usize> Square for DynResidue<LIMBS>
Source§impl<const LIMBS: usize> Sub<&DynResidue<LIMBS>> for &DynResidue<LIMBS>
impl<const LIMBS: usize> Sub<&DynResidue<LIMBS>> for &DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
-
operator.Source§fn sub(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn sub(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
-
operation. Read moreSource§impl<const LIMBS: usize> Sub<&DynResidue<LIMBS>> for DynResidue<LIMBS>
impl<const LIMBS: usize> Sub<&DynResidue<LIMBS>> for DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
-
operator.Source§fn sub(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn sub(self, rhs: &DynResidue<LIMBS>) -> DynResidue<LIMBS>
-
operation. Read moreSource§impl<const LIMBS: usize> Sub<DynResidue<LIMBS>> for &DynResidue<LIMBS>
impl<const LIMBS: usize> Sub<DynResidue<LIMBS>> for &DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
-
operator.Source§fn sub(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn sub(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
-
operation. Read moreSource§impl<const LIMBS: usize> Sub for DynResidue<LIMBS>
impl<const LIMBS: usize> Sub for DynResidue<LIMBS>
Source§type Output = DynResidue<LIMBS>
type Output = DynResidue<LIMBS>
-
operator.Source§fn sub(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
fn sub(self, rhs: DynResidue<LIMBS>) -> DynResidue<LIMBS>
-
operation. Read moreSource§impl<const LIMBS: usize> SubAssign<&DynResidue<LIMBS>> for DynResidue<LIMBS>
impl<const LIMBS: usize> SubAssign<&DynResidue<LIMBS>> for DynResidue<LIMBS>
Source§fn sub_assign(&mut self, rhs: &DynResidue<LIMBS>)
fn sub_assign(&mut self, rhs: &DynResidue<LIMBS>)
-=
operation. Read moreSource§impl<const LIMBS: usize> SubAssign for DynResidue<LIMBS>
impl<const LIMBS: usize> SubAssign for DynResidue<LIMBS>
Source§fn sub_assign(&mut self, rhs: DynResidue<LIMBS>)
fn sub_assign(&mut self, rhs: DynResidue<LIMBS>)
-=
operation. Read moreSource§impl<const LIMBS: usize> Zeroize for DynResidue<LIMBS>
Available on crate feature zeroize
only.
impl<const LIMBS: usize> Zeroize for DynResidue<LIMBS>
zeroize
only.NOTE: this does not zeroize the parameters, in order to maintain some form of type consistency
impl<const LIMBS: usize> Copy for DynResidue<LIMBS>
impl<const LIMBS: usize> Eq for DynResidue<LIMBS>
impl<const LIMBS: usize> StructuralPartialEq for DynResidue<LIMBS>
Auto Trait Implementations§
impl<const LIMBS: usize> Freeze for DynResidue<LIMBS>
impl<const LIMBS: usize> RefUnwindSafe for DynResidue<LIMBS>
impl<const LIMBS: usize> Send for DynResidue<LIMBS>
impl<const LIMBS: usize> Sync for DynResidue<LIMBS>
impl<const LIMBS: usize> Unpin for DynResidue<LIMBS>
impl<const LIMBS: usize> UnwindSafe for DynResidue<LIMBS>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ConditionallyNegatable for T
impl<T> ConditionallyNegatable for T
Source§fn conditional_negate(&mut self, choice: Choice)
fn conditional_negate(&mut self, choice: Choice)
Source§impl<T, Exponent, BasesAndExponents> MultiExponentiate<Exponent, BasesAndExponents> for Twhere
T: MultiExponentiateBoundedExp<Exponent, BasesAndExponents>,
Exponent: Bounded,
BasesAndExponents: AsRef<[(T, Exponent)]> + ?Sized,
impl<T, Exponent, BasesAndExponents> MultiExponentiate<Exponent, BasesAndExponents> for Twhere
T: MultiExponentiateBoundedExp<Exponent, BasesAndExponents>,
Exponent: Bounded,
BasesAndExponents: AsRef<[(T, Exponent)]> + ?Sized,
Source§fn multi_exponentiate(bases_and_exponents: &BasesAndExponents) -> T
fn multi_exponentiate(bases_and_exponents: &BasesAndExponents) -> T
x1 ^ k1 * ... * xn ^ kn
.Source§impl<T, Exponent> Pow<Exponent> for Twhere
T: PowBoundedExp<Exponent>,
Exponent: Bounded,
impl<T, Exponent> Pow<Exponent> for Twhere
T: PowBoundedExp<Exponent>,
Exponent: Bounded,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.