@@ -25,19 +25,19 @@ use crate::{AffinePoint, Curve448, Curve448FieldBytes, ORDER};
25
25
/// A point in Montgomery form including the y-coordinate.
26
26
#[ derive( Copy , Clone , Debug , Default , Eq ) ]
27
27
pub struct MontgomeryPoint {
28
- pub ( super ) x : FieldElement ,
29
- pub ( super ) y : FieldElement ,
28
+ pub ( super ) U : FieldElement ,
29
+ pub ( super ) V : FieldElement ,
30
30
}
31
31
32
32
impl MontgomeryPoint {
33
33
/// The identity element of the group: the point at infinity.
34
34
pub const IDENTITY : Self = Self {
35
- x : FieldElement :: ZERO ,
36
- y : FieldElement :: ONE ,
35
+ U : FieldElement :: ZERO ,
36
+ V : FieldElement :: ONE ,
37
37
} ;
38
38
39
- pub ( crate ) fn new ( x : FieldElement , y : FieldElement ) -> Self {
40
- Self { x , y }
39
+ pub ( crate ) fn new ( U : FieldElement , V : FieldElement ) -> Self {
40
+ Self { U , V }
41
41
}
42
42
43
43
/// Generate a random [`MontgomeryPoint`].
@@ -61,15 +61,15 @@ impl MontgomeryPoint {
61
61
impl ConditionallySelectable for MontgomeryPoint {
62
62
fn conditional_select ( a : & Self , b : & Self , choice : Choice ) -> Self {
63
63
Self {
64
- x : FieldElement :: conditional_select ( & a. x , & b. x , choice) ,
65
- y : FieldElement :: conditional_select ( & a. y , & b. y , choice) ,
64
+ U : FieldElement :: conditional_select ( & a. U , & b. U , choice) ,
65
+ V : FieldElement :: conditional_select ( & a. V , & b. V , choice) ,
66
66
}
67
67
}
68
68
}
69
69
70
70
impl ConstantTimeEq for MontgomeryPoint {
71
71
fn ct_eq ( & self , other : & Self ) -> Choice {
72
- self . x . ct_eq ( & other. x ) & self . y . ct_eq ( & other. y )
72
+ self . U . ct_eq ( & other. U ) & self . V . ct_eq ( & other. V )
73
73
}
74
74
}
75
75
@@ -82,8 +82,8 @@ impl PartialEq for MontgomeryPoint {
82
82
impl From < & MontgomeryPoint > for ProjectiveMontgomeryPoint {
83
83
fn from ( value : & MontgomeryPoint ) -> Self {
84
84
ProjectiveMontgomeryPoint {
85
- U : value. x ,
86
- V : value. y ,
85
+ U : value. U ,
86
+ V : value. V ,
87
87
W : FieldElement :: ONE ,
88
88
}
89
89
}
@@ -97,7 +97,7 @@ impl From<MontgomeryPoint> for ProjectiveMontgomeryPoint {
97
97
98
98
impl From < & MontgomeryPoint > for MontgomeryXpoint {
99
99
fn from ( value : & MontgomeryPoint ) -> Self {
100
- MontgomeryXpoint ( value. x . to_bytes ( ) )
100
+ MontgomeryXpoint ( value. U . to_bytes ( ) )
101
101
}
102
102
}
103
103
@@ -110,8 +110,8 @@ impl From<MontgomeryPoint> for MontgomeryXpoint {
110
110
impl From < & MontgomeryPoint > for AffinePoint {
111
111
// https://www.rfc-editor.org/rfc/rfc7748#section-4.2
112
112
fn from ( value : & MontgomeryPoint ) -> AffinePoint {
113
- let x = value. x ;
114
- let y = value. y ;
113
+ let x = value. U ;
114
+ let y = value. V ;
115
115
let mut t0 = x. square ( ) ; // x^2
116
116
let t1 = t0 + FieldElement :: ONE ; // x^2+1
117
117
t0 -= FieldElement :: ONE ; // x^2-1
@@ -157,19 +157,19 @@ impl AffineCoordinates for MontgomeryPoint {
157
157
type FieldRepr = Curve448FieldBytes ;
158
158
159
159
fn x ( & self ) -> Self :: FieldRepr {
160
- self . x . to_bytes ( ) . into ( )
160
+ self . U . to_bytes ( ) . into ( )
161
161
}
162
162
163
163
fn y ( & self ) -> Self :: FieldRepr {
164
- self . y . to_bytes ( ) . into ( )
164
+ self . V . to_bytes ( ) . into ( )
165
165
}
166
166
167
167
fn x_is_odd ( & self ) -> Choice {
168
- self . x . is_negative ( )
168
+ self . U . is_negative ( )
169
169
}
170
170
171
171
fn y_is_odd ( & self ) -> Choice {
172
- self . y . is_negative ( )
172
+ self . V . is_negative ( )
173
173
}
174
174
}
175
175
@@ -282,10 +282,10 @@ impl PartialEq for ProjectiveMontgomeryPoint {
282
282
impl From < & ProjectiveMontgomeryPoint > for MontgomeryPoint {
283
283
fn from ( value : & ProjectiveMontgomeryPoint ) -> Self {
284
284
let W_inv = value. W . invert ( ) ;
285
- let x = value. U * W_inv ;
286
- let y = value. V * W_inv ;
285
+ let U = value. U * W_inv ;
286
+ let V = value. V * W_inv ;
287
287
288
- MontgomeryPoint { x , y }
288
+ MontgomeryPoint { U , V }
289
289
}
290
290
}
291
291
@@ -430,10 +430,10 @@ impl CurveGroup for ProjectiveMontgomeryPoint {
430
430
431
431
fn to_affine ( & self ) -> Self :: AffineRepr {
432
432
let W_inv = self . W . invert ( ) ;
433
- let x = self . U * W_inv ;
434
- let y = self . V * W_inv ;
433
+ let U = self . U * W_inv ;
434
+ let V = self . V * W_inv ;
435
435
436
- MontgomeryPoint { x , y }
436
+ MontgomeryPoint { U , V }
437
437
}
438
438
}
439
439
@@ -453,10 +453,10 @@ impl GroupEncoding for ProjectiveMontgomeryPoint {
453
453
_ => ( Choice :: from ( 0 ) , Choice :: from ( 0 ) ) ,
454
454
} ;
455
455
456
- FieldElement :: from_repr ( & x_bytes) . and_then ( |x | {
456
+ FieldElement :: from_repr ( & x_bytes) . and_then ( |U | {
457
457
CtOption :: new (
458
458
ProjectiveMontgomeryXpoint {
459
- U : x ,
459
+ U ,
460
460
W : FieldElement :: ONE ,
461
461
}
462
462
. to_extended ( sign) ,
@@ -474,13 +474,13 @@ impl GroupEncoding for ProjectiveMontgomeryPoint {
474
474
let affine = self . to_affine ( ) ;
475
475
let mut compressed_bytes = Array :: default ( ) ;
476
476
477
- compressed_bytes[ 0 ] = if affine. y . is_negative ( ) . unwrap_u8 ( ) == 1 {
477
+ compressed_bytes[ 0 ] = if affine. V . is_negative ( ) . unwrap_u8 ( ) == 1 {
478
478
0x03
479
479
} else {
480
480
0x02
481
481
} ;
482
482
483
- compressed_bytes[ 1 ..] . copy_from_slice ( & affine. x . to_bytes ( ) [ ..] ) ;
483
+ compressed_bytes[ 1 ..] . copy_from_slice ( & affine. U . to_bytes ( ) [ ..] ) ;
484
484
compressed_bytes
485
485
}
486
486
}
0 commit comments