Bipoint.hpp 1.6 KB

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