Skip to content

Commit d2d0e0f

Browse files
committed
Migrated from Residue to Monty
1 parent 49d72c5 commit d2d0e0f

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/modular/boxed_monty_form.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,8 @@ impl BoxedMontyForm {
251251
/// (since the modulus `p` in Montgomery form is always odd, this divides entirely).
252252
pub fn div_by_2(&self) -> Self {
253253
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?
259256
}
260257
}
261258
}
@@ -279,7 +276,7 @@ fn convert_to_montgomery(integer: &mut BoxedUint, params: &BoxedMontyParams) {
279276

280277
#[cfg(test)]
281278
mod tests {
282-
use super::{BoxedMontyParams, BoxedUint};
279+
use super::{BoxedMontyForm, BoxedMontyParams, BoxedUint};
283280

284281
#[test]
285282
fn new_params_with_invalid_modulus() {
@@ -299,9 +296,9 @@ mod tests {
299296

300297
#[test]
301298
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());
305302
let two = one.add(&one);
306303

307304
assert_eq!(zero.div_by_2(), zero);

src/modular/monty_form.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ mod test {
269269

270270
#[test]
271271
fn div_by_2() {
272-
let params = DynResidueParams::new(&Uint::<1>::from(9u8)).unwrap();
273-
let zero = DynResidue::zero(params.clone());
274-
let one = DynResidue::one(params.clone());
272+
let params = MontyParams::new(&Uint::<1>::from(9u8)).unwrap();
273+
let zero = MontyForm::zero(params.clone());
274+
let one = MontyForm::one(params.clone());
275275
let two = one.add(&one);
276276

277277
assert_eq!(zero.div_by_2(), zero);

0 commit comments

Comments
 (0)