|
@@ -42,68 +42,15 @@ size_t bits_per_leaf = std::is_same<leaf_t, bool>::value ? 1 : sizeof(leaf_t) *
|
|
|
bool is_packed = (sizeof(leaf_t) < sizeof(node_t));
|
|
|
size_t leaves_per_node = is_packed ? sizeof(node_t) * CHAR_BIT / bits_per_leaf : 1;
|
|
|
size_t __depth(const size_t nitems) { return std::ceil(std::log2(std::ceil(static_cast<double>(nitems) / leaves_per_node))); }
|
|
|
-
|
|
|
+size_t communication_cost = 0;
|
|
|
#include "mpc.h"
|
|
|
#include "dpfgen.h"
|
|
|
#include "share-conversion.h"
|
|
|
|
|
|
-void mpc_gen(const size_t depth, AES_KEY& prgkey, const size_t db_nitems, const size_t n_threads, std::vector<socket_t>& sockets0, std::vector<socket_t>& sockets1,
|
|
|
- __m128i** output0, int8_t ** flags0, __m128i** output1, int8_t ** flags1, dpfP2 * dpf_instance0 , dpfP2 * dpf_instance1, size_t ind,
|
|
|
- size_t socket_no = 0)
|
|
|
+void mpc_gen (const size_t depth, AES_KEY& prgkey, const size_t db_nitems,
|
|
|
+ const size_t n_threads, std::vector<socket_t>& sockets0, std::vector<socket_t>& sockets1, __m128i** output0, int8_t ** flags0, __m128i** output1, int8_t ** flags1, dpfP2 * dpf_instance0 ,
|
|
|
+ dpfP2 * dpf_instance1, size_t ind,size_t socket_no = 0)
|
|
|
{
|
|
|
-
|
|
|
- // struct cw_construction
|
|
|
- // {
|
|
|
- // __m128i rand_b, gamma_b;
|
|
|
- // uint8_t bit_b;
|
|
|
- // };
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- for(size_t j = 0; j < depth; ++j)
|
|
|
- {
|
|
|
-
|
|
|
- // __m128i rand0, rand1, gamma0, gamma1;
|
|
|
-
|
|
|
- // arc4random_buf(&rand0, sizeof(__m128i));
|
|
|
- // arc4random_buf(&rand1, sizeof(__m128i));
|
|
|
- // uint8_t bit0, bit1;
|
|
|
- // bit0 = rand();
|
|
|
- // bit0 = bit0 % 2;
|
|
|
- // bit1 = rand();
|
|
|
- // bit1 = bit1 %2;
|
|
|
-
|
|
|
- // gamma0 = (bit1 == 1) ? rand0 : _mm_setzero_si128();
|
|
|
- // gamma1 = (bit0 == 1) ? rand1 : _mm_setzero_si128();
|
|
|
-
|
|
|
-
|
|
|
- // cw_construction computecw0, computecw1;
|
|
|
-
|
|
|
- // computecw0.rand_b = rand0;
|
|
|
- // computecw0.gamma_b = gamma0;
|
|
|
- // computecw0.bit_b = bit0;
|
|
|
-
|
|
|
- // computecw1.rand_b = rand1;
|
|
|
- // computecw1.gamma_b = gamma1;
|
|
|
- // computecw1.bit_b = bit1;
|
|
|
-
|
|
|
- // boost::asio::write(sockets0[socket_no], boost::asio::buffer(&computecw0, sizeof(computecw0)));
|
|
|
- // boost::asio::write(sockets1[socket_no], boost::asio::buffer(&computecw1, sizeof(computecw1)));
|
|
|
-
|
|
|
- // #ifdef DEBUG
|
|
|
- // boost::asio::write(sockets0[socket_no], boost::asio::buffer(&rand0, sizeof(rand0)));
|
|
|
- // boost::asio::write(sockets0[socket_no], boost::asio::buffer(&gamma0, sizeof(gamma0)));
|
|
|
- // boost::asio::write(sockets0[socket_no], boost::asio::buffer(&bit0, sizeof(bit0)));
|
|
|
-
|
|
|
- // boost::asio::write(sockets1[socket_no], boost::asio::buffer(&rand1, sizeof(rand1)));
|
|
|
- // boost::asio::write(sockets1[socket_no], boost::asio::buffer(&gamma1, sizeof(gamma1)));
|
|
|
- // boost::asio::write(sockets1[socket_no], boost::asio::buffer(&bit1, sizeof(bit1)));
|
|
|
- // #endif
|
|
|
- }
|
|
|
-
|
|
|
- // boost::asio::read(sockets0[socket_no+1], boost::asio::buffer(&dpf_instance0[ind], sizeof(dpfP2)));
|
|
|
- // boost::asio::read(sockets1[socket_no+1], boost::asio::buffer(&dpf_instance1[ind], sizeof(dpfP2)));
|
|
|
-
|
|
|
evaluate_dpfs(db_nitems, dpf_instance0[ind], prgkey, 0, db_nitems-1, output0[ind], flags0[ind], false, ind);
|
|
|
evaluate_dpfs(db_nitems, dpf_instance1[ind], prgkey, 0, db_nitems-1, output1[ind], flags1[ind], true , ind);
|
|
|
|