fp6e.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * File: dclxvi-20130329/fp6e.h
  3. * Author: Ruben Niederhagen, Peter Schwabe
  4. * Public Domain
  5. */
  6. #ifndef FP6E_H
  7. #define FP6E_H
  8. #include "fp2e.h"
  9. // Elements from F_{p^6}= F_{p^2}[Y] / (Y^3 - xi)F_{p^2}[Y] are represented as aY^2 + bY + c
  10. typedef struct fp6e_struct fp6e_struct_t;
  11. struct fp6e_struct
  12. {
  13. fp2e_t m_a;
  14. fp2e_t m_b;
  15. fp2e_t m_c;
  16. };
  17. typedef fp6e_struct_t fp6e_t[1];
  18. void fp6e_short_coeffred(fp6e_t rop);
  19. // Set fp6e_t rop to given value:
  20. void fp6e_set(fp6e_t rop, const fp6e_t op);
  21. // Initialize an fp6e, set to value given in three fp2es
  22. void fp6e_set_fp2e(fp6e_t rop, const fp2e_t a, const fp2e_t b, const fp2e_t c);
  23. // Initialize an fp6e, set to value given in six strings
  24. void fp6e_set_str(fp6e_t rop, const char *a1, const char *a0, const char *b1, const char *b0, const char *c1, const char *c0);
  25. // Set rop to one:
  26. void fp6e_setone(fp6e_t rop);
  27. // Set rop to zero:
  28. void fp6e_setzero(fp6e_t rop);
  29. // Compare for equality:
  30. int fp6e_iseq(const fp6e_t op1, const fp6e_t op2);
  31. int fp6e_isone(const fp6e_t op);
  32. int fp6e_iszero(const fp6e_t op);
  33. void fp6e_cmov(fp6e_t rop, const fp6e_t op, int c);
  34. // Add two fp6e, store result in rop:
  35. void fp6e_add(fp6e_t rop, const fp6e_t op1, const fp6e_t op2);
  36. // Subtract op2 from op1, store result in rop:
  37. void fp6e_sub(fp6e_t rop, const fp6e_t op1, const fp6e_t op2);
  38. // Negate an fp6e
  39. void fp6e_neg(fp6e_t rop, const fp6e_t op);
  40. // Multiply two fp6e, store result in rop:
  41. void fp6e_mul(fp6e_t rop, const fp6e_t op1, const fp6e_t op2);
  42. // Compute the double of a square of an fp6e, store result in rop:
  43. void fp6e_squaredouble(fp6e_t rop, const fp6e_t op);
  44. // Multiply with tau:
  45. void fp6e_multau(fp6e_t rop, const fp6e_t op);
  46. void fp6e_mul_fpe(fp6e_t rop, const fp6e_t op1, const fpe_t op2);
  47. void fp6e_mul_fp2e(fp6e_t rop, const fp6e_t op1, const fp2e_t op2);
  48. // Multiply an fp6e by a short fp6e, store result in rop:
  49. // the short fp6e is given by 2 fp2e elements op2 = b2*tau + c2.
  50. void fp6e_mul_shortfp6e(fp6e_t rop, const fp6e_t op1, const fp6e_t op2);
  51. void fp6e_invert(fp6e_t rop, const fp6e_t op);
  52. void fp6e_frobenius_p(fp6e_t rop, const fp6e_t op);
  53. void fp6e_frobenius_p2(fp6e_t rop, const fp6e_t op);
  54. // Print the element to stdout:
  55. void fp6e_print(FILE *outfile, const fp6e_t op);
  56. #endif // ifndef FP6E_H