From 264be6ea2f50fdfaf3814bec7b44638fdb40bb69 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 25 Jul 2020 10:56:14 -0700 Subject: [PATCH] elliptic-curve: add `Arithmetic` trait Several potentially useful traits (including the ECDSA ones) need access to these types, so it's helpful to have a single trait that defines them as associated types. Some additional bounds would really be helpful, but we can add those as they come up in practice. --- elliptic-curve/src/weierstrass/curve.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/elliptic-curve/src/weierstrass/curve.rs b/elliptic-curve/src/weierstrass/curve.rs index c7fdf623a..1d0079282 100644 --- a/elliptic-curve/src/weierstrass/curve.rs +++ b/elliptic-curve/src/weierstrass/curve.rs @@ -16,5 +16,14 @@ pub trait Curve: Clone + Debug + Default + Eq + Ord + Send + Sync { type ScalarSize: ArrayLength + Add + Add + Eq + Ord + Unsigned; } +/// Curve arithmetic support +pub trait Arithmetic: Curve { + /// Scalar type for a given curve + type Scalar; + + /// Affine point type for a given curve + type AffinePoint; +} + /// Alias for [`SecretKey`] type for a given Weierstrass curve pub type SecretKey = crate::secret_key::SecretKey<::ScalarSize>;