forked from data61/MP-SPDZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TinyMC.h
78 lines (63 loc) · 1.42 KB
/
TinyMC.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
77
78
/*
* TinyMC.h
*
*/
#ifndef GC_TINYMC_H_
#define GC_TINYMC_H_
#include "Protocols/MAC_Check_Base.h"
namespace GC
{
template<class T>
class TinyMC : public MAC_Check_Base<T>
{
typename T::part_type::MAC_Check part_MC;
PointerVector<int> sizes;
public:
static void setup(Player& P)
{
T::part_type::MAC_Check::setup(P);
}
static void teardown()
{
T::part_type::MAC_Check::teardown();
}
TinyMC(typename T::mac_key_type mac_key) :
part_MC(mac_key)
{
this->alphai = mac_key;
}
typename T::part_type::MAC_Check& get_part_MC()
{
return part_MC;
}
void init_open(const Player& P, int n)
{
part_MC.init_open(P);
sizes.clear();
sizes.reserve(n);
}
void prepare_open(const T& secret, int = -1)
{
for (auto& part : secret.get_regs())
part_MC.prepare_open(part);
sizes.push_back(secret.get_regs().size());
}
void exchange(const Player& P)
{
part_MC.exchange(P);
}
typename T::open_type finalize_raw()
{
int n = sizes.next();
typename T::open_type opened = 0;
for (int i = 0; i < n; i++)
opened += typename T::open_type(part_MC.finalize_raw().get_bit(0)) << i;
return opened;
}
void Check(const Player& P)
{
part_MC.Check(P);
}
};
} /* namespace GC */
#endif /* GC_TINYMC_H_ */