diff --git a/elliptic-curve/src/scalar.rs b/elliptic-curve/src/scalar.rs index 957d7bd74..78946fe02 100644 --- a/elliptic-curve/src/scalar.rs +++ b/elliptic-curve/src/scalar.rs @@ -1,6 +1,6 @@ //! Scalar types -use crate::{Arithmetic, Curve, ElementBytes, FromBytes}; +use crate::{ops::Invert, Arithmetic, Curve, ElementBytes, FromBytes}; use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}; #[cfg(feature = "rand")] @@ -84,6 +84,19 @@ where } } +impl Invert for NonZeroScalar +where + C: Curve + Arithmetic, + C::Scalar: Invert, +{ + type Output = ::Output; + + /// Perform a scalar inversion + fn invert(&self) -> CtOption { + self.scalar.invert() + } +} + #[cfg(feature = "rand")] impl Generate for NonZeroScalar where