From fa541cca721970f9de04f067ac76f5ceb56f7139 Mon Sep 17 00:00:00 2001 From: Pedro Fontana Date: Fri, 10 Nov 2023 11:33:22 -0300 Subject: [PATCH] Remove inverse_mod method --- crates/starknet-types-core/src/felt.rs | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/crates/starknet-types-core/src/felt.rs b/crates/starknet-types-core/src/felt.rs index 6b5ee2d..b8fdb73 100644 --- a/crates/starknet-types-core/src/felt.rs +++ b/crates/starknet-types-core/src/felt.rs @@ -170,16 +170,11 @@ impl Felt { Self(self.0.pow(exponent.0.representative())) } - /// Modular multiplication between `self` and `rhs` modulo `p`. + /// Field multiplication between `self` and `rhs`, then apply modulo `p`. pub fn mul_mod(&self, rhs: &Self, p: &NonZeroFelt) -> Self { (self * rhs).div_rem(p).1 } - /// Modular inverse of `self` modulo `p`. - pub fn inverse_mod(&self, p: &NonZeroFelt) -> Option { - self.inverse().map(|x| x.div_rem(p).1) - } - /// Remainder of dividing `self` by `n` as integers. pub fn mod_floor(&self, n: &NonZeroFelt) -> Self { self.div_rem(n).1 @@ -1027,19 +1022,6 @@ mod test { prop_assert_eq!(x * x.inverse().unwrap(), Felt::ONE ) } - #[test] - fn inverse_mod_of_zero_is_none(p in nonzero_felt()) { - let nzp = NonZeroFelt(p.0); - prop_assert!(Felt::ZERO.inverse_mod(&nzp).is_none()); - } - - #[test] - fn inverse_mod_in_range(x in nonzero_felt(), p in nonzero_felt()) { - let nzp = NonZeroFelt(p.0); - prop_assert!(x.inverse_mod(&nzp) <= Some(Felt::MAX)); - prop_assert!(x.inverse_mod(&nzp) < Some(p)); - } - #[test] fn mul_mod_in_range(x in any::(), y in any::(), p in nonzero_felt()) { let nzp = NonZeroFelt(p.0);