| 1 | #include <cross_platform.h> |
| 2 | |
| 3 | #ifndef GE_H |
| 4 | #define GE_H |
| 5 | |
| 6 | /* |
| 7 | ge means group element. |
| 8 | |
| 9 | Here the group is the set of pairs (x,y) of field elements (see fe.h) |
| 10 | satisfying -x^2 + y^2 = 1 + d x^2y^2 |
| 11 | where d = -121665/121666. |
| 12 | |
| 13 | Representations: |
| 14 | ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z |
| 15 | ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT |
| 16 | ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T |
| 17 | ge_precomp (Duif): (y+x,y-x,2dxy) |
| 18 | */ |
| 19 | |
| 20 | #include <fe.h> |
| 21 | |
| 22 | typedef struct { |
| 23 | fe X; |
| 24 | fe Y; |
| 25 | fe Z; |
| 26 | } ge_p2; |
| 27 | |
| 28 | typedef struct { |
| 29 | fe X; |
| 30 | fe Y; |
| 31 | fe Z; |
| 32 | fe T; |
| 33 | } ge_p3; |
| 34 | |
| 35 | typedef struct { |
| 36 | fe X; |
| 37 | fe Y; |
| 38 | fe Z; |
| 39 | fe T; |
| 40 | } ge_p1p1; |
| 41 | |
| 42 | typedef struct { |
| 43 | fe yplusx; |
| 44 | fe yminusx; |
| 45 | fe xy2d; |
| 46 | } ge_precomp; |
| 47 | |
| 48 | typedef struct { |
| 49 | fe YplusX; |
| 50 | fe YminusX; |
| 51 | fe Z; |
| 52 | fe T2d; |
| 53 | } ge_cached; |
| 54 | |
| 55 | #define ge_frombytes_negate_vartime crypto_sign_ed25519_ref10_ge_frombytes_negate_vartime |
| 56 | #define ge_tobytes crypto_sign_ed25519_ref10_ge_tobytes |
| 57 | #define ge_p3_tobytes crypto_sign_ed25519_ref10_ge_p3_tobytes |
| 58 | |
| 59 | #define ge_p2_0 crypto_sign_ed25519_ref10_ge_p2_0 |
| 60 | #define ge_p3_0 crypto_sign_ed25519_ref10_ge_p3_0 |
| 61 | #define ge_precomp_0 crypto_sign_ed25519_ref10_ge_precomp_0 |
| 62 | #define ge_p3_to_p2 crypto_sign_ed25519_ref10_ge_p3_to_p2 |
| 63 | #define ge_p3_to_cached crypto_sign_ed25519_ref10_ge_p3_to_cached |
| 64 | #define ge_p1p1_to_p2 crypto_sign_ed25519_ref10_ge_p1p1_to_p2 |
| 65 | #define ge_p1p1_to_p3 crypto_sign_ed25519_ref10_ge_p1p1_to_p3 |
| 66 | #define ge_p2_dbl crypto_sign_ed25519_ref10_ge_p2_dbl |
| 67 | #define ge_p3_dbl crypto_sign_ed25519_ref10_ge_p3_dbl |
| 68 | |
| 69 | #define ge_madd crypto_sign_ed25519_ref10_ge_madd |
| 70 | #define ge_msub crypto_sign_ed25519_ref10_ge_msub |
| 71 | #define ge_add crypto_sign_ed25519_ref10_ge_add |
| 72 | #define ge_sub crypto_sign_ed25519_ref10_ge_sub |
| 73 | #define ge_scalarmult_base crypto_sign_ed25519_ref10_ge_scalarmult_base |
| 74 | #define ge_double_scalarmult_vartime crypto_sign_ed25519_ref10_ge_double_scalarmult_vartime |
| 75 | |
| 76 | #ifdef __cplusplus |
| 77 | extern "C" { |
| 78 | #endif |
| 79 | extern void INTERFACE ge_tobytes(unsigned char *,const ge_p2 *); |
| 80 | extern void INTERFACE ge_p3_tobytes(unsigned char *,const ge_p3 *); |
| 81 | extern int INTERFACE ge_frombytes_negate_vartime(ge_p3 *,const unsigned char *); |
| 82 | |
| 83 | extern void INTERFACE ge_p2_0(ge_p2 *); |
| 84 | extern void INTERFACE ge_p3_0(ge_p3 *); |
| 85 | extern void INTERFACE ge_precomp_0(ge_precomp *); |
| 86 | extern void INTERFACE ge_p3_to_p2(ge_p2 *,const ge_p3 *); |
| 87 | extern void INTERFACE ge_p3_to_cached(ge_cached *,const ge_p3 *); |
| 88 | extern void INTERFACE ge_p1p1_to_p2(ge_p2 *,const ge_p1p1 *); |
| 89 | extern void INTERFACE ge_p1p1_to_p3(ge_p3 *,const ge_p1p1 *); |
| 90 | extern void INTERFACE ge_p2_dbl(ge_p1p1 *,const ge_p2 *); |
| 91 | extern void INTERFACE ge_p3_dbl(ge_p1p1 *,const ge_p3 *); |
| 92 | |
| 93 | extern void INTERFACE ge_madd(ge_p1p1 *,const ge_p3 *,const ge_precomp *); |
| 94 | extern void INTERFACE ge_msub(ge_p1p1 *,const ge_p3 *,const ge_precomp *); |
| 95 | extern void INTERFACE ge_add(ge_p1p1 *,const ge_p3 *,const ge_cached *); |
| 96 | extern void INTERFACE ge_sub(ge_p1p1 *,const ge_p3 *,const ge_cached *); |
| 97 | extern void INTERFACE ge_scalarmult_base(ge_p3 *,const unsigned char *); |
| 98 | extern void INTERFACE ge_double_scalarmult_vartime(ge_p2 *,const unsigned char *,const ge_p3 *,const unsigned char *); |
| 99 | #ifdef __cplusplus |
| 100 | } |
| 101 | #endif |
| 102 | |
| 103 | #endif |