Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
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
董子豪
sgxwallet
Commits
45aced00
Unverified
Commit
45aced00
authored
May 06, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed docs
parent
4616ef27
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
112 deletions
+101
-112
ServerInit.cpp
ServerInit.cpp
+3
-1
testw.cpp
testw.cpp
+95
-109
testw.py
testw.py
+3
-2
No files found.
ServerInit.cpp
View file @
45aced00
...
@@ -106,10 +106,12 @@ void initEnclave(uint32_t _logLevel) {
...
@@ -106,10 +106,12 @@ void initEnclave(uint32_t _logLevel) {
}
}
int
sgxServerInited
=
0
;
void
initAll
(
uint32_t
_logLevel
,
bool
_checkCert
,
bool
_autoSign
)
{
void
initAll
(
uint32_t
_logLevel
,
bool
_checkCert
,
bool
_autoSign
)
{
static
int
sgxServerInited
;
cout
<<
"Running sgxwallet version:"
<<
SGXWALLET_VERSION
<<
endl
;
cout
<<
"Running sgxwallet version:"
<<
SGXWALLET_VERSION
<<
endl
;
CHECK_STATE
(
sgxServerInited
==
0
)
CHECK_STATE
(
sgxServerInited
==
0
)
sgxServerInited
=
1
;
sgxServerInited
=
1
;
...
...
testw.cpp
View file @
45aced00
...
@@ -115,7 +115,7 @@ void resetDB() {
...
@@ -115,7 +115,7 @@ void resetDB() {
REQUIRE
(
system
(
"rm -rf "
SGXDATA_FOLDER
)
==
0
);
REQUIRE
(
system
(
"rm -rf "
SGXDATA_FOLDER
)
==
0
);
}
}
shared_ptr
<
string
>
encryptTestKey
()
{
shared_ptr
<
string
>
encryptTestKey
()
{
const
char
*
key
=
TEST_BLS_KEY_SHARE
;
const
char
*
key
=
TEST_BLS_KEY_SHARE
;
int
errStatus
=
-
1
;
int
errStatus
=
-
1
;
...
@@ -133,12 +133,11 @@ shared_ptr<string> encryptTestKey() {
...
@@ -133,12 +133,11 @@ shared_ptr<string> encryptTestKey() {
}
}
vector
<
libff
::
alt_bn128_Fr
>
splitStringToFr
(
const
char
*
coeffs
,
const
char
symbol
)
{
vector
<
libff
::
alt_bn128_Fr
>
splitStringToFr
(
const
char
*
coeffs
,
const
char
symbol
)
{
string
str
(
coeffs
);
string
str
(
coeffs
);
string
delim
;
string
delim
;
delim
.
push_back
(
symbol
);
delim
.
push_back
(
symbol
);
vector
<
libff
::
alt_bn128_Fr
>
tokens
;
vector
<
libff
::
alt_bn128_Fr
>
tokens
;
size_t
prev
=
0
,
pos
=
0
;
size_t
prev
=
0
,
pos
=
0
;
do
{
do
{
pos
=
str
.
find
(
delim
,
prev
);
pos
=
str
.
find
(
delim
,
prev
);
...
@@ -154,12 +153,12 @@ vector<libff::alt_bn128_Fr> splitStringToFr(const char *coeffs, const char symbo
...
@@ -154,12 +153,12 @@ vector<libff::alt_bn128_Fr> splitStringToFr(const char *coeffs, const char symbo
return
tokens
;
return
tokens
;
}
}
vector
<
string
>
splitStringTest
(
const
char
*
coeffs
,
const
char
symbol
)
{
vector
<
string
>
splitStringTest
(
const
char
*
coeffs
,
const
char
symbol
)
{
libff
::
init_alt_bn128_params
();
libff
::
init_alt_bn128_params
();
string
str
(
coeffs
);
string
str
(
coeffs
);
string
delim
;
string
delim
;
delim
.
push_back
(
symbol
);
delim
.
push_back
(
symbol
);
vector
<
string
>
g2Strings
;
vector
<
string
>
g2Strings
;
size_t
prev
=
0
,
pos
=
0
;
size_t
prev
=
0
,
pos
=
0
;
do
{
do
{
pos
=
str
.
find
(
delim
,
prev
);
pos
=
str
.
find
(
delim
,
prev
);
...
@@ -175,7 +174,7 @@ vector<string> splitStringTest(const char *coeffs, const char symbol) {
...
@@ -175,7 +174,7 @@ vector<string> splitStringTest(const char *coeffs, const char symbol) {
return
g2Strings
;
return
g2Strings
;
}
}
libff
::
alt_bn128_G2
vectStringToG2
(
const
vector
<
string
>
&
G2_str_vect
)
{
libff
::
alt_bn128_G2
vectStringToG2
(
const
vector
<
string
>
&
G2_str_vect
)
{
libff
::
init_alt_bn128_params
();
libff
::
init_alt_bn128_params
();
libff
::
alt_bn128_G2
coeff
=
libff
::
alt_bn128_G2
::
zero
();
libff
::
alt_bn128_G2
coeff
=
libff
::
alt_bn128_G2
::
zero
();
coeff
.
X
.
c0
=
libff
::
alt_bn128_Fq
(
G2_str_vect
.
at
(
0
).
c_str
());
coeff
.
X
.
c0
=
libff
::
alt_bn128_Fq
(
G2_str_vect
.
at
(
0
).
c_str
());
...
@@ -193,6 +192,7 @@ using namespace jsonrpc;
...
@@ -193,6 +192,7 @@ using namespace jsonrpc;
using
namespace
std
;
using
namespace
std
;
void
sendRPCRequest
()
{
void
sendRPCRequest
()
{
HttpClient
client
(
"http://localhost:1029"
);
HttpClient
client
(
"http://localhost:1029"
);
...
@@ -206,8 +206,8 @@ void sendRPCRequest() {
...
@@ -206,8 +206,8 @@ void sendRPCRequest() {
Json
::
Value
secretShares
[
n
];
Json
::
Value
secretShares
[
n
];
Json
::
Value
pubBLSKeys
[
n
];
Json
::
Value
pubBLSKeys
[
n
];
Json
::
Value
BLSSigShares
[
n
];
Json
::
Value
BLSSigShares
[
n
];
vector
<
string
>
pubShares
(
n
);
vector
<
string
>
pubShares
(
n
);
vector
<
string
>
poly_names
(
n
);
vector
<
string
>
poly_names
(
n
);
int
schain_id
=
randGen
();
int
schain_id
=
randGen
();
int
dkg_id
=
randGen
();
int
dkg_id
=
randGen
();
...
@@ -236,7 +236,7 @@ void sendRPCRequest() {
...
@@ -236,7 +236,7 @@ void sendRPCRequest() {
int
k
=
0
;
int
k
=
0
;
vector
<
string
>
secShares_vect
(
n
);
vector
<
string
>
secShares_vect
(
n
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
for
(
int
i
=
0
;
i
<
n
;
i
++
)
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
...
@@ -254,13 +254,14 @@ void sendRPCRequest() {
...
@@ -254,13 +254,14 @@ void sendRPCRequest() {
string
hash
=
"09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db"
;
string
hash
=
"09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db"
;
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
uint64_t
binLen
;
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
()))
{
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
()))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
}
}
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
coeffs_pkeys_map
;
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
coeffs_pkeys_map
;
for
(
int
i
=
0
;
i
<
t
;
i
++
)
{
for
(
int
i
=
0
;
i
<
t
;
i
++
)
{
...
@@ -276,20 +277,19 @@ void sendRPCRequest() {
...
@@ -276,20 +277,19 @@ void sendRPCRequest() {
BLSSigShares
[
i
]
=
c
.
blsSignMessageHash
(
blsName
,
hash
,
t
,
n
,
i
+
1
);
BLSSigShares
[
i
]
=
c
.
blsSignMessageHash
(
blsName
,
hash
,
t
,
n
,
i
+
1
);
REQUIRE
(
BLSSigShares
[
i
][
"status"
]
==
0
);
REQUIRE
(
BLSSigShares
[
i
][
"status"
]
==
0
);
shared_ptr
<
string
>
sig_share_ptr
=
make_shared
<
string
>
(
BLSSigShares
[
i
][
"signatureShare"
].
asString
());
shared_ptr
<
string
>
sig_share_ptr
=
make_shared
<
string
>
(
BLSSigShares
[
i
][
"signatureShare"
].
asString
());
BLSSigShare
sig
(
sig_share_ptr
,
i
+
1
,
t
,
n
);
BLSSigShare
sig
(
sig_share_ptr
,
i
+
1
,
t
,
n
);
sigShareSet
.
addSigShare
(
make_shared
<
BLSSigShare
>
(
sig
));
sigShareSet
.
addSigShare
(
make_shared
<
BLSSigShare
>
(
sig
));
}
}
shared_ptr
<
BLSSignature
>
commonSig
=
sigShareSet
.
merge
();
shared_ptr
<
BLSSignature
>
commonSig
=
sigShareSet
.
merge
();
}
}
void
destroyEnclave
()
{
void
destroyEnclave
()
{
if
(
eid
!=
0
)
{
if
(
eid
!=
0
)
{
sgx_destroy_enclave
(
eid
);
sgx_destroy_enclave
(
eid
);
...
@@ -325,8 +325,6 @@ public:
...
@@ -325,8 +325,6 @@ public:
};
};
TEST_CASE_METHOD
(
Fixture
,
"BLS key encrypt"
,
"[bls-key-encrypt]"
)
{
TEST_CASE_METHOD
(
Fixture
,
"BLS key encrypt"
,
"[bls-key-encrypt]"
)
{
auto
key
=
encryptTestKey
();
auto
key
=
encryptTestKey
();
...
@@ -369,7 +367,7 @@ TEST_CASE_METHOD("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
...
@@ -369,7 +367,7 @@ TEST_CASE_METHOD("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
TEST_CASE_METHOD
(
Fixture
,
"DKG gen test"
,
"[dkg-gen]"
)
{
TEST_CASE_METHOD
(
Fixture
,
"DKG gen test"
,
"[dkg-gen]"
)
{
vector
<
uint8_t
>
encryptedDKGSecret
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encryptedDKGSecret
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
int
errStatus
=
0
;
int
errStatus
=
0
;
...
@@ -397,7 +395,7 @@ TEST_CASE_METHOD(Fixture, "DKG public shares test", "[dkg-pub-shares]") {
...
@@ -397,7 +395,7 @@ TEST_CASE_METHOD(Fixture, "DKG public shares test", "[dkg-pub-shares]") {
libff
::
init_alt_bn128_params
();
libff
::
init_alt_bn128_params
();
vector
<
uint8_t
>
encryptedDKGSecret
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encryptedDKGSecret
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
int
errStatus
=
0
;
int
errStatus
=
0
;
...
@@ -422,10 +420,10 @@ TEST_CASE_METHOD(Fixture, "DKG public shares test", "[dkg-pub-shares]") {
...
@@ -422,10 +420,10 @@ TEST_CASE_METHOD(Fixture, "DKG public shares test", "[dkg-pub-shares]") {
// printf(" LEN: %d \n", (int) strlen(pubShares.data()));
// printf(" LEN: %d \n", (int) strlen(pubShares.data()));
// printf(" result: %s \n", pubShares.data());
// printf(" result: %s \n", pubShares.data());
vector
<
string
>
g2Strings
=
splitString
(
pubShares
.
data
(),
','
);
vector
<
string
>
g2Strings
=
splitString
(
pubShares
.
data
(),
','
);
vector
<
libff
::
alt_bn128_G2
>
pubSharesG2
;
vector
<
libff
::
alt_bn128_G2
>
pubSharesG2
;
for
(
u_int64_t
i
=
0
;
i
<
g2Strings
.
size
();
i
++
)
{
for
(
u_int64_t
i
=
0
;
i
<
g2Strings
.
size
();
i
++
)
{
vector
<
string
>
coeffStr
=
splitString
(
g2Strings
.
at
(
i
).
c_str
(),
':'
);
vector
<
string
>
coeffStr
=
splitString
(
g2Strings
.
at
(
i
).
c_str
(),
':'
);
//libff::alt_bn128_G2 el = VectStringToG2(coeffStr);
//libff::alt_bn128_G2 el = VectStringToG2(coeffStr);
//cerr << "pub_share G2 " << i+1 << " : " << endl;
//cerr << "pub_share G2 " << i+1 << " : " << endl;
//el.print_coordinates();
//el.print_coordinates();
...
@@ -441,8 +439,8 @@ TEST_CASE_METHOD(Fixture, "DKG public shares test", "[dkg-pub-shares]") {
...
@@ -441,8 +439,8 @@ TEST_CASE_METHOD(Fixture, "DKG public shares test", "[dkg-pub-shares]") {
signatures
::
Dkg
dkgObj
(
t
,
n
);
signatures
::
Dkg
dkgObj
(
t
,
n
);
vector
<
libff
::
alt_bn128_Fr
>
poly
=
splitStringToFr
(
secret
.
data
(),
colon
);
vector
<
libff
::
alt_bn128_Fr
>
poly
=
splitStringToFr
(
secret
.
data
(),
colon
);
vector
<
libff
::
alt_bn128_G2
>
pubSharesDkg
=
dkgObj
.
VerificationVector
(
poly
);
vector
<
libff
::
alt_bn128_G2
>
pubSharesDkg
=
dkgObj
.
VerificationVector
(
poly
);
// printf("calculated public shares (X.c0): \n");
// printf("calculated public shares (X.c0): \n");
for
(
uint32_t
i
=
0
;
i
<
pubSharesDkg
.
size
();
i
++
)
{
for
(
uint32_t
i
=
0
;
i
<
pubSharesDkg
.
size
();
i
++
)
{
libff
::
alt_bn128_G2
el
=
pubSharesDkg
.
at
(
i
);
libff
::
alt_bn128_G2
el
=
pubSharesDkg
.
at
(
i
);
...
@@ -467,14 +465,13 @@ TEST_CASE_METHOD(Fixture, "DKG public shares test", "[dkg-pub-shares]") {
...
@@ -467,14 +465,13 @@ TEST_CASE_METHOD(Fixture, "DKG public shares test", "[dkg-pub-shares]") {
TEST_CASE_METHOD
(
Fixture
,
"DKG encrypted secret shares test"
,
"[dkg-encr-sshares]"
)
{
TEST_CASE_METHOD
(
Fixture
,
"DKG encrypted secret shares test"
,
"[dkg-encr-sshares]"
)
{
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
result
(
BUF_LEN
,
0
);
vector
<
char
>
result
(
BUF_LEN
,
0
);
int
errStatus
=
0
;
int
errStatus
=
0
;
uint32_t
encLen
=
0
;
uint32_t
encLen
=
0
;
vector
<
uint8_t
>
encryptedDKGSecret
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encryptedDKGSecret
(
BUF_LEN
,
0
);
status
=
trustedGenDkgSecret
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encryptedDKGSecret
.
data
(),
&
encLen
,
2
);
status
=
trustedGenDkgSecret
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encryptedDKGSecret
.
data
(),
&
encLen
,
2
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
// cerr << " poly generated" << endl;
// cerr << " poly generated" << endl;
...
@@ -483,7 +480,7 @@ TEST_CASE_METHOD(Fixture, "DKG encrypted secret shares test", "[dkg-encr-sshares
...
@@ -483,7 +480,7 @@ TEST_CASE_METHOD(Fixture, "DKG encrypted secret shares test", "[dkg-encr-sshares
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
// cerr << " poly set" << endl;
// cerr << " poly set" << endl;
vector
<
uint8_t
>
encrPRDHKey
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encrPRDHKey
(
BUF_LEN
,
0
);
string
pub_keyB
=
"c0152c48bf640449236036075d65898fded1e242c00acb45519ad5f788ea7cbf9a5df1559e7fc87932eee5478b1b9023de19df654395574a690843988c3ff475"
;
string
pub_keyB
=
"c0152c48bf640449236036075d65898fded1e242c00acb45519ad5f788ea7cbf9a5df1559e7fc87932eee5478b1b9023de19df654395574a690843988c3ff475"
;
...
@@ -503,7 +500,7 @@ TEST_CASE_METHOD(Fixture, "DKG verification test", "[dkg-verify]") {
...
@@ -503,7 +500,7 @@ TEST_CASE_METHOD(Fixture, "DKG verification test", "[dkg-verify]") {
int
errStatus
=
0
;
int
errStatus
=
0
;
uint32_t
encLen
=
0
;
uint32_t
encLen
=
0
;
vector
<
uint8_t
>
encryptedDKGSecret
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encryptedDKGSecret
(
BUF_LEN
,
0
);
status
=
trustedGenDkgSecret
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encryptedDKGSecret
.
data
(),
&
encLen
,
2
);
status
=
trustedGenDkgSecret
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encryptedDKGSecret
.
data
(),
&
encLen
,
2
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
...
@@ -513,7 +510,7 @@ TEST_CASE_METHOD(Fixture, "DKG verification test", "[dkg-verify]") {
...
@@ -513,7 +510,7 @@ TEST_CASE_METHOD(Fixture, "DKG verification test", "[dkg-verify]") {
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
// cerr << " poly set" << endl;
// cerr << " poly set" << endl;
vector
<
uint8_t
>
encrPrDHKey
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encrPrDHKey
(
BUF_LEN
,
0
);
string
pub_keyB
=
"c0152c48bf640449236036075d65898fded1e242c00acb45519ad5f788ea7cbf9a5df1559e7fc87932eee5478b1b9023de19df654395574a690843988c3ff475"
;
string
pub_keyB
=
"c0152c48bf640449236036075d65898fded1e242c00acb45519ad5f788ea7cbf9a5df1559e7fc87932eee5478b1b9023de19df654395574a690843988c3ff475"
;
...
@@ -525,16 +522,15 @@ TEST_CASE_METHOD(Fixture, "DKG verification test", "[dkg-verify]") {
...
@@ -525,16 +522,15 @@ TEST_CASE_METHOD(Fixture, "DKG verification test", "[dkg-verify]") {
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
}
}
TEST_CASE_METHOD
(
Fixture
,
"ECDSA keygen and signature test"
,
"[ecdsa]"
)
{
TEST_CASE_METHOD
(
Fixture
,
"ECDSA keygen and signature test"
,
"[ecdsa
-key-sig-gen
]"
)
{
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
int
errStatus
=
0
;
int
errStatus
=
0
;
vector
<
uint8_t
>
encr_pr_key
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encr_pr_key
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_x
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_x
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_y
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_y
(
BUF_LEN
,
0
);
...
@@ -570,12 +566,12 @@ TEST_CASE_METHOD(Fixture, "ECDSA keygen and signature test", "[ecdsa]") {
...
@@ -570,12 +566,12 @@ TEST_CASE_METHOD(Fixture, "ECDSA keygen and signature test", "[ecdsa]") {
}
}
TEST_CASE_METHOD
(
Fixture
,
"Test test"
,
"[
test
]"
)
{
TEST_CASE_METHOD
(
Fixture
,
"Test test"
,
"[
ecdsa-key-gen
]"
)
{
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
int
errStatus
=
0
;
int
errStatus
=
0
;
vector
<
uint8_t
>
encr_pr_key
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encr_pr_key
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_x
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_x
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_y
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_y
(
BUF_LEN
,
0
);
uint32_t
encLen
=
0
;
uint32_t
encLen
=
0
;
...
@@ -584,10 +580,6 @@ TEST_CASE_METHOD(Fixture, "Test test", "[test]") {
...
@@ -584,10 +580,6 @@ TEST_CASE_METHOD(Fixture, "Test test", "[test]") {
pub_key_y
.
data
());
pub_key_y
.
data
());
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
}
}
TEST_CASE_METHOD
(
Fixture
,
"get public ECDSA key"
,
"[get-pub-ecdsa-key]"
)
{
TEST_CASE_METHOD
(
Fixture
,
"get public ECDSA key"
,
"[get-pub-ecdsa-key]"
)
{
...
@@ -595,7 +587,7 @@ TEST_CASE_METHOD(Fixture, "get public ECDSA key", "[get-pub-ecdsa-key]") {
...
@@ -595,7 +587,7 @@ TEST_CASE_METHOD(Fixture, "get public ECDSA key", "[get-pub-ecdsa-key]") {
int
errStatus
=
0
;
int
errStatus
=
0
;
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encPrivKey
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encPrivKey
(
BUF_LEN
,
0
);
vector
<
char
>
pubKeyX
(
BUF_LEN
,
0
);
vector
<
char
>
pubKeyX
(
BUF_LEN
,
0
);
vector
<
char
>
pubKeyY
(
BUF_LEN
,
0
);
vector
<
char
>
pubKeyY
(
BUF_LEN
,
0
);
uint32_t
encLen
=
0
;
uint32_t
encLen
=
0
;
...
@@ -655,8 +647,8 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
...
@@ -655,8 +647,8 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
Json
::
Value
secretShares
[
n
];
Json
::
Value
secretShares
[
n
];
Json
::
Value
pubBLSKeys
[
n
];
Json
::
Value
pubBLSKeys
[
n
];
Json
::
Value
blsSigShares
[
n
];
Json
::
Value
blsSigShares
[
n
];
vector
<
string
>
pubShares
(
n
);
vector
<
string
>
pubShares
(
n
);
vector
<
string
>
polyNames
(
n
);
vector
<
string
>
polyNames
(
n
);
int
schain_id
=
randGen
();
int
schain_id
=
randGen
();
int
dkg_id
=
randGen
();
int
dkg_id
=
randGen
();
...
@@ -691,9 +683,9 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
...
@@ -691,9 +683,9 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
int
k
=
0
;
int
k
=
0
;
vector
<
string
>
secShares_vect
(
n
);
vector
<
string
>
secShares_vect
(
n
);
vector
<
string
>
pSharesBad
(
pubShares
);
vector
<
string
>
pSharesBad
(
pubShares
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
for
(
int
i
=
0
;
i
<
n
;
i
++
)
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
...
@@ -721,14 +713,15 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
...
@@ -721,14 +713,15 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
string
hash
=
"09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db"
;
string
hash
=
"09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db"
;
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
uint64_t
binLen
;
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
()))
{
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
()))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
}
}
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
coeffsPubKeysMap
;
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
coeffsPubKeysMap
;
for
(
int
i
=
0
;
i
<
t
;
i
++
)
{
for
(
int
i
=
0
;
i
<
t
;
i
++
)
{
string
endName
=
polyNames
[
i
].
substr
(
4
);
string
endName
=
polyNames
[
i
].
substr
(
4
);
...
@@ -738,15 +731,15 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
...
@@ -738,15 +731,15 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
c
.
createBLSPrivateKey
(
blsName
,
etnKeys
[
i
][
"keyName"
].
asString
(),
polyNames
[
i
],
secShares_vect
[
i
],
t
,
n
);
c
.
createBLSPrivateKey
(
blsName
,
etnKeys
[
i
][
"keyName"
].
asString
(),
polyNames
[
i
],
secShares_vect
[
i
],
t
,
n
);
pubBLSKeys
[
i
]
=
c
.
getBLSPublicKeyShare
(
blsName
);
pubBLSKeys
[
i
]
=
c
.
getBLSPublicKeyShare
(
blsName
);
blsSigShares
[
i
]
=
c
.
blsSignMessageHash
(
blsName
,
hash
,
t
,
n
,
i
+
1
);
blsSigShares
[
i
]
=
c
.
blsSignMessageHash
(
blsName
,
hash
,
t
,
n
,
i
+
1
);
shared_ptr
<
string
>
sig_share_ptr
=
make_shared
<
string
>
(
blsSigShares
[
i
][
"signatureShare"
].
asString
());
shared_ptr
<
string
>
sig_share_ptr
=
make_shared
<
string
>
(
blsSigShares
[
i
][
"signatureShare"
].
asString
());
BLSSigShare
sig
(
sig_share_ptr
,
i
+
1
,
t
,
n
);
BLSSigShare
sig
(
sig_share_ptr
,
i
+
1
,
t
,
n
);
sigShareSet
.
addSigShare
(
make_shared
<
BLSSigShare
>
(
sig
));
sigShareSet
.
addSigShare
(
make_shared
<
BLSSigShare
>
(
sig
));
vector
<
string
>
pubKeyVect
;
vector
<
string
>
pubKeyVect
;
for
(
uint8_t
j
=
0
;
j
<
4
;
j
++
)
{
for
(
uint8_t
j
=
0
;
j
<
4
;
j
++
)
{
pubKeyVect
.
push_back
(
pubBLSKeys
[
i
][
"blsPublicKeyShare"
][
j
].
asString
());
pubKeyVect
.
push_back
(
pubBLSKeys
[
i
][
"blsPublicKeyShare"
][
j
].
asString
());
}
}
BLSPublicKeyShare
pubKey
(
make_shared
<
vector
<
string
>>
(
pubKeyVect
),
t
,
n
);
BLSPublicKeyShare
pubKey
(
make_shared
<
vector
<
string
>>
(
pubKeyVect
),
t
,
n
);
REQUIRE
(
pubKey
.
VerifySigWithHelper
(
hash_arr
,
make_shared
<
BLSSigShare
>
(
sig
),
t
,
n
));
REQUIRE
(
pubKey
.
VerifySigWithHelper
(
hash_arr
,
make_shared
<
BLSSigShare
>
(
sig
),
t
,
n
));
coeffsPubKeysMap
[
i
+
1
]
=
make_shared
<
BLSPublicKeyShare
>
(
pubKey
);
coeffsPubKeysMap
[
i
+
1
]
=
make_shared
<
BLSPublicKeyShare
>
(
pubKey
);
...
@@ -755,8 +748,9 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
...
@@ -755,8 +748,9 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
cerr
<<
"5"
<<
endl
;
cerr
<<
"5"
<<
endl
;
shared_ptr
<
BLSSignature
>
commonSig
=
sigShareSet
.
merge
();
shared_ptr
<
BLSSignature
>
commonSig
=
sigShareSet
.
merge
();
BLSPublicKey
common_public
(
make_shared
<
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>>
(
coeffsPubKeysMap
),
t
,
n
);
BLSPublicKey
common_public
(
make_shared
<
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
>
(
coeffsPubKeysMap
),
t
,
n
);
REQUIRE
(
common_public
.
VerifySigWithHelper
(
hash_arr
,
commonSig
,
t
,
n
));
REQUIRE
(
common_public
.
VerifySigWithHelper
(
hash_arr
,
commonSig
,
t
,
n
));
cerr
<<
"6"
<<
endl
;
cerr
<<
"6"
<<
endl
;
...
@@ -765,7 +759,7 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
...
@@ -765,7 +759,7 @@ TEST_CASE_METHOD(Fixture, "BLS_DKG test", "[bls-dkg]") {
}
}
TEST_CASE_METHOD
(
Fixture
,
"API test"
,
"[api]"
)
{
TEST_CASE_METHOD
(
Fixture
,
"API test"
,
"[
ecdsa-key-gen-
api]"
)
{
//HttpServer httpserver(1025);
//HttpServer httpserver(1025);
//SGXWalletServer s(httpserver,
//SGXWalletServer s(httpserver,
...
@@ -793,7 +787,6 @@ TEST_CASE_METHOD(Fixture, "API test", "[api]") {
...
@@ -793,7 +787,6 @@ TEST_CASE_METHOD(Fixture, "API test", "[api]") {
"378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25"
);
"378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25"
);
string
share_big0
=
"501e364a6ea516f4812b013bcc150cbb435a2c465c9fd525951264969d8441a986798fd3317c1c3e60f868bb26c4cff837d9185f4be6015d8326437cb5b69480495859cd5a385430ece51252acdc234d8dbde75708b600ac50b2974e813ee26bd87140d88647fcc44df7262bbba24328e8ce622cd627a15b508ffa0db9ae81e0e110fab42cfe40da66b524218ca3c8e5aa3363fbcadef748dc3523a7ffb95b8f5d8141a5163db9f69d1ab223494ed71487c9bb032a74c08a222d897a5e49a617"
;
string
share_big0
=
"501e364a6ea516f4812b013bcc150cbb435a2c465c9fd525951264969d8441a986798fd3317c1c3e60f868bb26c4cff837d9185f4be6015d8326437cb5b69480495859cd5a385430ece51252acdc234d8dbde75708b600ac50b2974e813ee26bd87140d88647fcc44df7262bbba24328e8ce622cd627a15b508ffa0db9ae81e0e110fab42cfe40da66b524218ca3c8e5aa3363fbcadef748dc3523a7ffb95b8f5d8141a5163db9f69d1ab223494ed71487c9bb032a74c08a222d897a5e49a617"
;
string
share_big
=
"03f749e2fcc28021895d757ec16d1636784446f5effcd3096b045136d8ab02657b32adc577f421330b81f5b7063df3b08a0621a897df2584b9046ca416e50ecc27e8c3277e981f7e650f8640289be128eecf0105f89a20e5ffb164744c45cf191d627ce9ab6c44e2ef96f230f2a4de742ea43b6f74b56849138026610b2d965605ececba527048a0f29f46334b1cec1d23df036248b24eccca99057d24764acee66c1a3f2f44771d0d237bf9d18c4177277e3ce3dc4e83686a2647fce1565ee0"
;
string
share_big
=
"03f749e2fcc28021895d757ec16d1636784446f5effcd3096b045136d8ab02657b32adc577f421330b81f5b7063df3b08a0621a897df2584b9046ca416e50ecc27e8c3277e981f7e650f8640289be128eecf0105f89a20e5ffb164744c45cf191d627ce9ab6c44e2ef96f230f2a4de742ea43b6f74b56849138026610b2d965605ececba527048a0f29f46334b1cec1d23df036248b24eccca99057d24764acee66c1a3f2f44771d0d237bf9d18c4177277e3ce3dc4e83686a2647fce1565ee0"
;
string
share
=
share_big
.
substr
(
0
,
192
);
string
share
=
share_big
.
substr
(
0
,
192
);
...
@@ -807,8 +800,6 @@ TEST_CASE_METHOD(Fixture, "API test", "[api]") {
...
@@ -807,8 +800,6 @@ TEST_CASE_METHOD(Fixture, "API test", "[api]") {
string
shares
=
"252122c309ed1f32faa897ede140c5b9c1bc07d5d9c94b7a22d4eeb13da7b7142aa466376a6008de4aab9858aa34848775282c4c3b56370bf25827321619c6e47701c8a32e3f4bb28f5a3b12a09800f318c550cedff6150e9a673ea56ece8b7637092c06c423b627c38ff86d1e66608bdc1496ef855b86e9f773441ac0b285d92aa466376a6008de4aab9858aa34848775282c4c3b56370bf25827321619c6e47701c8a32e3f4bb28f5a3b12a09800f318c550cedff6150e9a673ea56ece8b76"
;
string
shares
=
"252122c309ed1f32faa897ede140c5b9c1bc07d5d9c94b7a22d4eeb13da7b7142aa466376a6008de4aab9858aa34848775282c4c3b56370bf25827321619c6e47701c8a32e3f4bb28f5a3b12a09800f318c550cedff6150e9a673ea56ece8b7637092c06c423b627c38ff86d1e66608bdc1496ef855b86e9f773441ac0b285d92aa466376a6008de4aab9858aa34848775282c4c3b56370bf25827321619c6e47701c8a32e3f4bb28f5a3b12a09800f318c550cedff6150e9a673ea56ece8b76"
;
string
s_share
=
"13b871ad5025fed10a41388265b19886e78f449f758fe8642ade51440fcf850bb2083f87227d8fb53fdfb2854e2d0abec4f47e2197b821b564413af96124cd84a8700f8eb9ed03161888c9ef58d6e5896403de3608e634e23e92fba041aa283484427d0e6de20922216c65865cfe26edd2cf9cbfc3116d007710e8d82feafd9135c497bef0c800ca310ba6044763572681510dad5e043ebd87ffaa1a4cd45a899222207f3d05dec8110d132ad34c62d6a3b40bf8e9f40f875125c3035062d2ca"
;
string
s_share
=
"13b871ad5025fed10a41388265b19886e78f449f758fe8642ade51440fcf850bb2083f87227d8fb53fdfb2854e2d0abec4f47e2197b821b564413af96124cd84a8700f8eb9ed03161888c9ef58d6e5896403de3608e634e23e92fba041aa283484427d0e6de20922216c65865cfe26edd2cf9cbfc3116d007710e8d82feafd9135c497bef0c800ca310ba6044763572681510dad5e043ebd87ffaa1a4cd45a899222207f3d05dec8110d132ad34c62d6a3b40bf8e9f40f875125c3035062d2ca"
;
string
ethKeyName
=
"tmp_NEK:8abc8e8280fb060988b65da4b8cb00779a1e816ec42f8a40ae2daa520e484a01"
;
string
ethKeyName
=
"tmp_NEK:8abc8e8280fb060988b65da4b8cb00779a1e816ec42f8a40ae2daa520e484a01"
;
...
@@ -826,11 +817,9 @@ TEST_CASE_METHOD(Fixture, "getServerStatus test", "[get-server-status]") {
...
@@ -826,11 +817,9 @@ TEST_CASE_METHOD(Fixture, "getServerStatus test", "[get-server-status]") {
}
}
TEST_CASE_METHOD
(
Fixture
,
"ManySimultaneousThreads"
,
"[many-threads-test]"
)
{
TEST_CASE_METHOD
(
Fixture
,
"ManySimultaneousThreads"
,
"[many-threads-test]"
)
{
vector
<
thread
>
threads
;
vector
<
thread
>
threads
;
int
num_threads
=
4
;
int
num_threads
=
4
;
for
(
int
i
=
0
;
i
<
num_threads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num_threads
;
i
++
)
{
threads
.
push_back
(
thread
(
sendRPCRequest
));
threads
.
push_back
(
thread
(
sendRPCRequest
));
...
@@ -843,14 +832,13 @@ TEST_CASE_METHOD(Fixture, "ManySimultaneousThreads", "[many-threads-test]") {
...
@@ -843,14 +832,13 @@ TEST_CASE_METHOD(Fixture, "ManySimultaneousThreads", "[many-threads-test]") {
}
}
TEST_CASE_METHOD
(
Fixture
,
"ecdsa API test"
,
"[ecdsa-api]"
)
{
TEST_CASE_METHOD
(
Fixture
,
"ecdsa API test"
,
"[ecdsa-
key-gen-sign-
api]"
)
{
HttpClient
client
(
"http://localhost:1029"
);
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
Json
::
Value
genKey
=
c
.
generateECDSAKey
();
Json
::
Value
genKey
=
c
.
generateECDSAKey
();
REQUIRE
(
genKey
[
"status"
].
asInt
()
==
0
);
REQUIRE
(
genKey
[
"status"
].
asInt
()
==
0
);
...
@@ -921,7 +909,6 @@ TEST_CASE_METHOD(Fixture, "dkg API test", "[dkg-api]") {
...
@@ -921,7 +909,6 @@ TEST_CASE_METHOD(Fixture, "dkg API test", "[dkg-api]") {
REQUIRE
(
genPolyWrong_t
[
"status"
].
asInt
()
!=
0
);
REQUIRE
(
genPolyWrong_t
[
"status"
].
asInt
()
!=
0
);
Json
::
Value
verifVectWrong_t
=
c
.
getVerificationVector
(
polyName
,
1
,
2
);
Json
::
Value
verifVectWrong_t
=
c
.
getVerificationVector
(
polyName
,
1
,
2
);
REQUIRE
(
verifVectWrong_t
[
"status"
].
asInt
()
!=
0
);
REQUIRE
(
verifVectWrong_t
[
"status"
].
asInt
()
!=
0
);
...
@@ -955,28 +942,25 @@ TEST_CASE_METHOD(Fixture, "dkg API test", "[dkg-api]") {
...
@@ -955,28 +942,25 @@ TEST_CASE_METHOD(Fixture, "dkg API test", "[dkg-api]") {
REQUIRE
(
verificationWrongSkeys
[
"status"
].
asInt
()
!=
0
);
REQUIRE
(
verificationWrongSkeys
[
"status"
].
asInt
()
!=
0
);
}
}
TEST_CASE_METHOD
(
Fixture
,
"
isPolyExists test"
,
"[is-poly
]"
)
{
TEST_CASE_METHOD
(
Fixture
,
"
PolyExists test"
,
"[poly-exists
]"
)
{
HttpClient
client
(
"http://localhost:1029"
);
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
string
polyName
=
"POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1"
;
string
polyName
=
"POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1"
;
Json
::
Value
genPoly
=
c
.
generateDKGPoly
(
polyName
,
2
);
Json
::
Value
genPoly
=
c
.
generateDKGPoly
(
polyName
,
2
);
Json
::
Value
polyExists
=
c
.
isPolyExists
(
polyName
);
Json
::
Value
polyExists
=
c
.
isPolyExists
(
polyName
);
REQUIRE
(
polyExists
[
"
IsExist
"
].
asBool
());
REQUIRE
(
polyExists
[
"
exists
"
].
asBool
());
Json
::
Value
polyDoesNotExist
=
c
.
isPolyExists
(
"Vasya"
);
Json
::
Value
polyDoesNotExist
=
c
.
isPolyExists
(
"Vasya"
);
REQUIRE
(
!
polyDoesNotExist
[
"IsExist"
].
asBool
());
REQUIRE
(
!
polyDoesNotExist
[
"exists"
].
asBool
());
}
}
...
@@ -993,8 +977,8 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -993,8 +977,8 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
Json
::
Value
secretShares
[
n
];
Json
::
Value
secretShares
[
n
];
Json
::
Value
pubBLSKeys
[
n
];
Json
::
Value
pubBLSKeys
[
n
];
Json
::
Value
BLSSigShares
[
n
];
Json
::
Value
BLSSigShares
[
n
];
vector
<
string
>
pubShares
(
n
);
vector
<
string
>
pubShares
(
n
);
vector
<
string
>
poly_names
(
n
);
vector
<
string
>
poly_names
(
n
);
int
schain_id
=
randGen
();
int
schain_id
=
randGen
();
int
dkg_id
=
randGen
();
int
dkg_id
=
randGen
();
...
@@ -1023,7 +1007,7 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -1023,7 +1007,7 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
}
}
int
k
=
0
;
int
k
=
0
;
vector
<
string
>
secShares_vect
(
n
);
vector
<
string
>
secShares_vect
(
n
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
for
(
int
i
=
0
;
i
<
n
;
i
++
)
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
...
@@ -1048,14 +1032,15 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -1048,14 +1032,15 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
string
hash
=
"09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db"
;
string
hash
=
"09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db"
;
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
uint64_t
binLen
;
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
()))
{
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
()))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
}
}
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
coeffs_pkeys_map
;
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
coeffs_pkeys_map
;
for
(
int
i
=
0
;
i
<
t
;
i
++
)
{
for
(
int
i
=
0
;
i
<
t
;
i
++
)
{
string
endName
=
poly_names
[
i
].
substr
(
4
);
string
endName
=
poly_names
[
i
].
substr
(
4
);
...
@@ -1070,29 +1055,30 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -1070,29 +1055,30 @@ TEST_CASE_METHOD(Fixture, "AES_DKG test", "[aes-dkg]") {
REQUIRE
(
BLSSigShares
[
i
][
"status"
]
==
0
);
REQUIRE
(
BLSSigShares
[
i
][
"status"
]
==
0
);
shared_ptr
<
string
>
sig_share_ptr
=
make_shared
<
string
>
(
BLSSigShares
[
i
][
"signatureShare"
].
asString
());
shared_ptr
<
string
>
sig_share_ptr
=
make_shared
<
string
>
(
BLSSigShares
[
i
][
"signatureShare"
].
asString
());
BLSSigShare
sig
(
sig_share_ptr
,
i
+
1
,
t
,
n
);
BLSSigShare
sig
(
sig_share_ptr
,
i
+
1
,
t
,
n
);
sigShareSet
.
addSigShare
(
make_shared
<
BLSSigShare
>
(
sig
));
sigShareSet
.
addSigShare
(
make_shared
<
BLSSigShare
>
(
sig
));
vector
<
string
>
pubKey_vect
;
vector
<
string
>
pubKey_vect
;
for
(
uint8_t
j
=
0
;
j
<
4
;
j
++
)
{
for
(
uint8_t
j
=
0
;
j
<
4
;
j
++
)
{
pubKey_vect
.
push_back
(
pubBLSKeys
[
i
][
"blsPublicKeyShare"
][
j
].
asString
());
pubKey_vect
.
push_back
(
pubBLSKeys
[
i
][
"blsPublicKeyShare"
][
j
].
asString
());
}
}
BLSPublicKeyShare
pubKey
(
make_shared
<
vector
<
string
>>
(
pubKey_vect
),
t
,
n
);
BLSPublicKeyShare
pubKey
(
make_shared
<
vector
<
string
>>
(
pubKey_vect
),
t
,
n
);
REQUIRE
(
pubKey
.
VerifySigWithHelper
(
hash_arr
,
make_shared
<
BLSSigShare
>
(
sig
),
t
,
n
));
REQUIRE
(
pubKey
.
VerifySigWithHelper
(
hash_arr
,
make_shared
<
BLSSigShare
>
(
sig
),
t
,
n
));
coeffs_pkeys_map
[
i
+
1
]
=
make_shared
<
BLSPublicKeyShare
>
(
pubKey
);
coeffs_pkeys_map
[
i
+
1
]
=
make_shared
<
BLSPublicKeyShare
>
(
pubKey
);
}
}
shared_ptr
<
BLSSignature
>
commonSig
=
sigShareSet
.
merge
();
shared_ptr
<
BLSSignature
>
commonSig
=
sigShareSet
.
merge
();
BLSPublicKey
common_public
(
make_shared
<
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>>
(
coeffs_pkeys_map
),
t
,
n
);
BLSPublicKey
common_public
(
make_shared
<
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
>
(
coeffs_pkeys_map
),
t
,
n
);
REQUIRE
(
common_public
.
VerifySigWithHelper
(
hash_arr
,
commonSig
,
t
,
n
));
REQUIRE
(
common_public
.
VerifySigWithHelper
(
hash_arr
,
commonSig
,
t
,
n
));
}
}
TEST_CASE_METHOD
(
Fixture
,
"bls_sign
_api
test"
,
"[bls-sign]"
)
{
TEST_CASE_METHOD
(
Fixture
,
"bls_sign test"
,
"[bls-sign]"
)
{
HttpClient
client
(
"http://localhost:1029"
);
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
...
@@ -1118,7 +1104,7 @@ TEST_CASE_METHOD(Fixture, "AES encrypt/decrypt", "[AES-encrypt-decrypt]") {
...
@@ -1118,7 +1104,7 @@ TEST_CASE_METHOD(Fixture, "AES encrypt/decrypt", "[AES-encrypt-decrypt]") {
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);;
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);;
uint32_t
encLen
;
uint32_t
encLen
;
string
key
=
"123456789"
;
string
key
=
"123456789"
;
vector
<
uint8_t
>
encrypted_key
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encrypted_key
(
BUF_LEN
,
0
);
status
=
trustedEncryptKeyAES
(
eid
,
&
errStatus
,
errMsg
.
data
(),
key
.
c_str
(),
encrypted_key
.
data
(),
&
encLen
);
status
=
trustedEncryptKeyAES
(
eid
,
&
errStatus
,
errMsg
.
data
(),
key
.
c_str
(),
encrypted_key
.
data
(),
&
encLen
);
...
...
testw.py
View file @
45aced00
...
@@ -42,10 +42,11 @@ testList = ["[bls-key-encrypt]", "[dkg-gen]",
...
@@ -42,10 +42,11 @@ testList = ["[bls-key-encrypt]", "[dkg-gen]",
"[test]"
,
"[test]"
,
"[get-pub-ecdsa-key-test]"
,
"[get-pub-ecdsa-key-test]"
,
"[bls-dkg]"
,
"[bls-dkg]"
,
"[api]"
,
"[
ecdsa-
api]"
,
"[get-server-status]"
,
"[get-server-status]"
,
"[many-threads]"
,
"[many-threads]"
,
"[ecdsa-api]"
,
"[ecdsa-key-gen-api]"
,
"[ecdsa-key-gen-sign-api]"
,
"[dkg-api]"
,
"[dkg-api]"
,
"[is-poly]"
,
"[is-poly]"
,
# "[bls-sign]",
# "[bls-sign]",
...
...
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