Browse Source

removed expanded params.
Now should check the encode->decode and pir parts separately,
after adding scaling.

hao chen 5 years ago
parent
commit
45157efc6e
7 changed files with 95 additions and 111 deletions
  1. 9 15
      main.cpp
  2. 5 11
      pir.cpp
  3. 2 3
      pir.hpp
  4. 28 32
      pir_client.cpp
  5. 3 4
      pir_client.hpp
  6. 42 42
      pir_server.cpp
  7. 6 4
      pir_server.hpp

+ 9 - 15
main.cpp

@@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
 
     // uint64_t number_of_items = 1 << 13;
     // uint64_t number_of_items = 4096;
-     uint64_t number_of_items = 1 << 16;
+    uint64_t number_of_items = 1 << 16;
 
     uint64_t size_per_item = 288; // in bytes
     // uint64_t size_per_item = 1 << 10; // 1 KB.
@@ -24,15 +24,14 @@ int main(int argc, char *argv[]) {
 
     uint32_t N = 2048;
     uint32_t logt = 20;
-    uint32_t d = 2;
+    uint32_t d = 1;
 
     EncryptionParameters params(scheme_type::BFV);
-    EncryptionParameters expanded_params(scheme_type::BFV);
     PirParams pir_params;
 
     // Generates all parameters
     cout << "Generating all parameters" << endl;
-    gen_params(number_of_items, size_per_item, N, logt, d, params, expanded_params, pir_params);
+    gen_params(number_of_items, size_per_item, N, logt, d, params, pir_params);
 
     // Create test database
     auto db(make_unique<uint8_t[]>(number_of_items * size_per_item));
@@ -51,10 +50,10 @@ int main(int argc, char *argv[]) {
 
     // Initialize PIR Server
     cout << "Initializing server and client" << endl;
-    PIRServer server(expanded_params, pir_params);
+    PIRServer server(params, pir_params);
 
     // Initialize PIR client....
-    PIRClient client(params, expanded_params, pir_params);
+    PIRClient client(params, pir_params);
     GaloisKeys galois_keys = client.generate_galois_keys();
 
     // Set galois key
@@ -65,14 +64,9 @@ int main(int argc, char *argv[]) {
     // The following can be used to update parameters rather than creating new instances
     // (here it doesn't do anything).
     cout << "Updating database size to: " << number_of_items << " elements" << endl;
-    update_params(number_of_items, size_per_item, d, params, expanded_params, pir_params);
+    // update_params(number_of_items, size_per_item, d, params, expanded_params, pir_params);
 
-    uint32_t logtp = ceil(log2(expanded_params.plain_modulus().value()));
 
-    cout << "logtp: " << logtp << endl;
-
-    client.update_parameters(expanded_params, pir_params);
-    server.update_parameters(expanded_params, pir_params);
 
     // Measure database setup
     auto time_pre_s = high_resolution_clock::now();
@@ -106,14 +100,14 @@ int main(int argc, char *argv[]) {
     auto time_decode_us = duration_cast<microseconds>(time_decode_e - time_decode_s).count();
 
     // Convert to elements
-    vector<uint8_t> elems(N * logtp / 8);
-    coeffs_to_bytes(logtp, result, elems.data(), (N * logtp) / 8);
+    vector<uint8_t> elems(N * logt / 8);
+    coeffs_to_bytes(logt, result, elems.data(), (N * logt) / 8);
 
     // Check that we retrieved the correct element
     for (uint32_t i = 0; i < size_per_item; i++) {
         if (elems[(offset * size_per_item) + i] != check_db.get()[(ele_index * size_per_item) + i]) {
             cout << "elems " << (int)elems[(offset * size_per_item) + i] << ", db "
-                 << check_db.get()[(ele_index * size_per_item) + i] << endl;
+                 << (int) check_db.get()[(ele_index * size_per_item) + i] << endl;
             cout << "PIR result wrong!" << endl;
             return -1;
         }

+ 5 - 11
pir.cpp

@@ -33,19 +33,17 @@ vector<uint64_t> get_dimensions(uint64_t plaintext_num, uint32_t d) {
 }
 
 void gen_params(uint64_t ele_num, uint64_t ele_size, uint32_t N, uint32_t logt,
-                uint32_t d, EncryptionParameters &params, EncryptionParameters &expanded_params,
+                uint32_t d, EncryptionParameters &params,
                 PirParams &pir_params) {
     
     // Determine the maximum size of each dimension
-    uint32_t logtp = plainmod_after_expansion(logt, N, d, ele_num, ele_size);
 
-    uint64_t plain_mod = static_cast<uint64_t>(1) << logt;
-    uint64_t expanded_plain_mod = static_cast<uint64_t>(1) << logtp;
-    uint64_t plaintext_num = plaintexts_per_db(logtp, N, ele_num, ele_size);
+    // plain modulus = a power of 2 plus 1
+    uint64_t plain_mod = (static_cast<uint64_t>(1) << logt) + 1;
+    uint64_t plaintext_num = plaintexts_per_db(logt, N, ele_num, ele_size);
 
 #ifdef DEBUG
     cout << "log(plain mod) before expand = " << logt << endl;
-    cout << "log(plain mod) after expand = " << logtp << endl;
     cout << "number of FV plaintexts = " << plaintext_num << endl;
 #endif
 
@@ -62,16 +60,12 @@ void gen_params(uint64_t ele_num, uint64_t ele_size, uint32_t N, uint32_t logt,
     params.set_coeff_modulus(coeff_mod_array);
     params.set_plain_modulus(plain_mod);
 
-    expanded_params.set_poly_modulus_degree(N);
-    expanded_params.set_coeff_modulus(coeff_mod_array);
-    expanded_params.set_plain_modulus(expanded_plain_mod);
-
     vector<uint64_t> nvec = get_dimensions(plaintext_num, d);
 
     uint32_t expansion_ratio = 0;
     for (uint32_t i = 0; i < params.coeff_modulus().size(); ++i) {
         double logqi = log2(params.coeff_modulus()[i].value());
-        expansion_ratio += ceil(logqi / logtp);
+        expansion_ratio += ceil(logqi / logt);
     }
 
     pir_params.d = d;

+ 2 - 3
pir.hpp

@@ -26,14 +26,13 @@ void gen_params(std::uint64_t ele_num,  // number of elements (not FV plaintexts
                 std::uint32_t N,        // degree of polynomial
                 std::uint32_t logt,     // bits of plaintext coefficient
                 std::uint32_t d,        // dimension of database
-                seal::EncryptionParameters &params, seal::EncryptionParameters &expanded_params,
+                seal::EncryptionParameters &params,
                 PirParams &pir_params);
 
 void update_params(std::uint64_t ele_num, 
                    std::uint64_t ele_size,
                    std::uint32_t d,
-                   const seal::EncryptionParameters &old_params,
-                   seal::EncryptionParameters &expanded_params, PirParams &pir_params);
+                   const seal::EncryptionParameters &old_params, PirParams &pir_params);
 
 // returns the plaintext modulus after expansion
 std::uint32_t plainmod_after_expansion(std::uint32_t logt, std::uint32_t N, 

+ 28 - 32
pir_client.cpp

@@ -5,57 +5,53 @@ using namespace seal;
 using namespace seal::util;
 
 PIRClient::PIRClient(const EncryptionParameters &params,
-                     const EncryptionParameters &expanded_params, 
                      const PirParams &pir_parms) :
-    params_(params),
-    expanded_params_(expanded_params) {
+    params_(params){
 
-    auto context = SEALContext::Create(params_);
-    newcontext_ = SEALContext::Create(expanded_params_);
+    newcontext_ = SEALContext::Create(params_);
 
     pir_params_ = pir_parms;
 
-    keygen_ = make_unique<KeyGenerator>(context);
-    encryptor_ = make_unique<Encryptor>(context, keygen_->public_key());
+    keygen_ = make_unique<KeyGenerator>(newcontext_);
+    encryptor_ = make_unique<Encryptor>(newcontext_, keygen_->public_key());
 
     SecretKey secret_key = keygen_->secret_key();
-    secret_key.parms_id() = expanded_params.parms_id();
 
     decryptor_ = make_unique<Decryptor>(newcontext_, secret_key);
     evaluator_ = make_unique<Evaluator>(newcontext_);
 }
 
-void PIRClient::update_parameters(const EncryptionParameters &expanded_params,
-                                  const PirParams &pir_params) 
-{
+// void PIRClient::update_parameters(const EncryptionParameters &expanded_params,
+//                                   const PirParams &pir_params) 
+// {
 
-    // The only thing that can change is the plaintext modulus and pir_params
-    assert(expanded_params.poly_modulus_degree() == expanded_params_.poly_modulus_degree());
-    assert(expanded_params.coeff_modulus() == expanded_params_.coeff_modulus());
+//     // The only thing that can change is the plaintext modulus and pir_params
+//     assert(expanded_params.poly_modulus_degree() == params_.poly_modulus_degree());
+//     assert(expanded_params.coeff_modulus() == params_.coeff_modulus());
 
-    expanded_params_ = expanded_params;
-    pir_params_ = pir_params;
-    auto newcontext = SEALContext::Create(expanded_params);
+//     params_ = expanded_params;
+//     pir_params_ = pir_params;
+//     auto newcontext = SEALContext::Create(expanded_params);
 
-    SecretKey secret_key = keygen_->secret_key();
-    secret_key.parms_id() = expanded_params.parms_id();
+//     SecretKey secret_key = keygen_->secret_key();
+//     secret_key.parms_id() = expanded_params.parms_id();
 
-    decryptor_ = make_unique<Decryptor>(newcontext, secret_key);
-    evaluator_ = make_unique<Evaluator>(newcontext);
-}
+//     decryptor_ = make_unique<Decryptor>(newcontext, secret_key);
+//     evaluator_ = make_unique<Evaluator>(newcontext);
+// }
 
 PirQuery PIRClient::generate_query(uint64_t desiredIndex) {
 
     vector<uint64_t> indices = compute_indices(desiredIndex, pir_params_.nvec);
     vector<Ciphertext> result;
 
-    Plaintext pt(expanded_params_.poly_modulus_degree());
+    Plaintext pt(params_.poly_modulus_degree());
     for (uint32_t i = 0; i < indices.size(); i++) {
         pt.set_zero();
         pt[indices[i]] = 1;
         Ciphertext dest;
         encryptor_->encrypt(pt, dest);
-        dest.parms_id() = expanded_params_.parms_id();
+        dest.parms_id() = params_.parms_id();
         result.push_back(dest);
     }
 
@@ -64,7 +60,7 @@ PirQuery PIRClient::generate_query(uint64_t desiredIndex) {
 
 uint64_t PIRClient::get_fv_index(uint64_t element_idx, uint64_t ele_size) {
     auto N = params_.poly_modulus_degree();
-    auto logtp = ceil(log2(expanded_params_.plain_modulus().value()));
+    auto logtp = ceil(log2(params_.plain_modulus().value()));
 
     auto ele_per_ptxt = elements_per_ptxt(logtp, N, ele_size);
     return static_cast<uint64_t>(element_idx / ele_per_ptxt);
@@ -72,7 +68,7 @@ uint64_t PIRClient::get_fv_index(uint64_t element_idx, uint64_t ele_size) {
 
 uint64_t PIRClient::get_fv_offset(uint64_t element_idx, uint64_t ele_size) {
     uint32_t N = params_.poly_modulus_degree();
-    uint32_t logtp = ceil(log2(expanded_params_.plain_modulus().value()));
+    uint32_t logtp = ceil(log2(params_.plain_modulus().value()));
 
     uint64_t ele_per_ptxt = elements_per_ptxt(logtp, N, ele_size);
     return element_idx % ele_per_ptxt;
@@ -139,9 +135,9 @@ GaloisKeys PIRClient::generate_galois_keys() {
 
 Ciphertext PIRClient::compose_to_ciphertext(vector<Plaintext> plains) {
     size_t encrypted_count = 2;
-    auto coeff_count = expanded_params_.poly_modulus_degree();
-    auto coeff_mod_count = expanded_params_.coeff_modulus().size();
-    uint64_t plainMod = expanded_params_.plain_modulus().value();
+    auto coeff_count = params_.poly_modulus_degree();
+    auto coeff_mod_count = params_.coeff_modulus().size();
+    uint64_t plainMod = params_.plain_modulus().value();
 
     Ciphertext result(newcontext_);
     result.resize(encrypted_count);
@@ -155,7 +151,7 @@ Ciphertext PIRClient::compose_to_ciphertext(vector<Plaintext> plains) {
             // create a polynomial to store the current decomposition value
             // which will be copied into the array to populate it at the current
             // index.
-            double logqj = log2(expanded_params_.coeff_modulus()[j].value());
+            double logqj = log2(params_.coeff_modulus()[j].value());
             int expansion_ratio = ceil(logqj / log2(plainMod));
 
             // cout << "expansion ratio = " << expansion_ratio << endl;
@@ -184,12 +180,12 @@ Ciphertext PIRClient::compose_to_ciphertext(vector<Plaintext> plains) {
             /*
             for (int m = 0; m < coeff_count; m++) {
                 *(encrypted_pointer + m + j * coeff_count) %=
-                    expanded_params_.coeff_modulus()[j].value();
+                    params_.coeff_modulus()[j].value();
             }
             */
         }
     }
 
-    result.parms_id() = expanded_params_.parms_id();
+    result.parms_id() = params_.parms_id();
     return result;
 }

+ 3 - 4
pir_client.hpp

@@ -6,10 +6,10 @@
 class PIRClient {
   public:
     PIRClient(const seal::EncryptionParameters &parms,
-              const seal::EncryptionParameters &expandedParams, const PirParams &pirparms);
+               const PirParams &pirparms);
 
-    void update_parameters(const seal::EncryptionParameters &expandedParams,
-                           const PirParams &pirparms);
+    //void update_parameters(const seal::EncryptionParameters &expandedParams,
+    //                       const PirParams &pirparms);
 
     PirQuery generate_query(std::uint64_t desiredIndex);
     seal::Plaintext decode_reply(PirReply reply);
@@ -23,7 +23,6 @@ class PIRClient {
   private:
     // Should we store a decryptor and an encryptor?
     seal::EncryptionParameters params_;
-    seal::EncryptionParameters expanded_params_;
     PirParams pir_params_;
 
     std::unique_ptr<seal::Encryptor> encryptor_;

+ 42 - 42
pir_server.cpp

@@ -4,40 +4,40 @@ using namespace std;
 using namespace seal;
 using namespace seal::util;
 
-PIRServer::PIRServer(const EncryptionParameters &expanded_params, const PirParams &pir_params) :
-    expanded_params_(expanded_params), 
+PIRServer::PIRServer(const EncryptionParameters &params, const PirParams &pir_params) :
+    params_(params), 
     pir_params_(pir_params),
     is_db_preprocessed_(false)
 {
-    auto context = SEALContext::Create(expanded_params, false);
+    auto context = SEALContext::Create(params, false);
     evaluator_ = make_unique<Evaluator>(context);
 }
 
-void PIRServer::update_parameters(const EncryptionParameters &expanded_params,
-                                  const PirParams &pir_params) {
+// void PIRServer::update_parameters(const EncryptionParameters &expanded_params,
+//                                   const PirParams &pir_params) {
 
-    // The only thing that can change is the plaintext modulus and pir_params
-    assert(expanded_params.poly_modulus_degree() == expanded_params_.poly_modulus_degree());
-    assert(expanded_params.coeff_modulus() == expanded_params_.coeff_modulus());
+//     // The only thing that can change is the plaintext modulus and pir_params
+//     assert(expanded_params.poly_modulus_degree() == params_.poly_modulus_degree());
+//     assert(expanded_params.coeff_modulus() == params_.coeff_modulus());
 
-    expanded_params_ = expanded_params;
-    pir_params_ = pir_params;
-    auto context = SEALContext::Create(expanded_params);
-    evaluator_ = make_unique<Evaluator>(context);
-    is_db_preprocessed_ = false;
+//     params_ = expanded_params;
+//     pir_params_ = pir_params;
+//     auto context = SEALContext::Create(expanded_params);
+//     evaluator_ = make_unique<Evaluator>(context);
+//     is_db_preprocessed_ = false;
 
-    // Update all the galois keys
-    for (std::pair<const int, GaloisKeys> &key : galoisKeys_) {
-        key.second.parms_id() = expanded_params_.parms_id();
-    }
-}
+//     // Update all the galois keys
+//     for (std::pair<const int, GaloisKeys> &key : galoisKeys_) {
+//         key.second.parms_id() = params_.parms_id();
+//     }
+// }
 
 void PIRServer::preprocess_database() {
     if (!is_db_preprocessed_) {
 
         for (uint32_t i = 0; i < db_->size(); i++) {
             evaluator_->transform_to_ntt_inplace(
-                db_->operator[](i), expanded_params_.parms_id());
+                db_->operator[](i), params_.parms_id());
         }
 
         is_db_preprocessed_ = true;
@@ -57,11 +57,11 @@ void PIRServer::set_database(unique_ptr<vector<Plaintext>> &&db) {
 void PIRServer::set_database(const std::unique_ptr<const std::uint8_t[]> &bytes, 
     uint64_t ele_num, uint64_t ele_size) {
 
-    uint32_t logtp = ceil(log2(expanded_params_.plain_modulus().value()));
-    uint32_t N = expanded_params_.poly_modulus_degree();
+    uint32_t logt = floor(log2(params_.plain_modulus().value()));
+    uint32_t N = params_.poly_modulus_degree();
 
     // number of FV plaintexts needed to represent all elements
-    uint64_t total = plaintexts_per_db(logtp, N, ele_num, ele_size);
+    uint64_t total = plaintexts_per_db(logt, N, ele_num, ele_size);
 
     // number of FV plaintexts needed to create the d-dimensional matrix
     uint64_t prod = 1;
@@ -74,12 +74,12 @@ void PIRServer::set_database(const std::unique_ptr<const std::uint8_t[]> &bytes,
     auto result = make_unique<vector<Plaintext>>();
     result->reserve(matrix_plaintexts);
 
-    uint64_t ele_per_ptxt = elements_per_ptxt(logtp, N, ele_size);
+    uint64_t ele_per_ptxt = elements_per_ptxt(logt, N, ele_size);
     uint64_t bytes_per_ptxt = ele_per_ptxt * ele_size;
 
     uint64_t db_size = ele_num * ele_size;
 
-    uint64_t coeff_per_ptxt = ele_per_ptxt * coefficients_per_element(logtp, ele_size);
+    uint64_t coeff_per_ptxt = ele_per_ptxt * coefficients_per_element(logt, ele_size);
     assert(coeff_per_ptxt <= N);
 
     uint32_t offset = 0;
@@ -97,7 +97,7 @@ void PIRServer::set_database(const std::unique_ptr<const std::uint8_t[]> &bytes,
         }
 
         // Get the coefficients of the elements that will be packed in plaintext i
-        vector<uint64_t> coefficients = bytes_to_coeffs(logtp, bytes.get() + offset, process_bytes);
+        vector<uint64_t> coefficients = bytes_to_coeffs(logt, bytes.get() + offset, process_bytes);
         offset += process_bytes;
 
         uint64_t used = coefficients.size();
@@ -137,7 +137,7 @@ void PIRServer::set_database(const std::unique_ptr<const std::uint8_t[]> &bytes,
 }
 
 void PIRServer::set_galois_key(std::uint32_t client_id, seal::GaloisKeys galkey) {
-    galkey.parms_id() = expanded_params_.parms_id();
+    galkey.parms_id() = params_.parms_id();
     galoisKeys_[client_id] = galkey;
 }
 
@@ -150,7 +150,7 @@ PirReply PIRServer::generate_reply(PirQuery query, uint32_t client_id) {
         product *= nvec[i];
     }
 
-    auto coeff_count = expanded_params_.poly_modulus_degree();
+    auto coeff_count = params_.poly_modulus_degree();
 
     vector<Plaintext> *cur = db_.get();
     vector<Plaintext> intermediate_plain; // decompose....
@@ -169,7 +169,7 @@ PirReply PIRServer::generate_reply(PirQuery query, uint32_t client_id) {
         // Transform plaintext to NTT. If database is pre-processed, can skip
         if ((!is_db_preprocessed_) || i > 0) {
             for (uint32_t jj = 0; jj < cur->size(); jj++) {
-                evaluator_->transform_to_ntt_inplace((*cur)[jj], expanded_params_.parms_id());
+                evaluator_->transform_to_ntt_inplace((*cur)[jj], params_.parms_id());
             }
         }
 
@@ -227,7 +227,7 @@ inline vector<Ciphertext> PIRServer::expand_query(const Ciphertext &encrypted, u
                                            uint32_t client_id) {
 
 #ifdef DEBUG
-    uint64_t plainMod = expanded_params_.plain_modulus().value();
+    uint64_t plainMod = params_.plain_modulus().value();
     cout << "PIRServer side plain modulus = " << plainMod << endl;
 #endif
 
@@ -238,7 +238,7 @@ inline vector<Ciphertext> PIRServer::expand_query(const Ciphertext &encrypted, u
     Plaintext two("2");
 
     vector<int> galois_elts;
-    auto n = expanded_params_.poly_modulus_degree();
+    auto n = params_.poly_modulus_degree();
 
     for (uint32_t i = 0; i < logm; i++) {
         galois_elts.push_back((n + exponentiate_uint64(2, i)) / exponentiate_uint64(2, i));
@@ -295,8 +295,8 @@ inline vector<Ciphertext> PIRServer::expand_query(const Ciphertext &encrypted, u
 inline void PIRServer::multiply_power_of_X(const Ciphertext &encrypted, Ciphertext &destination,
                                     uint32_t index) {
 
-    auto coeff_mod_count = expanded_params_.coeff_modulus().size();
-    auto coeff_count = expanded_params_.poly_modulus_degree();
+    auto coeff_mod_count = params_.coeff_modulus().size();
+    auto coeff_count = params_.poly_modulus_degree();
     auto encrypted_count = encrypted.size();
 
     // First copy over.
@@ -308,7 +308,7 @@ inline void PIRServer::multiply_power_of_X(const Ciphertext &encrypted, Cipherte
         for (int j = 0; j < coeff_mod_count; j++) {
             negacyclic_shift_poly_coeffmod(encrypted.data(i) + (j * coeff_count),
                                            coeff_count - 1, index,
-                                           expanded_params_.coeff_modulus()[j],
+                                           params_.coeff_modulus()[j],
                                            destination.data(i) + (j * coeff_count));
         }
     }
@@ -317,12 +317,12 @@ inline void PIRServer::multiply_power_of_X(const Ciphertext &encrypted, Cipherte
 inline void PIRServer::decompose_to_plaintexts_ptr(const Ciphertext &encrypted, Plaintext *plain_ptr) {
 
     vector<Plaintext> result;
-    auto coeff_count = expanded_params_.poly_modulus_degree();
-    auto coeff_mod_count = expanded_params_.coeff_modulus().size();
+    auto coeff_count = params_.poly_modulus_degree();
+    auto coeff_mod_count = params_.coeff_modulus().size();
     auto encrypted_count = encrypted.size();
 
     // Generate powers of t.
-    uint64_t plainModMinusOne = expanded_params_.plain_modulus().value() - 1;
+    uint64_t plainModMinusOne = params_.plain_modulus().value() - 1;
     int exp = ceil(log2(plainModMinusOne + 1));
 
     // A triple for loop. Going over polys, moduli, and decomposed index.
@@ -334,7 +334,7 @@ inline void PIRServer::decompose_to_plaintexts_ptr(const Ciphertext &encrypted,
             // create a polynomial to store the current decomposition value
             // which will be copied into the array to populate it at the current
             // index.
-            int logqj = log2(expanded_params_.coeff_modulus()[j].value());
+            int logqj = log2(params_.coeff_modulus()[j].value());
             int expansion_ratio = ceil(logqj + exp - 1) / exp;
 
             // cout << "expansion ratio = " << expansion_ratio << endl;
@@ -354,13 +354,13 @@ inline void PIRServer::decompose_to_plaintexts_ptr(const Ciphertext &encrypted,
 
 vector<Plaintext> PIRServer::decompose_to_plaintexts(const Ciphertext &encrypted) {
     vector<Plaintext> result;
-    auto coeff_count = expanded_params_.poly_modulus_degree();
-    auto coeff_mod_count = expanded_params_.coeff_modulus().size();
-    auto plain_bit_count = expanded_params_.plain_modulus().bit_count();
+    auto coeff_count = params_.poly_modulus_degree();
+    auto coeff_mod_count = params_.coeff_modulus().size();
+    auto plain_bit_count = params_.plain_modulus().bit_count();
     auto encrypted_count = encrypted.size();
 
     // Generate powers of t.
-    uint64_t plainMod = expanded_params_.plain_modulus().value();
+    uint64_t plainMod = params_.plain_modulus().value();
 
     // A triple for loop. Going over polys, moduli, and decomposed index.
     for (int i = 0; i < encrypted_count; i++) {
@@ -370,7 +370,7 @@ vector<Plaintext> PIRServer::decompose_to_plaintexts(const Ciphertext &encrypted
             // create a polynomial to store the current decomposition value
             // which will be copied into the array to populate it at the current
             // index.
-            int logqj = log2(expanded_params_.coeff_modulus()[j].value());
+            int logqj = log2(params_.coeff_modulus()[j].value());
             int expansion_ratio = ceil(logqj / log2(plainMod));
 
             // cout << "expansion ratio = " << expansion_ratio << endl;

+ 6 - 4
pir_server.hpp

@@ -7,10 +7,10 @@
 
 class PIRServer {
   public:
-    PIRServer(const seal::EncryptionParameters &expanded_params, const PirParams &pir_params);
+    PIRServer(const seal::EncryptionParameters &params, const PirParams &pir_params);
 
-    void update_parameters(const seal::EncryptionParameters &expanded_params,
-                           const PirParams &pir_params);
+    //void update_parameters(const seal::EncryptionParameters &expanded_params,
+    //                       const PirParams &pir_params);
 
     // NOTE: server takes over ownership of db and frees it when it exits.
     // Caller cannot free db
@@ -26,7 +26,9 @@ class PIRServer {
     void set_galois_key(std::uint32_t client_id, seal::GaloisKeys galkey);
 
   private:
-    seal::EncryptionParameters expanded_params_; // SEAL parameters
+    seal::EncryptionParameters params_; // SEAL parameters
+
+    //seal::EncryptionParameters expanded_params_; // SEAL parameters
     PirParams pir_params_;                       // PIR parameters
     std::unique_ptr<Database> db_;
     bool is_db_preprocessed_;