Unverified Commit 833cf64a authored by Oleh Nikolaiev's avatar Oleh Nikolaiev Committed by GitHub

Merge pull request #8 from skalenetwork/enhancement/SKALE-1779-Change-generateECDSAKey-in-SGX

SKALE-1779-Change-generateECDSAKey-in-SGX
parents 25de8639 8a1e5032
......@@ -145,7 +145,6 @@ std::string get_secret_shares(const std::string& polyName, const char* encrypted
std::string name = "DKG_DH_KEY_" + polyName + "_" + std::to_string(i) + ":";
//writeDataToDB(name, hexEncrKey);
std::cerr << errMsg1 << std::endl << std::endl;
//std::cerr << "iteration " << i <<" result length is " << result.length() << std::endl ;
//std::cerr << "iteration " << i <<" share length is " << strlen(cur_share) << std::endl;
......@@ -230,6 +229,51 @@ std::string GetBLSPubKey(const char * encryptedKeyHex){
get_bls_pub_key(eid, &err_status, errMsg1, encr_key, dec_key_len, pub_key);
std::string result = pub_key;
}
std::pair<std::string, std::string> response_to_complaint(const std::string& polyName, const char* encryptedPolyHex, int n, int t, int ind){
char* errMsg1 = (char*) calloc(1024,1);
int err_status = 0;
uint64_t enc_len = 0;
uint8_t* encr_dkg_poly = (uint8_t*) calloc(DKG_MAX_SEALED_LEN, 1);
hex2carray2(encryptedPolyHex, &enc_len, encr_dkg_poly, 6100);
status = set_encrypted_dkg_poly(eid, &err_status, errMsg1, encr_dkg_poly);
std::string DH_key_name = polyName + "_" + std::to_string(ind) + ":";
std::shared_ptr<std::string> hexEncrKey_ptr = readFromDb(DH_key_name, "DKG_DH_KEY_");
char *hexEncrKey = (char *) calloc(2 * BUF_LEN, 1);
uint64_t DH_enc_len = 0;
uint8_t encrypted_DHkey[BUF_LEN];
hex2carray(hexEncrKey_ptr->c_str(), &DH_enc_len, encrypted_DHkey);
uint32_t dec_len;
char decrpyted_DHkey[ECDSA_SKEY_LEN];
char s_shareG2[257];
status = complaint_response(eid, &err_status, errMsg1, encrypted_DHkey, encr_dkg_poly, &dec_len,
decrpyted_DHkey, s_shareG2, t, n, ind);
std::pair<std::string, std::string> result;
result.first = decrpyted_DHkey;
result.second = s_shareG2;
//std::cerr << errMsg1 << std::endl << std::endl;
//std::cerr << "iteration " << i <<" result length is " << result.length() << std::endl ;
//std::cerr << "iteration " << i <<" share length is " << strlen(cur_share) << std::endl;
//std::cerr << "iteration " << i <<" share is " << cur_share << std::endl;
//result += '\0';
free(encr_dkg_poly);
free(errMsg1);
free(hexEncrKey);
return result;
}
\ No newline at end of file
......@@ -18,6 +18,8 @@ std::string get_secret_shares(const std::string& polyName, const char* encrypted
bool VerifyShares(const char* publicShares, const char* encr_sshare, const char * encryptedKeyHex, int t, int n, int ind);
std::pair<std::string, std::string> response_to_complaint(const std::string& polyName, const char* encryptedPolyHex, int n, int t, int ind);
bool CreateBLSShare( const std::string& BLSKeyName, const char * s_shares, const char * encryptedKeyHex);
std::string GetBLSPubKey(const char * encryptedKeyHex);
......
......@@ -7,6 +7,8 @@
#include "sgxwallet.h"
#include <iostream>
#include <gmp.h>
#include <random>
std::vector<std::string> gen_ecdsa_key(){
char *errMsg = (char *)calloc(1024, 1);
......@@ -17,7 +19,7 @@ std::vector<std::string> gen_ecdsa_key(){
uint32_t enc_len = 0;
status = generate_ecdsa_key(eid, &err_status, errMsg, encr_pr_key, &enc_len, pub_key_x, pub_key_y );
std::vector<std::string> keys(2);
std::vector<std::string> keys(3);
std::cerr << "account key is " << errMsg << std::endl;
char *hexEncrKey = (char *) calloc(2*BUF_LEN, 1);
carray2Hex(encr_pr_key, enc_len, hexEncrKey);
......@@ -26,6 +28,24 @@ std::vector<std::string> gen_ecdsa_key(){
//std::cerr << "in ECDSACrypto encr key x " << keys.at(0) << std::endl;
//std::cerr << "in ECDSACrypto encr_len %d " << enc_len << std::endl;
std::default_random_engine rand_gen((unsigned int) time(0));
unsigned long seed = rand_gen();
gmp_randstate_t state;
gmp_randinit_default(state);
gmp_randseed_ui(state, seed);
mpz_t rand32;
mpz_init(rand32);
mpz_urandomb(rand32, state, 257);
char arr[mpz_sizeinbase (rand32, 16) + 2];
char * rand_str = mpz_get_str(arr, 16, rand32);
keys.at(2) = rand_str;
gmp_randclear(state);
mpz_clear(rand32);
free(errMsg);
free(pub_key_x);
......
......@@ -103,6 +103,23 @@ void LevelDB::deleteOlegKey (const std::string &_key) {
std::cerr << "key deleted " << full_key << std::endl;
}
void LevelDB::deleteTempNEK(const std::string &_key){
std::lock_guard<std::recursive_mutex> lock(mutex);
std::string prefix = _key.substr(0,8);
if (prefix != "tmp_NEK:") {
return;
}
auto status = db->Delete(writeOptions, Slice(_key));
throwExceptionOnError(status);
std::cerr << "key deleted " << _key << std::endl;
}
void LevelDB::writeByteArray(const char *_key, size_t _keyLen, const char *value,
size_t _valueLen) {
......
......@@ -62,6 +62,8 @@ public:
void deleteOlegKey (const std::string &_key);
void deleteTempNEK (const std::string &_key);
public:
......
......@@ -144,7 +144,7 @@ Json::Value importECDSAKeyImpl(const std::string &key, const std::string &keyNam
}
Json::Value generateECDSAKeyImpl(const std::string &_keyName) {
Json::Value generateECDSAKeyImpl() {
Json::Value result;
result["status"] = 0;
......@@ -153,7 +153,6 @@ Json::Value generateECDSAKeyImpl(const std::string &_keyName) {
cerr << "Calling method generateECDSAKey" << endl;
std::vector<std::string>keys;
try {
......@@ -162,20 +161,56 @@ Json::Value generateECDSAKeyImpl(const std::string &_keyName) {
throw RPCException(UNKNOWN_ERROR, "");
}
// std::cerr << "write encr key" << keys.at(0) << std::endl;
writeECDSAKey(_keyName, keys.at(0));
std::string keyName = "tmp_NEK:" + keys.at(2);
//writeECDSAKey(keyName, keys.at(0));
writeDataToDB(keyName, keys.at(0));
result["encryptedKey"] = keys.at(0);
result["PublicKey"] = keys.at(1);
result["KeyName"] = keyName;
} catch (RPCException &_e) {
std::cerr << " err str " << _e.errString << std::endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
}
//std::cerr << "in SGXWalletServer encr key x " << keys.at(0) << std::endl;
result["encryptedKey"] = keys.at(0);
result["PublicKey"] = keys.at(1);
return result;
}
Json::Value renameESDSAKeyImpl(const std::string& KeyName, const std::string& tempKeyName){
Json::Value result;
result["status"] = 0;
result["errorMessage"] = "";
result["encryptedKey"] = "";
//std::cerr << "in SGXWalletServer encr key x " << keys.at(0) << std::endl;
try {
return result;
std::string prefix = tempKeyName.substr(0,8);
if (prefix != "tmp_NEK:") {
throw RPCException(UNKNOWN_ERROR, "");
}
prefix = KeyName.substr(0,5);
if (prefix != "NODE_") {
throw RPCException(UNKNOWN_ERROR, "");
}
std::string chain_str = "CHAIN_";
if ( KeyName.find(chain_str) == std::string::npos){
throw RPCException(UNKNOWN_ERROR, "");
}
std::shared_ptr<std::string> key_ptr = readFromDb(tempKeyName,"");//readECDSAKey(_keyName);
writeDataToDB(KeyName, *key_ptr);
levelDb->deleteTempNEK(tempKeyName);
} catch (RPCException &_e) {
std::cerr << " err str " << _e.errString << std::endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
}
return result;
}
......@@ -397,10 +432,10 @@ Json::Value CreateBLSPrivateKeyImpl(const std::string & BLSKeyName, const std::s
std::cerr << "error " << std::endl;
}
/* for ( int i = 0; i < n; i++){
for ( int i = 0; i < n; i++){
std::string name = polyName + "_" + std::to_string(i) + ":";
levelDb -> deleteDHDKGKey(name);
}*/
}
} catch (RPCException &_e) {
std::cerr << " err str " << _e.errString << std::endl;
......@@ -432,8 +467,30 @@ Json::Value GetBLSPublicKeyShareImpl(const std::string & BLSKeyName){
return result;
}
Json::Value ComplaintResponseImpl(const std::string& polyName, int n, int t, int ind){
Json::Value result;
result["status"] = 0;
result["errorMessage"] = "";
try {
std::shared_ptr<std::string> encr_poly_ptr = readFromDb(polyName, "DKGPoly:");
std::pair<std::string, std::string> response = response_to_complaint(polyName, encr_poly_ptr->c_str(), n, t, ind);
result["share*G2"] = response.second;
result["DHKey"] = response.first;
} catch (RPCException &_e) {
std::cerr << " err str " << _e.errString << std::endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
}
return result;
}
Json::Value SGXWalletServer::generateDKGPoly(const std::string& polyName, int t){
std::cerr << "entered generateECDSAKey" << std::endl;
std::cerr << "entered generateDKGPoly" << std::endl;
lock_guard<recursive_mutex> lock(m);
return generateDKGPolyImpl(polyName, t);
}
......@@ -465,9 +522,14 @@ Json::Value SGXWalletServer::GetBLSPublicKeyShare(const std::string & BLSKeyName
Json::Value SGXWalletServer::generateECDSAKey(const std::string &_keyName) {
Json::Value SGXWalletServer::generateECDSAKey() {
lock_guard<recursive_mutex> lock(m);
return generateECDSAKeyImpl(_keyName);
return generateECDSAKeyImpl();
}
Json::Value SGXWalletServer::renameESDSAKey(const std::string& KeyName, const std::string& tempKeyName){
lock_guard<recursive_mutex> lock(m);
return renameESDSAKeyImpl(KeyName, tempKeyName);
}
Json::Value SGXWalletServer::getPublicECDSAKey(const std::string &_keyName) {
......@@ -476,12 +538,12 @@ Json::Value SGXWalletServer::getPublicECDSAKey(const std::string &_keyName) {
}
Json::Value SGXWalletServer::ecdsaSignMessageHash(int base, const std::string &_keyName, const std::string &messageHash ) {
lock_guard<recursive_mutex> lock(m);
std::cerr << "entered ecdsaSignMessageHash" << std::endl;
std::cerr << "MessageHash first " << messageHash << std::endl;
return ecdsaSignMessageHashImpl(base,_keyName, messageHash);
}
Json::Value SGXWalletServer::ecdsaSignMessageHash(int base, const std::string &_keyName, const std::string &messageHash ) {
lock_guard<recursive_mutex> lock(m);
std::cerr << "entered ecdsaSignMessageHash" << std::endl;
std::cerr << "MessageHash first " << messageHash << std::endl;
return ecdsaSignMessageHashImpl(base,_keyName, messageHash);
}
Json::Value
......@@ -502,6 +564,11 @@ Json::Value SGXWalletServer::importECDSAKey(const std::string &key, const std::s
return importECDSAKeyImpl(key, keyName);
}
Json::Value SGXWalletServer::ComplaintResponse(const std::string& polyName, int n, int t, int ind){
lock_guard<recursive_mutex> lock(m);
return ComplaintResponseImpl(polyName, n, t, ind);
}
shared_ptr<string> readFromDb(const string & name, const string & prefix) {
......
......@@ -24,7 +24,8 @@ public:
virtual Json::Value blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash, int n, int t, int signerIndex);
virtual Json::Value importECDSAKey(const std::string& key, const std::string& keyName);
virtual Json::Value generateECDSAKey(const std::string& keyName);
virtual Json::Value generateECDSAKey();
virtual Json::Value renameESDSAKey(const std::string& KeyName, const std::string& tempKeyName);
virtual Json::Value ecdsaSignMessageHash(int base, const std::string& keyShareName, const std::string& messageHash);
virtual Json::Value getPublicECDSAKey(const std::string& keyName);
......@@ -34,6 +35,7 @@ public:
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 n, int t, int ind);
};
......@@ -53,7 +55,8 @@ Json::Value importBLSKeyShareImpl(int index, const std::string& keyShare, const
Json::Value blsSignMessageHashImpl(const std::string& keyShareName, const std::string& messageHash, int n, int t, int signerIndex);
Json::Value importECDSAKeyImpl(const std::string& key, const std::string& keyName);
Json::Value generateECDSAKeyImpl(const std::string& keyName);
Json::Value generateECDSAKeyImpl();
Json::Value renameESDSAKeyImpl(const std::string& KeyName, const std::string& tempKeyName);
Json::Value ecdsaSignMessageHashImpl(int base, const std::string& keyName, const std::string& messageHash);
Json::Value getPublicECDSAKeyImpl(const std::string& keyName);
......@@ -63,5 +66,6 @@ Json::Value getSecretShareImpl(const std::string& polyName, const Json::Value& p
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 n, int t, int ind);
#endif //SGXWALLET_SGXWALLETSERVER_HPP
\ No newline at end of file
......@@ -16,7 +16,8 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
this->bindAndAddMethod(jsonrpc::Procedure("blsSignMessageHash", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "keyShareName",jsonrpc::JSON_STRING,"messageHash",jsonrpc::JSON_STRING,"n",jsonrpc::JSON_INTEGER,"signerIndex",jsonrpc::JSON_INTEGER,"t",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::blsSignMessageHashI);
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, "keyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::generateECDSAKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("generateECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, NULL), &AbstractStubServer::generateECDSAKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("renameESDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "KeyName",jsonrpc::JSON_STRING,"tempKeyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::renameESDSAKeyI);
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);
......@@ -43,9 +44,14 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
}
inline virtual void generateECDSAKeyI(const Json::Value &request, Json::Value &response)
{
response = this->generateECDSAKey(request["keyName"].asString());
(void)request;
response = this->generateECDSAKey();
}
inline virtual void getPublicECDSAKeyI(const Json::Value &request, Json::Value &response)
inline virtual void renameESDSAKeyI(const Json::Value &request, Json::Value &response)
{
response = this->renameESDSAKey(request["KeyName"].asString(), request["tempKeyName"].asString());
}
inline virtual void getPublicECDSAKeyI(const Json::Value &request, Json::Value &response)
{
response = this->getPublicECDSAKey(request["keyName"].asString());
}
......@@ -81,7 +87,8 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
virtual Json::Value importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t) = 0;
virtual Json::Value blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash, int n, int signerIndex, int t) = 0;
virtual Json::Value importECDSAKey(const std::string& key, const std::string& keyName) = 0;
virtual Json::Value generateECDSAKey(const std::string& keyName) = 0;
virtual Json::Value generateECDSAKey() = 0;
virtual Json::Value renameESDSAKey(const std::string& KeyName, const std::string& tempKeyName) = 0;
virtual Json::Value getPublicECDSAKey(const std::string& keyName) = 0;
virtual Json::Value ecdsaSignMessageHash(int base, const std::string& keyName, const std::string& messageHash) = 0;
......
......@@ -618,25 +618,29 @@ void get_encr_sshare(int *err_status, char *err_string, uint8_t *encrypted_skey,
free(cypher);
}
/*void complaint_response(int *err_status, char *err_string, uint8_t *encrypted_DHkey, uint8_t *encrypted_koefs, uint32_t* dec_len,
char* s_key, char* s_shareG2, uint8_t _t, uint8_t _n, uint8_t ind1, uint8_t ind2){
void complaint_response(int *err_status, char *err_string, uint8_t *encrypted_DHkey, uint8_t *encrypted_dkg_secret, uint32_t* dec_len,
char* DH_key, char* s_shareG2, uint8_t _t, uint8_t _n, uint8_t ind1){
uint32_t enc_len;
sgx_status_t status = sgx_unseal_data(
(const sgx_sealed_data_t *)encrypted_DHkey, NULL, 0, (uint8_t *)skey, &enc_len);
(const sgx_sealed_data_t *)encrypted_DHkey, NULL, 0, (uint8_t *)DH_key, &enc_len);
if (status != SGX_SUCCESS) {
snprintf(err_string, BUF_LEN,"sgx_unseal_data failed with status %d", status);
return;
}
char* s_shareG2 = (char *)malloc(196);
calc_secret_shareG2(decrypted_koefs, s_shareG2, _t, ind2);
char* decrypted_dkg_secret = (char*)malloc(DKG_BUFER_LENGTH);
uint32_t decr_len;
decrypt_dkg_secret(err_status, err_string, encrypted_dkg_secret, (uint8_t*)decrypted_dkg_secret, &decr_len);
if (*err_status != 0) {
snprintf(err_string, BUF_LEN,"sgx_unseal_data failed with status %d", *err_status);
return;
}
free(s_shareG2);
}*/
calc_secret_shareG2(decrypted_dkg_secret, s_shareG2, _t, ind1);
free(decrypted_dkg_secret);
}
void dkg_verification(int *err_status, char* err_string, const char * public_shares, const char* s_share,
uint8_t* encrypted_key, uint64_t key_len, unsigned _t, int _ind, int * result){
......@@ -770,9 +774,6 @@ void create_bls_key(int *err_status, char* err_string, const char* s_shares,
return;
}
//snprintf(err_string, BUF_LEN,"sshare is %s", decr_sshare);
//snprintf(err_string, BUF_LEN,"encr_share is %s", encr_sshare);
//snprintf(err_string, BUF_LEN,"common_key is %s", common_key);
......
......@@ -143,6 +143,18 @@ enclave {
[in, count = 1024] uint8_t* encrypted_key,
uint64_t key_len,
[out, count = 320] char* bls_pub_key);
public void complaint_response(
[user_check] int *err_status,
[out, count = 1024] char* err_string,
[in, count = 1024] uint8_t *encrypted_DHkey,
[in, count = 3050] uint8_t *encrypted_dkg_secret,
[user_check] uint32_t* dec_len,
[out, count = 65] char* DH_key,
[out, count = 257] char* s_shareG2,
uint8_t _t,
uint8_t _n,
uint8_t ind1);
};
......
......@@ -29,7 +29,6 @@
"errorMessage": "12345",
"signatureShare": "12345"
}
},
{
......@@ -47,17 +46,27 @@
{
"name": "generateECDSAKey",
"params": {
"keyName": "key1"
},
"returns": {
"status": 0,
"errorMessage": "12345",
"encryptedKey": "12345",
"KeyName": "tmp:123",
"PublicKey": "12345"
}
},
{
"name": "renameESDSAKey",
"params": {
"tempKeyName": "key1",
"KeyName": "key2"
},
"returns": {
"status": 0,
"errorMessage": "12345"
}
},
{
"name": "getPublicECDSAKey",
"params": {
......@@ -101,7 +110,7 @@
{
"name": "getVerificationVector",
"params": {
"polyName": "key1",
"polyName": "p1",
"n": 3,
"t": 3
},
......@@ -139,7 +148,7 @@
"returns": {
"status": 0,
"errorMessage": "12345",
"result": True
"result": true
}
},
{
......@@ -169,6 +178,22 @@
"errorMessage": "12345",
"BLSPublicKeyShare": "123"
}
},
{
"name": "ComplaintResponse",
"params": {
"polyName": "p1",
"n": 3,
"t": 3,
"ind": 1
},
"returns": {
"status": 0,
"errorMessage": "12345",
"share*G2": "123",
"DHKey": "123"
}
}
......
......@@ -17,7 +17,7 @@ int init_client() {
Json::Value params;
try {
cout << c.generateECDSAKey("test_key") << endl;
cout << c.generateECDSAKey() << endl;
} catch (JsonRpcException &e) {
cerr << e.what() << endl;
}
......
......@@ -51,15 +51,26 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value generateECDSAKey(const std::string& keyName) throw (jsonrpc::JsonRpcException)
Json::Value generateECDSAKey() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["keyName"] = keyName;
Json::Value result = this->CallMethod("generateECDSAKey",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("generateECDSAKey",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value renameESDSAKey(const std::string& KeyName, const std::string& tempKeyName) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["KeyName"] = KeyName;
p["tempKeyName"] = tempKeyName;
Json::Value result = this->CallMethod("renameESDSAKey",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value getPublicECDSAKey(const std::string& keyName) throw (jsonrpc::JsonRpcException)
{
......
......@@ -724,7 +724,8 @@ TEST_CASE("API test", "[api_test]") {
//levelDb->deleteOlegKey("1");
// cout << c.generateECDSAKey("key1") << endl;
cout << c.generateECDSAKey() << endl;
// cout << c.renameESDSAKey("NODE_1CHAIN_1","tmp_NEK:bcacde0d26c0ea2c7e649992e7f791e1fba2492f5b7ae63dadb799075167c7fc");
//cout<<c.getPublicECDSAKey("test_key1");
//cout << c.ecdsaSignMessageHash(16, "known_key1","0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db" );
// cout << c.blsSignMessageHash(TEST_BLS_KEY_NAME, "0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db", 2,2,1 );
......@@ -755,7 +756,7 @@ TEST_CASE("API test", "[api_test]") {
std::string share = share_big.substr(0, 192);
std::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);
......
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