1 #ifndef GE_H 2 #define GE_H 3 4 #include "fe.h" 5 6 7 /* 8 ge means group element. 9 10 Here the group is the set of pairs (x,y) of field elements (see fe.h) 11 satisfying -x^2 + y^2 = 1 + d x^2y^2 12 where d = -121665/121666. 13 14 Representations: 15 ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z 16 ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT 17 ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T 18 ge_precomp (Duif): (y+x,y-x,2dxy) 19 */ 20 21 typedef struct { 22 fe X; 23 fe Y; 24 fe Z; 25 } ge_p2; 26 27 typedef struct { 28 fe X; 29 fe Y; 30 fe Z; 31 fe T; 32 } ge_p3; 33 34 typedef struct { 35 fe X; 36 fe Y; 37 fe Z; 38 fe T; 39 } ge_p1p1; 40 41 typedef struct { 42 fe yplusx; 43 fe yminusx; 44 fe xy2d; 45 } ge_precomp; 46 47 typedef struct { 48 fe YplusX; 49 fe YminusX; 50 fe Z; 51 fe T2d; 52 } ge_cached; 53 54 void ge_p3_tobytes(unsigned char *s, const ge_p3 *h); 55 void ge_tobytes(unsigned char *s, const ge_p2 *h); 56 int ge_frombytes_negate_vartime(ge_p3 *h, const unsigned char *s); 57 58 void ge_add(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q); 59 void ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q); 60 void ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a, const ge_p3 *A, const unsigned char *b); 61 void ge_madd(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q); 62 void ge_msub(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q); 63 void ge_scalarmult_base(ge_p3 *h, const unsigned char *a); 64 65 void ge_p1p1_to_p2(ge_p2 *r, const ge_p1p1 *p); 66 void ge_p1p1_to_p3(ge_p3 *r, const ge_p1p1 *p); 67 void ge_p2_0(ge_p2 *h); 68 void ge_p2_dbl(ge_p1p1 *r, const ge_p2 *p); 69 void ge_p3_0(ge_p3 *h); 70 void ge_p3_dbl(ge_p1p1 *r, const ge_p3 *p); 71 void ge_p3_to_cached(ge_cached *r, const ge_p3 *p); 72 void ge_p3_to_p2(ge_p2 *r, const ge_p3 *p); 73 74 #endif 75