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
5c8b0818
Commit
5c8b0818
authored
Feb 26, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test basic ashe sum
parent
397608d0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
1 deletion
+41
-1
ASHE.cc
crypto/ASHE.cc
+12
-0
ASHE.hh
crypto/ASHE.hh
+3
-0
test_ASHE.cc
debug/test_ASHE.cc
+26
-1
No files found.
crypto/ASHE.cc
View file @
5c8b0818
...
@@ -54,6 +54,18 @@ std::pair<long,std::vector<uint64_t>> RAW_ASHE::sum(std::vector<RAW_ASHE> input)
...
@@ -54,6 +54,18 @@ std::pair<long,std::vector<uint64_t>> RAW_ASHE::sum(std::vector<RAW_ASHE> input)
return
std
::
make_pair
(
res
,
ivs
);
return
std
::
make_pair
(
res
,
ivs
);
}
}
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
RAW_ASHE
::
sum
(
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
left
,
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
right
)
{
std
::
vector
<
uint64_t
>
vecsum
;
for
(
auto
item
:
left
.
second
)
vecsum
.
push_back
(
item
);
for
(
auto
item
:
right
.
second
)
vecsum
.
push_back
(
item
);
return
std
::
make_pair
((
left
.
first
+
right
.
first
)
%
RAW_ASHE_MAX
,
vecsum
);
}
uint64_t
RAW_ASHE
::
decrypt_sum
(
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
input
){
uint64_t
RAW_ASHE
::
decrypt_sum
(
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
input
){
long
res
=
input
.
first
;
long
res
=
input
.
first
;
for
(
auto
item
:
input
.
second
){
for
(
auto
item
:
input
.
second
){
...
...
crypto/ASHE.hh
View file @
5c8b0818
...
@@ -23,6 +23,9 @@ public:
...
@@ -23,6 +23,9 @@ public:
static
uint64_t
Fi
(
uint64_t
IV
)
{
return
bf
.
encrypt
(
IV
)
%
RAW_ASHE_MAX
;}
static
uint64_t
Fi
(
uint64_t
IV
)
{
return
bf
.
encrypt
(
IV
)
%
RAW_ASHE_MAX
;}
static
uint64_t
Fi_1
(
uint64_t
IV
)
{
return
bf
.
encrypt
(
IV
-
1
)
%
RAW_ASHE_MAX
;}
static
uint64_t
Fi_1
(
uint64_t
IV
)
{
return
bf
.
encrypt
(
IV
-
1
)
%
RAW_ASHE_MAX
;}
static
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
sum
(
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
left
,
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
right
);
static
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
sum
(
std
::
vector
<
RAW_ASHE
>
);
static
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
sum
(
std
::
vector
<
RAW_ASHE
>
);
static
uint64_t
decrypt_sum
(
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
);
static
uint64_t
decrypt_sum
(
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
);
};
};
...
...
debug/test_ASHE.cc
View file @
5c8b0818
...
@@ -43,11 +43,36 @@ void test2(){
...
@@ -43,11 +43,36 @@ void test2(){
}
}
}
}
static
void
test3
()
{
std
::
vector
<
uint64_t
>
ivs
;
std
::
vector
<
long
>
cipher
;
for
(
unsigned
int
i
=
1
;
i
<=
10
;
i
++
)
{
uint64_t
IV
=
randomValue
();
if
(
IV
==
0
)
IV
=
1
;
RAW_ASHE
ashe
(
IV
);
//cipher.push_back(ashe.encrypt(i,IV));
}
}
static
void
test4
()
{
RAW_ASHE
ashe1
(
1
);
RAW_ASHE
ashe2
(
2
);
auto
enc1
=
ashe1
.
encrypt
(
1
,
1
);
auto
enc2
=
ashe2
.
encrypt
(
2
,
2
);
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
enc1t
=
{
enc1
.
first
,{
enc1
.
second
}};
std
::
pair
<
long
,
std
::
vector
<
uint64_t
>>
enc2t
=
{
enc2
.
first
,{
enc2
.
second
}};
auto
encsum
=
ashe1
.
sum
(
enc1t
,
enc2t
);
std
::
cout
<<
ashe1
.
decrypt_sum
(
encsum
)
<<
std
::
endl
;
}
int
main
(){
int
main
(){
UNUSED
(
test1
);
UNUSED
(
test1
);
test2
();
UNUSED
(
test2
);
test3
();
test4
();
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