curvepoint_fp.h 2.0 KB

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