Unverified Commit 80a0bde9 authored by kladko's avatar kladko

SKALE-2077 Fixed Naming

parent 7e252ab9
......@@ -270,7 +270,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
return result;
}
bool CreateBLSShare( const string& BLSKeyName, const char * s_shares, const char * encryptedKeyHex){
bool CreateBLSShare( const string& blsKeyName, const char * s_shares, const char * encryptedKeyHex){
if (DEBUG_PRINT) {
spdlog::info("ENTER CreateBLSShare");
}
......@@ -299,10 +299,10 @@ bool CreateBLSShare( const string& BLSKeyName, const char * s_shares, const char
//cerr << "enc_bls_len " << enc_bls_len << endl;
carray2Hex(encr_bls_key, enc_bls_len, hexBLSKey);
// cerr << "BEFORE WRITE BLS KEY TO DB" << endl;
writeDataToDB(BLSKeyName, hexBLSKey);
writeDataToDB(blsKeyName, hexBLSKey);
if (DEBUG_PRINT) {
spdlog::info("hexBLSKey length is {}", char_traits<char>::length(hexBLSKey));
spdlog::info("bls key {}", BLSKeyName, " is ", hexBLSKey );
spdlog::info("bls key {}", blsKeyName, " is ", hexBLSKey );
}
free(hexBLSKey);
return true;
......
......@@ -39,7 +39,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
std::string decrypt_DHKey(const std::string& polyName, int ind);
bool CreateBLSShare( const std::string& BLSKeyName, const char * s_shares, const char * encryptedKeyHex);
bool CreateBLSShare( const std::string& blsKeyName, const char * s_shares, const char * encryptedKeyHex);
std::vector<std::string> GetBLSPubKey(const char * encryptedKeyHex);
......
......@@ -274,8 +274,8 @@ Json::Value generateECDSAKeyImpl() {
writeDataToDB(keyName, keys.at(0));
result["encryptedKey"] = keys.at(0);
result["PublicKey"] = keys.at(1);
result["KeyName"] = keyName;
result["publicKey"] = keys.at(1);
result["keyName"] = keyName;
} catch (RPCException &_e) {
cerr << " err str " << _e.errString << endl;
......@@ -388,7 +388,7 @@ Json::Value getPublicECDSAKeyImpl(const string& keyName){
Json::Value result;
result["status"] = 0;
result["errorMessage"] = "";
result["PublicKey"] = "";
result["publicKey"] = "";
spdlog::info("Calling method getPublicECDSAKey");
......@@ -404,7 +404,7 @@ Json::Value getPublicECDSAKeyImpl(const string& keyName){
spdlog::info("PublicKey {}", Pkey);
spdlog::info("PublicKey length {}", Pkey.length());
}
result["PublicKey"] = Pkey;
result["publicKey"] = Pkey;
} catch (RPCException &_e) {
result["status"] = _e.status;
......@@ -509,22 +509,22 @@ Json::Value getSecretShareImpl(const string& polyName, const Json::Value& public
string s = get_secret_shares(polyName, encr_poly_ptr->c_str(), pubKeys_vect, t, n);
//cerr << "result is " << s << endl;
result["SecretShare"] = s;
result["secretShare"] = s;
} catch (RPCException &_e) {
//cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
result["SecretShare"] = "";
result["secretShare"] = "";
}
return result;
}
Json::Value DKGVerificationImpl(const string& publicShares, const string& EthKeyName,
Json::Value dkgVerificationImpl(const string& publicShares, const string& ethKeyName,
const string& SecretShare, int t, int n, int ind){
spdlog::info("enter DKGVerificationImpl");
spdlog::info("enter dkgVerificationImpl");
Json::Value result;
result["status"] = 0;
......@@ -533,7 +533,7 @@ Json::Value DKGVerificationImpl(const string& publicShares, const string& EthKey
try {
if ( !checkECDSAKeyName(EthKeyName)){
if ( !checkECDSAKeyName(ethKeyName)){
throw RPCException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
}
if( !check_n_t(t, n) || ind > n || ind < 0){
......@@ -546,7 +546,7 @@ Json::Value DKGVerificationImpl(const string& publicShares, const string& EthKey
throw RPCException(INVALID_DKG_PARAMS, "Invalid length of public shares");
}
shared_ptr<string> encryptedKeyHex_ptr = readFromDb(EthKeyName);
shared_ptr<string> encryptedKeyHex_ptr = readFromDb(ethKeyName);
if ( !VerifyShares(publicShares.c_str(), SecretShare.c_str(), encryptedKeyHex_ptr->c_str(), t, n, ind )){
result["result"] = false;
......@@ -562,9 +562,9 @@ Json::Value DKGVerificationImpl(const string& publicShares, const string& EthKey
return result;
}
Json::Value CreateBLSPrivateKeyImpl(const string & BLSKeyName, const string& EthKeyName, const string& polyName, const string & SecretShare, int t, int n){
Json::Value createBLSPrivateKeyImpl(const string & blsKeyName, const string& ethKeyName, const string& polyName, const string & SecretShare, int t, int n){
spdlog::info("CreateBLSPrivateKeyImpl entered");
spdlog::info("createBLSPrivateKeyImpl entered");
Json::Value result;
result["status"] = 0;
......@@ -577,13 +577,13 @@ Json::Value CreateBLSPrivateKeyImpl(const string & BLSKeyName, const string& Eth
spdlog::info("secret shares - {}", SecretShare);
throw RPCException(INVALID_SECRET_SHARES_LENGTH, "Invalid secret share length");
}
if ( !checkECDSAKeyName(EthKeyName)){
if ( !checkECDSAKeyName(ethKeyName)){
throw RPCException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
}
if ( !checkName(polyName, "POLY")){
throw RPCException(INVALID_POLY_NAME, "Invalid polynomial name");
}
if ( !checkName(BLSKeyName, "BLS_KEY")){
if ( !checkName(blsKeyName, "BLS_KEY")){
throw RPCException(INVALID_POLY_NAME, "Invalid BLS key name");
}
if( !check_n_t(t, n)){
......@@ -594,9 +594,9 @@ Json::Value CreateBLSPrivateKeyImpl(const string & BLSKeyName, const string& Eth
spdlog::info("secret shares from json are - {}", SecretShare);
}
shared_ptr<string> encryptedKeyHex_ptr = readFromDb(EthKeyName);
shared_ptr<string> encryptedKeyHex_ptr = readFromDb(ethKeyName);
bool res = CreateBLSShare(BLSKeyName, SecretShare.c_str(), encryptedKeyHex_ptr->c_str());
bool res = CreateBLSShare(blsKeyName, SecretShare.c_str(), encryptedKeyHex_ptr->c_str());
if (res){
spdlog::info("BLS KEY SHARE CREATED ");
}
......@@ -621,17 +621,17 @@ Json::Value CreateBLSPrivateKeyImpl(const string & BLSKeyName, const string& Eth
return result;
}
Json::Value GetBLSPublicKeyShareImpl(const string & BLSKeyName){
Json::Value getBLSPublicKeyShareImpl(const string & blsKeyName){
Json::Value result;
result["status"] = 0;
result["errorMessage"] = "";
try {
if ( !checkName(BLSKeyName, "BLS_KEY")){
if ( !checkName(blsKeyName, "BLS_KEY")){
throw RPCException(INVALID_POLY_NAME, "Invalid BLSKey name");
}
shared_ptr<string> encryptedKeyHex_ptr = readFromDb(BLSKeyName);
shared_ptr<string> encryptedKeyHex_ptr = readFromDb(blsKeyName);
if (DEBUG_PRINT) {
spdlog::info("encr_bls_key_share is {}", *encryptedKeyHex_ptr);
spdlog::info("length is {}", encryptedKeyHex_ptr->length());
......@@ -654,7 +654,7 @@ Json::Value GetBLSPublicKeyShareImpl(const string & BLSKeyName){
return result;
}
Json::Value ComplaintResponseImpl(const string& polyName, int ind){
Json::Value complaintResponseImpl(const string& polyName, int ind){
Json::Value result;
result["status"] = 0;
result["errorMessage"] = "";
......@@ -680,12 +680,12 @@ Json::Value ComplaintResponseImpl(const string& polyName, int ind){
}
Json::Value MultG2Impl(const string& x){
Json::Value multG2Impl(const string& x){
Json::Value result;
result["status"] = 0;
result["errorMessage"] = "";
try {
spdlog::info("MultG2Impl try ");
spdlog::info("multG2Impl try ");
vector<string> xG2_vect = mult_G2(x);
for ( uint8_t i = 0; i < 4; i++) {
result["x*G2"][i] = xG2_vect.at(i);
......@@ -700,7 +700,7 @@ Json::Value MultG2Impl(const string& x){
return result;
}
Json::Value IsPolyExistsImpl(const string& polyName){
Json::Value isPolyExistsImpl(const string& polyName){
Json::Value result;
shared_ptr<string> poly_str_ptr = LevelDB::getLevelDb()->readString(polyName);
......@@ -738,19 +738,19 @@ Json::Value SGXWalletServer::getSecretShare(const string& polyName, const Json::
return getSecretShareImpl(polyName, publicKeys, t, n);
}
Json::Value SGXWalletServer::DKGVerification( const string& publicShares, const string& EthKeyName, const string& SecretShare, int t, int n, int index){
Json::Value SGXWalletServer::dkgVerification( const string& publicShares, const string& ethKeyName, const string& SecretShare, int t, int n, int index){
lock_guard<recursive_mutex> lock(m);
return DKGVerificationImpl(publicShares, EthKeyName, SecretShare, t, n, index);
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){
Json::Value SGXWalletServer::createBLSPrivateKey(const string & blsKeyName, const string& ethKeyName, const string& polyName, const string& SecretShare, int t, int n){
lock_guard<recursive_mutex> 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_guard<recursive_mutex> lock(m);
return GetBLSPublicKeyShareImpl(BLSKeyName);
return getBLSPublicKeyShareImpl(blsKeyName);
}
......@@ -799,19 +799,19 @@ Json::Value SGXWalletServer::importECDSAKey(const string &key, const string &key
return importECDSAKeyImpl(key, keyName);
}
Json::Value SGXWalletServer::ComplaintResponse(const string& polyName, int ind){
Json::Value SGXWalletServer::complaintResponse(const string& polyName, int ind){
lock_guard<recursive_mutex> 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_guard<recursive_mutex> lock(m);
return MultG2Impl(x);
return multG2Impl(x);
}
Json::Value SGXWalletServer::IsPolyExists(const string& polyName){
Json::Value SGXWalletServer::isPolyExists(const string& polyName){
lock_guard<recursive_mutex> lock(m);
return IsPolyExistsImpl(polyName);
return isPolyExistsImpl(polyName);
}
Json::Value SGXWalletServer::getServerStatus() {
......
......@@ -56,13 +56,12 @@ public:
virtual Json::Value generateDKGPoly(const std::string& polyName, int t);
virtual Json::Value getVerificationVector(const std::string& polyName, int t, int n);
virtual Json::Value getSecretShare(const std::string& polyName, const Json::Value& publicKeys, int t, int n);
virtual Json::Value DKGVerification(const std::string& publicShares, const std::string& EthKeyName, const std::string& SecretShare, int t, int n, int index);
virtual Json::Value CreateBLSPrivateKey(const std::string & BLSKeyName, const std::string& EthKeyName, const std::string& polyName, const std::string & SecretShare, int t, int n);
virtual Json::Value GetBLSPublicKeyShare(const std::string & BLSKeyName);
virtual Json::Value ComplaintResponse(const std::string& polyName, int ind);
virtual Json::Value MultG2(const std::string & x);
virtual Json::Value IsPolyExists(const std::string& polyName);
virtual Json::Value dkgVerification(const std::string& publicShares, const std::string& ethKeyName, const std::string& SecretShare, int t, int n, int index);
virtual Json::Value createBLSPrivateKey(const std::string & blsKeyName, const std::string& ethKeyName, const std::string& polyName, const std::string & SecretShare, int t, int n);
virtual Json::Value getBLSPublicKeyShare(const std::string & blsKeyName);
virtual Json::Value complaintResponse(const std::string& polyName, int ind);
virtual Json::Value multG2(const std::string & x);
virtual Json::Value isPolyExists(const std::string& polyName);
virtual Json::Value getServerStatus();
};
......@@ -85,12 +84,12 @@ Json::Value getPublicECDSAKeyImpl(const std::string& keyName);
Json::Value generateDKGPolyImpl(const std::string& polyName, int t);
Json::Value getVerificationVectorImpl(const std::string& polyName, int t, int n);
Json::Value getSecretShareImpl(const std::string& polyName, const Json::Value& publicKeys, int t, int n);
Json::Value DKGVerificationImpl(const std::string& publicShares, const std::string& EthKeyName, const std::string& SecretShare, int t, int n, int index);
Json::Value CreateBLSPrivateKeyImpl(const std::string & BLSKeyName, const std::string& EthKeyName, const std::string& polyName, const std::string & SecretShare, int t, int n);
Json::Value GetBLSPublicKeyShareImpl(const std::string & BLSKeyName);
Json::Value ComplaintResponseImpl(const std::string& polyName, int ind);
Json::Value MultG2Impl(const std::string & x);
Json::Value IsPolyExistsImpl(const std::string& polyName);
Json::Value dkgVerificationImpl(const std::string& publicShares, const std::string& ethKeyName, const std::string& SecretShare, int t, int n, int index);
Json::Value createBLSPrivateKeyImpl(const std::string & blsKeyName, const std::string& ethKeyName, const std::string& polyName, const std::string & SecretShare, int t, int n);
Json::Value getBLSPublicKeyShareImpl(const std::string & blsKeyName);
Json::Value complaintResponseImpl(const std::string& polyName, int ind);
Json::Value multG2Impl(const std::string & x);
Json::Value isPolyExistsImpl(const std::string& polyName);
Json::Value getServerStatusImpl();
......
......@@ -17,19 +17,19 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
this->bindAndAddMethod(jsonrpc::Procedure("importECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "key",jsonrpc::JSON_STRING,"keyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::importECDSAKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("generateECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, NULL), &AbstractStubServer::generateECDSAKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("renameECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "KeyName",jsonrpc::JSON_STRING,"tempKeyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::renameECDSAKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("renameECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "keyName",jsonrpc::JSON_STRING,"tempKeyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::renameECDSAKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("getPublicECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "keyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::getPublicECDSAKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("ecdsaSignMessageHash", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "base",jsonrpc::JSON_INTEGER,"keyName",jsonrpc::JSON_STRING,"messageHash",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::ecdsaSignMessageHashI);
this->bindAndAddMethod(jsonrpc::Procedure("generateDKGPoly", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING,"t",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::generateDKGPolyI);
this->bindAndAddMethod(jsonrpc::Procedure("getVerificationVector", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT,"polyName",jsonrpc::JSON_STRING, "t",jsonrpc::JSON_INTEGER,"t",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::getVerificationVectorI);
this->bindAndAddMethod(jsonrpc::Procedure("getSecretShare", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING,"publicKeys",jsonrpc::JSON_ARRAY, "n",jsonrpc::JSON_INTEGER,"t",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::getSecretShareI);
this->bindAndAddMethod(jsonrpc::Procedure("DKGVerification", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "publicShares",jsonrpc::JSON_STRING, "EthKeyName",jsonrpc::JSON_STRING, "SecretShare",jsonrpc::JSON_STRING,"t",jsonrpc::JSON_INTEGER, "n",jsonrpc::JSON_INTEGER, "index",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::DKGVerificationI);
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("ComplaintResponse", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING,"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("IsPolyExists", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::IsPolyExistsI);
this->bindAndAddMethod(jsonrpc::Procedure("dkgVerification", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "publicShares",jsonrpc::JSON_STRING, "ethKeyName",jsonrpc::JSON_STRING, "secretShare",jsonrpc::JSON_STRING,"t",jsonrpc::JSON_INTEGER, "n",jsonrpc::JSON_INTEGER, "index",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::dkgVerificationI);
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("complaintResponse", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING,"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("isPolyExists", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::isPolyExistsI);
this->bindAndAddMethod(jsonrpc::Procedure("getServerStatus", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, NULL), &AbstractStubServer::getServerStatusI);
}
......@@ -54,7 +54,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
}
inline virtual void renameECDSAKeyI(const Json::Value &request, Json::Value &response)
{
response = this->renameECDSAKey(request["KeyName"].asString(), request["tempKeyName"].asString());
response = this->renameECDSAKey(request["keyName"].asString(), request["tempKeyName"].asString());
}
inline virtual void getPublicECDSAKeyI(const Json::Value &request, Json::Value &response)
{
......@@ -77,29 +77,29 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
{
response = this->getSecretShare(request["polyName"].asString(), request["publicKeys"], request["t"].asInt(),request["n"].asInt());
}
inline virtual void DKGVerificationI(const Json::Value &request, Json::Value &response)
inline virtual void dkgVerificationI(const Json::Value &request, Json::Value &response)
{
response = this->DKGVerification(request["publicShares"].asString(), request["EthKeyName"].asString(), request["SecretShare"].asString(), request["t"].asInt(), request["n"].asInt(), request["index"].asInt());
response = this->dkgVerification(request["publicShares"].asString(), request["ethKeyName"].asString(), request["secretShare"].asString(), request["t"].asInt(), request["n"].asInt(), request["index"].asInt());
}
inline virtual void CreateBLSPrivateKeyI(const Json::Value &request, Json::Value &response)
inline virtual void createBLSPrivateKeyI(const Json::Value &request, Json::Value &response)
{
response = this->CreateBLSPrivateKey(request["BLSKeyName"].asString(), request["EthKeyName"].asString(), request["polyName"].asString(),request["SecretShare"].asString(),request["t"].asInt(), request["n"].asInt());
response = this->createBLSPrivateKey(request["blsKeyName"].asString(), request["ethKeyName"].asString(), request["polyName"].asString(),request["secretShare"].asString(),request["t"].asInt(), request["n"].asInt());
}
inline virtual void GetBLSPublicKeyShareI(const Json::Value &request, Json::Value &response)
inline virtual void getBLSPublicKeyShareI(const Json::Value &request, Json::Value &response)
{
response = this->GetBLSPublicKeyShare(request["BLSKeyName"].asString());
response = this->getBLSPublicKeyShare(request["blsKeyName"].asString());
}
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["ind"].asInt());
}
inline virtual void MultG2I(const Json::Value &request, Json::Value &response)
inline virtual void multG2I(const Json::Value &request, Json::Value &response)
{
response = this->MultG2(request["x"].asString());
response = this->multG2(request["x"].asString());
}
inline virtual void IsPolyExistsI(const Json::Value &request, Json::Value &response)
inline virtual void isPolyExistsI(const Json::Value &request, Json::Value &response)
{
response = this->IsPolyExists(request["polyName"].asString());
response = this->isPolyExists(request["polyName"].asString());
}
......@@ -120,12 +120,12 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
virtual Json::Value generateDKGPoly(const std::string& polyName, int t) = 0;
virtual Json::Value getVerificationVector(const std::string& polyName, int t, int n) = 0;
virtual Json::Value getSecretShare(const std::string& polyName, const Json::Value& publicKeys, int t, int n) = 0;
virtual Json::Value DKGVerification( const std::string& publicShares, const std::string& EthKeyName, const std::string& SecretShare, int t, int n, int index) = 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 ComplaintResponse(const std::string& polyName, int ind) = 0;
virtual Json::Value MultG2(const std::string & x) = 0;
virtual Json::Value IsPolyExists(const std::string& polyName) = 0;
virtual Json::Value dkgVerification( const std::string& publicShares, const std::string& ethKeyName, const std::string& SecretShare, int t, int n, int index) = 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 complaintResponse(const std::string& polyName, int ind) = 0;
virtual Json::Value multG2(const std::string & x) = 0;
virtual Json::Value isPolyExists(const std::string& polyName) = 0;
virtual Json::Value getServerStatus() = 0;
};
......
......@@ -50,8 +50,8 @@
"status": 0,
"errorMessage": "12345",
"encryptedKey": "12345",
"KeyName": "tmp:123",
"PublicKey": "12345"
"keyName": "tmp:123",
"publicKey": "12345"
}
},
......@@ -59,7 +59,7 @@
"name": "renameECDSAKey",
"params": {
"tempKeyName": "key1",
"KeyName": "key2"
"keyName": "key2"
},
"returns": {
"status": 0,
......@@ -75,7 +75,7 @@
"returns": {
"status": 0,
"errorMessage": "12345",
"PublicKey": "12345"
"publicKey": "12345"
}
},
......@@ -132,15 +132,15 @@
"returns": {
"status": 0,
"errorMessage": "12345",
"SecretShare": "123"
"secretShare": "123"
}
},
{
"name": "DKGVerification",
"name": "dkgVerification",
"params": {
"publicShares": "123",
"EthKeyName":"NEK:hex",
"SecretShare": "f_ij",
"ethKeyName":"NEK:hex",
"secretShare": "f_ij",
"n": 3,
"t": 3,
"index" : 2
......@@ -152,26 +152,26 @@
}
},
{
"name": "CreateBLSPrivateKey",
"name": "createBLSPrivateKey",
"params": {
"BLSKeyName": "BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID: ",
"EthKeyName":"NEK:hex",
"blsKeyName": "BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID: ",
"ethKeyName":"NEK:hex",
"polyName":"POLY:SCHAIN_ID :NODE_ID :DKG_ID: ",
"SecretShare": "122",
"secretShare": "122",
"n": 3,
"t": 3
},
"returns": {
"status": 0,
"errorMessage": "12345",
"BLSKeyName": "key"
"blsKeyName": "key"
}
},
{
"name": "GetBLSPublicKeyShare",
"name": "getBLSPublicKeyShare",
"params": {
"BLSKeyName": "BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID"
"blsKeyName": "BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID"
},
"returns": {
"status": 0,
......@@ -181,7 +181,7 @@
},
{
"name": "ComplaintResponse",
"name": "complaintResponse",
"params": {
"polyName": "p1",
"n": 3,
......
......@@ -68,7 +68,7 @@ class StubClient : public jsonrpc::Client
Json::Value renameECDSAKey(const std::string& KeyName, const std::string& tempKeyName) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["KeyName"] = KeyName;
p["keyName"] = KeyName;
p["tempKeyName"] = tempKeyName;
Json::Value result = this->CallMethod("renameECDSAKey",p);
if (result.isObject())
......@@ -140,80 +140,80 @@ class StubClient : public jsonrpc::Client
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value DKGVerification(const std::string& publicShares, const std::string& EthKeyName, const std::string& SecretShare, int t, int n, int index) throw (jsonrpc::JsonRpcException)
Json::Value dkgVerification(const std::string& publicShares, const std::string& ethKeyName, const std::string& SecretShare, int t, int n, int index) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["EthKeyName"] = EthKeyName;
p["SecretShare"] = SecretShare;
p["ethKeyName"] = ethKeyName;
p["secretShare"] = SecretShare;
p["index"] = index;
p["n"] = n;
p["publicShares"] = publicShares;
p["t"] = t;
Json::Value result = this->CallMethod("DKGVerification",p);
Json::Value result = this->CallMethod("dkgVerification",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value CreateBLSPrivateKey(const std::string & BLSKeyName, const std::string& EthKeyName, const std::string& polyName, const std::string& SecretShare, int t, int n) throw (jsonrpc::JsonRpcException)
Json::Value createBLSPrivateKey(const std::string & blsKeyName, const std::string& ethKeyName, const std::string& polyName, const std::string& SecretShare, int t, int n) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["BLSKeyName"] = BLSKeyName;
p["EthKeyName"] = EthKeyName;
p["blsKeyName"] = blsKeyName;
p["ethKeyName"] = ethKeyName;
p["polyName"] = polyName;
p["SecretShare"] = SecretShare;
p["secretShare"] = SecretShare;
p["n"] = n;
p["t"] = t;
Json::Value result = this->CallMethod("CreateBLSPrivateKey",p);
Json::Value result = this->CallMethod("reateBLSPrivateKey",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value GetBLSPublicKeyShare(const std::string & BLSKeyName) throw (jsonrpc::JsonRpcException)
Json::Value getBLSPublicKeyShare(const std::string & blsKeyName) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["BLSKeyName"] = BLSKeyName;
p["blsKeyName"] = blsKeyName;
Json::Value result = this->CallMethod("GetBLSPublicKeyShare",p);
Json::Value result = this->CallMethod("getBLSPublicKeyShare",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value ComplaintResponse(const std::string& polyName, int ind) throw (jsonrpc::JsonRpcException)
Json::Value complaintResponse(const std::string& polyName, int ind) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["polyName"] = polyName;
p["ind"] = ind;
Json::Value result = this->CallMethod("ComplaintResponse",p);
Json::Value result = this->CallMethod("complaintResponse",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value MultG2(const std::string & x) throw (jsonrpc::JsonRpcException)
Json::Value multG2(const std::string & x) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["x"] = x;
Json::Value result = this->CallMethod("MultG2",p);
Json::Value result = this->CallMethod("multG2",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value IsPolyExists(const std::string & polyName) throw (jsonrpc::JsonRpcException)
Json::Value isPolyExists(const std::string & polyName) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["polyName"] = polyName;
Json::Value result = this->CallMethod("IsPolyExists",p);
Json::Value result = this->CallMethod("isPolyExists",p);
if (result.isObject())
return result;
else
......
......@@ -781,7 +781,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
poly_names[i] = polyName;
VerifVects[i] = c.getVerificationVector(polyName, t, n);
cout << "VV " << i << " " << VerifVects[i] << endl;
pubEthKeys.append(EthKeys[i]["PublicKey"]);
pubEthKeys.append(EthKeys[i]["publicKey"]);
}
......@@ -797,9 +797,9 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
// cerr << "length is" << pubShares[i].length() << endl;
}
Json::Value ComplaintResponse = c.ComplaintResponse(poly_names[1], 0);
cerr << "share * G2 is " << ComplaintResponse["share*G2"].asString();
cerr << "DHKey is " << ComplaintResponse["DHKey"].asString();
Json::Value complaintResponse = c.complaintResponse(poly_names[1], 0);
cerr << "share * G2 is " << complaintResponse["share*G2"].asString();
cerr << "DHKey is " << complaintResponse["DHKey"].asString();
int k = 0;
......@@ -810,16 +810,16 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
for ( int i = 0; i < n; i++)
for ( int j = 0; j < n; j++){
// if ( i != j ){
cerr << "SecretShare length is " << secretShares[i]["SecretShare"].asString().length() << endl;
string secretShare = secretShares[i]["SecretShare"].asString().substr(192*j, 192);
secShares_vect[i] += secretShares[j]["SecretShare"].asString().substr(192*i, 192);
bool res = c.DKGVerification(pubShares[i], EthKeys[j]["KeyName"].asString(), secretShare, t, n, j)["result"].asBool();
cerr << "secretShare length is " << secretShares[i]["secretShare"].asString().length() << endl;
string secretShare = secretShares[i]["secretShare"].asString().substr(192*j, 192);
secShares_vect[i] += secretShares[j]["secretShare"].asString().substr(192*i, 192);
bool res = c.dkgVerification(pubShares[i], EthKeys[j]["keyName"].asString(), secretShare, t, n, j)["result"].asBool();
k++;
cerr << "NOW K IS " << k << " i is " << i << " j is " << j << endl;
REQUIRE(res);
pSharesBad[i][0] = 'q';
Json::Value wrongVerif = c.DKGVerification(pSharesBad[i], EthKeys[j]["KeyName"].asString(), secretShare, t, n, j);
Json::Value wrongVerif = c.dkgVerification(pSharesBad[i], EthKeys[j]["keyName"].asString(), secretShare, t, n, j);
res = wrongVerif["result"].asBool();
REQUIRE(!res);
cerr << "wrong verification " << wrongVerif << endl;
......@@ -842,10 +842,10 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
for ( int i = 0; i < t; i++){
string endName = poly_names[i].substr(4);
string blsName = "BLS_KEY" + poly_names[i].substr(4);
string secretShare = secretShares[i]["SecretShare"].asString();
//cout << c.CreateBLSPrivateKey(blsName, EthKeys[i]["KeyName"].asString(), poly_names[i], secretShare, t, n);
cout << c.CreateBLSPrivateKey(blsName, EthKeys[i]["KeyName"].asString(), poly_names[i], secShares_vect[i], t, n);
pubBLSKeys[i] = c.GetBLSPublicKeyShare(blsName);
string secretShare = secretShares[i]["secretShare"].asString();
//cout << c.createBLSPrivateKey(blsName, EthKeys[i]["keyName"].asString(), poly_names[i], secretShare, t, n);
cout << c.createBLSPrivateKey(blsName, EthKeys[i]["keyName"].asString(), poly_names[i], secShares_vect[i], t, n);
pubBLSKeys[i] = c.getBLSPublicKeyShare(blsName);
cerr << "BLS KEY SHARE NAME IS " << blsName << endl;
//string hash = "09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db";
BLSSigShares[i] = c.blsSignMessageHash(blsName, hash, t, n, i + 1);
......@@ -870,7 +870,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
REQUIRE( common_public.VerifySigWithHelper(hash_arr, commonSig, t, n) );
cout << "try to get bls public key" << endl;
cout << c.GetBLSPublicKeyShare("BLS_KEY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:0");
cout << c.getBLSPublicKeyShare("BLS_KEY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:0");
}
......@@ -904,8 +904,8 @@ TEST_CASE("API test", "[api_test]") {
Json::Value genKey = c.generateECDSAKey();
cout << genKey << endl;
cout << c.ecdsaSignMessageHash(16, genKey["KeyName"].asString(),"0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db" );
Json::Value getPubKey = c.getPublicECDSAKey(genKey["KeyName"].asString());
cout << c.ecdsaSignMessageHash(16, genKey["keyName"].asString(),"0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db" );
Json::Value getPubKey = c.getPublicECDSAKey(genKey["keyName"].asString());
cout << getPubKey << endl;
// cout << c.renameESDSAKey("NODE_1CHAIN_1","tmp_NEK:bcacde0d26c0ea2c7e649992e7f791e1fba2492f5b7ae63dadb799075167c7fc");
// cout<<c.getPublicECDSAKey("NEK:7ca98cf32fd1edba26ea685820719fd2201b068a10c1264d382abbde13802a0e");
......@@ -943,34 +943,34 @@ TEST_CASE("API test", "[api_test]") {
string share = share_big.substr(0, 192);
string publicShares = "1fc8154abcbf0c2ebf559571d7b57a8995c0e293a73d4676a8f76051a0d0ace30e00a87c9f087254c9c860c3215c4f11e8f85a3e8fae19358f06a0cbddf3df1924b1347b9b58f5bcb20958a19bdbdd832181cfa9f9e9fd698f6a485051cb47b829d10f75b6e227a7d7366dd02825b5718072cd42c39f0352071808622b7db6421b1069f519527e49052a8da6e3720cbda9212fc656eef945f5e56a4159c3b9622d883400460a9eff07fe1873f9b1ec50f6cf70098b9da0b90625b176f12329fa2ecc65082c626dc702d9cfb23a06770d4a2c7867e269efe84e3709b11001fb380a32d609855d1d46bc60f21140c636618b8ff55ed06d7788b6f81b498f96d3f9";
// cout << c.DKGVerification(publicShares, "test_key1", "37092c06c423b627c38ff86d1e66608bdc1496ef855b86e9f773441ac0b285d92aa466376a6008de4aab9858aa34848775282c4c3b56370bf25827321619c6e47701c8a32e3f4bb28f5a3b12a09800f318c550cedff6150e9a673ea56ece8b76", 2, 2, 0);
// cout << c.dkgVerification(publicShares, "test_key1", "37092c06c423b627c38ff86d1e66608bdc1496ef855b86e9f773441ac0b285d92aa466376a6008de4aab9858aa34848775282c4c3b56370bf25827321619c6e47701c8a32e3f4bb28f5a3b12a09800f318c550cedff6150e9a673ea56ece8b76", 2, 2, 0);
// cout << c.DKGVerification("oleh1", "key0", "37092c06c423b627c38ff86d1e66608bdc1496ef855b86e9f773441ac0b285d92aa466376a6008de4aab9858aa34848775282c4c3b56370bf25827321619c6e47701c8a32e3f4bb28f5a3b12a09800f318c550cedff6150e9a673ea56ece8b76", 2, 2, 0);
// cout << c.dkgVerification("oleh1", "key0", "37092c06c423b627c38ff86d1e66608bdc1496ef855b86e9f773441ac0b285d92aa466376a6008de4aab9858aa34848775282c4c3b56370bf25827321619c6e47701c8a32e3f4bb28f5a3b12a09800f318c550cedff6150e9a673ea56ece8b76", 2, 2, 0);
Json::Value SecretShare;
SecretShare.append(share_big0);
SecretShare.append(share_big);
//cout << c.CreateBLSPrivateKey( "test_bls_key1","test_key1", "p2", share_big0, 2, 2 );
//cout << c.createBLSPrivateKey( "test_bls_key1","test_key1", "p2", share_big0, 2, 2 );
// string shares = "252122c309ed1f32faa897ede140c5b9c1bc07d5d9c94b7a22d4eeb13da7b7142aa466376a6008de4aab9858aa34848775282c4c3b56370bf25827321619c6e47701c8a32e3f4bb28f5a3b12a09800f318c550cedff6150e9a673ea56ece8b76df831dbef474cfc38be1c980130a8d273ff410fbf87deece9d7756a1b08ba9e954c1676cc7f2cac16e16cff0c877d8cf967381321fb4cc78e3638245a1dc85419766d281aff4935cc6eac25c9842032c8f7fae567c57622969599a72c42d2e1e";
string shares = "252122c309ed1f32faa897ede140c5b9c1bc07d5d9c94b7a22d4eeb13da7b7142aa466376a6008de4aab9858aa34848775282c4c3b56370bf25827321619c6e47701c8a32e3f4bb28f5a3b12a09800f318c550cedff6150e9a673ea56ece8b7637092c06c423b627c38ff86d1e66608bdc1496ef855b86e9f773441ac0b285d92aa466376a6008de4aab9858aa34848775282c4c3b56370bf25827321619c6e47701c8a32e3f4bb28f5a3b12a09800f318c550cedff6150e9a673ea56ece8b76";
//cout << c.CreateBLSPrivateKey( "test_bls1","key0", "oleh1", shares, 2, 2 );
//cout << c.createBLSPrivateKey( "test_bls1","key0", "oleh1", shares, 2, 2 );
//cout << c.GetBLSPublicKeyShare("test_bls_key0");
//cout << c.getBLSPublicKeyShare("test_bls_key0");
string s_share = "13b871ad5025fed10a41388265b19886e78f449f758fe8642ade51440fcf850bb2083f87227d8fb53fdfb2854e2d0abec4f47e2197b821b564413af96124cd84a8700f8eb9ed03161888c9ef58d6e5896403de3608e634e23e92fba041aa283484427d0e6de20922216c65865cfe26edd2cf9cbfc3116d007710e8d82feafd9135c497bef0c800ca310ba6044763572681510dad5e043ebd87ffaa1a4cd45a899222207f3d05dec8110d132ad34c62d6a3b40bf8e9f40f875125c3035062d2ca";
string EthKeyName = "tmp_NEK:8abc8e8280fb060988b65da4b8cb00779a1e816ec42f8a40ae2daa520e484a01";
//cout << c.CreateBLSPrivateKey( "test_blskey", EthKeyName, "JCGMt", s_share, 2, 2 );
//cout << c.GetBLSPublicKeyShare("test_blskey");
string ethKeyName = "tmp_NEK:8abc8e8280fb060988b65da4b8cb00779a1e816ec42f8a40ae2daa520e484a01";
//cout << c.createBLSPrivateKey( "test_blskey", ethKeyName, "JCGMt", s_share, 2, 2 );
//cout << c.getBLSPublicKeyShare("test_blskey");
// cout << c.blsSignMessageHash("dOsRY","38433e5ce087dcc1be82fcc834eae83c256b3db87d34f84440d0b708daa0c6f7", 2, 2, 1);
// cout << c.ComplaintResponse("POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1", 0);
// cout << c.GetBLSPublicKeyShare("BLS_KEY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:0");
// cout << c.complaintResponse("POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1", 0);
// cout << c.getBLSPublicKeyShare("BLS_KEY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:0");
// cout << c.getPublicECDSAKey("NEK:91573248d6b0ebd5b1bd313ab35163361b423c0f9f01bad085d166650b8b2c1f");
//cout << c.MultG2("4160780231445160889237664391382223604184857153814275770598791864649971919844");
//cout << c.multG2("4160780231445160889237664391382223604184857153814275770598791864649971919844");
} catch (JsonRpcException &e) {
cerr << e.what() << endl;
......@@ -1015,7 +1015,7 @@ void SendRPCRequest(){
poly_names[i] = polyName;
VerifVects[i] = c.getVerificationVector(polyName, t, n);
cout << "VV " << i << " " << VerifVects[i] << endl;
pubEthKeys.append(EthKeys[i]["PublicKey"]);
pubEthKeys.append(EthKeys[i]["publicKey"]);
}
for ( uint8_t i = 0; i < n; i++){
......@@ -1030,9 +1030,9 @@ void SendRPCRequest(){
// cerr << "length is" << pubShares[i].length() << endl;
}
// Json::Value ComplaintResponse = c.ComplaintResponse(poly_names[1], 0);
// cerr << "share * G2 is " << ComplaintResponse["share*G2"].asString();
// cerr << "DHKey is " << ComplaintResponse["DHKey"].asString();
// Json::Value complaintResponse = c.complaintResponse(poly_names[1], 0);
// cerr << "share * G2 is " << complaintResponse["share*G2"].asString();
// cerr << "DHKey is " << complaintResponse["DHKey"].asString();
int k = 0;
......@@ -1041,10 +1041,10 @@ void SendRPCRequest(){
for ( int i = 0; i < n; i++)
for ( int j = 0; j < n; j++){
if ( i != j ){
cerr << "SecretShare length is " << secretShares[i]["SecretShare"].asString().length() << endl;
string secretShare = secretShares[i]["SecretShare"].asString().substr(192*j, 192 );
secShares_vect[i] += secretShares[j]["SecretShare"].asString().substr(192*i, 192 );
bool res = c.DKGVerification(pubShares[i], EthKeys[j]["KeyName"].asString(), secretShare, t, n, j)["result"].asBool();
cerr << "SecretShare length is " << secretShares[i]["secretShare"].asString().length() << endl;
string secretShare = secretShares[i]["secretShare"].asString().substr(192*j, 192 );
secShares_vect[i] += secretShares[j]["secretShare"].asString().substr(192*i, 192 );
bool res = c.dkgVerification(pubShares[i], EthKeys[j]["keyName"].asString(), secretShare, t, n, j)["result"].asBool();
k++;
cerr << "NOW K IS " << k << " i is " << i << " j is " << j << endl;
REQUIRE( res );
......@@ -1087,19 +1087,19 @@ TEST_CASE("ecdsa API test", "[ecdsa_api_test]") {
cout << genKey << endl;
REQUIRE(genKey["status"].asInt() == 0);
Json::Value getPubKey = c.getPublicECDSAKey(genKey["KeyName"].asString());
Json::Value getPubKey = c.getPublicECDSAKey(genKey["keyName"].asString());
cout << getPubKey << endl;
REQUIRE(getPubKey["status"].asInt() == 0);
REQUIRE(getPubKey["PublicKey"].asString() == genKey["PublicKey"].asString());
REQUIRE(getPubKey["publicKey"].asString() == genKey["publicKey"].asString());
Json::Value ecdsaSign = c.ecdsaSignMessageHash(16, genKey["KeyName"].asString(), "0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db");
Json::Value ecdsaSign = c.ecdsaSignMessageHash(16, genKey["keyName"].asString(), "0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db");
cout << ecdsaSign << endl;
REQUIRE(ecdsaSign["status"].asInt() == 0);
// //wrong base
// Json::Value ecdsaSignWrongBase = c.ecdsaSignMessageHash(0, genKey["KeyName"].asString(), "0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db");
// Json::Value ecdsaSignWrongBase = c.ecdsaSignMessageHash(0, genKey["keyName"].asString(), "0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db");
// cout << ecdsaSignWrongBase << endl;
// REQUIRE(ecdsaSignWrongBase["status"].asInt() != 0);
//
......@@ -1112,7 +1112,7 @@ TEST_CASE("ecdsa API test", "[ecdsa_api_test]") {
// cout << getPubKeyWrongKeyName << endl;
//
// //wrong hash
// Json::Value ecdsaSignWrongHash = c.ecdsaSignMessageHash(16, genKey["KeyName"].asString(), "");
// Json::Value ecdsaSignWrongHash = c.ecdsaSignMessageHash(16, genKey["keyName"].asString(), "");
// cout << ecdsaSignWrongHash << endl;
// REQUIRE(ecdsaSignWrongHash["status"].asInt() != 0);
......@@ -1186,14 +1186,14 @@ TEST_CASE("dkg API test", "[dkg_api_test]") {
//wrong verif
Json::Value Skeys = c.getSecretShare(polyName, publicKeys, 2, 2);
Json::Value verifVect = c.getVerificationVector(polyName, 2, 2);
Json::Value verificationWrongSkeys = c.DKGVerification("","","",2, 2, 1);
Json::Value verificationWrongSkeys = c.dkgVerification("","","",2, 2, 1);
REQUIRE(verificationWrongSkeys["status"].asInt() != 0);
cout << verificationWrongSkeys << endl;
sgx_destroy_enclave(eid);
}
TEST_CASE("IsPolyExists test", "[is_poly_test]") {
TEST_CASE("isPolyExists test", "[is_poly_test]") {
DEBUG_PRINT = 1;
is_sgx_https = 0;
......@@ -1211,11 +1211,11 @@ TEST_CASE("IsPolyExists test", "[is_poly_test]") {
string polyName = "POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1";
Json::Value genPoly = c.generateDKGPoly(polyName, 2);
cout << genPoly << endl;
Json::Value polyExists = c.IsPolyExists(polyName);
Json::Value polyExists = c.isPolyExists(polyName);
cout << polyExists << endl;
REQUIRE(polyExists["IsExist"].asBool());
Json::Value polyDoesNotExist = c.IsPolyExists("Vasya");
Json::Value polyDoesNotExist = c.isPolyExists("Vasya");
cout << polyDoesNotExist << endl;
REQUIRE(!polyDoesNotExist["IsExist"].asBool());
......
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