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
31eb341a
Unverified
Commit
31eb341a
authored
Mar 12, 2020
by
Stan Kladko
Committed by
GitHub
Mar 12, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #59 from skalenetwork/FIX_TEST
Fix test
parents
1d31bf37
8250f8b2
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
852 additions
and
816 deletions
+852
-816
BLSCrypto.cpp
BLSCrypto.cpp
+2
-2
DKGCrypto.cpp
DKGCrypto.cpp
+30
-30
ECDSACrypto.cpp
ECDSACrypto.cpp
+8
-8
LevelDB.cpp
LevelDB.cpp
+5
-5
SEKManager.cpp
SEKManager.cpp
+1
-1
SGXRegistrationServer.cpp
SGXRegistrationServer.cpp
+127
-138
SGXRegistrationServer.h
SGXRegistrationServer.h
+4
-6
SGXWalletServer.cpp
SGXWalletServer.cpp
+436
-437
SGXWalletServer.h
SGXWalletServer.h
+0
-3
SGXWalletServer.hpp
SGXWalletServer.hpp
+90
-44
ServerInit.cpp
ServerInit.cpp
+12
-11
ServerInit.h
ServerInit.h
+3
-3
start.sh
docker/start.sh
+17
-17
docker-compose.yml
run_sgx/docker-compose.yml
+1
-1
docker-compose.yml
run_sgx_sim/docker-compose.yml
+1
-1
sgxwallet.c
sgxwallet.c
+67
-61
sgxwallet_common.h
sgxwallet_common.h
+3
-3
testw.cpp
testw.cpp
+45
-45
No files found.
BLSCrypto.cpp
View file @
31eb341a
...
@@ -306,7 +306,7 @@ bool sign_aes(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, siz
...
@@ -306,7 +306,7 @@ bool sign_aes(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, siz
bool
bls_sign
(
const
char
*
_encryptedKeyHex
,
const
char
*
_hashHex
,
size_t
_t
,
size_t
_n
,
size_t
_signerIndex
,
bool
bls_sign
(
const
char
*
_encryptedKeyHex
,
const
char
*
_hashHex
,
size_t
_t
,
size_t
_n
,
size_t
_signerIndex
,
char
*
_sig
)
{
char
*
_sig
)
{
if
(
!
is_ae
s
){
if
(
!
encryptKey
s
){
return
sign
(
_encryptedKeyHex
,
_hashHex
,
_t
,
_n
,
_signerIndex
,
_sig
);
return
sign
(
_encryptedKeyHex
,
_hashHex
,
_t
,
_n
,
_signerIndex
,
_sig
);
}
}
else
{
else
{
...
@@ -326,7 +326,7 @@ char* encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key)
...
@@ -326,7 +326,7 @@ char* encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key)
//status = encrypt_key(eid, errStatus, errMsg, keyArray, encryptedKey, &encryptedLen);
//status = encrypt_key(eid, errStatus, errMsg, keyArray, encryptedKey, &encryptedLen);
status
=
encrypt_key_aes
(
eid
,
errStatus
,
errMsg
->
data
(),
keyArray
->
data
(),
encryptedKey
->
data
(),
&
encryptedLen
);
status
=
encrypt_key_aes
(
eid
,
errStatus
,
errMsg
->
data
(),
keyArray
->
data
(),
encryptedKey
->
data
(),
&
encryptedLen
);
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"errStatus is {}"
,
*
errStatus
);
spdlog
::
info
(
"errStatus is {}"
,
*
errStatus
);
spdlog
::
info
(
" errMsg is "
,
errMsg
->
data
()
);
spdlog
::
info
(
" errMsg is "
,
errMsg
->
data
()
);
}
}
...
...
DKGCrypto.cpp
View file @
31eb341a
...
@@ -83,7 +83,7 @@ string gen_dkg_poly( int _t){
...
@@ -83,7 +83,7 @@ string gen_dkg_poly( int _t){
uint32_t
enc_len
=
0
;
uint32_t
enc_len
=
0
;
if
(
!
is_ae
s
)
if
(
!
encryptKey
s
)
status
=
gen_dkg_secret
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
_t
);
status
=
gen_dkg_secret
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
_t
);
else
else
status
=
gen_dkg_secret_aes
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
_t
);
status
=
gen_dkg_secret_aes
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
_t
);
...
@@ -91,13 +91,13 @@ string gen_dkg_poly( int _t){
...
@@ -91,13 +91,13 @@ string gen_dkg_poly( int _t){
throw
RPCException
(
-
666
,
errMsg
.
data
()
)
;
throw
RPCException
(
-
666
,
errMsg
.
data
()
)
;
}
}
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"gen_dkg_secret, status {}"
,
err_status
,
" err msg "
,
errMsg
.
data
());
spdlog
::
info
(
"gen_dkg_secret, status {}"
,
err_status
,
" err msg "
,
errMsg
.
data
());
spdlog
::
info
(
"in DKGCrypto encr len is {}"
,
enc_len
);
spdlog
::
info
(
"in DKGCrypto encr len is {}"
,
enc_len
);
}
}
uint64_t
length
=
DKG_MAX_SEALED_LEN
;
uint64_t
length
=
DKG_MAX_SEALED_LEN
;
if
(
is_ae
s
){
if
(
encryptKey
s
){
length
=
enc_len
;
length
=
enc_len
;
}
}
...
@@ -118,7 +118,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
...
@@ -118,7 +118,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
//char errMsg1[BUF_LEN];
//char errMsg1[BUF_LEN];
int
err_status
=
0
;
int
err_status
=
0
;
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
// cerr << "got encr poly " << encryptedPolyHex << endl;
// cerr << "got encr poly " << encryptedPolyHex << endl;
spdlog
::
info
(
"got encr poly size {}"
,
char_traits
<
char
>::
length
(
encryptedPolyHex
));
spdlog
::
info
(
"got encr poly size {}"
,
char_traits
<
char
>::
length
(
encryptedPolyHex
));
}
}
...
@@ -137,7 +137,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
...
@@ -137,7 +137,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
throw
RPCException
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
throw
RPCException
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
}
}
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
//cerr << "hex_encr_poly is " << encryptedPolyHex << std::endl;
//cerr << "hex_encr_poly is " << encryptedPolyHex << std::endl;
spdlog
::
info
(
"hex_encr_poly length is {}"
,
strlen
(
encryptedPolyHex
));
spdlog
::
info
(
"hex_encr_poly length is {}"
,
strlen
(
encryptedPolyHex
));
spdlog
::
info
(
"enc len {}"
,
enc_len
);
spdlog
::
info
(
"enc len {}"
,
enc_len
);
...
@@ -148,7 +148,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
...
@@ -148,7 +148,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
uint32_t
len
=
0
;
uint32_t
len
=
0
;
if
(
!
is_ae
s
)
if
(
!
encryptKey
s
)
status
=
get_public_shares
(
eid
,
&
err_status
,
errMsg1
,
encr_dkg_poly
,
len
,
public_shares
,
t
,
n
);
status
=
get_public_shares
(
eid
,
&
err_status
,
errMsg1
,
encr_dkg_poly
,
len
,
public_shares
,
t
,
n
);
else
{
else
{
...
@@ -158,7 +158,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
...
@@ -158,7 +158,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
throw
RPCException
(
-
666
,
errMsg1
);
throw
RPCException
(
-
666
,
errMsg1
);
}
}
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"err msg is {}"
,
errMsg1
);
spdlog
::
info
(
"err msg is {}"
,
errMsg1
);
spdlog
::
info
(
"public_shares:"
);
spdlog
::
info
(
"public_shares:"
);
...
@@ -200,7 +200,7 @@ string get_secret_shares(const string& polyName, const char* encryptedPolyHex, c
...
@@ -200,7 +200,7 @@ string get_secret_shares(const string& polyName, const char* encryptedPolyHex, c
std
::
cerr
<<
"enc_len is "
<<
enc_len
<<
std
::
endl
;
std
::
cerr
<<
"enc_len is "
<<
enc_len
<<
std
::
endl
;
if
(
!
is_ae
s
)
if
(
!
encryptKey
s
)
status
=
set_encrypted_dkg_poly
(
eid
,
&
err_status
,
errMsg1
,
encr_dkg_poly
);
status
=
set_encrypted_dkg_poly
(
eid
,
&
err_status
,
errMsg1
,
encr_dkg_poly
);
else
else
status
=
set_encrypted_dkg_poly_aes
(
eid
,
&
err_status
,
errMsg1
,
encr_dkg_poly
,
&
enc_len
);
status
=
set_encrypted_dkg_poly_aes
(
eid
,
&
err_status
,
errMsg1
,
encr_dkg_poly
,
&
enc_len
);
...
@@ -226,11 +226,11 @@ string get_secret_shares(const string& polyName, const char* encryptedPolyHex, c
...
@@ -226,11 +226,11 @@ string get_secret_shares(const string& polyName, const char* encryptedPolyHex, c
char
pubKeyB
[
129
];
char
pubKeyB
[
129
];
strncpy
(
pubKeyB
,
pub_keyB
.
c_str
(),
128
);
strncpy
(
pubKeyB
,
pub_keyB
.
c_str
(),
128
);
pubKeyB
[
128
]
=
0
;
pubKeyB
[
128
]
=
0
;
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"pubKeyB is {}"
,
pub_keyB
);
spdlog
::
info
(
"pubKeyB is {}"
,
pub_keyB
);
}
}
if
(
!
is_ae
s
)
if
(
!
encryptKey
s
)
get_encr_sshare
(
eid
,
&
err_status
,
errMsg1
,
encrypted_skey
,
&
dec_len
,
get_encr_sshare
(
eid
,
&
err_status
,
errMsg1
,
encrypted_skey
,
&
dec_len
,
cur_share
,
s_shareG2
,
pubKeyB
,
t
,
n
,
i
+
1
);
cur_share
,
s_shareG2
,
pubKeyB
,
t
,
n
,
i
+
1
);
else
else
...
@@ -239,14 +239,14 @@ string get_secret_shares(const string& polyName, const char* encryptedPolyHex, c
...
@@ -239,14 +239,14 @@ string get_secret_shares(const string& polyName, const char* encryptedPolyHex, c
if
(
err_status
!=
0
){
if
(
err_status
!=
0
){
throw
RPCException
(
-
666
,
errMsg1
);
throw
RPCException
(
-
666
,
errMsg1
);
}
}
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"cur_share is {}"
,
cur_share
);
spdlog
::
info
(
"cur_share is {}"
,
cur_share
);
}
}
result
+=
cur_share
;
result
+=
cur_share
;
//uint32_t enc_len = BUF_LEN;
//uint32_t enc_len = BUF_LEN;
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"dec len is {}"
,
dec_len
);
spdlog
::
info
(
"dec len is {}"
,
dec_len
);
}
}
...
@@ -257,17 +257,17 @@ string get_secret_shares(const string& polyName, const char* encryptedPolyHex, c
...
@@ -257,17 +257,17 @@ string get_secret_shares(const string& polyName, const char* encryptedPolyHex, c
string
DHKey_name
=
"DKG_DH_KEY_"
+
polyName
+
"_"
+
to_string
(
i
)
+
":"
;
string
DHKey_name
=
"DKG_DH_KEY_"
+
polyName
+
"_"
+
to_string
(
i
)
+
":"
;
cerr
<<
"hexEncr DH Key: "
<<
hexEncrKey
<<
endl
;
cerr
<<
"hexEncr DH Key: "
<<
hexEncrKey
<<
endl
;
writeDataToDB
(
DHKey_name
,
hexEncrKey
);
SGXWalletServer
::
writeDataToDB
(
DHKey_name
,
hexEncrKey
);
string
shareG2_name
=
"shareG2_"
+
polyName
+
"_"
+
to_string
(
i
)
+
":"
;
string
shareG2_name
=
"shareG2_"
+
polyName
+
"_"
+
to_string
(
i
)
+
":"
;
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"name to write to db is {}"
,
DHKey_name
);
spdlog
::
info
(
"name to write to db is {}"
,
DHKey_name
);
spdlog
::
info
(
"name to write to db is {}"
,
shareG2_name
);
spdlog
::
info
(
"name to write to db is {}"
,
shareG2_name
);
spdlog
::
info
(
"s_shareG2: {}"
,
s_shareG2
);
spdlog
::
info
(
"s_shareG2: {}"
,
s_shareG2
);
}
}
writeDataToDB
(
shareG2_name
,
s_shareG2
);
SGXWalletServer
::
writeDataToDB
(
shareG2_name
,
s_shareG2
);
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"errMsg: {}"
,
errMsg1
);
spdlog
::
info
(
"errMsg: {}"
,
errMsg1
);
// cerr << "iteration " << i <<" result length is " << result.length() << endl ;
// cerr << "iteration " << i <<" result length is " << result.length() << endl ;
// cerr << "iteration " << i <<" share length is " << strlen(cur_share) << endl;
// cerr << "iteration " << i <<" share length is " << strlen(cur_share) << endl;
...
@@ -295,7 +295,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
...
@@ -295,7 +295,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
throw
RPCException
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
throw
RPCException
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
}
}
int
result
;
int
result
;
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
cerr
<<
"encryptedKeyHex "
<<
encryptedKeyHex
<<
endl
;
cerr
<<
"encryptedKeyHex "
<<
encryptedKeyHex
<<
endl
;
cerr
<<
"dec_key_len "
<<
dec_key_len
<<
endl
;
cerr
<<
"dec_key_len "
<<
dec_key_len
<<
endl
;
cerr
<<
"encr_sshare length is "
<<
strlen
(
encr_sshare
)
<<
endl
;
cerr
<<
"encr_sshare length is "
<<
strlen
(
encr_sshare
)
<<
endl
;
...
@@ -307,7 +307,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
...
@@ -307,7 +307,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
strncpy
(
pshares
,
publicShares
,
strlen
(
publicShares
)
);
strncpy
(
pshares
,
publicShares
,
strlen
(
publicShares
)
);
if
(
!
is_ae
s
)
if
(
!
encryptKey
s
)
dkg_verification
(
eid
,
&
err_status
,
errMsg1
,
pshares
,
encr_sshare
,
encr_key
,
dec_key_len
,
t
,
ind
,
&
result
);
dkg_verification
(
eid
,
&
err_status
,
errMsg1
,
pshares
,
encr_sshare
,
encr_key
,
dec_key_len
,
t
,
ind
,
&
result
);
else
else
dkg_verification_aes
(
eid
,
&
err_status
,
errMsg1
,
pshares
,
encr_sshare
,
encr_key
,
dec_key_len
,
t
,
ind
,
&
result
);
dkg_verification_aes
(
eid
,
&
err_status
,
errMsg1
,
pshares
,
encr_sshare
,
encr_key
,
dec_key_len
,
t
,
ind
,
&
result
);
...
@@ -316,7 +316,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
...
@@ -316,7 +316,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
throw
RPCException
(
INVALID_HEX
,
"Invalid public shares"
);
throw
RPCException
(
INVALID_HEX
,
"Invalid public shares"
);
}
}
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"errMsg1: {}"
,
errMsg1
);
spdlog
::
info
(
"errMsg1: {}"
,
errMsg1
);
spdlog
::
info
(
"result is: {}"
,
result
);
spdlog
::
info
(
"result is: {}"
,
result
);
}
}
...
@@ -327,7 +327,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
...
@@ -327,7 +327,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
}
}
bool
CreateBLSShare
(
const
string
&
blsKeyName
,
const
char
*
s_shares
,
const
char
*
encryptedKeyHex
){
bool
CreateBLSShare
(
const
string
&
blsKeyName
,
const
char
*
s_shares
,
const
char
*
encryptedKeyHex
){
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"ENTER CreateBLSShare"
);
spdlog
::
info
(
"ENTER CreateBLSShare"
);
}
}
// char* errMsg1 = (char*) calloc(1024,1);
// char* errMsg1 = (char*) calloc(1024,1);
...
@@ -346,7 +346,7 @@ bool CreateBLSShare( const string& blsKeyName, const char * s_shares, const char
...
@@ -346,7 +346,7 @@ bool CreateBLSShare( const string& blsKeyName, const char * s_shares, const char
uint32_t
enc_bls_len
=
0
;
uint32_t
enc_bls_len
=
0
;
//cerr << "BEFORE create_bls_key IN ENCLAVE " << endl;
//cerr << "BEFORE create_bls_key IN ENCLAVE " << endl;
if
(
!
is_ae
s
)
if
(
!
encryptKey
s
)
create_bls_key
(
eid
,
&
err_status
,
errMsg1
,
s_shares
,
encr_key
,
dec_key_len
,
encr_bls_key
,
&
enc_bls_len
);
create_bls_key
(
eid
,
&
err_status
,
errMsg1
,
s_shares
,
encr_key
,
dec_key_len
,
encr_bls_key
,
&
enc_bls_len
);
else
else
create_bls_key_aes
(
eid
,
&
err_status
,
errMsg1
,
s_shares
,
encr_key
,
dec_key_len
,
encr_bls_key
,
&
enc_bls_len
);
create_bls_key_aes
(
eid
,
&
err_status
,
errMsg1
,
s_shares
,
encr_key
,
dec_key_len
,
encr_bls_key
,
&
enc_bls_len
);
...
@@ -365,8 +365,8 @@ bool CreateBLSShare( const string& blsKeyName, const char * s_shares, const char
...
@@ -365,8 +365,8 @@ bool CreateBLSShare( const string& blsKeyName, const char * s_shares, const char
//cerr << "enc_bls_len " << enc_bls_len << endl;
//cerr << "enc_bls_len " << enc_bls_len << endl;
carray2Hex
(
encr_bls_key
,
enc_bls_len
,
hexBLSKey
);
carray2Hex
(
encr_bls_key
,
enc_bls_len
,
hexBLSKey
);
// cerr << "BEFORE WRITE BLS KEY TO DB" << endl;
// cerr << "BEFORE WRITE BLS KEY TO DB" << endl;
writeDataToDB
(
blsKeyName
,
hexBLSKey
);
SGXWalletServer
::
writeDataToDB
(
blsKeyName
,
hexBLSKey
);
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"hexBLSKey length is {}"
,
char_traits
<
char
>::
length
(
hexBLSKey
));
spdlog
::
info
(
"hexBLSKey length is {}"
,
char_traits
<
char
>::
length
(
hexBLSKey
));
spdlog
::
info
(
"bls key {}"
,
blsKeyName
,
" is "
,
hexBLSKey
);
spdlog
::
info
(
"bls key {}"
,
blsKeyName
,
" is "
,
hexBLSKey
);
}
}
...
@@ -389,11 +389,11 @@ vector<string> GetBLSPubKey(const char * encryptedKeyHex){
...
@@ -389,11 +389,11 @@ vector<string> GetBLSPubKey(const char * encryptedKeyHex){
}
}
char
pub_key
[
320
];
char
pub_key
[
320
];
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"dec_key_len is {}"
,
dec_key_len
);
spdlog
::
info
(
"dec_key_len is {}"
,
dec_key_len
);
}
}
if
(
!
is_ae
s
)
if
(
!
encryptKey
s
)
get_bls_pub_key
(
eid
,
&
err_status
,
errMsg1
,
encr_key
,
dec_key_len
,
pub_key
);
get_bls_pub_key
(
eid
,
&
err_status
,
errMsg1
,
encr_key
,
dec_key_len
,
pub_key
);
else
else
get_bls_pub_key_aes
(
eid
,
&
err_status
,
errMsg1
,
encr_key
,
dec_key_len
,
pub_key
);
get_bls_pub_key_aes
(
eid
,
&
err_status
,
errMsg1
,
encr_key
,
dec_key_len
,
pub_key
);
...
@@ -403,7 +403,7 @@ vector<string> GetBLSPubKey(const char * encryptedKeyHex){
...
@@ -403,7 +403,7 @@ vector<string> GetBLSPubKey(const char * encryptedKeyHex){
}
}
vector
<
string
>
pub_key_vect
=
SplitString
(
pub_key
,
':'
);
vector
<
string
>
pub_key_vect
=
SplitString
(
pub_key
,
':'
);
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"errMsg1 is {}"
,
errMsg1
);
spdlog
::
info
(
"errMsg1 is {}"
,
errMsg1
);
spdlog
::
info
(
"pub key is "
);
spdlog
::
info
(
"pub key is "
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
i
=
0
;
i
<
4
;
i
++
)
...
@@ -418,8 +418,8 @@ string decrypt_DHKey(const string& polyName, int ind){
...
@@ -418,8 +418,8 @@ string decrypt_DHKey(const string& polyName, int ind){
int
err_status
=
0
;
int
err_status
=
0
;
string
DH_key_name
=
polyName
+
"_"
+
to_string
(
ind
)
+
":"
;
string
DH_key_name
=
polyName
+
"_"
+
to_string
(
ind
)
+
":"
;
shared_ptr
<
string
>
hexEncrKey_ptr
=
readFromDb
(
DH_key_name
,
"DKG_DH_KEY_"
);
shared_ptr
<
string
>
hexEncrKey_ptr
=
SGXWalletServer
::
readFromDb
(
DH_key_name
,
"DKG_DH_KEY_"
);
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"encr DH key is {}"
,
*
hexEncrKey_ptr
);
spdlog
::
info
(
"encr DH key is {}"
,
*
hexEncrKey_ptr
);
}
}
...
@@ -430,14 +430,14 @@ string decrypt_DHKey(const string& polyName, int ind){
...
@@ -430,14 +430,14 @@ string decrypt_DHKey(const string& polyName, int ind){
if
(
!
hex2carray
(
hexEncrKey_ptr
->
c_str
(),
&
DH_enc_len
,
encrypted_DHkey
)){
if
(
!
hex2carray
(
hexEncrKey_ptr
->
c_str
(),
&
DH_enc_len
,
encrypted_DHkey
)){
throw
RPCException
(
INVALID_HEX
,
"Invalid hexEncrKey"
);
throw
RPCException
(
INVALID_HEX
,
"Invalid hexEncrKey"
);
}
}
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"encr DH key length is {}"
,
DH_enc_len
);
spdlog
::
info
(
"encr DH key length is {}"
,
DH_enc_len
);
spdlog
::
info
(
"hex encr DH key length is {}"
,
hexEncrKey_ptr
->
length
());
spdlog
::
info
(
"hex encr DH key length is {}"
,
hexEncrKey_ptr
->
length
());
}
}
char
DHKey
[
ECDSA_SKEY_LEN
];
char
DHKey
[
ECDSA_SKEY_LEN
];
if
(
!
is_ae
s
)
if
(
!
encryptKey
s
)
decrypt_key
(
eid
,
&
err_status
,
errMsg1
.
data
(),
encrypted_DHkey
,
DH_enc_len
,
DHKey
);
decrypt_key
(
eid
,
&
err_status
,
errMsg1
.
data
(),
encrypted_DHkey
,
DH_enc_len
,
DHKey
);
else
else
decrypt_key_aes
(
eid
,
&
err_status
,
errMsg1
.
data
(),
encrypted_DHkey
,
DH_enc_len
,
DHKey
);
decrypt_key_aes
(
eid
,
&
err_status
,
errMsg1
.
data
(),
encrypted_DHkey
,
DH_enc_len
,
DHKey
);
...
...
ECDSACrypto.cpp
View file @
31eb341a
...
@@ -51,7 +51,7 @@ std::vector<std::string> gen_ecdsa_key(){
...
@@ -51,7 +51,7 @@ std::vector<std::string> gen_ecdsa_key(){
char
*
pub_key_y
=
(
char
*
)
calloc
(
1024
,
1
);
char
*
pub_key_y
=
(
char
*
)
calloc
(
1024
,
1
);
uint32_t
enc_len
=
0
;
uint32_t
enc_len
=
0
;
if
(
!
is_ae
s
)
if
(
!
encryptKey
s
)
status
=
generate_ecdsa_key
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
status
=
generate_ecdsa_key
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
else
else
status
=
generate_ecdsa_key_aes
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
status
=
generate_ecdsa_key_aes
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
...
@@ -61,7 +61,7 @@ std::vector<std::string> gen_ecdsa_key(){
...
@@ -61,7 +61,7 @@ std::vector<std::string> gen_ecdsa_key(){
throw
RPCException
(
status
,
errMsg
)
;
throw
RPCException
(
status
,
errMsg
)
;
}
}
std
::
vector
<
std
::
string
>
keys
(
3
);
std
::
vector
<
std
::
string
>
keys
(
3
);
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
std
::
cerr
<<
"account key is "
<<
errMsg
<<
std
::
endl
;
std
::
cerr
<<
"account key is "
<<
errMsg
<<
std
::
endl
;
std
::
cerr
<<
"enc_len is "
<<
enc_len
<<
std
::
endl
;
std
::
cerr
<<
"enc_len is "
<<
enc_len
<<
std
::
endl
;
// std::cerr << "enc_key is " << std::endl;
// std::cerr << "enc_key is " << std::endl;
...
@@ -77,7 +77,7 @@ std::vector<std::string> gen_ecdsa_key(){
...
@@ -77,7 +77,7 @@ std::vector<std::string> gen_ecdsa_key(){
unsigned
long
seed
=
rand_gen
();
unsigned
long
seed
=
rand_gen
();
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"seed is {}"
,
seed
);
spdlog
::
info
(
"seed is {}"
,
seed
);
std
::
cerr
<<
"strlen is "
<<
strlen
(
hexEncrKey
)
<<
std
::
endl
;
std
::
cerr
<<
"strlen is "
<<
strlen
(
hexEncrKey
)
<<
std
::
endl
;
}
}
...
@@ -122,7 +122,7 @@ std::string get_ecdsa_pubkey(const char* encryptedKeyHex){
...
@@ -122,7 +122,7 @@ std::string get_ecdsa_pubkey(const char* encryptedKeyHex){
throw
RPCException
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
throw
RPCException
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
}
}
if
(
!
is_ae
s
)
if
(
!
encryptKey
s
)
status
=
get_public_ecdsa_key
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
enc_len
,
pub_key_x
,
pub_key_y
);
status
=
get_public_ecdsa_key
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
enc_len
,
pub_key_x
,
pub_key_y
);
else
status
=
get_public_ecdsa_key_aes
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
enc_len
,
pub_key_x
,
pub_key_y
);
else
status
=
get_public_ecdsa_key_aes
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
enc_len
,
pub_key_x
,
pub_key_y
);
if
(
err_status
!=
0
){
if
(
err_status
!=
0
){
...
@@ -130,7 +130,7 @@ std::string get_ecdsa_pubkey(const char* encryptedKeyHex){
...
@@ -130,7 +130,7 @@ std::string get_ecdsa_pubkey(const char* encryptedKeyHex){
}
}
std
::
string
pubKey
=
std
::
string
(
pub_key_x
)
+
std
::
string
(
pub_key_y
);
//concatPubKeyWith0x(pub_key_x, pub_key_y);//
std
::
string
pubKey
=
std
::
string
(
pub_key_x
)
+
std
::
string
(
pub_key_y
);
//concatPubKeyWith0x(pub_key_x, pub_key_y);//
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"enc_len is {}"
,
enc_len
);
spdlog
::
info
(
"enc_len is {}"
,
enc_len
);
spdlog
::
info
(
"pubkey is {}"
,
pubKey
);
spdlog
::
info
(
"pubkey is {}"
,
pubKey
);
spdlog
::
info
(
"pubkey length is {}"
,
pubKey
.
length
());
spdlog
::
info
(
"pubkey length is {}"
,
pubKey
.
length
());
...
@@ -162,20 +162,20 @@ std::vector<std::string> ecdsa_sign_hash(const char* encryptedKeyHex, const char
...
@@ -162,20 +162,20 @@ std::vector<std::string> ecdsa_sign_hash(const char* encryptedKeyHex, const char
throw
RPCException
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
throw
RPCException
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
}
}
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"encryptedKeyHex: {}"
,
encryptedKeyHex
);
spdlog
::
info
(
"encryptedKeyHex: {}"
,
encryptedKeyHex
);
spdlog
::
info
(
"HASH: {}"
,
hashHex
);
spdlog
::
info
(
"HASH: {}"
,
hashHex
);
spdlog
::
info
(
"encrypted len: {}"
,
dec_len
);
spdlog
::
info
(
"encrypted len: {}"
,
dec_len
);
}
}
if
(
!
is_ae
s
)
if
(
!
encryptKey
s
)
status
=
ecdsa_sign1
(
eid
,
&
err_status
,
errMsg
,
encr_key
,
ECDSA_ENCR_LEN
,
(
unsigned
char
*
)
hashHex
,
signature_r
,
signature_s
,
&
signature_v
,
base
);
status
=
ecdsa_sign1
(
eid
,
&
err_status
,
errMsg
,
encr_key
,
ECDSA_ENCR_LEN
,
(
unsigned
char
*
)
hashHex
,
signature_r
,
signature_s
,
&
signature_v
,
base
);
else
status
=
ecdsa_sign_aes
(
eid
,
&
err_status
,
errMsg
,
encr_key
,
dec_len
,
(
unsigned
char
*
)
hashHex
,
signature_r
,
signature_s
,
&
signature_v
,
base
);
else
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
){
if
(
err_status
!=
0
){
throw
RPCException
(
-
666
,
errMsg
)
;
throw
RPCException
(
-
666
,
errMsg
)
;
}
}
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"signature r in ecdsa_sign_hash: {}"
,
signature_r
);
spdlog
::
info
(
"signature r in ecdsa_sign_hash: {}"
,
signature_r
);
spdlog
::
info
(
"signature s in ecdsa_sign_hash: {}"
,
signature_s
);
spdlog
::
info
(
"signature s in ecdsa_sign_hash: {}"
,
signature_s
);
}
}
...
...
LevelDB.cpp
View file @
31eb341a
...
@@ -62,7 +62,7 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
...
@@ -62,7 +62,7 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
auto
status
=
db
->
Get
(
readOptions
,
_key
,
&*
result
);
auto
status
=
db
->
Get
(
readOptions
,
_key
,
&*
result
);
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"key to read from db: {}"
,
_key
);
spdlog
::
info
(
"key to read from db: {}"
,
_key
);
//std::cerr << "key to read from db: " << _key << std::endl;
//std::cerr << "key to read from db: " << _key << std::endl;
}
}
...
@@ -83,7 +83,7 @@ void LevelDB::writeString(const string &_key, const string &_value) {
...
@@ -83,7 +83,7 @@ void LevelDB::writeString(const string &_key, const string &_value) {
throwExceptionOnError
(
status
);
throwExceptionOnError
(
status
);
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"written key: {}"
,
_key
);
spdlog
::
info
(
"written key: {}"
,
_key
);
// std::cerr << "written key " << _key << std::endl;
// std::cerr << "written key " << _key << std::endl;
}
}
...
@@ -100,7 +100,7 @@ void LevelDB::deleteDHDKGKey (const string &_key) {
...
@@ -100,7 +100,7 @@ void LevelDB::deleteDHDKGKey (const string &_key) {
throwExceptionOnError
(
status
);
throwExceptionOnError
(
status
);
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"key deleted: {}"
,
full_key
);
spdlog
::
info
(
"key deleted: {}"
,
full_key
);
//std::cerr << "key deleted " << full_key << std::endl;
//std::cerr << "key deleted " << full_key << std::endl;
}
}
...
@@ -130,7 +130,7 @@ void LevelDB::deleteKey(const string &_key){
...
@@ -130,7 +130,7 @@ void LevelDB::deleteKey(const string &_key){
throwExceptionOnError
(
status
);
throwExceptionOnError
(
status
);
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"key deleted: {}"
,
_key
);
spdlog
::
info
(
"key deleted: {}"
,
_key
);
// std::cerr << "key deleted " << _key << std::endl;
// std::cerr << "key deleted " << _key << std::endl;
}
}
...
@@ -219,7 +219,7 @@ void LevelDB::writeDataUnique(const string & Name, const string &value) {
...
@@ -219,7 +219,7 @@ void LevelDB::writeDataUnique(const string & Name, const string &value) {
}
}
writeString
(
key
,
value
);
writeString
(
key
,
value
);
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"{}"
,
Name
,
" is written to db"
);
spdlog
::
info
(
"{}"
,
Name
,
" is written to db"
);
//std::cerr << Name << " is written to db " << std::endl;
//std::cerr << Name << " is written to db " << std::endl;
}
}
...
...
SEKManager.cpp
View file @
31eb341a
...
@@ -231,7 +231,7 @@ void init_SEK(){
...
@@ -231,7 +231,7 @@ void init_SEK(){
gen_SEK
();
gen_SEK
();
}
}
else
{
else
{
if
(
DEBUG_PRINT
)
if
(
printDebugInfo
)
spdlog
::
info
(
"going to set SEK from db"
);
spdlog
::
info
(
"going to set SEK from db"
);
set_SEK
(
encr_SEK_ptr
);
set_SEK
(
encr_SEK_ptr
);
}
}
...
...
SGXRegistrationServer.cpp
View file @
31eb341a
This diff is collapsed.
Click to expand it.
SGXRegistrationServer.h
View file @
31eb341a
...
@@ -33,14 +33,12 @@ using namespace std;
...
@@ -33,14 +33,12 @@ using namespace std;
class
SGXRegistrationServer
:
public
AbstractRegServer
{
class
SGXRegistrationServer
:
public
AbstractRegServer
{
std
::
recursive_mutex
m
;
std
::
recursive_mutex
m
;
bool
is_cert_created
;
bool
isCertCreated
;
bool
cert_auto_sign
;
bool
autoSign
;
//std::string hash;
public
:
public
:
SGXRegistrationServer
(
AbstractServerConnector
&
connector
,
serverVersion_t
type
,
bool
auto_s
ign
=
false
);
SGXRegistrationServer
(
AbstractServerConnector
&
connector
,
serverVersion_t
type
,
bool
_autoS
ign
=
false
);
void
set_cert_created
(
bool
b
);
void
set_cert_created
(
bool
b
);
...
@@ -50,7 +48,7 @@ public:
...
@@ -50,7 +48,7 @@ public:
};
};
extern
int
init
_registration_server
(
bool
sign_automatically
=
false
);
extern
int
init
RegistrationServer
(
bool
_autoSign
=
false
);
...
...
SGXWalletServer.cpp
View file @
31eb341a
This diff is collapsed.
Click to expand it.
SGXWalletServer.h
View file @
31eb341a
...
@@ -31,9 +31,6 @@
...
@@ -31,9 +31,6 @@
#endif
#endif
EXTERNC
int
init_https_server
(
bool
check_certs
);
EXTERNC
int
init_http_server
();
...
...
SGXWalletServer.hpp
View file @
31eb341a
...
@@ -25,72 +25,118 @@
...
@@ -25,72 +25,118 @@
#define SGXWALLET_SGXWALLETSERVER_HPP
#define SGXWALLET_SGXWALLETSERVER_HPP
#include "abstractstubserver.h"
#include "abstractstubserver.h"
#include <mutex>
#include <mutex>
using
namespace
jsonrpc
;
using
namespace
jsonrpc
;
using
namespace
std
;
using
namespace
std
;
class
SGXWalletServer
:
public
AbstractStubServer
{
class
SGXWalletServer
:
public
AbstractStubServer
{
SGXWalletServer
*
server
=
nullptr
;
SGXWalletServer
*
server
=
nullptr
;
std
::
recursive_mutex
m
;
recursive_mutex
m
;
public
:
public
:
SGXWalletServer
(
AbstractServerConnector
&
connector
,
serverVersion_t
type
);
SGXWalletServer
(
AbstractServerConnector
&
_connector
,
serverVersion_t
_type
);
virtual
Json
::
Value
importBLSKeyShare
(
const
string
&
_keyShare
,
const
string
&
_keyShareName
,
int
_t
,
int
_n
,
int
index
);
virtual
Json
::
Value
blsSignMessageHash
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
_t
,
int
_n
,
int
_signerIndex
);
virtual
Json
::
Value
importBLSKeyShare
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyShareName
,
int
t
,
int
n
,
int
index
);
virtual
Json
::
Value
importECDSAKey
(
const
string
&
_key
,
const
string
&
_keyName
);
virtual
Json
::
Value
blsSignMessageHash
(
const
std
::
string
&
keyShareName
,
const
std
::
string
&
messageHash
,
int
t
,
int
n
,
int
signerIndex
);
virtual
Json
::
Value
importECDSAKey
(
const
std
::
string
&
key
,
const
std
::
string
&
keyName
);
virtual
Json
::
Value
generateECDSAKey
();
virtual
Json
::
Value
generateECDSAKey
();
virtual
Json
::
Value
renameECDSAKey
(
const
std
::
string
&
KeyName
,
const
std
::
string
&
tempKeyName
);
virtual
Json
::
Value
ecdsaSignMessageHash
(
int
base
,
const
std
::
string
&
keyShareName
,
const
std
::
string
&
messageHash
);
virtual
Json
::
Value
renameECDSAKey
(
const
string
&
_keyName
,
const
string
&
_tmpKeyName
);
virtual
Json
::
Value
getPublicECDSAKey
(
const
std
::
string
&
keyName
);
virtual
Json
::
Value
virtual
Json
::
Value
generateDKGPoly
(
const
std
::
string
&
polyName
,
int
t
);
ecdsaSignMessageHash
(
int
_base
,
const
string
&
_keyShareName
,
const
string
&
_messageHash
);
virtual
Json
::
Value
getVerificationVector
(
const
std
::
string
&
polyName
,
int
t
,
int
n
);
virtual
Json
::
Value
getSecretShare
(
const
std
::
string
&
polyName
,
const
Json
::
Value
&
publicKeys
,
int
t
,
int
n
);
virtual
Json
::
Value
getPublicECDSAKey
(
const
string
&
_keyName
);
virtual
Json
::
Value
dkgVerification
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
);
virtual
Json
::
Value
createBLSPrivateKey
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
virtual
Json
::
Value
generateDKGPoly
(
const
string
&
_polyName
,
int
_t
);
virtual
Json
::
Value
getBLSPublicKeyShare
(
const
std
::
string
&
blsKeyName
);
virtual
Json
::
Value
complaintResponse
(
const
std
::
string
&
polyName
,
int
ind
);
virtual
Json
::
Value
getVerificationVector
(
const
string
&
_polynomeName
,
int
_t
,
int
_n
);
virtual
Json
::
Value
multG2
(
const
std
::
string
&
x
);
virtual
Json
::
Value
isPolyExists
(
const
std
::
string
&
polyName
);
virtual
Json
::
Value
getSecretShare
(
const
string
&
_polyName
,
const
Json
::
Value
&
_publicKeys
,
int
t
,
int
n
);
virtual
Json
::
Value
dkgVerification
(
const
string
&
_publicShares
,
const
string
&
ethKeyName
,
const
string
&
SecretShare
,
int
t
,
int
n
,
int
index
);
virtual
Json
::
Value
createBLSPrivateKey
(
const
string
&
blsKeyName
,
const
string
&
ethKeyName
,
const
string
&
polyName
,
const
string
&
SecretShare
,
int
t
,
int
n
);
virtual
Json
::
Value
getBLSPublicKeyShare
(
const
string
&
blsKeyName
);
virtual
Json
::
Value
complaintResponse
(
const
string
&
polyName
,
int
ind
);
virtual
Json
::
Value
multG2
(
const
string
&
x
);
virtual
Json
::
Value
isPolyExists
(
const
string
&
polyName
);
virtual
Json
::
Value
getServerStatus
();
virtual
Json
::
Value
getServerStatus
();
}
;
static
shared_ptr
<
string
>
readFromDb
(
const
string
&
name
,
const
string
&
prefix
=
""
)
;
shared_ptr
<
string
>
readFromDb
(
const
string
&
name
,
const
string
&
prefix
=
""
);
static
void
writeDataToDB
(
const
string
&
Name
,
const
string
&
value
);
void
writeDataToDB
(
const
string
&
Name
,
const
string
&
value
);
void
writeKeyShare
(
const
string
&
_keyShareName
,
const
string
&
value
,
int
index
,
int
n
,
int
t
);
static
void
writeKeyShare
(
const
string
&
_keyShareName
,
const
string
&
_value
,
int
_index
,
int
_n
,
int
_t
);
shared_ptr
<
std
::
string
>
readKeyShare
(
const
string
&
_keyShare
);
Json
::
Value
importBLSKeyShareImpl
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyShareName
,
int
t
,
int
n
,
int
index
);
static
shared_ptr
<
string
>
readKeyShare
(
const
string
&
_keyShare
);
Json
::
Value
blsSignMessageHashImpl
(
const
std
::
string
&
keyShareName
,
const
std
::
string
&
messageHash
,
int
t
,
int
n
,
int
signerIndex
);
Json
::
Value
importECDSAKeyImpl
(
const
std
::
string
&
key
,
const
std
::
string
&
keyName
);
static
Json
::
Value
Json
::
Value
generateECDSAKeyImpl
();
importBLSKeyShareImpl
(
const
string
&
_keyShare
,
const
string
&
_keyShareName
,
int
t
,
int
n
,
int
_index
);
Json
::
Value
renameECDSAKeyImpl
(
const
std
::
string
&
KeyName
,
const
std
::
string
&
tempKeyName
);
Json
::
Value
ecdsaSignMessageHashImpl
(
int
base
,
const
std
::
string
&
keyName
,
const
std
::
string
&
messageHash
);
Json
::
Value
getPublicECDSAKeyImpl
(
const
std
::
string
&
keyName
);
Json
::
Value
generateDKGPolyImpl
(
const
std
::
string
&
polyName
,
int
t
);
static
Json
::
Value
Json
::
Value
getVerificationVectorImpl
(
const
std
::
string
&
polyName
,
int
t
,
int
n
);
blsSignMessageHashImpl
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
t
,
int
n
,
Json
::
Value
getSecretShareImpl
(
const
std
::
string
&
polyName
,
const
Json
::
Value
&
publicKeys
,
int
t
,
int
n
);
int
_signerIndex
);
Json
::
Value
dkgVerificationImpl
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
);
Json
::
Value
createBLSPrivateKeyImpl
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
Json
::
Value
getBLSPublicKeyShareImpl
(
const
std
::
string
&
blsKeyName
);
Json
::
Value
complaintResponseImpl
(
const
std
::
string
&
polyName
,
int
ind
);
Json
::
Value
multG2Impl
(
const
std
::
string
&
x
);
Json
::
Value
isPolyExistsImpl
(
const
std
::
string
&
polyName
);
Json
::
Value
getServerStatusImpl
();
static
Json
::
Value
importECDSAKeyImpl
(
const
string
&
_key
,
const
string
&
_keyName
);
static
Json
::
Value
generateECDSAKeyImpl
();
static
Json
::
Value
renameECDSAKeyImpl
(
const
string
&
_keyName
,
const
string
&
_tempKeyName
);
static
Json
::
Value
ecdsaSignMessageHashImpl
(
int
_base
,
const
string
&
keyName
,
const
string
&
_messageHash
);
static
Json
::
Value
getPublicECDSAKeyImpl
(
const
string
&
_keyName
);
static
Json
::
Value
generateDKGPolyImpl
(
const
string
&
_polyName
,
int
_t
);
static
Json
::
Value
getVerificationVectorImpl
(
const
string
&
_polyName
,
int
_t
,
int
_n
);
static
Json
::
Value
getSecretShareImpl
(
const
string
&
_polyName
,
const
Json
::
Value
&
_publicKeys
,
int
_t
,
int
_n
);
static
Json
::
Value
dkgVerificationImpl
(
const
string
&
_publicShares
,
const
string
&
_ethKeyName
,
const
string
&
_secretShare
,
int
_t
,
int
_n
,
int
_index
);
static
Json
::
Value
createBLSPrivateKeyImpl
(
const
string
&
_blsKeyName
,
const
string
&
_ethKeyName
,
const
string
&
_polyName
,
const
string
&
_secretShare
,
int
_t
,
int
_n
);
static
Json
::
Value
getBLSPublicKeyShareImpl
(
const
string
&
_blsKeyName
);
static
Json
::
Value
complaintResponseImpl
(
const
string
&
_polyName
,
int
_ind
);
static
Json
::
Value
multG2Impl
(
const
string
&
_x
);
static
Json
::
Value
isPolyExistsImpl
(
const
string
&
_polyName
);
static
Json
::
Value
getServerStatusImpl
();
static
void
printDB
();
static
int
initHttpServer
();
static
int
initHttpsServer
(
bool
_checkCerts
);
};
#endif //SGXWALLET_SGXWALLETSERVER_HPP
#endif //SGXWALLET_SGXWALLETSERVER_HPP
\ No newline at end of file
ServerInit.cpp
View file @
31eb341a
...
@@ -64,13 +64,14 @@
...
@@ -64,13 +64,14 @@
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include "SGXWalletServer.hpp"
#include "SGXWALLET_VERSION"
#include "SGXWALLET_VERSION"
//#include <system>
//#include <system>
void
init
_d
aemon
()
{
void
init
D
aemon
()
{
libff
::
init_alt_bn128_params
();
libff
::
init_alt_bn128_params
();
...
@@ -79,7 +80,7 @@ void init_daemon() {
...
@@ -79,7 +80,7 @@ void init_daemon() {
void
init
_e
nclave
()
{
void
init
E
nclave
()
{
eid
=
0
;
eid
=
0
;
updated
=
0
;
updated
=
0
;
...
@@ -95,7 +96,7 @@ void init_enclave() {
...
@@ -95,7 +96,7 @@ void init_enclave() {
}
}
#endif
#endif
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"SGX_DEBUG_FLAG = {}"
,
SGX_DEBUG_FLAG
);
spdlog
::
info
(
"SGX_DEBUG_FLAG = {}"
,
SGX_DEBUG_FLAG
);
}
}
...
@@ -121,7 +122,7 @@ void init_enclave() {
...
@@ -121,7 +122,7 @@ void init_enclave() {
exit
(
1
);
exit
(
1
);
}
}
if
(
DEBUG_PRINT
)
{
if
(
printDebugInfo
)
{
spdlog
::
info
(
"libtgmp initialized"
);
spdlog
::
info
(
"libtgmp initialized"
);
//fprintf(stderr, "libtgmp initialized\n");
//fprintf(stderr, "libtgmp initialized\n");
}
}
...
@@ -130,27 +131,27 @@ void init_enclave() {
...
@@ -130,27 +131,27 @@ void init_enclave() {
int
sgxServerInited
=
0
;
int
sgxServerInited
=
0
;
void
init
_all
(
bool
check_cert
,
bool
sign_automatically
,
void
(
*
SEK_func
)())
{
void
init
All
(
bool
_checkCert
,
bool
_autoSign
,
void
(
*
SEK_func
)())
{
cout
<<
"Running sgxwallet version:"
<<
SGXWALLET_VERSION
<<
endl
;
cout
<<
"Running sgxwallet version:"
<<
SGXWALLET_VERSION
<<
endl
;
//spdlog::set_pattern("%c");
//spdlog::set_pattern("%c");
if
(
sgxServerInited
==
1
)
if
(
sgxServerInited
==
1
)
return
;
return
;
init
_e
nclave
();
init
E
nclave
();
init
_d
aemon
();
init
D
aemon
();
//init_SEK();
//init_SEK();
SEK_func
();
SEK_func
();
sgxServerInited
=
1
;
sgxServerInited
=
1
;
if
(
is_sgx_https
)
{
if
(
useHTTPS
)
{
init_https_server
(
check_c
ert
);
SGXWalletServer
::
initHttpsServer
(
_checkC
ert
);
init_registration_server
(
sign_automatically
);
initRegistrationServer
(
_autoSign
);
init_csrmanager_server
();
init_csrmanager_server
();
}
}
else
{
else
{
init_http_s
erver
();
SGXWalletServer
::
initHttpS
erver
();
}
}
//std::cerr << "enclave inited" << std::endl;
//std::cerr << "enclave inited" << std::endl;
...
...
ServerInit.h
View file @
31eb341a
...
@@ -30,11 +30,11 @@
...
@@ -30,11 +30,11 @@
#define EXTERNC
#define EXTERNC
#endif
#endif
EXTERNC
void
init
_all
(
bool
check_cert
,
bool
sign_automatically
,
void
(
*
func
)());
EXTERNC
void
init
All
(
bool
_checkCert
,
bool
_autoSign
,
void
(
*
func
)());
EXTERNC
void
init
_d
aemon
();
EXTERNC
void
init
D
aemon
();
EXTERNC
void
init
_e
nclave
();
EXTERNC
void
init
E
nclave
();
...
...
docker/start.sh
View file @
31eb341a
...
@@ -5,25 +5,25 @@ cd /usr/src/sdk;
...
@@ -5,25 +5,25 @@ cd /usr/src/sdk;
echo
$1
echo
$1
if
[
"
$1
"
=
-t
]
;
then
if
[
"
$1
"
=
-t
]
;
then
set
-e
set
-e
#
./testw [bls-key-encrypt]
./testw
[
bls-key-encrypt]
#
./testw [bls-key-encrypt-decrypt]
./testw
[
bls-key-encrypt-decrypt]
#
./testw [dkg-gen]
./testw
[
dkg-gen]
#
./testw [dkg-pub_shares]
./testw
[
dkg-pub_shares]
#
./testw [dkg-verify]
./testw
[
dkg-verify]
#
./testw [ecdsa_test]
./testw
[
ecdsa_test]
#
./testw [test_test]
./testw
[
test_test]
#
./testw [get_pub_ecdsa_key_test]
./testw
[
get_pub_ecdsa_key_test]
#
./testw [bls_dkg]
./testw
[
bls_dkg]
#
./testw [api_test]
./testw
[
api_test]
#
./testw [getServerStatus_test]
./testw
[
getServerStatus_test]
#
./testw [dkg_api_test]
./testw
[
dkg_api_test]
#
./testw [is_poly_test]
./testw
[
is_poly_test]
#
./testw [AES-encrypt-decrypt]
./testw
[
AES-encrypt-decrypt]
#./testw [ecdsa_api_test]
#./testw [ecdsa_api_test]
#./testw [dkg-encr_sshares]
#./testw [dkg-encr_sshares]
#
./testw [bls_sign]
#
./testw [bls_sign]
#
./testw [many_threads_test]
./testw
[
many_threads_test]
#
./testw [aes_dkg]
./testw
[
aes_dkg]
else
else
./sgxwallet
$1
$2
$3
$4
./sgxwallet
$1
$2
$3
$4
fi
fi
...
...
run_sgx/docker-compose.yml
View file @
31eb341a
...
@@ -17,6 +17,6 @@ services:
...
@@ -17,6 +17,6 @@ services:
max-size
:
"
10m"
max-size
:
"
10m"
max-file
:
"
4"
max-file
:
"
4"
restart
:
unless-stopped
restart
:
unless-stopped
command
:
-
t
command
:
-
s -d -y
run_sgx_sim/docker-compose.yml
View file @
31eb341a
...
@@ -14,5 +14,5 @@ services:
...
@@ -14,5 +14,5 @@ services:
max-size
:
"
10m"
max-size
:
"
10m"
max-file
:
"
4"
max-file
:
"
4"
restart
:
unless-stopped
restart
:
unless-stopped
command
:
-s -y
command
:
-s -y
-d
sgxwallet.c
View file @
31eb341a
...
@@ -44,10 +44,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...
@@ -44,10 +44,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
#include <stdbool.h>
void
usage
()
{
void
usage
()
{
fprintf
(
stderr
,
"usage: sgxwallet
\n
"
);
fprintf
(
stderr
,
"usage: sgxwallet
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
sgx_launch_token_t
token
=
{
0
};
sgx_launch_token_t
token
=
{
0
};
...
@@ -55,67 +54,74 @@ sgx_enclave_id_t eid;
...
@@ -55,67 +54,74 @@ sgx_enclave_id_t eid;
sgx_status_t
status
;
sgx_status_t
status
;
int
updated
;
int
updated
;
void
printUsage
()
{
fprintf
(
stderr
,
"Available flags:
\n
"
);
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
,
"-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
"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
void
(
*
SEK_initializer
)();
void
(
*
SEK_initializer
)();
SEK_initializer
=
init_SEK
;
SEK_initializer
=
init_SEK
;
bool
check_client_cert
=
true
;
bool
checkClientCert
=
true
;
bool
sign_automatically
=
false
;
bool
sign_automatically
=
false
;
int
opt
;
int
opt
;
if
(
argc
>
1
&&
strlen
(
argv
[
1
])
==
1
){
if
(
argc
>
1
&&
strlen
(
argv
[
1
])
==
1
)
{
fprintf
(
stderr
,
"option is too short %s
\n
"
,
argv
[
1
]);
fprintf
(
stderr
,
"option is too short %s
\n
"
,
argv
[
1
]);
exit
(
1
);
}
is_aes
=
0
;
while
((
opt
=
getopt
(
argc
,
argv
,
"cshd0aby"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'h'
:
if
(
strlen
(
argv
[
1
])
==
2
)
{
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
,
"-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
"
);
exit
(
0
);
}
else
{
fprintf
(
stderr
,
"unknown flag %s
\n
"
,
argv
[
1
]);
exit
(
1
);
exit
(
1
);
}
case
'c'
:
check_client_cert
=
false
;
break
;
case
's'
:
sign_automatically
=
true
;
break
;
case
'd'
:
DEBUG_PRINT
=
1
;
break
;
case
'0'
:
is_sgx_https
=
0
;
break
;
case
'a'
:
is_aes
=
0
;
break
;
case
'b'
:
SEK_initializer
=
enter_SEK
;
break
;
case
'y'
:
autoconfirm
=
true
;
break
;
case
'?'
:
// fprintf(stderr, "unknown flag\n");
exit
(
1
);
default:
break
;
}
}
}
init_all
(
check_client_cert
,
sign_automatically
,
SEK_initializer
);
while
(
true
)
{
encryptKeys
=
0
;
sleep
(
10
);
}
while
((
opt
=
getopt
(
argc
,
argv
,
"cshd0aby"
))
!=
-
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'
:
checkClientCert
=
false
;
break
;
case
's'
:
sign_automatically
=
true
;
break
;
case
'd'
:
printDebugInfo
=
1
;
break
;
case
'0'
:
useHTTPS
=
0
;
break
;
case
'a'
:
encryptKeys
=
0
;
break
;
case
'b'
:
SEK_initializer
=
enter_SEK
;
break
;
case
'y'
:
autoconfirm
=
true
;
break
;
case
'?'
:
printUsage
();
exit
(
1
);
default:
break
;
}
}
initAll
(
checkClientCert
,
sign_automatically
,
SEK_initializer
);
while
(
true
)
{
sleep
(
10
);
}
return
0
;
return
0
;
}
}
sgxwallet_common.h
View file @
31eb341a
...
@@ -35,9 +35,9 @@
...
@@ -35,9 +35,9 @@
extern
int
DEBUG_PRINT
;
extern
int
printDebugInfo
;
extern
int
is_sgx_https
;
extern
int
useHTTPS
;
extern
int
is_ae
s
;
extern
int
encryptKey
s
;
extern
bool
autoconfirm
;
extern
bool
autoconfirm
;
#define BUF_LEN 1024
#define BUF_LEN 1024
...
...
testw.cpp
View file @
31eb341a
...
@@ -121,10 +121,10 @@ char *encryptTestKey() {
...
@@ -121,10 +121,10 @@ char *encryptTestKey() {
TEST_CASE
(
"BLS key encrypt"
,
"[bls-key-encrypt]"
)
{
TEST_CASE
(
"BLS key encrypt"
,
"[bls-key-encrypt]"
)
{
DEBUG_PRINT
=
1
;
printDebugInfo
=
1
;
is_sgx_https
=
0
;
useHTTPS
=
0
;
autoconfirm
=
true
;
autoconfirm
=
true
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
auto
key
=
encryptTestKey
();
auto
key
=
encryptTestKey
();
REQUIRE
(
key
!=
nullptr
);
REQUIRE
(
key
!=
nullptr
);
free
(
key
);
free
(
key
);
...
@@ -134,11 +134,11 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
...
@@ -134,11 +134,11 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
TEST_CASE
(
"BLS key encrypt/decrypt"
,
"[bls-key-encrypt-decrypt]"
)
{
TEST_CASE
(
"BLS key encrypt/decrypt"
,
"[bls-key-encrypt-decrypt]"
)
{
{
{
DEBUG_PRINT
=
1
;
printDebugInfo
=
1
;
is_sgx_https
=
0
;
useHTTPS
=
0
;
autoconfirm
=
true
;
autoconfirm
=
true
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
//init_enclave();
//init_enclave();
...
@@ -169,7 +169,7 @@ TEST_CASE("DKG gen test", "[dkg-gen]") {
...
@@ -169,7 +169,7 @@ TEST_CASE("DKG gen test", "[dkg-gen]") {
autoconfirm
=
true
;
autoconfirm
=
true
;
//init_all();
//init_all();
init
_e
nclave
();
init
E
nclave
();
vector
<
uint8_t
>
encrypted_dkg_secret
(
DKG_MAX_SEALED_LEN
,
0
);
vector
<
uint8_t
>
encrypted_dkg_secret
(
DKG_MAX_SEALED_LEN
,
0
);
vector
<
char
>
errMsg
(
1024
,
0
);
vector
<
char
>
errMsg
(
1024
,
0
);
...
@@ -257,7 +257,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub_shares]") {
...
@@ -257,7 +257,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub_shares]") {
autoconfirm
=
true
;
autoconfirm
=
true
;
//init_all();
//init_all();
libff
::
init_alt_bn128_params
();
libff
::
init_alt_bn128_params
();
init
_e
nclave
();
init
E
nclave
();
vector
<
uint8_t
>
encrypted_dkg_secret
(
DKG_MAX_SEALED_LEN
,
0
);
vector
<
uint8_t
>
encrypted_dkg_secret
(
DKG_MAX_SEALED_LEN
,
0
);
vector
<
char
>
errMsg
(
1024
,
0
);
vector
<
char
>
errMsg
(
1024
,
0
);
...
@@ -327,7 +327,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub_shares]") {
...
@@ -327,7 +327,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub_shares]") {
TEST_CASE
(
"DKG encrypted secret shares test"
,
"[dkg-encr_sshares]"
)
{
TEST_CASE
(
"DKG encrypted secret shares test"
,
"[dkg-encr_sshares]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
// init_all();
// init_all();
init
_e
nclave
();
init
E
nclave
();
vector
<
char
>
errMsg
(
1024
,
1
);
vector
<
char
>
errMsg
(
1024
,
1
);
vector
<
char
>
result
(
130
,
1
);
vector
<
char
>
result
(
130
,
1
);
...
@@ -363,7 +363,7 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr_sshares]") {
...
@@ -363,7 +363,7 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr_sshares]") {
TEST_CASE
(
"DKG verification test"
,
"[dkg-verify]"
)
{
TEST_CASE
(
"DKG verification test"
,
"[dkg-verify]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
// init_all();
// init_all();
init
_e
nclave
();
init
E
nclave
();
vector
<
char
>
errMsg
(
1024
,
0
);
vector
<
char
>
errMsg
(
1024
,
0
);
vector
<
char
>
result
(
130
,
0
);
vector
<
char
>
result
(
130
,
0
);
...
@@ -401,7 +401,7 @@ TEST_CASE("DKG verification test", "[dkg-verify]") {
...
@@ -401,7 +401,7 @@ TEST_CASE("DKG verification test", "[dkg-verify]") {
TEST_CASE
(
"ECDSA keygen and signature test"
,
"[ecdsa_test]"
)
{
TEST_CASE
(
"ECDSA keygen and signature test"
,
"[ecdsa_test]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
init
_e
nclave
();
init
E
nclave
();
vector
<
char
>
errMsg
(
1024
,
0
);
vector
<
char
>
errMsg
(
1024
,
0
);
int
err_status
=
0
;
int
err_status
=
0
;
...
@@ -446,7 +446,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa_test]") {
...
@@ -446,7 +446,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa_test]") {
TEST_CASE
(
"Test test"
,
"[test_test]"
)
{
TEST_CASE
(
"Test test"
,
"[test_test]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
init
_e
nclave
();
init
E
nclave
();
vector
<
char
>
errMsg
(
1024
,
0
);
vector
<
char
>
errMsg
(
1024
,
0
);
int
err_status
=
0
;
int
err_status
=
0
;
...
@@ -476,7 +476,7 @@ TEST_CASE("Test test", "[test_test]") {
...
@@ -476,7 +476,7 @@ TEST_CASE("Test test", "[test_test]") {
TEST_CASE
(
"get public ECDSA key"
,
"[get_pub_ecdsa_key_test]"
)
{
TEST_CASE
(
"get public ECDSA key"
,
"[get_pub_ecdsa_key_test]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
//init_all();
//init_all();
init
_e
nclave
();
init
E
nclave
();
int
err_status
=
0
;
int
err_status
=
0
;
vector
<
char
>
errMsg
(
1024
,
0
);
vector
<
char
>
errMsg
(
1024
,
0
);
...
@@ -549,10 +549,10 @@ string ConvertDecToHex(string dec, int numBytes = 32) {
...
@@ -549,10 +549,10 @@ string ConvertDecToHex(string dec, int numBytes = 32) {
TEST_CASE
(
"BLS_DKG test"
,
"[bls_dkg]"
)
{
TEST_CASE
(
"BLS_DKG test"
,
"[bls_dkg]"
)
{
is_sgx_https
=
0
;
useHTTPS
=
0
;
DEBUG_PRINT
=
1
;
printDebugInfo
=
1
;
cerr
<<
"test started"
<<
endl
;
cerr
<<
"test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
...
@@ -683,10 +683,10 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
...
@@ -683,10 +683,10 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
TEST_CASE
(
"API test"
,
"[api_test]"
)
{
TEST_CASE
(
"API test"
,
"[api_test]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
//DEBUG_PRINT = 1;
//DEBUG_PRINT = 1;
is_sgx_https
=
0
;
useHTTPS
=
0
;
//cerr << __GNUC__ << endl;
//cerr << __GNUC__ << endl;
cerr
<<
"API test started"
<<
endl
;
cerr
<<
"API test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
//HttpServer httpserver(1025);
//HttpServer httpserver(1025);
//SGXWalletServer s(httpserver,
//SGXWalletServer s(httpserver,
// JSONRPC_SERVER_V2); // hybrid server (json-rpc 1.0 & 2.0)
// JSONRPC_SERVER_V2); // hybrid server (json-rpc 1.0 & 2.0)
...
@@ -789,8 +789,8 @@ TEST_CASE("API test", "[api_test]") {
...
@@ -789,8 +789,8 @@ TEST_CASE("API test", "[api_test]") {
TEST_CASE
(
"getServerStatus test"
,
"[getServerStatus_test]"
)
{
TEST_CASE
(
"getServerStatus test"
,
"[getServerStatus_test]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
is_sgx_https
=
0
;
useHTTPS
=
0
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
HttpClient
client
(
"http://localhost:1029"
);
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
REQUIRE
(
c
.
getServerStatus
()[
"status"
]
==
0
);
REQUIRE
(
c
.
getServerStatus
()[
"status"
]
==
0
);
...
@@ -911,11 +911,11 @@ void SendRPCRequest() {
...
@@ -911,11 +911,11 @@ void SendRPCRequest() {
TEST_CASE
(
"ManySimultaneousThreads"
,
"[many_threads_test]"
)
{
TEST_CASE
(
"ManySimultaneousThreads"
,
"[many_threads_test]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
is_sgx_https
=
0
;
useHTTPS
=
0
;
DEBUG_PRINT
=
1
;
printDebugInfo
=
1
;
is_ae
s
=
1
;
encryptKey
s
=
1
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
vector
<
thread
>
threads
;
vector
<
thread
>
threads
;
int
num_threads
=
4
;
int
num_threads
=
4
;
...
@@ -932,12 +932,12 @@ TEST_CASE("ManySimultaneousThreads", "[many_threads_test]") {
...
@@ -932,12 +932,12 @@ TEST_CASE("ManySimultaneousThreads", "[many_threads_test]") {
TEST_CASE
(
"ecdsa API test"
,
"[ecdsa_api_test]"
)
{
TEST_CASE
(
"ecdsa API test"
,
"[ecdsa_api_test]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
DEBUG_PRINT
=
1
;
printDebugInfo
=
1
;
is_sgx_https
=
0
;
useHTTPS
=
0
;
is_ae
s
=
1
;
encryptKey
s
=
1
;
cerr
<<
"ecdsa_api_test started"
<<
endl
;
cerr
<<
"ecdsa_api_test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
HttpClient
client
(
"http://localhost:1029"
);
...
@@ -984,11 +984,11 @@ TEST_CASE("ecdsa API test", "[ecdsa_api_test]") {
...
@@ -984,11 +984,11 @@ TEST_CASE("ecdsa API test", "[ecdsa_api_test]") {
TEST_CASE
(
"dkg API test"
,
"[dkg_api_test]"
)
{
TEST_CASE
(
"dkg API test"
,
"[dkg_api_test]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
DEBUG_PRINT
=
1
;
printDebugInfo
=
1
;
is_sgx_https
=
0
;
useHTTPS
=
0
;
cerr
<<
"dkg_api_test started"
<<
endl
;
cerr
<<
"dkg_api_test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
HttpClient
client
(
"http://localhost:1029"
);
...
@@ -1062,11 +1062,11 @@ TEST_CASE("dkg API test", "[dkg_api_test]") {
...
@@ -1062,11 +1062,11 @@ TEST_CASE("dkg API test", "[dkg_api_test]") {
TEST_CASE
(
"isPolyExists test"
,
"[is_poly_test]"
)
{
TEST_CASE
(
"isPolyExists test"
,
"[is_poly_test]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
DEBUG_PRINT
=
1
;
printDebugInfo
=
1
;
is_sgx_https
=
0
;
useHTTPS
=
0
;
cerr
<<
"is_poly_test started"
<<
endl
;
cerr
<<
"is_poly_test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
HttpClient
client
(
"http://localhost:1029"
);
...
@@ -1091,14 +1091,14 @@ TEST_CASE("isPolyExists test", "[is_poly_test]") {
...
@@ -1091,14 +1091,14 @@ TEST_CASE("isPolyExists test", "[is_poly_test]") {
TEST_CASE
(
"AES_DKG test"
,
"[aes_dkg]"
)
{
TEST_CASE
(
"AES_DKG test"
,
"[aes_dkg]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
is_sgx_https
=
0
;
useHTTPS
=
0
;
DEBUG_PRINT
=
1
;
printDebugInfo
=
1
;
is_ae
s
=
1
;
encryptKey
s
=
1
;
reset_db
();
reset_db
();
cerr
<<
"test started"
<<
endl
;
cerr
<<
"test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
...
@@ -1223,12 +1223,12 @@ TEST_CASE("AES_DKG test", "[aes_dkg]") {
...
@@ -1223,12 +1223,12 @@ TEST_CASE("AES_DKG test", "[aes_dkg]") {
TEST_CASE
(
"bls_sign_api test"
,
"[bls_sign]"
)
{
TEST_CASE
(
"bls_sign_api test"
,
"[bls_sign]"
)
{
autoconfirm
=
true
;
autoconfirm
=
true
;
is_sgx_https
=
0
;
useHTTPS
=
0
;
DEBUG_PRINT
=
1
;
printDebugInfo
=
1
;
is_ae
s
=
1
;
encryptKey
s
=
1
;
cerr
<<
"test started"
<<
endl
;
cerr
<<
"test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
...
@@ -1258,10 +1258,10 @@ TEST_CASE("bls_sign_api test", "[bls_sign]") {
...
@@ -1258,10 +1258,10 @@ TEST_CASE("bls_sign_api test", "[bls_sign]") {
TEST_CASE
(
"AES encrypt/decrypt"
,
"[AES-encrypt-decrypt]"
)
{
TEST_CASE
(
"AES encrypt/decrypt"
,
"[AES-encrypt-decrypt]"
)
{
{
{
autoconfirm
=
true
;
autoconfirm
=
true
;
DEBUG_PRINT
=
1
;
printDebugInfo
=
1
;
is_sgx_https
=
0
;
useHTTPS
=
0
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
//init_enclave();
//init_enclave();
int
errStatus
=
-
1
;
int
errStatus
=
-
1
;
...
...
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