curvepoint_fp.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * File: dclxvi-20130329/curvepoint_fp.h
  3. * Author: Ruben Niederhagen, Peter Schwabe
  4. * Public Domain
  5. */
  6. #ifndef CURVEPOINT_FP_H
  7. #define CURVEPOINT_FP_H
  8. #include <stdio.h>
  9. #include "fpe.h"
  10. #include "scalar.h"
  11. /// Structure describing a point on a BN-curve
  12. typedef struct curvepoint_fp_struct curvepoint_fp_struct_t;
  13. struct curvepoint_fp_struct
  14. {
  15. fpe_t m_x; // X-Coordinate (Jacobian Coordinate system)
  16. fpe_t m_y; // Y-Coordinate (Jacobian Coordinate system)
  17. fpe_t m_z; // Y-Coordinate (Jacobian Coordinate system)
  18. fpe_t m_t; // T = Z^2, only used during pairing computation, set to zero if not set
  19. };
  20. typedef curvepoint_fp_struct_t curvepoint_fp_t[1];
  21. void curvepoint_fp_init(curvepoint_fp_t rop);
  22. void curvepoint_fp_init_set_str(curvepoint_fp_t rop, const char* x,const char* y,const char* z);
  23. void curvepoint_fp_init_set(curvepoint_fp_t rop, const curvepoint_fp_t op);
  24. void curvepoint_fp_init_set_fpe(curvepoint_fp_t rop, const fpe_t opx, const fpe_t opy);
  25. void curvepoint_fp_setneutral(curvepoint_fp_t rop);
  26. // Generate a point on the curve
  27. void curvepoint_fp_set_str(curvepoint_fp_t point, const char* x,const char* y,const char* z);
  28. // Generate a curvepoint_fp_t by copying the coordinates from another curvepoint_fp
  29. void curvepoint_fp_set(curvepoint_fp_t point, const curvepoint_fp_t arg);
  30. void curvepoint_fp_add_vartime(curvepoint_fp_t rop, const curvepoint_fp_t op1, const curvepoint_fp_t op2);
  31. void curvepoint_fp_double(curvepoint_fp_t rop, const curvepoint_fp_t op);
  32. void curvepoint_fp_scalarmult_vartime(curvepoint_fp_t rop, const curvepoint_fp_t op, const scalar_t s);
  33. // Compute the Inverse of a Point op, store result in rop:
  34. void curvepoint_fp_neg(curvepoint_fp_t rop, const curvepoint_fp_t op);
  35. // Transform to Affine Coordinates (z=1)
  36. void curvepoint_fp_makeaffine(curvepoint_fp_t point);
  37. // Print the (Jacobian) coordinates of a point
  38. void curvepoint_fp_print(FILE *outfile, const curvepoint_fp_t point);
  39. #endif // ifdef CURVEPOINT_FP_H