pir_client.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "pir.hpp"
  3. #include <memory>
  4. #include <vector>
  5. using namespace std;
  6. class PIRClient {
  7. public:
  8. PIRClient(const seal::EncryptionParameters &parms,
  9. const PirParams &pirparms);
  10. //void update_parameters(const seal::EncryptionParameters &expandedParams,
  11. // const PirParams &pirparms);
  12. PirQuery generate_query(std::uint64_t desiredIndex);
  13. seal::Plaintext decode_reply(PirReply reply);
  14. seal::GaloisKeys generate_galois_keys();
  15. // Index and offset of an element in an FV plaintext
  16. uint64_t get_fv_index(uint64_t element_idx, uint64_t ele_size);
  17. uint64_t get_fv_offset(uint64_t element_idx, uint64_t ele_size);
  18. void compute_inverse_scales();
  19. private:
  20. // Should we store a decryptor and an encryptor?
  21. seal::EncryptionParameters params_;
  22. PirParams pir_params_;
  23. std::unique_ptr<seal::Encryptor> encryptor_;
  24. std::unique_ptr<seal::Decryptor> decryptor_;
  25. std::unique_ptr<seal::Evaluator> evaluator_;
  26. std::unique_ptr<seal::KeyGenerator> keygen_;
  27. std::shared_ptr<seal::SEALContext> newcontext_;
  28. vector<uint64_t> indices_; // the indices for retrieval.
  29. vector<uint64_t> inverse_scales_;
  30. seal::Ciphertext compose_to_ciphertext(std::vector<seal::Plaintext> plains);
  31. friend class PIRServer;
  32. };