Bipoint.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. friend std::istream& operator>>(std::istream& is, CurveBipoint& input);
  26. private:
  27. curvepoint_fp_t point[2];
  28. bool equal(const curvepoint_fp_t& op1, const curvepoint_fp_t& op2) const;
  29. };
  30. class CurveBipointHash
  31. {
  32. public:
  33. size_t operator()(const CurveBipoint& x) const;
  34. };
  35. class TwistBipoint
  36. {
  37. public:
  38. TwistBipoint();
  39. TwistBipoint(twistpoint_fp2_t p1, twistpoint_fp2_t p2);
  40. twistpoint_fp2_t& operator[](int n);
  41. const twistpoint_fp2_t& operator[](int n) const;
  42. TwistBipoint operator+(const TwistBipoint& b) const;
  43. TwistBipoint operator*(const Scalar& mult) const;
  44. bool operator==(const TwistBipoint& b) const;
  45. bool operator!=(const TwistBipoint& b) const;
  46. void make_affine();
  47. friend class TwistBipointHash;
  48. friend std::ostream& operator<<(std::ostream& os, const TwistBipoint& output);
  49. friend std::istream& operator>>(std::istream& is, TwistBipoint& input);
  50. private:
  51. twistpoint_fp2_t point[2];
  52. bool equal(const twistpoint_fp2_t& op1, const twistpoint_fp2_t& op2) const;
  53. };
  54. class TwistBipointHash
  55. {
  56. public:
  57. size_t operator()(const TwistBipoint& x) const;
  58. };
  59. #endif