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

Method run

Machines/TripleMachine.cpp:173–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173void TripleMachine::run()
174{
175 cout << "my_num: " << my_num << endl;
176 network_opts.start_networking(N[0], my_num);
177 nConnections = 1;
178 if (bonding)
179 {
180 if (network_opts.ip_filename.empty())
181 {
182 cerr << "Bonding only works with --ip-file-name" << endl;
183 exit(1);
184 }
185 N[1].init(my_num, network_opts.portnum_base + 1000,
186 network_opts.ip_filename + "2", nplayers);
187 nConnections = 2;
188 }
189 // do the base OTs
190 PlainPlayer P(N[0], "base");
191 OTTripleSetup setup(P, true);
192 player = &P;
193
194 vector<GeneratorThread*> generators(nthreads);
195 vector<pthread_t> threads(nthreads);
196
197 for (int i = 0; i < nthreads; i++)
198 {
199 if (prime)
200 generators[i] = new_generator<Share<gfpvar1>>(setup, i, mac_keyp);
201 else if (z2k)
202 {
203 if (z2k == 32 and z2s == 32)
204 generators[i] = new_generator<Spdz2kShare<32, 32>>(setup, i, mac_keyz);
205 else if (z2k == 64 and z2s == 64)
206 generators[i] = new_generator<Spdz2kShare<64, 64>>(setup, i, mac_keyz);
207 else if (z2k == 64 and z2s == 48)
208 generators[i] = new_generator<Spdz2kShare<64, 48>>(setup, i, mac_keyz);
209 else if (z2k == 66 and z2s == 64)
210 generators[i] = new_generator<Spdz2kShare<66, 64>>(setup, i, mac_keyz);
211 else if (z2k == 66 and z2s == 48)
212 generators[i] = new_generator<Spdz2kShare<66, 48>>(setup, i, mac_keyz);
213#ifdef RING_SIZE
214 else if (z2k == RING_SIZE and z2s == SPDZ2K_DEFAULT_SECURITY)
215 generators[i] = new_generator<Spdz2kShare<RING_SIZE, SPDZ2K_DEFAULT_SECURITY>>(setup, i, mac_keyz);
216#endif
217 else
218 throw runtime_error("not compiled for k=" + to_string(z2k) + " and s=" + to_string(z2s));
219 }
220 else
221 generators[i] = new_generator<Share<gf2n>>(setup, i, mac_key2);
222 }
223 ntriples = generators[0]->nTriples * nthreads;
224 cout <<"Setup generators\n";
225 for (int i = 0; i < nthreads; i++)
226 {
227 // lock before starting thread to avoid race condition
228 generators[i]->lock();
229 pthread_create(&threads[i], 0, run_ngenerator_thread, generators[i]);
230 }

Callers

nothing calls this directly

Calls 13

timeval_diff_in_secondsFunction · 0.85
to_stringFunction · 0.50
start_networkingMethod · 0.45
emptyMethod · 0.45
initMethod · 0.45
lockMethod · 0.45
waitMethod · 0.45
signalMethod · 0.45
unlockMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected