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