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
a2c0c34a
Unverified
Commit
a2c0c34a
authored
Mar 12, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test
parent
f0f043ad
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
107 additions
and
101 deletions
+107
-101
SGXWalletServer.cpp
SGXWalletServer.cpp
+16
-16
SGXWalletServer.hpp
SGXWalletServer.hpp
+8
-8
ServerInit.cpp
ServerInit.cpp
+2
-2
ServerInit.h
ServerInit.h
+1
-1
start.sh
docker/start.sh
+1
-1
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
+65
-59
testw.cpp
testw.cpp
+12
-12
No files found.
SGXWalletServer.cpp
View file @
a2c0c34a
...
...
@@ -735,20 +735,20 @@ Json::Value SGXWalletServer::getServerStatusImpl() {
}
Json
::
Value
SGXWalletServer
::
generateDKGPoly
(
const
string
&
polyName
,
int
t
)
{
Json
::
Value
SGXWalletServer
::
generateDKGPoly
(
const
string
&
_polyName
,
int
_
t
)
{
spdlog
::
info
(
"entered generateDKGPoly"
);
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
generateDKGPolyImpl
(
polyName
,
t
);
return
generateDKGPolyImpl
(
_polyName
,
_
t
);
}
Json
::
Value
SGXWalletServer
::
getVerificationVector
(
const
string
&
polyName
,
int
t
,
int
n
)
{
Json
::
Value
SGXWalletServer
::
getVerificationVector
(
const
string
&
_polynomeName
,
int
_t
,
int
_
n
)
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
getVerificationVectorImpl
(
polyName
,
t
,
n
);
return
getVerificationVectorImpl
(
_polynomeName
,
_t
,
_
n
);
}
Json
::
Value
SGXWalletServer
::
getSecretShare
(
const
string
&
polyName
,
const
Json
::
Value
&
publicKeys
,
int
t
,
int
n
)
{
Json
::
Value
SGXWalletServer
::
getSecretShare
(
const
string
&
_polyName
,
const
Json
::
Value
&
_
publicKeys
,
int
t
,
int
n
)
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
getSecretShareImpl
(
polyName
,
publicKeys
,
t
,
n
);
return
getSecretShareImpl
(
_polyName
,
_
publicKeys
,
t
,
n
);
}
Json
::
Value
...
...
@@ -776,9 +776,9 @@ Json::Value SGXWalletServer::generateECDSAKey() {
return
generateECDSAKeyImpl
();
}
Json
::
Value
SGXWalletServer
::
renameECDSAKey
(
const
string
&
KeyName
,
const
string
&
te
mpKeyName
)
{
Json
::
Value
SGXWalletServer
::
renameECDSAKey
(
const
string
&
_keyName
,
const
string
&
_t
mpKeyName
)
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
renameECDSAKeyImpl
(
KeyName
,
te
mpKeyName
);
return
renameECDSAKeyImpl
(
_keyName
,
_t
mpKeyName
);
}
Json
::
Value
SGXWalletServer
::
getPublicECDSAKey
(
const
string
&
_keyName
)
{
...
...
@@ -787,13 +787,13 @@ Json::Value SGXWalletServer::getPublicECDSAKey(const string &_keyName) {
}
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHash
(
int
base
,
const
string
&
_keyName
,
const
string
&
messageHash
)
{
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHash
(
int
_base
,
const
string
&
_keyShareName
,
const
string
&
_
messageHash
)
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
spdlog
::
info
(
"entered ecdsaSignMessageHash"
);
if
(
printDebugInfo
)
{
spdlog
::
info
(
"MessageHash first {}"
,
messageHash
);
spdlog
::
info
(
"MessageHash first {}"
,
_
messageHash
);
}
return
ecdsaSignMessageHashImpl
(
base
,
_keyName
,
messageHash
);
return
ecdsaSignMessageHashImpl
(
_base
,
_keyShareName
,
_
messageHash
);
}
...
...
@@ -804,15 +804,15 @@ SGXWalletServer::importBLSKeyShare(const string &_keyShare, const string &_keySh
return
importBLSKeyShareImpl
(
_keyShare
,
_keyShareName
,
_t
,
_n
,
index
);
}
Json
::
Value
SGXWalletServer
::
blsSignMessageHash
(
const
string
&
keyShareName
,
const
string
&
messageHash
,
int
t
,
int
n
,
int
signerIndex
)
{
Json
::
Value
SGXWalletServer
::
blsSignMessageHash
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
_t
,
int
_
n
,
int
_
signerIndex
)
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
blsSignMessageHashImpl
(
keyShareName
,
messageHash
,
t
,
n
,
signerIndex
);
return
blsSignMessageHashImpl
(
_keyShareName
,
_messageHash
,
_t
,
_n
,
_
signerIndex
);
}
Json
::
Value
SGXWalletServer
::
importECDSAKey
(
const
string
&
key
,
const
string
&
keyName
)
{
Json
::
Value
SGXWalletServer
::
importECDSAKey
(
const
string
&
_key
,
const
string
&
_
keyName
)
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
importECDSAKeyImpl
(
key
,
keyName
);
return
importECDSAKeyImpl
(
_key
,
_
keyName
);
}
Json
::
Value
SGXWalletServer
::
complaintResponse
(
const
string
&
polyName
,
int
ind
)
{
...
...
SGXWalletServer.hpp
View file @
a2c0c34a
...
...
@@ -45,23 +45,23 @@ public:
importBLSKeyShare
(
const
std
::
string
&
_keyShare
,
const
std
::
string
&
_keyShareName
,
int
_t
,
int
_n
,
int
index
);
virtual
Json
::
Value
blsSignMessageHash
(
const
std
::
string
&
keyShareName
,
const
std
::
string
&
messageHash
,
int
t
,
int
n
,
int
signerIndex
);
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
importECDSAKey
(
const
std
::
string
&
_key
,
const
std
::
string
&
_
keyName
);
virtual
Json
::
Value
generateECDSAKey
();
virtual
Json
::
Value
renameECDSAKey
(
const
std
::
string
&
KeyName
,
const
std
::
string
&
te
mpKeyName
);
virtual
Json
::
Value
renameECDSAKey
(
const
std
::
string
&
_keyName
,
const
std
::
string
&
_t
mpKeyName
);
virtual
Json
::
Value
ecdsaSignMessageHash
(
int
base
,
const
std
::
string
&
keyShareName
,
const
std
::
string
&
messageHash
);
virtual
Json
::
Value
ecdsaSignMessageHash
(
int
_base
,
const
std
::
string
&
_keyShareName
,
const
std
::
string
&
_
messageHash
);
virtual
Json
::
Value
getPublicECDSAKey
(
const
std
::
string
&
keyName
);
virtual
Json
::
Value
getPublicECDSAKey
(
const
std
::
string
&
_
keyName
);
virtual
Json
::
Value
generateDKGPoly
(
const
std
::
string
&
polyName
,
int
t
);
virtual
Json
::
Value
generateDKGPoly
(
const
std
::
string
&
_polyName
,
int
_
t
);
virtual
Json
::
Value
getVerificationVector
(
const
std
::
string
&
polyName
,
int
t
,
int
n
);
virtual
Json
::
Value
getVerificationVector
(
const
std
::
string
&
_polynomeName
,
int
_t
,
int
_
n
);
virtual
Json
::
Value
getSecretShare
(
const
std
::
string
&
polyName
,
const
Json
::
Value
&
publicKeys
,
int
t
,
int
n
);
virtual
Json
::
Value
getSecretShare
(
const
std
::
string
&
_polyName
,
const
Json
::
Value
&
_
publicKeys
,
int
t
,
int
n
);
virtual
Json
::
Value
dkgVerification
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
SecretShare
,
...
...
ServerInit.cpp
View file @
a2c0c34a
...
...
@@ -131,7 +131,7 @@ void init_enclave() {
int
sgxServerInited
=
0
;
void
init
_a
ll
(
bool
check_cert
,
bool
sign_automatically
,
void
(
*
SEK_func
)())
{
void
init
A
ll
(
bool
check_cert
,
bool
sign_automatically
,
void
(
*
SEK_func
)())
{
cout
<<
"Running sgxwallet version:"
<<
SGXWALLET_VERSION
<<
endl
;
...
...
@@ -141,7 +141,7 @@ void init_all(bool check_cert, bool sign_automatically, void (*SEK_func)()) {
init_enclave
();
init_daemon
();
//init_SEK();
SEK_
func
();
func
();
sgxServerInited
=
1
;
...
...
ServerInit.h
View file @
a2c0c34a
...
...
@@ -30,7 +30,7 @@
#define EXTERNC
#endif
EXTERNC
void
init
_a
ll
(
bool
check_cert
,
bool
sign_automatically
,
void
(
*
func
)());
EXTERNC
void
init
A
ll
(
bool
check_cert
,
bool
sign_automatically
,
void
(
*
func
)());
EXTERNC
void
init_daemon
();
...
...
docker/start.sh
View file @
a2c0c34a
...
...
@@ -21,7 +21,7 @@ if [ "$1" = -t ]; then
./testw
[
AES-encrypt-decrypt]
./testw
[
ecdsa_api_test]
#./testw [dkg-encr_sshares]
./testw
[
bls_sign]
#
./testw [bls_sign]
./testw
[
many_threads_test]
./testw
[
aes_dkg]
else
...
...
run_sgx/docker-compose.yml
View file @
a2c0c34a
...
...
@@ -17,6 +17,6 @@ services:
max-size
:
"
10m"
max-file
:
"
4"
restart
:
unless-stopped
command
:
-
t
command
:
-
s -d -y
run_sgx_sim/docker-compose.yml
View file @
a2c0c34a
...
...
@@ -14,5 +14,5 @@ services:
max-size
:
"
10m"
max-file
:
"
4"
restart
:
unless-stopped
command
:
-s -y
command
:
-s -y
-d
sgxwallet.c
View file @
a2c0c34a
...
...
@@ -44,10 +44,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
void
usage
()
{
fprintf
(
stderr
,
"usage: sgxwallet
\n
"
);
exit
(
1
);
fprintf
(
stderr
,
"usage: sgxwallet
\n
"
);
exit
(
1
);
}
sgx_launch_token_t
token
=
{
0
};
...
...
@@ -55,67 +54,74 @@ sgx_enclave_id_t eid;
sgx_status_t
status
;
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
[])
{
void
(
*
SEK_initializer
)();
SEK_initializer
=
init_SEK
;
bool
check_client_c
ert
=
true
;
bool
sign_automatically
=
false
;
int
opt
;
if
(
argc
>
1
&&
strlen
(
argv
[
1
])
==
1
)
{
fprintf
(
stderr
,
"option is too short %s
\n
"
,
argv
[
1
]);
exit
(
1
);
}
void
(
*
SEK_initializer
)();
SEK_initializer
=
init_SEK
;
bool
checkClientC
ert
=
true
;
bool
sign_automatically
=
false
;
int
opt
;
if
(
argc
>
1
&&
strlen
(
argv
[
1
])
==
1
)
{
fprintf
(
stderr
,
"option is too short %s
\n
"
,
argv
[
1
]);
exit
(
1
);
}
encryptKeys
=
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
);
}
case
'c'
:
check_client_cert
=
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
'?'
:
// fprintf(stderr, "unknown flag\n");
exit
(
1
);
default:
break
;
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
;
}
}
}
init_all
(
check_client_cert
,
sign_automatically
,
SEK_initializer
);
initAll
(
checkClientCert
,
sign_automatically
,
SEK_initializer
);
while
(
true
)
{
sleep
(
10
);
}
while
(
true
)
{
sleep
(
10
);
}
return
0
;
return
0
;
}
testw.cpp
View file @
a2c0c34a
...
...
@@ -124,7 +124,7 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
printDebugInfo
=
1
;
useHTTPS
=
0
;
autoconfirm
=
true
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
auto
key
=
encryptTestKey
();
REQUIRE
(
key
!=
nullptr
);
free
(
key
);
...
...
@@ -138,7 +138,7 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
useHTTPS
=
0
;
autoconfirm
=
true
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
//init_enclave();
...
...
@@ -552,7 +552,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
useHTTPS
=
0
;
printDebugInfo
=
1
;
cerr
<<
"test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
...
...
@@ -686,7 +686,7 @@ TEST_CASE("API test", "[api_test]") {
useHTTPS
=
0
;
//cerr << __GNUC__ << endl;
cerr
<<
"API test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
//HttpServer httpserver(1025);
//SGXWalletServer s(httpserver,
// JSONRPC_SERVER_V2); // hybrid server (json-rpc 1.0 & 2.0)
...
...
@@ -790,7 +790,7 @@ TEST_CASE("API test", "[api_test]") {
TEST_CASE
(
"getServerStatus test"
,
"[getServerStatus_test]"
)
{
autoconfirm
=
true
;
useHTTPS
=
0
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
REQUIRE
(
c
.
getServerStatus
()[
"status"
]
==
0
);
...
...
@@ -915,7 +915,7 @@ TEST_CASE("ManySimultaneousThreads", "[many_threads_test]") {
printDebugInfo
=
1
;
encryptKeys
=
1
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
vector
<
thread
>
threads
;
int
num_threads
=
4
;
...
...
@@ -937,7 +937,7 @@ TEST_CASE("ecdsa API test", "[ecdsa_api_test]") {
encryptKeys
=
1
;
cerr
<<
"ecdsa_api_test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
...
...
@@ -988,7 +988,7 @@ TEST_CASE("dkg API test", "[dkg_api_test]") {
useHTTPS
=
0
;
cerr
<<
"dkg_api_test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
...
...
@@ -1066,7 +1066,7 @@ TEST_CASE("isPolyExists test", "[is_poly_test]") {
useHTTPS
=
0
;
cerr
<<
"is_poly_test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
...
...
@@ -1098,7 +1098,7 @@ TEST_CASE("AES_DKG test", "[aes_dkg]") {
reset_db
();
cerr
<<
"test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
...
...
@@ -1228,7 +1228,7 @@ TEST_CASE("bls_sign_api test", "[bls_sign]") {
encryptKeys
=
1
;
cerr
<<
"test started"
<<
endl
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
...
...
@@ -1261,7 +1261,7 @@ TEST_CASE("AES encrypt/decrypt", "[AES-encrypt-decrypt]") {
printDebugInfo
=
1
;
useHTTPS
=
0
;
init
_a
ll
(
false
,
true
,
init_SEK
);
init
A
ll
(
false
,
true
,
init_SEK
);
//init_enclave();
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