6
6
using namespace seal ;
7
7
8
8
auto start = std::chrono::steady_clock::now();
9
+ auto diff = std::chrono::steady_clock::now() - start;
9
10
void fhe_jpg (std::vector<Ciphertext> &raw_data,
10
11
int width,
11
12
int height,
@@ -46,7 +47,7 @@ int main(int argc, char** argv) {
46
47
SecretKey secret_key;
47
48
public_key.load (pkfile);
48
49
secret_key.load (skfile);
49
- auto diff = std::chrono::steady_clock::now () - start;
50
+ diff = std::chrono::steady_clock::now () - start;
50
51
std::cout << " Key Load Time: " ;
51
52
std::cout << chrono::duration<double , milli>(diff).count () << " ms" << std::endl;
52
53
pkfile.close (); skfile.close ();
@@ -94,13 +95,11 @@ int main(int argc, char** argv) {
94
95
*/
95
96
96
97
// Actually run the FHE calculations necessary...
97
- start = std::chrono::steady_clock::now ();
98
98
fhe_jpg (nothingpersonnel, WIDTH, HEIGHT, evaluator, encoder, encryptor);
99
- diff = std::chrono::steady_clock::now () - start;
100
- std::cout << " DCT/QUANT calculation time: " ;
101
- std::cout << chrono::duration<double , milli>(diff).count () << " ms" << std::endl;
102
99
103
100
101
+
102
+
104
103
return 0 ;
105
104
}
106
105
@@ -110,11 +109,29 @@ void fhe_jpg(std::vector<Ciphertext> &raw_data,
110
109
Evaluator &evaluator,
111
110
FractionalEncoder &encoder,
112
111
Encryptor &encryptor) {
113
- std::cout << " Got here" << std::endl;
112
+ // Perform DCT and quantization
113
+ start = std::chrono::steady_clock::now ();
114
114
std::vector<std::vector<Ciphertext>> blocks = split_image_eight_block (raw_data, width, height);
115
- std::cout << " Got here" << std::endl;
116
115
for (int i = 0 ; i < blocks.size (); i++) {
117
116
encrypted_dct (blocks[i], evaluator, encoder, encryptor);
118
117
quantize_fhe (blocks[i], S_STD_LUM_QUANT, evaluator, encoder, encryptor);
119
118
}
119
+ diff = std::chrono::steady_clock::now () - start;
120
+ std::cout << " DCT/QUANT calculation time: " ;
121
+ std::cout << chrono::duration<double , milli>(diff).count () << " ms" << std::endl;
122
+
123
+ // Write output
124
+ std::ofstream myfile;
125
+ myfile.open (" ../image/zoop.txt" );
126
+ start = std::chrono::steady_clock::now ();
127
+ for (int i = 0 ; i < blocks.size (); i++) {
128
+ for (int j = 0 ; j < blocks[i].size (); j++) {
129
+ blocks[i][j].save (myfile);
130
+ }
131
+ }
132
+ myfile.close ();
133
+ diff = std::chrono::steady_clock::now () - start;
134
+ std::cout << " Ciphertext write time: " ;
135
+ std::cout << chrono::duration<double , milli>(diff).count () << " ms" << std::endl;
136
+
120
137
}
0 commit comments