diff --git a/ec/src/lib.rs b/ec/src/lib.rs index d57a41e70..79b07b870 100644 --- a/ec/src/lib.rs +++ b/ec/src/lib.rs @@ -247,6 +247,8 @@ pub trait AffineCurve: + Neg + Zeroize + core::iter::Sum + + Mul + + for<'a> Mul<&'a Self::ScalarField, Output = Self::Projective> + for<'a> core::iter::Sum<&'a Self> + From<::Projective> { diff --git a/ec/src/models/short_weierstrass.rs b/ec/src/models/short_weierstrass.rs index a7d7bca9d..6a9dd7600 100644 --- a/ec/src/models/short_weierstrass.rs +++ b/ec/src/models/short_weierstrass.rs @@ -376,6 +376,15 @@ impl<'a, P: SWCurveConfig> core::iter::Sum<&'a Self> for Affine

{ } } +impl<'a, P: SWCurveConfig, T: Borrow> Mul for Affine

{ + type Output = Projective

; + + #[inline] + fn mul(self, other: T) -> Self::Output { + self.mul_bigint(other.borrow().into_bigint()) + } +} + /// Jacobian coordinates for a point on an elliptic curve in short Weierstrass /// form, over the base field `P::BaseField`. This struct implements arithmetic /// via the Jacobian formulae diff --git a/ec/src/models/twisted_edwards.rs b/ec/src/models/twisted_edwards.rs index 0a56037c3..ae2762c9d 100644 --- a/ec/src/models/twisted_edwards.rs +++ b/ec/src/models/twisted_edwards.rs @@ -338,6 +338,15 @@ impl Distribution> for Standard { } } +impl<'a, P: TECurveConfig, T: Borrow> Mul for Affine

{ + type Output = Projective

; + + #[inline] + fn mul(self, other: T) -> Self::Output { + self.mul_bigint(other.borrow().into_bigint()) + } +} + ////////////////////////////////////////////////////////////////////////////// /// `Projective` implements Extended Twisted Edwards Coordinates