diff --git a/crates/starknet-types-core/src/felt/mod.rs b/crates/starknet-types-core/src/felt/mod.rs index 2a986cc..9e92f1c 100644 --- a/crates/starknet-types-core/src/felt/mod.rs +++ b/crates/starknet-types-core/src/felt/mod.rs @@ -360,6 +360,11 @@ impl Felt { Self(self.0.square()) } + /// Doubles the point `self` + pub fn double(&self) -> Self { + Self(self.0.add(self.0)) + } + /// Raises `self` to the power of `exponent`. pub fn pow(&self, exponent: impl Into) -> Self { Self(self.0.pow(exponent.into())) @@ -1304,6 +1309,11 @@ mod test { } #[test] + fn double_in_range(x in any::()) { + prop_assert!(x.double() == x + x); + } + + #[test] fn square_in_range(x in any::()) { prop_assert!(x.square() <= Felt::MAX); }