PrivateKey.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. private:
  18. BGNPrivateKey();
  19. friend class BGN;
  20. 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);
  21. CurveBipoint pi_1(const CurveBipoint& input) const;
  22. TwistBipoint pi_2(const TwistBipoint& input) const;
  23. Quadripoint pi_T(const Quadripoint & input) const;
  24. Scalar a1, b1, c1, d1, a2, b2, c2, d2;
  25. CurveBipoint pi_1_curvegen;
  26. TwistBipoint pi_2_twistgen;
  27. Quadripoint pi_T_pairgen;
  28. std::unordered_map<CurveBipoint, Scalar, CurveBipointHash> curve_memoizer;
  29. std::unordered_map<TwistBipoint, Scalar, TwistBipointHash> twist_memoizer;
  30. std::unordered_map<Quadripoint, Scalar, QuadripointHash> pair_memoizer;
  31. Scalar curve_max_checked, twist_max_checked, pair_max_checked;
  32. };
  33. #endif