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
f4c89a31
Unverified
Commit
f4c89a31
authored
4 years ago
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2002 clean up
parent
15743726
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
66 deletions
+0
-66
testw.cpp
testw.cpp
+0
-66
No files found.
testw.cpp
View file @
f4c89a31
...
@@ -120,7 +120,6 @@ void resetDB() {
...
@@ -120,7 +120,6 @@ void resetDB() {
}
}
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
;
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);;
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);;
...
@@ -129,7 +128,6 @@ shared_ptr <string> encryptTestKey() {
...
@@ -129,7 +128,6 @@ shared_ptr <string> encryptTestKey() {
REQUIRE
(
encryptedKeyHex
!=
nullptr
);
REQUIRE
(
encryptedKeyHex
!=
nullptr
);
REQUIRE
(
errStatus
==
0
);
REQUIRE
(
errStatus
==
0
);
return
make_shared
<
string
>
(
encryptedKeyHex
);
return
make_shared
<
string
>
(
encryptedKeyHex
);
}
}
...
@@ -155,7 +153,6 @@ vector <libff::alt_bn128_Fr> splitStringToFr(const char *coeffs, const char symb
...
@@ -155,7 +153,6 @@ vector <libff::alt_bn128_Fr> splitStringToFr(const char *coeffs, const char symb
}
}
vector
<
string
>
splitStringTest
(
const
char
*
coeffs
,
const
char
symbol
)
{
vector
<
string
>
splitStringTest
(
const
char
*
coeffs
,
const
char
symbol
)
{
string
str
(
coeffs
);
string
str
(
coeffs
);
string
delim
;
string
delim
;
delim
.
push_back
(
symbol
);
delim
.
push_back
(
symbol
);
...
@@ -176,7 +173,6 @@ vector <string> splitStringTest(const char *coeffs, const char symbol) {
...
@@ -176,7 +173,6 @@ vector <string> splitStringTest(const char *coeffs, const char symbol) {
}
}
libff
::
alt_bn128_G2
vectStringToG2
(
const
vector
<
string
>
&
G2_str_vect
)
{
libff
::
alt_bn128_G2
vectStringToG2
(
const
vector
<
string
>
&
G2_str_vect
)
{
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
());
coeff
.
X
.
c1
=
libff
::
alt_bn128_Fq
(
G2_str_vect
.
at
(
1
).
c_str
());
coeff
.
X
.
c1
=
libff
::
alt_bn128_Fq
(
G2_str_vect
.
at
(
1
).
c_str
());
...
@@ -190,11 +186,9 @@ libff::alt_bn128_G2 vectStringToG2(const vector <string> &G2_str_vect) {
...
@@ -190,11 +186,9 @@ libff::alt_bn128_G2 vectStringToG2(const vector <string> &G2_str_vect) {
void
sendRPCRequest
()
{
void
sendRPCRequest
()
{
HttpClient
client
(
RPC_ENDPOINT
);
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
int
n
=
16
,
t
=
16
;
int
n
=
16
,
t
=
16
;
Json
::
Value
ethKeys
[
n
];
Json
::
Value
ethKeys
[
n
];
Json
::
Value
verifVects
[
n
];
Json
::
Value
verifVects
[
n
];
...
@@ -236,13 +230,11 @@ void sendRPCRequest() {
...
@@ -236,13 +230,11 @@ void sendRPCRequest() {
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
++
)
{
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
);
k
++
;
k
++
;
}
}
...
@@ -276,12 +268,9 @@ void sendRPCRequest() {
...
@@ -276,12 +268,9 @@ void sendRPCRequest() {
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
();
}
}
...
@@ -362,8 +351,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA key gen", "[ecdsa-key-gen]") {
...
@@ -362,8 +351,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA key gen", "[ecdsa-key-gen]") {
}
}
TEST_CASE_METHOD
(
TestFixture
,
"ECDSA get public key"
,
"[ecdsa-get-pub-key]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"ECDSA get public key"
,
"[ecdsa-get-pub-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
);
...
@@ -371,7 +358,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA get public key", "[ecdsa-get-pub-key]") {
...
@@ -371,7 +358,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA get public key", "[ecdsa-get-pub-key]") {
vector
<
char
>
pubKeyY
(
BUF_LEN
,
0
);
vector
<
char
>
pubKeyY
(
BUF_LEN
,
0
);
uint32_t
encLen
=
0
;
uint32_t
encLen
=
0
;
status
=
trustedGenerateEcdsaKey
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encPrivKey
.
data
(),
&
encLen
,
pubKeyX
.
data
(),
status
=
trustedGenerateEcdsaKey
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encPrivKey
.
data
(),
&
encLen
,
pubKeyX
.
data
(),
pubKeyY
.
data
());
pubKeyY
.
data
());
...
@@ -450,8 +436,6 @@ TEST_CASE_METHOD(TestFixture, "BLS key encrypt", "[bls-key-encrypt]") {
...
@@ -450,8 +436,6 @@ TEST_CASE_METHOD(TestFixture, "BLS key encrypt", "[bls-key-encrypt]") {
}
}
TEST_CASE_METHOD
(
TestFixture
,
"DKG gen test"
,
"[dkg-gen]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"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
);
...
@@ -469,13 +453,10 @@ TEST_CASE_METHOD(TestFixture, "DKG gen test", "[dkg-gen]") {
...
@@ -469,13 +453,10 @@ TEST_CASE_METHOD(TestFixture, "DKG gen test", "[dkg-gen]") {
(
uint8_t
*
)
secret
.
data
(),
&
dec_len
);
(
uint8_t
*
)
secret
.
data
(),
&
dec_len
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
}
}
TEST_CASE_METHOD
(
TestFixture
,
"DKG public shares test"
,
"[dkg-pub-shares]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"DKG public shares test"
,
"[dkg-pub-shares]"
)
{
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
);
...
@@ -495,7 +476,6 @@ TEST_CASE_METHOD(TestFixture, "DKG public shares test", "[dkg-pub-shares]") {
...
@@ -495,7 +476,6 @@ 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
);
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
++
)
{
...
@@ -525,13 +505,10 @@ TEST_CASE_METHOD(TestFixture, "DKG public shares test", "[dkg-pub-shares]") {
...
@@ -525,13 +505,10 @@ TEST_CASE_METHOD(TestFixture, "DKG public shares test", "[dkg-pub-shares]") {
mpz_clear
(
x_c0
);
mpz_clear
(
x_c0
);
}
}
REQUIRE
(
pubSharesG2
==
pubSharesDkg
);
REQUIRE
(
pubSharesG2
==
pubSharesDkg
);
}
}
TEST_CASE_METHOD
(
TestFixture
,
"DKG encrypted secret shares test"
,
"[dkg-encr-sshares]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"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
);
...
@@ -581,11 +558,9 @@ TEST_CASE_METHOD(TestFixture, "DKG encrypted secret shares test", "[dkg-encr-ssh
...
@@ -581,11 +558,9 @@ TEST_CASE_METHOD(TestFixture, "DKG encrypted secret shares test", "[dkg-encr-ssh
TEST_CASE_METHOD
(
TestFixture
,
"DKG_BLS test"
,
"[dkg-bls]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"DKG_BLS test"
,
"[dkg-bls]"
)
{
HttpClient
client
(
RPC_ENDPOINT
);
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
int
n
=
16
,
t
=
16
;
int
n
=
16
,
t
=
16
;
Json
::
Value
etnKeys
[
n
];
Json
::
Value
etnKeys
[
n
];
Json
::
Value
verifVects
[
n
];
Json
::
Value
verifVects
[
n
];
...
@@ -632,8 +607,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
...
@@ -632,8 +607,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
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
++
)
{
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
,
bool
res
=
c
.
dkgVerification
(
pubShares
[
i
],
etnKeys
[
j
][
"keyName"
].
asString
(),
secretShare
,
t
,
n
,
...
@@ -647,7 +620,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
...
@@ -647,7 +620,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
n
,
j
);
n
,
j
);
res
=
wrongVerif
[
"result"
].
asBool
();
res
=
wrongVerif
[
"result"
].
asBool
();
REQUIRE
(
!
res
);
REQUIRE
(
!
res
);
}
}
BLSSigShareSet
sigShareSet
(
t
,
n
);
BLSSigShareSet
sigShareSet
(
t
,
n
);
...
@@ -685,7 +657,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
...
@@ -685,7 +657,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
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
);
}
}
...
@@ -693,7 +664,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
...
@@ -693,7 +664,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
BLSPublicKey
common_public
(
make_shared
<
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
>
(
coeffsPubKeysMap
),
t
,
BLSPublicKey
common_public
(
make_shared
<
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
>
(
coeffsPubKeysMap
),
t
,
n
);
n
);
REQUIRE
(
common_public
.
VerifySigWithHelper
(
hash_arr
,
commonSig
,
t
,
n
));
REQUIRE
(
common_public
.
VerifySigWithHelper
(
hash_arr
,
commonSig
,
t
,
n
));
}
}
...
@@ -701,18 +671,15 @@ TEST_CASE_METHOD(TestFixture, "Get ServerStatus", "[get-server-status]") {
...
@@ -701,18 +671,15 @@ TEST_CASE_METHOD(TestFixture, "Get ServerStatus", "[get-server-status]") {
HttpClient
client
(
RPC_ENDPOINT
);
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
REQUIRE
(
c
.
getServerStatus
()[
"status"
]
==
0
);
REQUIRE
(
c
.
getServerStatus
()[
"status"
]
==
0
);
}
}
TEST_CASE_METHOD
(
TestFixture
,
"Get ServerVersion"
,
"[get-server-version]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"Get ServerVersion"
,
"[get-server-version]"
)
{
HttpClient
client
(
RPC_ENDPOINT
);
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
REQUIRE
(
c
.
getServerVersion
()[
"version"
]
==
SGXWalletServer
::
getVersion
());
REQUIRE
(
c
.
getServerVersion
()[
"version"
]
==
SGXWalletServer
::
getVersion
());
}
}
TEST_CASE_METHOD
(
TestFixtureHTTPS
,
"Cert request sign"
,
"[cert-sign]"
)
{
TEST_CASE_METHOD
(
TestFixtureHTTPS
,
"Cert request sign"
,
"[cert-sign]"
)
{
REQUIRE
(
SGXRegistrationServer
::
getServer
()
!=
nullptr
);
REQUIRE
(
SGXRegistrationServer
::
getServer
()
!=
nullptr
);
string
csrFile
=
"insecure-samples/yourdomain.csr"
;
string
csrFile
=
"insecure-samples/yourdomain.csr"
;
...
@@ -735,15 +702,11 @@ TEST_CASE_METHOD(TestFixtureHTTPS, "Cert request sign", "[cert-sign]") {
...
@@ -735,15 +702,11 @@ TEST_CASE_METHOD(TestFixtureHTTPS, "Cert request sign", "[cert-sign]") {
TEST_CASE_METHOD
(
TestFixture
,
"DKG API test"
,
"[dkg-api]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"DKG API test"
,
"[dkg-api]"
)
{
HttpClient
client
(
RPC_ENDPOINT
);
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
string
polyName
=
SAMPLE_POLY_NAME
;
string
polyName
=
SAMPLE_POLY_NAME
;
Json
::
Value
genPoly
=
c
.
generateDKGPoly
(
polyName
,
2
);
Json
::
Value
genPoly
=
c
.
generateDKGPoly
(
polyName
,
2
);
Json
::
Value
publicKeys
;
Json
::
Value
publicKeys
;
...
@@ -757,57 +720,43 @@ TEST_CASE_METHOD(TestFixture, "DKG API test", "[dkg-api]") {
...
@@ -757,57 +720,43 @@ TEST_CASE_METHOD(TestFixture, "DKG API test", "[dkg-api]") {
Json
::
Value
verifVectWrongName
=
c
.
getVerificationVector
(
"poly"
,
2
,
2
);
Json
::
Value
verifVectWrongName
=
c
.
getVerificationVector
(
"poly"
,
2
,
2
);
REQUIRE
(
verifVectWrongName
[
"status"
].
asInt
()
!=
0
);
REQUIRE
(
verifVectWrongName
[
"status"
].
asInt
()
!=
0
);
Json
::
Value
secretSharesWrongName
=
c
.
getSecretShare
(
"poly"
,
publicKeys
,
2
,
2
);
Json
::
Value
secretSharesWrongName
=
c
.
getSecretShare
(
"poly"
,
publicKeys
,
2
,
2
);
REQUIRE
(
secretSharesWrongName
[
"status"
].
asInt
()
!=
0
);
REQUIRE
(
secretSharesWrongName
[
"status"
].
asInt
()
!=
0
);
// wrong_t
// wrong_t
Json
::
Value
genPolyWrong_t
=
c
.
generateDKGPoly
(
polyName
,
33
);
Json
::
Value
genPolyWrong_t
=
c
.
generateDKGPoly
(
polyName
,
33
);
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
);
Json
::
Value
secretSharesWrong_t
=
c
.
getSecretShare
(
polyName
,
publicKeys
,
3
,
3
);
Json
::
Value
secretSharesWrong_t
=
c
.
getSecretShare
(
polyName
,
publicKeys
,
3
,
3
);
REQUIRE
(
secretSharesWrong_t
[
"status"
].
asInt
()
!=
0
);
REQUIRE
(
secretSharesWrong_t
[
"status"
].
asInt
()
!=
0
);
// wrong_n
// wrong_n
Json
::
Value
verifVectWrong_n
=
c
.
getVerificationVector
(
polyName
,
2
,
1
);
Json
::
Value
verifVectWrong_n
=
c
.
getVerificationVector
(
polyName
,
2
,
1
);
REQUIRE
(
verifVectWrong_n
[
"status"
].
asInt
()
!=
0
);
REQUIRE
(
verifVectWrong_n
[
"status"
].
asInt
()
!=
0
);
Json
::
Value
publicKeys1
;
Json
::
Value
publicKeys1
;
publicKeys1
.
append
(
SAMPLE_DKG_PUB_KEY_1
);
publicKeys1
.
append
(
SAMPLE_DKG_PUB_KEY_1
);
Json
::
Value
secretSharesWrong_n
=
c
.
getSecretShare
(
polyName
,
publicKeys1
,
2
,
1
);
Json
::
Value
secretSharesWrong_n
=
c
.
getSecretShare
(
polyName
,
publicKeys1
,
2
,
1
);
REQUIRE
(
secretSharesWrong_n
[
"status"
].
asInt
()
!=
0
);
REQUIRE
(
secretSharesWrong_n
[
"status"
].
asInt
()
!=
0
);
//wrong number of publicKeys
//wrong number of publicKeys
Json
::
Value
secretSharesWrongPkeys
=
c
.
getSecretShare
(
polyName
,
publicKeys
,
2
,
3
);
Json
::
Value
secretSharesWrongPkeys
=
c
.
getSecretShare
(
polyName
,
publicKeys
,
2
,
3
);
REQUIRE
(
secretSharesWrongPkeys
[
"status"
].
asInt
()
!=
0
);
REQUIRE
(
secretSharesWrongPkeys
[
"status"
].
asInt
()
!=
0
);
//wrong verif
//wrong verif
Json
::
Value
Skeys
=
c
.
getSecretShare
(
polyName
,
publicKeys
,
2
,
2
);
Json
::
Value
Skeys
=
c
.
getSecretShare
(
polyName
,
publicKeys
,
2
,
2
);
Json
::
Value
verifVect
=
c
.
getVerificationVector
(
polyName
,
2
,
2
);
Json
::
Value
verifVect
=
c
.
getVerificationVector
(
polyName
,
2
,
2
);
Json
::
Value
verificationWrongSkeys
=
c
.
dkgVerification
(
""
,
""
,
""
,
2
,
2
,
1
);
Json
::
Value
verificationWrongSkeys
=
c
.
dkgVerification
(
""
,
""
,
""
,
2
,
2
,
1
);
REQUIRE
(
verificationWrongSkeys
[
"status"
].
asInt
()
!=
0
);
REQUIRE
(
verificationWrongSkeys
[
"status"
].
asInt
()
!=
0
);
}
}
TEST_CASE_METHOD
(
TestFixture
,
"PolyExists test"
,
"[dkg-poly-exists]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"PolyExists test"
,
"[dkg-poly-exists]"
)
{
HttpClient
client
(
RPC_ENDPOINT
);
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
string
polyName
=
SAMPLE_POLY_NAME
;
string
polyName
=
SAMPLE_POLY_NAME
;
Json
::
Value
genPoly
=
c
.
generateDKGPoly
(
polyName
,
2
);
Json
::
Value
genPoly
=
c
.
generateDKGPoly
(
polyName
,
2
);
...
@@ -818,15 +767,12 @@ TEST_CASE_METHOD(TestFixture, "PolyExists test", "[dkg-poly-exists]") {
...
@@ -818,15 +767,12 @@ TEST_CASE_METHOD(TestFixture, "PolyExists test", "[dkg-poly-exists]") {
Json
::
Value
polyDoesNotExist
=
c
.
isPolyExists
(
"Vasya"
);
Json
::
Value
polyDoesNotExist
=
c
.
isPolyExists
(
"Vasya"
);
REQUIRE
(
!
polyDoesNotExist
[
"IsExist"
].
asBool
());
REQUIRE
(
!
polyDoesNotExist
[
"IsExist"
].
asBool
());
}
}
TEST_CASE_METHOD
(
TestFixture
,
"AES_DKG test"
,
"[aes-dkg]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"AES_DKG test"
,
"[aes-dkg]"
)
{
HttpClient
client
(
RPC_ENDPOINT
);
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
int
n
=
2
,
t
=
2
;
int
n
=
2
,
t
=
2
;
Json
::
Value
ethKeys
[
n
];
Json
::
Value
ethKeys
[
n
];
Json
::
Value
verifVects
[
n
];
Json
::
Value
verifVects
[
n
];
...
@@ -860,7 +806,6 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -860,7 +806,6 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
string
pubShare
=
verifVects
[
i
][
"verificationVector"
][
k
][
j
].
asString
();
string
pubShare
=
verifVects
[
i
][
"verificationVector"
][
k
][
j
].
asString
();
pubShares
[
i
]
+=
convertDecToHex
(
pubShare
);
pubShares
[
i
]
+=
convertDecToHex
(
pubShare
);
}
}
}
}
int
k
=
0
;
int
k
=
0
;
...
@@ -868,7 +813,6 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -868,7 +813,6 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
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
++
)
{
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
);
...
@@ -877,7 +821,6 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -877,7 +821,6 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
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
);
...
@@ -894,7 +837,6 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -894,7 +837,6 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
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
++
)
{
...
@@ -922,20 +864,15 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
...
@@ -922,20 +864,15 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
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
,
BLSPublicKey
common_public
(
make_shared
<
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
>
(
coeffs_pkeys_map
),
t
,
n
);
n
);
REQUIRE
(
common_public
.
VerifySigWithHelper
(
hash_arr
,
commonSig
,
t
,
n
));
REQUIRE
(
common_public
.
VerifySigWithHelper
(
hash_arr
,
commonSig
,
t
,
n
));
}
}
TEST_CASE_METHOD
(
TestFixture
,
"AES encrypt/decrypt"
,
"[aes-encrypt-decrypt]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"AES encrypt/decrypt"
,
"[aes-encrypt-decrypt]"
)
{
int
errStatus
=
-
1
;
int
errStatus
=
-
1
;
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
uint32_t
encLen
;
uint32_t
encLen
;
...
@@ -959,8 +896,6 @@ TEST_CASE_METHOD(TestFixture, "AES encrypt/decrypt", "[aes-encrypt-decrypt]") {
...
@@ -959,8 +896,6 @@ TEST_CASE_METHOD(TestFixture, "AES encrypt/decrypt", "[aes-encrypt-decrypt]") {
TEST_CASE_METHOD
(
TestFixture
,
"SGX encrypt/decrypt"
,
"[sgx-encrypt-decrypt]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"SGX encrypt/decrypt"
,
"[sgx-encrypt-decrypt]"
)
{
int
errStatus
=
-
1
;
int
errStatus
=
-
1
;
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
uint32_t
encLen
;
uint32_t
encLen
;
...
@@ -979,7 +914,6 @@ TEST_CASE_METHOD(TestFixture, "SGX encrypt/decrypt", "[sgx-encrypt-decrypt]") {
...
@@ -979,7 +914,6 @@ TEST_CASE_METHOD(TestFixture, "SGX encrypt/decrypt", "[sgx-encrypt-decrypt]") {
REQUIRE
(
status
==
0
);
REQUIRE
(
status
==
0
);
REQUIRE
(
errStatus
==
0
);
REQUIRE
(
errStatus
==
0
);
REQUIRE
(
key
.
compare
(
decr_key
.
data
())
==
0
);
REQUIRE
(
key
.
compare
(
decr_key
.
data
())
==
0
);
}
}
...
...
This diff is collapsed.
Click to expand it.
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