diff --git a/elliptic-curve/src/lib.rs b/elliptic-curve/src/lib.rs index 1c55378fe..d13365992 100644 --- a/elliptic-curve/src/lib.rs +++ b/elliptic-curve/src/lib.rs @@ -69,6 +69,7 @@ extern crate alloc; extern crate std; pub mod ops; +pub mod point; pub mod scalar; #[cfg(feature = "dev")] @@ -83,7 +84,6 @@ pub mod sec1; pub mod weierstrass; mod error; -mod point; mod secret_key; #[cfg(feature = "arithmetic")] diff --git a/elliptic-curve/src/point/non_identity.rs b/elliptic-curve/src/point/non_identity.rs index 075e3a94d..81c31cd19 100644 --- a/elliptic-curve/src/point/non_identity.rs +++ b/elliptic-curve/src/point/non_identity.rs @@ -1,6 +1,6 @@ //! Non-identity point type. -use core::ops::Deref; +use core::ops::{Deref, Mul}; use group::{prime::PrimeCurveAffine, Curve, GroupEncoding}; use rand_core::{CryptoRng, RngCore}; @@ -9,6 +9,8 @@ use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}; #[cfg(feature = "serde")] use serdect::serde::{de, ser, Deserialize, Serialize}; +use crate::{CurveArithmetic, NonZeroScalar, Scalar}; + /// Non-identity point type. /// /// This type ensures that its value is not the identity point, ala `core::num::NonZero*`. @@ -22,13 +24,22 @@ pub struct NonIdentity
{ impl
NonIdentity
where
- P: ConditionallySelectable + ConstantTimeEq + Default + GroupEncoding,
+ P: ConditionallySelectable + ConstantTimeEq + Default,
{
/// Create a [`NonIdentity`] from a point.
pub fn new(point: P) -> CtOption NonIdentity
+where
+ P: ConditionallySelectable + ConstantTimeEq + Default + GroupEncoding,
+{
/// Decode a [`NonIdentity`] from its encoding.
pub fn from_repr(repr: &P::Repr) -> CtOption {
impl NonIdentity
where
- P: ConditionallySelectable + ConstantTimeEq + Curve + Default + GroupEncoding,
+ P: ConditionallySelectable + ConstantTimeEq + Curve + Default,
{
/// Generate a random `NonIdentity
+where
+ C: CurveArithmetic,
+ P: Copy + Mul ;
+
+ fn mul(self, rhs: NonZeroScalar
+where
+ C: CurveArithmetic,
+ P: Copy + Mul ;
+
+ fn mul(self, rhs: &NonZeroScalar Serialize for NonIdentity
where
diff --git a/elliptic-curve/src/public_key.rs b/elliptic-curve/src/public_key.rs
index a916cd8a8..045a1aa6a 100644
--- a/elliptic-curve/src/public_key.rs
+++ b/elliptic-curve/src/public_key.rs
@@ -155,6 +155,11 @@ where
self.point.into()
}
+ /// Convert this [`PublicKey`] to a [`NonIdentity`] of the inner [`AffinePoint`]
+ pub fn to_non_identity(&self) -> NonIdentity ) -> Self {
- PublicKey::from(&value)
+ Self::from(&value)
}
}
@@ -287,6 +292,24 @@ where
}
}
+impl