Skip to content

Commit 711144e

Browse files
authored
Uint: remove UNSAT_LIMBS from inv_*mod (#531)
It's really an implementation detail of the Bernstein-Yang inverter, and not actually customizable by the caller, so get it out of the way.
1 parent f372474 commit 711144e

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/uint/inv_mod.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,21 @@ impl<const LIMBS: usize> Uint<LIMBS> {
8181

8282
ConstCtOption::new(x, is_some)
8383
}
84+
}
8485

86+
impl<const LIMBS: usize, const UNSAT_LIMBS: usize> Uint<LIMBS>
87+
where
88+
Odd<Self>: PrecomputeInverter<Inverter = BernsteinYangInverter<LIMBS, UNSAT_LIMBS>>,
89+
{
8590
/// Computes the multiplicative inverse of `self` mod `modulus`, where `modulus` is odd.
86-
pub const fn inv_odd_mod<const UNSAT_LIMBS: usize>(
87-
&self,
88-
modulus: &Odd<Self>,
89-
) -> ConstCtOption<Self>
90-
where
91-
Odd<Self>: PrecomputeInverter<Inverter = BernsteinYangInverter<LIMBS, UNSAT_LIMBS>>,
92-
{
91+
pub const fn inv_odd_mod(&self, modulus: &Odd<Self>) -> ConstCtOption<Self> {
9392
BernsteinYangInverter::<LIMBS, UNSAT_LIMBS>::new(modulus, &Uint::ONE).inv(self)
9493
}
9594

9695
/// Computes the multiplicative inverse of `self` mod `modulus`.
9796
///
9897
/// Returns some if an inverse exists, otherwise none.
99-
pub const fn inv_mod<const UNSAT_LIMBS: usize>(&self, modulus: &Self) -> ConstCtOption<Self>
100-
where
101-
Odd<Self>: PrecomputeInverter<Inverter = BernsteinYangInverter<LIMBS, UNSAT_LIMBS>>,
102-
{
98+
pub const fn inv_mod(&self, modulus: &Self) -> ConstCtOption<Self> {
10399
// Decompose `modulus = s * 2^k` where `s` is odd
104100
let k = modulus.trailing_zeros();
105101
let s = modulus.overflowing_shr(k).unwrap_or(Self::ZERO);

0 commit comments

Comments
 (0)