Browse Source

Remember to exchange the rotation values in the 2-party online write protocol

Ian Goldberg 1 year ago
parent
commit
d3204178f6
1 changed files with 17 additions and 1 deletions
  1. 17 1
      duoram-online/duoram.cpp

+ 17 - 1
duoram-online/duoram.cpp

@@ -220,9 +220,9 @@ int main(const int argc, const char * argv[])
      std::cout << "ri_reconstruction = " << ri_reconstruction << std::endl;
     #endif
 
-    #ifdef ThreeParty
      DuORAM_Write * WritePb_     = new DuORAM_Write[number_of_writes];
      DuORAM_Write * WritePb_recv = new DuORAM_Write[number_of_writes];
+    #ifdef ThreeParty
      DB_t * read_out = new DB_t[number_of_writes];
      DB_t * Gamma =  new DB_t[number_of_writes];
     #endif
@@ -302,7 +302,19 @@ int main(const int argc, const char * argv[])
        std::cout << "cw = " << CW[w] << std::endl;
       #endif 
      }
+    #else // 2-party case
+    for(size_t w = 0; w < number_of_writes; ++w)
+    {
+      WritePb_[w].shift = where_to_write[w] -ri;
+      WritePb_[w].CW = distinguised_value[0];
+      boost::asio::write(sockets_[0],  boost::asio::buffer(&WritePb_[w],    sizeof(DuORAM_Write)));
+      communication_cost_write += sizeof(DuORAM_Write);
+      boost::asio::read(sockets_[0],   boost::asio::buffer(&WritePb_recv[w], sizeof(DuORAM_Write)));
+      rotate_by_[w] = WritePb_[w].shift + WritePb_recv[w].shift;
+    }
     #endif
+    delete[] WritePb_;
+    delete[] WritePb_recv;
 
     for(size_t w = 0; w < number_of_writes; ++w)
     {			
@@ -316,6 +328,10 @@ int main(const int argc, const char * argv[])
      #endif
     }  
 
+    delete[] rotate_by_;
+    delete[] CW;
+    delete[] update_message;
+
    auto end_writes = std::chrono::steady_clock::now();
    std::chrono::duration<double> elapsed_seconds_writes = end_writes - start_writes;
    write_time = elapsed_seconds_writes.count();