|
7 | 7 |
|
8 | 8 | use super::{BoxedMontyForm, BoxedMontyParams}; |
9 | 9 | use crate::{ |
10 | | - AmmMultiplier, BoxedUint, CtLt, Limb, MontyMultiplier, Mul, MulAssign, Square, SquareAssign, |
| 10 | + AmmMultiplier, BoxedUint, Limb, MontyMultiplier, Mul, MulAssign, Square, SquareAssign, |
11 | 11 | modular::mul::montgomery_multiply_inner, word, |
12 | 12 | }; |
13 | 13 |
|
@@ -49,32 +49,6 @@ impl BoxedMontyForm { |
49 | 49 | params: self.params.clone(), |
50 | 50 | } |
51 | 51 | } |
52 | | - |
53 | | - /// Instantiate [`BoxedMontyForm`] from the result of an "Almost Montgomery Multiplication". |
54 | | - pub(crate) fn from_amm(mut z: BoxedUint, params: BoxedMontyParams) -> Self { |
55 | | - // Ensure the output is properly reduced. |
56 | | - // |
57 | | - // Using the properties of `almost_montgomery_mul()` (see its documentation): |
58 | | - // - We have an incoming `x` which is fully reduced (`floor(x / modulus) = 0`). |
59 | | - // - We build an array of `powers` which are produced by multiplying the previous power by |
60 | | - // `x`, so for each power `floor(power / modulus) <= 1`. |
61 | | - // - Then we take turns squaring the accumulator `z` (bringing `floor(z / modulus)` to 1 |
62 | | - // regardless of the previous reduction level) and multiplying by a power of `x` |
63 | | - // (bringing `floor(z / modulus)` to at most 2). |
64 | | - // - Then we either exit the loop, or square again, which brings `floor(z / modulus)` back |
65 | | - // to 1. |
66 | | - // |
67 | | - // We now need to reduce `z` at most twice to bring it within `[0, modulus)`. |
68 | | - let modulus = params.modulus(); |
69 | | - z.conditional_borrowing_sub_assign(modulus, !z.ct_lt(modulus)); |
70 | | - z.conditional_borrowing_sub_assign(modulus, !z.ct_lt(modulus)); |
71 | | - debug_assert!(&z < modulus); |
72 | | - |
73 | | - Self { |
74 | | - montgomery_form: z, |
75 | | - params, |
76 | | - } |
77 | | - } |
78 | 52 | } |
79 | 53 |
|
80 | 54 | impl Mul<&BoxedMontyForm> for &BoxedMontyForm { |
|
0 commit comments