Skip to content

Commit b58906d

Browse files
committed
Add output write and overall run script
1 parent 60fed47 commit b58906d

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

homo/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LDFLAGS=-g
77

88
.PHONY : all clean
99

10-
all : raymond dct encode test sender reciever
10+
all : raymond dct encode test server client
1111

1212

1313
raymond : raymond.cpp

homo/server.cpp

+24-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using namespace seal;
77

88
auto start = std::chrono::steady_clock::now();
9+
auto diff = std::chrono::steady_clock::now() - start;
910
void 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
}

keys/.placeholder

Whitespace-only changes.

run.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cd homo
2+
make server
3+
make client
4+
cd ../bin
5+
6+
./client
7+
./server
8+
./client RECEIVE

0 commit comments

Comments
 (0)