Skip to content

Commit be222c3

Browse files
committed
update experiments
1 parent a352dca commit be222c3

File tree

9 files changed

+307
-293
lines changed

9 files changed

+307
-293
lines changed

experiment/encryption_time.cpp renamed to experiment/client_encryption.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "exp.hpp"
22

3-
void ipe_enc_time(const int round){
3+
void ipe_client_enc_time(const int round){
44
// Open the output files.
5-
std::ofstream file("enc_time.txt", std::ios_base::app);
6-
file << "IPE Enc Timings" << std::endl;
5+
std::ofstream file("client_enc_time.txt", std::ios_base::app);
6+
file << "IPE Timings" << std::endl;
77

88
for (int length = 10; length <= 200; length += 10){
99
// Create holder for timings.
@@ -35,75 +35,75 @@ void ipe_enc_time(const int round){
3535
file << std::endl << std::endl;
3636
}
3737

38-
void our_enc_time(const int round){
38+
void sse_client_enc_time(const int round){
3939
// Open the output files.
40-
std::ofstream file("enc_time.txt", std::ios_base::app);
41-
file << "Our Enc Timings" << std::endl;
40+
std::ofstream file("client_enc_time.txt", std::ios_base::app);
41+
file << "SSE Timings" << std::endl;
4242

43+
// Setup and Encryption time.
4344
for (int length = 10; length <= 200; length += 10){
4445
// Create holder for timings.
4546
std::chrono::duration<double, std::milli> time{};
4647

4748
// Create pp and msk.
48-
auto pp = Filter::pp_gen(1, length);
49-
auto msk = Filter::msk_gen(pp);
49+
auto msk = SseFilter::msk_gen();
5050

51-
// Perform ROUND number of Enc.
51+
// Perform ROUND number of setup.
5252
for (int i = 0; i < round; ++i){
5353
// Create a random vector of desired length.
5454
auto x = Helper::rand_int_vec(length, 1, std::numeric_limits<int>::max());
5555

5656
// Encryption timings.
5757
auto start = std::chrono::high_resolution_clock::now();
58-
std::ignore = Filter::enc(pp, msk, x);
58+
std::ignore = SseFilter::enc(msk, x);
5959
auto end = std::chrono::high_resolution_clock::now();
6060
time += end - start;
6161
}
6262

6363
// Output the time.
6464
file << "(" << length << ", " << time.count() / round << ")" << std::endl;
65-
66-
// Close the BP.
67-
BP::close();
6865
}
6966
// Create some blank spaces.
7067
file << std::endl << std::endl;
7168
}
7269

73-
void sse_enc_time(const int round){
70+
void our_client_enc_time(const int round){
7471
// Open the output files.
75-
std::ofstream file("enc_time.txt", std::ios_base::app);
76-
file << "SSE Enc Timings" << std::endl;
72+
std::ofstream file("client_enc_time.txt", std::ios_base::app);
73+
file << "Our Timings" << std::endl;
7774

78-
// Setup and Encryption time.
7975
for (int length = 10; length <= 200; length += 10){
8076
// Create holder for timings.
8177
std::chrono::duration<double, std::milli> time{};
8278

8379
// Create pp and msk.
84-
auto msk = SseFilter::msk_gen();
80+
auto pp = Filter::pp_gen(1, length);
81+
auto msk = Filter::msk_gen(pp);
8582

86-
// Perform ROUND number of setup.
83+
// Perform ROUND number of Enc.
8784
for (int i = 0; i < round; ++i){
8885
// Create a random vector of desired length.
8986
auto x = Helper::rand_int_vec(length, 1, std::numeric_limits<int>::max());
9087

9188
// Encryption timings.
9289
auto start = std::chrono::high_resolution_clock::now();
93-
std::ignore = SseFilter::enc(msk, x);
90+
std::ignore = Filter::enc(pp, msk, x);
9491
auto end = std::chrono::high_resolution_clock::now();
9592
time += end - start;
9693
}
9794

9895
// Output the time.
9996
file << "(" << length << ", " << time.count() / round << ")" << std::endl;
97+
98+
// Close the BP.
99+
BP::close();
100100
}
101101
// Create some blank spaces.
102102
file << std::endl << std::endl;
103103
}
104104

105105
void bench_enc_time(const int round){
106-
ipe_enc_time(round);
107-
our_enc_time(round);
108-
sse_enc_time(round);
106+
ipe_client_enc_time(round);
107+
sse_client_enc_time(round);
108+
our_client_enc_time(round);
109109
}

experiment/setup_time.cpp renamed to experiment/client_setup.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "exp.hpp"
22

3-
void ipe_setup_time(const int round){
3+
void ipe_client_setup_time(const int round){
44
// Open the output files.
5-
std::ofstream file("setup_time.txt", std::ios_base::app);
6-
file << "IPE Setup Timings" << std::endl;
5+
std::ofstream file("client_setup_time.txt", std::ios_base::app);
6+
file << "IPE Timings" << std::endl;
77

88
for (int length = 10; length <= 200; length += 10){
99
// Create holder for timings.
@@ -29,10 +29,10 @@ void ipe_setup_time(const int round){
2929
file << std::endl << std::endl;
3030
}
3131

32-
void our_setup_time(const int round){
32+
void sse_client_setup_time(const int round){
3333
// Open the output files.
34-
std::ofstream file("setup_time.txt", std::ios_base::app);
35-
file << "Our Setup Timings" << std::endl;
34+
std::ofstream file("client_setup_time.txt", std::ios_base::app);
35+
file << "SSE Timings" << std::endl;
3636

3737
for (int length = 10; length <= 200; length += 10){
3838
// Create holder for timings.
@@ -42,13 +42,10 @@ void our_setup_time(const int round){
4242
for (int i = 0; i < round; ++i){
4343
// Setup timings.
4444
auto start = std::chrono::high_resolution_clock::now();
45-
// Create pp and msk.
46-
auto pp = Filter::pp_gen(1, length);
47-
std::ignore = Filter::msk_gen(pp);
45+
// Create the PRF object.
46+
std::ignore = SseFilter::msk_gen();
4847
auto end = std::chrono::high_resolution_clock::now();
4948
time += end - start;
50-
// Close the pairing group.
51-
BP::close();
5249
}
5350

5451
// Output the time.
@@ -58,10 +55,10 @@ void our_setup_time(const int round){
5855
file << std::endl << std::endl;
5956
}
6057

61-
void sse_setup_time(const int round){
58+
void our_client_setup_time(const int round){
6259
// Open the output files.
63-
std::ofstream file("setup_time.txt", std::ios_base::app);
64-
file << "SSE Setup Timings" << std::endl;
60+
std::ofstream file("client_setup_time.txt", std::ios_base::app);
61+
file << "Our Timings" << std::endl;
6562

6663
for (int length = 10; length <= 200; length += 10){
6764
// Create holder for timings.
@@ -71,10 +68,13 @@ void sse_setup_time(const int round){
7168
for (int i = 0; i < round; ++i){
7269
// Setup timings.
7370
auto start = std::chrono::high_resolution_clock::now();
74-
// Create the PRF object.
75-
std::ignore = SseFilter::msk_gen();
71+
// Create pp and msk.
72+
auto pp = Filter::pp_gen(1, length);
73+
std::ignore = Filter::msk_gen(pp);
7674
auto end = std::chrono::high_resolution_clock::now();
7775
time += end - start;
76+
// Close the pairing group.
77+
BP::close();
7878
}
7979

8080
// Output the time.
@@ -84,8 +84,8 @@ void sse_setup_time(const int round){
8484
file << std::endl << std::endl;
8585
}
8686

87-
void bench_setup_time(const int round){
88-
ipe_setup_time(round);
89-
our_setup_time(round);
90-
sse_setup_time(round);
87+
void bench_client_setup_time(const int round){
88+
ipe_client_setup_time(round);
89+
sse_client_setup_time(round);
90+
our_client_setup_time(round);
9191
}
Lines changed: 53 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
/// This file benchmarks when total length is 20 and selecting all columns, the cost of filtering n rows.
2-
/// Note this is client query operation time, hence keygen is used.
3-
41
#include "exp.hpp"
52

6-
void ipe_mul_row_time(const int round){
3+
void ipe_client_single_filter_time(const int round){
74
// Open the output files.
8-
std::ofstream time_file("multiple_row_time.txt", std::ios_base::app);
9-
time_file << "IPE Row Timings" << std::endl;
5+
std::ofstream time_file("client_single_filter_time.txt", std::ios_base::app);
6+
time_file << "IPE Timings" << std::endl;
7+
8+
std::ofstream storage_file("client_single_filter_storage.txt", std::ios_base::app);
9+
storage_file << "IPE Storage" << std::endl;
1010

11-
std::ofstream storage_file("multiple_row_storage.txt", std::ios_base::app);
12-
storage_file << "IPE Row Storage" << std::endl;
11+
// Create pp and msk.
12+
auto pp = IpeFilter::pp_gen(1, 20);
13+
auto msk = IpeFilter::msk_gen(pp);
1314

1415
for (int num_row = 1; num_row <= 20; ++num_row){
1516
// Create holder for timings.
1617
std::chrono::duration<double, std::milli> time{};
17-
18-
// Create pp and msk.
19-
auto pp = IpeFilter::pp_gen(1, 20);
20-
auto msk = IpeFilter::msk_gen(pp);
2118
G2Vec sk;
2219

2320
// Perform round number of Enc.
@@ -44,106 +41,104 @@ void ipe_mul_row_time(const int round){
4441
// Close the BP.
4542
BP::close();
4643
}
44+
4745
// Create some blank spaces.
4846
time_file << std::endl << std::endl;
4947
storage_file << std::endl << std::endl;
5048
}
5149

52-
void our_mul_row_time(const int round){
50+
void sse_client_single_filter_time(const int round){
5351
// Open the output files.
54-
std::ofstream time_file("multiple_row_time.txt", std::ios_base::app);
55-
time_file << "Our Row Timings" << std::endl;
52+
std::ofstream time_file("client_single_filter_time.txt", std::ios_base::app);
53+
time_file << "SSE Timings" << std::endl;
54+
55+
std::ofstream storage_file("client_single_filter_storage.txt", std::ios_base::app);
56+
storage_file << "SSE Storage" << std::endl;
5657

57-
std::ofstream storage_file("multiple_row_storage.txt", std::ios_base::app);
58-
storage_file << "Our Row Storage" << std::endl;
58+
// Create pp and msk.
59+
auto msk = SseFilter::msk_gen();
60+
CharMat sk;
5961

6062
for (int num_row = 1; num_row <= 20; ++num_row){
6163
// Create holder for timings.
6264
std::chrono::duration<double, std::milli> time{};
6365

64-
// Create pp and msk.
65-
auto pp = Filter::pp_gen(1, 20);
66-
auto msk = Filter::msk_gen(pp);
67-
G2Vec sk;
68-
69-
// Perform round number of Enc.
66+
// Perform ROUND number of setup.
7067
for (int i = 0; i < round; ++i){
7168
// Create a random vector of desired length.
7269
auto y = Helper::rand_int_vec(20, 1, std::numeric_limits<int>::max());
7370

7471
// Keygen timings.
7572
auto start = std::chrono::high_resolution_clock::now();
76-
sk = Filter::keygen(pp, msk, y);
73+
sk = SseFilter::keygen(msk, y, static_cast<int>(std::pow(2, num_row)));
7774
auto end = std::chrono::high_resolution_clock::now();
7875
time += end - start;
7976
}
8077

81-
// Compute the secret key size.
82-
unsigned long sk_size = sk.size() * sizeof(uint8_t) * pp.pairing_group->Gp->g2_size;
78+
// Also create holder for size.
79+
unsigned long sk_size = sk.size() * sk[0].size() * sizeof(unsigned char);
8380

8481
// Output the time.
8582
time_file << "(" << num_row << ", " << time.count() / round << ")" << std::endl;
8683

8784
// Output the storage.
8885
storage_file << "(" << num_row << ", " << sk_size << ")" << std::endl;
89-
90-
// Close the BP.
91-
BP::close();
9286
}
87+
9388
// Create some blank spaces.
9489
time_file << std::endl << std::endl;
9590
storage_file << std::endl << std::endl;
9691
}
9792

98-
void sse_mul_row_time(const int round){
93+
void our_client_single_filter_time(const int round){
9994
// Open the output files.
100-
std::ofstream time_file("multiple_row_time.txt", std::ios_base::app);
101-
time_file << "SSE Row Timings" << std::endl;
95+
std::ofstream time_file("client_single_filter_time.txt", std::ios_base::app);
96+
time_file << "Our Timings" << std::endl;
10297

103-
std::ofstream storage_file("multiple_row_storage.txt", std::ios_base::app);
104-
storage_file << "SSE Row Storage" << std::endl;
98+
std::ofstream storage_file("client_single_filter_storage.txt", std::ios_base::app);
99+
storage_file << "Our Storage" << std::endl;
100+
101+
// Create pp and msk.
102+
auto pp = Filter::pp_gen(1, 20);
103+
auto msk = Filter::msk_gen(pp);
105104

106105
for (int num_row = 1; num_row <= 20; ++num_row){
107106
// Create holder for timings.
108107
std::chrono::duration<double, std::milli> time{};
108+
G2Vec sk;
109109

110-
// Compute the number of rows used.
111-
int pow_row = static_cast<int>(std::pow(2, num_row));
112-
113-
// Create pp and msk.
114-
auto msk = SseFilter::msk_gen();
115-
CharVec sk;
116-
117-
// Perform ROUND number of setup.
110+
// Perform round number of Enc.
118111
for (int i = 0; i < round; ++i){
119-
for (int j = 0; j < pow_row; ++j){
120-
// Create a random vector of desired length.
121-
auto y = Helper::rand_int_vec(20, 1, std::numeric_limits<int>::max());
122-
123-
// Keygen timings.
124-
auto start = std::chrono::high_resolution_clock::now();
125-
sk = SseFilter::keygen(msk, y);
126-
auto end = std::chrono::high_resolution_clock::now();
127-
time += end - start;
128-
}
112+
// Create a random vector of desired length.
113+
auto y = Helper::rand_int_vec(20, 1, std::numeric_limits<int>::max());
114+
115+
// Keygen timings.
116+
auto start = std::chrono::high_resolution_clock::now();
117+
sk = Filter::keygen(pp, msk, y);
118+
auto end = std::chrono::high_resolution_clock::now();
119+
time += end - start;
129120
}
130121

131-
// Also create holder for size.
132-
unsigned long sk_size = sk.size() * sizeof(unsigned char) * pow_row;
122+
// Compute the secret key size.
123+
unsigned long sk_size = sk.size() * sizeof(uint8_t) * pp.pairing_group->Gp->g2_size;
133124

134125
// Output the time.
135126
time_file << "(" << num_row << ", " << time.count() / round << ")" << std::endl;
136127

137128
// Output the storage.
138129
storage_file << "(" << num_row << ", " << sk_size << ")" << std::endl;
130+
131+
// Close the BP.
132+
BP::close();
139133
}
134+
140135
// Create some blank spaces.
141136
time_file << std::endl << std::endl;
142137
storage_file << std::endl << std::endl;
143138
}
144139

145-
void bench_mul_row_time(const int round){
146-
ipe_mul_row_time(round);
147-
our_mul_row_time(round);
148-
sse_mul_row_time(round);
140+
void bench_client_single_filter_time(const int round){
141+
ipe_client_single_filter_time(round);
142+
sse_client_single_filter_time(round);
143+
our_client_single_filter_time(round);
149144
}

0 commit comments

Comments
 (0)