forked from data61/MP-SPDZ
-
Notifications
You must be signed in to change notification settings - Fork 1
/
OTTripleSetup.cpp
62 lines (55 loc) · 1.64 KB
/
OTTripleSetup.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "OTTripleSetup.h"
void OTTripleSetup::setup()
{
timeval baseOTstart, baseOTend;
gettimeofday(&baseOTstart, NULL);
G.ReSeed();
for (int i = 0; i < nbase; i++)
{
base_receiver_inputs[i] = G.get_uchar() & 1;
}
//baseReceiverInput.randomize(G);
for (int i = 0; i < nparties - 1; i++)
{
baseOTs[i]->set_receiver_inputs(base_receiver_inputs);
baseOTs[i]->exec_base(false);
baseSenderInputs[i] = baseOTs[i]->sender_inputs;
baseReceiverOutputs[i] = baseOTs[i]->receiver_outputs;
}
gettimeofday(&baseOTend, NULL);
#ifdef VERBOSE_BASEOT
double basetime = timeval_diff(&baseOTstart, &baseOTend);
cout << "\t\tBaseTime: " << basetime/1000000 << endl << flush;
#endif
for (size_t i = 0; i < baseOTs.size(); i++)
{
delete baseOTs[i];
}
// Receiver send something to force synchronization
// (since Sender finishes baseOTs before Receiver)
}
void OTTripleSetup::close_connections()
{
for (size_t i = 0; i < players.size(); i++)
{
delete players[i];
}
}
OTTripleSetup OTTripleSetup::get_fresh()
{
OTTripleSetup res = *this;
for (int i = 0; i < nparties - 1; i++)
{
BaseOT bot(nbase, 128, 0);
bot.sender_inputs = baseSenderInputs[i];
bot.receiver_outputs = baseReceiverOutputs[i];
bot.set_seeds();
bot.extend_length();
baseSenderInputs[i] = bot.sender_inputs;
baseReceiverOutputs[i] = bot.receiver_outputs;
bot.extend_length();
res.baseSenderInputs[i] = bot.sender_inputs;
res.baseReceiverOutputs[i] = bot.receiver_outputs;
}
return res;
}