/* * ReplicatedRingMachine.hpp * */ #ifndef PROCESSOR_RINGMACHINE_HPP_ #define PROCESSOR_RINGMACHINE_HPP_ #include "RingMachine.h" #include "HonestMajorityMachine.h" #include "Processor/RingOptions.h" #include "Tools/ezOptionParser.h" #include "Math/gf2n.h" #include "OnlineMachine.hpp" #include "OnlineOptions.hpp" template class U, template class V> HonestMajorityRingMachine::HonestMajorityRingMachine(int argc, const char** argv, int nplayers) { ez::ezOptionParser opt; HonestMajorityRingMachine(argc, argv, opt, nplayers); } template class U, template class V> HonestMajorityRingMachine::HonestMajorityRingMachine(int argc, const char** argv, ez::ezOptionParser& opt, int nplayers) { OnlineOptions online_opts(opt, argc, argv, U<64>()); RingMachine(argc, argv, opt, online_opts, nplayers); } inline void ring_domain_error(int R) { cerr << "not compiled for " << R << "-bit computation, " << endl; cerr << "compile with -DRING_SIZE=" << R << endl; exit(1); } template class U, template class V, class W> RingMachine::RingMachine(int argc, const char** argv, ez::ezOptionParser& opt, OnlineOptions& online_opts, int nplayers) { assert(nplayers or U<64>::variable_players); RingOptions opts(opt, argc, argv); W machine(argc, argv, opt, online_opts, gf2n(), nplayers); int R = opts.ring_size_from_opts_or_schedule(online_opts.progname); #define X(L) \ if (R == L) \ { \ machine.template run, V>(); \ return; \ } X(64) #ifndef FEWER_RINGS X(72) X(128) X(192) #endif #ifdef RING_SIZE X(RING_SIZE) #endif #undef X ring_domain_error(R); } template class U, template class V> HonestMajorityRingMachineWithSecurity::HonestMajorityRingMachineWithSecurity( int argc, const char** argv, ez::ezOptionParser& opt) { OnlineOptions online_opts(opt, argc, argv, U<64, 40>()); RingOptions opts(opt, argc, argv); HonestMajorityMachine machine(argc, argv, opt, online_opts); int R = opts.ring_size_from_opts_or_schedule(online_opts.progname); #define Y(K, S) \ case S: \ machine.run, V>(); \ break; #define X(K) \ if (R == K) \ { \ int S = online_opts.security_parameter; \ switch (S) \ { \ Y(K, DEFAULT_SECURITY) \ default: \ cerr << "not compiled for security parameter " << to_string(S) << endl; \ cerr << "add 'Y(K, " << S << ")' to " __FILE__ ", line 76" << endl; \ cerr << "or compile with -DDEFAULT_SECURITY=" << S << endl; \ exit(1); \ } \ return; \ } X(64) #ifdef RING_SIZE X(RING_SIZE) #endif #ifndef FEWER_RINGS X(72) X(128) #endif #undef X ring_domain_error(R); } #endif /* PROCESSOR_RINGMACHINE_HPP_ */