Переглянути джерело

Have Reg{A,X,B}S definitely initialize to 0 when constructed

Ian Goldberg 1 рік тому
батько
коміт
9e3895c950
2 змінених файлів з 6 додано та 9 видалено
  1. 0 9
      online.cpp
  2. 6 0
      types.hpp

+ 0 - 9
online.cpp

@@ -253,7 +253,6 @@ static void rdpf_timing(MPCIO &mpcio, const PRACOptions &opts, char **args)
                     RDPF &dpf = dp.dpf[i];
                     dpf.expand(op_counter);
                     RegXS scaled_xor;
-                    scaled_xor.xshare = 0;
                     for (address_t x=0;x<(address_t(1)<<depth);++x) {
                         DPFnode leaf = dpf.leaf(x, op_counter);
                         RegXS sx = dpf.scaled_xs(leaf);
@@ -269,7 +268,6 @@ static void rdpf_timing(MPCIO &mpcio, const PRACOptions &opts, char **args)
                     RDPF &dpf = dt.dpf[i];
                     dpf.expand(op_counter);
                     RegXS scaled_xor;
-                    scaled_xor.xshare = 0;
                     for (address_t x=0;x<(address_t(1)<<depth);++x) {
                         DPFnode leaf = dpf.leaf(x, op_counter);
                         RegXS sx = dpf.scaled_xs(leaf);
@@ -311,7 +309,6 @@ static void rdpfeval_timing(MPCIO &mpcio, const PRACOptions &opts, char **args)
                 for (int i=0;i<2;++i) {
                     RDPF &dpf = dp.dpf[i];
                     RegXS scaled_xor;
-                    scaled_xor.xshare = 0;
                     auto ev = StreamEval(dpf, start, op_counter, false);
                     for (address_t x=0;x<(address_t(1)<<depth);++x) {
                         DPFnode leaf = ev.next();
@@ -327,7 +324,6 @@ static void rdpfeval_timing(MPCIO &mpcio, const PRACOptions &opts, char **args)
                 for (int i=0;i<3;++i) {
                     RDPF &dpf = dt.dpf[i];
                     RegXS scaled_xor;
-                    scaled_xor.xshare = 0;
                     auto ev = StreamEval(dpf, start, op_counter, false);
                     for (address_t x=0;x<(address_t(1)<<depth);++x) {
                         DPFnode leaf = ev.next();
@@ -368,8 +364,6 @@ static void tupleeval_timing(MPCIO &mpcio, const PRACOptions &opts, char **args)
             if (mpcio.player == 2) {
                 RDPFPair dp = tio.rdpfpair(depth);
                 RegXS scaled_xor0, scaled_xor1;
-                scaled_xor0.xshare = 0;
-                scaled_xor1.xshare = 0;
                 auto ev = StreamEval(dp, start, op_counter, false);
                 for (address_t x=0;x<(address_t(1)<<depth);++x) {
                     auto [L0, L1] = ev.next();
@@ -387,9 +381,6 @@ static void tupleeval_timing(MPCIO &mpcio, const PRACOptions &opts, char **args)
             } else {
                 RDPFTriple dt = tio.rdpftriple(depth);
                 RegXS scaled_xor0, scaled_xor1, scaled_xor2;
-                scaled_xor0.xshare = 0;
-                scaled_xor1.xshare = 0;
-                scaled_xor2.xshare = 0;
                 auto ev = StreamEval(dt, start, op_counter, false);
                 for (address_t x=0;x<(address_t(1)<<depth);++x) {
                     auto [L0, L1, L2] = ev.next();

+ 6 - 0
types.hpp

@@ -46,6 +46,8 @@ using nbits_t = uint8_t;
 struct RegAS {
     value_t ashare;
 
+    RegAS() : ashare(0) {}
+
     // Set each side's share to a random value nbits bits long
     inline void randomize(size_t nbits = VALUE_BITS) {
         value_t mask = MASKBITS(nbits);
@@ -102,6 +104,8 @@ struct RegAS {
 struct RegBS {
     bit_t bshare;
 
+    RegBS() : bshare(0) {}
+
     // Set each side's share to a random bit
     inline void randomize() {
         unsigned char randb;
@@ -125,6 +129,8 @@ struct RegBS {
 struct RegXS {
     value_t xshare;
 
+    RegXS() : xshare(0) {}
+
     // Set each side's share to a random value nbits bits long
     inline void randomize(size_t nbits = VALUE_BITS) {
         value_t mask = MASKBITS(nbits);