pub struct BoxedMontyForm { /* private fields */ }
alloc
only.Expand description
An integer in Montgomery form represented using heap-allocated limbs.
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 value 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.
This method will panic if products
is empty. All terms must be associated
with equivalent MontyParams
.
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 new_with_arc(integer: BoxedUint, params: Arc<BoxedMontyParams>) -> Self
pub fn new_with_arc(integer: BoxedUint, params: Arc<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 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.
Trait Implementations§
Source§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 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 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 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 Clone for BoxedMontyForm
impl Clone for BoxedMontyForm
Source§fn clone(&self) -> BoxedMontyForm
fn clone(&self) -> BoxedMontyForm
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for BoxedMontyForm
impl Debug for BoxedMontyForm
Source§impl Invert for BoxedMontyForm
impl Invert for BoxedMontyForm
Source§impl Monty for BoxedMontyForm
impl Monty for BoxedMontyForm
Source§type Params = BoxedMontyParams
type Params = BoxedMontyParams
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 lincomb_vartime(products: &[(&Self, &Self)]) -> Self
fn lincomb_vartime(products: &[(&Self, &Self)]) -> Self
Source§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 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 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 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 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 Neg for BoxedMontyForm
impl Neg for BoxedMontyForm
Source§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
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
.Source§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 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 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 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 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!