Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
Practical-Cryptdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhaozhen
Practical-Cryptdb
Commits
6543f6f4
Commit
6543f6f4
authored
Jan 30, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_layers
parent
d3bc7806
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
229 additions
and
50 deletions
+229
-50
test_layer_ASHE.cc
debug/test_layer_ASHE.cc
+27
-4
test_layer_DET_int.cc
debug/test_layer_DET_int.cc
+23
-4
test_layer_DET_str.cc
debug/test_layer_DET_str.cc
+29
-4
test_layer_HOM.cc
debug/test_layer_HOM.cc
+28
-15
test_layer_OPE_int.cc
debug/test_layer_OPE_int.cc
+24
-4
test_layer_OPE_str.cc
debug/test_layer_OPE_str.cc
+22
-5
test_layer_RND_int.cc
debug/test_layer_RND_int.cc
+27
-4
test_layer_RND_str.cc
debug/test_layer_RND_str.cc
+28
-5
test_layer_SWP.cc
debug/test_layer_SWP.cc
+21
-5
No files found.
debug/test_layer_ASHE.cc
View file @
6543f6f4
...
@@ -90,16 +90,39 @@ Create_field* getUnsignedIntField(){
...
@@ -90,16 +90,39 @@ Create_field* getUnsignedIntField(){
*/
*/
int
int
main
()
{
main
(
int
argc
,
char
**
argv
)
{
init
();
init
();
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
Create_field
*
cf
=
NULL
;
ASHE
*
as
=
new
ASHE
(
*
cf
,
key
);
ASHE
*
as
=
new
ASHE
(
*
cf
,
key
);
Item
*
plain
=
getItemInt
(
"123"
);
int
num_of_tests
=
10000
;
Item
*
enc
=
as
->
encrypt
(
*
plain
,
0u
);
Item
*
dec
=
as
->
decrypt
(
*
enc
,
0u
);
if
(
argc
==
2
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
}
Item
*
plain
=
getItemInt
(
"123456789"
);
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
as
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_ASHE_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
dec
=
as
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"DEC_ASHE_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
(
void
)
dec
;
return
0
;
return
0
;
...
...
debug/test_layer_DET_int.cc
View file @
6543f6f4
...
@@ -101,7 +101,7 @@ Create_field* getUnsignedIntField(){
...
@@ -101,7 +101,7 @@ Create_field* getUnsignedIntField(){
int
int
main
()
{
main
(
int
argc
,
char
**
argv
)
{
init
();
init
();
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
std
::
string
key
=
"key"
;
...
@@ -109,9 +109,28 @@ main() {
...
@@ -109,9 +109,28 @@ main() {
DET_int
*
ds
=
new
DET_int
(
*
cf
,
key
);
DET_int
*
ds
=
new
DET_int
(
*
cf
,
key
);
Item
*
plain
=
getItemInt
(
"123"
);
int
num_of_tests
=
10000
;
Item
*
enc
=
ds
->
encrypt
(
*
plain
,
0u
);
if
(
argc
==
2
){
Item
*
dec
=
ds
->
decrypt
(
*
enc
,
0u
);
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
}
Item
*
plain
=
getItemInt
(
"123456789"
);
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
ds
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"DEC_DET_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
dec
=
ds
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"ENC_DET_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
(
void
)
dec
;
return
0
;
return
0
;
...
...
debug/test_layer_DET_str.cc
View file @
6543f6f4
...
@@ -99,16 +99,41 @@ Create_field* getUnsignedIntField(){
...
@@ -99,16 +99,41 @@ Create_field* getUnsignedIntField(){
*/
*/
int
int
main
()
{
main
(
int
argc
,
char
**
argv
)
{
init
();
init
();
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
Create_field
*
cf
=
NULL
;
DET_str
*
ds
=
new
DET_str
(
*
cf
,
key
);
DET_str
*
ds
=
new
DET_str
(
*
cf
,
key
);
Item
*
plain
=
getItemString
(
"helloworld"
);
int
num_of_tests
=
10000
;
Item
*
enc
=
ds
->
encrypt
(
*
plain
,
0u
);
int
length
=
16
;
Item
*
dec
=
ds
->
decrypt
(
*
enc
,
0u
);
if
(
argc
==
3
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
length
=
std
::
stoi
(
std
::
string
(
argv
[
2
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
}
std
::
string
input
(
length
,
'a'
);
Item
*
plain
=
getItemString
(
input
);
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
std
::
cout
<<
"length: "
<<
length
<<
" ## "
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
ds
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_DET_STR_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
dec
=
ds
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"DEC_DET_STR_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
(
void
)
dec
;
return
0
;
return
0
;
...
...
debug/test_layer_HOM.cc
View file @
6543f6f4
...
@@ -58,22 +58,13 @@ static void init(){
...
@@ -58,22 +58,13 @@ static void init(){
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
}
}
static
Item
*
getItemString
(
std
::
string
input
)
{
return
MySQLFieldTypeToItem
(
MYSQL_TYPE_STRING
,
input
);
}
/*
static
static
Item
*
Item
*
getItemInt
(
std
::
string
input
)
{
getItemInt
(
std
::
string
input
)
{
return
new
(
current_thd
->
mem_root
)
return
new
(
current_thd
->
mem_root
)
Item_int
(
static_cast
<
ulonglong
>
(
valFromStr
(
input
)));
Item_int
(
static_cast
<
ulonglong
>
(
valFromStr
(
input
)));
}
}
/*
static
static
Item *
Item *
getItemString(std::string input) {
getItemString(std::string input) {
...
@@ -99,18 +90,40 @@ Create_field* getUnsignedIntField(){
...
@@ -99,18 +90,40 @@ Create_field* getUnsignedIntField(){
*/
*/
int
int
main
()
{
main
(
int
argc
,
char
**
argv
)
{
init
();
init
();
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
Create_field
*
cf
=
NULL
;
HOM
*
hm
=
new
HOM
(
*
cf
,
key
);
HOM
*
hm
=
new
HOM
(
*
cf
,
key
);
Item
*
plain
=
getItemString
(
"helloworld"
);
int
num_of_tests
=
10000
;
Item
*
enc
=
hm
->
encrypt
(
*
plain
,
0u
);
if
(
argc
==
2
){
Item
*
dec
=
hm
->
decrypt
(
*
enc
,
0u
);
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
(
void
)
dec
;
}
else
{
std
::
cout
<<
"num_of_tests"
<<
std
::
endl
;
}
Item
*
plain
=
getItemInt
(
"123456789"
);
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
hm
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"HOM_ENC_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
dec
=
hm
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"HOM_DEC_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
return
0
;
return
0
;
}
}
...
...
debug/test_layer_OPE_int.cc
View file @
6543f6f4
...
@@ -102,17 +102,37 @@ Create_field* getUnsignedIntField(){
...
@@ -102,17 +102,37 @@ Create_field* getUnsignedIntField(){
int
int
main
()
{
main
(
int
argc
,
char
**
argv
)
{
init
();
init
();
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
std
::
string
key
=
"key"
;
Create_field
*
cf
=
getUnsignedIntField
();
Create_field
*
cf
=
getUnsignedIntField
();
OPE_int
*
op
=
new
OPE_int
(
*
cf
,
key
);
OPE_int
*
op
=
new
OPE_int
(
*
cf
,
key
);
Item
*
plain
=
getItemInt
(
"123"
);
//getItemString("helloworld");
int
num_of_tests
=
10000
;
if
(
argc
==
2
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
}
Item
*
enc
=
op
->
encrypt
(
*
plain
,
0u
);
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
Item
*
dec
=
op
->
decrypt
(
*
enc
,
0u
);
Item
*
plain
=
getItemInt
(
"123456789"
);
//getItemString("helloworld");
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
op
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_OPE_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
dec
=
op
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"DEC_OPE_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
(
void
)
dec
;
return
0
;
return
0
;
...
...
debug/test_layer_OPE_str.cc
View file @
6543f6f4
...
@@ -98,19 +98,36 @@ Create_field* getUnsignedIntField(){
...
@@ -98,19 +98,36 @@ Create_field* getUnsignedIntField(){
*/
*/
int
int
main
()
{
main
(
int
argc
,
char
**
argv
)
{
init
();
init
();
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
Create_field
*
cf
=
NULL
;
OPE_str
*
op
=
new
OPE_str
(
*
cf
,
key
);
OPE_str
*
op
=
new
OPE_str
(
*
cf
,
key
);
Item
*
plain
=
getItemString
(
"helloworld"
);
int
num_of_tests
=
10000
;
Item
*
enc
=
op
->
encrypt
(
*
plain
,
0u
);
int
length
=
16
;
// Item* dec = op->decrypt(*enc,0u);
(
void
)
enc
;
if
(
argc
==
3
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
length
=
std
::
stoi
(
std
::
string
(
argv
[
2
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
}
std
::
string
input
(
length
,
'a'
);
Item
*
plain
=
getItemString
(
input
);
std
::
cout
<<
"length: "
<<
length
<<
" ## "
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
timer
t
;
Item
*
enc
=
NULL
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
op
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_OPE_STR_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
enc
;
return
0
;
return
0
;
}
}
...
...
debug/test_layer_RND_int.cc
View file @
6543f6f4
...
@@ -103,16 +103,39 @@ Create_field* getUnsignedIntField(){
...
@@ -103,16 +103,39 @@ Create_field* getUnsignedIntField(){
int
int
main
()
{
main
(
int
argc
,
char
**
argv
)
{
init
();
init
();
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
std
::
string
key
=
"key"
;
Create_field
*
cf
=
getUnsignedIntField
();
Create_field
*
cf
=
getUnsignedIntField
();
RND_int
*
ri
=
new
RND_int
(
*
cf
,
key
);
RND_int
*
ri
=
new
RND_int
(
*
cf
,
key
);
Item
*
plain
=
getItemInt
(
"123"
);
int
num_of_tests
=
10000
;
Item
*
enc
=
ri
->
encrypt
(
*
plain
,
0u
);
if
(
argc
==
2
){
Item
*
dec
=
ri
->
decrypt
(
*
enc
,
0u
);
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
}
Item
*
plain
=
getItemInt
(
"123456789"
);
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
){
enc
=
ri
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_RND_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
){
dec
=
ri
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"DEC_RND_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
(
void
)
dec
;
return
0
;
return
0
;
...
...
debug/test_layer_RND_str.cc
View file @
6543f6f4
...
@@ -99,18 +99,41 @@ Create_field* getUnsignedIntField(){
...
@@ -99,18 +99,41 @@ Create_field* getUnsignedIntField(){
*/
*/
int
int
main
()
{
main
(
int
argc
,
char
**
argv
)
{
init
();
init
();
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
Create_field
*
cf
=
NULL
;
RND_str
*
rs
=
new
RND_str
(
*
cf
,
key
);
RND_str
*
rs
=
new
RND_str
(
*
cf
,
key
);
Item
*
plain
=
getItemString
(
"helloworld"
);
int
num_of_tests
=
10000
;
Item
*
enc
=
rs
->
encrypt
(
*
plain
,
0u
);
int
length
=
16
;
Item
*
dec
=
rs
->
decrypt
(
*
enc
,
0u
);
(
void
)
dec
;
if
(
argc
==
3
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
length
=
std
::
stoi
(
std
::
string
(
argv
[
2
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
}
std
::
string
input
(
length
,
'a'
);
Item
*
plain
=
getItemString
(
input
);
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
std
::
cout
<<
"length: "
<<
length
<<
" ## "
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
){
enc
=
rs
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_RND_STR_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
){
dec
=
rs
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"DEC_RND_STR_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
(
void
)
enc
;
return
0
;
return
0
;
}
}
...
...
debug/test_layer_SWP.cc
View file @
6543f6f4
...
@@ -99,19 +99,35 @@ Create_field* getUnsignedIntField(){
...
@@ -99,19 +99,35 @@ Create_field* getUnsignedIntField(){
*/
*/
int
int
main
()
{
main
(
int
argc
,
char
**
argv
)
{
init
();
init
();
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
Create_field
*
cf
=
NULL
;
Search
*
sw
=
new
Search
(
*
cf
,
key
);
Search
*
sw
=
new
Search
(
*
cf
,
key
);
Item
*
plain
=
getItemString
(
"helloworld"
);
int
num_of_tests
=
10000
;
int
length
=
16
;
Item
*
enc
=
sw
->
encrypt
(
*
plain
,
0u
);
if
(
argc
==
3
){
// Item* dec = ds->decrypt(*enc,0u);
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
(
void
)
enc
;
length
=
std
::
stoi
(
std
::
string
(
argv
[
2
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
}
std
::
string
input
(
length
,
'a'
);
Item
*
plain
=
getItemString
(
input
);
std
::
cout
<<
"length: "
<<
length
<<
" ## "
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
timer
t
;
Item
*
enc
=
NULL
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
sw
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_OPE_STR_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
enc
;
return
0
;
return
0
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment