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
dbf340bd
Unverified
Commit
dbf340bd
authored
Jan 25, 2021
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug/SKALE-3751-enable-zeromq
parent
fb3c9968
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
11 deletions
+32
-11
SGXWalletServer.cpp
SGXWalletServer.cpp
+28
-11
SGXWalletServer.hpp
SGXWalletServer.hpp
+4
-0
sgx_util
sgx_util
+0
-0
No files found.
SGXWalletServer.cpp
View file @
dbf340bd
...
@@ -118,6 +118,12 @@ void SGXWalletServer::printDB() {
...
@@ -118,6 +118,12 @@ void SGXWalletServer::printDB() {
#define NUM_THREADS 200
#define NUM_THREADS 200
#endif
#endif
bool
SGXWalletServer
::
verifyCert
(
string
&
_certFileName
)
{
string
rootCAPath
=
string
(
SGXDATA_FOLDER
)
+
"cert_data/rootCA.pem"
;
string
verifyCert
=
"cert/verify_client_cert "
+
rootCAPath
+
" "
+
_certFileName
;
return
system
(
verifyCert
.
c_str
())
==
0
;
}
int
SGXWalletServer
::
initHttpsServer
(
bool
_checkCerts
)
{
int
SGXWalletServer
::
initHttpsServer
(
bool
_checkCerts
)
{
COUNT_STATISTICS
COUNT_STATISTICS
...
@@ -158,6 +164,16 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
...
@@ -158,6 +164,16 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
}
}
}
}
spdlog
::
info
(
"Verifying server cert"
);
if
(
verifyCert
(
certPath
))
{
spdlog
::
info
(
"SERVER CERTIFICATE IS SUCCESSFULLY VERIFIED"
);
}
else
{
spdlog
::
info
(
"SERVER CERTIFICATE VERIFICATION FAILED"
);
exit
(
-
12
);
}
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
,
certPath
,
keyPath
,
rootCAPath
,
_checkCerts
,
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
,
certPath
,
keyPath
,
rootCAPath
,
_checkCerts
,
NUM_THREADS
);
NUM_THREADS
);
...
@@ -213,18 +229,19 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
...
@@ -213,18 +229,19 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
}
}
if
(
!
checkHex
(
hashTmp
))
{
if
(
!
checkHex
(
hashTmp
))
{
throw
SGXException
(
BLS_IMPORT_INVALID_KEY_SHARE
,
string
(
__FUNCTION__
)
+
":Invalid BLS key share, please use hex"
);
throw
SGXException
(
BLS_IMPORT_INVALID_KEY_SHARE
,
string
(
__FUNCTION__
)
+
":Invalid BLS key share, please use hex"
);
}
}
encryptedKeyShareHex
=
encryptBLSKeyShare2Hex
(
&
errStatus
,
(
char
*
)
errMsg
.
data
(),
hashTmp
.
c_str
());
encryptedKeyShareHex
=
encryptBLSKeyShare2Hex
(
&
errStatus
,
(
char
*
)
errMsg
.
data
(),
hashTmp
.
c_str
());
if
(
errStatus
!=
0
)
{
if
(
errStatus
!=
0
)
{
throw
SGXException
(
errStatus
,
string
(
__FUNCTION__
)
+
":"
+
errMsg
.
data
());
throw
SGXException
(
errStatus
,
string
(
__FUNCTION__
)
+
":"
+
errMsg
.
data
());
}
}
if
(
encryptedKeyShareHex
.
empty
())
{
if
(
encryptedKeyShareHex
.
empty
())
{
throw
SGXException
(
BLS_IMPORT_EMPTY_ENCRYPTED_KEY_SHARE
,
string
(
__FUNCTION__
)
+
throw
SGXException
(
BLS_IMPORT_EMPTY_ENCRYPTED_KEY_SHARE
,
string
(
__FUNCTION__
)
+
":Empty encrypted key share"
);
":Empty encrypted key share"
);
}
}
result
[
"encryptedKeyShare"
]
=
encryptedKeyShareHex
;
result
[
"encryptedKeyShare"
]
=
encryptedKeyShareHex
;
...
@@ -309,7 +326,6 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
...
@@ -309,7 +326,6 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
result
[
"signatureShare"
]
=
string
(
signature
.
data
());
result
[
"signatureShare"
]
=
string
(
signature
.
data
());
RETURN_SUCCESS
(
result
);
RETURN_SUCCESS
(
result
);
}
}
...
@@ -435,7 +451,7 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
...
@@ -435,7 +451,7 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
try
{
try
{
if
(
!
checkECDSAKeyName
(
_keyName
))
{
if
(
!
checkECDSAKeyName
(
_keyName
))
{
throw
SGXException
(
INVALID_ECDSA_GETPKEY_KEY_NAME
,
string
(
__FUNCTION__
)
+
throw
SGXException
(
INVALID_ECDSA_GETPKEY_KEY_NAME
,
string
(
__FUNCTION__
)
+
":Invalid ECDSA import key name"
);
":Invalid ECDSA import key name"
);
}
}
shared_ptr
<
string
>
keyStr
=
readFromDb
(
_keyName
);
shared_ptr
<
string
>
keyStr
=
readFromDb
(
_keyName
);
publicKey
=
getECDSAPubKey
(
keyStr
->
c_str
());
publicKey
=
getECDSAPubKey
(
keyStr
->
c_str
());
...
@@ -814,7 +830,7 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const string &name) {
...
@@ -814,7 +830,7 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const string &name) {
result
[
"deleted"
]
=
true
;
result
[
"deleted"
]
=
true
;
}
else
{
}
else
{
auto
error_msg
=
"BLS key not found: "
+
name
;
auto
error_msg
=
"BLS key not found: "
+
name
;
throw
SGXException
(
DELETE_BLS_KEY_NOT_FOUND
,
string
(
__FUNCTION__
)
+
":"
+
error_msg
.
c_str
());
throw
SGXException
(
DELETE_BLS_KEY_NOT_FOUND
,
string
(
__FUNCTION__
)
+
":"
+
error_msg
.
c_str
());
}
}
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
...
@@ -903,8 +919,9 @@ Json::Value SGXWalletServer::dkgVerificationV2Impl(const string &_publicShares,
...
@@ -903,8 +919,9 @@ Json::Value SGXWalletServer::dkgVerificationV2Impl(const string &_publicShares,
}
}
Json
::
Value
Json
::
Value
SGXWalletServer
::
createBLSPrivateKeyV2Impl
(
const
string
&
_blsKeyName
,
const
string
&
_ethKeyName
,
const
string
&
_polyName
,
SGXWalletServer
::
createBLSPrivateKeyV2Impl
(
const
string
&
_blsKeyName
,
const
string
&
_ethKeyName
,
const
string
&
_secretShare
,
int
_t
,
int
_n
)
{
const
string
&
_polyName
,
const
string
&
_secretShare
,
int
_t
,
int
_n
)
{
COUNT_STATISTICS
COUNT_STATISTICS
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
...
@@ -1058,7 +1075,7 @@ SGXWalletServer::dkgVerificationV2(const string &_publicShares, const string &et
...
@@ -1058,7 +1075,7 @@ SGXWalletServer::dkgVerificationV2(const string &_publicShares, const string &et
Json
::
Value
Json
::
Value
SGXWalletServer
::
createBLSPrivateKeyV2
(
const
string
&
blsKeyName
,
const
string
&
ethKeyName
,
const
string
&
polyName
,
SGXWalletServer
::
createBLSPrivateKeyV2
(
const
string
&
blsKeyName
,
const
string
&
ethKeyName
,
const
string
&
polyName
,
const
string
&
SecretShare
,
int
t
,
int
n
)
{
const
string
&
SecretShare
,
int
t
,
int
n
)
{
return
createBLSPrivateKeyV2Impl
(
blsKeyName
,
ethKeyName
,
polyName
,
SecretShare
,
t
,
n
);
return
createBLSPrivateKeyV2Impl
(
blsKeyName
,
ethKeyName
,
polyName
,
SecretShare
,
t
,
n
);
}
}
...
@@ -1066,7 +1083,7 @@ shared_ptr <string> SGXWalletServer::readFromDb(const string &name, const string
...
@@ -1066,7 +1083,7 @@ shared_ptr <string> SGXWalletServer::readFromDb(const string &name, const string
auto
dataStr
=
checkDataFromDb
(
prefix
+
name
);
auto
dataStr
=
checkDataFromDb
(
prefix
+
name
);
if
(
dataStr
==
nullptr
)
{
if
(
dataStr
==
nullptr
)
{
throw
SGXException
(
KEY_SHARE_DOES_NOT_EXIST
,
string
(
__FUNCTION__
)
+
":Data with this name does not exist"
);
throw
SGXException
(
KEY_SHARE_DOES_NOT_EXIST
,
string
(
__FUNCTION__
)
+
":Data with this name does not exist"
);
}
}
return
dataStr
;
return
dataStr
;
...
...
SGXWalletServer.hpp
View file @
dbf340bd
...
@@ -55,7 +55,11 @@ class SGXWalletServer : public AbstractStubServer {
...
@@ -55,7 +55,11 @@ class SGXWalletServer : public AbstractStubServer {
static
void
checkForDuplicate
(
map
<
string
,
string
>
&
_map
,
recursive_mutex
&
_m
,
const
string
&
_key
,
static
void
checkForDuplicate
(
map
<
string
,
string
>
&
_map
,
recursive_mutex
&
_m
,
const
string
&
_key
,
const
string
&
_value
);
const
string
&
_value
);
public
:
public
:
static
bool
verifyCert
(
string
&
_certFileName
);
static
const
char
*
getVersion
()
{
static
const
char
*
getVersion
()
{
return
TOSTRING
(
SGXWALLET_VERSION
);
return
TOSTRING
(
SGXWALLET_VERSION
);
}
}
...
...
sgx_util
0 → 100755
View file @
dbf340bd
File added
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