Bipoint.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef __BIPOINT_HPP
  2. #define __BIPOINT_HPP
  3. #include "Scalar.hpp"
  4. #include "curvepoint_fp.h"
  5. #include "twistpoint_fp2.h"
  6. /* It doesn't actually make sense to instantiate this generally;
  7. * we'll specify for each real type directly.
  8. * We still have to make something here, though, so it's empty. */
  9. template <typename T>
  10. class Bipoint
  11. {};
  12. template <>
  13. class Bipoint<curvepoint_fp_t>
  14. {
  15. public:
  16. Bipoint();
  17. Bipoint(curvepoint_fp_t p1, curvepoint_fp_t p2);
  18. curvepoint_fp_t& operator[](int n);
  19. const curvepoint_fp_t& operator[](int n) const;
  20. Bipoint<curvepoint_fp_t> operator+(const Bipoint<curvepoint_fp_t>& b) const;
  21. Bipoint<curvepoint_fp_t> operator*(const Scalar& mult) const;
  22. bool operator==(const Bipoint<curvepoint_fp_t>& b) const;
  23. bool operator!=(const Bipoint<curvepoint_fp_t>& b) const;
  24. // "double" is a type, so you can't just name the function that I don't think, but that's all this is
  25. Bipoint<curvepoint_fp_t> mult_by_2() const;
  26. void make_affine();
  27. private:
  28. curvepoint_fp_t point[2];
  29. };
  30. template <>
  31. class Bipoint<twistpoint_fp2_t>
  32. {
  33. public:
  34. Bipoint();
  35. Bipoint(twistpoint_fp2_t p1, twistpoint_fp2_t p2);
  36. twistpoint_fp2_t& operator[](int n);
  37. const twistpoint_fp2_t& operator[](int n) const;
  38. Bipoint<twistpoint_fp2_t> operator+(const Bipoint<twistpoint_fp2_t>& b) const;
  39. Bipoint<twistpoint_fp2_t> operator*(const Scalar& mult) const;
  40. bool operator==(const Bipoint<twistpoint_fp2_t>& b) const;
  41. bool operator!=(const Bipoint<twistpoint_fp2_t>& b) const;
  42. // "double" is a type, so you can't just name the function that I don't think, but that's all this is
  43. Bipoint<twistpoint_fp2_t> mult_by_2() const;
  44. void make_affine();
  45. private:
  46. twistpoint_fp2_t point[2];
  47. };
  48. #endif