@@ -25,34 +25,34 @@ 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
44
44
impl ConditionallySelectable for MontgomeryPoint {
45
45
fn conditional_select ( a : & Self , b : & Self , choice : Choice ) -> Self {
46
46
Self {
47
- x : FieldElement :: conditional_select ( & a. x , & b. x , choice) ,
48
- y : FieldElement :: conditional_select ( & a. y , & b. y , choice) ,
47
+ U : FieldElement :: conditional_select ( & a. U , & b. U , choice) ,
48
+ V : FieldElement :: conditional_select ( & a. V , & b. V , choice) ,
49
49
}
50
50
}
51
51
}
52
52
53
53
impl ConstantTimeEq for MontgomeryPoint {
54
54
fn ct_eq ( & self , other : & Self ) -> Choice {
55
- self . x . ct_eq ( & other. x ) & self . y . ct_eq ( & other. y )
55
+ self . U . ct_eq ( & other. U ) & self . V . ct_eq ( & other. V )
56
56
}
57
57
}
58
58
@@ -65,8 +65,8 @@ impl PartialEq for MontgomeryPoint {
65
65
impl From < & MontgomeryPoint > for ProjectiveMontgomeryPoint {
66
66
fn from ( value : & MontgomeryPoint ) -> Self {
67
67
ProjectiveMontgomeryPoint {
68
- U : value. x ,
69
- V : value. y ,
68
+ U : value. U ,
69
+ V : value. V ,
70
70
W : FieldElement :: ONE ,
71
71
}
72
72
}
@@ -80,7 +80,7 @@ impl From<MontgomeryPoint> for ProjectiveMontgomeryPoint {
80
80
81
81
impl From < & MontgomeryPoint > for MontgomeryXpoint {
82
82
fn from ( value : & MontgomeryPoint ) -> Self {
83
- MontgomeryXpoint ( value. x . to_bytes ( ) )
83
+ MontgomeryXpoint ( value. U . to_bytes ( ) )
84
84
}
85
85
}
86
86
@@ -93,8 +93,8 @@ impl From<MontgomeryPoint> for MontgomeryXpoint {
93
93
impl From < & MontgomeryPoint > for AffinePoint {
94
94
// https://www.rfc-editor.org/rfc/rfc7748#section-4.2
95
95
fn from ( value : & MontgomeryPoint ) -> AffinePoint {
96
- let x = value. x ;
97
- let y = value. y ;
96
+ let x = value. U ;
97
+ let y = value. V ;
98
98
let mut t0 = x. square ( ) ; // x^2
99
99
let t1 = t0 + FieldElement :: ONE ; // x^2+1
100
100
t0 -= FieldElement :: ONE ; // x^2-1
@@ -140,19 +140,19 @@ impl AffineCoordinates for MontgomeryPoint {
140
140
type FieldRepr = Curve448FieldBytes ;
141
141
142
142
fn x ( & self ) -> Self :: FieldRepr {
143
- self . x . to_bytes ( ) . into ( )
143
+ self . U . to_bytes ( ) . into ( )
144
144
}
145
145
146
146
fn y ( & self ) -> Self :: FieldRepr {
147
- self . y . to_bytes ( ) . into ( )
147
+ self . V . to_bytes ( ) . into ( )
148
148
}
149
149
150
150
fn x_is_odd ( & self ) -> Choice {
151
- self . x . is_negative ( )
151
+ self . U . is_negative ( )
152
152
}
153
153
154
154
fn y_is_odd ( & self ) -> Choice {
155
- self . y . is_negative ( )
155
+ self . V . is_negative ( )
156
156
}
157
157
}
158
158
@@ -259,10 +259,10 @@ impl PartialEq for ProjectiveMontgomeryPoint {
259
259
impl From < & ProjectiveMontgomeryPoint > for MontgomeryPoint {
260
260
fn from ( value : & ProjectiveMontgomeryPoint ) -> Self {
261
261
let W_inv = value. W . invert ( ) ;
262
- let x = value. U * W_inv ;
263
- let y = value. V * W_inv ;
262
+ let U = value. U * W_inv ;
263
+ let V = value. V * W_inv ;
264
264
265
- MontgomeryPoint { x , y }
265
+ MontgomeryPoint { U , V }
266
266
}
267
267
}
268
268
@@ -404,10 +404,10 @@ impl CurveGroup for ProjectiveMontgomeryPoint {
404
404
405
405
fn to_affine ( & self ) -> Self :: AffineRepr {
406
406
let W_inv = self . W . invert ( ) ;
407
- let x = self . U * W_inv ;
408
- let y = self . V * W_inv ;
407
+ let U = self . U * W_inv ;
408
+ let V = self . V * W_inv ;
409
409
410
- MontgomeryPoint { x , y }
410
+ MontgomeryPoint { U , V }
411
411
}
412
412
}
413
413
@@ -427,10 +427,10 @@ impl GroupEncoding for ProjectiveMontgomeryPoint {
427
427
_ => ( Choice :: from ( 0 ) , Choice :: from ( 0 ) ) ,
428
428
} ;
429
429
430
- FieldElement :: from_repr ( & x_bytes) . and_then ( |x | {
430
+ FieldElement :: from_repr ( & x_bytes) . and_then ( |U | {
431
431
CtOption :: new (
432
432
ProjectiveMontgomeryXpoint {
433
- U : x ,
433
+ U ,
434
434
W : FieldElement :: ONE ,
435
435
}
436
436
. to_extended ( sign) ,
@@ -448,13 +448,13 @@ impl GroupEncoding for ProjectiveMontgomeryPoint {
448
448
let affine = self . to_affine ( ) ;
449
449
let mut compressed_bytes = Array :: default ( ) ;
450
450
451
- compressed_bytes[ 0 ] = if affine. y . is_negative ( ) . unwrap_u8 ( ) == 1 {
451
+ compressed_bytes[ 0 ] = if affine. V . is_negative ( ) . unwrap_u8 ( ) == 1 {
452
452
0x03
453
453
} else {
454
454
0x02
455
455
} ;
456
456
457
- compressed_bytes[ 1 ..] . copy_from_slice ( & affine. x . to_bytes ( ) [ ..] ) ;
457
+ compressed_bytes[ 1 ..] . copy_from_slice ( & affine. U . to_bytes ( ) [ ..] ) ;
458
458
compressed_bytes
459
459
}
460
460
}
0 commit comments