-
Notifications
You must be signed in to change notification settings - Fork 0
/
fhe.h
108 lines (90 loc) · 2.07 KB
/
fhe.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
#include <utility>
using std::pair;
//Bitstring type, used to encode items
using bitstr_t = long unsigned int;
//Abstract parameter type
class Parms_wrapper{
};
using parms_t = Parms_wrapper;
//Abstract plaintext type
class Pt_wrapper{
public:
Pt_wrapper(const parms_t & p, const bitstr_t val = 0) {}
void set_to_random_nonzero(){
return;
}
bool is_zero() const {
return false;
}
};
using ptext_t = Pt_wrapper;
//Abstract ciphertext type
class Ct_wrapper{
public:
Ct_wrapper(const parms_t & p) {}
//Arithmetic operators available
//Ciphertext-ciphertext operations
Ct_wrapper & operator+(const Ct_wrapper & other) const {
return other;
}
Ct_wrapper & operator*(const Ct_wrapper & other) const {
return other;
}
Ct_wrapper & operator*=(const Ct_wrapper & other){
return other;
}
Ct_wrapper & operator+=(const Ct_wrapper & other){
return other;
}
Ct_wrapper & operator-(const Ct_wrapper & other) const {
return other;
}
Ct_wrapper & operator-=(const Ct_wrapper & other){
return other;
}
//Ciphertext-plaintext operations
Ct_wrapper & operator+(const ptext_t & other) const {
return *this;
}
Ct_wrapper & operator*(const ptext_t & other) const {
return *this;
}
Ct_wrapper & operator*=(const ptext_t & other){
return *this;
}
Ct_wrapper & operator+=(const ptext_t & other){
return *this;
}
Ct_wrapper & operator-(const ptext_t & other) const {
return *this;
}
Ct_wrapper & operator-=(const ptext_t & other){
return *this;
}
Ct_wrapper & operator=(const Ct_wrapper & other){
return *this = other;
}
};
using ctext_t = Ct_wrapper;
//Key types
class Key_wrapper{
}
using pk_t = Key_wrapper;
using sk_t = Key_wrapper;
//Non-class FHE functions
parms_t Setup(const unsigned int lambda){
parms_t p;
return p;
}
std::pair<sk_t, pk_t> KeyGen(const parms_t & p){
std::pair<sk_t, pk_t> keypair;
return keypair;
}
ctext_t Encrypt(const ptext_t & m, const pk_t & pk){
ctext_t c;
return c;
}
ptext_t Decrypt(const ctext_t & c, const sk_t & sk){
ptext_t m;
return m;
}