@@ -34,6 +34,9 @@ int main(int argc, const char** argv) {
34
34
int coeff_modulus = COEFF_MODULUS;
35
35
int resized_width = 0 ;
36
36
int resized_height = 0 ;
37
+ int degree = 12 ;
38
+ double delta = 0.5 ;
39
+ int order = 64 ;
37
40
38
41
39
42
try {
@@ -44,6 +47,9 @@ int main(int argc, const char** argv) {
44
47
(" f,file" , " Filename for input file to be resized" , cxxopts::value<std::string>())
45
48
(" v,verbose" , " Verbose logging output" , cxxopts::value<bool >(verbose))
46
49
(" o,outfile" , " Filename for homomorphic ciphertext to be saved to" , cxxopts::value<std::string>())
50
+ (" delta" , " Delta for step function size" , cxxopts::value<double >())
51
+ (" order" , " Order of approximation for step function approximation Fourier series" , cxxopts::value<int >())
52
+ (" degree" , " Terms for step function approximation" , cxxopts::value<int >())
47
53
(" ncoeff" , " Number of coefficients for integer portion of encoding" , cxxopts::value<int >())
48
54
(" fcoeff" , " Number of coefficients for fractional portion of encoding" , cxxopts::value<int >())
49
55
(" cmod" , " Coefficient Modulus for polynomial encoding" , cxxopts::value<int >())
@@ -64,6 +70,9 @@ int main(int argc, const char** argv) {
64
70
if (result.count (" fcoeff" )) n_fractional_coeffs = result[" fcoeff" ].as <int >();
65
71
if (result.count (" pmod" )) plain_modulus = result[" pmod" ].as <int >();
66
72
if (result.count (" cmod" )) coeff_modulus = result[" cmod" ].as <int >();
73
+ if (result.count (" degree" )) degree = result[" degree" ].as <int >();
74
+ if (result.count (" order" )) order = result[" order" ].as <int >();
75
+ if (result.count (" delta" )) delta = result[" delta" ].as <double >();
67
76
if (result.count (" n_poly_base" )) n_poly_base = result[" base" ].as <int >();
68
77
}
69
78
catch (const cxxopts::OptionException& e) {
@@ -116,35 +125,26 @@ int main(int argc, const char** argv) {
116
125
Ciphertext c, index , elem, count;
117
126
std::vector<std::vector<Ciphertext>> res;
118
127
for (int i = 0 ; i < 3 ; i++) {
119
- std::cout << " Color " << i << std::endl;
120
128
encryptor.encrypt (encoder.encode (0 ), index );
121
129
std::vector<Ciphertext> channel;
122
130
for (int j = 0 ; j < width * height; j++) {
123
131
encryptor.encrypt (encoder.encode (0 ), c);
124
132
channel.push_back (c);
125
133
}
126
134
for (int j = 0 ; j < pairs[i]; j++) {
127
- std::cout << " Run " << j << std::endl;
128
135
std::vector<Ciphertext> run;
129
136
elem.load (myfile);
130
137
count.load (myfile);
131
- debug_approximated_step (elem, index , count, 63 , 0.5 , run, evaluator, encoder, encryptor, decryptor);
138
+ approximated_step (elem, index , count, order, degree, delta, width, height , run, evaluator, encoder, encryptor, decryptor);
132
139
for (int k = 0 ; k < width * height; k++) {
133
140
// Plaintext p;
134
141
// decryptor.decrypt(run[k], p);
135
142
// std::cout << encoder.decode(p) << '\t';
136
143
evaluator.add (channel[k], run[k]);
137
144
}
138
- std::cout << std::endl;
139
145
evaluator.add (index , count);
140
146
}
141
147
res.push_back (channel);
142
- for (int j = 0 ; j < width * height; j++) {
143
- Plaintext p;
144
- decryptor.decrypt (res[i][j], p);
145
- std::cout << encoder.decode (p) << ' \t ' ;
146
- }
147
- std::cout << std::endl;
148
148
}
149
149
for (int i = 0 ; i < width * height; i++) {
150
150
for (int j = 0 ; j < 3 ; j++) {
0 commit comments