1
0

ge.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef GE_H
  2. #define GE_H
  3. /*
  4. ge means group element.
  5. Here the group is the set of pairs (x,y) of field elements (see fe.h)
  6. satisfying -x^2 + y^2 = 1 + d x^2y^2
  7. where d = -121665/121666.
  8. Representations:
  9. ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z
  10. ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT
  11. ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T
  12. ge_precomp (Duif): (y+x,y-x,2dxy)
  13. */
  14. #include "fe.h"
  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. typedef unsigned char bytes32[32];
  44. #define ge_frombytes_negate_vartime CRYPTO_NAMESPACE(ge_frombytes_negate_vartime)
  45. #define ge_tobytes CRYPTO_NAMESPACE(ge_tobytes)
  46. #define ge_p3_tobytes CRYPTO_NAMESPACE(ge_p3_tobytes)
  47. #define ge_p3_batchtobytes_destructive_1 CRYPTO_NAMESPACE(ge_p3_batchtobytes_destructive_1)
  48. #define ge_p3_batchtobytes_destructive_finish CRYPTO_NAMESPACE(ge_p3_batchtobytes_destructive_finish)
  49. #define ge_p2_0 CRYPTO_NAMESPACE(ge_p2_0)
  50. #define ge_p3_0 CRYPTO_NAMESPACE(ge_p3_0)
  51. #define ge_precomp_0 CRYPTO_NAMESPACE(ge_precomp_0)
  52. #define ge_p3_to_p2 CRYPTO_NAMESPACE(ge_p3_to_p2)
  53. #define ge_p3_to_cached CRYPTO_NAMESPACE(ge_p3_to_cached)
  54. #define ge_p1p1_to_p2 CRYPTO_NAMESPACE(ge_p1p1_to_p2)
  55. #define ge_p1p1_to_p3 CRYPTO_NAMESPACE(ge_p1p1_to_p3)
  56. #define ge_p2_dbl CRYPTO_NAMESPACE(ge_p2_dbl)
  57. #define ge_p3_dbl CRYPTO_NAMESPACE(ge_p3_dbl)
  58. #define ge_madd CRYPTO_NAMESPACE(ge_madd)
  59. #define ge_msub CRYPTO_NAMESPACE(ge_msub)
  60. #define ge_add CRYPTO_NAMESPACE(ge_add)
  61. #define ge_sub CRYPTO_NAMESPACE(ge_sub)
  62. #define ge_scalarmult_base CRYPTO_NAMESPACE(ge_scalarmult_base)
  63. #define ge_double_scalarmult_vartime CRYPTO_NAMESPACE(ge_double_scalarmult_vartime)
  64. extern void ge_tobytes(unsigned char *,const ge_p2 *);
  65. extern void ge_p3_tobytes(unsigned char *,const ge_p3 *);
  66. extern void ge_p3_batchtobytes_destructive_1(bytes32 *out,ge_p3 *in,fe *tmp,size_t num);
  67. extern void ge_p3_batchtobytes_destructive_finish(bytes32 out,ge_p3 *unf);
  68. extern int ge_frombytes_negate_vartime(ge_p3 *,const unsigned char *);
  69. extern void ge_p2_0(ge_p2 *);
  70. extern void ge_p3_0(ge_p3 *);
  71. extern void ge_precomp_0(ge_precomp *);
  72. extern void ge_p3_to_p2(ge_p2 *,const ge_p3 *);
  73. extern void ge_p3_to_cached(ge_cached *,const ge_p3 *);
  74. extern void ge_p1p1_to_p2(ge_p2 *,const ge_p1p1 *);
  75. extern void ge_p1p1_to_p3(ge_p3 *,const ge_p1p1 *);
  76. extern void ge_p2_dbl(ge_p1p1 *,const ge_p2 *);
  77. extern void ge_p3_dbl(ge_p1p1 *,const ge_p3 *);
  78. extern void ge_madd(ge_p1p1 *,const ge_p3 *,const ge_precomp *);
  79. extern void ge_msub(ge_p1p1 *,const ge_p3 *,const ge_precomp *);
  80. extern void ge_add(ge_p1p1 *,const ge_p3 *,const ge_cached *);
  81. extern void ge_sub(ge_p1p1 *,const ge_p3 *,const ge_cached *);
  82. extern void ge_scalarmult_base(ge_p3 *,const unsigned char *);
  83. extern void ge_double_scalarmult_vartime(ge_p2 *,const unsigned char *,const ge_p3 *,const unsigned char *);
  84. #endif