forked from bristolcrypto/SPDZ-2
-
Notifications
You must be signed in to change notification settings - Fork 272
/
CcdPrep.h
98 lines (79 loc) · 2.13 KB
/
CcdPrep.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
/*
* CcdPrep.h
*
*/
#ifndef GC_CCDPREP_H_
#define GC_CCDPREP_H_
#include "Protocols/ReplicatedPrep.h"
class DataPositions;
namespace GC
{
template<class T> class ShareThread;
template<class T>
class CcdPrep : public BufferPrep<T>
{
typename T::part_type::LivePrep part_prep;
SubProcessor<typename T::part_type>* part_proc;
public:
static const bool use_part = true;
CcdPrep(DataPositions& usage) :
BufferPrep<T>(usage), part_prep(usage), part_proc(0)
{
}
CcdPrep(SubProcessor<T>*, DataPositions& usage) :
CcdPrep(usage)
{
}
~CcdPrep();
void set_protocol(typename T::Protocol& protocol);
Preprocessing<typename T::part_type>& get_part()
{
return part_prep;
}
void buffer_triples()
{
assert(part_proc);
this->triples.push_back({});
for (auto& x : this->triples.back())
x.resize_regs(T::default_length);
for (int i = 0; i < T::default_length; i++)
{
auto triple = part_prep.get_triple(1);
for (int j = 0; j < 3; j++)
this->triples.back()[j].get_bit(j) = triple[j];
}
}
void buffer_bits()
{
assert(part_proc);
for (int i = 0; i < OnlineOptions::singleton.batch_size; i++)
{
typename T::part_type tmp;
part_prep.get_one_no_count(DATA_BIT, tmp);
this->bits.push_back(tmp);
}
}
void buffer_squares()
{
throw not_implemented();
}
void buffer_inverses()
{
throw not_implemented();
}
void buffer_inputs(int player)
{
this->inputs[player].push_back({});
this->inputs[player].back().share.resize_regs(T::default_length);
for (int i = 0; i < T::default_length; i++)
{
typename T::part_type::open_type tmp;
part_prep.get_input(this->inputs[player].back().share.get_reg(i),
tmp, player);
this->inputs[player].back().value ^=
(typename T::clear(tmp.get_bit(0)) << i);
}
}
};
} /* namespace GC */
#endif /* GC_CCDPREP_H_ */