@@ -141,6 +141,10 @@ pub trait Integer:
141141 + WrappingShr
142142 + Zero
143143{
144+ /// The corresponding Montgomery representation,
145+ /// optimized for the performance of modular operations at the price of a conversion overhead.
146+ type MontyForm : MontyFormLike < Integer = Self > ;
147+
144148 /// The value `1`.
145149 fn one ( ) -> Self ;
146150
@@ -514,16 +518,10 @@ pub trait WideningMul<Rhs = Self>: Sized {
514518 fn widening_mul ( & self , rhs : Rhs ) -> Self :: Output ;
515519}
516520
517- /// This integer has a representation optimized for the performance of modular operations.
518- pub trait HasMontyForm {
519- /// The representation type.
520- type MontyForm : MontyFormLike < Raw = Self > ;
521- }
522-
523521/// A representation of an integer optimized for the performance of modular operations.
524522pub trait MontyFormLike {
525523 /// The original integer type.
526- type Raw : HasMontyForm < MontyForm = Self > ;
524+ type Integer : Integer < MontyForm = Self > ;
527525
528526 /// The precomputed data needed for this representation.
529527 type Params : Clone ;
@@ -532,10 +530,10 @@ pub trait MontyFormLike {
532530 ///
533531 /// Can return `None` if `modulus` is not valid for the representation;
534532 /// see the documentation of the specific type for the requirements.
535- fn new_params ( modulus : Self :: Raw ) -> CtOption < Self :: Params > ;
533+ fn new_params ( modulus : Self :: Integer ) -> CtOption < Self :: Params > ;
536534
537535 /// Convert the value into the representation using precomputed data.
538- fn new ( value : Self :: Raw , params : Self :: Params ) -> Self ;
536+ fn new ( value : Self :: Integer , params : Self :: Params ) -> Self ;
539537
540538 /// Returns zero in this representation.
541539 fn zero ( params : Self :: Params ) -> Self ;
0 commit comments