PublicKey.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef __BGN_PUBLICKEY_HPP
  2. #define __BGN_PUBLICKEY_HPP
  3. #include "Scalar.hpp"
  4. #include "Bipoint.hpp"
  5. #include "Quadripoint.hpp"
  6. #include "pairing.hpp"
  7. class BGNPublicKey
  8. {
  9. public:
  10. BGNPublicKey();
  11. BGNPublicKey(const BGNPublicKey& other);
  12. void encrypt(CurveBipoint& G_element, const Scalar& cleartext) const;
  13. void encrypt(TwistBipoint& H_element, const Scalar& cleartext) const;
  14. void encrypt(CurveBipoint& G_element, TwistBipoint& H_element, const Scalar& cleartext) const;
  15. CurveBipoint curveEncrypt(Scalar& lambda, const Scalar& cleartext) const;
  16. TwistBipoint twistEncrypt(Scalar& lambda, const Scalar& cleartext) const;
  17. CurveBipoint homomorphic_addition(const CurveBipoint& a, const CurveBipoint& b) const;
  18. TwistBipoint homomorphic_addition(const TwistBipoint& a, const TwistBipoint& b) const;
  19. Quadripoint homomorphic_addition(const Quadripoint& a, const Quadripoint& b) const;
  20. Quadripoint homomorphic_multiplication(const CurveBipoint& a, const TwistBipoint& b) const;
  21. CurveBipoint homomorphic_addition_no_rerandomize(const CurveBipoint& a, const CurveBipoint& b) const;
  22. TwistBipoint homomorphic_addition_no_rerandomize(const TwistBipoint& a, const TwistBipoint& b) const;
  23. Quadripoint homomorphic_addition_no_rerandomize(const Quadripoint& a, const Quadripoint& b) const;
  24. Quadripoint homomorphic_multiplication_no_rerandomize(const CurveBipoint& a, const TwistBipoint& b) const;
  25. CurveBipoint rerandomize(const CurveBipoint& a) const;
  26. TwistBipoint rerandomize(const TwistBipoint& a) const;
  27. Quadripoint rerandomize(const Quadripoint& a) const;
  28. CurveBipoint rerandomize(Scalar& lambda, const CurveBipoint& a) const;
  29. TwistBipoint rerandomize(Scalar& lambda, const TwistBipoint& a) const;
  30. CurveBipoint get_bipoint_curvegen() const;
  31. TwistBipoint get_bipoint_twistgen() const;
  32. CurveBipoint get_bipoint_curve_subgroup_gen() const;
  33. TwistBipoint get_bipoint_twist_subgroup_gen() const;
  34. friend std::ostream& operator<<(std::ostream& os, const BGNPublicKey& output);
  35. friend std::istream& operator>>(std::istream& is, BGNPublicKey& input);
  36. private:
  37. void set(const CurveBipoint& g, const TwistBipoint& h, const CurveBipoint& g1, const TwistBipoint& h1);
  38. friend class BGN;
  39. CurveBipoint bipoint_curvegen; // g
  40. TwistBipoint bipoint_twistgen; // h
  41. CurveBipoint bipoint_curve_subgroup_gen; // (g^(a1), g^(b1))
  42. TwistBipoint bipoint_twist_subgroup_gen; // (h^(a2), h^(b2))
  43. Quadripoint quadripoint_subgroup_gen_a; // e(g, h1)
  44. Quadripoint quadripoint_subgroup_gen_b; // e(g1, h)
  45. };
  46. #endif