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