-
Notifications
You must be signed in to change notification settings - Fork 0
/
EncRow.cpp
71 lines (56 loc) · 1.45 KB
/
EncRow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <chrono>
#include <string>
#include <sstream>
#include <fstream>
#include "pairing_3.h"
#include "aoe-m.h"
#include <sys/timeb.h>
//#define VERBOSE
int getMilliCount(){
timeb tb;
ftime(&tb);
int nCount = tb.millitm + (tb.time & 0xfffff) * 1000;
return nCount;
}
int getMilliSpan(int nTimeStart){
int nSpan = getMilliCount() - nTimeStart;
if(nSpan < 0)
nSpan += 0x100000 * 1000;
return nSpan;
}
main(int argc, char *argv[]){
/** Check the number of parameters */
if (argc < 6) {
/** Tell the user how to run the program */
cerr << "Usage: " << argv[0] << " key_file rows encrows noise num_threads" << endl;
return 1;
}
/** Set the random seed for noise parameter generation */
srand(time(NULL));
mr_init_threading();
PFC pfc(AES_SECURITY);
SecureSelect *db=NULL;
int m=0;
string key_file(argv[1]);
string table_name(argv[2]);
string enctable_name(argv[3]);
int rand_lim = atoi(argv[4]);
int num_threads = atoi(argv[5]);
db = new SecureSelect(&pfc,pfc.order());
if(!db->LoadKey(key_file))
return 0;
if(rand_lim<1){
cout << "Random paramter < 1, it has to be >= 1" << endl;
return 0;
}
#ifdef VERBOSE
int start = getMilliCount();
#endif
db->EncryptRowsMT(table_name,enctable_name,rand_lim, num_threads);
// db->EncryptRows(table_name,enctable_name,rand_lim);
#ifdef VERBOSE
int milliSecondsElapsed = getMilliSpan(start);
cout << "\texec time " << milliSecondsElapsed << endl;
#endif
}