1
1
// use crate::constants::A_PLUS_TWO_OVER_FOUR;
2
2
use crate :: EdwardsScalar ;
3
3
use crate :: edwards:: extended:: EdwardsPoint ;
4
- use crate :: field:: FieldElement ;
4
+ use crate :: field:: { ConstMontyType , FieldElement } ;
5
5
use core:: fmt;
6
6
use core:: ops:: Mul ;
7
+ use elliptic_curve:: bigint:: U448 ;
7
8
use subtle:: { Choice , ConditionallyNegatable , ConditionallySelectable , ConstantTimeEq } ;
8
9
9
10
impl MontgomeryXpoint {
@@ -243,6 +244,12 @@ impl ProjectiveMontgomeryXpoint {
243
244
W : FieldElement :: ZERO ,
244
245
} ;
245
246
247
+ /// The generator point
248
+ pub const GENERATOR : Self = Self {
249
+ U : FieldElement ( ConstMontyType :: new ( & U448 :: from_u64 ( 5 ) ) ) ,
250
+ W : FieldElement :: ONE ,
251
+ } ;
252
+
246
253
/// Convert the point to affine form
247
254
pub fn to_affine ( & self ) -> MontgomeryXpoint {
248
255
let x = self . U * self . W . invert ( ) ;
@@ -258,14 +265,12 @@ mod tests {
258
265
#[ test]
259
266
fn test_montgomery_edwards ( ) {
260
267
let scalar = EdwardsScalar :: from ( 200u32 ) ;
261
- use crate :: GOLDILOCKS_BASE_POINT as bp;
262
268
263
269
// Montgomery scalar mul
264
- let montgomery_bp = bp. to_montgomery_x ( ) ;
265
- let montgomery_res = & ( & montgomery_bp * & scalar) * & scalar;
270
+ let montgomery_res = & ( & ProjectiveMontgomeryXpoint :: GENERATOR * & scalar) * & scalar;
266
271
267
272
// Goldilocks scalar mul
268
- let goldilocks_point = bp . scalar_mul ( & scalar) . scalar_mul ( & scalar) ;
273
+ let goldilocks_point = EdwardsPoint :: GENERATOR * scalar * scalar;
269
274
assert_eq ! (
270
275
goldilocks_point. to_montgomery_x( ) ,
271
276
montgomery_res. to_affine( )
0 commit comments