Skip to content

Commit 24c77f9

Browse files
committed
update experiments
1 parent 5999abf commit 24c77f9

File tree

8 files changed

+437
-15
lines changed

8 files changed

+437
-15
lines changed

experiment/encryption_time.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void ipe_enc_time(const int round){
2020

2121
// Encryption timings.
2222
auto start = std::chrono::high_resolution_clock::now();
23-
auto ct = IpeFilter::enc(pp, msk, x);
23+
std::ignore = IpeFilter::enc(pp, msk, x);
2424
auto end = std::chrono::high_resolution_clock::now();
2525
time += end - start;
2626
}
@@ -55,7 +55,7 @@ void our_enc_time(const int round){
5555

5656
// Encryption timings.
5757
auto start = std::chrono::high_resolution_clock::now();
58-
auto ct = Filter::enc(pp, msk, x);
58+
std::ignore = Filter::enc(pp, msk, x);
5959
auto end = std::chrono::high_resolution_clock::now();
6060
time += end - start;
6161
}
@@ -90,7 +90,7 @@ void sse_enc_time(const int round){
9090

9191
// Encryption timings.
9292
auto start = std::chrono::high_resolution_clock::now();
93-
auto ct = SseFilter::enc(msk, x);
93+
std::ignore = SseFilter::enc(msk, x);
9494
auto end = std::chrono::high_resolution_clock::now();
9595
time += end - start;
9696
}

experiment/equality_time.cpp

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#include "exp.hpp"
2+
#include "kim_aggre.hpp"
3+
4+
void ipe_equality_time(const int round){
5+
// Open the output files.
6+
std::ofstream file("equality_time.txt", std::ios_base::app);
7+
file << "IPE Equality Timings" << std::endl;
8+
9+
for (int num_col : {2, 10, 20}){
10+
// Create holder for timings.
11+
std::chrono::duration<double, std::milli> time{};
12+
13+
// Create pp and msk.
14+
auto pp = IpeAggre::pp_gen(20);
15+
auto msk = IpeAggre::msk_gen(pp);
16+
17+
// Perform round number of Enc.
18+
for (int i = 0; i < round; ++i){
19+
// Create a random vector of desired length.
20+
auto x = Helper::rand_int_vec(20, 1, std::numeric_limits<int>::max());
21+
auto y = Helper::rand_int_vec(20, 1, 5);
22+
// Set the unselected portion to zero.
23+
for (int j = num_col + 1; j < 20; ++j){ y[j] = 0; }
24+
25+
// Compute ct and sk.
26+
auto ct = IpeAggre::enc(pp, msk, x);
27+
28+
// Keygen timing.
29+
auto start = std::chrono::high_resolution_clock::now();
30+
auto sk = IpeAggre::keygen(pp, msk, y, 100);
31+
auto end = std::chrono::high_resolution_clock::now();
32+
time += end - start;
33+
34+
// Decryption timings.
35+
start = std::chrono::high_resolution_clock::now();
36+
std::ignore = IpeAggre::dec(ct, sk);
37+
end = std::chrono::high_resolution_clock::now();
38+
time += end - start;
39+
}
40+
41+
// Output the time.
42+
file << "(" << num_col << ", " << time.count() / round << ")" << std::endl;
43+
44+
// Close the BP.
45+
BP::close();
46+
}
47+
// Create some blank spaces.
48+
file << std::endl << std::endl;
49+
}
50+
51+
void our_equality_time(const int round){
52+
// Open the output files.
53+
std::ofstream file("equality_time.txt", std::ios_base::app);
54+
file << "Our Equality Timings" << std::endl;
55+
56+
for (int num_col : {2, 10, 20}){
57+
// Create holder for timings.
58+
std::chrono::duration<double, std::milli> time{};
59+
60+
// Create pp and msk.
61+
auto pp = Aggre::pp_gen(20);
62+
auto msk = Aggre::msk_gen(pp);
63+
64+
// Perform round number of Enc.
65+
for (int i = 0; i < round; ++i){
66+
// Create a random vector of desired length.
67+
auto x = Helper::rand_int_vec(20, 1, std::numeric_limits<int>::max());
68+
// Create a random vector of desired length.
69+
auto y = Helper::rand_int_vec(num_col, 1, 5);
70+
71+
// Set the unselected portion to zero.
72+
IntVec sel;
73+
for (int j = 0; j < num_col; ++j){ sel.push_back(j); }
74+
75+
// Compute ct and sk.
76+
auto ct = Aggre::enc(pp, msk, x);
77+
78+
// Keygen timing.
79+
auto start = std::chrono::high_resolution_clock::now();
80+
auto sk = Aggre::keygen(pp, msk, y, 100, sel);
81+
auto end = std::chrono::high_resolution_clock::now();
82+
time += end - start;
83+
84+
// Decryption timings.
85+
start = std::chrono::high_resolution_clock::now();
86+
std::ignore = Aggre::dec(ct, sk, sel);
87+
end = std::chrono::high_resolution_clock::now();
88+
time += end - start;
89+
}
90+
91+
// Output the time.
92+
file << "(" << num_col << ", " << time.count() / round << ")" << std::endl;
93+
94+
// Close the BP.
95+
BP::close();
96+
}
97+
// Create some blank spaces.
98+
file << std::endl << std::endl;
99+
}
100+
101+
void kim_equality_time(const int round){
102+
// Open the output files.
103+
std::ofstream file("equality_time.txt", std::ios_base::app);
104+
file << "Kim Equality Timings" << std::endl;
105+
106+
for (int num_col : {2, 10, 20}){
107+
// Create holder for timings.
108+
std::chrono::duration<double, std::milli> time{};
109+
110+
// Create pp and msk.
111+
auto pp = KimAggre::pp_gen(20);
112+
auto msk = KimAggre::msk_gen(pp);
113+
114+
// Perform round number of Enc.
115+
for (int i = 0; i < round; ++i){
116+
// Create a random vector of desired length.
117+
auto x = Helper::rand_int_vec(20, 1, std::numeric_limits<int>::max());
118+
auto y = Helper::rand_int_vec(20, 1, 5);
119+
// Set the unselected portion to zero.
120+
for (int j = num_col + 1; j < 20; ++j){ y[j] = 0; }
121+
122+
// Compute ct and sk.
123+
auto ct = KimAggre::enc(pp, msk, x);
124+
125+
// Keygen timing.
126+
auto start = std::chrono::high_resolution_clock::now();
127+
auto sk = KimAggre::keygen(pp, msk, y, 100);
128+
auto end = std::chrono::high_resolution_clock::now();
129+
time += end - start;
130+
131+
// Decryption timings.
132+
start = std::chrono::high_resolution_clock::now();
133+
std::ignore = KimAggre::dec(ct, sk);
134+
end = std::chrono::high_resolution_clock::now();
135+
time += end - start;
136+
}
137+
138+
// Output the time.
139+
file << "(" << num_col << ", " << time.count() / round << ")" << std::endl;
140+
141+
// Close the BP.
142+
BP::close();
143+
}
144+
// Create some blank spaces.
145+
file << std::endl << std::endl;
146+
}
147+
148+
void bench_equality_time(const int round){
149+
ipe_equality_time(round);
150+
our_equality_time(round);
151+
kim_equality_time(round);
152+
}

experiment/exp.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include <limits>
44
#include <chrono>
55
#include <fstream>
6+
#include "aggre.hpp"
67
#include "filter.hpp"
8+
#include "ipe_aggre.hpp"
79
#include "ipe_filter.hpp"
810
#include "sse_filter.hpp"
911

@@ -30,3 +32,20 @@ void ipe_sel_col_time(int round);
3032
void our_sel_col_time(int round);
3133
void sse_sel_col_time(int round);
3234
void bench_sel_col_time(int round);
35+
36+
/// Benchmark for performing decryption on filter single value.
37+
void ipe_single_dec_time(int round);
38+
void our_single_dec_time(int round);
39+
void sse_single_dec_time(int round);
40+
void bench_single_dec_time(int round);
41+
42+
/// Benchmark for performing decryption on filter multiple value.
43+
void ipe_multi_dec_time(int round);
44+
void our_multi_dec_time(int round);
45+
void bench_multi_dec_time(int round);
46+
47+
/// Benchmark for performing equality test.
48+
void ipe_equality_time(int round);
49+
void our_equality_time(int round);
50+
void kim_equality_time(int round);
51+
void bench_equality_time(int round);

experiment/multi_filter_time.cpp

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#include "exp.hpp"
2+
3+
void ipe_multi_dec_time(const int round){
4+
// Open the output files.
5+
std::ofstream file("multi_dec_time.txt", std::ios_base::app);
6+
file << "IPE Multi Dec Timings" << std::endl;
7+
8+
for (int num_col : {2, 10, 20}){
9+
// Create holder for timings.
10+
std::chrono::duration<double, std::milli> time{};
11+
12+
// Create pp and msk.
13+
auto pp = IpeFilter::pp_gen(5, 20);
14+
auto msk = IpeFilter::msk_gen(pp);
15+
16+
// Perform round number of Enc.
17+
for (int i = 0; i < round; ++i){
18+
// Create a random vector of desired length.
19+
auto x = Helper::rand_int_vec(20, 1, std::numeric_limits<int>::max());
20+
auto y = Helper::rand_int_mat(20, 5, 1, std::numeric_limits<int>::max());
21+
// Set the unselected portion to zero.
22+
for (int j = num_col + 1; j < 20; ++j) for (int k = 0; k < 5; ++k) y[j][k] = 0;
23+
24+
// Compute ct and sk.
25+
auto ct = IpeFilter::enc(pp, msk, x);
26+
27+
// Keygen timing.
28+
auto start = std::chrono::high_resolution_clock::now();
29+
auto sk = IpeFilter::keygen(pp, msk, y);
30+
auto end = std::chrono::high_resolution_clock::now();
31+
time += end - start;
32+
33+
// Decryption timings.
34+
start = std::chrono::high_resolution_clock::now();
35+
std::ignore = IpeFilter::dec(ct, sk);
36+
end = std::chrono::high_resolution_clock::now();
37+
time += end - start;
38+
}
39+
40+
// Output the time.
41+
file << "(" << num_col << ", " << time.count() / round << ")" << std::endl;
42+
43+
// Close the BP.
44+
BP::close();
45+
}
46+
// Create some blank spaces.
47+
file << std::endl << std::endl;
48+
}
49+
50+
void our_multi_dec_time(const int round){
51+
// Open the output files.
52+
std::ofstream file("multi_dec_time.txt", std::ios_base::app);
53+
file << "Our Multi Dec Timings" << std::endl;
54+
55+
for (int num_col : {2, 10, 20}){
56+
// Create holder for timings.
57+
std::chrono::duration<double, std::milli> time{};
58+
59+
// Create pp and msk.
60+
auto pp = Filter::pp_gen(5, 20);
61+
auto msk = Filter::msk_gen(pp);
62+
63+
// Perform round number of Enc.
64+
for (int i = 0; i < round; ++i){
65+
// Create a random vector of desired length.
66+
auto x = Helper::rand_int_vec(20, 1, std::numeric_limits<int>::max());
67+
// Create a random vector of desired length.
68+
auto y = Helper::rand_int_vec(num_col, 5, std::numeric_limits<int>::max());
69+
70+
// Set the unselected portion to zero.
71+
IntVec sel;
72+
for (int j = 0; j < num_col; ++j){ sel.push_back(j); }
73+
74+
// Compute ct and sk.
75+
auto ct = Filter::enc(pp, msk, x);
76+
77+
// Keygen timing.
78+
auto start = std::chrono::high_resolution_clock::now();
79+
auto sk = Filter::keygen(pp, msk, y, sel);
80+
auto end = std::chrono::high_resolution_clock::now();
81+
time += end - start;
82+
83+
// Decryption timings.
84+
start = std::chrono::high_resolution_clock::now();
85+
std::ignore = Filter::dec(pp, ct, sk, sel);
86+
end = std::chrono::high_resolution_clock::now();
87+
time += end - start;
88+
}
89+
90+
// Output the time.
91+
file << "(" << num_col << ", " << time.count() / round << ")" << std::endl;
92+
93+
// Close the BP.
94+
BP::close();
95+
}
96+
// Create some blank spaces.
97+
file << std::endl << std::endl;
98+
}
99+
100+
void bench_multi_dec_time(const int round){
101+
ipe_multi_dec_time(round);
102+
our_multi_dec_time(round);
103+
}

experiment/run.cpp

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

33
int main(){
4-
// bench_setup_time(100);
5-
// bench_enc_time(100);
6-
// bench_mul_row_time(100);
7-
bench_sel_col_time(100);
8-
4+
bench_setup_time(1000);
5+
bench_enc_time(1000);
6+
bench_mul_row_time(1000);
7+
bench_sel_col_time(1000);
8+
bench_single_dec_time(1000);
9+
bench_multi_dec_time(1000);
10+
bench_equality_time(1000);
911
return 0;
10-
}
12+
}

experiment/select_col_time.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void ipe_sel_col_time(const int round){
2323

2424
// Keygen timings.
2525
auto start = std::chrono::high_resolution_clock::now();
26-
auto sk = IpeFilter::keygen(pp, msk, y);
26+
std::ignore = IpeFilter::keygen(pp, msk, y);
2727
auto end = std::chrono::high_resolution_clock::now();
2828
time += end - start;
2929
}
@@ -62,7 +62,7 @@ void our_sel_col_time(const int round){
6262

6363
// Keygen timings.
6464
auto start = std::chrono::high_resolution_clock::now();
65-
auto sk = Filter::keygen(pp, msk, y, sel);
65+
std::ignore = Filter::keygen(pp, msk, y, sel);
6666
auto end = std::chrono::high_resolution_clock::now();
6767
time += end - start;
6868
}
@@ -96,7 +96,7 @@ void sse_sel_col_time(const int round){
9696

9797
// Keygen timings.
9898
auto start = std::chrono::high_resolution_clock::now();
99-
auto sk = SseFilter::keygen(msk, y);
99+
std::ignore = SseFilter::keygen(msk, y);
100100
auto end = std::chrono::high_resolution_clock::now();
101101
time += end - start;
102102
}

experiment/setup_time.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void ipe_setup_time(const int round){
1515
auto start = std::chrono::high_resolution_clock::now();
1616
// Create pp and msk.
1717
auto pp = IpeFilter::pp_gen(1, length);
18-
auto msk = IpeFilter::msk_gen(pp);
18+
std::ignore = IpeFilter::msk_gen(pp);
1919
auto end = std::chrono::high_resolution_clock::now();
2020
time += end - start;
2121
// Close the pairing group.
@@ -44,7 +44,7 @@ void our_setup_time(const int round){
4444
auto start = std::chrono::high_resolution_clock::now();
4545
// Create pp and msk.
4646
auto pp = Filter::pp_gen(1, length);
47-
auto msk = Filter::msk_gen(pp);
47+
std::ignore = Filter::msk_gen(pp);
4848
auto end = std::chrono::high_resolution_clock::now();
4949
time += end - start;
5050
// Close the pairing group.
@@ -72,7 +72,7 @@ void sse_setup_time(const int round){
7272
// Setup timings.
7373
auto start = std::chrono::high_resolution_clock::now();
7474
// Create the PRF object.
75-
auto msk = SseFilter::msk_gen();
75+
std::ignore = SseFilter::msk_gen();
7676
auto end = std::chrono::high_resolution_clock::now();
7777
time += end - start;
7878
}

0 commit comments

Comments
 (0)