Skip to content

Commit 91d6acd

Browse files
authored
elliptic-curve: scalar Mul bounds (#1854)
Adds bounds on `CurveArithmetic::Scalar` that it has a `Mul<P>` impl for both `AffinePoint` and `ProjectivePoint`
1 parent d131d74 commit 91d6acd

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

elliptic-curve/src/arithmetic.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::{
44
Curve, FieldBytes, NonZeroScalar, PrimeCurve, ScalarPrimitive,
5-
ops::{Invert, LinearCombination, Reduce, ShrAssign},
5+
ops::{Invert, LinearCombination, Mul, Reduce, ShrAssign},
66
point::{AffineCoordinates, NonIdentity},
77
scalar::{FromUintUnchecked, IsHigh},
88
};
@@ -73,6 +73,10 @@ pub trait CurveArithmetic: Curve {
7373
+ Into<Self::Uint>
7474
+ Invert<Output = CtOption<Self::Scalar>>
7575
+ IsHigh
76+
+ Mul<Self::AffinePoint, Output = Self::ProjectivePoint>
77+
+ for<'a> Mul<&'a Self::AffinePoint, Output = Self::ProjectivePoint>
78+
+ Mul<Self::ProjectivePoint, Output = Self::ProjectivePoint>
79+
+ for<'a> Mul<&'a Self::ProjectivePoint, Output = Self::ProjectivePoint>
7680
+ PartialOrd
7781
+ Reduce<Self::Uint, Bytes = FieldBytes<Self>>
7882
+ ShrAssign<usize>

elliptic-curve/src/dev.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,38 @@ impl Mul<&Scalar> for Scalar {
271271
}
272272
}
273273

274+
impl Mul<AffinePoint> for Scalar {
275+
type Output = ProjectivePoint;
276+
277+
fn mul(self, _other: AffinePoint) -> ProjectivePoint {
278+
unimplemented!();
279+
}
280+
}
281+
282+
impl Mul<&AffinePoint> for Scalar {
283+
type Output = ProjectivePoint;
284+
285+
fn mul(self, _other: &AffinePoint) -> ProjectivePoint {
286+
unimplemented!();
287+
}
288+
}
289+
290+
impl Mul<ProjectivePoint> for Scalar {
291+
type Output = ProjectivePoint;
292+
293+
fn mul(self, _other: ProjectivePoint) -> ProjectivePoint {
294+
unimplemented!();
295+
}
296+
}
297+
298+
impl Mul<&ProjectivePoint> for Scalar {
299+
type Output = ProjectivePoint;
300+
301+
fn mul(self, _other: &ProjectivePoint) -> ProjectivePoint {
302+
unimplemented!();
303+
}
304+
}
305+
274306
impl MulAssign<Scalar> for Scalar {
275307
fn mul_assign(&mut self, _rhs: Scalar) {
276308
unimplemented!();

0 commit comments

Comments
 (0)