From fefbfb1d857a3145bb180169277c59927801feaf Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Mon, 31 Aug 2020 09:39:33 -0700 Subject: [PATCH] elliptic-curve: impl Deref for NonZeroScalar --- elliptic-curve/src/scalar.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/elliptic-curve/src/scalar.rs b/elliptic-curve/src/scalar.rs index 78946fe02..18bb9f92b 100644 --- a/elliptic-curve/src/scalar.rs +++ b/elliptic-curve/src/scalar.rs @@ -1,6 +1,7 @@ //! Scalar types use crate::{ops::Invert, Arithmetic, Curve, ElementBytes, FromBytes}; +use core::ops::Deref; use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}; #[cfg(feature = "rand")] @@ -64,6 +65,17 @@ where impl Copy for NonZeroScalar where C: Curve + Arithmetic {} +impl Deref for NonZeroScalar +where + C: Curve + Arithmetic, +{ + type Target = C::Scalar; + + fn deref(&self) -> &C::Scalar { + &self.scalar + } +} + impl FromBytes for NonZeroScalar where C: Curve + Arithmetic,