Bipoint.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef __BIPOINT_HPP
  2. #define __BIPOINT_HPP
  3. #include <ostream>
  4. #include <functional>
  5. #include "Scalar.hpp"
  6. #include "print_helpers.hpp"
  7. extern "C" {
  8. #include "curvepoint_fp.h"
  9. #include "twistpoint_fp2.h"
  10. }
  11. class CurveBipoint
  12. {
  13. public:
  14. CurveBipoint();
  15. CurveBipoint(curvepoint_fp_t p1, curvepoint_fp_t p2);
  16. curvepoint_fp_t& operator[](int n);
  17. const curvepoint_fp_t& operator[](int n) const;
  18. CurveBipoint operator+(const CurveBipoint& b) const;
  19. CurveBipoint operator*(const Scalar& mult) const;
  20. bool operator==(const CurveBipoint& b) const;
  21. bool operator!=(const CurveBipoint& b) const;
  22. void make_affine();
  23. friend class CurveBipointHash;
  24. friend std::ostream& operator<<(std::ostream& os, const CurveBipoint& output);
  25. private:
  26. curvepoint_fp_t point[2];
  27. bool equal(const curvepoint_fp_t& op1, const curvepoint_fp_t& op2) const;
  28. };
  29. class CurveBipointHash
  30. {
  31. public:
  32. size_t operator()(const CurveBipoint& x) const;
  33. };
  34. class TwistBipoint
  35. {
  36. public:
  37. TwistBipoint();
  38. TwistBipoint(twistpoint_fp2_t p1, twistpoint_fp2_t p2);
  39. twistpoint_fp2_t& operator[](int n);
  40. const twistpoint_fp2_t& operator[](int n) const;
  41. TwistBipoint operator+(const TwistBipoint& b) const;
  42. TwistBipoint operator*(const Scalar& mult) const;
  43. bool operator==(const TwistBipoint& b) const;
  44. bool operator!=(const TwistBipoint& b) const;
  45. void make_affine();
  46. friend class TwistBipointHash;
  47. friend std::ostream& operator<<(std::ostream& os, const TwistBipoint& output);
  48. private:
  49. twistpoint_fp2_t point[2];
  50. bool equal(const twistpoint_fp2_t& op1, const twistpoint_fp2_t& op2) const;
  51. };
  52. class TwistBipointHash
  53. {
  54. public:
  55. size_t operator()(const TwistBipoint& x) const;
  56. };
  57. #endif