Browse Source

Slightly better API for the common case of WIDTH=1

Ian Goldberg 2 years ago
parent
commit
04115039cf
2 changed files with 35 additions and 1 deletions
  1. 34 0
      duoram.hpp
  2. 1 1
      online.cpp

+ 34 - 0
duoram.hpp

@@ -256,6 +256,40 @@ public:
     // next oblivious read or write.  Bitonic sort is a prime example.
     void explicitonly(bool enable);
 
+    // Create an OblivIndex, non-incrementally (supply the shares of the
+    // index directly) or incrementally (the bits of the index will be
+    // supplied later, one at a time)
+
+    // Non-incremental, RegXS index
+    OblivIndex<RegXS,1> oblivindex(const RegXS &idx, nbits_t depth=0) {
+        if (depth == 0) {
+            depth = this->addr_size;
+        }
+        typename Duoram<T>::OblivIndex<RegXS,1>
+            res(this->tio, this->yield, idx, depth);
+        return res;
+    }
+
+    // Non-incremental, RegAS index
+    OblivIndex<RegAS,1> oblivindex(const RegAS &idx, nbits_t depth=0) {
+        if (depth == 0) {
+            depth = this->addr_size;
+        }
+        typename Duoram<T>::OblivIndex<RegAS,1>
+            res(this->tio, this->yield, idx, depth);
+        return res;
+    }
+
+    // Incremental (requires RegXS index, supplied bit-by-bit later)
+    OblivIndex<RegXS,1> oblivindex(nbits_t depth=0) {
+        if (depth == 0) {
+            depth = this->addr_size;
+        }
+        typename Duoram<T>::OblivIndex<RegXS,1>
+            res(this->tio, this->yield, depth);
+        return res;
+    }
+
     // For debugging or checking your answers (using this in general is
     // of course insecure)
 

+ 1 - 1
online.cpp

@@ -699,7 +699,7 @@ static void duoram_test(MPCIO &mpcio,
         printf("XOR Reading\n");
         T Ax = A[xidx];
         // Writing and reading with OblivIndex indices
-        typename Duoram<T>::OblivIndex<RegXS,1> oidx(tio, yield, oxidx, depth);
+        auto oidx = A.oblivindex(oxidx);
         printf("OblivIndex Updating\n");
         A[oidx] += O;
         printf("OblivIndex Reading\n");