Unverified Commit 55e6ef9f authored by kladko's avatar kladko

SKALE-3067-cleanup-sgx

parent 20362fb3
......@@ -73,7 +73,8 @@ public:
static void handleSGXException(Json::Value &_result, SGXException &_e);
};
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; __RESULT__["status"] = 0; __RESULT__["errorMessage"] = \
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \
int errStatus = UNKNOWN_ERROR; string errMsg(BUF_LEN, '\0');__RESULT__["status"] = 0; __RESULT__["errorMessage"] = \
"Server error. Please see server log.";
#define RESULT_SUCCESS(__RESULT__) ; __RESULT__["status"] = 0; __RESULT__["errorMessage"] = "";
#define HANDLE_SGX_EXCEPTION(_RESULT_) catch (SGXException &__e) { Log::handleSGXException(_RESULT_, __e);} \
......
......@@ -166,10 +166,8 @@ int SGXWalletServer::initHttpServer() { //without ssl
Json::Value
SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_keyShareName, int t, int n, int _index) {
Json::Value result;
INIT_RESULT(result);
int errStatus = UNKNOWN_ERROR;
string errMsg(BUF_LEN, '\0');
result["status"] = 0;
result["errorMessage"] = "";
......@@ -196,15 +194,20 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
result["errorMessage"] = _e.errString;
}
result["status"] = errStatus;
result["errorMessage"] = errMsg;
return result;
}
Json::Value
SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const string &_messageHash, int t, int n,
int _signerIndex) {
Json::Value result;
result["status"] = -1;
result["errorMessage"] = "Unknown server error";
INIT_RESULT(result);
result["signatureShare"] = "";
string signature(BUF_LEN, '\0');
......@@ -260,7 +263,9 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
}
Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string &_keyName) {
Json::Value result;
INIT_RESULT(result);
result["status"] = 0;
result["errorMessage"] = "";
result["encryptedKey"] = "";
......@@ -268,7 +273,9 @@ Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string
}
Json::Value SGXWalletServer::generateECDSAKeyImpl() {
Json::Value result;
INIT_RESULT(result);
result["status"] = 0;
result["errorMessage"] = "";
result["encryptedKey"] = "";
......@@ -300,6 +307,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const string &_tempKeyName) {
INIT_RESULT(result)
result["encryptedKey"] = "";
try {
......@@ -415,7 +423,9 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t
}
Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName, int _t, int _n) {
Json::Value result;
INIT_RESULT(result);
result["status"] = 0;
result["errorMessage"] = "";
......@@ -449,7 +459,9 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
}
Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const Json::Value &_pubKeys, int _t, int _n) {
Json::Value result;
INIT_RESULT(result);
result["status"] = 0;
result["errorMessage"] = "";
......@@ -488,7 +500,8 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, const string &_ethKeyName,
const string &_secretShare, int _t, int _n, int _index) {
Json::Value result;
INIT_RESULT(result)
result["status"] = 0;
result["errorMessage"] = "";
result["result"] = true;
......@@ -524,7 +537,9 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
Json::Value
SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string &_ethKeyName, const string &_polyName,
const string &_secretShare, int _t, int _n) {
Json::Value result;
INIT_RESULT(result)
result["status"] = 0;
result["errorMessage"] = "";
......
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