#include // arc4random_buf #include "online.hpp" #include "mpcops.hpp" #include "rdpf.hpp" static void online_test(MPCIO &mpcio, const PRACOptions &opts, char **args) { nbits_t nbits = VALUE_BITS; if (*args) { nbits = atoi(*args); } size_t memsize = 9; MPCTIO tio(mpcio, 0); bool is_server = (mpcio.player == 2); RegAS *A = new RegAS[memsize]; value_t V; RegBS F0, F1; RegXS X; if (!is_server) { A[0].randomize(); A[1].randomize(); F0.randomize(); A[4].randomize(); F1.randomize(); A[6].randomize(); A[7].randomize(); X.randomize(); arc4random_buf(&V, sizeof(V)); printf("A:\n"); for (size_t i=0; i coroutines; coroutines.emplace_back( [&](yield_t &yield) { mpc_mul(tio, yield, A[2], A[0], A[1], nbits); }); coroutines.emplace_back( [&](yield_t &yield) { mpc_valuemul(tio, yield, A[3], V, nbits); }); coroutines.emplace_back( [&](yield_t &yield) { mpc_flagmult(tio, yield, A[5], F0, A[4], nbits); }); coroutines.emplace_back( [&](yield_t &yield) { mpc_oswap(tio, yield, A[6], A[7], F1, nbits); }); coroutines.emplace_back( [&](yield_t &yield) { mpc_xs_to_as(tio, yield, A[8], X, nbits); }); run_coroutines(tio, coroutines); if (!is_server) { printf("\n"); printf("A:\n"); for (size_t i=0; i> peer_scaled_xor >> peer_scaled_sum; peer_scaled_sum += dpf.scaled_sum; peer_scaled_xor ^= dpf.scaled_xor; } for (address_t x=0;x<(address_t(1)<> peer_ub >> peer_ua >> peer_sx >> peer_sa; ub ^= peer_ub; ua += peer_ua; sx ^= peer_sx; sa += peer_sa; if (ub.bshare || ua.ashare || sx.xshare || sa.ashare) { printf("**** %x %016lx %016lx %016lx\n", ub.bshare, ua.ashare, sx.xshare, sa.ashare); printf("SCALE %016lx %016lx\n", peer_scaled_xor.xshare, peer_scaled_sum.ashare); } } } printf("\n"); } } tio.send(); }); } pool.join(); } static void rdpf_timing(MPCIO &mpcio, const PRACOptions &opts, char **args) { nbits_t depth=6; if (*args) { depth = atoi(*args); ++args; } int num_threads = opts.num_threads; boost::asio::thread_pool pool(num_threads); 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(); 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); RegXS scaled_xor; scaled_xor.xshare = 0; for (address_t x=0;x<(address_t(1)<