Просмотр исходного кода

Add a WIDTH template parameter to MemRefS

In preparation for related-index ORAM accesses
Ian Goldberg 1 год назад
Родитель
Сommit
3e20c8ed08
3 измененных файлов с 38 добавлено и 38 удалено
  1. 15 15
      duoram.hpp
  2. 15 15
      duoram.tcc
  3. 8 8
      shapes.hpp

+ 15 - 15
duoram.hpp

@@ -102,8 +102,8 @@ class Duoram<T>::Shape {
     // a particular field of T, then FT will be the type of the field
     // (RegAS or RegXS) and FST will be a pointer-to-member T::* type
     // pointing to that field.  Sh is the specific Shape subtype used to
-    // create the MemRefS.
-    template <typename U, typename FT, typename FST, typename Sh>
+    // create the MemRefS.  WIDTH is the RDPF width to use.
+    template <typename U, typename FT, typename FST, typename Sh, nbits_t WIDTH>
     class MemRefS;
     // When x is unshared explicit value.  FT and FST are as above.
     template <typename FT, typename FST>
@@ -299,17 +299,17 @@ public:
     }
 
     // Index into this Flat in various ways
-    typename Duoram::Shape::template MemRefS<RegAS,T,std::nullopt_t,Flat>
+    typename Duoram::Shape::template MemRefS<RegAS,T,std::nullopt_t,Flat,1>
             operator[](const RegAS &idx) {
         typename Duoram<T>::Shape::
-            template MemRefS<RegAS,T,std::nullopt_t,Flat>
+            template MemRefS<RegAS,T,std::nullopt_t,Flat,1>
             res(*this, idx, std::nullopt);
         return res;
     }
-    typename Duoram::Shape::template MemRefS<RegXS,T,std::nullopt_t,Flat>
+    typename Duoram::Shape::template MemRefS<RegXS,T,std::nullopt_t,Flat,1>
             operator[](const RegXS &idx) {
         typename Duoram<T>::Shape::
-            template MemRefS<RegXS,T,std::nullopt_t,Flat>
+            template MemRefS<RegXS,T,std::nullopt_t,Flat,1>
             res(*this, idx, std::nullopt);
         return res;
     }
@@ -372,10 +372,10 @@ public:
 // particular field of T, then FT will be the type of the field (RegAS
 // or RegXS) and FST will be a pointer-to-member T::* type pointing to
 // that field.  Sh is the specific Shape subtype used to create the
-// MemRefS.
+// MemRefS.  WIDTH is the RDPF width to use.
 
 template <typename T>
-template <typename U, typename FT, typename FST, typename Sh>
+template <typename U, typename FT, typename FST, typename Sh, nbits_t WIDTH>
 class Duoram<T>::Shape::MemRefS {
     Sh &shape;
     U idx;
@@ -384,19 +384,19 @@ class Duoram<T>::Shape::MemRefS {
 private:
     // Oblivious update to a shared index of Duoram memory, only for
     // FT = RegAS or RegXS
-    MemRefS<U,FT,FST,Sh> &oram_update(const FT& M, const prac_template_true&);
+    MemRefS<U,FT,FST,Sh,WIDTH> &oram_update(const FT& M, const prac_template_true&);
     // Oblivious update to a shared index of Duoram memory, for
     // FT not RegAS or RegXS
-    MemRefS<U,FT,FST,Sh> &oram_update(const FT& M, const prac_template_false&);
+    MemRefS<U,FT,FST,Sh,WIDTH> &oram_update(const FT& M, const prac_template_false&);
 
 public:
-    MemRefS<U,FT,FST,Sh>(Sh &shape, const U &idx, FST fieldsel) :
+    MemRefS<U,FT,FST,Sh,WIDTH>(Sh &shape, const U &idx, FST fieldsel) :
         shape(shape), idx(idx), fieldsel(fieldsel) {}
 
     // Create a MemRefExpl for accessing a partcular field of T
     template <typename SFT>
-    MemRefS<U,SFT,SFT T::*,Sh> field(SFT T::*subfieldsel) {
-        auto res = MemRefS<U,SFT,SFT T::*,Sh>(this->shape, idx, subfieldsel);
+    MemRefS<U,SFT,SFT T::*,Sh,WIDTH> field(SFT T::*subfieldsel) {
+        auto res = MemRefS<U,SFT,SFT T::*,Sh,WIDTH>(this->shape, idx, subfieldsel);
         return res;
     }
 
@@ -404,10 +404,10 @@ public:
     operator FT();
 
     // Oblivious update to a shared index of Duoram memory
-    MemRefS<U,FT,FST,Sh> &operator+=(const FT& M);
+    MemRefS<U,FT,FST,Sh,WIDTH> &operator+=(const FT& M);
 
     // Oblivious write to a shared index of Duoram memory
-    MemRefS<U,FT,FST,Sh> &operator=(const FT& M);
+    MemRefS<U,FT,FST,Sh,WIDTH> &operator=(const FT& M);
 };
 
 // An explicit memory reference.  You get one of these from a Shape A

+ 15 - 15
duoram.tcc

@@ -273,11 +273,11 @@ inline address_t IfRegXS<RegXS>(address_t val) { return val; }
 // a particular field of T, then FT will be the type of the field (RegAS
 // or RegXS) and FST will be a pointer-to-member T::* type pointing to
 // that field.  Sh is the specific Shape subtype used to create the
-// MemRefS.
+// MemRefS.  WIDTH is the RDPF width to use.
 
 template <typename T>
-template <typename U,typename FT,typename FST,typename Sh>
-Duoram<T>::Shape::MemRefS<U,FT,FST,Sh>::operator FT()
+template <typename U,typename FT,typename FST,typename Sh,nbits_t WIDTH>
+Duoram<T>::Shape::MemRefS<U,FT,FST,Sh,WIDTH>::operator FT()
 {
     FT res;
     Sh &shape = this->shape;
@@ -385,9 +385,9 @@ Duoram<T>::Shape::MemRefS<U,FT,FST,Sh>::operator FT()
 // Oblivious update to a shared index of Duoram memory, only for
 // FT = RegAS or RegXS.  The template parameters are as above.
 template <typename T>
-template <typename U, typename FT, typename FST, typename Sh>
-typename Duoram<T>::Shape::template MemRefS<U,FT,FST,Sh>
-    &Duoram<T>::Shape::MemRefS<U,FT,FST,Sh>::oram_update(const FT& M,
+template <typename U, typename FT, typename FST, typename Sh, nbits_t WIDTH>
+typename Duoram<T>::Shape::template MemRefS<U,FT,FST,Sh,WIDTH>
+    &Duoram<T>::Shape::MemRefS<U,FT,FST,Sh,WIDTH>::oram_update(const FT& M,
         const prac_template_true &)
 {
     Sh &shape = this->shape;
@@ -501,9 +501,9 @@ typename Duoram<T>::Shape::template MemRefS<U,FT,FST,Sh>
 // Oblivious update to a shared index of Duoram memory, only for
 // FT not RegAS or RegXS.  The template parameters are as above.
 template <typename T>
-template <typename U, typename FT, typename FST, typename Sh>
-typename Duoram<T>::Shape::template MemRefS<U,FT,FST,Sh>
-    &Duoram<T>::Shape::MemRefS<U,FT,FST,Sh>::oram_update(const FT& M,
+template <typename U, typename FT, typename FST, typename Sh, nbits_t WIDTH>
+typename Duoram<T>::Shape::template MemRefS<U,FT,FST,Sh,WIDTH>
+    &Duoram<T>::Shape::MemRefS<U,FT,FST,Sh,WIDTH>::oram_update(const FT& M,
         const prac_template_false &)
 {
     T::update(shape, shape.yield, idx, M);
@@ -513,9 +513,9 @@ typename Duoram<T>::Shape::template MemRefS<U,FT,FST,Sh>
 // Oblivious update to an additively or XOR shared index of Duoram
 // memory. The template parameters are as above.
 template <typename T>
-template <typename U, typename FT, typename FST, typename Sh>
-typename Duoram<T>::Shape::template MemRefS<U,FT,FST,Sh>
-    &Duoram<T>::Shape::MemRefS<U,FT,FST,Sh>::operator+=(const FT& M)
+template <typename U, typename FT, typename FST, typename Sh, nbits_t WIDTH>
+typename Duoram<T>::Shape::template MemRefS<U,FT,FST,Sh,WIDTH>
+    &Duoram<T>::Shape::MemRefS<U,FT,FST,Sh,WIDTH>::operator+=(const FT& M)
 {
     return oram_update(M, prac_basic_Reg_S<FT>());
 }
@@ -523,9 +523,9 @@ typename Duoram<T>::Shape::template MemRefS<U,FT,FST,Sh>
 // Oblivious write to an additively or XOR shared index of Duoram
 // memory. The template parameters are as above.
 template <typename T>
-template <typename U, typename FT, typename FST, typename Sh>
-typename Duoram<T>::Shape::template MemRefS<U,FT,FST,Sh>
-    &Duoram<T>::Shape::MemRefS<U,FT,FST,Sh>::operator=(const FT& M)
+template <typename U, typename FT, typename FST, typename Sh, nbits_t WIDTH>
+typename Duoram<T>::Shape::template MemRefS<U,FT,FST,Sh,WIDTH>
+    &Duoram<T>::Shape::MemRefS<U,FT,FST,Sh,WIDTH>::operator=(const FT& M)
 {
     FT oldval = *this;
     FT update = M - oldval;

+ 8 - 8
shapes.hpp

@@ -74,17 +74,17 @@ public:
     }
 
     // Index into this Pad in various ways
-    typename Duoram::Shape::template MemRefS<RegAS,T,std::nullopt_t,Pad>
+    typename Duoram::Shape::template MemRefS<RegAS,T,std::nullopt_t,Pad,1>
             operator[](const RegAS &idx) {
         typename Duoram<T>::Shape::
-            template MemRefS<RegAS,T,std::nullopt_t,Pad>
+            template MemRefS<RegAS,T,std::nullopt_t,Pad,1>
             res(*this, idx, std::nullopt);
         return res;
     }
-    typename Duoram::Shape::template MemRefS<RegXS,T,std::nullopt_t,Pad>
+    typename Duoram::Shape::template MemRefS<RegXS,T,std::nullopt_t,Pad,1>
             operator[](const RegXS &idx) {
         typename Duoram<T>::Shape::
-            template MemRefS<RegXS,T,std::nullopt_t,Pad>
+            template MemRefS<RegXS,T,std::nullopt_t,Pad,1>
             res(*this, idx, std::nullopt);
         return res;
     }
@@ -149,17 +149,17 @@ public:
     }
 
     // Index into this Stride in various ways
-    typename Duoram::Shape::template MemRefS<RegAS,T,std::nullopt_t,Stride>
+    typename Duoram::Shape::template MemRefS<RegAS,T,std::nullopt_t,Stride,1>
             operator[](const RegAS &idx) {
         typename Duoram<T>::Shape::
-            template MemRefS<RegAS,T,std::nullopt_t,Stride>
+            template MemRefS<RegAS,T,std::nullopt_t,Stride,1>
             res(*this, idx, std::nullopt);
         return res;
     }
-    typename Duoram::Shape::template MemRefS<RegXS,T,std::nullopt_t,Stride>
+    typename Duoram::Shape::template MemRefS<RegXS,T,std::nullopt_t,Stride,1>
             operator[](const RegXS &idx) {
         typename Duoram<T>::Shape::
-            template MemRefS<RegXS,T,std::nullopt_t,Stride>
+            template MemRefS<RegXS,T,std::nullopt_t,Stride,1>
             res(*this, idx, std::nullopt);
         return res;
     }