Forráskód Böngészése

Be clear about MPCTIO::{rdpftriple,rdpfpair}

Only computational peers should be calling rdpftriple and only the
server should be calling rdpfpair, and they should be doing so in
tandem.
Ian Goldberg 1 éve
szülő
commit
e127dd94f0
1 módosított fájl, 27 hozzáadás és 23 törlés
  1. 27 23
      mpcio.cpp

+ 27 - 23
mpcio.cpp

@@ -667,40 +667,44 @@ SelectTriple MPCTIO::selecttriple(yield_t &yield)
     return val;
 }
 
+// Only computational peers call this; the server should be calling
+// rdpfpair() at the same time
 RDPFTriple MPCTIO::rdpftriple(yield_t &yield, nbits_t depth,
     bool keep_expansion)
 {
+    assert(mpcio.player < 2);
     RDPFTriple val;
-    if (mpcio.player <= 2) {
-        MPCPeerIO &mpcpio = static_cast<MPCPeerIO&>(mpcio);
-        if (mpcio.mode == MODE_ONLINE) {
-            mpcpio.rdpftriples[thread_num][depth-1].get(val);
-        } else {
-            val = RDPFTriple(*this, yield, depth,
-                keep_expansion);
-            iostream_server() <<
-                val.dpf[(mpcio.player == 0) ? 1 : 2];
-            mpcpio.rdpftriples[thread_num][depth-1].inc();
-            yield();
-        }
+
+    MPCPeerIO &mpcpio = static_cast<MPCPeerIO&>(mpcio);
+    if (mpcio.mode == MODE_ONLINE) {
+        mpcpio.rdpftriples[thread_num][depth-1].get(val);
+    } else {
+        val = RDPFTriple(*this, yield, depth,
+            keep_expansion);
+        iostream_server() <<
+            val.dpf[(mpcio.player == 0) ? 1 : 2];
+        mpcpio.rdpftriples[thread_num][depth-1].inc();
+        yield();
     }
     return val;
 }
 
+// Only the server calls this; the computational peers should be calling
+// rdpftriple() at the same time
 RDPFPair MPCTIO::rdpfpair(yield_t &yield, nbits_t depth)
 {
+    assert(mpcio.player == 2);
     RDPFPair val;
-    if (mpcio.player == 2) {
-        MPCServerIO &mpcsrvio = static_cast<MPCServerIO&>(mpcio);
-        if (mpcio.mode == MODE_ONLINE) {
-            mpcsrvio.rdpfpairs[thread_num][depth-1].get(val);
-        } else {
-            RDPFTriple trip(*this, yield, depth, true);
-            yield();
-            iostream_p0() >> val.dpf[0];
-            iostream_p1() >> val.dpf[1];
-            mpcsrvio.rdpfpairs[thread_num][depth-1].inc();
-        }
+
+    MPCServerIO &mpcsrvio = static_cast<MPCServerIO&>(mpcio);
+    if (mpcio.mode == MODE_ONLINE) {
+        mpcsrvio.rdpfpairs[thread_num][depth-1].get(val);
+    } else {
+        RDPFTriple trip(*this, yield, depth, true);
+        yield();
+        iostream_p0() >> val.dpf[0];
+        iostream_p1() >> val.dpf[1];
+        mpcsrvio.rdpfpairs[thread_num][depth-1].inc();
     }
     return val;
 }