Unverified Commit a0f4a55d authored by svetaro's avatar svetaro

SKALE-1795 Add more exceptions to SGX server

parent 1b12bcfd
......@@ -89,6 +89,9 @@ std::vector <std::vector<std::string>> get_verif_vect(const char* encryptedPolyH
uint32_t len;
status = get_public_shares(eid, &err_status, errMsg1, encr_dkg_poly, len, public_shares, t, n);
if ( status != 0){
}
std::cerr << "err msg " << errMsg1 << std::endl;
std::cerr << "public_shares:" << std::endl;
......@@ -140,14 +143,20 @@ std::string get_secret_shares(const std::string& polyName, const char* encrypted
result += cur_share;
uint32_t enc_len = BUF_LEN;
carray2Hex(encrypted_skey, enc_len, hexEncrKey);
//uint32_t enc_len = BUF_LEN;
std::cerr << "dec len is " << dec_len << std::endl;
carray2Hex(encrypted_skey, dec_len, hexEncrKey);
std::string name = "DKG_DH_KEY_" + polyName + "_" + std::to_string(i) + ":";
std::cerr << "name to write to db is " << name << std::endl;
std::string DHKey_name = "DKG_DH_KEY_" + polyName + "_" + std::to_string(i) + ":";
std::cerr << "name to write to db is " << DHKey_name << std::endl;
std::cerr << "hexEncrKey: " << hexEncrKey << std::endl;
// writeDataToDB(name, hexEncrKey);
writeDataToDB(DHKey_name, hexEncrKey);
std::string shareG2_name = "shareG2_" + polyName + "_" + std::to_string(i) + ":";
std::cerr << "name to write to db is " << shareG2_name << std::endl;
std::cerr << "s_shareG2: " << s_shareG2 << std::endl;
writeDataToDB(shareG2_name, s_shareG2);
std::cerr << errMsg1 << std::endl << std::endl;
//std::cerr << "iteration " << i <<" result length is " << result.length() << std::endl ;
......@@ -246,18 +255,11 @@ std::vector<std::string> GetBLSPubKey(const char * encryptedKeyHex){
return pub_key_vect;
}
std::pair<std::string, std::string> response_to_complaint(const std::string& polyName, const char* encryptedPolyHex, int n, int t, int ind){
std::string decrypt_DHKey(const std::string& polyName, 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);
std::string DH_key_name = polyName + "_" + std::to_string(ind) + ":";
std::shared_ptr<std::string> hexEncrKey_ptr = readFromDb(DH_key_name, "DKG_DH_KEY_");
std::cerr << "encr DH key is " << hexEncrKey_ptr << std::endl;
......@@ -268,28 +270,14 @@ std::pair<std::string, std::string> response_to_complaint(const std::string& pol
uint8_t encrypted_DHkey[BUF_LEN];
hex2carray(hexEncrKey_ptr->c_str(), &DH_enc_len, encrypted_DHkey);
char DHKey[ECDSA_SKEY_LEN];
uint32_t dec_len;
char decrpyted_DHkey[ECDSA_SKEY_LEN];
char s_shareG2[320];//[257];
status = complaint_response(eid, &err_status, errMsg1, encrypted_DHkey, encr_dkg_poly, &dec_len,
decrpyted_DHkey, s_shareG2, t, n, ind);
decrypt_key(eid, &err_status, errMsg1, encrypted_DHkey, DH_enc_len, DHKey);
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;
free(encr_dkg_poly);
free(errMsg1);
free(hexEncrKey);
return result;
return DHKey;
}
......@@ -18,7 +18,7 @@ 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);
std::string decrypt_DHKey(const std::string& polyName, int ind);
bool CreateBLSShare( const std::string& BLSKeyName, const char * s_shares, const char * encryptedKeyHex);
......
......@@ -66,7 +66,7 @@ COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c
COMMON_ENCLAVE_SRC = secure_enclave_u.c secure_enclave_u.h
sgxwallet_SOURCES = sgxwallet.c SGXWalletServer.cpp RPCException.cpp BLSCrypto.cpp ECDSACrypto.cpp \
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp $(COMMON_SRC)
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp ServerDataChecker.cpp $(COMMON_SRC)
nodist_sgxwallet_SOURCES = $(COMMON_ENCLAVE_SRC)
......@@ -98,7 +98,7 @@ sgxwallet_LDADD=-l$(SGX_URTS_LIB) -Lleveldb/build -LlibBLS/build -LlibBLS/build
testw_SOURCES=testw.cpp stubclient.cpp SGXWalletServer.cpp RPCException.cpp BLSCrypto.cpp ServerInit.cpp LevelDB.cpp \
DKGCrypto.cpp BLSPrivateKeyShareSGX.cpp ECDSACrypto.cpp $(COMMON_SRC)
DKGCrypto.cpp BLSPrivateKeyShareSGX.cpp ECDSACrypto.cpp ServerDataChecker.cpp $(COMMON_SRC)
nodist_testw_SOURCES=${nodist_sgxwallet_SOURCES}
EXTRA_testw_DEPENDENCIES=${EXTRA_sgxwallet_DEPENDENCIES}
testw_LDADD= ${sgxwallet_LDADD}
This diff is collapsed.
......@@ -35,7 +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);
virtual Json::Value ComplaintResponse(const std::string& polyName, int ind);
};
......@@ -45,12 +45,6 @@ void writeDataToDB(const string & Name, const string &value);
void writeKeyShare(const string &_keyShareName, const string &value, int index, int n, int t);
shared_ptr<std::string> readKeyShare(const string& _keyShare);
void writeECDSAKey(const string& _keyName, const string& value);
shared_ptr<std::string> readECDSAKey(const string& _key);
void writeDKGPoly(const string &_polyName, const string &value);
Json::Value importBLSKeyShareImpl(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t);
Json::Value blsSignMessageHashImpl(const std::string& keyShareName, const std::string& messageHash, int n, int t, int signerIndex);
......@@ -66,6 +60,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);
Json::Value ComplaintResponseImpl(const std::string& polyName, int ind);
#endif //SGXWALLET_SGXWALLETSERVER_HPP
\ No newline at end of file
......@@ -2,7 +2,11 @@
// Created by kladko on 11/19/19.
//
std::vector<std::string> BLSutils::SplitString(std::string& str, const std::string& delim){
#include <vector>
#include "ServerDataChecker.h"
#include <gmp.h>
std::vector<std::string> SplitString(const std::string& str, const std::string& delim = ":"){
std::vector<std::string> tokens;
size_t prev = 0, pos = 0;
do {
......@@ -16,6 +20,166 @@ std::vector<std::string> BLSutils::SplitString(std::string& str, const std::stri
return tokens;
}
bool checkPolyName (std::string polyName){
bool checkECDSAKeyName(const std::string& keyName) {
std::vector<std::string> parts = SplitString(keyName);
if (parts.size() != 2) {
return false;
}
if (parts.at(0) != "NEK") {
return false;
}
if ( parts.at(1).length() > 64 || parts.at(1).length() < 1){
return false;
}
mpz_t num;
mpz_init(num);
if ( mpz_set_str(num, parts.at(1).c_str(), 16) == -1){
mpz_clear(num);
return false;
}
mpz_clear(num);
return true;
}
bool checkHex(const std::string& hex, const uint32_t sizeInBytes){
if ( hex.length() > sizeInBytes * 2 || hex.length() == 0){
return false;
}
mpz_t num;
mpz_init(num);
if ( mpz_set_str(num, hex.c_str(), 16) == -1){
mpz_clear(num);
return false;
}
mpz_clear(num);
return true;
}
bool checkPolyName (const std::string& polyName){
std::vector<std::string> parts = SplitString(polyName);
if ( parts.size() != 7) {
return false;
}
if ( parts.at(0) != "POLY") {
return false;
}
if ( parts.at(1) != "SCHAIN_ID"){
return false;
}
if ( parts.at(3) != "NODE_ID"){
return false;
}
if ( parts.at(5) != "DKG_ID"){
return false;
}
if ( parts.at(2).length() > 64 || parts.at(2).length() < 1){
return false;
}
if (parts.at(4).length() > 5 || parts.at(4).length() < 1){
return false;
}
if ( parts.at(6).length() > 64 || parts.at(6).length() < 1){
return false;
}
mpz_t num;
mpz_init(num);
if ( mpz_set_str(num, parts.at(2).c_str(), 16) == -1){
mpz_clear(num);
return false;
}
mpz_clear(num);
mpz_init(num);
if ( mpz_set_str(num, parts.at(4).c_str(), 10) == -1){
mpz_clear(num);
return false;
}
mpz_clear(num);
mpz_init(num);
if ( mpz_set_str(num, parts.at(6).c_str(),16) == -1){
mpz_clear(num);
return false;
}
mpz_clear(num);
return true;
}
bool checkName (const std::string& Name, const std::string& prefix){
std::vector<std::string> parts = SplitString(Name);
if ( parts.size() != 7) {
return false;
}
if ( parts.at(0) != prefix ) {
return false;
}
if ( parts.at(1) != "SCHAIN_ID"){
return false;
}
if ( parts.at(3) != "NODE_ID"){
return false;
}
if ( parts.at(5) != "DKG_ID"){
return false;
}
if ( parts.at(2).length() > 64 || parts.at(2).length() < 1){
return false;
}
if (parts.at(4).length() > 5 || parts.at(4).length() < 1){
return false;
}
if ( parts.at(6).length() > 64 || parts.at(6).length() < 1){
return false;
}
mpz_t num;
mpz_init(num);
if ( mpz_set_str(num, parts.at(2).c_str(), 16) == -1){
mpz_clear(num);
return false;
}
mpz_clear(num);
mpz_init(num);
if ( mpz_set_str(num, parts.at(4).c_str(), 10) == -1){
mpz_clear(num);
return false;
}
mpz_clear(num);
mpz_init(num);
if ( mpz_set_str(num, parts.at(6).c_str(),16) == -1){
mpz_clear(num);
return false;
}
mpz_clear(num);
return true;
}
bool check_n_t ( const int n, const int t){
if (t > n){
return false;
}
if ( t == 0 || n == 0){
return false;
}
if ( t < 0 || n < 0){
return false;
}
return true;
}
\ No newline at end of file
......@@ -5,4 +5,16 @@
#ifndef SGXD_SERVERDATACHECKER_H
#define SGXD_SERVERDATACHECKER_H
#include <string>
bool checkECDSAKeyName(const std::string& keyName);
bool checkHex(const std::string& hash, const uint32_t sizeInBytes = 32);
bool checkPolyName (const std::string& polyName);
bool checkName (const std::string& Name, const std::string& prefix);
bool check_n_t ( const int n, const int t);
#endif // SGXD_SERVERDATACHECKER_H
......@@ -27,7 +27,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
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, "n",jsonrpc::JSON_INTEGER,"t",jsonrpc::JSON_INTEGER, "ind",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::ComplaintResponseI);
this->bindAndAddMethod(jsonrpc::Procedure("ComplaintResponse", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING,"ind",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::ComplaintResponseI);
}
......@@ -86,7 +86,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
}
inline virtual void ComplaintResponseI(const Json::Value &request, Json::Value &response)
{
response = this->ComplaintResponse( request["polyName"].asString(), request["n"].asInt(), request["t"].asInt(),request["ind"].asInt());
response = this->ComplaintResponse( request["polyName"].asString(), request["ind"].asInt());
}
virtual Json::Value importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t) = 0;
......@@ -103,7 +103,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
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 n, int t, int ind) = 0;
virtual Json::Value ComplaintResponse(const std::string& polyName, int ind) = 0;
};
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
......@@ -100,6 +100,10 @@ void gen_dkg_poly( char* secret, unsigned _t ){
result += ":";
}
strncpy(secret, result.c_str(), result.length() + 1);
if (strlen(secret) == 0){
throw std::exception();
}
}
libff::alt_bn128_Fr PolynomialValue(const std::vector<libff::alt_bn128_Fr>& pol, libff::alt_bn128_Fr point, unsigned _t) {
......
......@@ -584,6 +584,8 @@ void get_encr_sshare(int *err_status, char *err_string, uint8_t *encrypted_skey,
generate_ecdsa_key(err_status, err_string, encrypted_skey, &enc_len, pub_key_x, pub_key_y);
// snprintf(err_string, BUF_LEN,"pub_key_x is %s", pub_key_x);
*dec_len = enc_len;
sgx_status_t status = sgx_unseal_data(
(const sgx_sealed_data_t *)encrypted_skey, NULL, 0, (uint8_t *)skey, &enc_len);
......
......@@ -29,6 +29,8 @@
#define DKG_BUFER_LENGTH 2490//3060
#define DKG_MAX_SEALED_LEN 3050
#define SECRET_SHARE_NUM_BYTES 96
#define ECDSA_SKEY_LEN 65
#define ECDSA_SKEY_BASE 16
#define ECDSA_ENCR_LEN 625
......@@ -46,7 +48,15 @@
#define COULD_NOT_ACCESS_DATABASE -9
#define NULL_DATABASE -10
#define WALLETDB_NAME "sgxwallet.db" //"test_sgxwallet.db"//
#define INVALID_POLY_NAME -11
#define INVALID_DKG_PARAMS -12
#define INVALID_ECDSA_KEY_NAME -20
#define INVALID_HEX -21
#define SGX_ERROR -666;
#define WALLETDB_NAME "test_sgxwallet.db"//"sgxwallet.db" //
#define ENCLAVE_NAME "secure_enclave.signed.so"
......
......@@ -139,7 +139,7 @@
"name": "DKGVerification",
"params": {
"publicShares": "123",
"EthKeyName":"key_j",
"EthKeyName":"NEK:hex",
"SecretShare": "f_ij",
"n": 3,
"t": 3,
......@@ -154,9 +154,9 @@
{
"name": "CreateBLSPrivateKey",
"params": {
"BLSKeyName": "key",
"EthKeyName":"key1",
"polyName":"p1",
"BLSKeyName": "BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID: ",
"EthKeyName":"NEK:hex",
"polyName":"POLY:SCHAIN_ID :NODE_ID :DKG_ID: ",
"SecretShare": "122",
"n": 3,
"t": 3
......@@ -171,7 +171,7 @@
{
"name": "GetBLSPublicKeyShare",
"params": {
"BLSKeyName": "key"
"BLSKeyName": "BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID"
},
"returns": {
"status": 0,
......
......@@ -173,12 +173,10 @@ class StubClient : public jsonrpc::Client
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value ComplaintResponse(const std::string& polyName, int n, int t, int ind) throw (jsonrpc::JsonRpcException)
Json::Value ComplaintResponse(const std::string& polyName, int ind) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["polyName"] = polyName;
p["n"] = n;
p["t"] = t;
p["ind"] = ind;
Json::Value result = this->CallMethod("ComplaintResponse",p);
if (result.isObject())
......
......@@ -701,13 +701,6 @@ TEST_CASE("get public ECDSA key", "[get_pub_ecdsa_key_test]") {
}*/
TEST_CASE( "dkg_complaint test1", "[dkgc]" ) {
init_daemon();
init_enclave();
char* encr_poly = "04000200000000000406ffffff02000000000000000000000b000000000000ff0000000000000000877a3884976af70f3de0ed7ad82b16cad2b5e69bf9976f3012a421ee7025c4b5000000f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ba090000000000000000000000000000ba090000000000000000000000000000426594165b64a693699c19f0efcbe2b1e7bde98de433a929f8fcdbc093e5f490d3f17674667de6160945584897077c401f3fa0bc05b26dc6ffea9a3d38bbcedaccb45bc39858050e97a5ae98f02ecd17ac32784d2cda930481805c1b9db38443ccef23a3c0bcc3f010a562bfc7b9d9db73fa412273ff884fdb8c0b9e72dfb114707f930bee9d44241fcfb7fd455d68b5cdf2b687afcf9fa8b568a7b17ea60258d821fbdeafdc8524db14165530836216eaccd3d7f9e03762db61d0c506f4fbb4f6d21336c8fd1e59cf6c57d91046cd0a4b0e044daab39371bb9dcbf11aa652246b6a93ff536629c8b54fa7e8074795190edc702ca162386f1c26c3601c2ea27a677194a2c183396ecad15c0d5da95a8137c4e7967c2b3f829a6d80d4fa13a53058e7aa3b807ca665770ba6495e38526f92479aac823e8224ca633982722424dc2498929bd076daea93a73d4ad60e4924496bcca55a95977139801cb7407caf4bba76ac972ea91cbee2661d18d404cd652b0df6ef09736f473d4cead9a218809e0a726bfcf2823006375d25b07c514eab9249a4d17da0f2a3f05886dc3698bba6de7b2e32beb96386a69385274dac607e2e7f7e68fa7673b83c99798298e44d64c118c42ce8a0102cb45cb892283c5d201c19ae12a38890e18ef610f87fd63c3571b8e9ba782ebd62282e14cc4bf5cb9eb4280a5cb63b4b31a88720c043fd1e0c3b916016cc46c480bab1e7fdf5a2960df8babdbe19083e17bd65c58482affb3dd549f5674eb761be49b80c16ded7f41bc1993d5af5d27a55b9be24fa20d288087978c70119bed4c441f0e109baf95d80df7623ff6ad31f28e906413d12ebeb4669f96c34931511b37b6a5be5935c905c893ed9b0518275bd5cf241c73f6d06169f30a74e65e6f240f8e2ed696a9964851fb18b827bbc15ea20738891a7a69312d85e47b42bd24dca3285876ad41a1750d53e5f919a453a91ddb11943292ced0130828dfa08c9d3cea0a50a2619af4735770df386074c72cd60b87ede0fe53885340b907c9c02d8a7fc4c7bf509c169b049ef627c33926c9247d9e1a44c27b86b722385d8e61af40919e96ed8feb2b781bfa68095d07966381bfaac7389010b45db671e3d5e7f488ad7ff69ac6fc599fb4f259c9cb9d1ee7265312ecc4dc4ad89b9850445a7e094a7a9f7e7cf71a159f4db849d0b7f9346065ac8e509fc3f7932db1f91c3a1e34604cbedd071772bbd414d4b96328aedf372ff4e4170ca0c23bbadd447b49eff0ae2c37b51052c6e1cf2a0ef0106fa892a4a18165bfeea92c565ae5aecfa8163aa12c762f40135664b467bd58470216b1124413a2a723a358a759425cf293a6cf0b42662892f42d62e6a446016365c22ab26ca4e7dbd1c404a3f2f515fb4fd2e33efc82cca453b63d6d9e8fc0369c0192684731314ab2d684f948171c1917f99603667367b8fa69d207e3bf9c05b13b4720f493642a497b403934dbb7865dd0d0c893483b5c2986baac9d7f50612abe37f2274531ad80aba90d76117d81f99cf7459097cd7a90c441339b581dcd0bf2e74a912415918546bb5c645362dd4424631588a95a0945cd723df229b1b6da93142de12084ef56c93e2f342ba524a15c94b6334ad3f8baaa05e5e55888559a0b73be9116ed2bb713eb01f188ac86ab6ff4b0228eeb7bf481369fad1b5dc8d1718e62f65eb2c4a2906539526cfd45d4ae6f1a903f88ae4cf7f9a4fb290a14db3595ac581d70daf5b020864b315c17a99d23f19f7aa255372fd5b709eacf27503e3ab8fba5785944158aeb73c5b432c65286ae05d1ee95b5c922e24a83ecef7f4d96bfe86bd7990c13db918dbba8977f3cbfe1854a8cdcc63ea73ce3f93757ef6cb77e8144c2df51a0de62eaa982a803b35f24c6f5edf2bbacce988bfe37e394ef2acb2f364c8939365c38c56d32d8c9e1600c8b521ed80f5ad82334e915b862ff3dbf343b914170be3b881a4696c6f97100b005435cbdbb7dd7ff7bec17b179ab7645166dacf59544d7cf7cfcb94ac35acde7311d2213f9aeb5734ccbd1ad800d517c0218b92310ebd9d76b96908aba2c8779111b5ed6acfa15817b4e7bbee845b1b4eb9b8daa4cdf0a0349dfde69f63355b2a32197fb2c4a504721d6857a97da303b14dc58831cbdccba06f4bb3616bc1f33e77e1df9a5419cf7613f4d363297a1c1b6f2010f5029c48fc6909076d1883ee7b21254753f9f420bd6602d49a359719a89c5a8d3c0a93337a1c937161e1490598c3b00cac95f1240b69b4080a81942e8f1900f978b16daac1c732b37083e800ca03bf8dc38d5e2cc45aac155d169050ec49070de42e1f7cdf59556788576366930f444b310e9c16ab39c0c704eabb135935dcc218ecf3327b78256674b5b43a6886ee3099d96c5a9d6d00a65b620986abed68eaafcab311da531847e9da30276ca398fee82c77293ce55c41e562cda9801bf76eac8d41345fa6b13e31dafbf774046a21e00fa07e882133b70a0853c51ab329e8c0ff5b6c93e385609a295a8d380c33e1ee9e69e812ad404d1252d56bc3ba583aaf4581f81f7ea2b34666eca35883922dde55007a0f0049149fea6d4a0911a001e48dc105020ffd84a45a7db78dd5b1e78a14a47d1ecb6d9ffc12e5183a3dc06f03e74a449e89b46ef91a74462938e6898fed3fb72b17a5a207da6ae04c1859da383a9a300ff31f3e5a668027e4f38cc35bd6c0a5a7532f8d33ee4ea2b77dd6b0d51475b263d26c3fde0ff79ccdca8b386bcf586384f18b95cc73b834d2969da753acc42c81ac171fa19be22652d5e0eadb37445dcbcf9bd3fc4220ac1977191a38cba9ced7b5a3c8defd07a1ff68dc85f2f8c88d3314ddf4f135aaf459127715de101943988add0333e38b7b85449111a6b72fa6965d1369a897508a4990d8150da9cd68f5c60f612dafb598463d23cfb6a3369418197d16709ec9b4f15dd9e85f7a4ae86152600d6bc7c1ba30516bc17e8852f087c3ef390ab05f6c57a4ab405fedbc04849a163ed292c45bb02afc2e059ca08adf3d51e2f9a79637f6cf5e222f9ea27ec37c67849c937a99e270f1d05add89ab42b6fe1648f02fcbfbefb2f176597df1e23c41c39c29ba2d48c2788ea95327657fdb41ec24aff3259631046f5a62c07288181453942a1f24f495d087522569eef5b117477349720adde22136fdceb92173741ed0ba4252ee7332e5f835a18f6708cf429167e328a8ed33518610ccea3b750c1460a140f2645bf28fa6bad57d298463e117426ea1b8b944e04032df3413391653805149ef7dba49fb4221bc64f40c039bbaf4ecaac256084402699a89bd440539e565582f2cfb0e35ab41f70326cd3f24168a3c2816553aa8ed19facb6d3a07af5ec7a5f9f80e96c9e41adbd6fa0d44bda9cb954fed933912ec9d320cf5c2fc687bd89a5c5a1ddd87b7e3db33c0138aaaa92dd4f4619c8f9dfcc269aa8fbeb7ede7e05c2f778b05d8339fa175e2447844cd86dd886b40cb3badc4ce986aa93a3d973d1c4a76b6bdc0";
std::pair<std::string, std::string> result = response_to_complaint("pp2", encr_poly, 2, 2, 0);
}
TEST_CASE( "pub_bls_key", "[pub_bls]" ) {
init_daemon();
init_enclave();
......@@ -733,7 +726,7 @@ TEST_CASE("API test", "[api_test]") {
// JSONRPC_SERVER_V2); // hybrid server (json-rpc 1.0 & 2.0)
// s.StartListening();
cerr << "Server inited" << endl;
HttpClient client("http://localhost:1025");
HttpClient client("http://localhost:1026");
StubClient c(client, JSONRPC_CLIENT_V2);
cerr << "Client inited" << endl;
......@@ -745,12 +738,16 @@ TEST_CASE("API test", "[api_test]") {
//levelDb->deleteDHDKGKey("p2_1:");
// cout << c.generateECDSAKey() << endl;
//cout << c.generateECDSAKey() << endl;
// cout << c.renameESDSAKey("NODE_1CHAIN_1","tmp_NEK:bcacde0d26c0ea2c7e649992e7f791e1fba2492f5b7ae63dadb799075167c7fc");
//cout<<c.getPublicECDSAKey("test_key1");
//cout<<c.getPublicECDSAKey("NEK:697fadfc597bdbfae9ffb7412b80939e848c9c2fec2657bb2122b6d0d4a0dca8");
//cout << c.ecdsaSignMessageHash(16, "NEK:697fadfc597bdbfae9ffb7412b80939e848c9c2fec2657bb2122b6d0d4a0dca8","0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db" );
//cout << c.ecdsaSignMessageHash(16, "known_key1","0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db" );
// cout << c.blsSignMessageHash(TEST_BLS_KEY_NAME, "0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db", 2,2,1 );
// cout << c.generateDKGPoly("pp2", 2);
// cout << c.generateDKGPoly("POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1", 2);
//cout << c.getVerificationVector("POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:2", 2, 2);
// cout << c.getVerificationVector("polyy", 5, 5);
// cout << c.getSecretShare("p2",
......@@ -763,8 +760,8 @@ TEST_CASE("API test", "[api_test]") {
Json::Value publicKeys;
publicKeys.append("505f55a38f9c064da744f217d1cb993a17705e9839801958cda7c884e08ab4dad7fd8d22953d3ac7f0913de24fd67d7ed36741141b8a3da152d7ba954b0f14e2");
publicKeys.append("378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25e6e");
// cout << c.getSecretShare("pp2", publicKeys, 2, 2);
publicKeys.append("378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25");
// cout << c.getSecretShare("POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1", publicKeys, 2, 2);
// cout << c.generateDKGPoly("p3", 3);
// cout << c.getSecretShare("p3",
// "669aa790e1c5f5199af82ab0b6f1965c382d23a2ebdda581454adba3fd082a30edab62b545f78f1e402ceef7340a0364a7046633d6151fe7e657d8b8a6352378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25e6e9d43f1c88581f53af993da1654c9f91829c1fe5344c4452ef8d2d8675c6a051c19029f6e4f82b035fb3552058cf22c5bbafd9e6456d579634987281765d130b0",
......@@ -798,9 +795,9 @@ TEST_CASE("API test", "[api_test]") {
//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.blsSignMessageHash("dOsRY","38433e5ce087dcc1be82fcc834eae83c256b3db87d34f84440d0b708daa0c6f7", 2, 2, 1);
//cout << c.ComplaintResponse("pp2", 2, 2, 0);
cout << c.ComplaintResponse("POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1", 0);
} catch (JsonRpcException &e) {
cerr << e.what() << endl;
......
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