Skip to content

Commit cfafae2

Browse files
authored
Use elliptic_curve::scalar_impls! instead of scalar_from_impls! (#1315)
1 parent 49c457a commit cfafae2

File tree

6 files changed

+11
-85
lines changed

6 files changed

+11
-85
lines changed

ed448-goldilocks/src/decaf/affine.rs

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -93,36 +93,6 @@ impl From<NonIdentity<AffinePoint>> for AffinePoint {
9393
}
9494
}
9595

96-
impl Mul<DecafScalar> for AffinePoint {
97-
type Output = DecafPoint;
98-
99-
#[inline]
100-
#[expect(clippy::op_ref, reason = "false-positive")]
101-
fn mul(self, scalar: DecafScalar) -> DecafPoint {
102-
&self * scalar
103-
}
104-
}
105-
106-
#[allow(clippy::op_ref)] // https://github.com/rust-lang/rust-clippy/issues/12463
107-
impl Mul<DecafScalar> for &AffinePoint {
108-
type Output = DecafPoint;
109-
110-
#[inline]
111-
fn mul(self, scalar: DecafScalar) -> DecafPoint {
112-
self * &scalar
113-
}
114-
}
115-
116-
#[allow(clippy::op_ref)] // https://github.com/rust-lang/rust-clippy/issues/12463
117-
impl Mul<&DecafScalar> for AffinePoint {
118-
type Output = DecafPoint;
119-
120-
#[inline]
121-
fn mul(self, scalar: &DecafScalar) -> DecafPoint {
122-
&self * scalar
123-
}
124-
}
125-
12696
impl Mul<&DecafScalar> for &AffinePoint {
12797
type Output = DecafPoint;
12898

@@ -132,20 +102,4 @@ impl Mul<&DecafScalar> for &AffinePoint {
132102
}
133103
}
134104

135-
impl Mul<AffinePoint> for DecafScalar {
136-
type Output = DecafPoint;
137-
138-
#[inline]
139-
fn mul(self, point: AffinePoint) -> DecafPoint {
140-
point * self
141-
}
142-
}
143-
144-
impl Mul<&AffinePoint> for DecafScalar {
145-
type Output = DecafPoint;
146-
147-
#[inline]
148-
fn mul(self, point: &AffinePoint) -> DecafPoint {
149-
point * self
150-
}
151-
}
105+
define_mul_variants!(LHS = AffinePoint, RHS = DecafScalar, Output = DecafPoint);

ed448-goldilocks/src/decaf/ops.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ impl Mul<&DecafScalar> for &DecafPoint {
2020

2121
define_mul_variants!(LHS = DecafPoint, RHS = DecafScalar, Output = DecafPoint);
2222

23-
impl Mul<&DecafPoint> for &DecafScalar {
24-
type Output = DecafPoint;
25-
26-
fn mul(self, point: &DecafPoint) -> DecafPoint {
27-
point * self
28-
}
29-
}
30-
31-
define_mul_variants!(LHS = DecafScalar, RHS = DecafPoint, Output = DecafPoint);
32-
3323
impl<'s> MulAssign<&'s DecafScalar> for DecafPoint {
3424
fn mul_assign(&mut self, scalar: &'s DecafScalar) {
3525
*self = *self * scalar;

ed448-goldilocks/src/decaf/scalar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl DecafScalar {
5252
}
5353
}
5454

55-
elliptic_curve::scalar_from_impls!(Decaf448, DecafScalar);
55+
elliptic_curve::scalar_impls!(Decaf448, DecafScalar);
5656

5757
/// The number of bytes needed to represent the scalar field
5858
pub type DecafScalarBytes = ScalarBytes<Decaf448>;

ed448-goldilocks/src/edwards/affine.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,17 @@ impl TryFrom<AffinePoint> for NonIdentity<AffinePoint> {
135135
}
136136
}
137137

138-
impl Mul<AffinePoint> for EdwardsScalar {
138+
impl Mul<&EdwardsScalar> for &AffinePoint {
139139
type Output = EdwardsPoint;
140140

141141
#[inline]
142-
#[expect(clippy::op_ref, reason = "false-positive")]
143-
fn mul(self, rhs: AffinePoint) -> EdwardsPoint {
144-
self * &rhs
142+
fn mul(self, scalar: &EdwardsScalar) -> Self::Output {
143+
self.to_edwards() * scalar
145144
}
146145
}
147146

148-
impl Mul<&AffinePoint> for EdwardsScalar {
149-
type Output = EdwardsPoint;
150-
151-
#[inline]
152-
fn mul(self, rhs: &AffinePoint) -> EdwardsPoint {
153-
rhs.to_edwards() * self
154-
}
155-
}
147+
define_mul_variants!(
148+
LHS = AffinePoint,
149+
RHS = EdwardsScalar,
150+
Output = EdwardsPoint
151+
);

ed448-goldilocks/src/edwards/extended.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -937,11 +937,6 @@ define_mul_variants!(
937937
RHS = EdwardsScalar,
938938
Output = EdwardsPoint
939939
);
940-
define_mul_variants!(
941-
LHS = EdwardsScalar,
942-
RHS = EdwardsPoint,
943-
Output = EdwardsPoint
944-
);
945940

946941
impl Mul<&EdwardsScalar> for &EdwardsPoint {
947942
type Output = EdwardsPoint;
@@ -952,15 +947,6 @@ impl Mul<&EdwardsScalar> for &EdwardsPoint {
952947
}
953948
}
954949

955-
impl Mul<&EdwardsPoint> for &EdwardsScalar {
956-
type Output = EdwardsPoint;
957-
958-
/// Scalar multiplication: compute `scalar * self`.
959-
fn mul(self, point: &EdwardsPoint) -> EdwardsPoint {
960-
point * self
961-
}
962-
}
963-
964950
#[cfg(feature = "serde")]
965951
impl serdect::serde::Serialize for EdwardsPoint {
966952
fn serialize<S: serdect::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {

ed448-goldilocks/src/edwards/scalar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl EdwardsScalar {
6868
}
6969
}
7070

71-
elliptic_curve::scalar_from_impls!(Ed448, EdwardsScalar);
71+
elliptic_curve::scalar_impls!(Ed448, EdwardsScalar);
7272

7373
/// The number of bytes needed to represent the scalar field
7474
pub type EdwardsScalarBytes = ScalarBytes<Ed448>;

0 commit comments

Comments
 (0)