Bipoint.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef __BIPOINT_HPP
  2. #define __BIPOINT_HPP
  3. #include "mydouble.h"
  4. extern "C" {
  5. #include "fpe.h"
  6. }
  7. #include "curvepoint_fp.h"
  8. extern "C" {
  9. #include "fp2e.h"
  10. }
  11. #include "twistpoint_fp2.h"
  12. /* It doesn't actually make sense to instantiate this generally;
  13. * we'll specify for each real type directly.
  14. * We still have to make something here, though, so it's empty. */
  15. template <typename T>
  16. class Bipoint
  17. {};
  18. template <>
  19. class Bipoint<curvepoint_fp_t>
  20. {
  21. public:
  22. Bipoint();
  23. Bipoint(curvepoint_fp_t p1, curvepoint_fp_t p2);
  24. curvepoint_fp_t& operator[](int n);
  25. const curvepoint_fp_t& operator[](int n) const;
  26. Bipoint<curvepoint_fp_t> operator+(const Bipoint<curvepoint_fp_t>& b) const;
  27. Bipoint<curvepoint_fp_t> operator*(const scalar_t& mult) const;
  28. bool operator==(const Bipoint<curvepoint_fp_t>& b) const;
  29. Bipoint<curvepoint_fp_t> multBy2() const;
  30. private:
  31. curvepoint_fp_t point[2];
  32. };
  33. template <>
  34. class Bipoint<twistpoint_fp2_t>
  35. {
  36. public:
  37. Bipoint();
  38. Bipoint(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. Bipoint<twistpoint_fp2_t> operator+(const Bipoint<twistpoint_fp2_t>& b) const;
  42. Bipoint<twistpoint_fp2_t> operator*(const scalar_t& mult) const;
  43. bool operator==(const Bipoint<twistpoint_fp2_t>& b) const;
  44. Bipoint<twistpoint_fp2_t> multBy2() const;
  45. private:
  46. twistpoint_fp2_t point[2];
  47. };
  48. #endif