forked from data61/MP-SPDZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DealerPrep.h
69 lines (58 loc) · 1.63 KB
/
DealerPrep.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
/*
* DealerPrep.h
*
*/
#ifndef GC_DEALERPREP_H_
#define GC_DEALERPREP_H_
#include "Protocols/DealerPrep.h"
#include "Protocols/ProtocolSet.h"
#include "ShiftableTripleBuffer.h"
#include "SemiSecret.h"
namespace GC
{
class DealerPrep : public BufferPrep<DealerSecret>, ShiftableTripleBuffer<DealerSecret>
{
Player* P;
public:
DealerPrep(DataPositions& usage, int = -1) :
BufferPrep<DealerSecret>(usage), P(0)
{
}
void set_protocol(DealerSecret::Protocol& protocol)
{
P = &protocol.P;
}
void buffer_triples()
{
ProtocolSetup<DealerShare<BitVec>> setup(*P);
ProtocolSet<DealerShare<BitVec>> set(*P, setup);
for (int i = 0; i < OnlineOptions::singleton.batch_size; i++)
{
auto triple = set.preprocessing.get_triple(
DealerSecret::default_length);
this->triples.push_back({{triple[0], triple[1], triple[2]}});
}
}
void buffer_bits()
{
SeededPRNG G;
if (P->my_num() != 0)
for (int i = 0; i < OnlineOptions::singleton.batch_size; i++)
this->bits.push_back(G.get_bit());
else
this->bits.resize(
this->bits.size() + OnlineOptions::singleton.batch_size);
}
void get(Dtype type, DealerSecret* data)
{
BufferPrep<DealerSecret>::get(type, data);
}
array<DealerSecret, 3> get_triple_no_count(int n_bits)
{
if (n_bits == -1)
n_bits = DealerSecret::default_length;
return ShiftableTripleBuffer<DealerSecret>::get_triple_no_count(n_bits);
}
};
}
#endif /* GC_DEALERPREP_H_ */