@@ -25,34 +25,34 @@ use crate::{AffinePoint, Curve448, Curve448FieldBytes, ORDER};
2525/// A point in Montgomery form including the y-coordinate.
2626#[ derive( Copy , Clone , Debug , Default , Eq ) ]
2727pub struct MontgomeryPoint {
28- pub ( super ) x : FieldElement ,
29- pub ( super ) y : FieldElement ,
28+ pub ( super ) U : FieldElement ,
29+ pub ( super ) V : FieldElement ,
3030}
3131
3232impl MontgomeryPoint {
3333 /// The identity element of the group: the point at infinity.
3434 pub const IDENTITY : Self = Self {
35- x : FieldElement :: ZERO ,
36- y : FieldElement :: ONE ,
35+ U : FieldElement :: ZERO ,
36+ V : FieldElement :: ONE ,
3737 } ;
3838
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 }
4141 }
4242}
4343
4444impl ConditionallySelectable for MontgomeryPoint {
4545 fn conditional_select ( a : & Self , b : & Self , choice : Choice ) -> Self {
4646 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) ,
4949 }
5050 }
5151}
5252
5353impl ConstantTimeEq for MontgomeryPoint {
5454 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 )
5656 }
5757}
5858
@@ -65,8 +65,8 @@ impl PartialEq for MontgomeryPoint {
6565impl From < & MontgomeryPoint > for ProjectiveMontgomeryPoint {
6666 fn from ( value : & MontgomeryPoint ) -> Self {
6767 ProjectiveMontgomeryPoint {
68- U : value. x ,
69- V : value. y ,
68+ U : value. U ,
69+ V : value. V ,
7070 W : FieldElement :: ONE ,
7171 }
7272 }
@@ -80,7 +80,7 @@ impl From<MontgomeryPoint> for ProjectiveMontgomeryPoint {
8080
8181impl From < & MontgomeryPoint > for MontgomeryXpoint {
8282 fn from ( value : & MontgomeryPoint ) -> Self {
83- MontgomeryXpoint ( value. x . to_bytes ( ) )
83+ MontgomeryXpoint ( value. U . to_bytes ( ) )
8484 }
8585}
8686
@@ -93,8 +93,8 @@ impl From<MontgomeryPoint> for MontgomeryXpoint {
9393impl From < & MontgomeryPoint > for AffinePoint {
9494 // https://www.rfc-editor.org/rfc/rfc7748#section-4.2
9595 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 ;
9898 let mut t0 = x. square ( ) ; // x^2
9999 let t1 = t0 + FieldElement :: ONE ; // x^2+1
100100 t0 -= FieldElement :: ONE ; // x^2-1
@@ -140,19 +140,19 @@ impl AffineCoordinates for MontgomeryPoint {
140140 type FieldRepr = Curve448FieldBytes ;
141141
142142 fn x ( & self ) -> Self :: FieldRepr {
143- self . x . to_bytes ( ) . into ( )
143+ self . U . to_bytes ( ) . into ( )
144144 }
145145
146146 fn y ( & self ) -> Self :: FieldRepr {
147- self . y . to_bytes ( ) . into ( )
147+ self . V . to_bytes ( ) . into ( )
148148 }
149149
150150 fn x_is_odd ( & self ) -> Choice {
151- self . x . is_negative ( )
151+ self . U . is_negative ( )
152152 }
153153
154154 fn y_is_odd ( & self ) -> Choice {
155- self . y . is_negative ( )
155+ self . V . is_negative ( )
156156 }
157157}
158158
@@ -259,10 +259,10 @@ impl PartialEq for ProjectiveMontgomeryPoint {
259259impl From < & ProjectiveMontgomeryPoint > for MontgomeryPoint {
260260 fn from ( value : & ProjectiveMontgomeryPoint ) -> Self {
261261 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 ;
264264
265- MontgomeryPoint { x , y }
265+ MontgomeryPoint { U , V }
266266 }
267267}
268268
@@ -404,10 +404,10 @@ impl CurveGroup for ProjectiveMontgomeryPoint {
404404
405405 fn to_affine ( & self ) -> Self :: AffineRepr {
406406 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 ;
409409
410- MontgomeryPoint { x , y }
410+ MontgomeryPoint { U , V }
411411 }
412412}
413413
@@ -427,10 +427,10 @@ impl GroupEncoding for ProjectiveMontgomeryPoint {
427427 _ => ( Choice :: from ( 0 ) , Choice :: from ( 0 ) ) ,
428428 } ;
429429
430- FieldElement :: from_repr ( & x_bytes) . and_then ( |x | {
430+ FieldElement :: from_repr ( & x_bytes) . and_then ( |U | {
431431 CtOption :: new (
432432 ProjectiveMontgomeryXpoint {
433- U : x ,
433+ U ,
434434 W : FieldElement :: ONE ,
435435 }
436436 . to_extended ( sign) ,
@@ -448,13 +448,13 @@ impl GroupEncoding for ProjectiveMontgomeryPoint {
448448 let affine = self . to_affine ( ) ;
449449 let mut compressed_bytes = Array :: default ( ) ;
450450
451- compressed_bytes[ 0 ] = if affine. y . is_negative ( ) . unwrap_u8 ( ) == 1 {
451+ compressed_bytes[ 0 ] = if affine. V . is_negative ( ) . unwrap_u8 ( ) == 1 {
452452 0x03
453453 } else {
454454 0x02
455455 } ;
456456
457- compressed_bytes[ 1 ..] . copy_from_slice ( & affine. x . to_bytes ( ) [ ..] ) ;
457+ compressed_bytes[ 1 ..] . copy_from_slice ( & affine. U . to_bytes ( ) [ ..] ) ;
458458 compressed_bytes
459459 }
460460}
0 commit comments