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
df8ce3b6
Unverified
Commit
df8ce3b6
authored
Jun 21, 2020
by
Stan Kladko
Committed by
GitHub
Jun 21, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #113 from skalenetwork/SGX-2678-fix3
SKALE-2678-BLS-test-vectors
parents
eec3a72b
0355ff29
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
23 deletions
+33
-23
BLSCrypto.cpp
BLSCrypto.cpp
+0
-2
DockerfileBase
DockerfileBase
+1
-1
Log.h
Log.h
+5
-0
Makefile.am
Makefile.am
+1
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+18
-18
SGXWalletServer.hpp
SGXWalletServer.hpp
+6
-1
TestUtils.cpp
TestUtils.cpp
+1
-0
sgxwall.cpp
sgxwall.cpp
+1
-0
No files found.
BLSCrypto.cpp
View file @
df8ce3b6
...
@@ -257,8 +257,6 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
...
@@ -257,8 +257,6 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
strncpy
(
_sig
,
sig
.
c_str
(),
BUF_LEN
);
strncpy
(
_sig
,
sig
.
c_str
(),
BUF_LEN
);
printf
(
"_sig is: %s
\n
"
,
sig
.
c_str
());
//string sigShareStr = keyShare->signWithHelperSGXstr(hash, _signerIndex);
//string sigShareStr = keyShare->signWithHelperSGXstr(hash, _signerIndex);
//strncpy(_sig, sigShareStr.c_str(), BUF_LEN);
//strncpy(_sig, sigShareStr.c_str(), BUF_LEN);
...
...
DockerfileBase
View file @
df8ce3b6
...
@@ -12,7 +12,7 @@ RUN apt update && \
...
@@ -12,7 +12,7 @@ RUN apt update && \
apt install -yq --no-install-recommends python-yaml vim \
apt install -yq --no-install-recommends python-yaml vim \
telnet git ca-certificates build-essential ocaml ocamlbuild \
telnet git ca-certificates build-essential ocaml ocamlbuild \
automake autoconf libtool wget python libssl-dev libssl-dev \
automake autoconf libtool wget python libssl-dev libssl-dev \
libcurl4-openssl-dev protobuf-compiler git libprotobuf-dev \
libcurl4-openssl-dev protobuf-compiler git libprotobuf-dev
libboost-all-dev
\
alien cmake debhelper uuid-dev libxml2-dev ccache vim libprotobuf10 \
alien cmake debhelper uuid-dev libxml2-dev ccache vim libprotobuf10 \
yasm cmake flex bison libprocps-dev ccache autoconf texinfo libssl-dev \
yasm cmake flex bison libprocps-dev ccache autoconf texinfo libssl-dev \
libboost-all-dev libjsonrpccpp-dev libjsonrpccpp-tools && \
libboost-all-dev libjsonrpccpp-dev libjsonrpccpp-tools && \
...
...
Log.h
View file @
df8ce3b6
...
@@ -41,6 +41,9 @@
...
@@ -41,6 +41,9 @@
#include "common.h"
#include "common.h"
#include <mutex> // For std::unique_lock
#include <shared_mutex>
using
namespace
std
;
using
namespace
std
;
...
@@ -75,6 +78,8 @@ public:
...
@@ -75,6 +78,8 @@ public:
#define HANDLE_SGX_EXCEPTION(_RESULT_) catch (SGXException &__e) { Log::handleSGXException(_RESULT_, __e);} \
#define HANDLE_SGX_EXCEPTION(_RESULT_) catch (SGXException &__e) { Log::handleSGXException(_RESULT_, __e);} \
catch (exception &__e) {spdlog::error(__e.what()); _RESULT_["status"] = 1; _RESULT_["errorMessage"] = __e.what();}
catch (exception &__e) {spdlog::error(__e.what()); _RESULT_["status"] = 1; _RESULT_["errorMessage"] = __e.what();}
#define READ_LOCK(__M__) ReadLock __rlock(__M__);
#define WRITE_LOCK(__M__) WriteLock __wlock(__M__);
#define LOCK(__M__) lock_guard<recursive_mutex> lock(__M__);
#define LOCK(__M__) lock_guard<recursive_mutex> lock(__M__);
#endif
#endif
...
...
Makefile.am
View file @
df8ce3b6
...
@@ -105,7 +105,7 @@ sgxwallet_LDADD=-l$(SGX_URTS_LIB) -l$(SGX_UAE_SERVICE_LIB) -LlibBLS/deps/deps_in
...
@@ -105,7 +105,7 @@ sgxwallet_LDADD=-l$(SGX_URTS_LIB) -l$(SGX_UAE_SERVICE_LIB) -LlibBLS/deps/deps_in
-ljsonrpccpp-stub
-ljsonrpccpp-server
-ljsonrpccpp-client
-ljsonrpccpp-common
-ljsoncpp
-lmicrohttpd
\
-ljsonrpccpp-stub
-ljsonrpccpp-server
-ljsonrpccpp-client
-ljsonrpccpp-common
-ljsoncpp
-lmicrohttpd
\
intel-sgx-ssl/Linux/package/lib64/libsgx_usgxssl.a
\
intel-sgx-ssl/Linux/package/lib64/libsgx_usgxssl.a
\
intel-sgx-ssl/Linux/package/lib64/libsgx_tsgxssl_crypto.a
\
intel-sgx-ssl/Linux/package/lib64/libsgx_tsgxssl_crypto.a
\
-lgnutls
-lgcrypt
-lcurl
-lssl
-lcrypto
-lz
-lpthread
-lboost_system
-lboost_thread
-lgnutls
-lgcrypt
-lcurl
-lssl
-lcrypto
-lz
-lpthread
testw_SOURCES
=
testw.cpp
$(COMMON_SRC)
testw_SOURCES
=
testw.cpp
$(COMMON_SRC)
...
...
SGXWalletServer.cpp
View file @
df8ce3b6
...
@@ -662,17 +662,17 @@ Json::Value SGXWalletServer::getServerVersionImpl() {
...
@@ -662,17 +662,17 @@ Json::Value SGXWalletServer::getServerVersionImpl() {
Json
::
Value
SGXWalletServer
::
generateDKGPoly
(
const
string
&
_polyName
,
int
_t
)
{
Json
::
Value
SGXWalletServer
::
generateDKGPoly
(
const
string
&
_polyName
,
int
_t
)
{
LOCK
(
m
)
WRITE_
LOCK
(
m
)
return
generateDKGPolyImpl
(
_polyName
,
_t
);
return
generateDKGPolyImpl
(
_polyName
,
_t
);
}
}
Json
::
Value
SGXWalletServer
::
getVerificationVector
(
const
string
&
_polynomeName
,
int
_t
,
int
_n
)
{
Json
::
Value
SGXWalletServer
::
getVerificationVector
(
const
string
&
_polynomeName
,
int
_t
,
int
_n
)
{
LOCK
(
m
)
WRITE_
LOCK
(
m
)
return
getVerificationVectorImpl
(
_polynomeName
,
_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
(
m
)
WRITE_
LOCK
(
m
)
return
getSecretShareImpl
(
_polyName
,
_publicKeys
,
t
,
n
);
return
getSecretShareImpl
(
_polyName
,
_publicKeys
,
t
,
n
);
}
}
...
@@ -680,41 +680,41 @@ Json::Value
...
@@ -680,41 +680,41 @@ Json::Value
SGXWalletServer
::
dkgVerification
(
const
string
&
_publicShares
,
const
string
&
ethKeyName
,
const
string
&
SecretShare
,
SGXWalletServer
::
dkgVerification
(
const
string
&
_publicShares
,
const
string
&
ethKeyName
,
const
string
&
SecretShare
,
int
t
,
int
t
,
int
n
,
int
index
)
{
int
n
,
int
index
)
{
LOCK
(
m
)
WRITE_
LOCK
(
m
)
return
dkgVerificationImpl
(
_publicShares
,
ethKeyName
,
SecretShare
,
t
,
n
,
index
);
return
dkgVerificationImpl
(
_publicShares
,
ethKeyName
,
SecretShare
,
t
,
n
,
index
);
}
}
Json
::
Value
Json
::
Value
SGXWalletServer
::
createBLSPrivateKey
(
const
string
&
blsKeyName
,
const
string
&
ethKeyName
,
const
string
&
polyName
,
SGXWalletServer
::
createBLSPrivateKey
(
const
string
&
blsKeyName
,
const
string
&
ethKeyName
,
const
string
&
polyName
,
const
string
&
SecretShare
,
int
t
,
int
n
)
{
const
string
&
SecretShare
,
int
t
,
int
n
)
{
LOCK
(
m
)
WRITE_
LOCK
(
m
)
return
createBLSPrivateKeyImpl
(
blsKeyName
,
ethKeyName
,
polyName
,
SecretShare
,
t
,
n
);
return
createBLSPrivateKeyImpl
(
blsKeyName
,
ethKeyName
,
polyName
,
SecretShare
,
t
,
n
);
}
}
Json
::
Value
SGXWalletServer
::
getBLSPublicKeyShare
(
const
string
&
blsKeyName
)
{
Json
::
Value
SGXWalletServer
::
getBLSPublicKeyShare
(
const
string
&
blsKeyName
)
{
LOCK
(
m
)
READ_
LOCK
(
m
)
return
getBLSPublicKeyShareImpl
(
blsKeyName
);
return
getBLSPublicKeyShareImpl
(
blsKeyName
);
}
}
Json
::
Value
SGXWalletServer
::
generateECDSAKey
()
{
Json
::
Value
SGXWalletServer
::
generateECDSAKey
()
{
LOCK
(
m
)
WRITE_
LOCK
(
m
)
return
generateECDSAKeyImpl
();
return
generateECDSAKeyImpl
();
}
}
Json
::
Value
SGXWalletServer
::
renameECDSAKey
(
const
string
&
_keyName
,
const
string
&
_tmpKeyName
)
{
Json
::
Value
SGXWalletServer
::
renameECDSAKey
(
const
string
&
_keyName
,
const
string
&
_tmpKeyName
)
{
LOCK
(
m
)
WRITE_
LOCK
(
m
)
return
renameECDSAKeyImpl
(
_keyName
,
_tmpKeyName
);
return
renameECDSAKeyImpl
(
_keyName
,
_tmpKeyName
);
}
}
Json
::
Value
SGXWalletServer
::
getPublicECDSAKey
(
const
string
&
_keyName
)
{
Json
::
Value
SGXWalletServer
::
getPublicECDSAKey
(
const
string
&
_keyName
)
{
LOCK
(
m
)
READ_
LOCK
(
m
)
return
getPublicECDSAKeyImpl
(
_keyName
);
return
getPublicECDSAKeyImpl
(
_keyName
);
}
}
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHash
(
int
_base
,
const
string
&
_keyShareName
,
const
string
&
_messageHash
)
{
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHash
(
int
_base
,
const
string
&
_keyShareName
,
const
string
&
_messageHash
)
{
LOCK
(
m
)
READ_
LOCK
(
m
)
spdlog
::
debug
(
"MessageHash first {}"
,
_messageHash
);
spdlog
::
debug
(
"MessageHash first {}"
,
_messageHash
);
return
ecdsaSignMessageHashImpl
(
_base
,
_keyShareName
,
_messageHash
);
return
ecdsaSignMessageHashImpl
(
_base
,
_keyShareName
,
_messageHash
);
}
}
...
@@ -723,43 +723,43 @@ Json::Value SGXWalletServer::ecdsaSignMessageHash(int _base, const string &_keyS
...
@@ -723,43 +723,43 @@ Json::Value SGXWalletServer::ecdsaSignMessageHash(int _base, const string &_keyS
Json
::
Value
Json
::
Value
SGXWalletServer
::
importBLSKeyShare
(
const
string
&
_keyShare
,
const
string
&
_keyShareName
,
int
_t
,
int
_n
,
SGXWalletServer
::
importBLSKeyShare
(
const
string
&
_keyShare
,
const
string
&
_keyShareName
,
int
_t
,
int
_n
,
int
index
)
{
int
index
)
{
LOCK
(
m
)
WRITE_
LOCK
(
m
)
return
importBLSKeyShareImpl
(
_keyShare
,
_keyShareName
,
_t
,
_n
,
index
);
return
importBLSKeyShareImpl
(
_keyShare
,
_keyShareName
,
_t
,
_n
,
index
);
}
}
Json
::
Value
SGXWalletServer
::
blsSignMessageHash
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
_t
,
int
_n
,
Json
::
Value
SGXWalletServer
::
blsSignMessageHash
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
_t
,
int
_n
,
int
_signerIndex
)
{
int
_signerIndex
)
{
LOCK
(
m
)
READ_
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
(
m
)
WRITE_
LOCK
(
m
)
return
importECDSAKeyImpl
(
_key
,
_keyName
);
return
importECDSAKeyImpl
(
_key
,
_keyName
);
}
}
Json
::
Value
SGXWalletServer
::
complaintResponse
(
const
string
&
polyName
,
int
ind
)
{
Json
::
Value
SGXWalletServer
::
complaintResponse
(
const
string
&
polyName
,
int
ind
)
{
LOCK
(
m
)
WRITE_
LOCK
(
m
)
return
complaintResponseImpl
(
polyName
,
ind
);
return
complaintResponseImpl
(
polyName
,
ind
);
}
}
Json
::
Value
SGXWalletServer
::
multG2
(
const
string
&
x
)
{
Json
::
Value
SGXWalletServer
::
multG2
(
const
string
&
x
)
{
LOCK
(
m
)
WRITE_
LOCK
(
m
)
return
multG2Impl
(
x
);
return
multG2Impl
(
x
);
}
}
Json
::
Value
SGXWalletServer
::
isPolyExists
(
const
string
&
polyName
)
{
Json
::
Value
SGXWalletServer
::
isPolyExists
(
const
string
&
polyName
)
{
LOCK
(
m
)
WRITE_
LOCK
(
m
)
return
isPolyExistsImpl
(
polyName
);
return
isPolyExistsImpl
(
polyName
);
}
}
Json
::
Value
SGXWalletServer
::
getServerStatus
()
{
Json
::
Value
SGXWalletServer
::
getServerStatus
()
{
LOCK
(
m
)
READ_
LOCK
(
m
)
return
getServerStatusImpl
();
return
getServerStatusImpl
();
}
}
Json
::
Value
SGXWalletServer
::
getServerVersion
()
{
Json
::
Value
SGXWalletServer
::
getServerVersion
()
{
LOCK
(
m
)
READ_
LOCK
(
m
)
return
getServerVersionImpl
();
return
getServerVersionImpl
();
}
}
...
...
SGXWalletServer.hpp
View file @
df8ce3b6
...
@@ -24,7 +24,12 @@
...
@@ -24,7 +24,12 @@
#ifndef SGXWALLET_SGXWALLETSERVER_HPP
#ifndef SGXWALLET_SGXWALLETSERVER_HPP
#define SGXWALLET_SGXWALLETSERVER_HPP
#define SGXWALLET_SGXWALLETSERVER_HPP
#include <boost/thread/locks.hpp>
#include <boost/thread/shared_mutex.hpp>
typedef
boost
::
shared_mutex
Lock
;
typedef
boost
::
unique_lock
<
Lock
>
WriteLock
;
typedef
boost
::
shared_lock
<
Lock
>
ReadLock
;
#include <jsonrpccpp/server/connectors/httpserver.h>
#include <jsonrpccpp/server/connectors/httpserver.h>
#include <mutex>
#include <mutex>
...
@@ -40,7 +45,7 @@ class SGXWalletServer : public AbstractStubServer {
...
@@ -40,7 +45,7 @@ class SGXWalletServer : public AbstractStubServer {
recursive_mutex
m
;
Lock
m
;
static
shared_ptr
<
SGXWalletServer
>
server
;
static
shared_ptr
<
SGXWalletServer
>
server
;
static
shared_ptr
<
HttpServer
>
httpServer
;
static
shared_ptr
<
HttpServer
>
httpServer
;
...
...
TestUtils.cpp
View file @
df8ce3b6
...
@@ -376,6 +376,7 @@ void TestUtils::doDKG(StubClient &c, int n, int t,
...
@@ -376,6 +376,7 @@ void TestUtils::doDKG(StubClient &c, int n, int t,
CHECK_STATE
(
response
[
"status"
]
==
0
);
CHECK_STATE
(
response
[
"status"
]
==
0
);
pubBLSKeys
[
i
]
=
c
.
getBLSPublicKeyShare
(
blsName
);
pubBLSKeys
[
i
]
=
c
.
getBLSPublicKeyShare
(
blsName
);
CHECK_STATE
(
pubBLSKeys
[
i
][
"status"
]
==
0
);
CHECK_STATE
(
pubBLSKeys
[
i
][
"status"
]
==
0
);
}
}
for
(
int
i
=
0
;
i
<
t
;
i
++
)
{
for
(
int
i
=
0
;
i
<
t
;
i
++
)
{
...
...
sgxwall.cpp
View file @
df8ce3b6
...
@@ -207,6 +207,7 @@ int main(int argc, char *argv[]) {
...
@@ -207,6 +207,7 @@ int main(int argc, char *argv[]) {
schainID
=
2
;
schainID
=
2
;
dkgID
=
2
;
dkgID
=
2
;
TestUtils
::
doDKG
(
c
,
16
,
11
,
ecdsaKeyNames
,
blsKeyNames
,
schainID
,
dkgID
);
TestUtils
::
doDKG
(
c
,
16
,
11
,
ecdsaKeyNames
,
blsKeyNames
,
schainID
,
dkgID
);
SGXWallet
::
serializeKeys
(
ecdsaKeyNames
,
blsKeyNames
,
"sgx_data/16node.json"
);
SGXWallet
::
serializeKeys
(
ecdsaKeyNames
,
blsKeyNames
,
"sgx_data/16node.json"
);
...
...
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