66using namespace seal ;
77
88auto start = std::chrono::steady_clock::now();
9+ auto diff = std::chrono::steady_clock::now() - start;
910void fhe_jpg (std::vector<Ciphertext> &raw_data,
1011 int width,
1112 int height,
@@ -46,7 +47,7 @@ int main(int argc, char** argv) {
4647 SecretKey secret_key;
4748 public_key.load (pkfile);
4849 secret_key.load (skfile);
49- auto diff = std::chrono::steady_clock::now () - start;
50+ diff = std::chrono::steady_clock::now () - start;
5051 std::cout << " Key Load Time: " ;
5152 std::cout << chrono::duration<double , milli>(diff).count () << " ms" << std::endl;
5253 pkfile.close (); skfile.close ();
@@ -94,13 +95,11 @@ int main(int argc, char** argv) {
9495 */
9596
9697 // Actually run the FHE calculations necessary...
97- start = std::chrono::steady_clock::now ();
9898 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;
10299
103100
101+
102+
104103 return 0 ;
105104}
106105
@@ -110,11 +109,29 @@ void fhe_jpg(std::vector<Ciphertext> &raw_data,
110109 Evaluator &evaluator,
111110 FractionalEncoder &encoder,
112111 Encryptor &encryptor) {
113- std::cout << " Got here" << std::endl;
112+ // Perform DCT and quantization
113+ start = std::chrono::steady_clock::now ();
114114 std::vector<std::vector<Ciphertext>> blocks = split_image_eight_block (raw_data, width, height);
115- std::cout << " Got here" << std::endl;
116115 for (int i = 0 ; i < blocks.size (); i++) {
117116 encrypted_dct (blocks[i], evaluator, encoder, encryptor);
118117 quantize_fhe (blocks[i], S_STD_LUM_QUANT, evaluator, encoder, encryptor);
119118 }
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+
120137}
0 commit comments