PrivateKey.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef __PRIVATEKEY_HPP
  2. #define __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 PrivateKey
  11. {
  12. public:
  13. Scalar decrypt(const CurveBipoint& ciphertext);
  14. Scalar decrypt(const TwistBipoint& ciphertext);
  15. Scalar decrypt(const Quadripoint & ciphertext);
  16. private:
  17. PrivateKey();
  18. friend class BGN;
  19. void set(const PublicKey& 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);
  20. CurveBipoint pi_1(const CurveBipoint& input) const;
  21. TwistBipoint pi_2(const TwistBipoint& input) const;
  22. Quadripoint pi_T(const Quadripoint & input) const;
  23. Scalar a1, b1, c1, d1, a2, b2, c2, d2;
  24. CurveBipoint pi_1_curvegen;
  25. TwistBipoint pi_2_twistgen;
  26. Quadripoint pi_T_pairgen;
  27. std::unordered_map<CurveBipoint, Scalar, CurveBipointHash> curve_memoizer;
  28. std::unordered_map<TwistBipoint, Scalar, TwistBipointHash> twist_memoizer;
  29. std::unordered_map<Quadripoint, Scalar, QuadripointHash> pair_memoizer;
  30. Scalar curve_max_checked, twist_max_checked, pair_max_checked;
  31. };
  32. #endif