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

Function main

Utils/export-trunc.cpp:8–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "Machines/minimal.hpp"
7
8int main(int argc, const char** argv)
9{
10 assert(argc > 1);
11 int my_number = atoi(argv[1]);
12 int port_base = 9999;
13 Names N(my_number, 3, "localhost", port_base);
14
15 typedef Rep3Share2<64> share_type;
16 Machine<share_type> machine(N);
17
18 int n = 1000;
19 vector<share_type> inputs;
20 for (int i = 0; i < n; i++)
21 inputs.push_back(share_type::constant(i, my_number));
22
23 vector<FunctionArgument> args = {inputs};
24 vector<share_type> results(n);
25 FunctionArgument res(results);
26
27 machine.run_function("trunc_pr", res, args);
28
29 Opener<share_type> MC(machine.get_player(), machine.get_sint_mac_key());
30 MC.init_open();
31 for (auto& x : results)
32 MC.prepare_open(x);
33 MC.exchange();
34
35 if (my_number == 0)
36 {
37 cout << "res: ";
38 for (int i = 0; i < 10; i++)
39 cout << MC.finalize_open() << " ";
40 cout << endl;
41 }
42 else
43 {
44 for (int i = 0; i < n; i++)
45 {
46 auto x = MC.finalize_open();
47 if (not (x == (i / 4) or x == (i / 4 + 1)))
48 {
49 cerr << "error at " << i << ": " << x << endl;
50 exit(1);
51 }
52 }
53 }
54}

Callers

nothing calls this directly

Calls 8

run_functionMethod · 0.80
get_sint_mac_keyMethod · 0.80
push_backMethod · 0.45
get_playerMethod · 0.45
init_openMethod · 0.45
prepare_openMethod · 0.45
exchangeMethod · 0.45
finalize_openMethod · 0.45

Tested by

no test coverage detected