Browse Source

Change op_counter to aes_ops everywhere

A previous commit changes aesops to aes_ops as well.  Now everything
is using the same name (and spelling).
Ian Goldberg 1 year ago
parent
commit
3c86beb097
7 changed files with 54 additions and 54 deletions
  1. 2 2
      aes.hpp
  2. 3 3
      dpf.hpp
  3. 15 15
      online.cpp
  4. 5 5
      prg.hpp
  5. 17 17
      rdpf.cpp
  6. 6 6
      rdpf.hpp
  7. 6 6
      rdpf.tcc

+ 2 - 2
aes.hpp

@@ -62,7 +62,7 @@ static inline void AES_128_Key_Expansion (AESkey &key, __m128i rawkey)
 }
 
 static inline void AES_ECB_encrypt(__m128i &ciphertext, __m128i plaintext,
-    const AESkey &key, size_t &op_counter)
+    const AESkey &key, size_t &aes_ops)
 {
     __m128i tmp;
     int j;
@@ -73,7 +73,7 @@ static inline void AES_ECB_encrypt(__m128i &ciphertext, __m128i plaintext,
     }
     tmp = _mm_aesenclast_si128 (tmp,key[j]);
     ciphertext=tmp;
-    ++op_counter;
+    ++aes_ops;
 }
 
 #endif

+ 3 - 3
dpf.hpp

@@ -60,18 +60,18 @@ struct DPF {
     //
     // Cost: 1 AES operation
     inline DPFnode descend(const DPFnode &parent, nbits_t parentdepth,
-        bit_t whichchild, size_t &op_counter) const;
+        bit_t whichchild, size_t &aes_ops) const;
 };
 
 // Descend from a node at depth parentdepth to one of its children
 // whichchild = 0: left child
 // whichchild = 1: right child
 inline DPFnode DPF::descend(const DPFnode &parent, nbits_t parentdepth,
-    bit_t whichchild, size_t &op_counter) const
+    bit_t whichchild, size_t &aes_ops) const
 {
     DPFnode prgout;
     bool flag = get_lsb(parent);
-    prg(prgout, parent, whichchild, op_counter);
+    prg(prgout, parent, whichchild, aes_ops);
     if (flag) {
         DPFnode CW = cw[parentdepth];
         bit_t cfbit = !!(cfbits & (value_t(1)<<parentdepth));

+ 15 - 15
online.cpp

@@ -169,13 +169,13 @@ static void rdpf_test(MPCIO &mpcio, yield_t &yield,
     for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
         boost::asio::post(pool, [&mpcio, thread_num, depth] {
             MPCTIO tio(mpcio, thread_num);
-            size_t &op_counter = tio.aes_ops();
+            size_t &aes_ops = tio.aes_ops();
             if (mpcio.player == 2) {
                 RDPFPair dp = tio.rdpfpair(depth);
                 for (int i=0;i<2;++i) {
                     const RDPF &dpf = dp.dpf[i];
                     for (address_t x=0;x<(address_t(1)<<depth);++x) {
-                        DPFnode leaf = dpf.leaf(x, op_counter);
+                        DPFnode leaf = dpf.leaf(x, aes_ops);
                         RegBS ub = dpf.unit_bs(leaf);
                         RegAS ua = dpf.unit_as(leaf);
                         RegXS sx = dpf.scaled_xs(leaf);
@@ -199,7 +199,7 @@ static void rdpf_test(MPCIO &mpcio, yield_t &yield,
                         peer_scaled_xor ^= dpf.scaled_xor;
                     }
                     for (address_t x=0;x<(address_t(1)<<depth);++x) {
-                        DPFnode leaf = dpf.leaf(x, op_counter);
+                        DPFnode leaf = dpf.leaf(x, aes_ops);
                         RegBS ub = dpf.unit_bs(leaf);
                         RegAS ua = dpf.unit_as(leaf);
                         RegXS sx = dpf.scaled_xs(leaf);
@@ -251,15 +251,15 @@ static void rdpf_timing(MPCIO &mpcio, yield_t &yield,
     for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
         boost::asio::post(pool, [&mpcio, thread_num, depth] {
             MPCTIO tio(mpcio, thread_num);
-            size_t &op_counter = tio.aes_ops();
+            size_t &aes_ops = tio.aes_ops();
             if (mpcio.player == 2) {
                 RDPFPair dp = tio.rdpfpair(depth);
                 for (int i=0;i<2;++i) {
                     RDPF &dpf = dp.dpf[i];
-                    dpf.expand(op_counter);
+                    dpf.expand(aes_ops);
                     RegXS scaled_xor;
                     for (address_t x=0;x<(address_t(1)<<depth);++x) {
-                        DPFnode leaf = dpf.leaf(x, op_counter);
+                        DPFnode leaf = dpf.leaf(x, aes_ops);
                         RegXS sx = dpf.scaled_xs(leaf);
                         scaled_xor ^= sx;
                     }
@@ -271,10 +271,10 @@ static void rdpf_timing(MPCIO &mpcio, yield_t &yield,
                 RDPFTriple dt = tio.rdpftriple(depth);
                 for (int i=0;i<3;++i) {
                     RDPF &dpf = dt.dpf[i];
-                    dpf.expand(op_counter);
+                    dpf.expand(aes_ops);
                     RegXS scaled_xor;
                     for (address_t x=0;x<(address_t(1)<<depth);++x) {
-                        DPFnode leaf = dpf.leaf(x, op_counter);
+                        DPFnode leaf = dpf.leaf(x, aes_ops);
                         RegXS sx = dpf.scaled_xs(leaf);
                         scaled_xor ^= sx;
                     }
@@ -309,13 +309,13 @@ static void rdpfeval_timing(MPCIO &mpcio, yield_t &yield,
     for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
         boost::asio::post(pool, [&mpcio, thread_num, depth, start] {
             MPCTIO tio(mpcio, thread_num);
-            size_t &op_counter = tio.aes_ops();
+            size_t &aes_ops = tio.aes_ops();
             if (mpcio.player == 2) {
                 RDPFPair dp = tio.rdpfpair(depth);
                 for (int i=0;i<2;++i) {
                     RDPF &dpf = dp.dpf[i];
                     RegXS scaled_xor;
-                    auto ev = StreamEval(dpf, start, 0, op_counter, false);
+                    auto ev = StreamEval(dpf, start, 0, aes_ops, false);
                     for (address_t x=0;x<(address_t(1)<<depth);++x) {
                         DPFnode leaf = ev.next();
                         RegXS sx = dpf.scaled_xs(leaf);
@@ -330,7 +330,7 @@ static void rdpfeval_timing(MPCIO &mpcio, yield_t &yield,
                 for (int i=0;i<3;++i) {
                     RDPF &dpf = dt.dpf[i];
                     RegXS scaled_xor;
-                    auto ev = StreamEval(dpf, start, 0, op_counter, false);
+                    auto ev = StreamEval(dpf, start, 0, aes_ops, false);
                     for (address_t x=0;x<(address_t(1)<<depth);++x) {
                         DPFnode leaf = ev.next();
                         RegXS sx = dpf.scaled_xs(leaf);
@@ -367,11 +367,11 @@ static void tupleeval_timing(MPCIO &mpcio, yield_t &yield,
     for (int thread_num = 0; thread_num < num_threads; ++thread_num) {
         boost::asio::post(pool, [&mpcio, thread_num, depth, start] {
             MPCTIO tio(mpcio, thread_num);
-            size_t &op_counter = tio.aes_ops();
+            size_t &aes_ops = tio.aes_ops();
             if (mpcio.player == 2) {
                 RDPFPair dp = tio.rdpfpair(depth);
                 RegXS scaled_xor0, scaled_xor1;
-                auto ev = StreamEval(dp, start, 0, op_counter, false);
+                auto ev = StreamEval(dp, start, 0, aes_ops, false);
                 for (address_t x=0;x<(address_t(1)<<depth);++x) {
                     auto [L0, L1] = ev.next();
                     RegXS sx0 = dp.dpf[0].scaled_xs(L0);
@@ -388,7 +388,7 @@ static void tupleeval_timing(MPCIO &mpcio, yield_t &yield,
             } else {
                 RDPFTriple dt = tio.rdpftriple(depth);
                 RegXS scaled_xor0, scaled_xor1, scaled_xor2;
-                auto ev = StreamEval(dt, start, 0, op_counter, false);
+                auto ev = StreamEval(dt, start, 0, aes_ops, false);
                 for (address_t x=0;x<(address_t(1)<<depth);++x) {
                     auto [L0, L1, L2] = ev.next();
                     RegXS sx0 = dt.dpf[0].scaled_xs(L0);
@@ -438,7 +438,7 @@ static void duoram_test(MPCIO &mpcio, yield_t &yield,
         boost::asio::post(pool, [&mpcio, &yield, thread_num, depth, share] {
             size_t size = size_t(1)<<depth;
             MPCTIO tio(mpcio, thread_num);
-            // size_t &op_counter = tio.aes_ops();
+            // size_t &aes_ops = tio.aes_ops();
             Duoram<T> oram(mpcio.player, size);
             auto A = oram.flat(tio, yield);
             RegAS aidx;

+ 5 - 5
prg.hpp

@@ -14,23 +14,23 @@ static const struct PRGkey {
 // Compute one of the children of node seed; whichchild=0 for
 // the left child, 1 for the right child
 static inline void prg(__m128i &out, __m128i seed, bool whichchild,
-    size_t &op_counter)
+    size_t &aes_ops)
 {
     __m128i in = set_lsb(seed, whichchild);
     __m128i mid;
-    AES_ECB_encrypt(mid, set_lsb(seed, whichchild), prgkey.k, op_counter);
+    AES_ECB_encrypt(mid, set_lsb(seed, whichchild), prgkey.k, aes_ops);
     out = mid ^ in;
 }
 
 // Compute both children of node seed
 static inline void prgboth(__m128i &left, __m128i &right, __m128i seed,
-    size_t &op_counter)
+    size_t &aes_ops)
 {
     __m128i in0 = set_lsb(seed, 0);
     __m128i in1 = set_lsb(seed, 1);
     __m128i mid0, mid1;
-    AES_ECB_encrypt(mid0, set_lsb(seed, 0), prgkey.k, op_counter);
-    AES_ECB_encrypt(mid1, set_lsb(seed, 1), prgkey.k, op_counter);
+    AES_ECB_encrypt(mid0, set_lsb(seed, 0), prgkey.k, aes_ops);
+    AES_ECB_encrypt(mid1, set_lsb(seed, 1), prgkey.k, aes_ops);
     left = mid0 ^ in0;
     right = mid1 ^ in1;
 }

+ 17 - 17
rdpf.cpp

@@ -261,7 +261,7 @@ size_t RDPF::size() const
 }
 
 // Get the leaf node for the given input
-DPFnode RDPF::leaf(address_t input, size_t &op_counter) const
+DPFnode RDPF::leaf(address_t input, size_t &aes_ops) const
 {
     // If we have a precomputed expansion, just use it
     if (expansion.size()) {
@@ -272,7 +272,7 @@ DPFnode RDPF::leaf(address_t input, size_t &op_counter) const
     DPFnode node = seed;
     for (nbits_t d=0;d<totdepth;++d) {
         bit_t dir = !!(input & (address_t(1)<<(totdepth-d-1)));
-        node = descend(node, d, dir, op_counter);
+        node = descend(node, d, dir, aes_ops);
     }
     return node;
 }
@@ -281,7 +281,7 @@ DPFnode RDPF::leaf(address_t input, size_t &op_counter) const
 //
 // This routine is slightly more efficient than repeatedly calling
 // Eval::next(), but it uses a lot more memory.
-void RDPF::expand(size_t &op_counter)
+void RDPF::expand(size_t &aes_ops)
 {
     nbits_t depth = this->depth();
     size_t num_leaves = size_t(1)<<depth;
@@ -292,10 +292,10 @@ void RDPF::expand(size_t &op_counter)
     DPFnode *path = new DPFnode[depth];
     path[0] = seed;
     for (nbits_t i=1;i<depth;++i) {
-        path[i] = descend(path[i-1], i-1, 0, op_counter);
+        path[i] = descend(path[i-1], i-1, 0, aes_ops);
     }
-    expansion[index++] = descend(path[depth-1], depth-1, 0, op_counter);
-    expansion[index++] = descend(path[depth-1], depth-1, 1, op_counter);
+    expansion[index++] = descend(path[depth-1], depth-1, 0, aes_ops);
+    expansion[index++] = descend(path[depth-1], depth-1, 1, aes_ops);
     while(index < num_leaves) {
         // Invariant: lastindex and index will both be even, and
         // index=lastindex+2
@@ -310,13 +310,13 @@ void RDPF::expand(size_t &op_counter)
         // left children.
         path[depth-how_many_1_bits] =
             descend(path[depth-how_many_1_bits-1],
-                depth-how_many_1_bits-1, 1, op_counter);
+                depth-how_many_1_bits-1, 1, aes_ops);
         for (nbits_t i = depth-how_many_1_bits; i < depth-1; ++i) {
-            path[i+1] = descend(path[i], i, 0, op_counter);
+            path[i+1] = descend(path[i], i, 0, aes_ops);
         }
         lastindex = index;
-        expansion[index++] = descend(path[depth-1], depth-1, 0, op_counter);
-        expansion[index++] = descend(path[depth-1], depth-1, 1, op_counter);
+        expansion[index++] = descend(path[depth-1], depth-1, 0, aes_ops);
+        expansion[index++] = descend(path[depth-1], depth-1, 1, aes_ops);
     }
 
     delete[] path;
@@ -349,23 +349,23 @@ RDPFTriple::RDPFTriple(MPCTIO &tio, yield_t &yield,
 
 RDPFTriple::node RDPFTriple::descend(const RDPFTriple::node &parent,
     nbits_t parentdepth, bit_t whichchild,
-    size_t &op_counter) const
+    size_t &aes_ops) const
 {
     auto [P0, P1, P2] = parent;
     DPFnode C0, C1, C2;
-    C0 = dpf[0].descend(P0, parentdepth, whichchild, op_counter);
-    C1 = dpf[1].descend(P1, parentdepth, whichchild, op_counter);
-    C2 = dpf[2].descend(P2, parentdepth, whichchild, op_counter);
+    C0 = dpf[0].descend(P0, parentdepth, whichchild, aes_ops);
+    C1 = dpf[1].descend(P1, parentdepth, whichchild, aes_ops);
+    C2 = dpf[2].descend(P2, parentdepth, whichchild, aes_ops);
     return std::make_tuple(C0,C1,C2);
 }
 
 RDPFPair::node RDPFPair::descend(const RDPFPair::node &parent,
     nbits_t parentdepth, bit_t whichchild,
-    size_t &op_counter) const
+    size_t &aes_ops) const
 {
     auto [P0, P1] = parent;
     DPFnode C0, C1;
-    C0 = dpf[0].descend(P0, parentdepth, whichchild, op_counter);
-    C1 = dpf[1].descend(P1, parentdepth, whichchild, op_counter);
+    C0 = dpf[0].descend(P0, parentdepth, whichchild, aes_ops);
+    C1 = dpf[1].descend(P1, parentdepth, whichchild, aes_ops);
     return std::make_tuple(C0,C1);
 }

+ 6 - 6
rdpf.hpp

@@ -61,10 +61,10 @@ struct RDPF : public DPF {
     // Get the leaf node for the given input
     //
     // Cost: depth AES operations
-    DPFnode leaf(address_t input, size_t &op_counter) const;
+    DPFnode leaf(address_t input, size_t &aes_ops) const;
 
     // Expand the DPF if it's not already expanded
-    void expand(size_t &op_counter);
+    void expand(size_t &aes_ops);
 
     // Get the bit-shared unit vector entry from the leaf node
     inline RegBS unit_bs(DPFnode leaf) const {
@@ -153,7 +153,7 @@ struct RDPFTriple {
 
     // Descend the three RDPFs in lock step
     node descend(const node &parent, nbits_t parentdepth,
-        bit_t whichchild, size_t &op_counter) const;
+        bit_t whichchild, size_t &aes_ops) const;
 
     // Templated versions of functions to get DPF components and outputs
     // so that the appropriate one can be selected with a template
@@ -207,7 +207,7 @@ struct RDPFPair {
 
     // Descend the two RDPFs in lock step
     node descend(const node &parent, nbits_t parentdepth,
-        bit_t whichchild, size_t &op_counter) const;
+        bit_t whichchild, size_t &aes_ops) const;
 
     // Templated versions of functions to get DPF components and outputs
     // so that the appropriate one can be selected with a template
@@ -229,7 +229,7 @@ struct RDPFPair {
 template <typename T>
 class StreamEval {
     const T &rdpf;
-    size_t &op_counter;
+    size_t &aes_ops;
     bool use_expansion;
     nbits_t depth;
     address_t counter_xor_offset;
@@ -249,7 +249,7 @@ public:
     // DPF((start+2) XOR xor_offset)
     // etc.
     StreamEval(const T &rdpf, address_t start,
-        address_t xor_offset, size_t &op_counter,
+        address_t xor_offset, size_t &aes_ops,
         bool use_expansion = true);
 
     // Get the next value (or tuple of values) from the evaluator

+ 6 - 6
rdpf.tcc

@@ -12,8 +12,8 @@
 // etc.
 template <typename T>
 StreamEval<T>::StreamEval(const T &rdpf, address_t start,
-    address_t xor_offset, size_t &op_counter,
-    bool use_expansion) : rdpf(rdpf), op_counter(op_counter),
+    address_t xor_offset, size_t &aes_ops,
+    bool use_expansion) : rdpf(rdpf), aes_ops(aes_ops),
     use_expansion(use_expansion), counter_xor_offset(xor_offset)
 {
     depth = rdpf.depth();
@@ -40,7 +40,7 @@ StreamEval<T>::StreamEval(const T &rdpf, address_t start,
         bool xor_offset_bit =
             !!(counter_xor_offset & (address_t(1)<<(depth-i)));
         path[i] = rdpf.descend(path[i-1], i-1,
-            dir ^ xor_offset_bit, op_counter);
+            dir ^ xor_offset_bit, aes_ops);
     }
 }
 
@@ -87,16 +87,16 @@ typename T::node StreamEval<T>::next()
         path[depth-how_many_1_bits] =
             rdpf.descend(path[depth-how_many_1_bits-1],
                 depth-how_many_1_bits-1,
-                top_changed_bit ^ xor_offset_bit, op_counter);
+                top_changed_bit ^ xor_offset_bit, aes_ops);
         for (nbits_t i = depth-how_many_1_bits; i < depth-1; ++i) {
             bool xor_offset_bit =
                 !!(counter_xor_offset & (address_t(1) << (depth-i-1)));
-            path[i+1] = rdpf.descend(path[i], i, xor_offset_bit, op_counter);
+            path[i+1] = rdpf.descend(path[i], i, xor_offset_bit, aes_ops);
         }
     }
     bool xor_offset_bit = counter_xor_offset & 1;
     typename T::node leaf = rdpf.descend(path[depth-1], depth-1,
-        (nextindex & 1) ^ xor_offset_bit, op_counter);
+        (nextindex & 1) ^ xor_offset_bit, aes_ops);
     pathindex = nextindex;
     nextindex = (nextindex + 1) & indexmask;
     return leaf;