@@ -25,19 +25,19 @@ 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 /// Generate a random [`MontgomeryPoint`].
@@ -61,15 +61,15 @@ impl MontgomeryPoint {
6161impl ConditionallySelectable for MontgomeryPoint {
6262 fn conditional_select ( a : & Self , b : & Self , choice : Choice ) -> Self {
6363 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) ,
6666 }
6767 }
6868}
6969
7070impl ConstantTimeEq for MontgomeryPoint {
7171 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 )
7373 }
7474}
7575
@@ -82,8 +82,8 @@ impl PartialEq for MontgomeryPoint {
8282impl From < & MontgomeryPoint > for ProjectiveMontgomeryPoint {
8383 fn from ( value : & MontgomeryPoint ) -> Self {
8484 ProjectiveMontgomeryPoint {
85- U : value. x ,
86- V : value. y ,
85+ U : value. U ,
86+ V : value. V ,
8787 W : FieldElement :: ONE ,
8888 }
8989 }
@@ -97,7 +97,7 @@ impl From<MontgomeryPoint> for ProjectiveMontgomeryPoint {
9797
9898impl From < & MontgomeryPoint > for MontgomeryXpoint {
9999 fn from ( value : & MontgomeryPoint ) -> Self {
100- MontgomeryXpoint ( value. x . to_bytes ( ) )
100+ MontgomeryXpoint ( value. U . to_bytes ( ) )
101101 }
102102}
103103
@@ -110,8 +110,8 @@ impl From<MontgomeryPoint> for MontgomeryXpoint {
110110impl From < & MontgomeryPoint > for AffinePoint {
111111 // https://www.rfc-editor.org/rfc/rfc7748#section-4.2
112112 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 ;
115115 let mut t0 = x. square ( ) ; // x^2
116116 let t1 = t0 + FieldElement :: ONE ; // x^2+1
117117 t0 -= FieldElement :: ONE ; // x^2-1
@@ -157,19 +157,19 @@ impl AffineCoordinates for MontgomeryPoint {
157157 type FieldRepr = Curve448FieldBytes ;
158158
159159 fn x ( & self ) -> Self :: FieldRepr {
160- self . x . to_bytes ( ) . into ( )
160+ self . U . to_bytes ( ) . into ( )
161161 }
162162
163163 fn y ( & self ) -> Self :: FieldRepr {
164- self . y . to_bytes ( ) . into ( )
164+ self . V . to_bytes ( ) . into ( )
165165 }
166166
167167 fn x_is_odd ( & self ) -> Choice {
168- self . x . is_negative ( )
168+ self . U . is_negative ( )
169169 }
170170
171171 fn y_is_odd ( & self ) -> Choice {
172- self . y . is_negative ( )
172+ self . V . is_negative ( )
173173 }
174174}
175175
@@ -282,10 +282,10 @@ impl PartialEq for ProjectiveMontgomeryPoint {
282282impl From < & ProjectiveMontgomeryPoint > for MontgomeryPoint {
283283 fn from ( value : & ProjectiveMontgomeryPoint ) -> Self {
284284 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 ;
287287
288- MontgomeryPoint { x , y }
288+ MontgomeryPoint { U , V }
289289 }
290290}
291291
@@ -430,10 +430,10 @@ impl CurveGroup for ProjectiveMontgomeryPoint {
430430
431431 fn to_affine ( & self ) -> Self :: AffineRepr {
432432 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 ;
435435
436- MontgomeryPoint { x , y }
436+ MontgomeryPoint { U , V }
437437 }
438438}
439439
@@ -453,10 +453,10 @@ impl GroupEncoding for ProjectiveMontgomeryPoint {
453453 _ => ( Choice :: from ( 0 ) , Choice :: from ( 0 ) ) ,
454454 } ;
455455
456- FieldElement :: from_repr ( & x_bytes) . and_then ( |x | {
456+ FieldElement :: from_repr ( & x_bytes) . and_then ( |U | {
457457 CtOption :: new (
458458 ProjectiveMontgomeryXpoint {
459- U : x ,
459+ U ,
460460 W : FieldElement :: ONE ,
461461 }
462462 . to_extended ( sign) ,
@@ -474,13 +474,13 @@ impl GroupEncoding for ProjectiveMontgomeryPoint {
474474 let affine = self . to_affine ( ) ;
475475 let mut compressed_bytes = Array :: default ( ) ;
476476
477- compressed_bytes[ 0 ] = if affine. y . is_negative ( ) . unwrap_u8 ( ) == 1 {
477+ compressed_bytes[ 0 ] = if affine. V . is_negative ( ) . unwrap_u8 ( ) == 1 {
478478 0x03
479479 } else {
480480 0x02
481481 } ;
482482
483- compressed_bytes[ 1 ..] . copy_from_slice ( & affine. x . to_bytes ( ) [ ..] ) ;
483+ compressed_bytes[ 1 ..] . copy_from_slice ( & affine. U . to_bytes ( ) [ ..] ) ;
484484 compressed_bytes
485485 }
486486}
0 commit comments