File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
ed448-goldilocks/src/montgomery Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use crate::edwards::extended::EdwardsPoint;
4
4
use crate :: field:: FieldElement ;
5
5
use core:: fmt;
6
6
use core:: ops:: Mul ;
7
- use subtle:: { Choice , ConditionallySelectable , ConstantTimeEq } ;
7
+ use subtle:: { Choice , ConditionallyNegatable , ConditionallySelectable , ConstantTimeEq } ;
8
8
9
9
impl MontgomeryXpoint {
10
10
/// First low order point on Curve448 and it's twist
@@ -131,6 +131,23 @@ impl MontgomeryXpoint {
131
131
& self . 0
132
132
}
133
133
134
+ /// Compute the Y-coordinate
135
+ pub fn y ( & self , sign : Choice ) -> [ u8 ; 56 ] {
136
+ self . y_internal ( sign) . to_bytes ( )
137
+ }
138
+
139
+ // See https://www.rfc-editor.org/rfc/rfc7748#section-1.
140
+ pub ( super ) fn y_internal ( & self , sign : Choice ) -> FieldElement {
141
+ // v^2 = u^3 + A*u^2 + u
142
+ let u = FieldElement :: from_bytes ( & self . 0 ) ;
143
+ let uu = u. square ( ) ;
144
+ let vv = uu * u + FieldElement :: J * uu + u;
145
+
146
+ let mut v = vv. sqrt ( ) ;
147
+ v. conditional_negate ( v. is_negative ( ) ^ sign) ;
148
+ v
149
+ }
150
+
134
151
/// Convert the point to a ProjectiveMontgomeryPoint
135
152
pub fn to_projective ( & self ) -> ProjectiveMontgomeryXpoint {
136
153
ProjectiveMontgomeryXpoint {
You can’t perform that action at this time.
0 commit comments