ge.h 1.6 KB

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