Bipoint.hpp 2.0 KB

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