PrivateKey.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef __BGN_PRIVATEKEY_HPP
  2. #define __BGN_PRIVATEKEY_HPP
  3. #include <iostream>
  4. #include <unordered_map>
  5. #include "Scalar.hpp"
  6. #include "Bipoint.hpp"
  7. #include "Quadripoint.hpp"
  8. #include "PublicKey.hpp"
  9. #include "pairing.hpp"
  10. class BGNPrivateKey
  11. {
  12. public:
  13. BGNPrivateKey(const BGNPrivateKey& other);
  14. Scalar decrypt(const CurveBipoint& ciphertext);
  15. Scalar decrypt(const TwistBipoint& ciphertext);
  16. Scalar decrypt(const Quadripoint & ciphertext);
  17. friend std::ostream& operator<<(std::ostream& os, const BGNPrivateKey& output);
  18. friend std::istream& operator>>(std::istream& is, BGNPrivateKey& input);
  19. private:
  20. BGNPrivateKey();
  21. friend class BGN;
  22. void set(const BGNPublicKey& pub_key, const Scalar& a1, const Scalar& b1, const Scalar& c1, const Scalar& d1, const Scalar& a2, const Scalar& b2, const Scalar& c2, const Scalar& d2);
  23. CurveBipoint pi_1(const CurveBipoint& input) const;
  24. TwistBipoint pi_2(const TwistBipoint& input) const;
  25. Quadripoint pi_T(const Quadripoint & input) const;
  26. Scalar a1, b1, c1, d1, a2, b2, c2, d2;
  27. CurveBipoint pi_1_curvegen;
  28. TwistBipoint pi_2_twistgen;
  29. Quadripoint pi_T_pairgen;
  30. std::unordered_map<CurveBipoint, Scalar, CurveBipointHash> curve_memoizer;
  31. std::unordered_map<TwistBipoint, Scalar, TwistBipointHash> twist_memoizer;
  32. std::unordered_map<Quadripoint, Scalar, QuadripointHash> pair_memoizer;
  33. Scalar curve_max_checked, twist_max_checked, pair_max_checked;
  34. };
  35. #endif