Trait crypto_bigint::Monty

source ·
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 div_by_2(&self) -> Self;
}
Expand description

A representation of an integer optimized for the performance of modular operations.

Required Associated Types§

source

type Integer: Integer<Monty = Self>

The original integer type.

source

type Params: 'static + Clone + Debug + Eq + Sized + Send + Sync

The precomputed data needed for this representation.

Required Methods§

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.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Monty for BoxedMontyForm

Available on crate feature alloc only.
source§

impl<const LIMBS: usize> Monty for MontyForm<LIMBS>

§

type Integer = Uint<LIMBS>

§

type Params = MontyParams<LIMBS>