Browse Source

Demonstrate independent simultaneous reads

Ian Goldberg 2 years ago
parent
commit
212a0d420e
2 changed files with 32 additions and 3 deletions
  1. 5 2
      duoram.hpp
  2. 27 1
      online.cpp

+ 5 - 2
duoram.hpp

@@ -87,7 +87,8 @@ class Duoram<T>::Shape {
     // additive-shared index (x) into an XOR-shared database (T), for
     // example.
 
-    // The parent class of the MemRef* classes
+    // The parent class of the MemRef* classes, used when deferencing a
+    // Shape with A[x]
     class MemRef;
 
     // When x is additively or XOR shared
@@ -143,7 +144,9 @@ protected:
     // Copy the given Shape except for the tio and yield
     Shape(const Shape &copy_from, MPCTIO &tio, yield_t &yield) :
         parent(copy_from.parent), duoram(copy_from.duoram),
-        shape_size(copy_from.shape_size), tio(tio), yield(yield),
+        shape_size(copy_from.shape_size),
+        addr_size(copy_from.addr_size), addr_mask(copy_from.addr_mask),
+        tio(tio), yield(yield),
         explicitmode(copy_from.explicitmode) {}
 
     // The index-mapping function. Input the index relative to this

+ 27 - 1
online.cpp

@@ -576,8 +576,9 @@ static void duoram_test(MPCIO &mpcio,
         // size_t &aes_ops = tio.aes_ops();
         Duoram<T> oram(tio.player(), size);
         auto A = oram.flat(tio, yield);
-        RegAS aidx;
+        RegAS aidx, aidx2;
         aidx.ashare = share;
+        aidx2.ashare = share + tio.player();
         T M;
         if (tio.player() == 0) {
             M.set(0xbabb0000);
@@ -608,6 +609,25 @@ static void duoram_test(MPCIO &mpcio,
             A[5] += Aa;
             Ae = A[6];
         }
+
+        // Simultaneous independent reads
+        std::vector<T> Av;
+        Av.resize(2);
+        std::vector<coro_t> coroutines;
+        run_coroutines(yield,
+            [&A, &Av, &aidx] (yield_t &yield) {
+                auto Acoro = A.context(yield);
+                printf("About to read 0\n");
+                Av[0] = Acoro[aidx];
+                printf("read 0\n");
+            },
+            [&A, &Av, &aidx2] (yield_t &yield) {
+                auto Acoro = A.context(yield);
+                printf("About to read 1\n");
+                Av[1] = Acoro[aidx2];
+                printf("read 1\n");
+            });
+
         if (depth <= 10) {
             oram.dump();
             auto check = A.reconstruct();
@@ -625,6 +645,12 @@ static void duoram_test(MPCIO &mpcio,
             printf("Read AX value = %016lx\n", checkreadx.share());
             printf("Read Ex value = %016lx\n", checkreade.share());
         }
+        for (auto &v : Av) {
+            auto checkv = A.reconstruct(v);
+            if (tio.player() == 0) {
+                printf("Read Av value = %016lx\n", checkv.share());
+            }
+        }
     });
 }