Browse Source

More cleaning up

Andrew Beams 3 years ago
parent
commit
c78e57e0cc
5 changed files with 0 additions and 47 deletions
  1. 0 17
      main.cpp
  2. 0 14
      pir_client.cpp
  3. 0 3
      pir_client.hpp
  4. 0 11
      pir_server.cpp
  5. 0 2
      pir_server.hpp

+ 0 - 17
main.cpp

@@ -97,29 +97,12 @@ int main(int argc, char *argv[]) {
     auto time_decode_e = chrono::high_resolution_clock::now();
     auto time_decode_us = duration_cast<microseconds>(time_decode_e - time_decode_s).count();
 
-    Ciphertext one_ct = client.get_encrypted_one();
-    Ciphertext reply2 = server.generate_public_reply(one_ct, index);
-    Plaintext result2 = client.decrypt(reply2);
-
     logt = floor(log2(params.plain_modulus().value()));
 
     // Convert from FV plaintext (polynomial) to database element at the client
     vector<uint8_t> elems(N * logt / 8);
     coeffs_to_bytes(logt, result, elems.data(), (N * logt) / 8);
 
-    vector<uint8_t> elems2(N * logt / 8);
-    coeffs_to_bytes(logt, result2, elems2.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] != elems2[(offset * size_per_item) + i]) {
-            cout << "Main: elems " << (int)elems[(offset * size_per_item) + i] << ", elems2 "
-                 << (int)elems[(offset * size_per_item) + i] << endl;
-            cout << "Main: PIR results inconsistent at" << i << endl;
-            return -1;
-        }
-    }
-
     bool failed = false;
     // Check that we retrieved the correct element
     for (uint32_t i = 0; i < size_per_item; i++) {

+ 0 - 14
pir_client.cpp

@@ -210,17 +210,3 @@ Ciphertext PIRClient::compose_to_ciphertext(vector<Plaintext> plains) {
 
     return result;
 }
-
-Ciphertext PIRClient::get_encrypted_one(){
-    Ciphertext one_ct;
-    Plaintext one("1");
-    encryptor_->encrypt(one, one_ct);
-    return one_ct;
-}
-
-
-Plaintext PIRClient::decrypt(seal::Ciphertext ct){
-    Plaintext result;
-    decryptor_->decrypt(ct, result);
-    return result;
-}

+ 0 - 3
pir_client.hpp

@@ -20,9 +20,6 @@ class PIRClient {
     uint64_t get_fv_index(uint64_t element_idx, uint64_t ele_size);
     uint64_t get_fv_offset(uint64_t element_idx, uint64_t ele_size);
 
-    seal::Ciphertext get_encrypted_one();
-    seal::Plaintext decrypt(seal::Ciphertext ct);
-
 
   private:
     seal::EncryptionParameters params_;

+ 0 - 11
pir_server.cpp

@@ -266,17 +266,6 @@ PirReply PIRServer::generate_reply(PirQuery query, uint32_t client_id, const PIR
     return fail;
 }
 
-Ciphertext PIRServer::generate_public_reply(Ciphertext one_ct, std::uint64_t desiredIndex){
-    vector<Plaintext> *cur = db_.get();
-    Ciphertext result;
-    evaluator_->transform_to_ntt_inplace(one_ct);
-    cout << "transformed" << endl;
-    evaluator_->multiply_plain(one_ct, (*cur)[desiredIndex], result);
-    cout << "reply generated" << endl;
-    evaluator_->transform_from_ntt_inplace(result);
-    return result;
-}
-
 inline vector<Ciphertext> PIRServer::expand_query(const Ciphertext &encrypted, uint32_t m,
                                            uint32_t client_id, const PIRClient& client) {
 

+ 0 - 2
pir_server.hpp

@@ -20,8 +20,6 @@ class PIRServer {
             const seal::Ciphertext &encrypted, std::uint32_t m, uint32_t client_id, const PIRClient& client);
 
     PirReply generate_reply(PirQuery query, std::uint32_t client_id, const PIRClient& client);
-    
-    seal::Ciphertext generate_public_reply(seal::Ciphertext one_ct, std::uint64_t desiredIndex);
 
     void set_galois_key(std::uint32_t client_id, seal::GaloisKeys galkey);