Unverified Commit b33321c2 authored by kladko's avatar kladko

SKALE-3067-cleanup-sgx

parent 18c63687
......@@ -42,7 +42,6 @@ CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector,
Json::Value getUnsignedCSRsImpl() {
spdlog::info(__FUNCTION__);
INIT_RESULT(result)
try {
vector<string> hashes_vect = LevelDB::getCsrDb()->writeKeysToVector1(MAX_CSR_NUM);
for (int i = 0; i < (int) hashes_vect.size(); i++) {
......@@ -50,11 +49,12 @@ Json::Value getUnsignedCSRsImpl() {
}
} HANDLE_SGX_EXCEPTION(result);
return result;
RETURN_SUCCESS(result)
}
Json::Value signByHashImpl(const string &hash, int status) {
Json::Value result;
INIT_RESULT(result)
result["errorMessage"] = "";
try {
......@@ -102,7 +102,7 @@ Json::Value signByHashImpl(const string &hash, int status) {
} HANDLE_SGX_EXCEPTION(result)
return result;
return result;
}
Json::Value CSRManagerServer::getUnsignedCSRs() {
......
......@@ -152,9 +152,9 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n
return pubSharesVect;
}
string trustedGetSecretShares(const string &_polyName, const char *_encryptedPolyHex, const vector<string> &_publicKeys,
int _t,
int _n) {
string getSecretShares(const string &_polyName, const char *_encryptedPolyHex, const vector<string> &_publicKeys,
int _t,
int _n) {
vector<char> hexEncrKey(BUF_LEN, 0);
vector<char> errMsg1(BUF_LEN, 0);
int errStatus = 0;
......
......@@ -35,7 +35,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
vector<string> splitString(const char* coeffs, const char symbol);
string trustedGetSecretShares(const string& _polyName, const char* _encryptedPolyHex, const vector<string>& _publicKeys, int _t, int _n);
string getSecretShares(const string& _polyName, const char* _encryptedPolyHex, const vector<string>& _publicKeys, int _t, int _n);
bool verifyShares(const char* publicShares, const char* encr_sshare, const char * encryptedKeyHex, int t, int n, int ind);
......
......@@ -74,7 +74,7 @@ public:
};
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \
int errStatus = UNKNOWN_ERROR; string errMsg(BUF_LEN, '\0');__RESULT__["status"] = 0; __RESULT__["errorMessage"] = \
int errStatus = UNKNOWN_ERROR; string errMsg(BUF_LEN, '\0');__RESULT__["status"] = UNKNOWN_ERROR; __RESULT__["errorMessage"] = \
"Server error. Please see server log.";
#define HANDLE_SGX_EXCEPTION(__RESULT__) \
......
......@@ -112,7 +112,8 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
} HANDLE_SGX_EXCEPTION(result)
return result;
RETURN_SUCCESS(result)
}
Json::Value getCertificateImpl(const string &hash) {
......@@ -147,7 +148,7 @@ Json::Value getCertificateImpl(const string &hash) {
} HANDLE_SGX_EXCEPTION(result)
return result;
RETURN_SUCCESS(result)
}
......
......@@ -221,22 +221,7 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
}
value = readFromDb(_keyShareName);
} catch (SGXException& _e) {
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
return result;
} catch (exception& _e) {
result["errorMessage"] = _e.what();
return result;
}
catch (...) {
exception_ptr p = current_exception();
printf("Exception %s \n", p.__cxa_exception_type()->name());
result["errorMessage"] = "Exception in dbRead";
return result;
}
try {
if (!bls_sign(value->c_str(), _messageHash.c_str(), t, n, _signerIndex, signature.data())) {
result["status"] = -1;
result["errorMessage"] = "Could not sign";
......@@ -409,8 +394,6 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
INIT_RESULT(result);
result["status"] = 0;
result["errorMessage"] = "";
vector <vector<string>> verifVector;
try {
......@@ -438,17 +421,14 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
result["verificationVector"] = "";
}
RETURN_SUCCESS(result)
return result;
}
Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const Json::Value &_pubKeys, int _t, int _n) {
INIT_RESULT(result);
result["status"] = 0;
result["errorMessage"] = "";
try {
if (_pubKeys.size() != (uint64_t) _n) {
throw SGXException(INVALID_DKG_PARAMS, "invalid number of public keys");
......@@ -470,11 +450,12 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
pubKeysStrs.push_back(_pubKeys[i].asString());
}
string s = trustedGetSecretShares(_polyName, encrPoly->c_str(), pubKeysStrs, _t, _n);
string s = getSecretShares(_polyName, encrPoly->c_str(), pubKeysStrs, _t, _n);
result["secretShare"] = s;
} HANDLE_SGX_EXCEPTION(result)
RETURN_SUCCESS(result)
}
Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, const string &_ethKeyName,
......@@ -517,8 +498,6 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
INIT_RESULT(result)
result["status"] = 0;
result["errorMessage"] = "";
try {
if (_secretShare.length() != (uint64_t) _n * 192) {
......@@ -615,9 +594,7 @@ Json::Value SGXWalletServer::multG2Impl(const string &_x) {
} HANDLE_SGX_EXCEPTION(result)
result["status"] = 0;
result["errorMessage"] = "";
return result;
RETURN_SUCCESS(result)
}
Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
......@@ -633,9 +610,7 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
}
} HANDLE_SGX_EXCEPTION(result)
result["status"] = 0;
result["errorMessage"] = "";
return result;
RETURN_SUCCESS(result)
}
Json::Value SGXWalletServer::getServerStatusImpl() {
......@@ -647,9 +622,7 @@ Json::Value SGXWalletServer::getServerVersionImpl() {
INIT_RESULT(result)
result["version"] = TOSTRING(SGXWALLET_VERSION);
result["status"] = 0;
result["errorMessage"] = "";
return result;
RETURN_SUCCESS(result)
}
Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) {
......
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