forked from bristolcrypto/SPDZ-2
-
Notifications
You must be signed in to change notification settings - Fork 272
/
TinierShare.h
142 lines (114 loc) · 2.68 KB
/
TinierShare.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* TinierShare.h
*
*/
#ifndef GC_TINIERSHARE_H_
#define GC_TINIERSHARE_H_
#include "Processor/DummyProtocol.h"
#include "Protocols/Share.h"
#include "Math/Bit.h"
class gf2n_mac_key : public gf2n_short
{
public:
gf2n_mac_key()
{
}
template<class T>
gf2n_mac_key(const T& other) :
gf2n_short(other)
{
}
};
namespace GC
{
template<class T> class TinierSecret;
template<class T> class TinierSharePrep;
template<class T>
class TinierShare: public Share_<SemiShare<Bit>, SemiShare<T>>,
public ShareSecret<TinierSecret<T>>
{
typedef TinierShare This;
public:
typedef Share_<SemiShare<Bit>, SemiShare<T>> super;
typedef T mac_key_type;
typedef T mac_type;
typedef T sacri_type;
typedef Share<T> input_check_type;
typedef This prep_type;
typedef This prep_check_type;
typedef This bit_prep_type;
typedef MAC_Check_<This> MAC_Check;
typedef Direct_MAC_Check<This> Direct_MC;
typedef TinierSharePrep<This> LivePrep;
typedef ::Input<This> Input;
typedef Beaver<This> Protocol;
typedef NPartyTripleGenerator<TinierSecret<T>> TripleGenerator;
typedef void DynamicMemory;
typedef SwitchableOutput out_type;
typedef This small_type;
typedef TinierSecret<T> whole_type;
static const int default_length = 1;
static const bool expensive_triples = true;
static string name()
{
return "tinier share";
}
static string type_string()
{
return "Tinier";
}
static string type_short()
{
return "TT";
}
static ShareThread<TinierSecret<T>>& get_party()
{
return ShareThread<TinierSecret<T>>::s();
}
static MAC_Check* new_mc(mac_key_type mac_key)
{
return new MAC_Check(mac_key);
}
TinierShare()
{
}
TinierShare(const super& other) :
super(other)
{
}
TinierShare(const typename super::share_type& share, const typename super::mac_type& mac) :
super(share, mac)
{
}
TinierShare(const TinierSecret<T>& other);
void XOR(const This& a, const This& b)
{
*this = a + b;
}
This operator^(const This& other) const
{
return *this + other;
}
This& operator^=(const This& other)
{
*this += other;
return *this;
}
void public_input(bool input)
{
auto& party = get_party();
*this = super::constant(input, party.P->my_num(),
party.MC->get_alphai());
}
This lsb() const
{
return *this;
}
This get_bit(int i)
{
assert(i == 0);
return lsb();
}
};
} /* namespace GC */
#endif /* GC_TINIERSHARE_H_ */