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
d635fca0
Unverified
Commit
d635fca0
authored
Jun 08, 2021
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3951 fix getStatus, add tests
parent
6dfd5e58
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
27 deletions
+53
-27
testw.cpp
testw.cpp
+18
-0
ReqMessage.cpp
zmq_src/ReqMessage.cpp
+18
-18
ZMQClient.cpp
zmq_src/ZMQClient.cpp
+3
-3
ZMQClient.h
zmq_src/ZMQClient.h
+1
-1
ZMQMessage.cpp
zmq_src/ZMQMessage.cpp
+3
-3
ZMQMessage.h
zmq_src/ZMQMessage.h
+10
-2
No files found.
testw.cpp
View file @
d635fca0
...
@@ -523,6 +523,24 @@ TEST_CASE_METHOD(TestFixture, "Delete Bls Key", "[delete-bls-key]") {
...
@@ -523,6 +523,24 @@ TEST_CASE_METHOD(TestFixture, "Delete Bls Key", "[delete-bls-key]") {
REQUIRE
(
c
.
deleteBlsKey
(
name
)[
"deleted"
]
==
true
);
REQUIRE
(
c
.
deleteBlsKey
(
name
)[
"deleted"
]
==
true
);
}
}
TEST_CASE_METHOD
(
TestFixture
,
"Delete Bls Key Zmq"
,
"[delete-bls-key-zmq]"
)
{
auto
client
=
make_shared
<
ZMQClient
>
(
ZMQ_IP
,
ZMQ_PORT
,
true
,
"./sgx_data/cert_data/rootCA.pem"
,
"./sgx_data/cert_data/rootCA.key"
);
std
::
string
name
=
"BLS_KEY:SCHAIN_ID:123456789:NODE_ID:0:DKG_ID:0"
;
libff
::
alt_bn128_Fr
key
=
libff
::
alt_bn128_Fr
(
"6507625568967977077291849236396320012317305261598035438182864059942098934847"
);
std
::
string
key_str
=
TestUtils
::
stringFromFr
(
key
);
REQUIRE
(
!
client
->
importBLSKeyShare
(
key_str
,
name
));
key_str
=
"0xe632f7fde2c90a073ec43eaa90dca7b82476bf28815450a11191484934b9c3f"
;
REQUIRE
(
client
->
importBLSKeyShare
(
key_str
,
name
));
REQUIRE_NOTHROW
(
client
->
blsSignMessageHash
(
name
,
SAMPLE_HASH
,
1
,
1
));
REQUIRE
(
client
->
deleteBLSKey
(
name
));
}
TEST_CASE_METHOD
(
TestFixture
,
"Import ECDSA Key"
,
"[import-ecdsa-key]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"Import ECDSA Key"
,
"[import-ecdsa-key]"
)
{
HttpClient
client
(
RPC_ENDPOINT
);
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
...
...
zmq_src/ReqMessage.cpp
View file @
d635fca0
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
Json
::
Value
ECDSASignReqMessage
::
process
()
{
Json
::
Value
ECDSASignReqMessage
::
process
()
{
auto
base
=
get
Ui
nt64Rapid
(
"base"
);
auto
base
=
get
I
nt64Rapid
(
"base"
);
auto
keyName
=
getStringRapid
(
"keyName"
);
auto
keyName
=
getStringRapid
(
"keyName"
);
auto
hash
=
getStringRapid
(
"messageHash"
);
auto
hash
=
getStringRapid
(
"messageHash"
);
auto
result
=
SGXWalletServer
::
ecdsaSignMessageHashImpl
(
base
,
keyName
,
hash
);
auto
result
=
SGXWalletServer
::
ecdsaSignMessageHashImpl
(
base
,
keyName
,
hash
);
...
@@ -39,8 +39,8 @@ Json::Value ECDSASignReqMessage::process() {
...
@@ -39,8 +39,8 @@ Json::Value ECDSASignReqMessage::process() {
Json
::
Value
BLSSignReqMessage
::
process
()
{
Json
::
Value
BLSSignReqMessage
::
process
()
{
auto
keyName
=
getStringRapid
(
"keyShareName"
);
auto
keyName
=
getStringRapid
(
"keyShareName"
);
auto
hash
=
getStringRapid
(
"messageHash"
);
auto
hash
=
getStringRapid
(
"messageHash"
);
auto
t
=
get
Ui
nt64Rapid
(
"t"
);
auto
t
=
get
I
nt64Rapid
(
"t"
);
auto
n
=
get
Ui
nt64Rapid
(
"n"
);
auto
n
=
get
I
nt64Rapid
(
"n"
);
auto
result
=
SGXWalletServer
::
blsSignMessageHashImpl
(
keyName
,
hash
,
t
,
n
);
auto
result
=
SGXWalletServer
::
blsSignMessageHashImpl
(
keyName
,
hash
,
t
,
n
);
result
[
"type"
]
=
ZMQMessage
::
BLS_SIGN_RSP
;
result
[
"type"
]
=
ZMQMessage
::
BLS_SIGN_RSP
;
return
result
;
return
result
;
...
@@ -77,7 +77,7 @@ Json::Value getPublicECDSAReqMessage::process() {
...
@@ -77,7 +77,7 @@ Json::Value getPublicECDSAReqMessage::process() {
Json
::
Value
generateDKGPolyReqMessage
::
process
()
{
Json
::
Value
generateDKGPolyReqMessage
::
process
()
{
auto
polyName
=
getStringRapid
(
"polyName"
);
auto
polyName
=
getStringRapid
(
"polyName"
);
auto
t
=
get
Ui
nt64Rapid
(
"t"
);
auto
t
=
get
I
nt64Rapid
(
"t"
);
auto
result
=
SGXWalletServer
::
generateDKGPolyImpl
(
polyName
,
t
);
auto
result
=
SGXWalletServer
::
generateDKGPolyImpl
(
polyName
,
t
);
result
[
"type"
]
=
ZMQMessage
::
GENERATE_DKG_POLY_RSP
;
result
[
"type"
]
=
ZMQMessage
::
GENERATE_DKG_POLY_RSP
;
return
result
;
return
result
;
...
@@ -85,8 +85,8 @@ Json::Value generateDKGPolyReqMessage::process() {
...
@@ -85,8 +85,8 @@ Json::Value generateDKGPolyReqMessage::process() {
Json
::
Value
getVerificationVectorReqMessage
::
process
()
{
Json
::
Value
getVerificationVectorReqMessage
::
process
()
{
auto
polyName
=
getStringRapid
(
"polyName"
);
auto
polyName
=
getStringRapid
(
"polyName"
);
auto
t
=
get
Ui
nt64Rapid
(
"t"
);
auto
t
=
get
I
nt64Rapid
(
"t"
);
auto
n
=
get
Ui
nt64Rapid
(
"n"
);
auto
n
=
get
I
nt64Rapid
(
"n"
);
auto
result
=
SGXWalletServer
::
getVerificationVectorImpl
(
polyName
,
t
,
n
);
auto
result
=
SGXWalletServer
::
getVerificationVectorImpl
(
polyName
,
t
,
n
);
result
[
"type"
]
=
ZMQMessage
::
GET_VV_RSP
;
result
[
"type"
]
=
ZMQMessage
::
GET_VV_RSP
;
return
result
;
return
result
;
...
@@ -94,8 +94,8 @@ Json::Value getVerificationVectorReqMessage::process() {
...
@@ -94,8 +94,8 @@ Json::Value getVerificationVectorReqMessage::process() {
Json
::
Value
getSecretShareReqMessage
::
process
()
{
Json
::
Value
getSecretShareReqMessage
::
process
()
{
auto
polyName
=
getStringRapid
(
"polyName"
);
auto
polyName
=
getStringRapid
(
"polyName"
);
auto
t
=
get
Ui
nt64Rapid
(
"t"
);
auto
t
=
get
I
nt64Rapid
(
"t"
);
auto
n
=
get
Ui
nt64Rapid
(
"n"
);
auto
n
=
get
I
nt64Rapid
(
"n"
);
auto
pubKeys
=
getJsonValueRapid
(
"publicKeys"
);
auto
pubKeys
=
getJsonValueRapid
(
"publicKeys"
);
auto
result
=
SGXWalletServer
::
getSecretShareV2Impl
(
polyName
,
pubKeys
,
t
,
n
);
auto
result
=
SGXWalletServer
::
getSecretShareV2Impl
(
polyName
,
pubKeys
,
t
,
n
);
result
[
"type"
]
=
ZMQMessage
::
GET_SECRET_SHARE_RSP
;
result
[
"type"
]
=
ZMQMessage
::
GET_SECRET_SHARE_RSP
;
...
@@ -104,9 +104,9 @@ Json::Value getSecretShareReqMessage::process() {
...
@@ -104,9 +104,9 @@ Json::Value getSecretShareReqMessage::process() {
Json
::
Value
dkgVerificationReqMessage
::
process
()
{
Json
::
Value
dkgVerificationReqMessage
::
process
()
{
auto
ethKeyName
=
getStringRapid
(
"ethKeyName"
);
auto
ethKeyName
=
getStringRapid
(
"ethKeyName"
);
auto
t
=
get
Ui
nt64Rapid
(
"t"
);
auto
t
=
get
I
nt64Rapid
(
"t"
);
auto
n
=
get
Ui
nt64Rapid
(
"n"
);
auto
n
=
get
I
nt64Rapid
(
"n"
);
auto
idx
=
get
Ui
nt64Rapid
(
"index"
);
auto
idx
=
get
I
nt64Rapid
(
"index"
);
auto
pubShares
=
getStringRapid
(
"publicShares"
);
auto
pubShares
=
getStringRapid
(
"publicShares"
);
auto
secretShare
=
getStringRapid
(
"secretShare"
);
auto
secretShare
=
getStringRapid
(
"secretShare"
);
auto
result
=
SGXWalletServer
::
dkgVerificationV2Impl
(
pubShares
,
ethKeyName
,
secretShare
,
t
,
n
,
idx
);
auto
result
=
SGXWalletServer
::
dkgVerificationV2Impl
(
pubShares
,
ethKeyName
,
secretShare
,
t
,
n
,
idx
);
...
@@ -119,8 +119,8 @@ Json::Value createBLSPrivateKeyReqMessage::process() {
...
@@ -119,8 +119,8 @@ Json::Value createBLSPrivateKeyReqMessage::process() {
auto
ethKeyName
=
getStringRapid
(
"ethKeyName"
);
auto
ethKeyName
=
getStringRapid
(
"ethKeyName"
);
auto
polyName
=
getStringRapid
(
"polyName"
);
auto
polyName
=
getStringRapid
(
"polyName"
);
auto
secretShare
=
getStringRapid
(
"secretShare"
);
auto
secretShare
=
getStringRapid
(
"secretShare"
);
auto
t
=
get
Ui
nt64Rapid
(
"t"
);
auto
t
=
get
I
nt64Rapid
(
"t"
);
auto
n
=
get
Ui
nt64Rapid
(
"n"
);
auto
n
=
get
I
nt64Rapid
(
"n"
);
auto
result
=
SGXWalletServer
::
createBLSPrivateKeyV2Impl
(
blsKeyName
,
ethKeyName
,
polyName
,
secretShare
,
t
,
n
);
auto
result
=
SGXWalletServer
::
createBLSPrivateKeyV2Impl
(
blsKeyName
,
ethKeyName
,
polyName
,
secretShare
,
t
,
n
);
result
[
"type"
]
=
ZMQMessage
::
CREATE_BLS_PRIVATE_RSP
;
result
[
"type"
]
=
ZMQMessage
::
CREATE_BLS_PRIVATE_RSP
;
return
result
;
return
result
;
...
@@ -134,8 +134,8 @@ Json::Value getBLSPublicReqMessage::process() {
...
@@ -134,8 +134,8 @@ Json::Value getBLSPublicReqMessage::process() {
}
}
Json
::
Value
getAllBLSPublicKeysReqMessage
::
process
()
{
Json
::
Value
getAllBLSPublicKeysReqMessage
::
process
()
{
auto
t
=
get
Ui
nt64Rapid
(
"t"
);
auto
t
=
get
I
nt64Rapid
(
"t"
);
auto
n
=
get
Ui
nt64Rapid
(
"n"
);
auto
n
=
get
I
nt64Rapid
(
"n"
);
auto
pubShares
=
getJsonValueRapid
(
"publicShares"
);
auto
pubShares
=
getJsonValueRapid
(
"publicShares"
);
auto
result
=
SGXWalletServer
::
calculateAllBLSPublicKeysImpl
(
pubShares
,
t
,
n
);
auto
result
=
SGXWalletServer
::
calculateAllBLSPublicKeysImpl
(
pubShares
,
t
,
n
);
result
[
"type"
]
=
ZMQMessage
::
GET_ALL_BLS_PUBLIC_RSP
;
result
[
"type"
]
=
ZMQMessage
::
GET_ALL_BLS_PUBLIC_RSP
;
...
@@ -144,9 +144,9 @@ Json::Value getAllBLSPublicKeysReqMessage::process() {
...
@@ -144,9 +144,9 @@ Json::Value getAllBLSPublicKeysReqMessage::process() {
Json
::
Value
complaintResponseReqMessage
::
process
()
{
Json
::
Value
complaintResponseReqMessage
::
process
()
{
auto
polyName
=
getStringRapid
(
"polyName"
);
auto
polyName
=
getStringRapid
(
"polyName"
);
auto
t
=
get
Ui
nt64Rapid
(
"t"
);
auto
t
=
get
I
nt64Rapid
(
"t"
);
auto
n
=
get
Ui
nt64Rapid
(
"n"
);
auto
n
=
get
I
nt64Rapid
(
"n"
);
auto
idx
=
get
Ui
nt64Rapid
(
"ind"
);
auto
idx
=
get
I
nt64Rapid
(
"ind"
);
auto
result
=
SGXWalletServer
::
complaintResponseImpl
(
polyName
,
t
,
n
,
idx
);
auto
result
=
SGXWalletServer
::
complaintResponseImpl
(
polyName
,
t
,
n
,
idx
);
result
[
"type"
]
=
ZMQMessage
::
COMPLAINT_RESPONSE_RSP
;
result
[
"type"
]
=
ZMQMessage
::
COMPLAINT_RESPONSE_RSP
;
return
result
;
return
result
;
...
...
zmq_src/ZMQClient.cpp
View file @
d635fca0
...
@@ -313,14 +313,14 @@ string ZMQClient::ecdsaSignMessageHash(int base, const std::string &keyName, con
...
@@ -313,14 +313,14 @@ string ZMQClient::ecdsaSignMessageHash(int base, const std::string &keyName, con
return
result
->
getSignature
();
return
result
->
getSignature
();
}
}
void
ZMQClient
::
importBLSKeyShare
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyName
)
{
bool
ZMQClient
::
importBLSKeyShare
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyName
)
{
Json
::
Value
p
;
Json
::
Value
p
;
p
[
"type"
]
=
ZMQMessage
::
IMPORT_BLS_REQ
;
p
[
"type"
]
=
ZMQMessage
::
IMPORT_BLS_REQ
;
p
[
"keyName"
]
=
keyName
;
p
[
"key
Share
Name"
]
=
keyName
;
p
[
"keyShare"
]
=
keyShare
;
p
[
"keyShare"
]
=
keyShare
;
auto
result
=
dynamic_pointer_cast
<
importBLSRspMessage
>
(
doRequestReply
(
p
));
auto
result
=
dynamic_pointer_cast
<
importBLSRspMessage
>
(
doRequestReply
(
p
));
CHECK_STATE
(
result
);
CHECK_STATE
(
result
);
CHECK_STATE
(
result
->
getStatus
()
==
0
)
;
return
result
->
getStatus
()
==
0
;
}
}
string
ZMQClient
::
importECDSAKey
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyName
)
{
string
ZMQClient
::
importECDSAKey
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyName
)
{
...
...
zmq_src/ZMQClient.h
View file @
d635fca0
...
@@ -87,7 +87,7 @@ public:
...
@@ -87,7 +87,7 @@ public:
string
ecdsaSignMessageHash
(
int
base
,
const
std
::
string
&
keyName
,
const
std
::
string
&
messageHash
);
string
ecdsaSignMessageHash
(
int
base
,
const
std
::
string
&
keyName
,
const
std
::
string
&
messageHash
);
void
importBLSKeyShare
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyName
);
bool
importBLSKeyShare
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyName
);
string
importECDSAKey
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyName
);
string
importECDSAKey
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyName
);
...
...
zmq_src/ZMQMessage.cpp
View file @
d635fca0
...
@@ -34,12 +34,12 @@
...
@@ -34,12 +34,12 @@
#include "ZMQMessage.h"
#include "ZMQMessage.h"
uint64_t
ZMQMessage
::
get
Ui
nt64Rapid
(
const
char
*
_name
)
{
uint64_t
ZMQMessage
::
get
I
nt64Rapid
(
const
char
*
_name
)
{
CHECK_STATE
(
_name
);
CHECK_STATE
(
_name
);
CHECK_STATE
(
d
->
HasMember
(
_name
));
CHECK_STATE
(
d
->
HasMember
(
_name
));
const
rapidjson
::
Value
&
a
=
(
*
d
)[
_name
];
const
rapidjson
::
Value
&
a
=
(
*
d
)[
_name
];
CHECK_STATE
(
a
.
Is
Ui
nt64
());
CHECK_STATE
(
a
.
Is
I
nt64
());
return
a
.
Get
Ui
nt64
();
return
a
.
Get
I
nt64
();
};
};
Json
::
Value
ZMQMessage
::
getJsonValueRapid
(
const
char
*
_name
)
{
Json
::
Value
ZMQMessage
::
getJsonValueRapid
(
const
char
*
_name
)
{
...
...
zmq_src/ZMQMessage.h
View file @
d635fca0
...
@@ -108,14 +108,22 @@ public:
...
@@ -108,14 +108,22 @@ public:
string
getStringRapid
(
const
char
*
_name
);
string
getStringRapid
(
const
char
*
_name
);
uint64_t
get
Ui
nt64Rapid
(
const
char
*
_name
);
uint64_t
get
I
nt64Rapid
(
const
char
*
_name
);
Json
::
Value
getJsonValueRapid
(
const
char
*
_name
);
Json
::
Value
getJsonValueRapid
(
const
char
*
_name
);
bool
getBoolRapid
(
const
char
*
_name
);
bool
getBoolRapid
(
const
char
*
_name
);
uint64_t
getStatus
()
{
uint64_t
getStatus
()
{
return
getUint64Rapid
(
"status"
);
return
getInt64Rapid
(
"status"
);
}
std
::
string
rapidToString
()
{
rapidjson
::
StringBuffer
buffer
;
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
d
->
Accept
(
writer
);
std
::
string
strRequest
=
buffer
.
GetString
();
return
strRequest
;
}
}
static
shared_ptr
<
ZMQMessage
>
parse
(
const
char
*
_msg
,
size_t
_size
,
bool
_isRequest
,
static
shared_ptr
<
ZMQMessage
>
parse
(
const
char
*
_msg
,
size_t
_size
,
bool
_isRequest
,
...
...
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