You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.3 KiB

  1. #ifndef __FR_H
  2. #define __FR_H
  3. #include <stdint.h>
  4. #define Fr_N64 4
  5. #define Fr_SHORT 0x00000000
  6. #define Fr_LONG 0x80000000
  7. #define Fr_LONGMONTGOMERY 0xC0000000
  8. typedef struct __attribute__((__packed__)) {
  9. int32_t shortVal;
  10. u_int32_t type;
  11. u_int64_t longVal[Fr_N64];
  12. } FrElement;
  13. typedef FrElement *PFrElement;
  14. extern FrElement Fr_q;
  15. extern "C" void Fr_copy(PFrElement r, PFrElement a);
  16. extern "C" void Fr_copyn(PFrElement r, PFrElement a, int n);
  17. extern "C" void Fr_add(PFrElement r, PFrElement a, PFrElement b);
  18. extern "C" void Fr_sub(PFrElement r, PFrElement a, PFrElement b);
  19. extern "C" void Fr_neg(PFrElement r, PFrElement a);
  20. extern "C" void Fr_mul(PFrElement r, PFrElement a, PFrElement b);
  21. extern "C" void Fr_square(PFrElement r, PFrElement a);
  22. extern "C" void Fr_band(PFrElement r, PFrElement a, PFrElement b);
  23. extern "C" void Fr_bor(PFrElement r, PFrElement a, PFrElement b);
  24. extern "C" void Fr_bxor(PFrElement r, PFrElement a, PFrElement b);
  25. extern "C" void Fr_bnot(PFrElement r, PFrElement a);
  26. extern "C" void Fr_eq(PFrElement r, PFrElement a, PFrElement b);
  27. extern "C" void Fr_neq(PFrElement r, PFrElement a, PFrElement b);
  28. extern "C" void Fr_lt(PFrElement r, PFrElement a, PFrElement b);
  29. extern "C" void Fr_gt(PFrElement r, PFrElement a, PFrElement b);
  30. extern "C" void Fr_leq(PFrElement r, PFrElement a, PFrElement b);
  31. extern "C" void Fr_geq(PFrElement r, PFrElement a, PFrElement b);
  32. extern "C" void Fr_land(PFrElement r, PFrElement a, PFrElement b);
  33. extern "C" void Fr_lor(PFrElement r, PFrElement a, PFrElement b);
  34. extern "C" void Fr_lnot(PFrElement r, PFrElement a);
  35. extern "C" void Fr_toNormal(PFrElement pE);
  36. extern "C" void Fr_toLongNormal(PFrElement pE);
  37. extern "C" void Fr_toMontgomery(PFrElement pE);
  38. void Fr_str2element(PFrElement pE, char const*s);
  39. char *Fr_element2str(PFrElement pE);
  40. void Fr_idiv(PFrElement r, PFrElement a, PFrElement b);
  41. void Fr_mod(PFrElement r, PFrElement a, PFrElement b);
  42. void Fr_inv(PFrElement r, PFrElement a);
  43. void Fr_div(PFrElement r, PFrElement a, PFrElement b);
  44. void Fr_shl(PFrElement r, PFrElement a, PFrElement b);
  45. void Fr_shr(PFrElement r, PFrElement a, PFrElement b);
  46. void Fr_pow(PFrElement r, PFrElement a, PFrElement b);
  47. int Fr_isTrue(PFrElement pE);
  48. int Fr_toInt(PFrElement pE);
  49. void Fr_init();
  50. extern FrElement Fr_q;
  51. #endif // __FR_H