Browse Source

Rename triples to multtriples and selecttriples to nodeselecttriples

Ian Goldberg 1 year ago
parent
commit
878db98688
6 changed files with 22 additions and 22 deletions
  1. 1 1
      README.md
  2. 11 11
      mpcio.cpp
  3. 3 3
      mpcio.hpp
  4. 2 2
      mpcops.cpp
  5. 4 4
      preproc.cpp
  6. 1 1
      types.hpp

+ 1 - 1
README.md

@@ -52,7 +52,7 @@ Then the <code>_args_</code> specify what resources to compute.  You actually on
 
 The args in preprocessing mode are each of the form <code>_type_:_num_</code> to indicate to create <code>_num_</code> resources of the given type.  The available types include:
 
-  - `t`: a multiplication triple
+  - `m`: a multiplication triple
   - `h`: a multiplication half-triple
   - <code>r*d*</code>: A DPF of depth <code>_d_</code> for random accesses to memory (RDPF).  A DPF of depth _d_ can be used to process 2<sup>_d_</sup> memory locations.
   - `c`: a DPF for comparisons (CDPF)

+ 11 - 11
mpcio.cpp

@@ -286,7 +286,7 @@ MPCPeerIO::MPCPeerIO(unsigned player, ProcessingMode mode,
 {
     unsigned num_threads = unsigned(peersocks.size());
     for (unsigned i=0; i<num_threads; ++i) {
-        triples.emplace_back(player, mode, "triples", i);
+        multtriples.emplace_back(player, mode, "mults", i);
     }
     for (unsigned i=0; i<num_threads; ++i) {
         halftriples.emplace_back(player, mode, "halves", i);
@@ -311,15 +311,15 @@ MPCPeerIO::MPCPeerIO(unsigned player, ProcessingMode mode,
 
 void MPCPeerIO::dump_precomp_stats(std::ostream &os)
 {
-    for (size_t i=0; i<triples.size(); ++i) {
+    for (size_t i=0; i<multtriples.size(); ++i) {
         size_t cnt;
         if (i > 0) {
             os << " ";
         }
         os << "T" << i;
-        cnt = triples[i].get_stats();
+        cnt = multtriples[i].get_stats();
         if (cnt > 0) {
-            os << " t:" << cnt;
+            os << " m:" << cnt;
         }
         cnt = halftriples[i].get_stats();
         if (cnt > 0) {
@@ -341,8 +341,8 @@ void MPCPeerIO::dump_precomp_stats(std::ostream &os)
 
 void MPCPeerIO::reset_precomp_stats()
 {
-    for (size_t i=0; i<triples.size(); ++i) {
-        triples[i].reset_stats();
+    for (size_t i=0; i<multtriples.size(); ++i) {
+        multtriples[i].reset_stats();
         halftriples[i].reset_stats();
         for (nbits_t depth=1; depth<=ADDRESS_MAX_BITS; ++depth) {
             rdpftriples[i][depth-1].reset_stats();
@@ -583,7 +583,7 @@ void MPCTIO::send()
 // Functions to get precomputed values.  If we're in the online
 // phase, get them from PreCompStorage.  If we're in the
 // preprocessing or online-only phase, read them from the server.
-MultTriple MPCTIO::triple(yield_t &yield)
+MultTriple MPCTIO::multtriple(yield_t &yield)
 {
     MultTriple val;
     if (mpcio.player < 2) {
@@ -591,12 +591,12 @@ MultTriple MPCTIO::triple(yield_t &yield)
         if (mpcpio.mode != MODE_ONLINE) {
             yield();
             recv_server(&val, sizeof(val));
-            mpcpio.triples[thread_num].inc();
+            mpcpio.multtriples[thread_num].inc();
         } else {
-            mpcpio.triples[thread_num].get(val);
+            mpcpio.multtriples[thread_num].get(val);
         }
     } else if (mpcio.mode != MODE_ONLINE) {
-        // Create triples (X0,Y0,Z0),(X1,Y1,Z1) such that
+        // Create multiplication triples (X0,Y0,Z0),(X1,Y1,Z1) such that
         // (X0*Y1 + Y0*X1) = (Z0+Z1)
         value_t X0, Y0, Z0, X1, Y1, Z1;
         arc4random_buf(&X0, sizeof(X0));
@@ -650,7 +650,7 @@ HalfTriple MPCTIO::halftriple(yield_t &yield, bool tally)
     return val;
 }
 
-SelectTriple MPCTIO::selecttriple(yield_t &yield)
+SelectTriple MPCTIO::nodeselecttriple(yield_t &yield)
 {
     SelectTriple val;
     if (mpcio.player < 2) {

+ 3 - 3
mpcio.hpp

@@ -207,7 +207,7 @@ struct MPCPeerIO : public MPCIO {
     // culprit), but you can have a deque of those for some reason.
     std::deque<MPCSingleIO> peerios;
     std::deque<MPCSingleIO> serverios;
-    std::vector<PreCompStorage<MultTriple, MultTripleName>> triples;
+    std::vector<PreCompStorage<MultTriple, MultTripleName>> multtriples;
     std::vector<PreCompStorage<HalfTriple, HalfTripleName>> halftriples;
     std::vector<PreCompStorage<CDPF, CDPFName>> cdpfs;
     // The outer vector is (like above) one item per thread
@@ -370,9 +370,9 @@ public:
     // phase, get them from PreCompStorage.  If we're in the
     // preprocessing phase, read them from the server.
 
-    MultTriple triple(yield_t &yield);
+    MultTriple multtriple(yield_t &yield);
     HalfTriple halftriple(yield_t &yield, bool tally=true);
-    SelectTriple selecttriple(yield_t &yield);
+    SelectTriple nodeselecttriple(yield_t &yield);
 
     // These ones only work during the online phase
     // Computational peers call:

+ 2 - 2
mpcops.cpp

@@ -32,7 +32,7 @@ void mpc_cross(MPCTIO &tio, yield_t &yield,
 {
     const value_t mask = MASKBITS(nbits);
     size_t nbytes = BITBYTES(nbits);
-    auto [X, Y, Z] = tio.triple(yield);
+    auto [X, Y, Z] = tio.multtriple(yield);
 
     // Send x+X and y+Y
     value_t blind_x = (x.ashare + X) & mask;
@@ -220,7 +220,7 @@ void mpc_reconstruct_choice(MPCTIO &tio, yield_t &yield,
     DPFnode fext = if128_mask[f.bshare];
 
     // Compute XOR shares of f & (x ^ y)
-    auto [X, Y, Z] = tio.selecttriple(yield);
+    auto [X, Y, Z] = tio.nodeselecttriple(yield);
 
     bit_t blind_f = f.bshare ^ X;
     DPFnode d = x ^ y;

+ 4 - 4
preproc.cpp

@@ -98,14 +98,14 @@ void preprocessing_comp(MPCIO &mpcio, const PRACOptions &opts, char **args)
                 tio.recv_server(&num, 4);
                 if (type == 0x80) {
                     // Multiplication triples
-                    auto tripfile = ofiles.open("triples",
+                    auto tripfile = ofiles.open("mults",
                         mpcio.player, thread_num);
 
                     for (unsigned int i=0; i<num; ++i) {
                         coroutines.emplace_back(
                             [&tio, tripfile](yield_t &yield) {
                                 yield();
-                                MultTriple T = tio.triple(yield);
+                                MultTriple T = tio.multtriple(yield);
                                 tripfile.os() << T;
                             });
                     }
@@ -224,7 +224,7 @@ void preprocessing_server(MPCServerIO &mpcsrvio, const PRACOptions &opts, char *
                 unsigned num = atoi(colon+1);
                 *colon = '\0';
                 char *type = arg;
-                if (!strcmp(type, "t")) {
+                if (!strcmp(type, "m")) {
                     unsigned char typetag = 0x80;
                     stio.queue_p0(&typetag, 1);
                     stio.queue_p0(&num, 4);
@@ -235,7 +235,7 @@ void preprocessing_server(MPCServerIO &mpcsrvio, const PRACOptions &opts, char *
                         coroutines.emplace_back(
                             [&stio](yield_t &yield) {
                                 yield();
-                                stio.triple(yield);
+                                stio.multtriple(yield);
                             });
                     }
                 } else if (!strcmp(type, "h")) {

+ 1 - 1
types.hpp

@@ -606,7 +606,7 @@ using MultTriple = std::tuple<value_t, value_t, value_t>;
 // The *Name structs are a way to get strings representing the names of
 // the types as would be given to preprocessing to create them in
 // advance.
-struct MultTripleName { static constexpr const char *name = "t"; };
+struct MultTripleName { static constexpr const char *name = "m"; };
 
 // A half-triple is (X0,Z0) held by P0 (and correspondingly (Y1,Z1) held
 // by P1), with all values random, but subject to the relation that