pub trait Monty:
'static
+ Clone
+ Debug
+ Eq
+ Sized
+ Send
+ Sync
+ Add<Output = Self>
+ for<'a> Add<&'a Self, Output = Self>
+ AddAssign
+ for<'a> AddAssign<&'a Self>
+ Sub<Output = Self>
+ for<'a> Sub<&'a Self, Output = Self>
+ SubAssign
+ for<'a> SubAssign<&'a Self>
+ Mul<Output = Self>
+ for<'a> Mul<&'a Self, Output = Self>
+ MulAssign
+ for<'a> MulAssign<&'a Self>
+ Neg<Output = Self>
+ PowBoundedExp<Self::Integer>
+ Square
+ SquareAssign {
type Integer: Integer<Monty = Self>;
type Params: 'static + Clone + Debug + Eq + Sized + Send + Sync;
// Required methods
fn new_params_vartime(modulus: Odd<Self::Integer>) -> Self::Params;
fn new(value: Self::Integer, params: Self::Params) -> Self;
fn zero(params: Self::Params) -> Self;
fn one(params: Self::Params) -> Self;
fn params(&self) -> &Self::Params;
fn as_montgomery(&self) -> &Self::Integer;
fn double(&self) -> Self;
fn div_by_2(&self) -> Self;
fn lincomb_vartime(products: &[(&Self, &Self)]) -> Self;
}
Expand description
A representation of an integer optimized for the performance of modular operations.
Required Associated Types§
Required Methods§
Sourcefn new_params_vartime(modulus: Odd<Self::Integer>) -> Self::Params
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
.
Sourcefn new(value: Self::Integer, params: Self::Params) -> Self
fn new(value: Self::Integer, params: Self::Params) -> Self
Convert the value into the representation using precomputed data.
Sourcefn as_montgomery(&self) -> &Self::Integer
fn as_montgomery(&self) -> &Self::Integer
Access the value in Montgomery form.
Sourcefn lincomb_vartime(products: &[(&Self, &Self)]) -> Self
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
Montgomery parameters.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.