@@ -251,11 +251,8 @@ impl BoxedMontyForm {
251
251
/// (since the modulus `p` in Montgomery form is always odd, this divides entirely).
252
252
pub fn div_by_2 ( & self ) -> Self {
253
253
Self {
254
- montgomery_form : div_by_2:: boxed:: div_by_2 (
255
- & self . montgomery_form ,
256
- & self . residue_params . modulus ,
257
- ) ,
258
- residue_params : self . residue_params . clone ( ) , // TODO: avoid clone?
254
+ montgomery_form : div_by_2:: boxed:: div_by_2 ( & self . montgomery_form , & self . params . modulus ) ,
255
+ params : self . params . clone ( ) , // TODO: avoid clone?
259
256
}
260
257
}
261
258
}
@@ -279,7 +276,7 @@ fn convert_to_montgomery(integer: &mut BoxedUint, params: &BoxedMontyParams) {
279
276
280
277
#[ cfg( test) ]
281
278
mod tests {
282
- use super :: { BoxedMontyParams , BoxedUint } ;
279
+ use super :: { BoxedMontyForm , BoxedMontyParams , BoxedUint } ;
283
280
284
281
#[ test]
285
282
fn new_params_with_invalid_modulus ( ) {
@@ -299,9 +296,9 @@ mod tests {
299
296
300
297
#[ test]
301
298
fn div_by_2 ( ) {
302
- let params = BoxedResidueParams :: new ( BoxedUint :: from ( 9u8 ) ) . unwrap ( ) ;
303
- let zero = BoxedResidue :: zero ( params. clone ( ) ) ;
304
- let one = BoxedResidue :: one ( params. clone ( ) ) ;
299
+ let params = BoxedMontyParams :: new ( BoxedUint :: from ( 9u8 ) ) . unwrap ( ) ;
300
+ let zero = BoxedMontyForm :: zero ( params. clone ( ) ) ;
301
+ let one = BoxedMontyForm :: one ( params. clone ( ) ) ;
305
302
let two = one. add ( & one) ;
306
303
307
304
assert_eq ! ( zero. div_by_2( ) , zero) ;
0 commit comments