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
6f35e65a
Unverified
Commit
6f35e65a
authored
Aug 13, 2020
by
Stan Kladko
Committed by
GitHub
Aug 13, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #141 from skalenetwork/SKALE-3067-cleanip2
Skale 3067 cleanip2
parents
b95ab32d
f3456f30
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
89 additions
and
169 deletions
+89
-169
CSRManagerServer.cpp
CSRManagerServer.cpp
+3
-6
LevelDB.cpp
LevelDB.cpp
+8
-31
Log.h
Log.h
+1
-1
SGXRegistrationServer.cpp
SGXRegistrationServer.cpp
+2
-2
SGXWalletServer.cpp
SGXWalletServer.cpp
+66
-125
SGXWalletServer.hpp
SGXWalletServer.hpp
+1
-2
TestUtils.cpp
TestUtils.cpp
+4
-2
secure_enclave.edl
secure_enclave/secure_enclave.edl
+2
-0
sgxwallet_common.h
sgxwallet_common.h
+2
-0
No files found.
CSRManagerServer.cpp
View file @
6f35e65a
...
@@ -40,7 +40,6 @@ CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector,
...
@@ -40,7 +40,6 @@ CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector,
serverVersion_t
type
)
:
abstractCSRManagerServer
(
connector
,
type
)
{}
serverVersion_t
type
)
:
abstractCSRManagerServer
(
connector
,
type
)
{}
Json
::
Value
getUnsignedCSRsImpl
()
{
Json
::
Value
getUnsignedCSRsImpl
()
{
spdlog
::
info
(
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
try
{
try
{
...
@@ -50,12 +49,11 @@ Json::Value getUnsignedCSRsImpl() {
...
@@ -50,12 +49,11 @@ 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"
]
=
""
;
try
{
try
{
if
(
!
(
status
==
0
||
status
==
2
))
{
if
(
!
(
status
==
0
||
status
==
2
))
{
...
@@ -89,7 +87,6 @@ Json::Value signByHashImpl(const string &hash, int status) {
...
@@ -89,7 +87,6 @@ Json::Value signByHashImpl(const string &hash, int status) {
LevelDB
::
getCsrStatusDb
()
->
deleteKey
(
status_db_key
);
LevelDB
::
getCsrStatusDb
()
->
deleteKey
(
status_db_key
);
LevelDB
::
getCsrStatusDb
()
->
writeDataUnique
(
status_db_key
,
"-1"
);
LevelDB
::
getCsrStatusDb
()
->
writeDataUnique
(
status_db_key
,
"-1"
);
throw
SGXException
(
FAIL_TO_CREATE_CERTIFICATE
,
"CLIENT CERTIFICATE GENERATION FAILED"
);
throw
SGXException
(
FAIL_TO_CREATE_CERTIFICATE
,
"CLIENT CERTIFICATE GENERATION FAILED"
);
//exit(-1);
}
}
}
}
...
@@ -102,7 +99,7 @@ Json::Value signByHashImpl(const string &hash, int status) {
...
@@ -102,7 +99,7 @@ Json::Value signByHashImpl(const string &hash, int status) {
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
CSRManagerServer
::
getUnsignedCSRs
()
{
Json
::
Value
CSRManagerServer
::
getUnsignedCSRs
()
{
...
...
LevelDB.cpp
View file @
6f35e65a
...
@@ -43,15 +43,10 @@ static WriteOptions writeOptions;
...
@@ -43,15 +43,10 @@ static WriteOptions writeOptions;
static
ReadOptions
readOptions
;
static
ReadOptions
readOptions
;
std
::
shared_ptr
<
string
>
LevelDB
::
readString
(
const
string
&
_key
)
{
std
::
shared_ptr
<
string
>
LevelDB
::
readString
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
result
=
std
::
make_shared
<
string
>
();
auto
result
=
std
::
make_shared
<
string
>
();
if
(
db
==
nullptr
)
{
CHECK_STATE
(
db
)
throw
SGXException
(
NULL_DATABASE
,
"Null db"
);
}
spdlog
::
debug
(
"key to read from db: {}"
,
_key
);
auto
status
=
db
->
Get
(
readOptions
,
_key
,
result
.
get
());
auto
status
=
db
->
Get
(
readOptions
,
_key
,
result
.
get
());
...
@@ -65,18 +60,14 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
...
@@ -65,18 +60,14 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
}
}
void
LevelDB
::
writeString
(
const
string
&
_key
,
const
string
&
_value
)
{
void
LevelDB
::
writeString
(
const
string
&
_key
,
const
string
&
_value
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
),
Slice
(
_value
));
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
),
Slice
(
_value
));
throwExceptionOnError
(
status
);
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"written key: {}"
,
_key
);
}
}
void
LevelDB
::
deleteDHDKGKey
(
const
string
&
_key
)
{
void
LevelDB
::
deleteDHDKGKey
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
string
full_key
=
"DKG_DH_KEY_"
+
_key
;
string
full_key
=
"DKG_DH_KEY_"
+
_key
;
...
@@ -84,48 +75,31 @@ void LevelDB::deleteDHDKGKey(const string &_key) {
...
@@ -84,48 +75,31 @@ void LevelDB::deleteDHDKGKey(const string &_key) {
throwExceptionOnError
(
status
);
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"key deleted: {}"
,
full_key
);
}
}
void
LevelDB
::
deleteTempNEK
(
const
string
&
_key
)
{
void
LevelDB
::
deleteTempNEK
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
string
prefix
=
_key
.
substr
(
0
,
8
);
CHECK_STATE
(
_key
.
rfind
(
"tmp_NEK"
,
0
)
==
0
);
if
(
prefix
!=
"tmp_NEK:"
)
{
return
;
}
auto
status
=
db
->
Delete
(
writeOptions
,
Slice
(
_key
));
auto
status
=
db
->
Delete
(
writeOptions
,
Slice
(
_key
));
throwExceptionOnError
(
status
);
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"key deleted: {}"
,
_key
);
}
}
void
LevelDB
::
deleteKey
(
const
string
&
_key
)
{
void
LevelDB
::
deleteKey
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Delete
(
writeOptions
,
Slice
(
_key
));
auto
status
=
db
->
Delete
(
writeOptions
,
Slice
(
_key
));
throwExceptionOnError
(
status
);
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"key deleted: {}"
,
_key
);
}
}
void
LevelDB
::
writeByteArray
(
const
char
*
_key
,
size_t
_keyLen
,
const
char
*
value
,
size_t
_valueLen
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
,
_keyLen
),
Slice
(
value
,
_valueLen
));
throwExceptionOnError
(
status
);
}
void
LevelDB
::
writeByteArray
(
string
&
_key
,
const
char
*
value
,
void
LevelDB
::
writeByteArray
(
string
&
_key
,
const
char
*
value
,
size_t
_valueLen
)
{
size_t
_valueLen
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
CHECK_STATE
(
value
);
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
),
Slice
(
value
,
_valueLen
));
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
),
Slice
(
value
,
_valueLen
));
...
@@ -142,6 +116,9 @@ void LevelDB::throwExceptionOnError(Status _status) {
...
@@ -142,6 +116,9 @@ void LevelDB::throwExceptionOnError(Status _status) {
}
}
uint64_t
LevelDB
::
visitKeys
(
LevelDB
::
KeyVisitor
*
_visitor
,
uint64_t
_maxKeysToVisit
)
{
uint64_t
LevelDB
::
visitKeys
(
LevelDB
::
KeyVisitor
*
_visitor
,
uint64_t
_maxKeysToVisit
)
{
CHECK_STATE
(
_visitor
);
uint64_t
readCounter
=
0
;
uint64_t
readCounter
=
0
;
leveldb
::
Iterator
*
it
=
db
->
NewIterator
(
readOptions
);
leveldb
::
Iterator
*
it
=
db
->
NewIterator
(
readOptions
);
...
@@ -187,7 +164,7 @@ void LevelDB::writeDataUnique(const string & Name, const string &value) {
...
@@ -187,7 +164,7 @@ void LevelDB::writeDataUnique(const string & Name, const string &value) {
writeString
(
key
,
value
);
writeString
(
key
,
value
);
spdlog
::
debug
(
"{}"
,
Name
,
" is written to db"
);
}
}
...
...
Log.h
View file @
6f35e65a
...
@@ -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 @
6f35e65a
...
@@ -112,7 +112,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
...
@@ -112,7 +112,7 @@ 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 +147,7 @@ Json::Value getCertificateImpl(const string &hash) {
...
@@ -147,7 +147,7 @@ Json::Value getCertificateImpl(const string &hash) {
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
}
...
...
SGXWalletServer.cpp
View file @
6f35e65a
...
@@ -85,8 +85,8 @@ bool isStringDec(const string &_str) {
...
@@ -85,8 +85,8 @@ bool isStringDec(const string &_str) {
return
!
_str
.
empty
()
&&
res
==
_str
.
end
();
return
!
_str
.
empty
()
&&
res
==
_str
.
end
();
}
}
shared_ptr
<
SGXWalletServer
>
SGXWalletServer
::
server
=
nullptr
;
shared_ptr
<
SGXWalletServer
>
SGXWalletServer
::
server
=
nullptr
;
shared_ptr
<
HttpServer
>
SGXWalletServer
::
httpServer
=
nullptr
;
shared_ptr
<
HttpServer
>
SGXWalletServer
::
httpServer
=
nullptr
;
SGXWalletServer
::
SGXWalletServer
(
AbstractServerConnector
&
_connector
,
SGXWalletServer
::
SGXWalletServer
(
AbstractServerConnector
&
_connector
,
serverVersion_t
_type
)
serverVersion_t
_type
)
...
@@ -142,7 +142,7 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
...
@@ -142,7 +142,7 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
,
certPath
,
keyPath
,
rootCAPath
,
_checkCerts
,
64
);
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
,
certPath
,
keyPath
,
rootCAPath
,
_checkCerts
,
64
);
server
=
make_shared
<
SGXWalletServer
>
(
*
httpServer
,
server
=
make_shared
<
SGXWalletServer
>
(
*
httpServer
,
JSONRPC_SERVER_V2
);
// hybrid server (json-rpc 1.0 & 2.0)
JSONRPC_SERVER_V2
);
// hybrid server (json-rpc 1.0 & 2.0)
if
(
!
server
->
StartListening
())
{
if
(
!
server
->
StartListening
())
{
spdlog
::
error
(
"SGX Server could not start listening"
);
spdlog
::
error
(
"SGX Server could not start listening"
);
...
@@ -156,7 +156,7 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
...
@@ -156,7 +156,7 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
int
SGXWalletServer
::
initHttpServer
()
{
//without ssl
int
SGXWalletServer
::
initHttpServer
()
{
//without ssl
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
+
3
);
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
+
3
);
server
=
make_shared
<
SGXWalletServer
>
(
*
httpServer
,
server
=
make_shared
<
SGXWalletServer
>
(
*
httpServer
,
JSONRPC_SERVER_V2
);
// hybrid server (json-rpc 1.0 & 2.0)
JSONRPC_SERVER_V2
);
// hybrid server (json-rpc 1.0 & 2.0)
if
(
!
server
->
StartListening
())
{
if
(
!
server
->
StartListening
())
{
spdlog
::
error
(
"Server could not start listening"
);
spdlog
::
error
(
"Server could not start listening"
);
exit
(
-
1
);
exit
(
-
1
);
...
@@ -166,19 +166,15 @@ int SGXWalletServer::initHttpServer() { //without ssl
...
@@ -166,19 +166,15 @@ int SGXWalletServer::initHttpServer() { //without ssl
Json
::
Value
Json
::
Value
SGXWalletServer
::
importBLSKeyShareImpl
(
const
string
&
_keyShare
,
const
string
&
_keyShareName
,
int
t
,
int
n
,
int
_index
)
{
SGXWalletServer
::
importBLSKeyShareImpl
(
const
string
&
_keyShare
,
const
string
&
_keyShareName
,
int
t
,
int
n
,
int
_index
)
{
Json
::
Value
result
;
int
errStatus
=
UNKNOWN_ERROR
;
INIT_RESULT
(
result
);
string
errMsg
(
BUF_LEN
,
'\0'
);
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"encryptedKeyShare"
]
=
""
;
result
[
"encryptedKeyShare"
]
=
""
;
string
encryptedKeyShareHex
;
string
encryptedKeyShareHex
;
try
{
try
{
encryptedKeyShareHex
=
encryptBLSKeyShare2Hex
(
&
errStatus
,
&
errMsg
.
front
(),
_keyShare
.
c_str
());
encryptedKeyShareHex
=
encryptBLSKeyShare2Hex
(
&
errStatus
,
(
char
*
)
errMsg
.
data
(),
_keyShare
.
c_str
());
if
(
errStatus
!=
0
)
{
if
(
errStatus
!=
0
)
{
throw
SGXException
(
errStatus
,
errMsg
.
data
());
throw
SGXException
(
errStatus
,
errMsg
.
data
());
...
@@ -191,23 +187,22 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
...
@@ -191,23 +187,22 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
result
[
"encryptedKeyShare"
]
=
encryptedKeyShareHex
;
result
[
"encryptedKeyShare"
]
=
encryptedKeyShareHex
;
writeKeyShare
(
_keyShareName
,
encryptedKeyShareHex
,
_index
,
n
,
t
);
writeKeyShare
(
_keyShareName
,
encryptedKeyShareHex
,
_index
,
n
,
t
);
}
catch
(
SGXException
&
_e
)
{
}
HANDLE_SGX_EXCEPTION
(
result
)
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
return
result
;
RETURN_SUCCESS
(
result
)
;
}
}
Json
::
Value
Json
::
Value
SGXWalletServer
::
blsSignMessageHashImpl
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
t
,
int
n
,
SGXWalletServer
::
blsSignMessageHashImpl
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
t
,
int
n
,
int
_signerIndex
)
{
int
_signerIndex
)
{
Json
::
Value
result
;
INIT_RESULT
(
result
)
result
[
"status"
]
=
-
1
;
result
[
"status"
]
=
-
1
;
result
[
"errorMessage"
]
=
"Unknown server error"
;
result
[
"signatureShare"
]
=
""
;
result
[
"signatureShare"
]
=
""
;
string
signature
(
BUF_LEN
,
'\0'
);
vector
<
char
>
signature
(
BUF_LEN
,
0
);
shared_ptr
<
string
>
value
=
nullptr
;
shared_ptr
<
string
>
value
=
nullptr
;
...
@@ -228,49 +223,26 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
...
@@ -228,49 +223,26 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
}
}
value
=
readFromDb
(
_keyShareName
);
value
=
readFromDb
(
_keyShareName
);
}
catch
(
SGXException
&
_e
)
{
if
(
!
bls_sign
(
value
->
c_str
(),
_messageHash
.
c_str
(),
t
,
n
,
_signerIndex
,
signature
.
data
()))
{
result
[
"status"
]
=
_e
.
status
;
throw
SGXException
(
-
1
,
"Could not sign data "
);
result
[
"errorMessage"
]
=
_e
.
errString
;
}
return
result
;
}
HANDLE_SGX_EXCEPTION
(
result
)
}
catch
(...)
{
exception_ptr
p
=
current_exception
();
printf
(
"Exception %s
\n
"
,
p
.
__cxa_exception_type
()
->
name
());
result
[
"status"
]
=
-
1
;
result
[
"errorMessage"
]
=
"Read key share has thrown exception:"
;
return
result
;
}
try
{
if
(
!
bls_sign
(
value
->
c_str
(),
_messageHash
.
c_str
(),
t
,
n
,
_signerIndex
,
&
signature
.
front
()))
{
result
[
"status"
]
=
-
1
;
result
[
"errorMessage"
]
=
"Could not sign"
;
return
result
;
}
}
catch
(...)
{
result
[
"status"
]
=
-
1
;
result
[
"errorMessage"
]
=
"Sign has thrown exception"
;
return
result
;
}
auto
it
=
std
::
find
(
signature
.
begin
(),
signature
.
end
(),
'\0'
);
result
[
"signatureShare"
]
=
string
(
signature
.
data
());
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
RETURN_SUCCESS
(
result
);
result
[
"signatureShare"
]
=
std
::
string
(
signature
.
begin
(),
it
);
return
result
;
}
}
Json
::
Value
SGXWalletServer
::
importECDSAKeyImpl
(
const
string
&
_key
,
const
string
&
_keyName
)
{
Json
::
Value
SGXWalletServer
::
importECDSAKeyImpl
(
const
string
&
_key
,
const
string
&
_keyName
)
{
Json
::
Value
result
;
INIT_RESULT
(
result
)
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"encryptedKey"
]
=
""
;
result
[
"encryptedKey"
]
=
""
;
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
SGXWalletServer
::
generateECDSAKeyImpl
()
{
Json
::
Value
SGXWalletServer
::
generateECDSAKeyImpl
()
{
Json
::
Value
result
;
INIT_RESULT
(
result
)
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"encryptedKey"
]
=
""
;
result
[
"encryptedKey"
]
=
""
;
vector
<
string
>
keys
;
vector
<
string
>
keys
;
...
@@ -284,9 +256,6 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
...
@@ -284,9 +256,6 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
string
keyName
=
"NEK:"
+
keys
.
at
(
2
);
string
keyName
=
"NEK:"
+
keys
.
at
(
2
);
spdlog
::
debug
(
"key name generated: {}"
,
keyName
);
spdlog
::
debug
(
"write encr key {}"
,
keys
.
at
(
0
));
writeDataToDB
(
keyName
,
keys
.
at
(
0
));
writeDataToDB
(
keyName
,
keys
.
at
(
0
));
result
[
"encryptedKey"
]
=
keys
.
at
(
0
);
result
[
"encryptedKey"
]
=
keys
.
at
(
0
);
...
@@ -295,7 +264,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
...
@@ -295,7 +264,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
result
[
"keyName"
]
=
keyName
;
result
[
"keyName"
]
=
keyName
;
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
;
}
}
Json
::
Value
SGXWalletServer
::
renameECDSAKeyImpl
(
const
string
&
_keyName
,
const
string
&
_tempKeyName
)
{
Json
::
Value
SGXWalletServer
::
renameECDSAKeyImpl
(
const
string
&
_keyName
,
const
string
&
_tempKeyName
)
{
...
@@ -322,7 +291,7 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
...
@@ -322,7 +291,7 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
LevelDB
::
getLevelDb
()
->
deleteTempNEK
(
_tempKeyName
);
LevelDB
::
getLevelDb
()
->
deleteTempNEK
(
_tempKeyName
);
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
;
}
}
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHashImpl
(
int
_base
,
const
string
&
_keyName
,
const
string
&
_messageHash
)
{
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHashImpl
(
int
_base
,
const
string
&
_keyName
,
const
string
&
_messageHash
)
{
...
@@ -360,14 +329,13 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
...
@@ -360,14 +329,13 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
throw
SGXException
(
INVALID_ECSDA_SIGNATURE
,
"Invalid ecdsa signature"
);
throw
SGXException
(
INVALID_ECSDA_SIGNATURE
,
"Invalid ecdsa signature"
);
}
}
spdlog
::
debug
(
"got signature_s {}"
,
signatureVector
.
at
(
2
));
result
[
"signature_v"
]
=
signatureVector
.
at
(
0
);
result
[
"signature_v"
]
=
signatureVector
.
at
(
0
);
result
[
"signature_r"
]
=
signatureVector
.
at
(
1
);
result
[
"signature_r"
]
=
signatureVector
.
at
(
1
);
result
[
"signature_s"
]
=
signatureVector
.
at
(
2
);
result
[
"signature_s"
]
=
signatureVector
.
at
(
2
);
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
SGXWalletServer
::
getPublicECDSAKeyImpl
(
const
string
&
_keyName
)
{
Json
::
Value
SGXWalletServer
::
getPublicECDSAKeyImpl
(
const
string
&
_keyName
)
{
...
@@ -384,14 +352,11 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
...
@@ -384,14 +352,11 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
}
}
shared_ptr
<
string
>
keyStr
=
readFromDb
(
_keyName
);
shared_ptr
<
string
>
keyStr
=
readFromDb
(
_keyName
);
publicKey
=
getECDSAPubKey
(
keyStr
->
c_str
());
publicKey
=
getECDSAPubKey
(
keyStr
->
c_str
());
spdlog
::
debug
(
"PublicKey {}"
,
publicKey
);
spdlog
::
debug
(
"PublicKey length {}"
,
publicKey
.
length
());
result
[
"PublicKey"
]
=
publicKey
;
result
[
"PublicKey"
]
=
publicKey
;
result
[
"publicKey"
]
=
publicKey
;
result
[
"publicKey"
]
=
publicKey
;
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
SGXWalletServer
::
generateDKGPolyImpl
(
const
string
&
_polyName
,
int
_t
)
{
Json
::
Value
SGXWalletServer
::
generateDKGPolyImpl
(
const
string
&
_polyName
,
int
_t
)
{
...
@@ -411,13 +376,11 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t
...
@@ -411,13 +376,11 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t
writeDataToDB
(
_polyName
,
encrPolyHex
);
writeDataToDB
(
_polyName
,
encrPolyHex
);
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
SGXWalletServer
::
getVerificationVectorImpl
(
const
string
&
_polyName
,
int
_t
,
int
_n
)
{
Json
::
Value
SGXWalletServer
::
getVerificationVectorImpl
(
const
string
&
_polyName
,
int
_t
,
int
_n
)
{
Json
::
Value
result
;
INIT_RESULT
(
result
)
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
vector
<
vector
<
string
>>
verifVector
;
vector
<
vector
<
string
>>
verifVector
;
try
{
try
{
...
@@ -428,7 +391,7 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
...
@@ -428,7 +391,7 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
throw
SGXException
(
INVALID_DKG_PARAMS
,
"Invalid parameters: n or t "
);
throw
SGXException
(
INVALID_DKG_PARAMS
,
"Invalid parameters: n or t "
);
}
}
shared_ptr
<
string
>
encrPoly
=
readFromDb
(
_polyName
);
shared_ptr
<
string
>
encrPoly
=
readFromDb
(
_polyName
);
verifVector
=
get_verif_vect
(
encrPoly
->
c_str
(),
_t
,
_n
);
verifVector
=
get_verif_vect
(
encrPoly
->
c_str
(),
_t
,
_n
);
...
@@ -438,20 +401,16 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
...
@@ -438,20 +401,16 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
result
[
"verificationVector"
][
i
][
j
]
=
currentCoef
.
at
(
j
);
result
[
"verificationVector"
][
i
][
j
]
=
currentCoef
.
at
(
j
);
}
}
}
}
}
catch
(
SGXException
&
_e
)
{
}
HANDLE_SGX_EXCEPTION
(
result
)
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
RETURN_SUCCESS
(
result
)
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"verificationVector"
]
=
""
;
}
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
)
{
Json
::
Value
result
;
INIT_RESULT
(
result
)
;
result
[
"s
tatus"
]
=
0
;
result
[
"s
ecretShare"
]
=
""
;
result
[
"
errorMessag
e"
]
=
""
;
result
[
"
SecretShar
e"
]
=
""
;
try
{
try
{
if
(
_pubKeys
.
size
()
!=
(
uint64_t
)
_n
)
{
if
(
_pubKeys
.
size
()
!=
(
uint64_t
)
_n
)
{
...
@@ -476,22 +435,16 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
...
@@ -476,22 +435,16 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
string
s
=
trustedGetSecretShares
(
_polyName
,
encrPoly
->
c_str
(),
pubKeysStrs
,
_t
,
_n
);
string
s
=
trustedGetSecretShares
(
_polyName
,
encrPoly
->
c_str
(),
pubKeysStrs
,
_t
,
_n
);
result
[
"secretShare"
]
=
s
;
result
[
"secretShare"
]
=
s
;
}
catch
(
SGXException
&
_e
)
{
result
[
"SecretShare"
]
=
s
;
result
[
"status"
]
=
_e
.
status
;
}
HANDLE_SGX_EXCEPTION
(
result
)
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"secretShare"
]
=
""
;
result
[
"SecretShare"
]
=
""
;
}
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
SGXWalletServer
::
dkgVerificationImpl
(
const
string
&
_publicShares
,
const
string
&
_ethKeyName
,
Json
::
Value
SGXWalletServer
::
dkgVerificationImpl
(
const
string
&
_publicShares
,
const
string
&
_ethKeyName
,
const
string
&
_secretShare
,
int
_t
,
int
_n
,
int
_index
)
{
const
string
&
_secretShare
,
int
_t
,
int
_n
,
int
_index
)
{
Json
::
Value
result
;
INIT_RESULT
(
result
)
result
[
"status"
]
=
0
;
result
[
"result"
]
=
false
;
result
[
"errorMessage"
]
=
""
;
result
[
"result"
]
=
true
;
try
{
try
{
if
(
!
checkECDSAKeyName
(
_ethKeyName
))
{
if
(
!
checkECDSAKeyName
(
_ethKeyName
))
{
...
@@ -509,29 +462,21 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
...
@@ -509,29 +462,21 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
_ethKeyName
);
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
_ethKeyName
);
if
(
!
verifyShares
(
_publicShares
.
c_str
(),
_secretShare
.
c_str
(),
encryptedKeyHex_ptr
->
c_str
(),
_t
,
_n
,
_index
))
{
if
(
verifyShares
(
_publicShares
.
c_str
(),
_secretShare
.
c_str
(),
encryptedKeyHex_ptr
->
c_str
(),
_t
,
_n
,
_index
))
{
result
[
"result"
]
=
fals
e
;
result
[
"result"
]
=
tru
e
;
}
}
}
catch
(
SGXException
&
_e
)
{
}
HANDLE_SGX_EXCEPTION
(
result
)
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"result"
]
=
false
;
}
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
Json
::
Value
SGXWalletServer
::
createBLSPrivateKeyImpl
(
const
string
&
_blsKeyName
,
const
string
&
_ethKeyName
,
const
string
&
_polyName
,
SGXWalletServer
::
createBLSPrivateKeyImpl
(
const
string
&
_blsKeyName
,
const
string
&
_ethKeyName
,
const
string
&
_polyName
,
const
string
&
_secretShare
,
int
_t
,
int
_n
)
{
const
string
&
_secretShare
,
int
_t
,
int
_n
)
{
Json
::
Value
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
)
{
spdlog
::
error
(
"Invalid secret share length - {}"
,
_secretShare
.
length
());
spdlog
::
error
(
"Secret share - {}"
,
_secretShare
);
throw
SGXException
(
INVALID_SECRET_SHARES_LENGTH
,
"Invalid secret share length"
);
throw
SGXException
(
INVALID_SECRET_SHARES_LENGTH
,
"Invalid secret share length"
);
}
}
if
(
!
checkECDSAKeyName
(
_ethKeyName
))
{
if
(
!
checkECDSAKeyName
(
_ethKeyName
))
{
...
@@ -546,11 +491,11 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
...
@@ -546,11 +491,11 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
if
(
!
check_n_t
(
_t
,
_n
))
{
if
(
!
check_n_t
(
_t
,
_n
))
{
throw
SGXException
(
INVALID_DKG_PARAMS
,
"Invalid DKG parameters: n or t "
);
throw
SGXException
(
INVALID_DKG_PARAMS
,
"Invalid DKG parameters: n or t "
);
}
}
vector
<
string
>
sshares_vect
;
vector
<
string
>
sshares_vect
;
spdlog
::
debug
(
"secret shares from json are - {}"
,
_secretShare
);
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
_ethKeyName
);
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
_ethKeyName
);
bool
res
=
CreateBLSShare
(
_blsKeyName
,
_secretShare
.
c_str
(),
encryptedKeyHex_ptr
->
c_str
());
bool
res
=
CreateBLSShare
(
_blsKeyName
,
_secretShare
.
c_str
(),
encryptedKeyHex_ptr
->
c_str
());
if
(
res
)
{
if
(
res
)
{
...
@@ -569,7 +514,7 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
...
@@ -569,7 +514,7 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
;
}
}
Json
::
Value
SGXWalletServer
::
getBLSPublicKeyShareImpl
(
const
string
&
_blsKeyName
)
{
Json
::
Value
SGXWalletServer
::
getBLSPublicKeyShareImpl
(
const
string
&
_blsKeyName
)
{
...
@@ -580,8 +525,6 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
...
@@ -580,8 +525,6 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
throw
SGXException
(
INVALID_BLS_NAME
,
"Invalid BLSKey name"
);
throw
SGXException
(
INVALID_BLS_NAME
,
"Invalid BLSKey name"
);
}
}
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
_blsKeyName
);
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
_blsKeyName
);
spdlog
::
debug
(
"encr_bls_key_share is {}"
,
*
encryptedKeyHex_ptr
);
spdlog
::
debug
(
"length is {}"
,
encryptedKeyHex_ptr
->
length
());
vector
<
string
>
public_key_vect
=
GetBLSPubKey
(
encryptedKeyHex_ptr
->
c_str
());
vector
<
string
>
public_key_vect
=
GetBLSPubKey
(
encryptedKeyHex_ptr
->
c_str
());
for
(
uint8_t
i
=
0
;
i
<
4
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
4
;
i
++
)
{
...
@@ -589,7 +532,7 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
...
@@ -589,7 +532,7 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
}
}
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
;
}
}
Json
::
Value
SGXWalletServer
::
complaintResponseImpl
(
const
string
&
_polyName
,
int
_ind
)
{
Json
::
Value
SGXWalletServer
::
complaintResponseImpl
(
const
string
&
_polyName
,
int
_ind
)
{
...
@@ -608,7 +551,7 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
...
@@ -608,7 +551,7 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
result
[
"dhKey"
]
=
DHKey
;
result
[
"dhKey"
]
=
DHKey
;
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
;
}
}
Json
::
Value
SGXWalletServer
::
multG2Impl
(
const
string
&
_x
)
{
Json
::
Value
SGXWalletServer
::
multG2Impl
(
const
string
&
_x
)
{
...
@@ -621,7 +564,7 @@ Json::Value SGXWalletServer::multG2Impl(const string &_x) {
...
@@ -621,7 +564,7 @@ Json::Value SGXWalletServer::multG2Impl(const string &_x) {
}
}
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
;
}
}
Json
::
Value
SGXWalletServer
::
isPolyExistsImpl
(
const
string
&
_polyName
)
{
Json
::
Value
SGXWalletServer
::
isPolyExistsImpl
(
const
string
&
_polyName
)
{
...
@@ -630,28 +573,28 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
...
@@ -630,28 +573,28 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
result
[
"IsExist"
]
=
false
;
result
[
"IsExist"
]
=
false
;
try
{
try
{
s
td
::
shared_ptr
<
std
::
string
>
poly_str_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
_polyName
);
s
hared_ptr
<
string
>
poly_str_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
_polyName
);
if
(
poly_str_ptr
!=
nullptr
)
{
if
(
poly_str_ptr
!=
nullptr
)
{
result
[
"IsExist"
]
=
true
;
result
[
"IsExist"
]
=
true
;
}
}
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
;
}
}
Json
::
Value
SGXWalletServer
::
getServerStatusImpl
()
{
Json
::
Value
SGXWalletServer
::
getServerStatusImpl
()
{
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
SGXWalletServer
::
getServerVersionImpl
()
{
Json
::
Value
SGXWalletServer
::
getServerVersionImpl
()
{
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"version"
]
=
TOSTRING
(
SGXWALLET_VERSION
);
result
[
"version"
]
=
TOSTRING
(
SGXWALLET_VERSION
);
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
SGXWalletServer
::
deleteBlsKeyImpl
(
const
st
d
::
string
&
name
)
{
Json
::
Value
SGXWalletServer
::
deleteBlsKeyImpl
(
const
st
ring
&
name
)
{
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"deleted"
]
=
false
;
result
[
"deleted"
]
=
false
;
...
@@ -659,18 +602,18 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) {
...
@@ -659,18 +602,18 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) {
if
(
!
checkName
(
name
,
"BLS_KEY"
))
{
if
(
!
checkName
(
name
,
"BLS_KEY"
))
{
throw
SGXException
(
INVALID_BLS_NAME
,
"Invalid BLSKey name format"
);
throw
SGXException
(
INVALID_BLS_NAME
,
"Invalid BLSKey name format"
);
}
}
s
td
::
shared_ptr
<
std
::
string
>
bls_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
name
);
s
hared_ptr
<
string
>
bls_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
name
);
if
(
bls_ptr
!=
nullptr
)
{
if
(
bls_ptr
!=
nullptr
)
{
LevelDB
::
getLevelDb
()
->
deleteKey
(
name
);
LevelDB
::
getLevelDb
()
->
deleteKey
(
name
);
result
[
"deleted"
]
=
true
;
result
[
"deleted"
]
=
true
;
return
result
;
}
else
{
}
else
{
std
::
string
error_msg
=
"BLS key with such name
not found: "
+
name
;
auto
error_msg
=
"BLS key
not found: "
+
name
;
throw
SGXException
(
INVALID_BLS_NAME
,
error_msg
.
c_str
());
throw
SGXException
(
INVALID_BLS_NAME
,
error_msg
.
c_str
());
}
}
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
}
Json
::
Value
SGXWalletServer
::
generateDKGPoly
(
const
string
&
_polyName
,
int
_t
)
{
Json
::
Value
SGXWalletServer
::
generateDKGPoly
(
const
string
&
_polyName
,
int
_t
)
{
...
@@ -715,7 +658,6 @@ Json::Value SGXWalletServer::getPublicECDSAKey(const string &_keyName) {
...
@@ -715,7 +658,6 @@ Json::Value SGXWalletServer::getPublicECDSAKey(const string &_keyName) {
}
}
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHash
(
int
_base
,
const
string
&
_keyShareName
,
const
string
&
_messageHash
)
{
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHash
(
int
_base
,
const
string
&
_keyShareName
,
const
string
&
_messageHash
)
{
spdlog
::
debug
(
"MessageHash first {}"
,
_messageHash
);
return
ecdsaSignMessageHashImpl
(
_base
,
_keyShareName
,
_messageHash
);
return
ecdsaSignMessageHashImpl
(
_base
,
_keyShareName
,
_messageHash
);
}
}
...
@@ -754,7 +696,7 @@ Json::Value SGXWalletServer::getServerVersion() {
...
@@ -754,7 +696,7 @@ Json::Value SGXWalletServer::getServerVersion() {
return
getServerVersionImpl
();
return
getServerVersionImpl
();
}
}
Json
::
Value
SGXWalletServer
::
deleteBlsKey
(
const
st
d
::
string
&
name
)
{
Json
::
Value
SGXWalletServer
::
deleteBlsKey
(
const
st
ring
&
name
)
{
return
deleteBlsKeyImpl
(
name
);
return
deleteBlsKeyImpl
(
name
);
}
}
...
@@ -786,8 +728,7 @@ void SGXWalletServer::writeDataToDB(const string &Name, const string &value) {
...
@@ -786,8 +728,7 @@ void SGXWalletServer::writeDataToDB(const string &Name, const string &value) {
auto
key
=
Name
;
auto
key
=
Name
;
if
(
LevelDB
::
getLevelDb
()
->
readString
(
Name
)
!=
nullptr
)
{
if
(
LevelDB
::
getLevelDb
()
->
readString
(
Name
)
!=
nullptr
)
{
spdlog
::
info
(
"name {}"
,
Name
,
" already exists"
);
throw
SGXException
(
KEY_NAME_ALREADY_EXISTS
,
"Name already exists"
);
throw
SGXException
(
KEY_SHARE_ALREADY_EXISTS
,
"Key share already exists"
);
}
}
LevelDB
::
getLevelDb
()
->
writeString
(
key
,
value
);
LevelDB
::
getLevelDb
()
->
writeString
(
key
,
value
);
...
...
SGXWalletServer.hpp
View file @
6f35e65a
...
@@ -24,10 +24,9 @@
...
@@ -24,10 +24,9 @@
#ifndef SGXWALLET_SGXWALLETSERVER_HPP
#ifndef SGXWALLET_SGXWALLETSERVER_HPP
#define SGXWALLET_SGXWALLETSERVER_HPP
#define SGXWALLET_SGXWALLETSERVER_HPP
#include <boost/thread/shared_mutex.hpp>
#include <jsonrpccpp/server/connectors/httpserver.h>
#include <jsonrpccpp/server/connectors/httpserver.h>
#include <mutex>
#include "abstractstubserver.h"
#include "abstractstubserver.h"
using
namespace
jsonrpc
;
using
namespace
jsonrpc
;
...
...
TestUtils.cpp
View file @
6f35e65a
...
@@ -174,8 +174,10 @@ void TestUtils::sendRPCRequest() {
...
@@ -174,8 +174,10 @@ void TestUtils::sendRPCRequest() {
vector
<
string
>
pubShares
(
n
);
vector
<
string
>
pubShares
(
n
);
vector
<
string
>
polyNames
(
n
);
vector
<
string
>
polyNames
(
n
);
int
schainID
=
randGen
();
static
atomic
<
int
>
counter
(
1
);
int
dkgID
=
randGen
();
int
schainID
=
counter
.
fetch_add
(
1
);
int
dkgID
=
counter
.
fetch_add
(
1
);
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
ethKeys
[
i
]
=
c
.
generateECDSAKey
();
ethKeys
[
i
]
=
c
.
generateECDSAKey
();
CHECK_STATE
(
ethKeys
[
i
][
"status"
]
==
0
);
CHECK_STATE
(
ethKeys
[
i
][
"status"
]
==
0
);
...
...
secure_enclave/secure_enclave.edl
View file @
6f35e65a
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
#define ECDSA_ENCR_LEN 93
#define ECDSA_ENCR_LEN 93
#define ECDSA_BIN_LEN 33
#define ECDSA_BIN_LEN 33
#define SMALL_BUF_SIZE 1024
#define SMALL_BUF_SIZE 1024
#define TINY_BUF_SIZE 256
enclave {
enclave {
trusted {
trusted {
...
...
sgxwallet_common.h
View file @
6f35e65a
...
@@ -89,6 +89,8 @@ extern int autoconfirm;
...
@@ -89,6 +89,8 @@ extern int autoconfirm;
#define INVALID_ECDSA_KEY_NAME -20
#define INVALID_ECDSA_KEY_NAME -20
#define INVALID_HEX -21
#define INVALID_HEX -21
#define INVALID_ECSDA_SIGNATURE -22
#define INVALID_ECSDA_SIGNATURE -22
#define KEY_NAME_ALREADY_EXISTS -23 \
#define ERROR_IN_ENCLAVE -33
#define ERROR_IN_ENCLAVE -33
...
...
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