瀏覽代碼

Store the max depth and the current depth in an RDPF

They're currently always the same, but will be different for incremental
RDPFs later
Ian Goldberg 1 年之前
父節點
當前提交
f15d8fc6e1
共有 2 個文件被更改,包括 13 次插入3 次删除
  1. 10 2
      rdpf.hpp
  2. 3 1
      rdpf.tcc

+ 10 - 2
rdpf.hpp

@@ -60,6 +60,14 @@ struct RDPF : public DPF {
         LeafInfo() : unit_sum_inverse(0) {}
     };
 
+    // The depth of this RDPF.  If this is not an incremental DPF, then
+    // both the maximum depth and current depth are just the normal
+    // depth (specified at DPF creation time).  If this is an
+    // incremental DPF, then the maximum depth is the one specified at
+    // creation time, but the current depth will be between 1 and that
+    // value (inclusive).
+    nbits_t maxdepth, curdepth;
+
     // The LeafInfo for each leaf level.  Normal RDPFs only have one
     // leaf level, so this will be a vector of length 1.  Incremental
     // RDPFs will have one entry for each level in the DPF.  The entry
@@ -69,7 +77,7 @@ struct RDPF : public DPF {
 
     // The leaf correction flag bits for the LWIDTH leaf words at each
     // leaf level.  The bit for leaf word j of level i (for an
-    // incremental DPF of total depth d) is leaf_cfbits[j] & (1<<(d-i)).
+    // incremental DPF of max depth m) is leaf_cfbits[j] & (1<<(m-i)).
     // For a normal (not incremental) RDPF, it's the same, but therefore
     // only the low bit of each of these LWIDTH words gets used.
     std::array<value_t,LWIDTH> leaf_cfbits;
@@ -103,7 +111,7 @@ struct RDPF : public DPF {
     }
 
     // The depth
-    inline nbits_t depth() const { return cw.size(); }
+    inline nbits_t depth() const { return curdepth; }
 
     // Get the leaf node for the given input
     //

+ 3 - 1
rdpf.tcc

@@ -197,7 +197,7 @@ inline typename RDPF<WIDTH>::LeafNode RDPF<WIDTH>::descend_to_leaf(
         LeafNode CWR = CW;
         for (nbits_t j=0;j<LWIDTH;++j) {
             bit_t cfbit = !!(leaf_cfbits[j] &
-                (value_t(1)<<(depth()-parentdepth)));
+                (value_t(1)<<(maxdepth-parentdepth)));
             CWR[j] ^= lsb128_mask[cfbit];
         }
         prgout ^= (whichchild ? CWR : CW);
@@ -358,6 +358,8 @@ RDPF<WIDTH>::RDPF(MPCTIO &tio, yield_t &yield,
     seed = set_lsb(seed, !!player);
     cfbits = 0;
     whichhalf = (player == 1);
+    maxdepth = depth;
+    curdepth = depth;
 
     // The root level is just the seed
     nbits_t level = 0;