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
45fa3241
Unverified
Commit
45fa3241
authored
Jun 09, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2002 improve tests
parent
c79ad665
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
14 deletions
+24
-14
testw.cpp
testw.cpp
+24
-14
No files found.
testw.cpp
View file @
45fa3241
...
@@ -533,9 +533,6 @@ TEST_CASE_METHOD(TestFixture, "DKG AES gen test", "[dkg-aes-gen]") {
...
@@ -533,9 +533,6 @@ TEST_CASE_METHOD(TestFixture, "DKG AES gen test", "[dkg-aes-gen]") {
(
uint8_t
*
)
secret
.
data
(),
&
encLen
);
(
uint8_t
*
)
secret
.
data
(),
&
encLen
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
for
(
auto
&
elem
:
errMsg1
)
{
std
::
cout
<<
elem
;
}
REQUIRE
(
errStatus
==
SGX_SUCCESS
);
REQUIRE
(
errStatus
==
SGX_SUCCESS
);
}
}
...
@@ -559,6 +556,8 @@ TEST_CASE_METHOD(TestFixture, "DKG public shares test", "[dkg-pub-shares]") {
...
@@ -559,6 +556,8 @@ TEST_CASE_METHOD(TestFixture, "DKG public shares test", "[dkg-pub-shares]") {
status
=
trustedGetPublicShares
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
status
=
trustedGetPublicShares
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encryptedDKGSecret
.
data
(),
encLen
,
pubShares
.
data
(),
t
,
n
);
encryptedDKGSecret
.
data
(),
encLen
,
pubShares
.
data
(),
t
,
n
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
errStatus
==
SGX_SUCCESS
);
vector
<
string
>
g2Strings
=
splitString
(
pubShares
.
data
(),
','
);
vector
<
string
>
g2Strings
=
splitString
(
pubShares
.
data
(),
','
);
vector
<
libff
::
alt_bn128_G2
>
pubSharesG2
;
vector
<
libff
::
alt_bn128_G2
>
pubSharesG2
;
...
@@ -612,6 +611,8 @@ TEST_CASE_METHOD(TestFixture, "DKG AES public shares test", "[dkg-aes-pub-shares
...
@@ -612,6 +611,8 @@ TEST_CASE_METHOD(TestFixture, "DKG AES public shares test", "[dkg-aes-pub-shares
status
=
trustedGetPublicSharesAES
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
status
=
trustedGetPublicSharesAES
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encryptedDKGSecret
.
data
(),
encLen
,
pubShares
.
data
(),
t
,
n
);
encryptedDKGSecret
.
data
(),
encLen
,
pubShares
.
data
(),
t
,
n
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
errStatus
==
SGX_SUCCESS
);
vector
<
string
>
g2Strings
=
splitString
(
pubShares
.
data
(),
','
);
vector
<
string
>
g2Strings
=
splitString
(
pubShares
.
data
(),
','
);
vector
<
libff
::
alt_bn128_G2
>
pubSharesG2
;
vector
<
libff
::
alt_bn128_G2
>
pubSharesG2
;
...
@@ -746,10 +747,12 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
...
@@ -746,10 +747,12 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
int
dkgID
=
randGen
();
int
dkgID
=
randGen
();
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
etnKeys
[
i
]
=
c
.
generateECDSAKey
();
etnKeys
[
i
]
=
c
.
generateECDSAKey
();
REQUIRE
(
ethKeys
[
i
][
"status"
]
==
0
);
string
polyName
=
string
polyName
=
"POLY:SCHAIN_ID:"
+
to_string
(
schainID
)
+
":NODE_ID:"
+
to_string
(
i
)
+
":DKG_ID:"
+
to_string
(
dkgID
);
"POLY:SCHAIN_ID:"
+
to_string
(
schainID
)
+
":NODE_ID:"
+
to_string
(
i
)
+
":DKG_ID:"
+
to_string
(
dkgID
);
c
.
generateDKGPoly
(
polyName
,
t
);
auto
response
=
c
.
generateDKGPoly
(
polyName
,
t
);
REQUIRE
(
response
[
"status"
]
==
0
);
polyNames
[
i
]
=
polyName
;
polyNames
[
i
]
=
polyName
;
verifVects
[
i
]
=
c
.
getVerificationVector
(
polyName
,
t
,
n
);
verifVects
[
i
]
=
c
.
getVerificationVector
(
polyName
,
t
,
n
);
REQUIRE
(
verifVects
[
i
][
"status"
]
==
0
);
REQUIRE
(
verifVects
[
i
][
"status"
]
==
0
);
...
@@ -778,12 +781,15 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
...
@@ -778,12 +781,15 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
string
secretShare
=
secretShares
[
i
][
"secretShare"
].
asString
().
substr
(
192
*
j
,
192
);
string
secretShare
=
secretShares
[
i
][
"secretShare"
].
asString
().
substr
(
192
*
j
,
192
);
secShares
[
i
]
+=
secretShares
[
j
][
"secretShare"
].
asString
().
substr
(
192
*
i
,
192
);
secShares
[
i
]
+=
secretShares
[
j
][
"secretShare"
].
asString
().
substr
(
192
*
i
,
192
);
bool
res
=
c
.
dkgVerification
(
pubShares
[
i
],
etnKeys
[
j
][
"keyName"
].
asString
(),
secretShare
,
t
,
n
,
auto
responce
=
c
.
dkgVerification
(
pubShares
[
i
],
etnKeys
[
j
][
"keyName"
].
asString
(),
secretShare
,
t
,
n
,
j
)[
"result"
].
asBool
();
j
)[
"result"
].
asBool
();
k
++
;
REQUIRE
(
responce
[
"status"
]
==
0
)
;
bool
res
=
responce
[
"result"
].
asBool
();
REQUIRE
(
res
);
REQUIRE
(
res
);
k
++
;
pSharesBad
[
i
][
0
]
=
'q'
;
pSharesBad
[
i
][
0
]
=
'q'
;
Json
::
Value
wrongVerif
=
c
.
dkgVerification
(
pSharesBad
[
i
],
etnKeys
[
j
][
"keyName"
].
asString
(),
secretShare
,
t
,
Json
::
Value
wrongVerif
=
c
.
dkgVerification
(
pSharesBad
[
i
],
etnKeys
[
j
][
"keyName"
].
asString
(),
secretShare
,
t
,
n
,
j
);
n
,
j
);
...
@@ -924,13 +930,13 @@ TEST_CASE_METHOD(TestFixture, "PolyExists test", "[dkg-poly-exists]") {
...
@@ -924,13 +930,13 @@ TEST_CASE_METHOD(TestFixture, "PolyExists test", "[dkg-poly-exists]") {
string
polyName
=
SAMPLE_POLY_NAME
;
string
polyName
=
SAMPLE_POLY_NAME
;
Json
::
Value
genPoly
=
c
.
generateDKGPoly
(
polyName
,
2
);
Json
::
Value
genPoly
=
c
.
generateDKGPoly
(
polyName
,
2
);
REQUIRE
(
genPoly
[
"status"
]
==
0
);
Json
::
Value
polyExists
=
c
.
isPolyExists
(
polyName
);
Json
::
Value
polyExists
=
c
.
isPolyExists
(
polyName
);
REQUIRE
(
polyExists
[
"status"
]
==
0
);
REQUIRE
(
polyExists
[
"IsExist"
].
asBool
());
REQUIRE
(
polyExists
[
"IsExist"
].
asBool
());
Json
::
Value
polyDoesNotExist
=
c
.
isPolyExists
(
"Vasya"
);
Json
::
Value
polyDoesNotExist
=
c
.
isPolyExists
(
"Vasya"
);
REQUIRE
(
!
polyDoesNotExist
[
"IsExist"
].
asBool
());
REQUIRE
(
!
polyDoesNotExist
[
"IsExist"
].
asBool
());
}
}
...
@@ -952,20 +958,24 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -952,20 +958,24 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
int
dkgID
=
randGen
();
int
dkgID
=
randGen
();
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
ethKeys
[
i
]
=
c
.
generateECDSAKey
();
ethKeys
[
i
]
=
c
.
generateECDSAKey
();
REQUIRE
(
ethKeys
[
i
][
"status"
]
==
0
);
string
polyName
=
string
polyName
=
"POLY:SCHAIN_ID:"
+
to_string
(
schainID
)
+
":NODE_ID:"
+
to_string
(
i
)
+
":DKG_ID:"
+
to_string
(
dkgID
);
"POLY:SCHAIN_ID:"
+
to_string
(
schainID
)
+
":NODE_ID:"
+
to_string
(
i
)
+
":DKG_ID:"
+
to_string
(
dkgID
);
REQUIRE
(
ethKeys
[
i
][
"status"
]
==
0
);
REQUIRE
(
ethKeys
[
i
][
"status"
]
==
0
);
c
.
generateDKGPoly
(
polyName
,
t
);
auto
response
=
c
.
generateDKGPoly
(
polyName
,
t
);
REQUIRE
(
response
[
"status"
]
==
0
);
polyNames
[
i
]
=
polyName
;
polyNames
[
i
]
=
polyName
;
verifVects
[
i
]
=
c
.
getVerificationVector
(
polyName
,
t
,
n
);
verifVects
[
i
]
=
c
.
getVerificationVector
(
polyName
,
t
,
n
);
REQUIRE
(
verifVects
[
i
][
"status"
]
==
0
);
pubEthKeys
.
append
(
ethKeys
[
i
][
"publicKey"
]);
pubEthKeys
.
append
(
ethKeys
[
i
][
"publicKey"
]);
}
}
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
secretShares
[
i
]
=
c
.
getSecretShare
(
polyNames
[
i
],
pubEthKeys
,
t
,
n
);
secretShares
[
i
]
=
c
.
getSecretShare
(
polyNames
[
i
],
pubEthKeys
,
t
,
n
);
REQUIRE
(
secretShares
[
i
][
"status"
]
==
0
);
REQUIRE
(
secretShares
[
i
][
"status"
]
==
0
);
for
(
uint8_t
k
=
0
;
k
<
t
;
k
++
)
for
(
uint8_t
k
=
0
;
k
<
t
;
k
++
)
for
(
uint8_t
j
=
0
;
j
<
4
;
j
++
)
{
for
(
uint8_t
j
=
0
;
j
<
4
;
j
++
)
{
string
pubShare
=
verifVects
[
i
][
"verificationVector"
][
k
][
j
].
asString
();
string
pubShare
=
verifVects
[
i
][
"verificationVector"
][
k
][
j
].
asString
();
...
@@ -981,13 +991,13 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -981,13 +991,13 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
string
secretShare
=
secretShares
[
i
][
"secretShare"
].
asString
().
substr
(
192
*
j
,
192
);
string
secretShare
=
secretShares
[
i
][
"secretShare"
].
asString
().
substr
(
192
*
j
,
192
);
secShares
[
i
]
+=
secretShares
[
j
][
"secretShare"
].
asString
().
substr
(
192
*
i
,
192
);
secShares
[
i
]
+=
secretShares
[
j
][
"secretShare"
].
asString
().
substr
(
192
*
i
,
192
);
Json
::
Value
verif
=
c
.
dkgVerification
(
pubShares
[
i
],
ethKeys
[
j
][
"keyName"
].
asString
(),
secretShare
,
t
,
n
,
j
);
Json
::
Value
verif
=
c
.
dkgVerification
(
pubShares
[
i
],
ethKeys
[
j
][
"keyName"
].
asString
(),
secretShare
,
t
,
n
,
j
);
REQUIRE
(
verif
[
"status"
]
==
0
);
bool
res
=
verif
[
"result"
].
asBool
();
bool
res
=
verif
[
"result"
].
asBool
();
k
++
;
k
++
;
REQUIRE
(
res
);
REQUIRE
(
res
);
}
}
Json
::
Value
complaintResponse
=
c
.
complaintResponse
(
polyNames
[
1
],
0
);
Json
::
Value
complaintResponse
=
c
.
complaintResponse
(
polyNames
[
1
],
0
);
REQUIRE
(
complaintResponse
[
"status"
]
==
0
);
REQUIRE
(
complaintResponse
[
"status"
]
==
0
);
BLSSigShareSet
sigShareSet
(
t
,
n
);
BLSSigShareSet
sigShareSet
(
t
,
n
);
...
@@ -1007,14 +1017,14 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -1007,14 +1017,14 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
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
);
string
blsName
=
"BLS_KEY"
+
polyNames
[
i
].
substr
(
4
);
string
blsName
=
"BLS_KEY"
+
polyNames
[
i
].
substr
(
4
);
c
.
createBLSPrivateKey
(
blsName
,
ethKeys
[
i
][
"keyName"
].
asString
(),
polyNames
[
i
],
secShares
[
i
],
t
,
n
);
auto
response
=
c
.
createBLSPrivateKey
(
blsName
,
ethKeys
[
i
][
"keyName"
].
asString
(),
polyNames
[
i
],
secShares
[
i
],
t
,
n
);
pubBLSKeys
[
i
]
=
c
.
getBLSPublicKeyShare
(
blsName
);
REQUIRE
(
response
[
"status"
]
==
0
);
pubBLSKeys
[
i
]
=
c
.
getBLSPublicKeyShare
(
blsName
);
REQUIRE
(
pubBLSKeys
[
i
][
"status"
]
==
0
);
REQUIRE
(
pubBLSKeys
[
i
][
"status"
]
==
0
);
string
hash
=
SAMPLE_HASH
;
string
hash
=
SAMPLE_HASH
;
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
());
...
...
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