pub struct BoxedMontyForm {
montgomery_form: BoxedUint,
params: BoxedMontyParams,
}Expand description
An integer in Montgomery form represented using heap-allocated limbs.
Fields§
§montgomery_form: BoxedUintValue in the Montgomery form.
params: BoxedMontyParamsMontgomery form parameters.
Implementations§
Source§impl BoxedMontyForm
impl BoxedMontyForm
Sourcepub fn invert(&self) -> CtOption<Self>
pub fn invert(&self) -> CtOption<Self>
Computes self^-1 representing the multiplicative inverse of self,
i.e. self * self^-1 = 1.
Sourcepub fn invert_vartime(&self) -> CtOption<Self>
pub fn invert_vartime(&self) -> CtOption<Self>
Computes self^-1 representing the multiplicative inverse of self,
i.e. self * self^-1 = 1.
This version is variable-time with respect to the self of self, but constant-time with
respect to self’s params.
Source§impl BoxedMontyForm
impl BoxedMontyForm
Sourcepub fn lincomb_vartime(products: &[(&Self, &Self)]) -> Self
pub fn lincomb_vartime(products: &[(&Self, &Self)]) -> Self
Calculate the sum of products of pairs (a, b) in products.
This method is variable time only with the value of the modulus.
For a modulus with leading zeros, this method is more efficient than a naive sum of products.
All terms must be associated with equivalent MontyParams.
§Panics
- if
productsis empty.
Source§impl BoxedMontyForm
impl BoxedMontyForm
Sourcepub fn pow_bounded_exp(&self, exponent: &BoxedUint, exponent_bits: u32) -> Self
pub fn pow_bounded_exp(&self, exponent: &BoxedUint, exponent_bits: u32) -> 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 BoxedMontyForm
impl BoxedMontyForm
Sourcepub fn new(integer: BoxedUint, params: &BoxedMontyParams) -> Self
pub fn new(integer: BoxedUint, params: &BoxedMontyParams) -> Self
Instantiates a new BoxedMontyForm that represents an integer modulo the provided params.
Sourcepub fn bits_precision(&self) -> u32
pub fn bits_precision(&self) -> u32
Bits of precision in the modulus.
Sourcepub fn retrieve(&self) -> BoxedUint
pub fn retrieve(&self) -> BoxedUint
Retrieves the integer currently encoded in this BoxedMontyForm, guaranteed to be reduced.
Sourcepub fn zero(params: &BoxedMontyParams) -> Self
pub fn zero(params: &BoxedMontyParams) -> Self
Instantiates a new ConstMontyForm that represents zero.
Sourcepub fn one(params: &BoxedMontyParams) -> Self
pub fn one(params: &BoxedMontyParams) -> Self
Instantiates a new ConstMontyForm that represents 1.
Sourcepub fn is_zero(&self) -> Choice
pub fn is_zero(&self) -> Choice
Determine if this value is equal to zero.
§Returns
If zero, returns Choice(1). Otherwise, returns Choice(0).
Sourcepub fn is_nonzero(&self) -> Choice
pub fn is_nonzero(&self) -> Choice
Determine if this value is not equal to zero.
§Returns
If zero, returns Choice(0). Otherwise, returns Choice(1).
Sourcepub fn params(&self) -> &BoxedMontyParams
pub fn params(&self) -> &BoxedMontyParams
Returns the parameter struct used to initialize this object.
Sourcepub fn as_montgomery(&self) -> &BoxedUint
pub fn as_montgomery(&self) -> &BoxedUint
Access the BoxedMontyForm value in Montgomery form.
Sourcepub fn as_montgomery_mut(&mut self) -> &mut BoxedUint
pub fn as_montgomery_mut(&mut self) -> &mut BoxedUint
Mutably access the BoxedMontyForm value in Montgomery form.
Sourcepub fn from_montgomery(integer: BoxedUint, params: &BoxedMontyParams) -> Self
pub fn from_montgomery(integer: BoxedUint, params: &BoxedMontyParams) -> Self
Create a BoxedMontyForm from a value in Montgomery form.
Sourcepub fn to_montgomery(&self) -> BoxedUint
pub fn to_montgomery(&self) -> BoxedUint
Extract the value from the BoxedMontyForm in Montgomery form.
Sourcepub fn div_by_2(&self) -> Self
pub fn div_by_2(&self) -> Self
Performs division by 2, that is returns x such that x + x = self.
Sourcepub fn div_by_2_assign(&mut self)
pub fn div_by_2_assign(&mut self)
Performs division by 2 inplace, that is finds x such that x + x = self
and writes it into self.
Trait Implementations§
Source§impl Add for BoxedMontyForm
impl Add for BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
+ operator.Source§fn add(self, rhs: BoxedMontyForm) -> BoxedMontyForm
fn add(self, rhs: BoxedMontyForm) -> BoxedMontyForm
+ operation. Read moreSource§impl Add<&BoxedMontyForm> for &BoxedMontyForm
impl Add<&BoxedMontyForm> for &BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
+ operator.Source§fn add(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
fn add(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
+ operation. Read moreSource§impl Add<&BoxedMontyForm> for BoxedMontyForm
impl Add<&BoxedMontyForm> for BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
+ operator.Source§fn add(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
fn add(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
+ operation. Read moreSource§impl Add<BoxedMontyForm> for &BoxedMontyForm
impl Add<BoxedMontyForm> for &BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
+ operator.Source§fn add(self, rhs: BoxedMontyForm) -> BoxedMontyForm
fn add(self, rhs: BoxedMontyForm) -> BoxedMontyForm
+ operation. Read moreSource§impl AddAssign for BoxedMontyForm
impl AddAssign for BoxedMontyForm
Source§fn add_assign(&mut self, rhs: BoxedMontyForm)
fn add_assign(&mut self, rhs: BoxedMontyForm)
+= operation. Read moreSource§impl AddAssign<&BoxedMontyForm> for BoxedMontyForm
impl AddAssign<&BoxedMontyForm> for BoxedMontyForm
Source§fn add_assign(&mut self, rhs: &BoxedMontyForm)
fn add_assign(&mut self, rhs: &BoxedMontyForm)
+= operation. Read moreSource§impl Clone for BoxedMontyForm
impl Clone for BoxedMontyForm
Source§fn clone(&self) -> BoxedMontyForm
fn clone(&self) -> BoxedMontyForm
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl CtAssignSlice for BoxedMontyForm
impl CtAssignSlice for BoxedMontyForm
Source§fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice)
fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice)
Source§impl CtEq for BoxedMontyForm
impl CtEq for BoxedMontyForm
Source§impl CtEqSlice for BoxedMontyForm
impl CtEqSlice for BoxedMontyForm
Source§fn ct_eq_slice(a: &[Self], b: &[Self]) -> Choice
fn ct_eq_slice(a: &[Self], b: &[Self]) -> Choice
a is equal to b in constant-time.Source§fn ct_ne_slice(a: &[Self], b: &[Self]) -> Choice
fn ct_ne_slice(a: &[Self], b: &[Self]) -> Choice
a is NOT equal to b in constant-time.impl CtSelectUsingCtAssign for BoxedMontyForm
Source§impl Debug for BoxedMontyForm
impl Debug for BoxedMontyForm
impl Eq for BoxedMontyForm
Source§impl<const LIMBS: usize, Params> From<&ConstMontyForm<Params, LIMBS>> for BoxedMontyFormwhere
Params: ConstMontyParams<LIMBS>,
impl<const LIMBS: usize, Params> From<&ConstMontyForm<Params, LIMBS>> for BoxedMontyFormwhere
Params: ConstMontyParams<LIMBS>,
Source§fn from(input: &ConstMontyForm<Params, LIMBS>) -> Self
fn from(input: &ConstMontyForm<Params, LIMBS>) -> Self
Source§impl<const LIMBS: usize> From<&FixedMontyForm<LIMBS>> for BoxedMontyForm
impl<const LIMBS: usize> From<&FixedMontyForm<LIMBS>> for BoxedMontyForm
Source§fn from(input: &FixedMontyForm<LIMBS>) -> Self
fn from(input: &FixedMontyForm<LIMBS>) -> Self
Source§impl<const LIMBS: usize, Params> From<ConstMontyForm<Params, LIMBS>> for BoxedMontyFormwhere
Params: ConstMontyParams<LIMBS>,
impl<const LIMBS: usize, Params> From<ConstMontyForm<Params, LIMBS>> for BoxedMontyFormwhere
Params: ConstMontyParams<LIMBS>,
Source§fn from(input: ConstMontyForm<Params, LIMBS>) -> Self
fn from(input: ConstMontyForm<Params, LIMBS>) -> Self
Source§impl<const LIMBS: usize> From<FixedMontyForm<LIMBS>> for BoxedMontyForm
impl<const LIMBS: usize> From<FixedMontyForm<LIMBS>> for BoxedMontyForm
Source§fn from(input: FixedMontyForm<LIMBS>) -> Self
fn from(input: FixedMontyForm<LIMBS>) -> Self
Source§impl Invert for BoxedMontyForm
impl Invert for BoxedMontyForm
Source§impl MontyForm for BoxedMontyForm
impl MontyForm for BoxedMontyForm
Source§type Params = BoxedMontyParams
type Params = BoxedMontyParams
Source§type Multiplier<'a> = BoxedMontyMultiplier<'a>
type Multiplier<'a> = BoxedMontyMultiplier<'a>
Source§fn new_params_vartime(modulus: Odd<Self::Integer>) -> Self::Params
fn new_params_vartime(modulus: Odd<Self::Integer>) -> Self::Params
modulus,
variable time in modulus.Source§fn new(value: Self::Integer, params: &Self::Params) -> Self
fn new(value: Self::Integer, params: &Self::Params) -> Self
Source§fn params(&self) -> &Self::Params
fn params(&self) -> &Self::Params
Source§fn as_montgomery(&self) -> &Self::Integer
fn as_montgomery(&self) -> &Self::Integer
Source§fn copy_montgomery_from(&mut self, other: &Self)
fn copy_montgomery_from(&mut self, other: &Self)
other into self.
NOTE: the parameters remain unchanged.Source§fn from_montgomery(integer: Self::Integer, params: &Self::Params) -> Self
fn from_montgomery(integer: Self::Integer, params: &Self::Params) -> Self
Source§fn into_montgomery(self) -> Self::Integer
fn into_montgomery(self) -> Self::Integer
self and return it.Source§fn div_by_2_assign(&mut self)
fn div_by_2_assign(&mut self)
x such that x + x = self
and writes it into self.Source§fn lincomb_vartime(products: &[(&Self, &Self)]) -> Self
fn lincomb_vartime(products: &[(&Self, &Self)]) -> Self
Source§impl Mul for BoxedMontyForm
impl Mul for BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
* operator.Source§fn mul(self, rhs: BoxedMontyForm) -> BoxedMontyForm
fn mul(self, rhs: BoxedMontyForm) -> BoxedMontyForm
* operation. Read moreSource§impl Mul<&BoxedMontyForm> for &BoxedMontyForm
impl Mul<&BoxedMontyForm> for &BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
* operator.Source§fn mul(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
fn mul(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
* operation. Read moreSource§impl Mul<&BoxedMontyForm> for BoxedMontyForm
impl Mul<&BoxedMontyForm> for BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
* operator.Source§fn mul(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
fn mul(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
* operation. Read moreSource§impl Mul<BoxedMontyForm> for &BoxedMontyForm
impl Mul<BoxedMontyForm> for &BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
* operator.Source§fn mul(self, rhs: BoxedMontyForm) -> BoxedMontyForm
fn mul(self, rhs: BoxedMontyForm) -> BoxedMontyForm
* operation. Read moreSource§impl MulAssign for BoxedMontyForm
impl MulAssign for BoxedMontyForm
Source§fn mul_assign(&mut self, rhs: BoxedMontyForm)
fn mul_assign(&mut self, rhs: BoxedMontyForm)
*= operation. Read moreSource§impl MulAssign<&BoxedMontyForm> for BoxedMontyForm
impl MulAssign<&BoxedMontyForm> for BoxedMontyForm
Source§fn mul_assign(&mut self, rhs: &BoxedMontyForm)
fn mul_assign(&mut self, rhs: &BoxedMontyForm)
*= operation. Read moreSource§impl Neg for BoxedMontyForm
impl Neg for BoxedMontyForm
Source§impl Neg for &BoxedMontyForm
impl Neg for &BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
- operator.Source§fn neg(self) -> BoxedMontyForm
fn neg(self) -> BoxedMontyForm
- operation. Read moreSource§impl PartialEq for BoxedMontyForm
impl PartialEq for BoxedMontyForm
Source§impl PowBoundedExp<BoxedUint> for BoxedMontyForm
impl PowBoundedExp<BoxedUint> for BoxedMontyForm
Source§impl Retrieve for BoxedMontyForm
impl Retrieve for BoxedMontyForm
impl Sealed for BoxedMontyForm
Source§impl Square for BoxedMontyForm
impl Square for BoxedMontyForm
Source§impl SquareAssign for BoxedMontyForm
impl SquareAssign for BoxedMontyForm
Source§fn square_assign(&mut self)
fn square_assign(&mut self)
self * self, but may be more efficient.
Writes the result in self.impl StructuralPartialEq for BoxedMontyForm
Source§impl Sub for BoxedMontyForm
impl Sub for BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
- operator.Source§fn sub(self, rhs: BoxedMontyForm) -> BoxedMontyForm
fn sub(self, rhs: BoxedMontyForm) -> BoxedMontyForm
- operation. Read moreSource§impl Sub<&BoxedMontyForm> for &BoxedMontyForm
impl Sub<&BoxedMontyForm> for &BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
- operator.Source§fn sub(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
fn sub(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
- operation. Read moreSource§impl Sub<&BoxedMontyForm> for BoxedMontyForm
impl Sub<&BoxedMontyForm> for BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
- operator.Source§fn sub(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
fn sub(self, rhs: &BoxedMontyForm) -> BoxedMontyForm
- operation. Read moreSource§impl Sub<BoxedMontyForm> for &BoxedMontyForm
impl Sub<BoxedMontyForm> for &BoxedMontyForm
Source§type Output = BoxedMontyForm
type Output = BoxedMontyForm
- operator.Source§fn sub(self, rhs: BoxedMontyForm) -> BoxedMontyForm
fn sub(self, rhs: BoxedMontyForm) -> BoxedMontyForm
- operation. Read moreSource§impl SubAssign for BoxedMontyForm
impl SubAssign for BoxedMontyForm
Source§fn sub_assign(&mut self, rhs: BoxedMontyForm)
fn sub_assign(&mut self, rhs: BoxedMontyForm)
-= operation. Read moreSource§impl SubAssign<&BoxedMontyForm> for BoxedMontyForm
impl SubAssign<&BoxedMontyForm> for BoxedMontyForm
Source§fn sub_assign(&mut self, rhs: &BoxedMontyForm)
fn sub_assign(&mut self, rhs: &BoxedMontyForm)
-= operation. Read moreSource§impl Zeroize for BoxedMontyForm
Available on crate feature zeroize only.NOTE: This zeroizes the value, but not the associated parameters!
impl Zeroize for BoxedMontyForm
zeroize only.NOTE: This zeroizes the value, but not the associated parameters!