Unverified Commit df8ce3b6 authored by Stan Kladko's avatar Stan Kladko Committed by GitHub

Merge pull request #113 from skalenetwork/SGX-2678-fix3

SKALE-2678-BLS-test-vectors
1 merge request!1Develop
......@@ -257,8 +257,6 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
strncpy(_sig, sig.c_str(), BUF_LEN);
printf("_sig is: %s\n", sig.c_str());
//string sigShareStr = keyShare->signWithHelperSGXstr(hash, _signerIndex);
//strncpy(_sig, sigShareStr.c_str(), BUF_LEN);
......
......@@ -12,7 +12,7 @@ RUN apt update && \
apt install -yq --no-install-recommends python-yaml vim \
telnet git ca-certificates build-essential ocaml ocamlbuild \
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 \
yasm cmake flex bison libprocps-dev ccache autoconf texinfo libssl-dev \
libboost-all-dev libjsonrpccpp-dev libjsonrpccpp-tools && \
......
......@@ -41,6 +41,9 @@
#include "common.h"
#include <mutex> // For std::unique_lock
#include <shared_mutex>
using namespace std;
......@@ -75,6 +78,8 @@ public:
#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();}
#define READ_LOCK(__M__) ReadLock __rlock(__M__);
#define WRITE_LOCK(__M__) WriteLock __wlock(__M__);
#define LOCK(__M__) lock_guard<recursive_mutex> lock(__M__);
#endif
......
......@@ -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 \
intel-sgx-ssl/Linux/package/lib64/libsgx_usgxssl.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)
......
......@@ -662,17 +662,17 @@ Json::Value SGXWalletServer::getServerVersionImpl() {
Json::Value SGXWalletServer::generateDKGPoly(const string &_polyName, int _t) {
LOCK(m)
WRITE_LOCK(m)
return generateDKGPolyImpl(_polyName, _t);
}
Json::Value SGXWalletServer::getVerificationVector(const string &_polynomeName, int _t, int _n) {
LOCK(m)
WRITE_LOCK(m)
return getVerificationVectorImpl(_polynomeName, _t, _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);
}
......@@ -680,41 +680,41 @@ Json::Value
SGXWalletServer::dkgVerification(const string &_publicShares, const string &ethKeyName, const string &SecretShare,
int t,
int n, int index) {
LOCK(m)
WRITE_LOCK(m)
return dkgVerificationImpl(_publicShares, ethKeyName, SecretShare, t, n, index);
}
Json::Value
SGXWalletServer::createBLSPrivateKey(const string &blsKeyName, const string &ethKeyName, const string &polyName,
const string &SecretShare, int t, int n) {
LOCK(m)
WRITE_LOCK(m)
return createBLSPrivateKeyImpl(blsKeyName, ethKeyName, polyName, SecretShare, t, n);
}
Json::Value SGXWalletServer::getBLSPublicKeyShare(const string &blsKeyName) {
LOCK(m)
READ_LOCK(m)
return getBLSPublicKeyShareImpl(blsKeyName);
}
Json::Value SGXWalletServer::generateECDSAKey() {
LOCK(m)
WRITE_LOCK(m)
return generateECDSAKeyImpl();
}
Json::Value SGXWalletServer::renameECDSAKey(const string &_keyName, const string &_tmpKeyName) {
LOCK(m)
WRITE_LOCK(m)
return renameECDSAKeyImpl(_keyName, _tmpKeyName);
}
Json::Value SGXWalletServer::getPublicECDSAKey(const string &_keyName) {
LOCK(m)
READ_LOCK(m)
return getPublicECDSAKeyImpl(_keyName);
}
Json::Value SGXWalletServer::ecdsaSignMessageHash(int _base, const string &_keyShareName, const string &_messageHash) {
LOCK(m)
READ_LOCK(m)
spdlog::debug("MessageHash first {}", _messageHash);
return ecdsaSignMessageHashImpl(_base, _keyShareName, _messageHash);
}
......@@ -723,43 +723,43 @@ Json::Value SGXWalletServer::ecdsaSignMessageHash(int _base, const string &_keyS
Json::Value
SGXWalletServer::importBLSKeyShare(const string &_keyShare, const string &_keyShareName, int _t, int _n,
int index) {
LOCK(m)
WRITE_LOCK(m)
return importBLSKeyShareImpl(_keyShare, _keyShareName, _t, _n, index);
}
Json::Value SGXWalletServer::blsSignMessageHash(const string &_keyShareName, const string &_messageHash, int _t, int _n,
int _signerIndex) {
LOCK(m)
READ_LOCK(m)
return blsSignMessageHashImpl(_keyShareName, _messageHash, _t, _n, _signerIndex);
}
Json::Value SGXWalletServer::importECDSAKey(const string &_key, const string &_keyName) {
LOCK(m)
WRITE_LOCK(m)
return importECDSAKeyImpl(_key, _keyName);
}
Json::Value SGXWalletServer::complaintResponse(const string &polyName, int ind) {
LOCK(m)
WRITE_LOCK(m)
return complaintResponseImpl(polyName, ind);
}
Json::Value SGXWalletServer::multG2(const string &x) {
LOCK(m)
WRITE_LOCK(m)
return multG2Impl(x);
}
Json::Value SGXWalletServer::isPolyExists(const string &polyName) {
LOCK(m)
WRITE_LOCK(m)
return isPolyExistsImpl(polyName);
}
Json::Value SGXWalletServer::getServerStatus() {
LOCK(m)
READ_LOCK(m)
return getServerStatusImpl();
}
Json::Value SGXWalletServer::getServerVersion() {
LOCK(m)
READ_LOCK(m)
return getServerVersionImpl();
}
......
......@@ -24,7 +24,12 @@
#ifndef 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 <mutex>
......@@ -40,7 +45,7 @@ class SGXWalletServer : public AbstractStubServer {
recursive_mutex m;
Lock m;
static shared_ptr<SGXWalletServer> server;
static shared_ptr<HttpServer> httpServer;
......
......@@ -376,6 +376,7 @@ void TestUtils::doDKG(StubClient &c, int n, int t,
CHECK_STATE(response["status"] == 0);
pubBLSKeys[i] = c.getBLSPublicKeyShare(blsName);
CHECK_STATE(pubBLSKeys[i]["status"] == 0);
}
for (int i = 0; i < t; i++) {
......
......@@ -207,6 +207,7 @@ int main(int argc, char *argv[]) {
schainID = 2;
dkgID = 2;
TestUtils::doDKG(c, 16, 11, ecdsaKeyNames, blsKeyNames, schainID, dkgID);
SGXWallet::serializeKeys(ecdsaKeyNames, blsKeyNames, "sgx_data/16node.json");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment