Skip to content

Commit ce00799

Browse files
committed
Rename MontgomeryPoint to AffineMontgomeryPoint
1 parent e2de5d6 commit ce00799

File tree

7 files changed

+71
-71
lines changed

7 files changed

+71
-71
lines changed

ed448-goldilocks/src/edwards/extended.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,9 @@ impl EdwardsPoint {
541541
MontgomeryXpoint(u.to_bytes())
542542
}
543543

544-
/// Convert this point to [`MontgomeryPoint`]
544+
/// Convert this point to [`AffineMontgomeryPoint`]
545545
// See https://www.rfc-editor.org/rfc/rfc7748#section-4.2 4-isogeny maps
546-
pub fn to_montgomery(&self) -> MontgomeryPoint {
546+
pub fn to_montgomery(&self) -> AffineMontgomeryPoint {
547547
// u = y^2/x^2
548548
// v = (2 - x^2 - y^2)*y/x^3
549549

@@ -556,9 +556,9 @@ impl EdwardsPoint {
556556
let u = yy * xx.invert();
557557
let v = (FieldElement::TWO - xx - yy) * affine.y * (xx * affine.x).invert();
558558

559-
MontgomeryPoint::conditional_select(
560-
&MontgomeryPoint::new(u, v),
561-
&MontgomeryPoint::IDENTITY,
559+
AffineMontgomeryPoint::conditional_select(
560+
&AffineMontgomeryPoint::new(u, v),
561+
&AffineMontgomeryPoint::IDENTITY,
562562
self.ct_eq(&Self::IDENTITY),
563563
)
564564
}

ed448-goldilocks/src/field/element.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
33

44
use super::{ConstMontyType, MODULUS};
55
use crate::{
6-
AffinePoint, Curve448, Decaf448, DecafPoint, Ed448, EdwardsPoint, MontgomeryPoint,
6+
AffineMontgomeryPoint, AffinePoint, Curve448, Decaf448, DecafPoint, Ed448, EdwardsPoint,
77
ProjectiveMontgomeryPoint, curve::twedwards::extended::ExtendedPoint as TwistedExtendedPoint,
88
};
99
use elliptic_curve::{
@@ -403,7 +403,7 @@ impl FieldElement {
403403
(inv_sqrt_x * u, zero_u | is_res)
404404
}
405405

406-
pub(crate) fn map_to_curve_elligator2_curve448(&self) -> MontgomeryPoint {
406+
pub(crate) fn map_to_curve_elligator2_curve448(&self) -> AffineMontgomeryPoint {
407407
let mut t1 = self.square(); // 1. t1 = u^2
408408
t1 *= Self::Z; // 2. t1 = Z * t1 // Z * u^2
409409
let e1 = t1.ct_eq(&Self::MINUS_ONE); // 3. e1 = t1 == -1 // exceptional case: Z * u^2 == -1
@@ -423,7 +423,7 @@ impl FieldElement {
423423
let mut y = y2.sqrt(); // 17. y = sqrt(y2)
424424
let e3 = y.is_negative(); // 18. e3 = sgn0(y) == 1
425425
y.conditional_negate(e2 ^ e3); // y = CMOV(-y, y, e2 xor e3)
426-
MontgomeryPoint::new(x, y)
426+
AffineMontgomeryPoint::new(x, y)
427427
}
428428

429429
// See https://www.rfc-editor.org/rfc/rfc9380.html#name-curve448-q-3-mod-4-k-1.

ed448-goldilocks/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub use edwards::{
6161
};
6262
pub use field::{MODULUS_LIMBS, ORDER, Scalar, WIDE_ORDER};
6363
pub use montgomery::{
64-
MontgomeryPoint, MontgomeryScalar, MontgomeryScalarBytes, MontgomeryXpoint,
64+
AffineMontgomeryPoint, MontgomeryScalar, MontgomeryScalarBytes, MontgomeryXpoint,
6565
ProjectiveMontgomeryPoint, ProjectiveMontgomeryXpoint, WideMontgomeryScalarBytes,
6666
};
6767
#[cfg(feature = "signing")]
@@ -213,7 +213,7 @@ impl FieldBytesEncoding<Curve448> for U448 {
213213
}
214214

215215
impl CurveArithmetic for Curve448 {
216-
type AffinePoint = MontgomeryPoint;
216+
type AffinePoint = AffineMontgomeryPoint;
217217
type ProjectivePoint = ProjectiveMontgomeryPoint;
218218
type Scalar = MontgomeryScalar;
219219
}

ed448-goldilocks/src/montgomery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod point;
1515
mod scalar;
1616
mod x;
1717

18-
pub use point::{MontgomeryPoint, ProjectiveMontgomeryPoint};
18+
pub use point::{AffineMontgomeryPoint, ProjectiveMontgomeryPoint};
1919
pub use scalar::{MontgomeryScalar, MontgomeryScalarBytes, WideMontgomeryScalarBytes};
2020
pub use x::{MontgomeryXpoint, ProjectiveMontgomeryXpoint};
2121

ed448-goldilocks/src/montgomery/ops.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
66
use elliptic_curve::CurveGroup;
77
use elliptic_curve::bigint::U448;
88

9-
use super::{MontgomeryPoint, MontgomeryScalar, MontgomeryXpoint, ProjectiveMontgomeryPoint};
9+
use super::{AffineMontgomeryPoint, MontgomeryScalar, MontgomeryXpoint, ProjectiveMontgomeryPoint};
1010

1111
impl Add<&ProjectiveMontgomeryPoint> for &ProjectiveMontgomeryPoint {
1212
type Output = ProjectiveMontgomeryPoint;
@@ -52,12 +52,12 @@ define_add_variants!(
5252
Output = ProjectiveMontgomeryPoint
5353
);
5454

55-
impl Add<&MontgomeryPoint> for &ProjectiveMontgomeryPoint {
55+
impl Add<&AffineMontgomeryPoint> for &ProjectiveMontgomeryPoint {
5656
type Output = ProjectiveMontgomeryPoint;
5757

5858
// See Complete Addition Law for Montgomery Curves - Algorithm 2.
5959
// With "Trade-Off Technique".
60-
fn add(self, rhs: &MontgomeryPoint) -> ProjectiveMontgomeryPoint {
60+
fn add(self, rhs: &AffineMontgomeryPoint) -> ProjectiveMontgomeryPoint {
6161
let (x1, y1, z1) = (self.U, self.V, self.W);
6262
let (x2, y2) = (rhs.U, rhs.V);
6363

@@ -92,11 +92,11 @@ impl Add<&MontgomeryPoint> for &ProjectiveMontgomeryPoint {
9292

9393
define_add_variants!(
9494
LHS = ProjectiveMontgomeryPoint,
95-
RHS = MontgomeryPoint,
95+
RHS = AffineMontgomeryPoint,
9696
Output = ProjectiveMontgomeryPoint
9797
);
9898

99-
impl Add<&ProjectiveMontgomeryPoint> for &MontgomeryPoint {
99+
impl Add<&ProjectiveMontgomeryPoint> for &AffineMontgomeryPoint {
100100
type Output = ProjectiveMontgomeryPoint;
101101

102102
fn add(self, other: &ProjectiveMontgomeryPoint) -> ProjectiveMontgomeryPoint {
@@ -105,7 +105,7 @@ impl Add<&ProjectiveMontgomeryPoint> for &MontgomeryPoint {
105105
}
106106

107107
define_add_variants!(
108-
LHS = MontgomeryPoint,
108+
LHS = AffineMontgomeryPoint,
109109
RHS = ProjectiveMontgomeryPoint,
110110
Output = ProjectiveMontgomeryPoint
111111
);
@@ -121,21 +121,21 @@ define_add_assign_variants!(
121121
RHS = ProjectiveMontgomeryPoint
122122
);
123123

124-
impl AddAssign<&MontgomeryPoint> for ProjectiveMontgomeryPoint {
125-
fn add_assign(&mut self, rhs: &MontgomeryPoint) {
124+
impl AddAssign<&AffineMontgomeryPoint> for ProjectiveMontgomeryPoint {
125+
fn add_assign(&mut self, rhs: &AffineMontgomeryPoint) {
126126
*self += Self::from(*rhs);
127127
}
128128
}
129129

130-
define_add_assign_variants!(LHS = ProjectiveMontgomeryPoint, RHS = MontgomeryPoint);
130+
define_add_assign_variants!(LHS = ProjectiveMontgomeryPoint, RHS = AffineMontgomeryPoint);
131131

132-
impl AddAssign<&ProjectiveMontgomeryPoint> for MontgomeryPoint {
132+
impl AddAssign<&ProjectiveMontgomeryPoint> for AffineMontgomeryPoint {
133133
fn add_assign(&mut self, rhs: &ProjectiveMontgomeryPoint) {
134134
*self = (ProjectiveMontgomeryPoint::from(*self) + rhs).into();
135135
}
136136
}
137137

138-
define_add_assign_variants!(LHS = MontgomeryPoint, RHS = ProjectiveMontgomeryPoint);
138+
define_add_assign_variants!(LHS = AffineMontgomeryPoint, RHS = ProjectiveMontgomeryPoint);
139139

140140
impl Mul<&MontgomeryScalar> for &ProjectiveMontgomeryPoint {
141141
type Output = ProjectiveMontgomeryPoint;
@@ -152,15 +152,15 @@ define_mul_variants!(
152152
Output = ProjectiveMontgomeryPoint
153153
);
154154

155-
impl Mul<&MontgomeryScalar> for &MontgomeryPoint {
155+
impl Mul<&MontgomeryScalar> for &AffineMontgomeryPoint {
156156
type Output = ProjectiveMontgomeryPoint;
157157

158158
// Montgomery curves and their arithmetic - Algorithm 6
159159
// https://eprint.iacr.org/2017/212.pdf
160160
fn mul(self, rhs: &MontgomeryScalar) -> ProjectiveMontgomeryPoint {
161161
pub const A2: FieldElement = FieldElement(ConstMontyType::new(&U448::from_u64(312652)));
162162

163-
let MontgomeryPoint { U: xP, V: yP } = self;
163+
let AffineMontgomeryPoint { U: xP, V: yP } = self;
164164
let (
165165
ProjectiveMontgomeryXpoint { U: xQ, W: zQ },
166166
ProjectiveMontgomeryXpoint { U: xD, W: zD },
@@ -191,7 +191,7 @@ impl Mul<&MontgomeryScalar> for &MontgomeryPoint {
191191
}
192192

193193
define_mul_variants!(
194-
LHS = MontgomeryPoint,
194+
LHS = AffineMontgomeryPoint,
195195
RHS = MontgomeryScalar,
196196
Output = ProjectiveMontgomeryPoint
197197
);
@@ -239,21 +239,21 @@ define_sub_variants!(
239239
Output = ProjectiveMontgomeryPoint
240240
);
241241

242-
impl Sub<&MontgomeryPoint> for &ProjectiveMontgomeryPoint {
242+
impl Sub<&AffineMontgomeryPoint> for &ProjectiveMontgomeryPoint {
243243
type Output = ProjectiveMontgomeryPoint;
244244

245-
fn sub(self, other: &MontgomeryPoint) -> ProjectiveMontgomeryPoint {
245+
fn sub(self, other: &AffineMontgomeryPoint) -> ProjectiveMontgomeryPoint {
246246
*self - ProjectiveMontgomeryPoint::from(*other)
247247
}
248248
}
249249

250250
define_sub_variants!(
251251
LHS = ProjectiveMontgomeryPoint,
252-
RHS = MontgomeryPoint,
252+
RHS = AffineMontgomeryPoint,
253253
Output = ProjectiveMontgomeryPoint
254254
);
255255

256-
impl Sub<&ProjectiveMontgomeryPoint> for &MontgomeryPoint {
256+
impl Sub<&ProjectiveMontgomeryPoint> for &AffineMontgomeryPoint {
257257
type Output = ProjectiveMontgomeryPoint;
258258

259259
fn sub(self, other: &ProjectiveMontgomeryPoint) -> ProjectiveMontgomeryPoint {
@@ -262,7 +262,7 @@ impl Sub<&ProjectiveMontgomeryPoint> for &MontgomeryPoint {
262262
}
263263

264264
define_sub_variants!(
265-
LHS = MontgomeryPoint,
265+
LHS = AffineMontgomeryPoint,
266266
RHS = ProjectiveMontgomeryPoint,
267267
Output = ProjectiveMontgomeryPoint
268268
);
@@ -278,21 +278,21 @@ define_sub_assign_variants!(
278278
RHS = ProjectiveMontgomeryPoint
279279
);
280280

281-
impl SubAssign<&MontgomeryPoint> for ProjectiveMontgomeryPoint {
282-
fn sub_assign(&mut self, rhs: &MontgomeryPoint) {
281+
impl SubAssign<&AffineMontgomeryPoint> for ProjectiveMontgomeryPoint {
282+
fn sub_assign(&mut self, rhs: &AffineMontgomeryPoint) {
283283
*self -= ProjectiveMontgomeryPoint::from(*rhs);
284284
}
285285
}
286286

287-
define_sub_assign_variants!(LHS = ProjectiveMontgomeryPoint, RHS = MontgomeryPoint);
287+
define_sub_assign_variants!(LHS = ProjectiveMontgomeryPoint, RHS = AffineMontgomeryPoint);
288288

289-
impl SubAssign<&ProjectiveMontgomeryPoint> for MontgomeryPoint {
289+
impl SubAssign<&ProjectiveMontgomeryPoint> for AffineMontgomeryPoint {
290290
fn sub_assign(&mut self, rhs: &ProjectiveMontgomeryPoint) {
291291
*self = (ProjectiveMontgomeryPoint::from(*self) - rhs).into();
292292
}
293293
}
294294

295-
define_sub_assign_variants!(LHS = MontgomeryPoint, RHS = ProjectiveMontgomeryPoint);
295+
define_sub_assign_variants!(LHS = AffineMontgomeryPoint, RHS = ProjectiveMontgomeryPoint);
296296

297297
impl<T> Sum<T> for ProjectiveMontgomeryPoint
298298
where

0 commit comments

Comments
 (0)