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();
......
This diff is collapsed.
......@@ -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
......
This diff is collapsed.
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