Browse Source

Add bool incremental parameters to constructors for RDPF, RDPFPair, RDPFTriple

The parameter is currently unused
Ian Goldberg 1 year ago
parent
commit
a277449c42
5 changed files with 29 additions and 18 deletions
  1. 3 2
      mpcio.hpp
  2. 5 4
      mpcio.tcc
  3. 13 6
      preproc.cpp
  4. 3 2
      rdpf.hpp
  5. 5 4
      rdpf.tcc

+ 3 - 2
mpcio.hpp

@@ -413,10 +413,11 @@ public:
     // Computational peers call:
     template <nbits_t WIDTH = 1>
     RDPFTriple<WIDTH> rdpftriple(yield_t &yield, nbits_t depth,
-        bool keep_expansion = true);
+        bool incremental = false, bool keep_expansion = true);
     // The server calls:
     template <nbits_t WIDTH = 1>
-    RDPFPair<WIDTH> rdpfpair(yield_t &yield, nbits_t depth);
+    RDPFPair<WIDTH> rdpfpair(yield_t &yield, nbits_t depth,
+        bool incremental = false);
     // Anyone can call:
     CDPF cdpf(yield_t &yield);
 

+ 5 - 4
mpcio.tcc

@@ -55,7 +55,7 @@ void PreCompStorage<T,N>::get(T& nextval)
 // rdpfpair() at the same time
 template <nbits_t WIDTH>
 RDPFTriple<WIDTH> MPCTIO::rdpftriple(yield_t &yield, nbits_t depth,
-    bool keep_expansion)
+    bool incremental, bool keep_expansion)
 {
     assert(mpcio.player < 2);
     RDPFTriple<WIDTH> val;
@@ -65,7 +65,7 @@ RDPFTriple<WIDTH> MPCTIO::rdpftriple(yield_t &yield, nbits_t depth,
         std::get<WIDTH-1>(mpcpio.rdpftriples)[thread_num][depth-1].get(val);
     } else {
         val = RDPFTriple<WIDTH>(*this, yield, depth,
-            keep_expansion);
+            incremental, keep_expansion);
         iostream_server() <<
             val.dpf[(mpcio.player == 0) ? 1 : 2];
         std::get<WIDTH-1>(mpcpio.rdpftriples)[thread_num][depth-1].inc();
@@ -77,7 +77,8 @@ RDPFTriple<WIDTH> MPCTIO::rdpftriple(yield_t &yield, nbits_t depth,
 // Only the server calls this; the computational peers should be calling
 // rdpftriple() at the same time
 template <nbits_t WIDTH>
-RDPFPair<WIDTH> MPCTIO::rdpfpair(yield_t &yield, nbits_t depth)
+RDPFPair<WIDTH> MPCTIO::rdpfpair(yield_t &yield, nbits_t depth,
+    bool incremental)
 {
     assert(mpcio.player == 2);
     RDPFPair<WIDTH> val;
@@ -86,7 +87,7 @@ RDPFPair<WIDTH> MPCTIO::rdpfpair(yield_t &yield, nbits_t depth)
     if (mpcio.mode == MODE_ONLINE) {
         std::get<WIDTH-1>(mpcsrvio.rdpfpairs)[thread_num][depth-1].get(val);
     } else {
-        RDPFTriple<WIDTH> trip(*this, yield, depth, true);
+        RDPFTriple<WIDTH> trip(*this, yield, depth, incremental, true);
         yield();
         iostream_p0() >> val.dpf[0];
         iostream_p1() >> val.dpf[1];

+ 13 - 6
preproc.cpp

@@ -165,40 +165,47 @@ void preprocessing_comp(MPCIO &mpcio, const PRACOptions &opts, char **args)
                     if (subtype > 1) {
                         sprintf(prefix+strlen(prefix), "%d_", subtype);
                     }
+                    bool incremental = false;
                     auto tripfile = ofiles.open(prefix,
                         mpcio.player, thread_num, type);
                     for (unsigned int i=0; i<num; ++i) {
                         coroutines.emplace_back(
-                            [&tio, &opts, tripfile, type, subtype](yield_t &yield) {
+                            [&tio, &opts, incremental, tripfile, type,
+                                subtype](yield_t &yield) {
                                 yield();
                                 switch(subtype) {
                                 case 1: {
                                     RDPFTriple<1> rdpftrip =
-                                        tio.rdpftriple<1>(yield, type, opts.expand_rdpfs);
+                                        tio.rdpftriple<1>(yield, type,
+                                            incremental, opts.expand_rdpfs);
                                     tripfile.os() << rdpftrip;
                                     break;
                                 }
                                 case 2: {
                                     RDPFTriple<2> rdpftrip =
-                                        tio.rdpftriple<2>(yield, type, opts.expand_rdpfs);
+                                        tio.rdpftriple<2>(yield, type,
+                                            incremental, opts.expand_rdpfs);
                                     tripfile.os() << rdpftrip;
                                     break;
                                 }
                                 case 3: {
                                     RDPFTriple<3> rdpftrip =
-                                        tio.rdpftriple<3>(yield, type, opts.expand_rdpfs);
+                                        tio.rdpftriple<3>(yield, type,
+                                            incremental, opts.expand_rdpfs);
                                     tripfile.os() << rdpftrip;
                                     break;
                                 }
                                 case 4: {
                                     RDPFTriple<4> rdpftrip =
-                                        tio.rdpftriple<4>(yield, type, opts.expand_rdpfs);
+                                        tio.rdpftriple<4>(yield, type,
+                                            incremental, opts.expand_rdpfs);
                                     tripfile.os() << rdpftrip;
                                     break;
                                 }
                                 case 5: {
                                     RDPFTriple<5> rdpftrip =
-                                        tio.rdpftriple<5>(yield, type, opts.expand_rdpfs);
+                                        tio.rdpftriple<5>(yield, type,
+                                            incremental, opts.expand_rdpfs);
                                     tripfile.os() << rdpftrip;
                                     break;
                                 }

+ 3 - 2
rdpf.hpp

@@ -100,7 +100,8 @@ struct RDPF : public DPF {
     // 2^{depth+1}-2 local AES operations for P0,P1
     // 0 local AES operations for P2
     RDPF(MPCTIO &tio, yield_t &yield,
-        RegXS target, nbits_t depth, bool save_expansion = false);
+        RegXS target, nbits_t depth, bool incremental = false,
+        bool save_expansion = false);
 
     // Do we have a precomputed expansion?
     inline bool has_expansion() const { return expansion.size() > 0; }
@@ -251,7 +252,7 @@ struct RDPFTriple {
     // Construct three RDPFs of the given depth all with the same
     // randomly generated target index.
     RDPFTriple(MPCTIO &tio, yield_t &yield,
-        nbits_t depth, bool save_expansion = false);
+        nbits_t depth, bool incremental = false, bool save_expansion = false);
 
     // Descend the three RDPFs in lock step
     node descend(const node &parent, nbits_t parentdepth,

+ 5 - 4
rdpf.tcc

@@ -818,7 +818,7 @@ static inline void create_level(MPCTIO &tio, yield_t &yield,
 // small optimization noted below.
 template <nbits_t WIDTH>
 RDPF<WIDTH>::RDPF(MPCTIO &tio, yield_t &yield,
-    RegXS target, nbits_t depth, bool save_expansion)
+    RegXS target, nbits_t depth, bool incremental, bool save_expansion)
 {
     int player = tio.player();
     size_t &aes_ops = tio.aes_ops();
@@ -965,7 +965,7 @@ void RDPF<WIDTH>::expand(size_t &aes_ops)
 // generated target index.
 template <nbits_t WIDTH>
 RDPFTriple<WIDTH>::RDPFTriple(MPCTIO &tio, yield_t &yield,
-    nbits_t depth, bool save_expansion)
+    nbits_t depth, bool incremental, bool save_expansion)
 {
     // Pick a random XOR share of the target
     xs_target.randomize(depth);
@@ -975,9 +975,10 @@ RDPFTriple<WIDTH>::RDPFTriple(MPCTIO &tio, yield_t &yield,
     std::vector<coro_t> coroutines;
     for (int i=0;i<3;++i) {
         coroutines.emplace_back(
-            [this, &tio, depth, i, save_expansion](yield_t &yield) {
+            [this, &tio, depth, i, incremental,
+                save_expansion](yield_t &yield) {
                 dpf[i] = RDPF<WIDTH>(tio, yield, xs_target, depth,
-                    save_expansion);
+                    incremental, save_expansion);
             });
     }
     coroutines.emplace_back(