forked from data61/MP-SPDZ
-
Notifications
You must be signed in to change notification settings - Fork 1
/
YaoEvaluator.h
76 lines (56 loc) · 1.54 KB
/
YaoEvaluator.h
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* YaoEvaluator.h
*
*/
#ifndef YAO_YAOEVALUATOR_H_
#define YAO_YAOEVALUATOR_H_
#include "YaoGate.h"
#include "YaoEvalMaster.h"
#include "YaoCommon.h"
#include "GC/Secret.h"
#include "GC/Thread.h"
#include "Tools/MMO.h"
#include "OT/OTExtensionWithMatrix.h"
class YaoEvaluator: public GC::Thread<GC::Secret<YaoEvalWire>>,
public YaoCommon<YaoEvalWire>
{
typedef GC::Thread<GC::Secret<YaoEvalWire>> super;
protected:
static thread_local YaoEvaluator* singleton;
ReceivedMsg gates;
ReceivedMsgStore gates_store;
YaoEvalMaster& master;
friend class YaoCommon<YaoEvalWire>;
friend class YaoEvalWire;
public:
ReceivedMsg output_masks;
ReceivedMsgStore output_masks_store;
MMO mmo;
RealTwoPartyPlayer player;
OTExtensionWithMatrix ot_ext;
static YaoEvaluator& s();
YaoEvaluator(int thread_num, YaoEvalMaster& master);
bool continuous() { return master.continuous and master.machine.nthreads == 1; }
void pre_run();
void run(GC::Program& program);
void run(GC::Program& program, Player& P);
void run_from_store(GC::Program& program);
bool receive(Player& P);
void receive_to_store(Player& P);
void load_gate(YaoGate& gate);
long get_gate_id() { return gate_id(thread_num); }
int get_n_worker_threads()
{ return max(1u, thread::hardware_concurrency() / master.machine.nthreads); }
};
inline void YaoEvaluator::load_gate(YaoGate& gate)
{
gates.unserialize(gate);
}
inline YaoEvaluator& YaoEvaluator::s()
{
if (singleton)
return *singleton;
else
throw runtime_error("singleton unavailable");
}
#endif /* YAO_YAOEVALUATOR_H_ */