MCPcopy Create free account
hub / github.com/data61/MP-SPDZ / main

Function main

Utils/l2h-example.cpp:12–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "Protocols/MascotPrep.hpp"
11
12int main(int argc, char** argv)
13{
14 // need player number and number of players
15 if (argc < 2)
16 {
17 cerr << "Usage: " << argv[0] << "<my number: 0/1/...> <total number of players>" << endl;
18 exit(1);
19 }
20
21 // set up networking on localhost
22 int my_number = atoi(argv[1]);
23 int n_parties = atoi(argv[2]);
24 int port_base = 9999;
25 Names N(my_number, n_parties, "localhost", port_base);
26
27 // template parameters are share types for integer and GF(2^n) computation
28 Machine<Share<gfp0>, Share<gf2n>> machine(N);
29
30 // protocols to be used directly
31 ProtocolSet<Share<gfp0>> set(machine.get_player(), machine.get_sint_mac_key());
32
33 // data to be used in steps
34 set.input.reset_all(machine.get_player());
35 set.input.add_from_all(2 + my_number);
36 set.input.exchange();
37 machine.Mp.MS.resize(n_parties);
38 for (int i = 0; i < n_parties; i++)
39 machine.Mp.MS[i] = set.input.finalize(i);
40
41 machine.run_step("l2h_multiplication");
42 machine.run_step("l2h_comparison");
43
44 // check results
45 // multiplication
46 assert(set.output.open(machine.Mp.MS[2], machine.get_player()) == 6);
47 // comparison
48 assert(set.output.open(machine.Mp.MS[3], machine.get_player()) == 1);
49
50 set.check();
51
52 // print usage
53 auto res = machine.stop_threads();
54 res.first.print_cost();
55}

Callers

nothing calls this directly

Calls 12

get_sint_mac_keyMethod · 0.80
run_stepMethod · 0.80
stop_threadsMethod · 0.80
print_costMethod · 0.80
get_playerMethod · 0.45
reset_allMethod · 0.45
add_from_allMethod · 0.45
exchangeMethod · 0.45
resizeMethod · 0.45
finalizeMethod · 0.45
openMethod · 0.45
checkMethod · 0.45

Tested by

no test coverage detected