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 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 moreimpl Eq for BoxedMontyForm
impl StructuralPartialEq for BoxedMontyForm
Auto Trait Implementations§
impl Freeze for BoxedMontyForm
impl RefUnwindSafe for BoxedMontyForm
impl Send for BoxedMontyForm
impl Sync for BoxedMontyForm
impl Unpin for BoxedMontyForm
impl UnwindSafe for BoxedMontyForm
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)