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
b33321c2
Unverified
Commit
b33321c2
authored
Aug 12, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3067-cleanup-sgx
parent
18c63687
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
44 deletions
+18
-44
CSRManagerServer.cpp
CSRManagerServer.cpp
+4
-4
DKGCrypto.cpp
DKGCrypto.cpp
+3
-3
DKGCrypto.h
DKGCrypto.h
+1
-1
Log.h
Log.h
+1
-1
SGXRegistrationServer.cpp
SGXRegistrationServer.cpp
+3
-2
SGXWalletServer.cpp
SGXWalletServer.cpp
+6
-33
No files found.
CSRManagerServer.cpp
View file @
b33321c2
...
@@ -42,7 +42,6 @@ CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector,
...
@@ -42,7 +42,6 @@ CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector,
Json
::
Value
getUnsignedCSRsImpl
()
{
Json
::
Value
getUnsignedCSRsImpl
()
{
spdlog
::
info
(
__FUNCTION__
);
spdlog
::
info
(
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
try
{
try
{
vector
<
string
>
hashes_vect
=
LevelDB
::
getCsrDb
()
->
writeKeysToVector1
(
MAX_CSR_NUM
);
vector
<
string
>
hashes_vect
=
LevelDB
::
getCsrDb
()
->
writeKeysToVector1
(
MAX_CSR_NUM
);
for
(
int
i
=
0
;
i
<
(
int
)
hashes_vect
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
hashes_vect
.
size
();
i
++
)
{
...
@@ -50,11 +49,12 @@ Json::Value getUnsignedCSRsImpl() {
...
@@ -50,11 +49,12 @@ Json::Value getUnsignedCSRsImpl() {
}
}
}
HANDLE_SGX_EXCEPTION
(
result
);
}
HANDLE_SGX_EXCEPTION
(
result
);
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
signByHashImpl
(
const
string
&
hash
,
int
status
)
{
Json
::
Value
signByHashImpl
(
const
string
&
hash
,
int
status
)
{
Json
::
Value
result
;
INIT_RESULT
(
result
)
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
try
{
try
{
...
@@ -102,7 +102,7 @@ Json::Value signByHashImpl(const string &hash, int status) {
...
@@ -102,7 +102,7 @@ Json::Value signByHashImpl(const string &hash, int status) {
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
return
result
;
}
}
Json
::
Value
CSRManagerServer
::
getUnsignedCSRs
()
{
Json
::
Value
CSRManagerServer
::
getUnsignedCSRs
()
{
...
...
DKGCrypto.cpp
View file @
b33321c2
...
@@ -152,9 +152,9 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n
...
@@ -152,9 +152,9 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n
return
pubSharesVect
;
return
pubSharesVect
;
}
}
string
trustedG
etSecretShares
(
const
string
&
_polyName
,
const
char
*
_encryptedPolyHex
,
const
vector
<
string
>
&
_publicKeys
,
string
g
etSecretShares
(
const
string
&
_polyName
,
const
char
*
_encryptedPolyHex
,
const
vector
<
string
>
&
_publicKeys
,
int
_t
,
int
_t
,
int
_n
)
{
int
_n
)
{
vector
<
char
>
hexEncrKey
(
BUF_LEN
,
0
);
vector
<
char
>
hexEncrKey
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg1
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg1
(
BUF_LEN
,
0
);
int
errStatus
=
0
;
int
errStatus
=
0
;
...
...
DKGCrypto.h
View file @
b33321c2
...
@@ -35,7 +35,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
...
@@ -35,7 +35,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
vector
<
string
>
splitString
(
const
char
*
coeffs
,
const
char
symbol
);
vector
<
string
>
splitString
(
const
char
*
coeffs
,
const
char
symbol
);
string
trustedG
etSecretShares
(
const
string
&
_polyName
,
const
char
*
_encryptedPolyHex
,
const
vector
<
string
>&
_publicKeys
,
int
_t
,
int
_n
);
string
g
etSecretShares
(
const
string
&
_polyName
,
const
char
*
_encryptedPolyHex
,
const
vector
<
string
>&
_publicKeys
,
int
_t
,
int
_n
);
bool
verifyShares
(
const
char
*
publicShares
,
const
char
*
encr_sshare
,
const
char
*
encryptedKeyHex
,
int
t
,
int
n
,
int
ind
);
bool
verifyShares
(
const
char
*
publicShares
,
const
char
*
encr_sshare
,
const
char
*
encryptedKeyHex
,
int
t
,
int
n
,
int
ind
);
...
...
Log.h
View file @
b33321c2
...
@@ -74,7 +74,7 @@ public:
...
@@ -74,7 +74,7 @@ public:
};
};
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \
int errStatus = UNKNOWN_ERROR; string errMsg(BUF_LEN, '\0');__RESULT__["status"] =
0
; __RESULT__["errorMessage"] = \
int errStatus = UNKNOWN_ERROR; string errMsg(BUF_LEN, '\0');__RESULT__["status"] =
UNKNOWN_ERROR
; __RESULT__["errorMessage"] = \
"Server error. Please see server log.";
"Server error. Please see server log.";
#define HANDLE_SGX_EXCEPTION(__RESULT__) \
#define HANDLE_SGX_EXCEPTION(__RESULT__) \
...
...
SGXRegistrationServer.cpp
View file @
b33321c2
...
@@ -112,7 +112,8 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
...
@@ -112,7 +112,8 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
getCertificateImpl
(
const
string
&
hash
)
{
Json
::
Value
getCertificateImpl
(
const
string
&
hash
)
{
...
@@ -147,7 +148,7 @@ Json::Value getCertificateImpl(const string &hash) {
...
@@ -147,7 +148,7 @@ Json::Value getCertificateImpl(const string &hash) {
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
}
...
...
SGXWalletServer.cpp
View file @
b33321c2
...
@@ -221,22 +221,7 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
...
@@ -221,22 +221,7 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
}
}
value
=
readFromDb
(
_keyShareName
);
value
=
readFromDb
(
_keyShareName
);
}
catch
(
SGXException
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
return
result
;
}
catch
(
exception
&
_e
)
{
result
[
"errorMessage"
]
=
_e
.
what
();
return
result
;
}
catch
(...)
{
exception_ptr
p
=
current_exception
();
printf
(
"Exception %s
\n
"
,
p
.
__cxa_exception_type
()
->
name
());
result
[
"errorMessage"
]
=
"Exception in dbRead"
;
return
result
;
}
try
{
if
(
!
bls_sign
(
value
->
c_str
(),
_messageHash
.
c_str
(),
t
,
n
,
_signerIndex
,
signature
.
data
()))
{
if
(
!
bls_sign
(
value
->
c_str
(),
_messageHash
.
c_str
(),
t
,
n
,
_signerIndex
,
signature
.
data
()))
{
result
[
"status"
]
=
-
1
;
result
[
"status"
]
=
-
1
;
result
[
"errorMessage"
]
=
"Could not sign"
;
result
[
"errorMessage"
]
=
"Could not sign"
;
...
@@ -409,8 +394,6 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
...
@@ -409,8 +394,6 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
INIT_RESULT
(
result
);
INIT_RESULT
(
result
);
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
vector
<
vector
<
string
>>
verifVector
;
vector
<
vector
<
string
>>
verifVector
;
try
{
try
{
...
@@ -438,17 +421,14 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
...
@@ -438,17 +421,14 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
result
[
"verificationVector"
]
=
""
;
result
[
"verificationVector"
]
=
""
;
}
}
RETURN_SUCCESS
(
result
)
return
result
;
}
}
Json
::
Value
SGXWalletServer
::
getSecretShareImpl
(
const
string
&
_polyName
,
const
Json
::
Value
&
_pubKeys
,
int
_t
,
int
_n
)
{
Json
::
Value
SGXWalletServer
::
getSecretShareImpl
(
const
string
&
_polyName
,
const
Json
::
Value
&
_pubKeys
,
int
_t
,
int
_n
)
{
INIT_RESULT
(
result
);
INIT_RESULT
(
result
);
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
try
{
try
{
if
(
_pubKeys
.
size
()
!=
(
uint64_t
)
_n
)
{
if
(
_pubKeys
.
size
()
!=
(
uint64_t
)
_n
)
{
throw
SGXException
(
INVALID_DKG_PARAMS
,
"invalid number of public keys"
);
throw
SGXException
(
INVALID_DKG_PARAMS
,
"invalid number of public keys"
);
...
@@ -470,11 +450,12 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
...
@@ -470,11 +450,12 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
pubKeysStrs
.
push_back
(
_pubKeys
[
i
].
asString
());
pubKeysStrs
.
push_back
(
_pubKeys
[
i
].
asString
());
}
}
string
s
=
trustedG
etSecretShares
(
_polyName
,
encrPoly
->
c_str
(),
pubKeysStrs
,
_t
,
_n
);
string
s
=
g
etSecretShares
(
_polyName
,
encrPoly
->
c_str
(),
pubKeysStrs
,
_t
,
_n
);
result
[
"secretShare"
]
=
s
;
result
[
"secretShare"
]
=
s
;
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
RETURN_SUCCESS
(
result
)
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
SGXWalletServer
::
dkgVerificationImpl
(
const
string
&
_publicShares
,
const
string
&
_ethKeyName
,
Json
::
Value
SGXWalletServer
::
dkgVerificationImpl
(
const
string
&
_publicShares
,
const
string
&
_ethKeyName
,
...
@@ -517,8 +498,6 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
...
@@ -517,8 +498,6 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
try
{
try
{
if
(
_secretShare
.
length
()
!=
(
uint64_t
)
_n
*
192
)
{
if
(
_secretShare
.
length
()
!=
(
uint64_t
)
_n
*
192
)
{
...
@@ -615,9 +594,7 @@ Json::Value SGXWalletServer::multG2Impl(const string &_x) {
...
@@ -615,9 +594,7 @@ Json::Value SGXWalletServer::multG2Impl(const string &_x) {
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
result
[
"status"
]
=
0
;
RETURN_SUCCESS
(
result
)
result
[
"errorMessage"
]
=
""
;
return
result
;
}
}
Json
::
Value
SGXWalletServer
::
isPolyExistsImpl
(
const
string
&
_polyName
)
{
Json
::
Value
SGXWalletServer
::
isPolyExistsImpl
(
const
string
&
_polyName
)
{
...
@@ -633,9 +610,7 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
...
@@ -633,9 +610,7 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
}
}
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
result
[
"status"
]
=
0
;
RETURN_SUCCESS
(
result
)
result
[
"errorMessage"
]
=
""
;
return
result
;
}
}
Json
::
Value
SGXWalletServer
::
getServerStatusImpl
()
{
Json
::
Value
SGXWalletServer
::
getServerStatusImpl
()
{
...
@@ -647,9 +622,7 @@ Json::Value SGXWalletServer::getServerVersionImpl() {
...
@@ -647,9 +622,7 @@ Json::Value SGXWalletServer::getServerVersionImpl() {
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"version"
]
=
TOSTRING
(
SGXWALLET_VERSION
);
result
[
"version"
]
=
TOSTRING
(
SGXWALLET_VERSION
);
result
[
"status"
]
=
0
;
RETURN_SUCCESS
(
result
)
result
[
"errorMessage"
]
=
""
;
return
result
;
}
}
Json
::
Value
SGXWalletServer
::
deleteBlsKeyImpl
(
const
std
::
string
&
name
)
{
Json
::
Value
SGXWalletServer
::
deleteBlsKeyImpl
(
const
std
::
string
&
name
)
{
...
...
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