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
aeb32822
Unverified
Commit
aeb32822
authored
Mar 26, 2020
by
Stan Kladko
Committed by
GitHub
Mar 26, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72 from skalenetwork/bug/SKALE-2345-hw-fails
Bug/skale 2345 hw fails
parents
6e7e4123
a3c8931c
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
263 additions
and
192 deletions
+263
-192
BLSCrypto.cpp
BLSCrypto.cpp
+10
-7
BLSCrypto.h
BLSCrypto.h
+10
-0
BLSCrypto.hpp
BLSCrypto.hpp
+0
-41
Dockerfile
Dockerfile
+1
-1
DockerfileSimulation
DockerfileSimulation
+2
-0
SGXWALLET_VERSION
SGXWALLET_VERSION
+1
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+6
-3
SGXWalletServer.hpp
SGXWalletServer.hpp
+1
-3
start.sh
docker/start.sh
+37
-20
docker-compose.yml
run_sgx/docker-compose.yml
+1
-1
run_skale_admin_tests.sh
run_skale_admin_tests.sh
+0
-7
testw.cpp
testw.cpp
+194
-108
No files found.
BLSCrypto.cpp
View file @
aeb32822
...
@@ -47,8 +47,6 @@
...
@@ -47,8 +47,6 @@
#include "SGXWalletServer.h"
#include "SGXWalletServer.h"
#include "BLSCrypto.h"
#include "BLSCrypto.h"
#include "BLSCrypto.hpp"
#include "ServerInit.h"
#include "ServerInit.h"
#include "RPCException.h"
#include "RPCException.h"
...
@@ -164,11 +162,16 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t
...
@@ -164,11 +162,16 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t
if
(
!
hex2carray
(
_hashHex
,
&
binLen
,
hash
->
data
()))
{
if
(
!
hex2carray
(
_hashHex
,
&
binLen
,
hash
->
data
()))
{
throw
RPCException
(
INVALID_HEX
,
"Invalid hash"
);
throw
RPCException
(
INVALID_HEX
,
"Invalid hash"
);
}
}
// assert(binLen == hash->size());
auto
keyShare
=
make_shared
<
BLSPrivateKeyShareSGX
>
(
keyStr
,
_t
,
_n
);
auto
keyShare
=
make_shared
<
BLSPrivateKeyShareSGX
>
(
keyStr
,
_t
,
_n
);
//cerr << "keyShare created" << endl;
// {
auto
sigShare
=
keyShare
->
signWithHelperSGX
(
hash
,
_signerIndex
);
auto
sigShare
=
keyShare
->
signWithHelperSGX
(
hash
,
_signerIndex
);
// }
auto
sigShareStr
=
sigShare
->
toString
();
auto
sigShareStr
=
sigShare
->
toString
();
...
@@ -309,7 +312,7 @@ bool bls_sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
...
@@ -309,7 +312,7 @@ bool bls_sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
}
}
}
}
shared_ptr
<
string
>
encryptBLSKeyShare2Hex
(
int
*
errStatus
,
char
*
err_string
,
const
char
*
_key
)
{
char
*
encryptBLSKeyShare2Hex
(
int
*
errStatus
,
char
*
err_string
,
const
char
*
_key
)
{
auto
keyArray
=
make_shared
<
vector
<
char
>>
(
BUF_LEN
,
0
);
auto
keyArray
=
make_shared
<
vector
<
char
>>
(
BUF_LEN
,
0
);
auto
encryptedKey
=
make_shared
<
vector
<
uint8_t
>>
(
BUF_LEN
,
0
);
auto
encryptedKey
=
make_shared
<
vector
<
uint8_t
>>
(
BUF_LEN
,
0
);
auto
errMsg
=
make_shared
<
vector
<
char
>>
(
BUF_LEN
,
0
);
auto
errMsg
=
make_shared
<
vector
<
char
>>
(
BUF_LEN
,
0
);
...
@@ -318,7 +321,7 @@ shared_ptr<string> encryptBLSKeyShare2Hex(int *errStatus, char *err_string, cons
...
@@ -318,7 +321,7 @@ shared_ptr<string> encryptBLSKeyShare2Hex(int *errStatus, char *err_string, cons
unsigned
int
encryptedLen
=
0
;
unsigned
int
encryptedLen
=
0
;
//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
);
spdlog
::
debug
(
"errStatus is {}"
,
*
errStatus
);
spdlog
::
debug
(
"errStatus is {}"
,
*
errStatus
);
...
@@ -336,11 +339,11 @@ shared_ptr<string> encryptBLSKeyShare2Hex(int *errStatus, char *err_string, cons
...
@@ -336,11 +339,11 @@ shared_ptr<string> encryptBLSKeyShare2Hex(int *errStatus, char *err_string, cons
}
}
vector
<
char
>
result
(
2
*
BUF_LEN
,
0
);
char
*
result
=
(
char
*
)
calloc
(
2
*
BUF_LEN
,
1
);
carray2Hex
(
encryptedKey
->
data
(),
encryptedLen
,
result
.
data
()
);
carray2Hex
(
encryptedKey
->
data
(),
encryptedLen
,
result
);
return
make_shared
<
string
>
(
result
.
data
())
;
return
result
;
}
}
char
*
decryptBLSKeyShareFromHex
(
int
*
errStatus
,
char
*
errMsg
,
const
char
*
_encryptedKey
)
{
char
*
decryptBLSKeyShareFromHex
(
int
*
errStatus
,
char
*
errMsg
,
const
char
*
_encryptedKey
)
{
...
...
BLSCrypto.h
View file @
aeb32822
...
@@ -30,6 +30,12 @@
...
@@ -30,6 +30,12 @@
#define EXTERNC
#define EXTERNC
#endif
#endif
//EXTERNC void init_all();
//
//EXTERNC void init_daemon();
//
//EXTERNC void init_enclave();
EXTERNC
bool
bls_sign
(
const
char
*
encryptedKeyHex
,
const
char
*
hashHex
,
size_t
t
,
size_t
n
,
EXTERNC
bool
bls_sign
(
const
char
*
encryptedKeyHex
,
const
char
*
hashHex
,
size_t
t
,
size_t
n
,
size_t
signerIndex
,
char
*
_sig
);
size_t
signerIndex
,
char
*
_sig
);
...
@@ -43,4 +49,8 @@ EXTERNC bool hex2carray2(const char * _hex, uint64_t *_bin_len,
...
@@ -43,4 +49,8 @@ EXTERNC bool hex2carray2(const char * _hex, uint64_t *_bin_len,
char
*
encryptBLSKeyShare2Hex
(
int
*
errStatus
,
char
*
err_string
,
const
char
*
_key
);
char
*
decryptBLSKeyShareFromHex
(
int
*
errStatus
,
char
*
errMsg
,
const
char
*
_encryptedKey
);
#endif //SGXWALLET_BLSCRYPTO_H
#endif //SGXWALLET_BLSCRYPTO_H
BLSCrypto.hpp
deleted
100644 → 0
View file @
6e7e4123
/*
Copyright (C) 2019-Present SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file BLSCrypto.hpp
@author Stan Kladko
@date 2019
*/
#ifndef SGXWALLET_BLSCRYPTO_HPP
#define SGXWALLET_BLSCRYPTO_HPP
#ifdef __cplusplus
#define EXTERNC extern "C"
#else
#define EXTERNC
#endif
using
namespace
std
;
shared_ptr
<
string
>
encryptBLSKeyShare2Hex
(
int
*
errStatus
,
char
*
err_string
,
const
char
*
_key
);
char
*
decryptBLSKeyShareFromHex
(
int
*
errStatus
,
char
*
errMsg
,
const
char
*
_encryptedKey
);
#endif //SGXWALLET_BLSCRYPTO_H
Dockerfile
View file @
aeb32822
FROM
skalenetwork/sgxwallet_base:latest
FROM
skalenetwork/sgxwallet_base:latest
WORKDIR
/usr/src/sdk
WORKDIR
/usr/src/sdk
RUN
touch
/var/hwmode
COPY
*.cpp ./
COPY
*.cpp ./
COPY
*.h ./
COPY
*.h ./
COPY
*.txt ./
COPY
*.txt ./
...
...
DockerfileSimulation
View file @
aeb32822
FROM skalenetwork/sgxwallet_base:latest
FROM skalenetwork/sgxwallet_base:latest
WORKDIR /usr/src/sdk
WORKDIR /usr/src/sdk
COPY *.cpp ./
COPY *.cpp ./
COPY *.h ./
COPY *.h ./
COPY *.txt ./
COPY *.txt ./
...
...
SGXWALLET_VERSION
View file @
aeb32822
#define SGXWALLET_VERSION "1.43.1"
#define SGXWALLET_VERSION "1.45.1"
\ No newline at end of file
\ No newline at end of file
SGXWalletServer.cpp
View file @
aeb32822
...
@@ -164,7 +164,7 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
...
@@ -164,7 +164,7 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
result
[
"encryptedKeyShare"
]
=
""
;
result
[
"encryptedKeyShare"
]
=
""
;
shared_ptr
<
string
>
encryptedKeyShareHex
=
nullptr
;
char
*
encryptedKeyShareHex
=
nullptr
;
try
{
try
{
...
@@ -178,15 +178,18 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
...
@@ -178,15 +178,18 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
throw
RPCException
(
errStatus
,
errMsg
);
throw
RPCException
(
errStatus
,
errMsg
);
}
}
result
[
"encryptedKeyShare"
]
=
*
encryptedKeyShareHex
;
result
[
"encryptedKeyShare"
]
=
string
(
encryptedKeyShareHex
)
;
writeKeyShare
(
_keyShareName
,
*
encryptedKeyShareHex
,
_index
,
n
,
t
);
writeKeyShare
(
_keyShareName
,
encryptedKeyShareHex
,
_index
,
n
,
t
);
}
catch
(
RPCException
&
_e
)
{
}
catch
(
RPCException
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
}
if
(
encryptedKeyShareHex
!=
nullptr
)
{
free
(
encryptedKeyShareHex
);
}
return
result
;
return
result
;
}
}
...
...
SGXWalletServer.hpp
View file @
aeb32822
...
@@ -25,11 +25,9 @@
...
@@ -25,11 +25,9 @@
#define SGXWALLET_SGXWALLETSERVER_HPP
#define SGXWALLET_SGXWALLETSERVER_HPP
#include <mutex>
#include "abstractstubserver.h"
#include "abstractstubserver.h"
#include <mutex>
#include "BLSCrypto.hpp"
using
namespace
jsonrpc
;
using
namespace
jsonrpc
;
using
namespace
std
;
using
namespace
std
;
...
...
docker/start.sh
View file @
aeb32822
#!/bin/bash
#!/bin/bash
set
-e
set
-v
source
/opt/intel/sgxsdk/environment
source
/opt/intel/sgxsdk/environment
cd
/usr/src/sdk
;
cd
/usr/src/sdk
;
echo
$1
if
[
-f
"/var/hwmode"
]
then
echo
"Running in SGX hardware mode"
export
LD_LIBRARY_PATH
=
${
LD_LIBRARY_PATH
}
:/opt/intel/sgxpsw/aesm/
jhid
-d
/opt/intel/sgxpsw/aesm/aesm_service &
pid
=
$!
sleep
2
else
echo
"Running in SGX simulation mode"
fi
if
[
"
$1
"
=
-t
]
;
then
if
[
"
$1
"
=
-t
]
;
then
set
-e
echo
"Test run requested"
./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 @
aeb32822
version
:
'
3'
version
:
'
3'
services
:
services
:
sgxwallet
:
sgxwallet
:
image
:
skalenetwork/sgxwallet:latest
image
:
skalenetwork/sgxwallet:latest
_commit
ports
:
ports
:
-
"
1026:1026"
-
"
1026:1026"
-
"
1027:1027"
-
"
1027:1027"
...
...
run_skale_admin_tests.sh
deleted
100755 → 0
View file @
6e7e4123
#!/bin/bash
cd
../skale-admin
source
skale-admin/bin/activate
docker stop
$(
docker ps
-a
-q
)
docker pull skalenetwork/sgxwalletsim:latest
ETH_PRIVATE_KEY
=
3dd85d854e41db7585080dfdb90f88a83f0c70e229c509a4a1da63d0c82d5ad0
MANAGER_BRANCH
=
delegation-fix bash ./scripts/deploy_manager.sh
ETH_PRIVATE_KEY
=
3dd85d854e41db7585080dfdb90f88a83f0c70e229c509a4a1da63d0c82d5ad0
IMA_ENDPOINT
=
http://localhost:1000
SCHAIN_TYPE
=
test2 bash ./scripts/run_tests.sh
testw.cpp
View file @
aeb32822
This diff is collapsed.
Click to expand it.
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