-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMPCShare.h
executable file
·94 lines (69 loc) · 2.66 KB
/
MPCShare.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
#ifndef __MPC_SHARE_H_
#define __MPC_SHARE_H_
#include "abycore/circuit/share.h"
#include <memory>
#include <iostream>
#include "../utils/Constants.h"
#include "../utils/Utils.h"
class AbstractTypedShare {
public:
share *content;
ITERATION_COUNTER_TYPE circuitCounter;
AbstractTypedShare(share *content1, int32_t circuitCounter1) {
content = content1;
circuitCounter = circuitCounter1;
}
~AbstractTypedShare() {
delete content;
}
void print_statistics() {
std::cout << "N: " << content->get_nvals() << " Bitlen: " << content->get_bitlength() << " Max Bitlen: "
<< content->get_max_bitlength() << std::endl;
}
};
class YaoShare_ : public AbstractTypedShare {
public:
explicit YaoShare_(share *content1, int32_t circuitCounter1) : AbstractTypedShare(content1, circuitCounter1) {}
};
class BooleanShare_ : public AbstractTypedShare {
public:
explicit BooleanShare_(share *content1, int32_t circuitCounter1) : AbstractTypedShare(content1, circuitCounter1) {}
};
class ArithmeticShare_ : public AbstractTypedShare {
public:
explicit ArithmeticShare_(share *content1, int32_t circuitCounter1) : AbstractTypedShare(content1,
circuitCounter1) {}
};
class UntypedOutputShare_ : public AbstractTypedShare {
public:
explicit UntypedOutputShare_(share *content1) : AbstractTypedShare(content1, -1) {}
void get_clear_value_vec(OUTPUT_NUMBER_TYPE **vec, uint32_t *bitlen, uint32_t *nvals) {
content->get_clear_value_vec(vec, bitlen, nvals);
}
template<class T>
T get_clear_value() {
if (content->get_nvals() != 1) print_stack_trace();
assert(content->get_nvals() == 1);
return content->get_clear_value<T>();
}
};
class UntypedSharedOutputShare_ : public AbstractTypedShare {
public:
explicit UntypedSharedOutputShare_(share *content1) : AbstractTypedShare(content1, -1) {}
template<class T>
void get_shared_value_vec(T **vec, uint32_t *bitlen, uint32_t *nvals) {
content->get_clear_value_vec(vec, bitlen, nvals);
}
template<class T>
T get_shared_value() {
if (content->get_nvals() != 1) print_stack_trace();
assert(content->get_nvals() == 1);
return content->get_clear_value<T>();
}
};
typedef std::shared_ptr<YaoShare_> YaoShare;
typedef std::shared_ptr<BooleanShare_> BooleanShare;
typedef std::shared_ptr<ArithmeticShare_> ArithmeticShare;
typedef std::shared_ptr<UntypedOutputShare_> UntypedOutputShare;
typedef std::shared_ptr<UntypedSharedOutputShare_> UntypedSharedOutputShare;
#endif /* __MPC_SHARE_H_ */