Browse Source

Remove trailing whitespace in spir_test.cpp and spir.hpp

Ian Goldberg 1 year ago
parent
commit
24a6713996
2 changed files with 44 additions and 44 deletions
  1. 2 2
      cpir-read/cxx/spir.hpp
  2. 42 42
      cpir-read/cxx/spir_test.cpp

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

@@ -4,7 +4,7 @@
 #include <string>
 #include <stdint.h>
 
-using std::string; 
+using std::string;
 
 class SPIR {
 public:
@@ -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

+ 42 - 42
cpir-read/cxx/spir_test.cpp

@@ -2,30 +2,30 @@
 #include <stdlib.h>
 #include <sys/random.h>
 #include <sys/time.h>
-#include <unistd.h>   
-#include <bsd/stdlib.h> 
+#include <unistd.h>
+#include <bsd/stdlib.h>
 #include <boost/asio.hpp>
-#include <string> 
+#include <string>
 using boost::asio::ip::tcp;
 #include "spir.hpp"
 using std::cout;
 using std::cerr;
- 
+
 static inline size_t elapsed_us(const struct timeval *start)
-{ 
+{
     struct timeval end;
     gettimeofday(&end, NULL);
     return (end.tv_sec-start->tv_sec)*1000000 + end.tv_usec - start->tv_usec;
 }
 using socket_t = boost::asio::ip::tcp::socket;
- 
+
  void accept_conncections_from_Pb(boost::asio::io_context&io_context, std::vector<socket_t>& sockets_, int port, size_t j)
 {
      tcp::acceptor acceptor_a(io_context, tcp::endpoint(tcp::v4(), port));
      tcp::socket sb_a(acceptor_a.accept());
-     sockets_[j] = std::move(sb_a); 
-   
-  // sockets_.emplace_back(std::move(sb_a)); 
+     sockets_[j] = std::move(sb_a);
+
+  // sockets_.emplace_back(std::move(sb_a));
 }
 
   void write_pub_params(tcp::socket& sout, string pub_params)
@@ -36,36 +36,36 @@ using socket_t = boost::asio::ip::tcp::socket;
      {
          auto bytes_written = sout.write_some(boost::asio::buffer(bytes_to_write, bytes_remaining));
          bytes_to_write += bytes_written;
-         bytes_remaining -= bytes_written; 
+         bytes_remaining -= bytes_written;
       }
   }
 
   void read_pub_params(tcp::socket& sin, string& pub_params_recv, size_t len)
-  {    
+  {
        pub_params_recv.resize(len);
        auto bytes_remaining = len;
 
         char * bytes_to_read = (char*)pub_params_recv.data();
- 
+
         while (bytes_remaining )
         {
           auto bytes_read = sin.read_some(boost::asio::buffer(bytes_to_read, bytes_remaining));
           bytes_to_read += bytes_read;
-          bytes_remaining -= bytes_read; 
+          bytes_remaining -= bytes_read;
         }
   }
 
 int main(int argc, char **argv)
-{ 
+{
     boost::asio::io_context io_context;
   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 size_t number_of_sockets = 5;
     std::vector<socket_t> sockets_;
     for(size_t j = 0; j < number_of_sockets + 1; ++j)
@@ -79,21 +79,21 @@ int main(int argc, char **argv)
     std::vector<socket_t> sockets_2;
 
     std::vector<int> ports;
-    for(size_t j = 0; j < number_of_sockets; ++j) 
+    for(size_t j = 0; j < number_of_sockets; ++j)
     {
         int port = 6000;
         ports.push_back(port + j);
     }
-    
+
     std::vector<int> ports2_0;
-    for(size_t j = 0; j < number_of_sockets; ++j) 
+    for(size_t j = 0; j < number_of_sockets; ++j)
     {
         int port = 8000;
         ports2_0.push_back(port + j);
     }
 
     std::vector<int> ports2_1;
-    for(size_t j = 0; j < number_of_sockets; ++j) 
+    for(size_t j = 0; j < number_of_sockets; ++j)
     {
         int port = 9000;
         ports2_1.push_back(port + j);
@@ -101,35 +101,35 @@ int main(int argc, char **argv)
 
 
 
-  #if (PARTY == 0)    
-     
- 
+  #if (PARTY == 0)
+
+
     for(size_t j = 0; j < number_of_sockets; ++j)
     {
       tcp::socket sb_a(io_context);
       boost::asio::connect(sb_a, resolver.resolve({host1, std::to_string(ports[j])}));
-        sockets_[j] = std::move(sb_a); 
+        sockets_[j] = std::move(sb_a);
     }
- #else  
- 
- 
- 
+ #else
+
 
-   boost::asio::thread_pool pool2(number_of_sockets); 
+
+
+   boost::asio::thread_pool pool2(number_of_sockets);
    for(size_t j = 0; j < number_of_sockets; ++j)
    {
         boost::asio::post(pool2, std::bind(accept_conncections_from_Pb,  std::ref(io_context), std::ref(sockets_), ports[j],  j));
-   } 
+   }
    pool2.join();
 
 #endif
 
- 
-    #if (PARTY == 0)    
+
+    #if (PARTY == 0)
         std::cout << "PARTY 0" << std::endl;
     #endif
 
-    #if (PARTY == 1)    
+    #if (PARTY == 1)
         std::cout << "PARTY 1" << std::endl;
     #endif
 
@@ -169,13 +169,13 @@ int main(int argc, char **argv)
 
     writer.join();
     reader.join();
- 
+
 
     SPIR_Server server(r, pub_params_recv);
     size_t otsetup_us = elapsed_us(&otsetup_start);
     cout << "One-time setup: " << otsetup_us << " µs\n";
     cout << "pub_params len = " << pub_params_recv.length() << "\n";
- 
+
     cout << "\n===== PREPROCESSING =====\n\n";
 
     cout << "num_preproc = " << num_preproc << "\n";
@@ -184,7 +184,7 @@ int main(int argc, char **argv)
     gettimeofday(&preproc_client_start, NULL);
 
     string preproc_msg = client.preproc(num_preproc);
-    
+
     string preproc_msg_recv = preproc_msg;
 
     boost::asio::write(sockets_[0], boost::asio::buffer(preproc_msg));
@@ -200,7 +200,7 @@ int main(int argc, char **argv)
     gettimeofday(&preproc_server_start, NULL);
 
     string preproc_resp = server.preproc_process(preproc_msg_recv);
-    
+
     string preproc_resp_recv = preproc_resp;
     boost::asio::write(sockets_[0], boost::asio::buffer(preproc_resp));
     boost::asio::read(sockets_[0], boost::asio::buffer(preproc_resp_recv));
@@ -245,7 +245,7 @@ int main(int argc, char **argv)
         cout << "idx = " << idx << std::endl;
         cout << "idx_reconstructed = " << idx_recv << std::endl;
         // idx = 100;
-        // #if(PARTY == 1) 
+        // #if(PARTY == 1)
         //     idx = 40;
         // #endif
 
@@ -288,11 +288,11 @@ int main(int argc, char **argv)
         boost::asio::read(sockets_[0], boost::asio::buffer(&entry_recv, sizeof(entry)));
 
         SPIR::DBEntry read_output = entry_recv - rand_blind;
-       
+
         boost::asio::write(sockets_[0], boost::asio::buffer(&read_output, sizeof(entry)));
         SPIR::DBEntry read_output_recv;
         boost::asio::read(sockets_[0], boost::asio::buffer(&read_output_recv, sizeof(entry)));
-        
+
         read_output_recv += read_output;
 
         cout << "read_output_recv = " << read_output_recv << std::endl;