pir_client.hpp 1.1 KB

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