@@ -80,9 +80,14 @@ pub const fn lincomb_const_monty_form<MOD: ConstMontyParams<LIMBS>, const LIMBS:
8080 let mut ret = Uint :: ZERO ;
8181 let mut remain = products. len ( ) ;
8282 if remain <= max_accum {
83- let carry =
84- impl_longa_monty_lincomb ! ( products, ret. limbs, modulus. 0 . limbs, mod_neg_inv, LIMBS ) ;
85- ret. try_sub_with_carry ( carry, & modulus. 0 ) . 0
83+ let carry = impl_longa_monty_lincomb ! (
84+ products,
85+ ret. limbs,
86+ modulus. as_ref( ) . limbs,
87+ mod_neg_inv,
88+ LIMBS
89+ ) ;
90+ ret. try_sub_with_carry ( carry, modulus. as_ref ( ) ) . 0
8691 } else {
8792 let mut window;
8893 while remain > 0 {
@@ -92,9 +97,14 @@ pub const fn lincomb_const_monty_form<MOD: ConstMontyParams<LIMBS>, const LIMBS:
9297 count = max_accum;
9398 }
9499 ( window, products) = products. split_at ( count) ;
95- let carry =
96- impl_longa_monty_lincomb ! ( window, buf. limbs, modulus. 0 . limbs, mod_neg_inv, LIMBS ) ;
97- buf = buf. try_sub_with_carry ( carry, & modulus. 0 ) . 0 ;
100+ let carry = impl_longa_monty_lincomb ! (
101+ window,
102+ buf. limbs,
103+ modulus. as_ref( ) . limbs,
104+ mod_neg_inv,
105+ LIMBS
106+ ) ;
107+ buf = buf. try_sub_with_carry ( carry, modulus. as_ref ( ) ) . 0 ;
98108 ret = ret. add_mod ( & buf, modulus. as_nz_ref ( ) ) ;
99109 remain -= count;
100110 }
@@ -112,9 +122,14 @@ pub const fn lincomb_monty_form<const LIMBS: usize>(
112122 let mut ret = Uint :: ZERO ;
113123 let mut remain = products. len ( ) ;
114124 if remain <= max_accum {
115- let carry =
116- impl_longa_monty_lincomb ! ( products, ret. limbs, modulus. 0 . limbs, mod_neg_inv, LIMBS ) ;
117- ret. try_sub_with_carry ( carry, & modulus. 0 ) . 0
125+ let carry = impl_longa_monty_lincomb ! (
126+ products,
127+ ret. limbs,
128+ modulus. as_ref( ) . limbs,
129+ mod_neg_inv,
130+ LIMBS
131+ ) ;
132+ ret. try_sub_with_carry ( carry, modulus. as_ref ( ) ) . 0
118133 } else {
119134 let mut window;
120135 while remain > 0 {
@@ -124,9 +139,14 @@ pub const fn lincomb_monty_form<const LIMBS: usize>(
124139 }
125140 ( window, products) = products. split_at ( count) ;
126141 let mut buf = Uint :: ZERO ;
127- let carry =
128- impl_longa_monty_lincomb ! ( window, buf. limbs, modulus. 0 . limbs, mod_neg_inv, LIMBS ) ;
129- buf = buf. try_sub_with_carry ( carry, & modulus. 0 ) . 0 ;
142+ let carry = impl_longa_monty_lincomb ! (
143+ window,
144+ buf. limbs,
145+ modulus. as_ref( ) . limbs,
146+ mod_neg_inv,
147+ LIMBS
148+ ) ;
149+ buf = buf. try_sub_with_carry ( carry, modulus. as_ref ( ) ) . 0 ;
130150 ret = ret. add_mod ( & buf, modulus. as_nz_ref ( ) ) ;
131151 remain -= count;
132152 }
@@ -142,26 +162,36 @@ pub fn lincomb_boxed_monty_form(
142162 mod_leading_zeros : u32 ,
143163) -> BoxedUint {
144164 let max_accum = 1 << u32_min ( mod_leading_zeros, usize:: BITS - 1 ) ;
145- let nlimbs = modulus. 0 . nlimbs ( ) ;
146- let mut ret = BoxedUint :: zero_with_precision ( modulus. 0 . bits_precision ( ) ) ;
165+ let nlimbs = modulus. as_ref ( ) . nlimbs ( ) ;
166+ let mut ret = BoxedUint :: zero_with_precision ( modulus. as_ref ( ) . bits_precision ( ) ) ;
147167 let mut remain = products. len ( ) ;
148168 if remain <= max_accum {
149- let carry =
150- impl_longa_monty_lincomb ! ( products, ret. limbs, modulus. 0 . limbs, mod_neg_inv, nlimbs) ;
151- ret. sub_assign_mod_with_carry ( carry, & modulus. 0 , & modulus. 0 ) ;
169+ let carry = impl_longa_monty_lincomb ! (
170+ products,
171+ ret. limbs,
172+ modulus. as_ref( ) . limbs,
173+ mod_neg_inv,
174+ nlimbs
175+ ) ;
176+ ret. sub_assign_mod_with_carry ( carry, modulus. as_ref ( ) , modulus. as_ref ( ) ) ;
152177 } else {
153178 let mut window;
154- let mut buf = BoxedUint :: zero_with_precision ( modulus. 0 . bits_precision ( ) ) ;
179+ let mut buf = BoxedUint :: zero_with_precision ( modulus. as_ref ( ) . bits_precision ( ) ) ;
155180 while remain > 0 {
156181 buf. limbs . fill ( Limb :: ZERO ) ;
157182 let mut count = remain;
158183 if count > max_accum {
159184 count = max_accum;
160185 }
161186 ( window, products) = products. split_at ( count) ;
162- let carry =
163- impl_longa_monty_lincomb ! ( window, buf. limbs, modulus. 0 . limbs, mod_neg_inv, nlimbs) ;
164- buf. sub_assign_mod_with_carry ( carry, & modulus. 0 , & modulus. 0 ) ;
187+ let carry = impl_longa_monty_lincomb ! (
188+ window,
189+ buf. limbs,
190+ modulus. as_ref( ) . limbs,
191+ mod_neg_inv,
192+ nlimbs
193+ ) ;
194+ buf. sub_assign_mod_with_carry ( carry, modulus. as_ref ( ) , modulus. as_ref ( ) ) ;
165195 ret. add_mod_assign ( & buf, modulus. as_nz_ref ( ) ) ;
166196 remain -= count;
167197 }
0 commit comments