Unverified Commit 091f6851 authored by Oleh's avatar Oleh

SKALE-3334 fix complaintResponse function

parent 1c1c6383
...@@ -586,7 +586,7 @@ Json::Value SGXWalletServer::calculateAllBLSPublicKeysImpl(const Json::Value& pu ...@@ -586,7 +586,7 @@ Json::Value SGXWalletServer::calculateAllBLSPublicKeysImpl(const Json::Value& pu
RETURN_SUCCESS(result); RETURN_SUCCESS(result);
} }
Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int _ind) { Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int _t, int _n, int _ind) {
spdlog::info("Entering {}", __FUNCTION__); spdlog::info("Entering {}", __FUNCTION__);
INIT_RESULT(result) INIT_RESULT(result)
...@@ -614,13 +614,12 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int ...@@ -614,13 +614,12 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
} }
} }
// TODO: delete dh keys for (int i = 0; i < _n; i++) {
// for (int i = 0; i < _n; i++) { string name = _polyName + "_" + to_string(i) + ":";
// string name = _polyName + "_" + to_string(i) + ":"; LevelDB::getLevelDb()->deleteDHDKGKey(name);
// LevelDB::getLevelDb()->deleteDHDKGKey(name); string shareG2_name = "shareG2_" + _polyName + "_" + to_string(i) + ":";
// string shareG2_name = "shareG2_" + _polyName + "_" + to_string(i) + ":"; LevelDB::getLevelDb()->deleteKey(shareG2_name);
// LevelDB::getLevelDb()->deleteKey(shareG2_name); }
// }
LevelDB::getLevelDb()->deleteKey(_polyName); LevelDB::getLevelDb()->deleteKey(_polyName);
string encryptedSecretShareName = "encryptedSecretShare:" + _polyName; string encryptedSecretShareName = "encryptedSecretShare:" + _polyName;
...@@ -748,8 +747,8 @@ Json::Value SGXWalletServer::blsSignMessageHash(const string &_keyShareName, con ...@@ -748,8 +747,8 @@ Json::Value SGXWalletServer::blsSignMessageHash(const string &_keyShareName, con
return blsSignMessageHashImpl(_keyShareName, _messageHash, _t, _n); return blsSignMessageHashImpl(_keyShareName, _messageHash, _t, _n);
} }
Json::Value SGXWalletServer::complaintResponse(const string &polyName, int ind) { Json::Value SGXWalletServer::complaintResponse(const string &polyName, int t, int n, int ind) {
return complaintResponseImpl(polyName, ind); return complaintResponseImpl(polyName, t, n, ind);
} }
Json::Value SGXWalletServer::multG2(const string &x) { Json::Value SGXWalletServer::multG2(const string &x) {
......
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
virtual Json::Value calculateAllBLSPublicKeys(const Json::Value& publicShares, int t, int n); virtual Json::Value calculateAllBLSPublicKeys(const Json::Value& publicShares, int t, int n);
virtual Json::Value complaintResponse(const string &polyName, int ind); virtual Json::Value complaintResponse(const string &polyName, int t, int n, int ind);
virtual Json::Value multG2(const string &x); virtual Json::Value multG2(const string &x);
......
...@@ -50,7 +50,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer> ...@@ -50,7 +50,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
this->bindAndAddMethod(jsonrpc::Procedure("createBLSPrivateKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "blsKeyName",jsonrpc::JSON_STRING, "ethKeyName",jsonrpc::JSON_STRING, "polyName", jsonrpc::JSON_STRING, "secretShare",jsonrpc::JSON_STRING,"t", jsonrpc::JSON_INTEGER,"n",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::createBLSPrivateKeyI); this->bindAndAddMethod(jsonrpc::Procedure("createBLSPrivateKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "blsKeyName",jsonrpc::JSON_STRING, "ethKeyName",jsonrpc::JSON_STRING, "polyName", jsonrpc::JSON_STRING, "secretShare",jsonrpc::JSON_STRING,"t", jsonrpc::JSON_INTEGER,"n",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::createBLSPrivateKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("getBLSPublicKeyShare", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "blsKeyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::getBLSPublicKeyShareI); this->bindAndAddMethod(jsonrpc::Procedure("getBLSPublicKeyShare", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "blsKeyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::getBLSPublicKeyShareI);
this->bindAndAddMethod(jsonrpc::Procedure("calculateAllBLSPublicKeys", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "publicShares", jsonrpc::JSON_ARRAY, "n", jsonrpc::JSON_INTEGER, "t", jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::calculateAllBLSPublicKeysI); this->bindAndAddMethod(jsonrpc::Procedure("calculateAllBLSPublicKeys", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "publicShares", jsonrpc::JSON_ARRAY, "n", jsonrpc::JSON_INTEGER, "t", jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::calculateAllBLSPublicKeysI);
this->bindAndAddMethod(jsonrpc::Procedure("complaintResponse", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING,"ind",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::complaintResponseI); this->bindAndAddMethod(jsonrpc::Procedure("complaintResponse", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING,"t",jsonrpc::JSON_INTEGER, "n",jsonrpc::JSON_INTEGER, "ind",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::complaintResponseI);
this->bindAndAddMethod(jsonrpc::Procedure("multG2", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "x",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::multG2I); this->bindAndAddMethod(jsonrpc::Procedure("multG2", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "x",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::multG2I);
this->bindAndAddMethod(jsonrpc::Procedure("isPolyExists", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::isPolyExistsI); this->bindAndAddMethod(jsonrpc::Procedure("isPolyExists", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::isPolyExistsI);
...@@ -111,7 +111,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer> ...@@ -111,7 +111,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
} }
inline virtual void complaintResponseI(const Json::Value &request, Json::Value &response) inline virtual void complaintResponseI(const Json::Value &request, Json::Value &response)
{ {
response = this->complaintResponse( request["polyName"].asString(), request["ind"].asInt()); response = this->complaintResponse( request["polyName"].asString(), request["t"].asInt(), request["n"].asInt(), request["ind"].asInt());
} }
inline virtual void multG2I(const Json::Value &request, Json::Value &response) inline virtual void multG2I(const Json::Value &request, Json::Value &response)
{ {
...@@ -152,7 +152,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer> ...@@ -152,7 +152,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
virtual Json::Value createBLSPrivateKey(const std::string & blsKeyName, const std::string& ethKeyName, const std::string& polyName, const std::string & SecretShare, int t, int n) = 0; virtual Json::Value createBLSPrivateKey(const std::string & blsKeyName, const std::string& ethKeyName, const std::string& polyName, const std::string & SecretShare, int t, int n) = 0;
virtual Json::Value getBLSPublicKeyShare(const std::string & blsKeyName) = 0; virtual Json::Value getBLSPublicKeyShare(const std::string & blsKeyName) = 0;
virtual Json::Value calculateAllBLSPublicKeys(const Json::Value& publicShares, int t, int n) = 0; virtual Json::Value calculateAllBLSPublicKeys(const Json::Value& publicShares, int t, int n) = 0;
virtual Json::Value complaintResponse(const std::string& polyName, int ind) = 0; virtual Json::Value complaintResponse(const std::string& polyName, int t, int n, int ind) = 0;
virtual Json::Value multG2(const std::string & x) = 0; virtual Json::Value multG2(const std::string & x) = 0;
virtual Json::Value isPolyExists(const std::string& polyName) = 0; virtual Json::Value isPolyExists(const std::string& polyName) = 0;
......
...@@ -171,10 +171,12 @@ class StubClient : public jsonrpc::Client ...@@ -171,10 +171,12 @@ class StubClient : public jsonrpc::Client
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
Json::Value complaintResponse(const std::string& polyName, int ind) Json::Value complaintResponse(const std::string& polyName, int t, int n,int ind)
{ {
Json::Value p; Json::Value p;
p["polyName"] = polyName; p["polyName"] = polyName;
p["t"] = t;
p["n"] = n;
p["ind"] = ind; p["ind"] = ind;
Json::Value result = this->CallMethod("complaintResponse",p); Json::Value result = this->CallMethod("complaintResponse",p);
if (result.isObject()) if (result.isObject())
......
...@@ -643,7 +643,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") { ...@@ -643,7 +643,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
REQUIRE(res); REQUIRE(res);
} }
Json::Value complaintResponse = c.complaintResponse(polyNames[1], 0); Json::Value complaintResponse = c.complaintResponse(polyNames[1], t, n, 0);
REQUIRE(complaintResponse["status"] == 0); REQUIRE(complaintResponse["status"] == 0);
BLSSigShareSet sigShareSet(t, n); BLSSigShareSet sigShareSet(t, n);
......
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