Struct crypto_bigint::modular::runtime_mod::DynResidue
source · 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>
§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>
§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>
§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>
§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§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>
§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>
§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>
§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>
§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>
§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§fn eq(&self, other: &DynResidue<LIMBS>) -> bool
fn eq(&self, other: &DynResidue<LIMBS>) -> bool
self
and other
values to be equal, and is used
by ==
.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>
§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>
§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>
§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>
§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>
impl<const LIMBS: usize> Zeroize for DynResidue<LIMBS>
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: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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
.