Skip to content

Commit 4b9eb55

Browse files
committed
Rename to MontgomeryPoint to MontgomeryXpoint
1 parent 425e867 commit 4b9eb55

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

ed448-goldilocks/src/edwards/extended.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ impl EdwardsPoint {
528528
T: FieldElement::ZERO,
529529
};
530530

531-
/// Convert this point to [`MontgomeryPoint`]
532-
pub fn to_montgomery(&self) -> MontgomeryPoint {
531+
/// Convert this point to [`MontgomeryXpoint`]
532+
pub fn to_montgomery_x(&self) -> MontgomeryXpoint {
533533
// u = y^2 * [(1-dy^2)/(1-y^2)]
534534

535535
let affine = self.to_affine();
@@ -539,7 +539,7 @@ impl EdwardsPoint {
539539

540540
let u = yy * (FieldElement::ONE - dyy) * (FieldElement::ONE - yy).invert();
541541

542-
MontgomeryPoint(u.to_bytes())
542+
MontgomeryXpoint(u.to_bytes())
543543
}
544544

545545
/// Generic scalar multiplication to compute s*P

ed448-goldilocks/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub use edwards::{
6161
WideEdwardsScalarBytes,
6262
};
6363
pub use field::{MODULUS_LIMBS, ORDER, Scalar, WIDE_ORDER};
64-
pub use montgomery::{MontgomeryPoint, ProjectiveMontgomeryPoint};
64+
pub use montgomery::{MontgomeryXpoint, ProjectiveMontgomeryXpoint};
6565
pub use ristretto::{CompressedRistretto, RistrettoPoint};
6666
#[cfg(feature = "signing")]
6767
pub use sign::*;

ed448-goldilocks/src/montgomery.rs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ use core::ops::Mul;
1919
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq};
2020

2121
// Low order points on Curve448 and it's twist
22-
const LOW_A: MontgomeryPoint = MontgomeryPoint([
22+
const LOW_A: MontgomeryXpoint = MontgomeryXpoint([
2323
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2424
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2525
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2626
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2727
]);
28-
const LOW_B: MontgomeryPoint = MontgomeryPoint([
28+
const LOW_B: MontgomeryXpoint = MontgomeryXpoint([
2929
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3030
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3131
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3232
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3333
]);
34-
const LOW_C: MontgomeryPoint = MontgomeryPoint([
34+
const LOW_C: MontgomeryXpoint = MontgomeryXpoint([
3535
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3636
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff,
3737
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -40,51 +40,51 @@ const LOW_C: MontgomeryPoint = MontgomeryPoint([
4040

4141
/// A point in Montgomery form
4242
#[derive(Copy, Clone)]
43-
pub struct MontgomeryPoint(pub [u8; 56]);
43+
pub struct MontgomeryXpoint(pub [u8; 56]);
4444

45-
impl Default for MontgomeryPoint {
46-
fn default() -> MontgomeryPoint {
45+
impl Default for MontgomeryXpoint {
46+
fn default() -> MontgomeryXpoint {
4747
Self([0u8; 56])
4848
}
4949
}
5050

51-
impl elliptic_curve::zeroize::DefaultIsZeroes for MontgomeryPoint {}
51+
impl elliptic_curve::zeroize::DefaultIsZeroes for MontgomeryXpoint {}
5252

53-
impl fmt::Debug for MontgomeryPoint {
53+
impl fmt::Debug for MontgomeryXpoint {
5454
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
5555
self.0[..].fmt(formatter)
5656
}
5757
}
5858

59-
impl ConstantTimeEq for MontgomeryPoint {
60-
fn ct_eq(&self, other: &MontgomeryPoint) -> Choice {
59+
impl ConstantTimeEq for MontgomeryXpoint {
60+
fn ct_eq(&self, other: &MontgomeryXpoint) -> Choice {
6161
self.0.ct_eq(&other.0)
6262
}
6363
}
6464

65-
impl PartialEq for MontgomeryPoint {
66-
fn eq(&self, other: &MontgomeryPoint) -> bool {
65+
impl PartialEq for MontgomeryXpoint {
66+
fn eq(&self, other: &MontgomeryXpoint) -> bool {
6767
self.ct_eq(other).into()
6868
}
6969
}
70-
impl Eq for MontgomeryPoint {}
70+
impl Eq for MontgomeryXpoint {}
7171

7272
/// A Projective point in Montgomery form
7373
#[derive(Copy, Clone, Debug)]
74-
pub struct ProjectiveMontgomeryPoint {
74+
pub struct ProjectiveMontgomeryXpoint {
7575
U: FieldElement,
7676
W: FieldElement,
7777
}
7878

79-
impl Mul<&EdwardsScalar> for &MontgomeryPoint {
80-
type Output = MontgomeryPoint;
79+
impl Mul<&EdwardsScalar> for &MontgomeryXpoint {
80+
type Output = MontgomeryXpoint;
8181

8282
#[allow(clippy::suspicious_arithmetic_impl)]
83-
fn mul(self, scalar: &EdwardsScalar) -> MontgomeryPoint {
83+
fn mul(self, scalar: &EdwardsScalar) -> MontgomeryXpoint {
8484
// Algorithm 8 of Costello-Smith 2017
8585
let affine_u = FieldElement::from_bytes(&self.0);
86-
let mut x0 = ProjectiveMontgomeryPoint::identity();
87-
let mut x1 = ProjectiveMontgomeryPoint {
86+
let mut x0 = ProjectiveMontgomeryXpoint::identity();
87+
let mut x1 = ProjectiveMontgomeryXpoint {
8888
U: affine_u,
8989
W: FieldElement::ONE,
9090
};
@@ -95,7 +95,7 @@ impl Mul<&EdwardsScalar> for &MontgomeryPoint {
9595
let bit = bits[s] as u8;
9696
let choice: u8 = swap ^ bit;
9797

98-
ProjectiveMontgomeryPoint::conditional_swap(&mut x0, &mut x1, Choice::from(choice));
98+
ProjectiveMontgomeryXpoint::conditional_swap(&mut x0, &mut x1, Choice::from(choice));
9999
differential_add_and_double(&mut x0, &mut x1, &affine_u);
100100

101101
swap = bit;
@@ -105,15 +105,15 @@ impl Mul<&EdwardsScalar> for &MontgomeryPoint {
105105
}
106106
}
107107

108-
impl Mul<&MontgomeryPoint> for &EdwardsScalar {
109-
type Output = MontgomeryPoint;
108+
impl Mul<&MontgomeryXpoint> for &EdwardsScalar {
109+
type Output = MontgomeryXpoint;
110110

111-
fn mul(self, point: &MontgomeryPoint) -> MontgomeryPoint {
111+
fn mul(self, point: &MontgomeryXpoint) -> MontgomeryXpoint {
112112
point * self
113113
}
114114
}
115115

116-
impl MontgomeryPoint {
116+
impl MontgomeryXpoint {
117117
/// Returns the generator specified in RFC7748
118118
pub const GENERATOR: Self = Self([
119119
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -140,30 +140,30 @@ impl MontgomeryPoint {
140140
}
141141

142142
/// Convert the point to a ProjectiveMontgomeryPoint
143-
pub fn to_projective(&self) -> ProjectiveMontgomeryPoint {
144-
ProjectiveMontgomeryPoint {
143+
pub fn to_projective(&self) -> ProjectiveMontgomeryXpoint {
144+
ProjectiveMontgomeryXpoint {
145145
U: FieldElement::from_bytes(&self.0),
146146
W: FieldElement::ONE,
147147
}
148148
}
149149
}
150150

151-
impl ConditionallySelectable for ProjectiveMontgomeryPoint {
151+
impl ConditionallySelectable for ProjectiveMontgomeryXpoint {
152152
fn conditional_select(
153-
a: &ProjectiveMontgomeryPoint,
154-
b: &ProjectiveMontgomeryPoint,
153+
a: &ProjectiveMontgomeryXpoint,
154+
b: &ProjectiveMontgomeryXpoint,
155155
choice: Choice,
156-
) -> ProjectiveMontgomeryPoint {
157-
ProjectiveMontgomeryPoint {
156+
) -> ProjectiveMontgomeryXpoint {
157+
ProjectiveMontgomeryXpoint {
158158
U: FieldElement::conditional_select(&a.U, &b.U, choice),
159159
W: FieldElement::conditional_select(&a.W, &b.W, choice),
160160
}
161161
}
162162
}
163163

164164
fn differential_add_and_double(
165-
P: &mut ProjectiveMontgomeryPoint,
166-
Q: &mut ProjectiveMontgomeryPoint,
165+
P: &mut ProjectiveMontgomeryXpoint,
166+
Q: &mut ProjectiveMontgomeryXpoint,
167167
affine_PmQ: &FieldElement,
168168
) {
169169
let t0 = P.U + P.W;
@@ -199,19 +199,19 @@ fn differential_add_and_double(
199199
Q.W = t17; // W_{Q'} = U_D * 4 (W_P U_Q - U_P W_Q)^2
200200
}
201201

202-
impl ProjectiveMontgomeryPoint {
202+
impl ProjectiveMontgomeryXpoint {
203203
/// The identity element of the group: the point at infinity.
204-
pub fn identity() -> ProjectiveMontgomeryPoint {
205-
ProjectiveMontgomeryPoint {
204+
pub fn identity() -> ProjectiveMontgomeryXpoint {
205+
ProjectiveMontgomeryXpoint {
206206
U: FieldElement::ONE,
207207
W: FieldElement::ZERO,
208208
}
209209
}
210210

211211
/// Convert the point to affine form
212-
pub fn to_affine(&self) -> MontgomeryPoint {
212+
pub fn to_affine(&self) -> MontgomeryXpoint {
213213
let x = self.U * self.W.invert();
214-
MontgomeryPoint(x.to_bytes())
214+
MontgomeryXpoint(x.to_bytes())
215215
}
216216
}
217217

@@ -226,11 +226,11 @@ mod tests {
226226
use crate::GOLDILOCKS_BASE_POINT as bp;
227227

228228
// Montgomery scalar mul
229-
let montgomery_bp = bp.to_montgomery();
229+
let montgomery_bp = bp.to_montgomery_x();
230230
let montgomery_res = &montgomery_bp * &scalar;
231231

232232
// Goldilocks scalar mul
233233
let goldilocks_point = bp.scalar_mul(&scalar);
234-
assert_eq!(goldilocks_point.to_montgomery(), montgomery_res);
234+
assert_eq!(goldilocks_point.to_montgomery_x(), montgomery_res);
235235
}
236236
}

0 commit comments

Comments
 (0)