Browse Source

Merge branch 'master' of git-crysp.uwaterloo.ca:duoram/code

avadapal 2 years ago
parent
commit
30e25f23b4
3 changed files with 18 additions and 6 deletions
  1. 1 1
      cpir-read/cxx/spir.hpp
  2. BIN
      cpir-read/cxx/spir_test
  3. 17 5
      cpir-read/cxx/spir_test.cpp

+ 1 - 1
cpir-read/cxx/spir.hpp

@@ -47,7 +47,7 @@ public:
 
     // preprocessing
     string preproc_process(const string &client_preproc); // returns the string to reply to the client
-  
+
     // SPIR query on the given database of N=2^r records, each of type DBEntry
     // rotate the database by rot, and blind each entry in the database additively with blind
     // returns the string to reply to the client

BIN
cpir-read/cxx/spir_test


+ 17 - 5
cpir-read/cxx/spir_test.cpp

@@ -61,7 +61,7 @@ int main(int argc, char **argv)
   tcp::resolver resolver(io_context);
     std::string addr = "127.0.0.1";
 
-  const std::string host1 = (argc < 1) ? "127.0.0.1" : argv[1];
+  const std::string host1 = (argc <= 1) ? "127.0.0.1" : argv[1];
 
 
 
@@ -142,10 +142,10 @@ int main(int argc, char **argv)
         r = strtoul(argv[2], NULL, 10);
         size_t num_records = ((size_t) 1)<<r;
         size_t num_records_mask = num_records - 1;
-        if (argc > 4) {
+        if (argc > 3) {
             num_threads = strtoul(argv[3], NULL, 10);
         }
-        if (argc > 5) {
+        if (argc > 4) {
             num_preproc = strtoul(argv[4], NULL, 10);
         }
         if (argc > 5) {
@@ -227,6 +227,10 @@ int main(int argc, char **argv)
 
     SPIR::DBEntry rand_blind =  1221030;
 
+    struct timeval all_queries_start;
+    gettimeofday(&all_queries_start, NULL);
+    size_t tot_query_bytes = 0;
+
     for (size_t i=0; i<num_pirs; ++i) {
         cout << "\n===== SPIR QUERY " << i+1 << " =====\n\n";
 
@@ -236,7 +240,8 @@ int main(int argc, char **argv)
             exit(1);
         }
         idx &= num_records_mask;
-                boost::asio::write(sockets_[0], boost::asio::buffer(&idx, sizeof(idx)));
+#ifdef CHECK_ANSWERS
+        boost::asio::write(sockets_[0], boost::asio::buffer(&idx, sizeof(idx)));
         size_t idx_recv;
         boost::asio::read(sockets_[0], boost::asio::buffer(&idx_recv, sizeof(idx_recv)));
 
@@ -248,12 +253,14 @@ int main(int argc, char **argv)
         // #if(PARTY == 1)
         //     idx = 40;
         // #endif
+#endif
 
         struct timeval query_client_start;
         gettimeofday(&query_client_start, NULL);
 
         string query_msg = client.query(idx);
         boost::asio::write(sockets_[0], boost::asio::buffer(query_msg));
+        tot_query_bytes += query_msg.length();
         string query_msg_recv(query_msg.length(), '\0');
         boost::asio::read(sockets_[0], boost::asio::buffer(query_msg_recv));
 
@@ -270,6 +277,7 @@ int main(int argc, char **argv)
         //string query_resp = server.query_process(query_msg_recv, db, 0, 0);
         string query_resp = server.query_process(query_msg_recv, db, idx, rand_blind);
         boost::asio::write(sockets_[0], boost::asio::buffer(query_resp));
+        tot_query_bytes += query_resp.length();
         string query_resp_recv = query_resp;
         boost::asio::read(sockets_[0], boost::asio::buffer(query_resp_recv));
 
@@ -282,7 +290,7 @@ int main(int argc, char **argv)
 
         SPIR::DBEntry entry = client.query_finish(query_resp_recv);
 
-
+#ifdef CHECK_ANSWERS
         boost::asio::write(sockets_[0], boost::asio::buffer(&entry, sizeof(entry)));
         SPIR::DBEntry entry_recv;
         boost::asio::read(sockets_[0], boost::asio::buffer(&entry_recv, sizeof(entry)));
@@ -296,12 +304,16 @@ int main(int argc, char **argv)
         read_output_recv += read_output;
 
         cout << "read_output_recv = " << read_output_recv << std::endl;
+#endif
 
 
         size_t query_finish_us = elapsed_us(&query_finish_start);
         cout << "Query client finish: " << query_finish_us << " µs\n";
         cout << "idx = " << idx << "; entry = " << entry << "\n";
      }
+    size_t all_queries_us = elapsed_us(&all_queries_start);
+    cout << "\n\nTotal query time: " << all_queries_us << " µs\n";
+    cout << "Total query bytes: " << tot_query_bytes << "\n";
 
         delete[] db;