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
70e861f9
Unverified
Commit
70e861f9
authored
Dec 15, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3660 remove semaphore
parent
0c65f553
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
74 deletions
+37
-74
BLSCrypto.cpp
BLSCrypto.cpp
+4
-8
BLSPrivateKeyShareSGX.cpp
BLSPrivateKeyShareSGX.cpp
+2
-4
DKGCrypto.cpp
DKGCrypto.cpp
+13
-28
ECDSACrypto.cpp
ECDSACrypto.cpp
+12
-19
SGXWalletServer.cpp
SGXWalletServer.cpp
+1
-5
sgxwallet_common.h
sgxwallet_common.h
+5
-10
No files found.
BLSCrypto.cpp
View file @
70e861f9
...
...
@@ -184,10 +184,8 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedBlsSignMessage
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encryptedKey
,
sz
,
xStrArg
,
yStrArg
,
signature
);
SEMAPHORE_END
status
=
trustedBlsSignMessage
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encryptedKey
,
sz
,
xStrArg
,
yStrArg
,
signature
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
...
...
@@ -226,10 +224,8 @@ string encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedEncryptKey
(
eid
,
errStatus
,
errMsg
.
data
(),
keyArray
->
data
(),
encryptedKey
->
data
(),
&
encryptedLen
);
SEMAPHORE_END
status
=
trustedEncryptKey
(
eid
,
errStatus
,
errMsg
.
data
(),
keyArray
->
data
(),
encryptedKey
->
data
(),
&
encryptedLen
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
*
errStatus
,
errMsg
.
data
());
...
...
BLSPrivateKeyShareSGX.cpp
View file @
70e861f9
...
...
@@ -149,10 +149,8 @@ string BLSPrivateKeyShareSGX::signWithHelperSGXstr(
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedBlsSignMessage
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encryptedKey
,
encryptedKeyHex
->
size
()
/
2
,
xStrArg
,
yStrArg
,
signature
);
SEMAPHORE_END
status
=
trustedBlsSignMessage
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encryptedKey
,
encryptedKeyHex
->
size
()
/
2
,
xStrArg
,
yStrArg
,
signature
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
...
...
DKGCrypto.cpp
View file @
70e861f9
...
...
@@ -136,11 +136,8 @@ string gen_dkg_poly(int _t) {
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedGenDkgSecret
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
_t
);
SEMAPHORE_END
status
=
trustedGenDkgSecret
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
_t
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
...
...
@@ -176,11 +173,8 @@ vector <vector<string>> get_verif_vect(const string &encryptedPolyHex, int t, in
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedGetPublicShares
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encrDKGPoly
.
data
(),
encLen
,
pubShares
.
data
(),
t
,
n
);
SEMAPHORE_END
status
=
trustedGetPublicShares
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encrDKGPoly
.
data
(),
encLen
,
pubShares
.
data
(),
t
,
n
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
...
...
@@ -369,10 +363,8 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedDkgVerify
(
eid
,
&
errStatus
,
errMsg
.
data
(),
pshares
,
encr_sshare
,
encr_key
,
decKeyLen
,
t
,
ind
,
&
result
);
SEMAPHORE_END
status
=
trustedDkgVerify
(
eid
,
&
errStatus
,
errMsg
.
data
(),
pshares
,
encr_sshare
,
encr_key
,
decKeyLen
,
t
,
ind
,
&
result
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
...
...
@@ -406,10 +398,8 @@ verifySharesV2(const char *publicShares, const char *encr_sshare, const char *en
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedDkgVerifyV2
(
eid
,
&
errStatus
,
errMsg
.
data
(),
pshares
,
encr_sshare
,
encr_key
,
decKeyLen
,
t
,
ind
,
&
result
);
SEMAPHORE_END
status
=
trustedDkgVerifyV2
(
eid
,
&
errStatus
,
errMsg
.
data
(),
pshares
,
encr_sshare
,
encr_key
,
decKeyLen
,
t
,
ind
,
&
result
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
...
...
@@ -437,10 +427,8 @@ bool createBLSShare(const string &blsKeyName, const char *s_shares, const char *
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedCreateBlsKey
(
eid
,
&
errStatus
,
errMsg
.
data
(),
s_shares
,
encr_key
,
decKeyLen
,
encr_bls_key
,
&
enc_bls_len
);
SEMAPHORE_END
status
=
trustedCreateBlsKey
(
eid
,
&
errStatus
,
errMsg
.
data
(),
s_shares
,
encr_key
,
decKeyLen
,
encr_bls_key
,
&
enc_bls_len
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
...
...
@@ -471,9 +459,7 @@ vector <string> getBLSPubKey(const char *encryptedKeyHex) {
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedGetBlsPubKey
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encrKey
,
decKeyLen
,
pubKey
);
SEMAPHORE_END
status
=
trustedGetBlsPubKey
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encrKey
,
decKeyLen
,
pubKey
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg1
.
data
());
...
...
@@ -557,9 +543,8 @@ string decryptDHKey(const string &polyName, int ind) {
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedDecryptKey
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encryptedDHKey
,
dhEncLen
,
DHKey
);
SEMAPHORE_END
status
=
trustedDecryptKey
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encryptedDHKey
,
dhEncLen
,
DHKey
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg1
.
data
())
return
DHKey
;
...
...
ECDSACrypto.cpp
View file @
70e861f9
...
...
@@ -59,11 +59,9 @@ vector <string> genECDSAKey() {
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedGenerateEcdsaKey
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encr_pr_key
.
data
(),
&
enc_len
,
pub_key_x
.
data
(),
pub_key_y
.
data
());
SEMAPHORE_END
status
=
trustedGenerateEcdsaKey
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encr_pr_key
.
data
(),
&
enc_len
,
pub_key_x
.
data
(),
pub_key_y
.
data
());
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
...
...
@@ -101,10 +99,8 @@ string getECDSAPubKey(const std::string& _encryptedKeyHex) {
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedGetPublicEcdsaKey
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encrPrKey
.
data
(),
enc_len
,
pubKeyX
.
data
(),
pubKeyY
.
data
());
SEMAPHORE_END
status
=
trustedGetPublicEcdsaKey
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encrPrKey
.
data
(),
enc_len
,
pubKeyX
.
data
(),
pubKeyY
.
data
());
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
())
...
...
@@ -190,12 +186,10 @@ vector <string> ecdsaSignHash(const std::string& encryptedKeyHex, const char *ha
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedEcdsaSign
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encryptedKey
.
data
(),
decLen
,
hashHex
,
signatureR
.
data
(),
signatureS
.
data
(),
&
signatureV
,
base
);
SEMAPHORE_END
status
=
trustedEcdsaSign
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encryptedKey
.
data
(),
decLen
,
hashHex
,
signatureR
.
data
(),
signatureS
.
data
(),
&
signatureV
,
base
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
...
...
@@ -242,10 +236,9 @@ string encryptECDSAKey(const string& _key) {
uint64_t
enc_len
=
0
;
sgx_status_t
status
=
SGX_SUCCESS
;
SEMAPHORE_BEGIN
status
=
trustedEncryptKey
(
eid
,
&
errStatus
,
errString
.
data
(),
key
.
data
(),
encryptedKey
.
data
(),
&
enc_len
);
SEMAPHORE_END
status
=
trustedEncryptKey
(
eid
,
&
errStatus
,
errString
.
data
(),
key
.
data
(),
encryptedKey
.
data
(),
&
enc_len
);
if
(
status
!=
0
)
{
throw
SGXException
(
status
,
string
(
"Could not encrypt ECDSA key: "
+
string
(
errString
.
begin
(),
errString
.
end
())).
c_str
());
...
...
SGXWalletServer.cpp
View file @
70e861f9
...
...
@@ -57,10 +57,6 @@ using namespace std;
std
::
shared_timed_mutex
sgxInitMutex
;
// MAX 200 threads can call enclave
boost
::
interprocess
::
interprocess_semaphore
enclaveSemaphore
(
200
);
uint64_t
initTime
;
void
setFullOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_enterBackupKey
)
{
...
...
@@ -123,7 +119,7 @@ void SGXWalletServer::printDB() {
#ifdef SGX_HW_SIM
#define NUM_THREADS 16
#else
#define NUM_THREADS
1024
#define NUM_THREADS
200
#endif
...
...
sgxwallet_common.h
View file @
70e861f9
...
...
@@ -113,7 +113,7 @@ extern bool autoconfirm;
#define FILE_NOT_FOUND -44
#define INVALID_DKG_GETSS_PARAMS -45
#define INVALID_DKG_GETSS_PUB_KEY_COUNT -46
#define
INVALID_DKG_GETSS_KEY_HEX -47
#define INVALID_DKG_GETSS_KEY_HEX -47
#define INVALID_DKG_VERIFY_ECDSA_KEY_NAME -48
#define INVALID_DKG_VERIFY_PARAMS -49
#define INVALID_DKG_VERIFY_SS_HEX -50
...
...
@@ -125,14 +125,14 @@ extern bool autoconfirm;
#define INVALID_CREATE_BLS_KEY_NAME -56
#define INVALID_CREATE_BLS_DKG_PARAMS -57
#define INVALID_CREATE_BLS_SHARE -58
#define
INVALID_GET_BLS_PUBKEY_NAME -59
#define INVALID_GET_BLS_PUBKEY_NAME -59
#define INVALID_DKG_CALCULATE_ALL_PARAMS -60
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES -61
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES_SIZE -62
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES_STRING -63
#define INVALID_DKG_CALCULATE_ALL_STRING_PUBSHARES_SLENGTH -64
#define INVALID_DKG_CALCULATE_ALL_STRING_PUBKEYS_SIZE -65
#define
INVALID_COMPLAINT_RESPONSE_POLY_NAME -66
#define INVALID_COMPLAINT_RESPONSE_POLY_NAME -66
#define INVALID_DKG_GETSS_V2_PARAMS -63
#define INVALID_DKG_GETSS_V2_POLY_NAME -64
#define INVALID_DKG_GETSS_V2_PUBKEY_COUNT -65
...
...
@@ -147,7 +147,7 @@ extern bool autoconfirm;
#define CONVERT_G2_INCORRECT_STRING_CONVERSION -74
#define DELETE_BLS_KEY_INVALID_KEYNAME -75
#define DELETE_BLS_KEY_NOT_FOUND -76
#define
VERIFY_SHARES_INVALID_PUBLIC_SHARES -77
#define VERIFY_SHARES_INVALID_PUBLIC_SHARES -77
#define VERIFY_SHARES_V2_INVALID_POLY_HEX -78
#define VERIFY_SHARES_V2_INVALID_PUBLIC_SHARES -79
#define CREATE_BLS_SHARE_INVALID_KEY_HEX -80
...
...
@@ -158,7 +158,7 @@ extern bool autoconfirm;
#define GET_ECDSA_PUB_KEY_INVALID_KEY_HEX -85
#define ECDSA_SIGN_INVALID_KEY_HEX -86
#define SET_SEK_INVALID_SEK_HEX -87
#define
TEST_INVALID_HEX -88
#define TEST_INVALID_HEX -88
#define SGX_ENCLAVE_ERROR -666
...
...
@@ -173,10 +173,5 @@ extern bool autoconfirm;
#define TEST_VALUE "1234567890"
#define SEMAPHORE_BEGIN { semaphore_guard __ENCLAVE__GUARD__(enclaveSemaphore) ;
#define SEMAPHORE_END }
#endif //SGXWALLET_SGXWALLET_COMMON_H
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