pub struct BoxedMontyForm { /* private fields */ }
Available on crate feature alloc only.
Expand description

An integer in Montgomery form represented using heap-allocated limbs.

Implementations§

source§

impl BoxedMontyForm

source

pub fn add(&self, rhs: &Self) -> Self

Adds rhs.

source§

impl BoxedMontyForm

source

pub fn invert(&self) -> CtOption<Self>

Computes self^-1 representing the multiplicative inverse of self. I.e. self * self^-1 = 1.

source§

impl BoxedMontyForm

source

pub fn mul(&self, rhs: &Self) -> Self

Multiplies by rhs.

source

pub fn square(&self) -> Self

Computes the (reduced) square.

source§

impl BoxedMontyForm

source

pub fn neg(&self) -> Self

Negates the number.

source§

impl BoxedMontyForm

source

pub fn pow(&self, exponent: &BoxedUint) -> Self

Raises to the exponent power.

source

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

source

pub fn sub(&self, rhs: &Self) -> Self

Subtracts rhs.

source§

impl BoxedMontyForm

source

pub fn new(integer: BoxedUint, params: BoxedMontyParams) -> Self

Instantiates a new BoxedMontyForm that represents an integer modulo the provided params.

source

pub fn new_with_arc(integer: BoxedUint, params: Arc<BoxedMontyParams>) -> Self

Available on crate feature std only.

Instantiates a new BoxedMontyForm that represents an integer modulo the provided params.

source

pub fn bits_precision(&self) -> u32

Bits of precision in the modulus.

source

pub fn retrieve(&self) -> BoxedUint

Retrieves the integer currently encoded in this BoxedMontyForm, guaranteed to be reduced.

source

pub fn zero(params: BoxedMontyParams) -> Self

Instantiates a new ConstMontyForm that represents zero.

source

pub fn one(params: BoxedMontyParams) -> Self

Instantiates a new ConstMontyForm that represents 1.

source

pub fn params(&self) -> &BoxedMontyParams

Returns the parameter struct used to initialize this object.

source

pub fn as_montgomery(&self) -> &BoxedUint

Access the BoxedMontyForm value in Montgomery form.

source

pub fn from_montgomery(integer: BoxedUint, params: BoxedMontyParams) -> Self

Create a BoxedMontyForm from a value in Montgomery form.

source

pub fn to_montgomery(&self) -> BoxedUint

Extract the value from the BoxedMontyForm in Montgomery form.

source

pub fn div_by_2(&self) -> Self

Performs division by 2, that is returns x such that x + x = self.

Trait Implementations§

source§

impl Add<&BoxedMontyForm> for &BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the + operator.
source§

fn add(self, rhs: &BoxedMontyForm) -> BoxedMontyForm

Performs the + operation. Read more
source§

impl Add<&BoxedMontyForm> for BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the + operator.
source§

fn add(self, rhs: &BoxedMontyForm) -> BoxedMontyForm

Performs the + operation. Read more
source§

impl Add<BoxedMontyForm> for &BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the + operator.
source§

fn add(self, rhs: BoxedMontyForm) -> BoxedMontyForm

Performs the + operation. Read more
source§

impl Add for BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the + operator.
source§

fn add(self, rhs: BoxedMontyForm) -> BoxedMontyForm

Performs the + operation. Read more
source§

impl AddAssign<&BoxedMontyForm> for BoxedMontyForm

source§

fn add_assign(&mut self, rhs: &BoxedMontyForm)

Performs the += operation. Read more
source§

impl AddAssign for BoxedMontyForm

source§

fn add_assign(&mut self, rhs: BoxedMontyForm)

Performs the += operation. Read more
source§

impl Clone for BoxedMontyForm

source§

fn clone(&self) -> BoxedMontyForm

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for BoxedMontyForm

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Invert for BoxedMontyForm

§

type Output = CtOption<BoxedMontyForm>

Output of the inversion.
source§

fn invert(&self) -> Self::Output

Computes the inverse.
source§

impl Monty for BoxedMontyForm

§

type Integer = BoxedUint

The original integer type.
§

type Params = BoxedMontyParams

The precomputed data needed for this representation.
source§

fn new_params_vartime(modulus: Odd<Self::Integer>) -> Self::Params

Create the precomputed data for Montgomery representation of integers modulo modulus, variable time in modulus.
source§

fn new(value: Self::Integer, params: Self::Params) -> Self

Convert the value into the representation using precomputed data.
source§

fn zero(params: Self::Params) -> Self

Returns zero in this representation.
source§

fn one(params: Self::Params) -> Self

Returns one in this representation.
source§

fn params(&self) -> &Self::Params

Returns the parameter struct used to initialize this object.
source§

fn as_montgomery(&self) -> &Self::Integer

Access the value in Montgomery form.
source§

fn div_by_2(&self) -> Self

Performs division by 2, that is returns x such that x + x = self.
source§

impl Mul<&BoxedMontyForm> for &BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &BoxedMontyForm) -> BoxedMontyForm

Performs the * operation. Read more
source§

impl Mul<&BoxedMontyForm> for BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &BoxedMontyForm) -> BoxedMontyForm

Performs the * operation. Read more
source§

impl Mul<BoxedMontyForm> for &BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the * operator.
source§

fn mul(self, rhs: BoxedMontyForm) -> BoxedMontyForm

Performs the * operation. Read more
source§

impl Mul for BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the * operator.
source§

fn mul(self, rhs: BoxedMontyForm) -> BoxedMontyForm

Performs the * operation. Read more
source§

impl MulAssign<&BoxedMontyForm> for BoxedMontyForm

source§

fn mul_assign(&mut self, rhs: &BoxedMontyForm)

Performs the *= operation. Read more
source§

impl MulAssign for BoxedMontyForm

source§

fn mul_assign(&mut self, rhs: BoxedMontyForm)

Performs the *= operation. Read more
source§

impl Neg for &BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the - operator.
source§

fn neg(self) -> BoxedMontyForm

Performs the unary - operation. Read more
source§

impl Neg for BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl PartialEq for BoxedMontyForm

source§

fn eq(&self, other: &BoxedMontyForm) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PowBoundedExp<BoxedUint> for BoxedMontyForm

source§

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. Read more
source§

impl Retrieve for BoxedMontyForm

§

type Output = BoxedUint

The original type.
source§

fn retrieve(&self) -> BoxedUint

Convert the number back from the optimized representation.
source§

impl Square for BoxedMontyForm

source§

fn square(&self) -> Self

Computes the same as self * self, but may be more efficient.
source§

impl SquareAssign for BoxedMontyForm

source§

fn square_assign(&mut self)

Computes the same as self * self, but may be more efficient. Writes the result in self.
source§

impl Sub<&BoxedMontyForm> for &BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &BoxedMontyForm) -> BoxedMontyForm

Performs the - operation. Read more
source§

impl Sub<&BoxedMontyForm> for BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &BoxedMontyForm) -> BoxedMontyForm

Performs the - operation. Read more
source§

impl Sub<BoxedMontyForm> for &BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the - operator.
source§

fn sub(self, rhs: BoxedMontyForm) -> BoxedMontyForm

Performs the - operation. Read more
source§

impl Sub for BoxedMontyForm

§

type Output = BoxedMontyForm

The resulting type after applying the - operator.
source§

fn sub(self, rhs: BoxedMontyForm) -> BoxedMontyForm

Performs the - operation. Read more
source§

impl SubAssign<&BoxedMontyForm> for BoxedMontyForm

source§

fn sub_assign(&mut self, rhs: &BoxedMontyForm)

Performs the -= operation. Read more
source§

impl SubAssign for BoxedMontyForm

source§

fn sub_assign(&mut self, rhs: BoxedMontyForm)

Performs the -= operation. Read more
source§

impl Eq for BoxedMontyForm

source§

impl StructuralEq for BoxedMontyForm

source§

impl StructuralPartialEq for BoxedMontyForm

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, Exponent> Pow<Exponent> for T
where T: PowBoundedExp<Exponent>, Exponent: Bounded,

source§

fn pow(&self, exponent: &Exponent) -> T

Raises to the exponent power.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.