SKALE-4161 format code

parent b60b5e99
...@@ -73,7 +73,6 @@ string TestUtils::stringFromFr(libff::alt_bn128_Fr &el) { ...@@ -73,7 +73,6 @@ string TestUtils::stringFromFr(libff::alt_bn128_Fr &el) {
return string(arr); return string(arr);
} }
string TestUtils::convertDecToHex(string dec, int numBytes) { string TestUtils::convertDecToHex(string dec, int numBytes) {
mpz_t num; mpz_t num;
mpz_init(num); mpz_init(num);
...@@ -190,7 +189,6 @@ void TestUtils::sendRPCRequest() { ...@@ -190,7 +189,6 @@ void TestUtils::sendRPCRequest() {
CHECK_STATE(sig["status"].asInt() == 0); CHECK_STATE(sig["status"].asInt() == 0);
} }
CHECK_STATE(ethKeys[i]["status"] == 0); CHECK_STATE(ethKeys[i]["status"] == 0);
string polyName = string polyName =
"POLY:SCHAIN_ID:" + to_string(schainID) + ":NODE_ID:" + to_string(i) + ":DKG_ID:" + to_string(dkgID); "POLY:SCHAIN_ID:" + to_string(schainID) + ":NODE_ID:" + to_string(i) + ":DKG_ID:" + to_string(dkgID);
...@@ -250,7 +248,6 @@ void TestUtils::sendRPCRequest() { ...@@ -250,7 +248,6 @@ void TestUtils::sendRPCRequest() {
publicShares["publicShares"][i] = pubShares[i]; publicShares["publicShares"][i] = pubShares[i];
} }
Json::Value blsPublicKeys; Json::Value blsPublicKeys;
for (int i6 = 0; i6 <= testCount; i6++) { for (int i6 = 0; i6 <= testCount; i6++) {
...@@ -263,7 +260,6 @@ void TestUtils::sendRPCRequest() { ...@@ -263,7 +260,6 @@ void TestUtils::sendRPCRequest() {
string blsName = "BLS_KEY" + polyNames[i].substr(4); string blsName = "BLS_KEY" + polyNames[i].substr(4);
string secretShare = secretShares[i]["secretShare"].asString(); string secretShare = secretShares[i]["secretShare"].asString();
auto response = c.createBLSPrivateKey(blsName, ethKeys[i]["keyName"].asString(), polyNames[i], secShares[i], auto response = c.createBLSPrivateKey(blsName, ethKeys[i]["keyName"].asString(), polyNames[i], secShares[i],
t, n); t, n);
CHECK_STATE(response["status"] == 0); CHECK_STATE(response["status"] == 0);
...@@ -399,14 +395,10 @@ void TestUtils::sendRPCRequestV2() { ...@@ -399,14 +395,10 @@ void TestUtils::sendRPCRequestV2() {
sigShareSet.merge(); sigShareSet.merge();
} }
void TestUtils::sendRPCRequestZMQ() { void TestUtils::sendRPCRequestZMQ() {
HttpClient client(RPC_ENDPOINT); HttpClient client(RPC_ENDPOINT);
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
int n = 16, t = 16; int n = 16, t = 16;
Json::Value ethKeys[n]; Json::Value ethKeys[n];
Json::Value verifVects[n]; Json::Value verifVects[n];
......
...@@ -65,7 +65,6 @@ ...@@ -65,7 +65,6 @@
#define PRINT_SRC_LINE cerr << "Executing line " << to_string(__LINE__) << endl; #define PRINT_SRC_LINE cerr << "Executing line " << to_string(__LINE__) << endl;
using namespace jsonrpc; using namespace jsonrpc;
using namespace std; using namespace std;
...@@ -97,7 +96,6 @@ public: ...@@ -97,7 +96,6 @@ public:
} }
}; };
class TestFixtureZMQSign { class TestFixtureZMQSign {
public: public:
TestFixtureZMQSign() { TestFixtureZMQSign() {
...@@ -112,7 +110,6 @@ public: ...@@ -112,7 +110,6 @@ public:
} }
}; };
class TestFixtureNoResetFromBackup { class TestFixtureNoResetFromBackup {
public: public:
TestFixtureNoResetFromBackup() { TestFixtureNoResetFromBackup() {
...@@ -127,7 +124,6 @@ public: ...@@ -127,7 +124,6 @@ public:
} }
}; };
class TestFixtureNoReset { class TestFixtureNoReset {
public: public:
TestFixtureNoReset() { TestFixtureNoReset() {
...@@ -161,7 +157,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA AES keygen and signature test", "[ecdsa-aes ...@@ -161,7 +157,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA AES keygen and signature test", "[ecdsa-aes
vector<char> signatureS(BUF_LEN, 0); vector<char> signatureS(BUF_LEN, 0);
uint8_t signatureV = 0; uint8_t signatureV = 0;
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
PRINT_SRC_LINE PRINT_SRC_LINE
status = trustedEcdsaSign(eid, &errStatus, errMsg.data(), encrPrivKey.data(), encLen, status = trustedEcdsaSign(eid, &errStatus, errMsg.data(), encrPrivKey.data(), encLen,
...@@ -174,7 +169,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA AES keygen and signature test", "[ecdsa-aes ...@@ -174,7 +169,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA AES keygen and signature test", "[ecdsa-aes
} }
TEST_CASE_METHOD(TestFixture, "ECDSA AES key gen", "[ecdsa-aes-key-gen]") { TEST_CASE_METHOD(TestFixture, "ECDSA AES key gen", "[ecdsa-aes-key-gen]") {
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
int errStatus = 0; int errStatus = 0;
...@@ -191,7 +185,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA AES key gen", "[ecdsa-aes-key-gen]") { ...@@ -191,7 +185,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA AES key gen", "[ecdsa-aes-key-gen]") {
REQUIRE(errStatus == SGX_SUCCESS); REQUIRE(errStatus == SGX_SUCCESS);
} }
TEST_CASE_METHOD(TestFixture, "ECDSA AES get public key", "[ecdsa-aes-get-pub-key]") { TEST_CASE_METHOD(TestFixture, "ECDSA AES get public key", "[ecdsa-aes-get-pub-key]") {
int errStatus = 0; int errStatus = 0;
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
...@@ -219,7 +212,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA AES get public key", "[ecdsa-aes-get-pub-ke ...@@ -219,7 +212,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA AES get public key", "[ecdsa-aes-get-pub-ke
REQUIRE(errStatus == SGX_SUCCESS); REQUIRE(errStatus == SGX_SUCCESS);
} }
/* Do later /* Do later
TEST_CASE_METHOD("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") { TEST_CASE_METHOD("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
resetDB(); resetDB();
...@@ -251,7 +243,6 @@ TEST_CASE_METHOD("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") { ...@@ -251,7 +243,6 @@ TEST_CASE_METHOD("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
*/ */
string genECDSAKeyAPI(StubClient &_c) { string genECDSAKeyAPI(StubClient &_c) {
Json::Value genKey = _c.generateECDSAKey(); Json::Value genKey = _c.generateECDSAKey();
CHECK_STATE(genKey["status"].asInt() == 0); CHECK_STATE(genKey["status"].asInt() == 0);
...@@ -281,10 +272,8 @@ TEST_CASE_METHOD(TestFixture, "ECDSA key gen API", "[ecdsa-key-gen-api]") { ...@@ -281,10 +272,8 @@ TEST_CASE_METHOD(TestFixture, "ECDSA key gen API", "[ecdsa-key-gen-api]") {
auto keyName = genECDSAKeyAPI(c); auto keyName = genECDSAKeyAPI(c);
Json::Value sig = c.ecdsaSignMessageHash(10, keyName, SAMPLE_HASH); Json::Value sig = c.ecdsaSignMessageHash(10, keyName, SAMPLE_HASH);
for (int i = 0; i <= 20; i++) { for (int i = 0; i <= 20; i++) {
try { try {
PRINT_SRC_LINE PRINT_SRC_LINE
...@@ -308,7 +297,6 @@ TEST_CASE_METHOD(TestFixture, "BLS key encrypt", "[bls-key-encrypt]") { ...@@ -308,7 +297,6 @@ TEST_CASE_METHOD(TestFixture, "BLS key encrypt", "[bls-key-encrypt]") {
sleep(3); sleep(3);
} }
TEST_CASE_METHOD(TestFixture, "DKG AES gen test", "[dkg-aes-gen]") { TEST_CASE_METHOD(TestFixture, "DKG AES gen test", "[dkg-aes-gen]") {
vector <uint8_t> encryptedDKGSecret(BUF_LEN, 0); vector <uint8_t> encryptedDKGSecret(BUF_LEN, 0);
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
...@@ -333,7 +321,6 @@ TEST_CASE_METHOD(TestFixture, "DKG AES gen test", "[dkg-aes-gen]") { ...@@ -333,7 +321,6 @@ TEST_CASE_METHOD(TestFixture, "DKG AES gen test", "[dkg-aes-gen]") {
sleep(3); sleep(3);
} }
TEST_CASE_METHOD(TestFixture, "DKG AES public shares test", "[dkg-aes-pub-shares]") { TEST_CASE_METHOD(TestFixture, "DKG AES public shares test", "[dkg-aes-pub-shares]") {
vector <uint8_t> encryptedDKGSecret(BUF_LEN, 0); vector <uint8_t> encryptedDKGSecret(BUF_LEN, 0);
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
...@@ -443,7 +430,6 @@ TEST_CASE_METHOD(TestFixture, "DKG AES encrypted secret shares version 2 test", ...@@ -443,7 +430,6 @@ TEST_CASE_METHOD(TestFixture, "DKG AES encrypted secret shares version 2 test",
REQUIRE(errStatus == SGX_SUCCESS); REQUIRE(errStatus == SGX_SUCCESS);
} }
/* /*
* ( "verification test", "[verify]" ) { * ( "verification test", "[verify]" ) {
...@@ -459,11 +445,6 @@ TEST_CASE_METHOD(TestFixture, "DKG AES encrypted secret shares version 2 test", ...@@ -459,11 +445,6 @@ TEST_CASE_METHOD(TestFixture, "DKG AES encrypted secret shares version 2 test",
}*/ }*/
TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") { TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
HttpClient client(RPC_ENDPOINT); HttpClient client(RPC_ENDPOINT);
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
...@@ -506,7 +487,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS V2 test", "[dkg-bls-v2]") { ...@@ -506,7 +487,6 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS V2 test", "[dkg-bls-v2]") {
TestUtils::doDKGV2(c, 16, 5, ecdsaKeyNames, blsKeyNames, schainID, dkgID); TestUtils::doDKGV2(c, 16, 5, ecdsaKeyNames, blsKeyNames, schainID, dkgID);
} }
TEST_CASE_METHOD(TestFixture, "DKG_BLS ZMQ test", "[dkgblszmq]") { TEST_CASE_METHOD(TestFixture, "DKG_BLS ZMQ test", "[dkgblszmq]") {
HttpClient client(RPC_ENDPOINT); HttpClient client(RPC_ENDPOINT);
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
...@@ -594,7 +574,6 @@ TEST_CASE_METHOD(TestFixture, "Get ServerVersion", "[get-server-version]") { ...@@ -594,7 +574,6 @@ TEST_CASE_METHOD(TestFixture, "Get ServerVersion", "[get-server-version]") {
sleep(3); sleep(3);
} }
TEST_CASE_METHOD(TestFixtureHTTPS, "Cert request sign", "[cert-sign]") { TEST_CASE_METHOD(TestFixtureHTTPS, "Cert request sign", "[cert-sign]") {
PRINT_SRC_LINE PRINT_SRC_LINE
...@@ -617,15 +596,12 @@ TEST_CASE_METHOD(TestFixtureHTTPS, "Cert request sign", "[cert-sign]") { ...@@ -617,15 +596,12 @@ TEST_CASE_METHOD(TestFixtureHTTPS, "Cert request sign", "[cert-sign]") {
REQUIRE(result["status"] == 0); REQUIRE(result["status"] == 0);
PRINT_SRC_LINE PRINT_SRC_LINE
result = SGXRegistrationServer::getServer()->SignCertificate("Haha"); result = SGXRegistrationServer::getServer()->SignCertificate("Haha");
REQUIRE(result["status"] != 0); REQUIRE(result["status"] != 0);
} }
TEST_CASE_METHOD(TestFixture, "DKG API V2 test", "[dkg-api-v2]") { TEST_CASE_METHOD(TestFixture, "DKG API V2 test", "[dkg-api-v2]") {
HttpClient client(RPC_ENDPOINT); HttpClient client(RPC_ENDPOINT);
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
...@@ -705,8 +681,6 @@ TEST_CASE_METHOD(TestFixture, "PolyExists test", "[dkg-poly-exists]") { ...@@ -705,8 +681,6 @@ TEST_CASE_METHOD(TestFixture, "PolyExists test", "[dkg-poly-exists]") {
REQUIRE(!polyDoesNotExist["IsExist"].asBool()); REQUIRE(!polyDoesNotExist["IsExist"].asBool());
} }
TEST_CASE_METHOD(TestFixture, "AES_DKG V2 test", "[aes-dkg-v2]") { TEST_CASE_METHOD(TestFixture, "AES_DKG V2 test", "[aes-dkg-v2]") {
HttpClient client(RPC_ENDPOINT); HttpClient client(RPC_ENDPOINT);
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
...@@ -831,8 +805,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG V2 test", "[aes-dkg-v2]") { ...@@ -831,8 +805,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG V2 test", "[aes-dkg-v2]") {
string hash = SAMPLE_HASH; string hash = SAMPLE_HASH;
auto hash_arr = make_shared < array < uint8_t, auto hash_arr = make_shared < array < uint8_t, 32 > > ();
32 > > ();
uint64_t binLen; uint64_t binLen;
...@@ -846,8 +819,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG V2 test", "[aes-dkg-v2]") { ...@@ -846,8 +819,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG V2 test", "[aes-dkg-v2]") {
string endName = polyNames[i].substr(4); string endName = polyNames[i].substr(4);
string blsName = "BLS_KEY" + polyNames[i].substr(4); string blsName = "BLS_KEY" + polyNames[i].substr(4);
auto response = c.createBLSPrivateKeyV2(blsName, ethKeys[i]["keyName"].asString(), polyNames[i], secShares[i], auto response = c.createBLSPrivateKeyV2(blsName, ethKeys[i]["keyName"].asString(), polyNames[i], secShares[i],
t, t, n);
n);
REQUIRE(response["status"] == 0); REQUIRE(response["status"] == 0);
PRINT_SRC_LINE PRINT_SRC_LINE
...@@ -902,8 +874,6 @@ TEST_CASE_METHOD(TestFixture, "AES encrypt/decrypt", "[aes-encrypt-decrypt]") { ...@@ -902,8 +874,6 @@ TEST_CASE_METHOD(TestFixture, "AES encrypt/decrypt", "[aes-encrypt-decrypt]") {
sleep(3); sleep(3);
} }
TEST_CASE_METHOD(TestFixture, "Many threads ecdsa dkg v2 bls", "[many-threads-crypto-v2]") { TEST_CASE_METHOD(TestFixture, "Many threads ecdsa dkg v2 bls", "[many-threads-crypto-v2]") {
vector <thread> threads; vector <thread> threads;
int num_threads = 4; int num_threads = 4;
...@@ -916,8 +886,6 @@ TEST_CASE_METHOD(TestFixture, "Many threads ecdsa dkg v2 bls", "[many-threads-cr ...@@ -916,8 +886,6 @@ TEST_CASE_METHOD(TestFixture, "Many threads ecdsa dkg v2 bls", "[many-threads-cr
} }
} }
TEST_CASE_METHOD(TestFixture, "First run", "[first-run]") { TEST_CASE_METHOD(TestFixture, "First run", "[first-run]") {
HttpClient client(RPC_ENDPOINT); HttpClient client(RPC_ENDPOINT);
...@@ -935,8 +903,6 @@ TEST_CASE_METHOD(TestFixture, "First run", "[first-run]") { ...@@ -935,8 +903,6 @@ TEST_CASE_METHOD(TestFixture, "First run", "[first-run]") {
} }
sleep(3); sleep(3);
} }
TEST_CASE_METHOD(TestFixtureNoReset, "Second run", "[second-run]") { TEST_CASE_METHOD(TestFixtureNoReset, "Second run", "[second-run]") {
...@@ -959,7 +925,6 @@ TEST_CASE_METHOD(TestFixtureNoReset, "Second run", "[second-run]") { ...@@ -959,7 +925,6 @@ TEST_CASE_METHOD(TestFixtureNoReset, "Second run", "[second-run]") {
} }
} }
TEST_CASE_METHOD(TestFixtureZMQSign, "ZMQ-ecdsa", "[zmq-ecdsa]") { TEST_CASE_METHOD(TestFixtureZMQSign, "ZMQ-ecdsa", "[zmq-ecdsa]") {
HttpClient htp(RPC_ENDPOINT); HttpClient htp(RPC_ENDPOINT);
...@@ -977,10 +942,8 @@ TEST_CASE_METHOD(TestFixtureZMQSign, "ZMQ-ecdsa", "[zmq-ecdsa]") { ...@@ -977,10 +942,8 @@ TEST_CASE_METHOD(TestFixtureZMQSign, "ZMQ-ecdsa", "[zmq-ecdsa]") {
int end = 10000000; int end = 10000000;
string sh = string(SAMPLE_HASH); string sh = string(SAMPLE_HASH);
std::vector <std::thread> workers; std::vector <std::thread> workers;
PRINT_SRC_LINE PRINT_SRC_LINE
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
...@@ -1003,6 +966,4 @@ TEST_CASE_METHOD(TestFixtureZMQSign, "ZMQ-ecdsa", "[zmq-ecdsa]") { ...@@ -1003,6 +966,4 @@ TEST_CASE_METHOD(TestFixtureZMQSign, "ZMQ-ecdsa", "[zmq-ecdsa]") {
} }
TEST_CASE_METHOD(TestFixtureNoResetFromBackup, "Backup restore", "[backup-restore]") {}
TEST_CASE_METHOD(TestFixtureNoResetFromBackup, "Backup restore", "[backup-restore]") {
}
...@@ -57,12 +57,10 @@ shared_ptr <ZMQMessage> ZMQClient::doRequestReply(Json::Value &_req) { ...@@ -57,12 +57,10 @@ shared_ptr <ZMQMessage> ZMQClient::doRequestReply(Json::Value &_req) {
string reqStr = fastWriter.write(_req); string reqStr = fastWriter.write(_req);
reqStr = reqStr.substr(0, reqStr.size() - 1); reqStr = reqStr.substr(0, reqStr.size() - 1);
CHECK_STATE(reqStr.front() == '{'); CHECK_STATE(reqStr.front() == '{');
CHECK_STATE(reqStr.at(reqStr.size() - 1) == '}'); CHECK_STATE(reqStr.at(reqStr.size() - 1) == '}');
auto resultStr = doZmqRequestReply(reqStr); auto resultStr = doZmqRequestReply(reqStr);
try { try {
...@@ -71,7 +69,6 @@ shared_ptr <ZMQMessage> ZMQClient::doRequestReply(Json::Value &_req) { ...@@ -71,7 +69,6 @@ shared_ptr <ZMQMessage> ZMQClient::doRequestReply(Json::Value &_req) {
CHECK_STATE(resultStr.front() == '{') CHECK_STATE(resultStr.front() == '{')
CHECK_STATE(resultStr.back() == '}') CHECK_STATE(resultStr.back() == '}')
return ZMQMessage::parse(resultStr.c_str(), resultStr.size(), false, false); return ZMQMessage::parse(resultStr.c_str(), resultStr.size(), false, false);
} catch (std::exception &e) { } catch (std::exception &e) {
spdlog::error(string("Error in doRequestReply:") + e.what()); spdlog::error(string("Error in doRequestReply:") + e.what());
...@@ -80,11 +77,8 @@ shared_ptr <ZMQMessage> ZMQClient::doRequestReply(Json::Value &_req) { ...@@ -80,11 +77,8 @@ shared_ptr <ZMQMessage> ZMQClient::doRequestReply(Json::Value &_req) {
spdlog::error("Error in doRequestReply"); spdlog::error("Error in doRequestReply");
throw; throw;
} }
} }
string ZMQClient::doZmqRequestReply(string &_req) { string ZMQClient::doZmqRequestReply(string &_req) {
stringstream request; stringstream request;
...@@ -134,8 +128,6 @@ string ZMQClient::readFileIntoString(const string &_fileName) { ...@@ -134,8 +128,6 @@ string ZMQClient::readFileIntoString(const string &_fileName) {
return str; return str;
} }
void ZMQClient::verifySig(EVP_PKEY* _pubkey, const string& _str, const string& _sig) { void ZMQClient::verifySig(EVP_PKEY* _pubkey, const string& _str, const string& _sig) {
CHECK_STATE(_pubkey); CHECK_STATE(_pubkey);
...@@ -167,8 +159,6 @@ void ZMQClient::verifySig(EVP_PKEY* _pubkey, const string& _str, const string& _ ...@@ -167,8 +159,6 @@ void ZMQClient::verifySig(EVP_PKEY* _pubkey, const string& _str, const string& _
/* First call EVP_DigestSignFinal with a NULL sig parameter to obtain the length of the /* First call EVP_DigestSignFinal with a NULL sig parameter to obtain the length of the
* signature. Length is returned in slen */ * signature. Length is returned in slen */
CHECK_STATE2(EVP_DigestVerifyFinal(mdctx, binSig.data(), binLen) == 1, CHECK_STATE2(EVP_DigestVerifyFinal(mdctx, binSig.data(), binLen) == 1,
ZMQ_COULD_NOT_VERIFY_SIG); ZMQ_COULD_NOT_VERIFY_SIG);
...@@ -177,7 +167,6 @@ void ZMQClient::verifySig(EVP_PKEY* _pubkey, const string& _str, const string& _ ...@@ -177,7 +167,6 @@ void ZMQClient::verifySig(EVP_PKEY* _pubkey, const string& _str, const string& _
return; return;
} }
string ZMQClient::signString(EVP_PKEY* _pkey, const string& _str) { string ZMQClient::signString(EVP_PKEY* _pkey, const string& _str) {
CHECK_STATE(_pkey); CHECK_STATE(_pkey);
...@@ -186,8 +175,6 @@ string ZMQClient::signString(EVP_PKEY* _pkey, const string& _str) { ...@@ -186,8 +175,6 @@ string ZMQClient::signString(EVP_PKEY* _pkey, const string& _str) {
static std::regex r("\\s+"); static std::regex r("\\s+");
auto msgToSign = std::regex_replace(_str, r, ""); auto msgToSign = std::regex_replace(_str, r, "");
EVP_MD_CTX *mdctx = NULL; EVP_MD_CTX *mdctx = NULL;
int ret = 0; int ret = 0;
unsigned char *signature = NULL; unsigned char *signature = NULL;
...@@ -196,10 +183,8 @@ string ZMQClient::signString(EVP_PKEY* _pkey, const string& _str) { ...@@ -196,10 +183,8 @@ string ZMQClient::signString(EVP_PKEY* _pkey, const string& _str) {
CHECK_STATE(mdctx = EVP_MD_CTX_create()); CHECK_STATE(mdctx = EVP_MD_CTX_create());
CHECK_STATE((EVP_DigestSignInit(mdctx, NULL, EVP_sha256(), NULL, _pkey) == 1)); CHECK_STATE((EVP_DigestSignInit(mdctx, NULL, EVP_sha256(), NULL, _pkey) == 1));
CHECK_STATE(EVP_DigestSignUpdate(mdctx, msgToSign.c_str(), msgToSign.size()) == 1); CHECK_STATE(EVP_DigestSignUpdate(mdctx, msgToSign.c_str(), msgToSign.size()) == 1);
/* First call EVP_DigestSignFinal with a NULL sig parameter to obtain the length of the /* First call EVP_DigestSignFinal with a NULL sig parameter to obtain the length of the
...@@ -331,7 +316,6 @@ string ZMQClient::ecdsaSignMessageHash(int base, const std::string &keyName, con ...@@ -331,7 +316,6 @@ string ZMQClient::ecdsaSignMessageHash(int base, const std::string &keyName, con
return result->getSignature(); return result->getSignature();
} }
uint64_t ZMQClient::getProcessID() { uint64_t ZMQClient::getProcessID() {
return syscall(__NR_gettid); return syscall(__NR_gettid);
} }
\ No newline at end of file
...@@ -92,7 +92,7 @@ public: ...@@ -92,7 +92,7 @@ public:
static string signString(EVP_PKEY* _pkey, const string& _str); static string signString(EVP_PKEY* _pkey, const string& _str);
static void verifySig(EVP_PKEY* _pubkey, const string& _str, const string& _sig); static void verifySig(EVP_PKEY* _pubkey, const string& _str, const string& _sig);
string blsSignMessageHash(const std::string &keyShareName, const std::string &messageHash, int t, int n); string blsSignMessageHash(const std::string &keyShareName, const std::string &messageHash, int t, int n);
...@@ -101,5 +101,4 @@ public: ...@@ -101,5 +101,4 @@ public:
}; };
#endif //SGXWALLET_ZMQCLIENT_H #endif //SGXWALLET_ZMQCLIENT_H
...@@ -66,8 +66,6 @@ public: ...@@ -66,8 +66,6 @@ public:
static void initZMQServer(bool _checkSignature); static void initZMQServer(bool _checkSignature);
static void exitZMQServer(); static void exitZMQServer();
private: private:
shared_ptr<zmq::context_t> ctx_; shared_ptr<zmq::context_t> ctx_;
shared_ptr<zmq::socket_t> frontend; shared_ptr<zmq::socket_t> frontend;
...@@ -81,5 +79,4 @@ private: ...@@ -81,5 +79,4 @@ private:
}; };
#endif //SGXWALLET_ZMQServer_H #endif //SGXWALLET_ZMQServer_H
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