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
90d7eaba
Unverified
Commit
90d7eaba
authored
Apr 16, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2454-add-logs-to-enclave
parent
3baf6d2e
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
242 additions
and
231 deletions
+242
-231
BLSCrypto.cpp
BLSCrypto.cpp
+4
-4
CMakeLists.txt
CMakeLists.txt
+1
-1
CSRManagerServer.cpp
CSRManagerServer.cpp
+83
-84
DKGCrypto.cpp
DKGCrypto.cpp
+15
-15
ECDSACrypto.cpp
ECDSACrypto.cpp
+6
-6
LevelDB.cpp
LevelDB.cpp
+4
-4
RPCException.cpp
RPCException.cpp
+1
-1
SEKManager.cpp
SEKManager.cpp
+7
-7
SGXException.h
SGXException.h
+2
-2
SGXRegistrationServer.cpp
SGXRegistrationServer.cpp
+7
-7
SGXWalletServer.cpp
SGXWalletServer.cpp
+69
-62
SGXWalletServer.h
SGXWalletServer.h
+4
-2
sgxwallet.c
sgxwallet.c
+15
-12
sgxwallet_common.h
sgxwallet_common.h
+1
-1
testw.cpp
testw.cpp
+23
-23
No files found.
BLSCrypto.cpp
View file @
90d7eaba
...
...
@@ -49,7 +49,7 @@
#include "BLSCrypto.h"
#include "ServerInit.h"
#include "
RPC
Exception.h"
#include "
SGX
Exception.h"
#include "spdlog/spdlog.h"
#include "common.h"
...
...
@@ -160,7 +160,7 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t
uint64_t
binLen
;
if
(
!
hex2carray
(
_hashHex
,
&
binLen
,
hash
->
data
()))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid hash"
);
}
// assert(binLen == hash->size());
...
...
@@ -201,7 +201,7 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
uint64_t
binLen
;
if
(
!
hex2carray
(
_hashHex
,
&
binLen
,
hash
->
data
()))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid hash"
);
}
// assert(binLen == hash->size());
...
...
@@ -335,7 +335,7 @@ char *encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key)
}
if
(
*
errStatus
!=
0
)
{
throw
RPC
Exception
(
-
666
,
errMsg
->
data
());
throw
SGX
Exception
(
-
666
,
errMsg
->
data
());
}
...
...
CMakeLists.txt
View file @
90d7eaba
...
...
@@ -58,7 +58,7 @@ add_executable(sgxwallet
LevelDB.h
oc_alloc.c
RPCException.cpp
RPC
Exception.h
SGX
Exception.h
secure_enclave_u.c
secure_enclave_u.h
SEKManager.cpp
...
...
CSRManagerServer.cpp
View file @
90d7eaba
...
...
@@ -23,7 +23,7 @@
#include "CSRManagerServer.h"
#include "
RPC
Exception.h"
#include "
SGX
Exception.h"
#include "sgxwallet_common.h"
#include <iostream>
...
...
@@ -40,21 +40,21 @@ jsonrpc::HttpServer *hs3 = nullptr;
CSRManagerServer
::
CSRManagerServer
(
AbstractServerConnector
&
connector
,
serverVersion_t
type
)
:
abstractCSRManagerServer
(
connector
,
type
)
{}
serverVersion_t
type
)
:
abstractCSRManagerServer
(
connector
,
type
)
{}
Json
::
Value
getUnsignedCSRsImpl
(){
Json
::
Value
getUnsignedCSRsImpl
()
{
spdlog
::
info
(
"Enter getUnsignedCSRsImpl"
);
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
try
{
try
{
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
++
)
{
result
[
"hashes"
][
i
]
=
hashes_vect
.
at
(
i
);
}
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -64,19 +64,19 @@ Json::Value getUnsignedCSRsImpl(){
return
result
;
}
Json
::
Value
signByHashImpl
(
const
string
&
hash
,
int
status
)
{
Json
::
Value
signByHashImpl
(
const
string
&
hash
,
int
status
)
{
Json
::
Value
result
;
result
[
"errorMessage"
]
=
""
;
try
{
if
(
!
(
status
==
0
||
status
==
2
))
{
throw
RPC
Exception
(
-
111
,
"Invalid csr status"
);
try
{
if
(
!
(
status
==
0
||
status
==
2
))
{
throw
SGX
Exception
(
-
111
,
"Invalid csr status"
);
}
string
csr_db_key
=
"CSR:HASH:"
+
hash
;
shared_ptr
<
string
>
csr_ptr
=
LevelDB
::
getCsrDb
()
->
readString
(
csr_db_key
);
if
(
csr_ptr
==
nullptr
)
{
throw
RPC
Exception
(
KEY_SHARE_DOES_NOT_EXIST
,
"HASH DOES NOT EXIST IN DB"
);
if
(
csr_ptr
==
nullptr
)
{
throw
SGX
Exception
(
KEY_SHARE_DOES_NOT_EXIST
,
"HASH DOES NOT EXIST IN DB"
);
}
if
(
status
==
0
)
{
...
...
@@ -86,7 +86,7 @@ Json::Value signByHashImpl(const string& hash, int status){
outfile
.
close
();
if
(
access
(
csr_name
.
c_str
(),
F_OK
)
!=
0
)
{
LevelDB
::
getCsrDb
()
->
deleteKey
(
csr_db_key
);
throw
RPC
Exception
(
FILE_NOT_FOUND
,
"Csr does not exist"
);
throw
SGX
Exception
(
FILE_NOT_FOUND
,
"Csr does not exist"
);
}
string
signClientCert
=
"cd sgx_data/cert && ./create_client_cert "
+
hash
;
...
...
@@ -99,7 +99,7 @@ Json::Value signByHashImpl(const string& hash, int status){
string
status_db_key
=
"CSR:HASH:"
+
hash
+
"STATUS:"
;
LevelDB
::
getCsrStatusDb
()
->
deleteKey
(
status_db_key
);
LevelDB
::
getCsrStatusDb
()
->
writeDataUnique
(
status_db_key
,
"-1"
);
throw
RPC
Exception
(
FAIL_TO_CREATE_CERTIFICATE
,
"CLIENT CERTIFICATE GENERATION FAILED"
);
throw
SGX
Exception
(
FAIL_TO_CREATE_CERTIFICATE
,
"CLIENT CERTIFICATE GENERATION FAILED"
);
//exit(-1);
}
}
...
...
@@ -111,7 +111,7 @@ Json::Value signByHashImpl(const string& hash, int status){
result
[
"status"
]
=
status
;
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -121,26 +121,25 @@ Json::Value signByHashImpl(const string& hash, int status){
}
Json
::
Value
CSRManagerServer
::
getUnsignedCSRs
(){
Json
::
Value
CSRManagerServer
::
getUnsignedCSRs
()
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
getUnsignedCSRsImpl
();
}
Json
::
Value
CSRManagerServer
::
signByHash
(
const
string
&
hash
,
int
status
)
{
Json
::
Value
CSRManagerServer
::
signByHash
(
const
string
&
hash
,
int
status
)
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
signByHashImpl
(
hash
,
status
);
}
int
init_csrmanager_server
(){
int
init_csrmanager_server
()
{
hs3
=
new
jsonrpc
::
HttpServer
(
BASE_PORT
+
2
);
hs3
->
BindLocalhost
();
hs3
->
BindLocalhost
();
cs
=
new
CSRManagerServer
(
*
hs3
,
JSONRPC_SERVER_V2
);
// server (json-rpc 2.0)
if
(
!
cs
->
StartListening
())
{
spdlog
::
info
(
"CSR manager server could not start listening"
);
exit
(
-
1
);
}
else
{
}
else
{
spdlog
::
info
(
"CSR manager server started on port {}"
,
BASE_PORT
+
2
);
}
return
0
;
...
...
DKGCrypto.cpp
View file @
90d7eaba
...
...
@@ -28,7 +28,7 @@
#include <memory>
#include "SGXWalletServer.hpp"
#include "
RPC
Exception.h"
#include "
SGX
Exception.h"
//#include <libBLS/libff/libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>
#include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>
...
...
@@ -88,7 +88,7 @@ string gen_dkg_poly(int _t) {
else
status
=
gen_dkg_secret_aes
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
_t
);
if
(
err_status
!=
0
)
{
throw
RPC
Exception
(
-
666
,
errMsg
.
data
());
throw
SGX
Exception
(
-
666
,
errMsg
.
data
());
}
spdlog
::
debug
(
"gen_dkg_secret, status {}"
,
err_status
,
" err msg "
,
errMsg
.
data
());
...
...
@@ -127,7 +127,7 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n
vector
<
uint8_t
>
encrDKGPoly
(
2
*
BUF_LEN
,
0
);
if
(
!
hex2carray2
(
encryptedPolyHex
,
&
encLen
,
encrDKGPoly
.
data
(),
6100
))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
}
...
...
@@ -144,7 +144,7 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n
status
=
get_public_shares_aes
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encrDKGPoly
.
data
(),
encLen
,
pubShares
.
data
(),
t
,
n
);
}
if
(
errStatus
!=
0
)
{
throw
RPC
Exception
(
-
666
,
errMsg1
.
data
());
throw
SGX
Exception
(
-
666
,
errMsg1
.
data
());
}
...
...
@@ -176,7 +176,7 @@ string get_secret_shares(const string &_polyName, const char *_encryptedPolyHex,
vector
<
uint8_t
>
encrDKGPoly
(
BUF_LEN
,
0
);
if
(
!
hex2carray2
(
_encryptedPolyHex
,
&
encLen
,
encrDKGPoly
.
data
(),
6100
))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
}
...
...
@@ -187,7 +187,7 @@ string get_secret_shares(const string &_polyName, const char *_encryptedPolyHex,
status
=
set_encrypted_dkg_poly_aes
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encrDKGPoly
.
data
(),
&
encLen
);
if
(
status
!=
SGX_SUCCESS
||
errStatus
!=
0
)
{
throw
RPC
Exception
(
-
666
,
errMsg1
.
data
());
throw
SGX
Exception
(
-
666
,
errMsg1
.
data
());
}
string
result
;
...
...
@@ -215,7 +215,7 @@ string get_secret_shares(const string &_polyName, const char *_encryptedPolyHex,
get_encr_sshare_aes
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encryptedSkey
.
data
(),
&
decLen
,
currentShare
.
data
(),
sShareG2
.
data
(),
pubKeyB
.
data
(),
_t
,
_n
,
i
+
1
);
if
(
errStatus
!=
0
)
{
throw
RPC
Exception
(
-
666
,
errMsg1
.
data
());
throw
SGX
Exception
(
-
666
,
errMsg1
.
data
());
}
spdlog
::
debug
(
"cur_share is {}"
,
currentShare
.
data
());
...
...
@@ -253,7 +253,7 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
uint8_t
encr_key
[
BUF_LEN
];
memset
(
encr_key
,
0
,
BUF_LEN
);
if
(
!
hex2carray
(
encryptedKeyHex
,
&
dec_key_len
,
encr_key
))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
}
int
result
;
...
...
@@ -270,7 +270,7 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
dkg_verification_aes
(
eid
,
&
err_status
,
errMsg1
,
pshares
,
encr_sshare
,
encr_key
,
dec_key_len
,
t
,
ind
,
&
result
);
if
(
result
==
2
)
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid public shares"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid public shares"
);
}
spdlog
::
debug
(
"errMsg1: {}"
,
errMsg1
);
...
...
@@ -295,7 +295,7 @@ bool CreateBLSShare(const string &blsKeyName, const char *s_shares, const char *
uint8_t
encr_key
[
BUF_LEN
];
memset
(
encr_key
,
0
,
BUF_LEN
);
if
(
!
hex2carray
(
encryptedKeyHex
,
&
dec_key_len
,
encr_key
))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
}
uint32_t
enc_bls_len
=
0
;
...
...
@@ -310,7 +310,7 @@ bool CreateBLSShare(const string &blsKeyName, const char *s_shares, const char *
spdlog
::
error
(
errMsg1
);
spdlog
::
error
(
"status {}"
,
err_status
);
throw
RPC
Exception
(
ERROR_IN_ENCLAVE
,
"Create BLS private key failed in enclave"
);
throw
SGX
Exception
(
ERROR_IN_ENCLAVE
,
"Create BLS private key failed in enclave"
);
}
else
{
char
hexBLSKey
[
2
*
BUF_LEN
];
...
...
@@ -334,7 +334,7 @@ vector<string> GetBLSPubKey(const char *encryptedKeyHex) {
uint64_t
dec_key_len
;
uint8_t
encr_key
[
BUF_LEN
];
if
(
!
hex2carray
(
encryptedKeyHex
,
&
dec_key_len
,
encr_key
))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
}
char
pub_key
[
320
];
...
...
@@ -346,7 +346,7 @@ vector<string> GetBLSPubKey(const char *encryptedKeyHex) {
get_bls_pub_key_aes
(
eid
,
&
err_status
,
errMsg1
,
encr_key
,
dec_key_len
,
pub_key
);
if
(
err_status
!=
0
)
{
spdlog
::
error
(
string
(
errMsg1
)
+
" . Status is {}"
,
err_status
);
throw
RPC
Exception
(
ERROR_IN_ENCLAVE
,
"Failed to get BLS public key in enclave"
);
throw
SGX
Exception
(
ERROR_IN_ENCLAVE
,
"Failed to get BLS public key in enclave"
);
}
vector
<
string
>
pub_key_vect
=
splitString
(
pub_key
,
':'
);
...
...
@@ -373,7 +373,7 @@ string decrypt_DHKey(const string &polyName, int ind) {
uint64_t
DH_enc_len
=
0
;
uint8_t
encrypted_DHkey
[
BUF_LEN
];
if
(
!
hex2carray
(
hexEncrKey_ptr
->
c_str
(),
&
DH_enc_len
,
encrypted_DHkey
))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid hexEncrKey"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid hexEncrKey"
);
}
spdlog
::
debug
(
"encr DH key length is {}"
,
DH_enc_len
);
spdlog
::
debug
(
"hex encr DH key length is {}"
,
hexEncrKey_ptr
->
length
());
...
...
@@ -386,7 +386,7 @@ string decrypt_DHKey(const string &polyName, int ind) {
else
decrypt_key_aes
(
eid
,
&
err_status
,
errMsg1
.
data
(),
encrypted_DHkey
,
DH_enc_len
,
DHKey
);
if
(
err_status
!=
0
)
{
throw
RPC
Exception
(
/*ERROR_IN_ENCLAVE*/
err_status
,
"decrypt key failed in enclave"
);
throw
SGX
Exception
(
/*ERROR_IN_ENCLAVE*/
err_status
,
"decrypt key failed in enclave"
);
}
return
DHKey
;
...
...
ECDSACrypto.cpp
View file @
90d7eaba
...
...
@@ -25,7 +25,7 @@
#include "BLSCrypto.h"
#include "sgxwallet.h"
#include "
RPC
Exception.h"
#include "
SGX
Exception.h"
#include <iostream>
#include <gmp.h>
...
...
@@ -58,7 +58,7 @@ std::vector<std::string> genECDSAKey() {
if
(
status
!=
SGX_SUCCESS
||
err_status
!=
0
)
{
spdlog
::
error
(
"RPCException thrown with status {}"
,
status
);
throw
RPC
Exception
(
status
,
errMsg
);
throw
SGX
Exception
(
status
,
errMsg
);
}
std
::
vector
<
std
::
string
>
keys
(
3
);
...
...
@@ -110,7 +110,7 @@ std::string getECDSAPubKey(const char *_encryptedKeyHex) {
uint64_t
enc_len
=
0
;
if
(
!
hex2carray
(
_encryptedKeyHex
,
&
enc_len
,
encrPrKey
.
data
()))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
}
if
(
!
encryptKeys
)
...
...
@@ -119,7 +119,7 @@ std::string getECDSAPubKey(const char *_encryptedKeyHex) {
else
status
=
get_public_ecdsa_key_aes
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrPrKey
.
data
(),
enc_len
,
pubKeyX
.
data
(),
pubKeyY
.
data
());
if
(
err_status
!=
0
)
{
throw
RPC
Exception
(
-
666
,
errMsg
.
data
());
throw
SGX
Exception
(
-
666
,
errMsg
.
data
());
}
string
pubKey
=
string
(
pubKeyX
.
data
())
+
string
(
pubKeyY
.
data
());
//concatPubKeyWith0x(pub_key_x, pub_key_y);//
...
...
@@ -146,7 +146,7 @@ vector<string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, i
//uint8_t encr_key[BUF_LEN];
uint8_t
*
encr_key
=
(
uint8_t
*
)
calloc
(
1024
,
1
);
if
(
!
hex2carray
(
encryptedKeyHex
,
&
dec_len
,
encr_key
))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
}
...
...
@@ -162,7 +162,7 @@ vector<string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, i
status
=
ecdsa_sign_aes
(
eid
,
&
err_status
,
errMsg
,
encr_key
,
dec_len
,
(
unsigned
char
*
)
hashHex
,
signature_r
,
signature_s
,
&
signature_v
,
base
);
if
(
err_status
!=
0
)
{
throw
RPC
Exception
(
-
666
,
errMsg
);
throw
SGX
Exception
(
-
666
,
errMsg
);
}
...
...
LevelDB.cpp
View file @
90d7eaba
...
...
@@ -31,7 +31,7 @@
#include "leveldb/db.h"
#include "sgxwallet_common.h"
#include "
RPC
Exception.h"
#include "
SGX
Exception.h"
#include "LevelDB.h"
#include "ServerInit.h"
...
...
@@ -57,7 +57,7 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
auto
result
=
std
::
make_shared
<
string
>
();
if
(
db
==
nullptr
)
{
throw
RPC
Exception
(
NULL_DATABASE
,
"Null db"
);
throw
SGX
Exception
(
NULL_DATABASE
,
"Null db"
);
}
auto
status
=
db
->
Get
(
readOptions
,
_key
,
&*
result
);
...
...
@@ -163,7 +163,7 @@ void LevelDB::throwExceptionOnError(Status _status) {
return
;
if
(
!
_status
.
ok
())
{
throw
RPC
Exception
(
COULD_NOT_ACCESS_DATABASE
,
(
"Could not access database database:"
+
_status
.
ToString
()).
c_str
());
throw
SGX
Exception
(
COULD_NOT_ACCESS_DATABASE
,
(
"Could not access database database:"
+
_status
.
ToString
()).
c_str
());
}
}
...
...
@@ -213,7 +213,7 @@ void LevelDB::writeDataUnique(const string & Name, const string &value) {
if
(
readString
(
Name
)
!=
nullptr
)
{
spdlog
::
debug
(
"name {}"
,
Name
,
" already exists"
);
// std::cerr << "name " << Name << " already exists" << std::endl;
throw
RPC
Exception
(
KEY_SHARE_ALREADY_EXISTS
,
"Data with this name already exists"
);
throw
SGX
Exception
(
KEY_SHARE_ALREADY_EXISTS
,
"Data with this name already exists"
);
}
writeString
(
key
,
value
);
...
...
RPCException.cpp
View file @
90d7eaba
...
...
@@ -21,4 +21,4 @@
@date 2019
*/
#include "
RPC
Exception.h"
#include "
SGX
Exception.h"
SEKManager.cpp
View file @
90d7eaba
...
...
@@ -22,7 +22,7 @@
*/
#include "SEKManager.h"
#include "
RPC
Exception.h"
#include "
SGX
Exception.h"
#include "BLSCrypto.h"
#include "LevelDB.h"
...
...
@@ -56,7 +56,7 @@ void create_test_key(){
status
=
encrypt_key_aes
(
eid
,
&
errStatus
,
errMsg
.
data
(),
key
.
c_str
(),
encrypted_key
,
&
enc_len
);
if
(
status
!=
0
){
std
::
cerr
<<
"encrypt test key failed with status "
<<
status
<<
std
::
endl
;
throw
RPC
Exception
(
status
,
errMsg
.
data
())
;
throw
SGX
Exception
(
status
,
errMsg
.
data
())
;
}
//std::cerr << "enc len is " << enc_len << std::endl;
...
...
@@ -101,7 +101,7 @@ bool check_SEK(std::string SEK){
status
=
set_SEK_backup
(
eid
,
&
err_status
,
errMsg
.
data
(),
encr_SEK
.
data
(),
&
l
,
SEK
.
c_str
()
);
if
(
status
!=
SGX_SUCCESS
){
cerr
<<
"RPCException thrown with status "
<<
status
<<
endl
;
throw
RPC
Exception
(
status
,
errMsg
.
data
());
throw
SGX
Exception
(
status
,
errMsg
.
data
());
}
status
=
decrypt_key_aes
(
eid
,
&
err_status
,
errMsg
.
data
(),
encr_test_key
.
data
(),
len
,
decr_key
.
data
());
...
...
@@ -135,7 +135,7 @@ void gen_SEK(){
status
=
generate_SEK
(
eid
,
&
err_status
,
errMsg
.
data
(),
encr_SEK
.
data
(),
&
enc_len
,
SEK
);
if
(
status
!=
SGX_SUCCESS
||
err_status
!=
0
){
throw
RPC
Exception
(
status
,
errMsg
.
data
())
;
throw
SGX
Exception
(
status
,
errMsg
.
data
())
;
}
vector
<
char
>
hexEncrKey
(
2
*
enc_len
+
1
,
0
);
...
...
@@ -175,13 +175,13 @@ void set_SEK(std::shared_ptr<std::string> hex_encr_SEK){
uint64_t
len
;
if
(
!
hex2carray
(
hex_encr_SEK
->
c_str
(),
&
len
,
encr_SEK
)){
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid encrypted SEK Hex"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid encrypted SEK Hex"
);
}
status
=
set_SEK
(
eid
,
&
err_status
,
errMsg
.
data
(),
encr_SEK
,
len
);
if
(
status
!=
SGX_SUCCESS
||
err_status
!=
0
){
cerr
<<
"RPCException thrown"
<<
endl
;
throw
RPC
Exception
(
status
,
errMsg
.
data
())
;
throw
SGX
Exception
(
status
,
errMsg
.
data
())
;
}
}
...
...
@@ -213,7 +213,7 @@ void enter_SEK(){
status
=
set_SEK_backup
(
eid
,
&
err_status
,
errMsg
.
data
(),
encr_SEK
.
data
(),
&
enc_len
,
SEK
.
c_str
()
);
if
(
status
!=
SGX_SUCCESS
){
cerr
<<
"RPCException thrown with status "
<<
status
<<
endl
;
throw
RPC
Exception
(
status
,
errMsg
.
data
());
throw
SGX
Exception
(
status
,
errMsg
.
data
());
}
vector
<
char
>
hexEncrKey
(
2
*
enc_len
+
1
,
0
);
...
...
RPC
Exception.h
→
SGX
Exception.h
View file @
90d7eaba
...
...
@@ -28,14 +28,14 @@
#include <string>
#include <exception>
class
RPC
Exception
:
public
std
::
exception
{
class
SGX
Exception
:
public
std
::
exception
{
public
:
int32_t
status
;
std
::
string
errString
;
RPC
Exception
(
int32_t
_status
,
const
char
*
_errString
)
:
status
(
_status
),
errString
(
_errString
)
{}
SGX
Exception
(
int32_t
_status
,
const
char
*
_errString
)
:
status
(
_status
),
errString
(
_errString
)
{}
};
...
...
SGXRegistrationServer.cpp
View file @
90d7eaba
...
...
@@ -32,7 +32,7 @@
#include "sgxwallet_common.h"
#include "
RPC
Exception.h"
#include "
SGX
Exception.h"
#include "LevelDB.h"
#include <thread>
...
...
@@ -79,7 +79,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
outfile
<<
_csr
<<
endl
;
outfile
.
close
();
if
(
access
(
csr_name
.
c_str
(),
F_OK
)
!=
0
)
{
throw
RPC
Exception
(
FILE_NOT_FOUND
,
"Csr does not exist"
);
throw
SGX
Exception
(
FILE_NOT_FOUND
,
"Csr does not exist"
);
}
string
genCert
=
"cd cert && ./create_client_cert "
+
hash
;
...
...
@@ -91,7 +91,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
spdlog
::
info
(
"CLIENT CERTIFICATE GENERATION FAILED"
);
string
status_db_key
=
"CSR:HASH:"
+
hash
+
"STATUS:"
;
LevelDB
::
getCsrStatusDb
()
->
writeDataUnique
(
status_db_key
,
to_string
(
FAIL_TO_CREATE_CERTIFICATE
));
throw
RPC
Exception
(
FAIL_TO_CREATE_CERTIFICATE
,
"CLIENT CERTIFICATE GENERATION FAILED"
);
throw
SGX
Exception
(
FAIL_TO_CREATE_CERTIFICATE
,
"CLIENT CERTIFICATE GENERATION FAILED"
);
//exit(-1);
}
}
...
...
@@ -102,7 +102,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
string
db_key
=
"CSR:HASH:"
+
hash
+
"STATUS:"
;
LevelDB
::
getCsrStatusDb
()
->
writeDataUnique
(
db_key
,
status
);
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -120,7 +120,7 @@ Json::Value GetSertificateImpl(const string &hash) {
string
db_key
=
"CSR:HASH:"
+
hash
+
"STATUS:"
;
shared_ptr
<
string
>
status_str_ptr
=
LevelDB
::
getCsrStatusDb
()
->
readString
(
db_key
);
if
(
status_str_ptr
==
nullptr
)
{
throw
RPC
Exception
(
KEY_SHARE_DOES_NOT_EXIST
,
"Data with this name does not exist in csr db"
);
throw
SGX
Exception
(
KEY_SHARE_DOES_NOT_EXIST
,
"Data with this name does not exist in csr db"
);
}
int
status
=
atoi
(
status_str_ptr
->
c_str
());
...
...
@@ -132,7 +132,7 @@ Json::Value GetSertificateImpl(const string &hash) {
string
status_db_key
=
"CSR:HASH:"
+
hash
+
"STATUS:"
;
LevelDB
::
getCsrStatusDb
()
->
deleteKey
(
status_db_key
);
LevelDB
::
getCsrStatusDb
()
->
writeDataUnique
(
status_db_key
,
to_string
(
FILE_NOT_FOUND
));
throw
RPC
Exception
(
FILE_NOT_FOUND
,
"Certificate does not exist"
);
throw
SGX
Exception
(
FILE_NOT_FOUND
,
"Certificate does not exist"
);
}
else
{
ostringstream
ss
;
ss
<<
infile
.
rdbuf
();
...
...
@@ -154,7 +154,7 @@ Json::Value GetSertificateImpl(const string &hash) {
result
[
"status"
]
=
status
;
result
[
"cert"
]
=
cert
;
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
SGXWalletServer.cpp
View file @
90d7eaba
...
...
@@ -23,7 +23,7 @@
#include "sgxwallet_common.h"
#include "
RPC
Exception.h"
#include "
SGX
Exception.h"
#include "LevelDB.h"
#include "BLSCrypto.h"
#include "ECDSACrypto.h"
...
...
@@ -45,21 +45,25 @@
#include "common.h"
void
setFullOptions
(
int
_printDebugInfo
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_encryptKeys
)
{
void
setFullOptions
(
int
_printDebugInfo
,
int
_printTraceInfo
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_encryptKeys
)
{
if
(
_printDebugInfo
)
spdlog
::
set_level
(
spdlog
::
level
::
debug
);
else
{
else
if
(
_printTraceInfo
)
{
spdlog
::
set_level
(
spdlog
::
level
::
trace
);
}
else
if
(
_printTraceInfo
)
{
spdlog
::
set_level
(
spdlog
::
level
::
info
);
}
printDebugInfo
=
_printDebugInfo
;
useHTTPS
=
_useHTTPS
;
autoconfirm
=
_autoconfirm
;
encryptKeys
=
_encryptKeys
;
}
void
setOptions
(
int
_printDebugInfo
,
int
_useHTTPS
,
int
_autoconfirm
)
{
setFullOptions
(
_printDebugInfo
,
_useHTTPS
,
_autoconfirm
,
false
);
void
setOptions
(
int
_printDebugInfo
,
int
_printTraceInfo
,
int
_useHTTPS
,
int
_autoconfirm
)
{
setFullOptions
(
_printDebugInfo
,
_printTraceInfo
,
_useHTTPS
,
_autoconfirm
,
false
);
}
...
...
@@ -171,18 +175,18 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
encryptedKeyShareHex
=
encryptBLSKeyShare2Hex
(
&
errStatus
,
errMsg
,
_keyShare
.
c_str
());
if
(
encryptedKeyShareHex
==
nullptr
)
{
throw
RPC
Exception
(
UNKNOWN_ERROR
,
""
);
throw
SGX
Exception
(
UNKNOWN_ERROR
,
""
);
}
if
(
errStatus
!=
0
)
{
throw
RPC
Exception
(
errStatus
,
errMsg
);
throw
SGX
Exception
(
errStatus
,
errMsg
);
}
result
[
"encryptedKeyShare"
]
=
string
(
encryptedKeyShareHex
);
writeKeyShare
(
_keyShareName
,
encryptedKeyShareHex
,
_index
,
n
,
t
);
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
...
...
@@ -195,7 +199,8 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
}
Json
::
Value
SGXWalletServer
::
blsSignMessageHashImpl
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
t
,
int
n
,
int
_signerIndex
)
{
SGXWalletServer
::
blsSignMessageHashImpl
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
t
,
int
n
,
int
_signerIndex
)
{
Json
::
Value
result
;
result
[
"status"
]
=
-
1
;
result
[
"errorMessage"
]
=
"Unknown server error"
;
...
...
@@ -207,7 +212,7 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
try
{
if
(
!
checkName
(
_keyShareName
,
"BLS_KEY"
))
{
throw
RPC
Exception
(
INVALID_POLY_NAME
,
"Invalid BLSKey name"
);
throw
SGX
Exception
(
INVALID_POLY_NAME
,
"Invalid BLSKey name"
);
}
string
cutHash
=
_messageHash
;
if
(
cutHash
[
0
]
==
'0'
&&
(
cutHash
[
1
]
==
'x'
||
cutHash
[
1
]
==
'X'
))
{
...
...
@@ -218,11 +223,11 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
}
if
(
!
checkHex
(
cutHash
))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid hash"
);
}
value
=
readFromDb
(
_keyShareName
);
}
catch
(
RPC
Exception
_e
)
{
}
catch
(
SGX
Exception
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
return
result
;
...
...
@@ -276,7 +281,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
keys
=
genECDSAKey
();
if
(
keys
.
size
()
==
0
)
{
throw
RPC
Exception
(
UNKNOWN_ERROR
,
"key was not generated"
);
throw
SGX
Exception
(
UNKNOWN_ERROR
,
"key was not generated"
);
}
string
keyName
=
"NEK:"
+
keys
.
at
(
2
);
...
...
@@ -291,7 +296,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
result
[
"PublicKey"
]
=
keys
.
at
(
1
);
result
[
"keyName"
]
=
keyName
;
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -310,15 +315,15 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
string
prefix
=
_tempKeyName
.
substr
(
0
,
8
);
if
(
prefix
!=
"tmp_NEK:"
)
{
throw
RPC
Exception
(
UNKNOWN_ERROR
,
"invalid temp key name"
);
throw
SGX
Exception
(
UNKNOWN_ERROR
,
"invalid temp key name"
);
}
prefix
=
_keyName
.
substr
(
0
,
12
);
if
(
prefix
!=
"NEK_NODE_ID:"
)
{
throw
RPC
Exception
(
UNKNOWN_ERROR
,
"invalid key name"
);
throw
SGX
Exception
(
UNKNOWN_ERROR
,
"invalid key name"
);
}
string
postfix
=
_keyName
.
substr
(
12
,
_keyName
.
length
());
if
(
!
isStringDec
(
postfix
))
{
throw
RPC
Exception
(
UNKNOWN_ERROR
,
"invalid key name"
);
throw
SGX
Exception
(
UNKNOWN_ERROR
,
"invalid key name"
);
}
shared_ptr
<
string
>
key_ptr
=
readFromDb
(
_tempKeyName
);
...
...
@@ -326,7 +331,7 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
writeDataToDB
(
_keyName
,
*
key_ptr
);
LevelDB
::
getLevelDb
()
->
deleteTempNEK
(
_tempKeyName
);
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -357,20 +362,20 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
}
if
(
!
checkECDSAKeyName
(
_keyName
))
{
throw
RPC
Exception
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
throw
SGX
Exception
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
}
if
(
!
checkHex
(
cutHash
))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid hash"
);
}
if
(
_base
<=
0
||
_base
>
32
)
{
throw
RPC
Exception
(
-
22
,
"Invalid base"
);
throw
SGX
Exception
(
-
22
,
"Invalid base"
);
}
shared_ptr
<
string
>
key_ptr
=
readFromDb
(
_keyName
,
""
);
sign_vect
=
ecdsaSignHash
(
key_ptr
->
c_str
(),
cutHash
.
c_str
(),
_base
);
if
(
sign_vect
.
size
()
!=
3
)
{
throw
RPC
Exception
(
INVALID_ECSDA_SIGNATURE
,
"Invalid ecdsa signature"
);
throw
SGX
Exception
(
INVALID_ECSDA_SIGNATURE
,
"Invalid ecdsa signature"
);
}
spdlog
::
debug
(
"got signature_s {}"
,
sign_vect
.
at
(
2
));
...
...
@@ -379,7 +384,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
result
[
"signature_r"
]
=
sign_vect
.
at
(
1
);
result
[
"signature_s"
]
=
sign_vect
.
at
(
2
);
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
"err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -399,7 +404,7 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
try
{
if
(
!
checkECDSAKeyName
(
_keyName
))
{
throw
RPC
Exception
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
throw
SGX
Exception
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
}
shared_ptr
<
string
>
keyStr
=
readFromDb
(
_keyName
);
publicKey
=
getECDSAPubKey
(
keyStr
->
c_str
());
...
...
@@ -409,7 +414,7 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
result
[
"PublicKey"
]
=
publicKey
;
result
[
"publicKey"
]
=
publicKey
;
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
...
...
@@ -428,17 +433,17 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t
try
{
if
(
!
checkName
(
_polyName
,
"POLY"
))
{
throw
RPC
Exception
(
INVALID_POLY_NAME
,
throw
SGX
Exception
(
INVALID_POLY_NAME
,
"Invalid polynomial name, it should be like POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1"
);
}
if
(
_t
<=
0
||
_t
>
32
)
{
throw
RPC
Exception
(
INVALID_DKG_PARAMS
,
"Invalid parameter t "
);
throw
SGX
Exception
(
INVALID_DKG_PARAMS
,
"Invalid parameter t "
);
}
encrPolyHex
=
gen_dkg_poly
(
_t
);
writeDataToDB
(
_polyName
,
encrPolyHex
);
//result["encryptedPoly"] = encrPolyHex;
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -456,10 +461,10 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
vector
<
vector
<
string
>>
verifVector
;
try
{
if
(
!
checkName
(
_polyName
,
"POLY"
))
{
throw
RPC
Exception
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
throw
SGX
Exception
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
if
(
!
check_n_t
(
_t
,
_n
))
{
throw
RPC
Exception
(
INVALID_DKG_PARAMS
,
"Invalid parameters: n or t "
);
throw
SGX
Exception
(
INVALID_DKG_PARAMS
,
"Invalid parameters: n or t "
);
}
shared_ptr
<
string
>
encr_poly_ptr
=
readFromDb
(
_polyName
);
...
...
@@ -475,7 +480,7 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
}
}
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -493,13 +498,13 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
try
{
if
(
_pubKeys
.
size
()
!=
(
uint64_t
)
_n
)
{
throw
RPC
Exception
(
INVALID_DKG_PARAMS
,
"invalid number of public keys"
);
throw
SGX
Exception
(
INVALID_DKG_PARAMS
,
"invalid number of public keys"
);
}
if
(
!
checkName
(
_polyName
,
"POLY"
))
{
throw
RPC
Exception
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
throw
SGX
Exception
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
if
(
!
check_n_t
(
_t
,
_n
))
{
throw
RPC
Exception
(
INVALID_DKG_PARAMS
,
"Invalid DKG parameters: n or t "
);
throw
SGX
Exception
(
INVALID_DKG_PARAMS
,
"Invalid DKG parameters: n or t "
);
}
shared_ptr
<
string
>
encr_poly_ptr
=
readFromDb
(
_polyName
);
...
...
@@ -507,7 +512,7 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
vector
<
string
>
pubKeysStrs
;
for
(
int
i
=
0
;
i
<
_n
;
i
++
)
{
if
(
!
checkHex
(
_pubKeys
[
i
].
asString
(),
64
))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid public key"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid public key"
);
}
pubKeysStrs
.
push_back
(
_pubKeys
[
i
].
asString
());
}
...
...
@@ -516,7 +521,7 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
//cerr << "result is " << s << endl;
result
[
"secretShare"
]
=
s
;
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
//cerr << " err str " << _e.errString << endl;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -538,16 +543,16 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
try
{
if
(
!
checkECDSAKeyName
(
_ethKeyName
))
{
throw
RPC
Exception
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
throw
SGX
Exception
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
}
if
(
!
check_n_t
(
_t
,
_n
)
||
_index
>
_n
||
_index
<
0
)
{
throw
RPC
Exception
(
INVALID_DKG_PARAMS
,
"Invalid DKG parameters: n or t "
);
throw
SGX
Exception
(
INVALID_DKG_PARAMS
,
"Invalid DKG parameters: n or t "
);
}
if
(
!
checkHex
(
_secretShare
,
SECRET_SHARE_NUM_BYTES
))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid Secret share"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid Secret share"
);
}
if
(
_publicShares
.
length
()
!=
(
uint64_t
)
256
*
_t
)
{
throw
RPC
Exception
(
INVALID_DKG_PARAMS
,
"Invalid length of public shares"
);
throw
SGX
Exception
(
INVALID_DKG_PARAMS
,
"Invalid length of public shares"
);
}
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
_ethKeyName
);
...
...
@@ -556,7 +561,7 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
result
[
"result"
]
=
false
;
}
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
//cerr << " err str " << _e.errString << endl;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -566,7 +571,8 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
return
result
;
}
Json
::
Value
SGXWalletServer
::
createBLSPrivateKeyImpl
(
const
string
&
_blsKeyName
,
const
string
&
_ethKeyName
,
const
string
&
_polyName
,
Json
::
Value
SGXWalletServer
::
createBLSPrivateKeyImpl
(
const
string
&
_blsKeyName
,
const
string
&
_ethKeyName
,
const
string
&
_polyName
,
const
string
&
_secretShare
,
int
_t
,
int
_n
)
{
...
...
@@ -579,19 +585,19 @@ Json::Value SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName,
if
(
_secretShare
.
length
()
!=
(
uint64_t
)
_n
*
192
)
{
spdlog
::
error
(
"Invalid secret share length - {}"
,
_secretShare
.
length
());
spdlog
::
error
(
"Secret share - {}"
,
_secretShare
);
throw
RPC
Exception
(
INVALID_SECRET_SHARES_LENGTH
,
"Invalid secret share length"
);
throw
SGX
Exception
(
INVALID_SECRET_SHARES_LENGTH
,
"Invalid secret share length"
);
}
if
(
!
checkECDSAKeyName
(
_ethKeyName
))
{
throw
RPC
Exception
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
throw
SGX
Exception
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
}
if
(
!
checkName
(
_polyName
,
"POLY"
))
{
throw
RPC
Exception
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
throw
SGX
Exception
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
if
(
!
checkName
(
_blsKeyName
,
"BLS_KEY"
))
{
throw
RPC
Exception
(
INVALID_POLY_NAME
,
"Invalid BLS key name"
);
throw
SGX
Exception
(
INVALID_POLY_NAME
,
"Invalid BLS key name"
);
}
if
(
!
check_n_t
(
_t
,
_n
))
{
throw
RPC
Exception
(
INVALID_DKG_PARAMS
,
"Invalid DKG parameters: n or t "
);
throw
SGX
Exception
(
INVALID_DKG_PARAMS
,
"Invalid DKG parameters: n or t "
);
}
vector
<
string
>
sshares_vect
;
...
...
@@ -603,7 +609,7 @@ Json::Value SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName,
if
(
res
)
{
spdlog
::
info
(
"BLS KEY SHARE CREATED "
);
}
else
{
throw
RPC
Exception
(
-
122
,
"Error while creating BLS key share"
);
throw
SGX
Exception
(
-
122
,
"Error while creating BLS key share"
);
}
for
(
int
i
=
0
;
i
<
_n
;
i
++
)
{
...
...
@@ -613,7 +619,7 @@ Json::Value SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName,
LevelDB
::
getLevelDb
()
->
deleteKey
(
shareG2_name
);
}
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
//cerr << " err str " << _e.errString << endl;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -631,7 +637,7 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
try
{
if
(
!
checkName
(
_blsKeyName
,
"BLS_KEY"
))
{
throw
RPC
Exception
(
INVALID_POLY_NAME
,
"Invalid BLSKey name"
);
throw
SGX
Exception
(
INVALID_POLY_NAME
,
"Invalid BLSKey name"
);
}
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
_blsKeyName
);
spdlog
::
debug
(
"encr_bls_key_share is {}"
,
*
encryptedKeyHex_ptr
);
...
...
@@ -643,7 +649,7 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
result
[
"BlsPublicKeyShare"
][
i
]
=
public_key_vect
.
at
(
i
);
}
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -660,7 +666,7 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
result
[
"errorMessage"
]
=
""
;
try
{
if
(
!
checkName
(
_polyName
,
"POLY"
))
{
throw
RPC
Exception
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
throw
SGX
Exception
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
string
shareG2_name
=
"shareG2_"
+
_polyName
+
"_"
+
to_string
(
_ind
)
+
":"
;
shared_ptr
<
string
>
shareG2_ptr
=
readFromDb
(
shareG2_name
);
...
...
@@ -671,7 +677,7 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
result
[
"dhKey"
]
=
DHKey
;
result
[
"DHKey"
]
=
DHKey
;
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -691,7 +697,7 @@ Json::Value SGXWalletServer::multG2Impl(const string &_x) {
result
[
"x*G2"
][
i
]
=
xG2_vect
.
at
(
i
);
}
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -714,7 +720,7 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
}
}
catch
(
RPC
Exception
&
_e
)
{
}
catch
(
SGX
Exception
&
_e
)
{
std
::
cerr
<<
" err str "
<<
_e
.
errString
<<
std
::
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -751,7 +757,8 @@ Json::Value SGXWalletServer::getSecretShare(const string &_polyName, const Json:
}
Json
::
Value
SGXWalletServer
::
dkgVerification
(
const
string
&
_publicShares
,
const
string
&
ethKeyName
,
const
string
&
SecretShare
,
int
t
,
SGXWalletServer
::
dkgVerification
(
const
string
&
_publicShares
,
const
string
&
ethKeyName
,
const
string
&
SecretShare
,
int
t
,
int
n
,
int
index
)
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
dkgVerificationImpl
(
_publicShares
,
ethKeyName
,
SecretShare
,
t
,
n
,
index
);
...
...
@@ -836,7 +843,7 @@ shared_ptr<string> SGXWalletServer::readFromDb(const string &name, const string
auto
dataStr
=
LevelDB
::
getLevelDb
()
->
readString
(
prefix
+
name
);
if
(
dataStr
==
nullptr
)
{
throw
RPC
Exception
(
KEY_SHARE_DOES_NOT_EXIST
,
"Data with this name does not exist"
);
throw
SGX
Exception
(
KEY_SHARE_DOES_NOT_EXIST
,
"Data with this name does not exist"
);
}
return
dataStr
;
...
...
@@ -847,7 +854,7 @@ shared_ptr<string> SGXWalletServer::readKeyShare(const string &_keyShareName) {
auto
keyShareStr
=
LevelDB
::
getLevelDb
()
->
readString
(
"BLSKEYSHARE:"
+
_keyShareName
);
if
(
keyShareStr
==
nullptr
)
{
throw
RPC
Exception
(
KEY_SHARE_DOES_NOT_EXIST
,
"Key share with this name does not exist"
);
throw
SGX
Exception
(
KEY_SHARE_DOES_NOT_EXIST
,
"Key share with this name does not exist"
);
}
return
keyShareStr
;
...
...
@@ -869,7 +876,7 @@ void SGXWalletServer::writeKeyShare(const string &_keyShareName, const string &_
auto
key
=
"BLSKEYSHARE:"
+
_keyShareName
;
if
(
LevelDB
::
getLevelDb
()
->
readString
(
_keyShareName
)
!=
nullptr
)
{
throw
RPC
Exception
(
KEY_SHARE_ALREADY_EXISTS
,
"Key share with this name already exists"
);
throw
SGX
Exception
(
KEY_SHARE_ALREADY_EXISTS
,
"Key share with this name already exists"
);
}
LevelDB
::
getLevelDb
()
->
writeString
(
key
,
_value
);
...
...
@@ -886,7 +893,7 @@ void SGXWalletServer::writeDataToDB(const string &Name, const string &value) {
if
(
LevelDB
::
getLevelDb
()
->
readString
(
Name
)
!=
nullptr
)
{
spdlog
::
info
(
"name {}"
,
Name
,
" already exists"
);
throw
RPC
Exception
(
KEY_SHARE_ALREADY_EXISTS
,
"Key share already exists"
);
throw
SGX
Exception
(
KEY_SHARE_ALREADY_EXISTS
,
"Key share already exists"
);
}
LevelDB
::
getLevelDb
()
->
writeString
(
key
,
value
);
...
...
SGXWalletServer.h
View file @
90d7eaba
...
...
@@ -31,8 +31,10 @@
#endif
EXTERNC
void
setFullOptions
(
int
_printDebugInfo
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_encryptKeys
);
EXTERNC
void
setOptions
(
int
_printDebugInfo
,
int
_useHTTPS
,
int
_autoconfirm
);
EXTERNC
void
setFullOptions
(
int
_printDebugInfo
,
int
_printTraceInfo
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_encryptKeys
);
EXTERNC
void
setOptions
(
int
_printDebugInfo
,
int
_printTraceInfo
,
int
_useHTTPS
,
int
_autoconfirm
);
...
...
sgxwallet.c
View file @
90d7eaba
...
...
@@ -59,6 +59,8 @@ void printUsage() {
fprintf
(
stderr
,
"-c do not verify client certificate
\n
"
);
fprintf
(
stderr
,
"-s sign client certificate without human confirmation
\n
"
);
fprintf
(
stderr
,
"-d turn on debug output
\n
"
);
fprintf
(
stderr
,
"-v verbose mode: turn on debug output
\n
"
);
fprintf
(
stderr
,
"-vv detailed verbose mode: turn on debug and trace outputs
\n
"
);
fprintf
(
stderr
,
"-0 launch SGXWalletServer using http (not https)
\n
"
);
fprintf
(
stderr
,
"-b Restore from back up (you will need to enter backup key)
\n
"
);
fprintf
(
stderr
,
"-y Do not ask user to acknoledge receipt of backup key
\n
"
);
...
...
@@ -69,6 +71,7 @@ int main(int argc, char *argv[]) {
bool
encryptKeysOption
=
false
;
bool
useHTTPSOption
=
true
;
bool
printDebugInfoOption
=
false
;
bool
printTraceInfoOption
=
false
;
bool
autoconfirmOption
=
false
;
bool
checkClientCertOption
=
true
;
bool
autoSignClientCertOption
=
false
;
...
...
@@ -83,17 +86,11 @@ int main(int argc, char *argv[]) {
while
((
opt
=
getopt
(
argc
,
argv
,
"cshd0aby"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"cshd0aby
vV
"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'h'
:
if
(
strlen
(
argv
[
1
])
==
2
)
{
printUsage
();
exit
(
0
);
}
else
{
fprintf
(
stderr
,
"unknown flag %s
\n
"
,
argv
[
1
]);
printUsage
();
exit
(
1
);
}
case
'c'
:
checkClientCertOption
=
false
;
break
;
...
...
@@ -103,6 +100,13 @@ int main(int argc, char *argv[]) {
case
'd'
:
printDebugInfoOption
=
true
;
break
;
case
'v'
:
printDebugInfoOption
=
true
;
break
;
case
'V'
:
printDebugInfoOption
=
true
;
printTraceInfoOption
=
true
;
break
;
case
'0'
:
useHTTPSOption
=
false
;
break
;
...
...
@@ -115,15 +119,14 @@ int main(int argc, char *argv[]) {
case
'y'
:
autoconfirmOption
=
true
;
break
;
case
'?'
:
default
:
printUsage
();
exit
(
1
);
default:
break
;
}
}
setFullOptions
(
printDebugInfoOption
,
useHTTPSOption
,
autoconfirmOption
,
encryptKeysOption
);
setFullOptions
(
printDebugInfoOption
,
printTraceInfoOption
,
useHTTPSOption
,
autoconfirmOption
,
encryptKeysOption
);
initAll
(
checkClientCertOption
,
autoSignClientCertOption
);
...
...
sgxwallet_common.h
View file @
90d7eaba
...
...
@@ -35,7 +35,7 @@
extern
int
printDebugInfo
;
extern
int
useHTTPS
;
extern
int
encryptKeys
;
extern
int
autoconfirm
;
...
...
testw.cpp
View file @
90d7eaba
...
...
@@ -52,7 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BLSCrypto.h"
#include "ServerInit.h"
#include "DKGCrypto.h"
#include "
RPC
Exception.h"
#include "
SGX
Exception.h"
#include "LevelDB.h"
#include "SGXWalletServer.hpp"
...
...
@@ -134,7 +134,7 @@ void destroyEnclave() {
TEST_CASE
(
"BLS key encrypt"
,
"[bls-key-encrypt]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
auto
key
=
encryptTestKey
();
REQUIRE
(
key
!=
nullptr
);
...
...
@@ -143,7 +143,7 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
/* Do later
TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false,
false,
true);
initAll(false, true);
//init_enclave();
...
...
@@ -175,7 +175,7 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
TEST_CASE
(
"DKG gen test"
,
"[dkg-gen]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
...
...
@@ -263,7 +263,7 @@ libff::alt_bn128_G2 VectStringToG2(const vector<string> &G2_str_vect) {
TEST_CASE
(
"DKG public shares test"
,
"[dkg-pub-shares]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
...
...
@@ -338,7 +338,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub-shares]") {
TEST_CASE
(
"DKG encrypted secret shares test"
,
"[dkg-encr-sshares]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
...
...
@@ -375,7 +375,7 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr-sshares]") {
TEST_CASE
(
"DKG verification test"
,
"[dkg-verify]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
...
...
@@ -416,7 +416,7 @@ TEST_CASE("DKG verification test", "[dkg-verify]") {
TEST_CASE
(
"ECDSA keygen and signature test"
,
"[ecdsa]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
...
...
@@ -460,7 +460,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") {
TEST_CASE
(
"Test test"
,
"[test]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
...
...
@@ -482,7 +482,7 @@ TEST_CASE("Test test", "[test]") {
TEST_CASE
(
"get public ECDSA key"
,
"[get-pub-ecdsa-key]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
int
errStatus
=
0
;
...
...
@@ -550,7 +550,7 @@ string ConvertDecToHex(string dec, int numBytes = 32) {
TEST_CASE
(
"BLS_DKG test"
,
"[bls-dkg]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
HttpClient
client
(
"http://localhost:1029"
);
...
...
@@ -636,7 +636,7 @@ TEST_CASE("BLS_DKG test", "[bls-dkg]") {
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
()))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid hash"
);
}
...
...
@@ -678,7 +678,7 @@ TEST_CASE("BLS_DKG test", "[bls-dkg]") {
}
TEST_CASE
(
"API test"
,
"[api]"
)
{
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
//HttpServer httpserver(1025);
...
...
@@ -733,7 +733,7 @@ TEST_CASE("API test", "[api]") {
TEST_CASE
(
"getServerStatus test"
,
"[get-server-status]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
...
...
@@ -806,7 +806,7 @@ void SendRPCRequest() {
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
()))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid hash"
);
}
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
koefs_pkeys_map
;
...
...
@@ -839,7 +839,7 @@ void SendRPCRequest() {
TEST_CASE
(
"ManySimultaneousThreads"
,
"[many-threads-test]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
...
...
@@ -858,7 +858,7 @@ TEST_CASE("ManySimultaneousThreads", "[many-threads-test]") {
TEST_CASE
(
"ecdsa API test"
,
"[ecdsa-api]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
...
...
@@ -906,7 +906,7 @@ TEST_CASE("ecdsa API test", "[ecdsa-api]") {
TEST_CASE
(
"dkg API test"
,
"[dkg-api]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
...
...
@@ -979,7 +979,7 @@ TEST_CASE("dkg API test", "[dkg-api]") {
TEST_CASE
(
"isPolyExists test"
,
"[is-poly]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
...
...
@@ -1005,7 +1005,7 @@ TEST_CASE("isPolyExists test", "[is-poly]") {
TEST_CASE
(
"AES_DKG test"
,
"[aes-dkg]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
...
...
@@ -1078,7 +1078,7 @@ TEST_CASE("AES_DKG test", "[aes-dkg]") {
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
()))
{
throw
RPC
Exception
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGX
Exception
(
INVALID_HEX
,
"Invalid hash"
);
}
...
...
@@ -1121,7 +1121,7 @@ TEST_CASE("AES_DKG test", "[aes-dkg]") {
TEST_CASE
(
"bls_sign_api test"
,
"[bls-sign]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
HttpClient
client
(
"http://localhost:1029"
);
...
...
@@ -1143,7 +1143,7 @@ TEST_CASE("bls_sign_api test", "[bls-sign]") {
TEST_CASE
(
"AES encrypt/decrypt"
,
"[AES-encrypt-decrypt]"
)
{
resetDB
();
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
false
,
true
);
initAll
(
false
,
true
);
...
...
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