File tree Expand file tree Collapse file tree 4 files changed +7
-11
lines changed Expand file tree Collapse file tree 4 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ impl AffinePoint {
111
111
}
112
112
113
113
/// Convert this point to [`MontgomeryXpoint`]
114
+ // See https://www.rfc-editor.org/rfc/rfc7748#section-4.2 4-isogeny maps
114
115
pub fn to_montgomery_x ( & self ) -> MontgomeryXpoint {
115
116
// u = y^2/x^2
116
117
let u = self . y . square ( ) * self . x . square ( ) . invert ( ) ;
@@ -119,10 +120,12 @@ impl AffinePoint {
119
120
}
120
121
121
122
/// Convert this point to [`MontgomeryPoint`]
123
+ // See https://www.rfc-editor.org/rfc/rfc7748#section-4.2 4-isogeny maps
122
124
pub fn to_montgomery ( & self ) -> MontgomeryPoint {
123
125
let x_sq = self . x . square ( ) ;
124
126
let y_sq = self . y . square ( ) ;
125
127
128
+ // u = y^2/x^2
126
129
let u = y_sq * x_sq. invert ( ) ;
127
130
// v = (2 - x^2 - y^2)*y/x^3)
128
131
let v = ( ( FieldElement :: TWO - x_sq - y_sq) * self . y ) * ( x_sq * self . x ) . invert ( ) ;
Original file line number Diff line number Diff line change @@ -1186,14 +1186,16 @@ mod tests {
1186
1186
1187
1187
// Test Montgomery to Edwards conversion.
1188
1188
let conv_p =
1189
- ProjectiveMontgomeryXpoint :: encode :: < ExpandMsgXof < Shake256 > > ( & [ msg] , & [ DST ] ) ;
1189
+ ProjectiveMontgomeryXpoint :: encode :: < ExpandMsgXof < Shake256 > > ( & [ msg] , & [ DST ] )
1190
+ . to_affine ( ) ;
1190
1191
let conv_p1 = conv_p. to_edwards ( Choice :: from ( 0 ) ) ;
1191
1192
let conv_p2 = conv_p. to_edwards ( Choice :: from ( 1 ) ) ;
1192
1193
assert ! ( conv_p1. x == p. x || conv_p2. x == p. x) ;
1193
1194
assert ! ( conv_p1. y == p. y || conv_p2. y == p. y) ;
1194
1195
1195
1196
let conv_p = Curve448 :: encode_from_bytes :: < ExpandMsgXof < Shake256 > > ( & [ msg] , & [ DST ] )
1196
1197
. unwrap ( )
1198
+ . to_affine ( )
1197
1199
. to_edwards ( ) ;
1198
1200
assert_eq ! ( conv_p. x, p. x) ;
1199
1201
assert_eq ! ( conv_p. y, p. y) ;
Original file line number Diff line number Diff line change @@ -174,11 +174,6 @@ impl ProjectiveMontgomeryPoint {
174
174
self . to_projective_x ( ) . to_affine ( )
175
175
}
176
176
177
- /// Convert this point to an [`AffinePoint`]
178
- pub fn to_edwards ( & self ) -> AffinePoint {
179
- self . to_affine ( ) . to_edwards ( )
180
- }
181
-
182
177
/// Hash a message to a point on the curve
183
178
///
184
179
/// Hash using the default domain separation tag and hash function.
Original file line number Diff line number Diff line change @@ -240,6 +240,7 @@ impl ProjectiveMontgomeryXpoint {
240
240
W : FieldElement :: ONE ,
241
241
} ;
242
242
243
+ // See https://www.rfc-editor.org/rfc/rfc7748#section-1
243
244
fn y ( & self , sign : Choice ) -> FieldElement {
244
245
// v^2 = u^3 + A*u^2 + u
245
246
let u_sq = self . U . square ( ) ;
@@ -342,11 +343,6 @@ impl ProjectiveMontgomeryXpoint {
342
343
pub fn to_extended ( & self , sign : Choice ) -> ProjectiveMontgomeryPoint {
343
344
ProjectiveMontgomeryPoint :: new ( self . U , self . y ( sign) , self . W )
344
345
}
345
-
346
- /// Convert this point to an [`AffinePoint`]
347
- pub fn to_edwards ( & self , sign : Choice ) -> AffinePoint {
348
- self . to_affine ( ) . to_edwards ( sign)
349
- }
350
346
}
351
347
352
348
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments