mirror of
https://github.com/data61/MP-SPDZ.git
synced 2026-01-09 13:37:58 -05:00
Various improvements.
This commit is contained in:
@@ -7,33 +7,62 @@
|
||||
|
||||
#include "Math/gfp.hpp"
|
||||
#include "Machines/SPDZ.hpp"
|
||||
#include "Protocols/CowGearShare.h"
|
||||
#include "Protocols/CowGearPrep.hpp"
|
||||
|
||||
template<class T>
|
||||
void run(char** argv, int prime_length);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
typedef Share<gfp> T;
|
||||
// bit length of prime
|
||||
const int prime_length = 128;
|
||||
|
||||
// compute number of 64-bit words needed
|
||||
const int n_limbs = (prime_length + 63) / 64;
|
||||
|
||||
// need player number and number of players
|
||||
if (argc < 3)
|
||||
{
|
||||
cerr << "Usage: " << argv[0] << "<my number: 0/1/...> <total number of players>" << endl;
|
||||
cerr << "Usage: " << argv[0] << "<my number: 0/1/...> <total number of players> [protocol]" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
string protocol = "MASCOT";
|
||||
if (argc > 3)
|
||||
protocol = argv[3];
|
||||
|
||||
if (protocol == "MASCOT")
|
||||
run<Share<gfp_<0, n_limbs>>>(argv, prime_length);
|
||||
else if (protocol == "CowGear")
|
||||
run<CowGearShare<gfp_<0, n_limbs>>>(argv, prime_length);
|
||||
else if (protocol == "SPDZ2k")
|
||||
run<Spdz2kShare<64, 64>>(argv, 0);
|
||||
else
|
||||
{
|
||||
cerr << "Unknown protocol: " << protocol << endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void run(char** argv, int prime_length)
|
||||
{
|
||||
// set up networking on localhost
|
||||
Names N;
|
||||
Server::start_networking(N, atoi(argv[1]), atoi(argv[2]), "localhost", 9999);
|
||||
int my_number = atoi(argv[1]);
|
||||
int n_parties = atoi(argv[2]);
|
||||
int port_base = 9999;
|
||||
Server::start_networking(N, my_number, n_parties, "localhost", port_base);
|
||||
CryptoPlayer P(N);
|
||||
|
||||
// initialize fields
|
||||
gfp::init_default(128);
|
||||
gfp1::init_default(128, false);
|
||||
T::bit_type::mac_key_type::init_field();
|
||||
T::clear::init_default(prime_length);
|
||||
T::clear::next::init_default(prime_length, false);
|
||||
|
||||
// must initialize MAC key for security of some protocols
|
||||
typename T::mac_key_type mac_key;
|
||||
T::read_or_generate_mac_key("", P, mac_key);
|
||||
typename T::bit_type::mac_key_type binary_mac_key;
|
||||
T::bit_type::part_type::read_or_generate_mac_key("", P, binary_mac_key);
|
||||
|
||||
// global OT setup
|
||||
BaseMachine machine;
|
||||
@@ -43,7 +72,10 @@ int main(int argc, char** argv)
|
||||
DataPositions usage;
|
||||
usage.set_num_players(P.num_players());
|
||||
|
||||
// binary MAC check setup
|
||||
// initialize binary computation
|
||||
T::bit_type::mac_key_type::init_field();
|
||||
typename T::bit_type::mac_key_type binary_mac_key;
|
||||
T::bit_type::part_type::read_or_generate_mac_key("", P, binary_mac_key);
|
||||
GC::ShareThread<typename T::bit_type> thread(N,
|
||||
OnlineOptions::singleton, P, binary_mac_key, usage);
|
||||
|
||||
@@ -55,7 +87,7 @@ int main(int argc, char** argv)
|
||||
SubProcessor<T> processor(output, preprocessing, P);
|
||||
|
||||
// input protocol
|
||||
typename T::Input input(processor);
|
||||
typename T::Input input(processor, output);
|
||||
|
||||
// multiplication protocol
|
||||
typename T::Protocol protocol(P);
|
||||
|
||||
Reference in New Issue
Block a user