File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 11#![ allow( dead_code) ]
2+ use crate :: TWISTED_EDWARDS_BASE_POINT ;
23use crate :: curve:: twedwards:: { extended:: ExtendedPoint , extensible:: ExtensiblePoint } ;
34use crate :: field:: FieldElement ;
45use subtle:: { Choice , ConditionallySelectable , ConstantTimeEq } ;
@@ -30,6 +31,12 @@ impl AffinePoint {
3031 y : FieldElement :: ONE ,
3132 } ;
3233
34+ /// Identity element
35+ pub ( crate ) const GENERATOR : AffinePoint = AffinePoint {
36+ x : TWISTED_EDWARDS_BASE_POINT . X ,
37+ y : TWISTED_EDWARDS_BASE_POINT . Y ,
38+ } ;
39+
3340 /// Checks if the AffinePoint is on the TwistedEdwards curve
3441 pub ( crate ) fn is_on_curve ( & self ) -> Choice {
3542 let xx = self . x . square ( ) ;
@@ -140,7 +147,6 @@ mod tests {
140147
141148 #[ test]
142149 fn test_negation ( ) {
143- use crate :: TWISTED_EDWARDS_BASE_POINT ;
144150 let a = TWISTED_EDWARDS_BASE_POINT . to_extensible ( ) . to_affine ( ) ;
145151 assert_eq ! ( a. is_on_curve( ) . unwrap_u8( ) , 1 ) ;
146152
Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ impl DefaultIsZeroes for AffinePoint {}
7373impl AffinePoint {
7474 /// The identity point
7575 pub const IDENTITY : Self = Self ( InnerAffinePoint :: IDENTITY ) ;
76+ /// The generator point
77+ pub const GENERATOR : Self = Self ( InnerAffinePoint :: GENERATOR ) ;
7678
7779 /// Convert to DecafPoint
7880 pub fn to_decaf ( & self ) -> DecafPoint {
@@ -115,3 +117,15 @@ impl Mul<&DecafScalar> for &AffinePoint {
115117}
116118
117119define_mul_variants ! ( LHS = AffinePoint , RHS = DecafScalar , Output = DecafPoint ) ;
120+
121+ #[ cfg( test) ]
122+ mod test {
123+ use super :: * ;
124+ use elliptic_curve:: CurveGroup ;
125+
126+ #[ test]
127+ fn generator ( ) {
128+ assert_eq ! ( AffinePoint :: GENERATOR . to_decaf( ) , DecafPoint :: GENERATOR ) ;
129+ assert_eq ! ( DecafPoint :: GENERATOR . to_affine( ) , AffinePoint :: GENERATOR ) ;
130+ }
131+ }
You can’t perform that action at this time.
0 commit comments