Unverified Commit 5abec529 authored by Ganna Kulikova's avatar Ganna Kulikova Committed by GitHub

Merge pull request #251 from skalenetwork/bug/SKALE-3654-SGX-errors

SKALE-3654-better-errors
parents 0b6294b6 1c69824a
......@@ -145,7 +145,7 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t
uint64_t binLen;
if (!hex2carray(_hashHex, &binLen, hash->data(), hash->size())) {
throw SGXException(INVALID_HEX, "Invalid hash");
throw SGXException(SIGN_FUNCTION_INVALID_HEX, string(__FUNCTION__) + ":Invalid hash");
}
auto keyShare = make_shared<BLSPrivateKeyShareSGX>(keyStr, _t, _n);
......@@ -170,7 +170,7 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
uint64_t binLen;
if (!hex2carray(_hashHex, &binLen, hash->data(), hash->size())) {
throw SGXException(INVALID_HEX, "Invalid hash");
throw SGXException(SIGN_AES_INVALID_HASH, string(__FUNCTION__) + ":Invalid hash");
}
shared_ptr <signatures::Bls> obj;
......
......@@ -92,7 +92,7 @@ string convertHexToDec(const string &hex_str) {
throw SGXException(INCORRECT_STRING_CONVERSION, e.what());
} catch (...) {
mpz_clear(dec);
throw SGXException(UNKNOWN_ERROR, "");
throw SGXException(EXCEPTION_IN_CONVERT_HEX_TO_DEC, "Exception in convert hex to dec");
}
clean:
......@@ -117,10 +117,10 @@ string convertG2ToString(const libff::alt_bn128_G2 &elem, int base, const string
return result;
} catch (exception &e) {
throw SGXException(INCORRECT_STRING_CONVERSION, e.what());
throw SGXException(CONVERT_G2_INCORRECT_STRING_CONVERSION, e.what());
return result;
} catch (...) {
throw SGXException(UNKNOWN_ERROR, "");
throw SGXException(EXCEPTION_IN_CONVERT_G2_STRING, "Exception in convert G2 to string");
return result;
}
......@@ -153,7 +153,7 @@ string gen_dkg_poly(int _t) {
return result;
}
vector <vector<string>> get_verif_vect(const string& encryptedPolyHex, int t, int n) {
vector <vector<string>> get_verif_vect(const string &encryptedPolyHex, int t, int n) {
auto encryptedPolyHexPtr = encryptedPolyHex.c_str();
......@@ -170,7 +170,7 @@ vector <vector<string>> get_verif_vect(const string& encryptedPolyHex, int t, in
vector <uint8_t> encrDKGPoly(2 * BUF_LEN, 0);
if (!hex2carray(encryptedPolyHexPtr, &encLen, encrDKGPoly.data(), 6100)) {
throw SGXException(INVALID_HEX, "Invalid encryptedPolyHex");
throw SGXException(GET_VV_INVALID_POLY_HEX, ":Invalid encryptedPolyHex");
}
......@@ -179,7 +179,7 @@ vector <vector<string>> get_verif_vect(const string& encryptedPolyHex, int t, in
SEMAPHORE_BEGIN
status = trustedGetPublicShares(eid, &errStatus, errMsg.data(), encrDKGPoly.data(), encLen,
pubShares.data(), t, n);
pubShares.data(), t, n);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
......@@ -194,10 +194,10 @@ vector <vector<string>> get_verif_vect(const string& encryptedPolyHex, int t, in
return pubSharesVect;
}
vector <vector<string>> getVerificationVectorMult(const std::string& encryptedPolyHex, int t, int n, size_t ind) {
vector <vector<string>> getVerificationVectorMult(const std::string &encryptedPolyHex, int t, int n, size_t ind) {
auto verificationVector = get_verif_vect(encryptedPolyHex, t, n);
vector<vector<string>> result(t);
vector <vector<string>> result(t);
for (int i = 0; i < t; ++i) {
libff::alt_bn128_G2 current_coefficient;
......@@ -207,7 +207,7 @@ vector <vector<string>> getVerificationVectorMult(const std::string& encryptedPo
current_coefficient.Y.c1 = libff::alt_bn128_Fq(verificationVector[i][3].c_str());
current_coefficient.Z = libff::alt_bn128_Fq2::one();
current_coefficient = libff::power(libff::alt_bn128_Fr(ind + 1), i) * current_coefficient;
current_coefficient = libff::power(libff::alt_bn128_Fr(ind + 1), i) * current_coefficient;
current_coefficient.to_affine_coordinates();
auto g2_str = convertG2ToString(current_coefficient);
......@@ -233,10 +233,9 @@ getSecretShares(const string &_polyName, const char *_encryptedPolyHex, const ve
if (!hex2carray(_encryptedPolyHex, &encLen, encrDKGPoly.data(), BUF_LEN)) {
throw SGXException(INVALID_HEX, "Invalid encryptedPolyHex");
throw SGXException(GET_SS_INVALID_HEX, string(__FUNCTION__) + ":Invalid encryptedPolyHex");
}
sgx_status_t status = SGX_SUCCESS;
READ_LOCK(sgxInitMutex);
......@@ -261,8 +260,8 @@ getSecretShares(const string &_polyName, const char *_encryptedPolyHex, const ve
errMsg.data(),
encrDKGPoly.data(), encLen,
encryptedSkey.data(), &decLen,
currentShare.data(), sShareG2.data(), pubKeyB.data(), _t, _n,
i + 1);
currentShare.data(), sShareG2.data(), pubKeyB.data(), _t, _n,
i + 1);
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
......@@ -284,7 +283,9 @@ getSecretShares(const string &_polyName, const char *_encryptedPolyHex, const ve
return result;
}
string getSecretSharesV2(const string& _polyName, const char* _encryptedPolyHex, const vector<string>& _publicKeys, int _t, int _n) {
string
getSecretSharesV2(const string &_polyName, const char *_encryptedPolyHex, const vector <string> &_publicKeys, int _t,
int _n) {
CHECK_STATE(_encryptedPolyHex);
vector<char> hexEncrKey(BUF_LEN, 0);
......@@ -295,10 +296,10 @@ string getSecretSharesV2(const string& _polyName, const char* _encryptedPolyHex,
if (!hex2carray(_encryptedPolyHex, &encLen, encrDKGPoly.data(), BUF_LEN)) {
throw SGXException(INVALID_HEX, "Invalid encryptedPolyHex");
throw SGXException(GET_SS_V2_INVALID_HEX,
string(__FUNCTION__) + ":Invalid encrypted poly Hex");
}
sgx_status_t status = SGX_SUCCESS;
READ_LOCK(sgxInitMutex);
......@@ -320,11 +321,11 @@ string getSecretSharesV2(const string& _polyName, const char* _encryptedPolyHex,
sgx_status_t status = SGX_SUCCESS;
status = trustedGetEncryptedSecretShareV2(eid, &errStatus,
errMsg.data(),
encrDKGPoly.data(), encLen,
encryptedSkey.data(), &decLen,
currentShare.data(), sShareG2.data(), pubKeyB.data(), _t, _n,
i + 1);
errMsg.data(),
encrDKGPoly.data(), encLen,
encryptedSkey.data(), &decLen,
currentShare.data(), sShareG2.data(), pubKeyB.data(), _t, _n,
i + 1);
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
......@@ -360,7 +361,7 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
SAFE_UINT8_BUF(encr_key, BUF_LEN);
if (!hex2carray(encryptedKeyHex, &decKeyLen, encr_key, BUF_LEN)) {
throw SGXException(INVALID_HEX, "Invalid encryptedPolyHex");
throw SGXException(VERIFY_SHARES_INVALID_KEY_HEX, string(__FUNCTION__) + ":Invalid encryptedPolyHex");
}
SAFE_CHAR_BUF(pshares, 8193);
......@@ -370,13 +371,14 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
SEMAPHORE_BEGIN
status = trustedDkgVerify(eid, &errStatus, errMsg.data(), pshares, encr_sshare, encr_key, decKeyLen, t,
ind, &result);
ind, &result);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
if (result == 2) {
throw SGXException(INVALID_HEX, "Invalid public shares");
throw SGXException(VERIFY_SHARES_INVALID_PUBLIC_SHARES,
string(__FUNCTION__) + +":Invalid public shares");
}
return result;
......@@ -396,7 +398,7 @@ verifySharesV2(const char *publicShares, const char *encr_sshare, const char *en
SAFE_UINT8_BUF(encr_key, BUF_LEN);
if (!hex2carray(encryptedKeyHex, &decKeyLen, encr_key, BUF_LEN)) {
throw SGXException(INVALID_HEX, "Invalid encryptedPolyHex");
throw SGXException(VERIFY_SHARES_V2_INVALID_POLY_HEX, string(__FUNCTION__) + ":Invalid encryptedPolyHex");
}
SAFE_CHAR_BUF(pshares, 8193);
......@@ -406,13 +408,13 @@ verifySharesV2(const char *publicShares, const char *encr_sshare, const char *en
SEMAPHORE_BEGIN
status = trustedDkgVerifyV2(eid, &errStatus, errMsg.data(), pshares, encr_sshare, encr_key, decKeyLen, t,
ind, &result);
ind, &result);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
if (result == 2) {
throw SGXException(INVALID_HEX, "Invalid public shares");
throw SGXException(VERIFY_SHARES_V2_INVALID_PUBLIC_SHARES, string(__FUNCTION__) + ":Invalid public shares");
}
return result;
......@@ -428,7 +430,7 @@ bool createBLSShare(const string &blsKeyName, const char *s_shares, const char *
uint64_t decKeyLen;SAFE_UINT8_BUF(encr_bls_key, BUF_LEN);SAFE_UINT8_BUF(encr_key, BUF_LEN);
if (!hex2carray(encryptedKeyHex, &decKeyLen, encr_key, BUF_LEN)) {
throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
throw SGXException(CREATE_BLS_SHARE_INVALID_KEY_HEX, string(__FUNCTION__) + ":Invalid encryptedKeyHex");
}
uint64_t enc_bls_len = 0;
......@@ -437,7 +439,7 @@ bool createBLSShare(const string &blsKeyName, const char *s_shares, const char *
SEMAPHORE_BEGIN
status = trustedCreateBlsKey(eid, &errStatus, errMsg.data(), s_shares, encr_key, decKeyLen, encr_bls_key,
&enc_bls_len);
&enc_bls_len);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
......@@ -461,7 +463,7 @@ vector <string> getBLSPubKey(const char *encryptedKeyHex) {
SAFE_UINT8_BUF(encrKey, BUF_LEN);
if (!hex2carray(encryptedKeyHex, &decKeyLen, encrKey, BUF_LEN)) {
throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
throw SGXException(GET_BLS_PUBKEY_INVALID_KEY_HEX, string(__FUNCTION__) + ":Invalid encryptedKeyHex");
}
SAFE_CHAR_BUF(pubKey, 320)
......@@ -545,10 +547,9 @@ string decryptDHKey(const string &polyName, int ind) {
vector<char> hexEncrKey(2 * BUF_LEN, 0);
uint64_t dhEncLen = 0;
SAFE_UINT8_BUF(encryptedDHKey, BUF_LEN)
uint64_t dhEncLen = 0;SAFE_UINT8_BUF(encryptedDHKey, BUF_LEN)
if (!hex2carray(hexEncrKeyPtr->c_str(), &dhEncLen, encryptedDHKey, BUF_LEN)) {
throw SGXException(INVALID_HEX, "Invalid hexEncrKey");
throw SGXException(DECRYPT_DH_KEY_INVALID_KEY_HEX, string(__FUNCTION__) + ":Invalid hexEncrKey");
}
spdlog::debug("encr DH key length is {}", dhEncLen);
......
......@@ -96,7 +96,7 @@ string getECDSAPubKey(const std::string& _encryptedKeyHex) {
if (!hex2carray(_encryptedKeyHex.c_str(), &enc_len, encrPrKey.data(),
BUF_LEN)) {
throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
throw SGXException(GET_ECDSA_PUB_KEY_INVALID_KEY_HEX, "Invalid encryptedKeyHex");
}
sgx_status_t status = SGX_SUCCESS;
......@@ -185,7 +185,7 @@ vector <string> ecdsaSignHash(const std::string& encryptedKeyHex, const char *ha
if (!hex2carray(encryptedKeyHex.c_str(), &decLen, encryptedKey.data(),
BUF_LEN)) {
throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
throw SGXException(ECDSA_SIGN_INVALID_KEY_HEX, "Invalid encryptedKeyHex");
}
sgx_status_t status = SGX_SUCCESS;
......
......@@ -52,7 +52,7 @@ level_enum Log::logLevelFromString(string &_s) {
}
void Log::handleSGXException(Json::Value& _result, SGXException& _e ) {
spdlog::error("Responding with JSON error:" + _e.errString);
_result["status"] = _e.status;
_result["errorMessage"] = _e.errString;
spdlog::error("Responding with JSON error:" + _e.getErrString());
_result["status"] = _e.getStatus();
_result["errorMessage"] = _e.getErrString();
}
/*
*
Copyright (C) 2019-Present SKALE Labs
This file is part of sgxwallet.
......@@ -83,26 +84,32 @@ spdlog::info(string(__FUNCTION__) + " processed " + to_string(__COUNT__) + " re
}
// if uknown error, the error is 10000 + line number
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \
int errStatus = UNKNOWN_ERROR; boost::ignore_unused(errStatus); string errMsg(BUF_LEN, '\0');__RESULT__["status"] = UNKNOWN_ERROR; __RESULT__["errorMessage"] = \
"Server error. Please see server log.";
int errStatus = -1 * (10000 + __LINE__); boost::ignore_unused(errStatus); string errMsg(BUF_LEN, '\0');__RESULT__["status"] = -1 * (10000 + __LINE__); __RESULT__["errorMessage"] = \
string(__FUNCTION__); \
string(__FUNCTION__) + ": server error. Please see server log.";
#define HANDLE_SGX_EXCEPTION(__RESULT__) \
catch (SGXException& _e) { \
if (_e.status != 0) {__RESULT__["status"] = _e.status;} else { __RESULT__["status"] = UNKNOWN_ERROR;}; \
__RESULT__["errorMessage"] = _e.errString; \
catch (const SGXException& _e) { \
if (_e.getStatus() != 0) {__RESULT__["status"] = _e.getStatus();} else { __RESULT__["status"] = -1 * (10000 + __LINE__);}; \
__RESULT__["errorMessage"] = _e.getErrString(); \
if (_e.getErrString().size() == 0) {__RESULT__["errorMessage"] = string(__FUNCTION__);}; \
spdlog::error("JSON call failed {}", __FUNCTION__); \
return __RESULT__; \
} catch (exception& _e) { \
__RESULT__["errorMessage"] = _e.what(); \
} catch (const exception& _e) { \
__RESULT__["status"] = -1 * (10000 + __LINE__); \
exception_ptr p = current_exception(); \
__RESULT__["errorMessage"] = string(p.__cxa_exception_type()->name()) + ":" + _e.what(); \
spdlog::error("JSON call failed {}", __FUNCTION__); \
return __RESULT__; \
}\
catch (...) { \
exception_ptr p = current_exception(); \
printf("Exception %s \n", p.__cxa_exception_type()->name()); \
__RESULT__["errorMessage"] = "Unknown exception"; \
spdlog::error(string("Exception:") + p.__cxa_exception_type()->name()); \
__RESULT__["errorMessage"] = string(p.__cxa_exception_type()->name()); \
spdlog::error("JSON call failed {}", __FUNCTION__); \
return __RESULT__; \
}
......
......@@ -231,7 +231,7 @@ void setSEK(shared_ptr <string> hex_encrypted_SEK) {
if (!hex2carray(hex_encrypted_SEK->c_str(), &len, encrypted_SEK,
BUF_LEN)) {
throw SGXException(INVALID_HEX, "Invalid encrypted SEK Hex");
throw SGXException(SET_SEK_INVALID_SEK_HEX, "Invalid encrypted SEK Hex");
}
sgx_status_t status = SGX_SUCCESS;
......
......@@ -27,19 +27,30 @@
#include <string>
#include <exception>
class SGXException : public std::exception {
using namespace std;
class SGXException : public exception {
const int32_t status;
const string errString;
public:
int32_t status;
std::string errString;
SGXException(int32_t _status, const string& _errString) : status(_status), errString(_errString) {}
const string getMessage() const {
return "SGXException:status:" + to_string(status) + ":" + errString;
}
SGXException(int32_t _status, const char* _errString) : status(_status), errString(_errString) {}
const string& getErrString() const {
return errString;
}
std::string getMessage() {
return "SGXException:status:" + std::to_string(status) + ":" + errString;
const int32_t getStatus() const {
return status;
}
};
#endif //SGXD_RPCEXCEPTION_H
......@@ -208,7 +208,7 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
try {
if (!checkName(_keyShareName, "BLS_KEY")) {
throw SGXException(INVALID_BLS_NAME, "Invalid BLS key name");
throw SGXException(BLS_IMPORT_INVALID_KEY_NAME, string(__FUNCTION__) + ":Invalid BLS key name");
}
string hashTmp = _keyShare;
......@@ -217,17 +217,18 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
}
if (!checkHex(hashTmp)) {
throw SGXException(INVALID_HEX, "Invalid BLS key share, please use hex");
throw SGXException(BLS_IMPORT_INVALID_KEY_SHARE, string(__FUNCTION__) + ":Invalid BLS key share, please use hex");
}
encryptedKeyShareHex = encryptBLSKeyShare2Hex(&errStatus, (char *) errMsg.data(), hashTmp.c_str());
if (errStatus != 0) {
throw SGXException(errStatus, errMsg.data());
throw SGXException(errStatus, string(__FUNCTION__) + ":" +errMsg.data());
}
if (encryptedKeyShareHex.empty()) {
throw SGXException(UNKNOWN_ERROR, "");
throw SGXException(BLS_IMPORT_EMPTY_ENCRYPTED_KEY_SHARE,string(__FUNCTION__) +
":Empty encrypted key share");
}
result["encryptedKeyShare"] = encryptedKeyShareHex;
......@@ -280,11 +281,11 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
try {
if (!checkName(_keyShareName, "BLS_KEY")) {
throw SGXException(INVALID_POLY_NAME, "Invalid BLSKey name");
throw SGXException(BLS_SIGN_INVALID_KS_NAME, string(__FUNCTION__) + ":Invalid BLSKey name");
}
if (!check_n_t(t, n)) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid t/n parameters");
throw SGXException(BLS_SIGN_INVALID_PARAMS, string(__FUNCTION__) + ":Invalid t/n parameters");
}
string hashTmp = _messageHash;
......@@ -296,14 +297,14 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
}
if (!checkHex(hashTmp)) {
throw SGXException(INVALID_HEX, "Invalid hash");
throw SGXException(INVALID_BLS_HEX, string(__FUNCTION__) + ":Invalid bls hex");
}
value = readFromDb(_keyShareName);
if (!bls_sign(value->c_str(), _messageHash.c_str(), t, n, signature.data())) {
throw SGXException(-1, "Could not sign data ");
throw SGXException(COULD_NOT_BLS_SIGN, ":Could not bls sign data ");
}
} HANDLE_SGX_EXCEPTION(result)
......@@ -324,7 +325,7 @@ Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_keyShare,
try {
if (!checkECDSAKeyName(_keyShareName)) {
throw SGXException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
throw SGXException(INVALID_ECDSA_IMPORT_KEY_NAME, string(__FUNCTION__) + ":Invalid ECDSA import key name");
}
string hashTmp = _keyShare;
......@@ -333,7 +334,8 @@ Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_keyShare,
}
if (!checkHex(hashTmp)) {
throw SGXException(INVALID_HEX, "Invalid ECDSA key share, please use hex");
throw SGXException(INVALID_ECDSA_IMPORT_HEX,
string(__FUNCTION__) + ":Invalid ECDSA key share, please use hex");
}
string encryptedKey = encryptECDSAKey(hashTmp);
......@@ -359,7 +361,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
keys = genECDSAKey();
if (keys.size() == 0) {
throw SGXException(UNKNOWN_ERROR, "key was not generated");
throw SGXException(ECDSA_GEN_EMPTY_KEY, string(__FUNCTION__) + ":key was not generated");
}
string keyName = "NEK:" + keys.at(2);
......@@ -388,7 +390,6 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
checkForDuplicate(ecdsaRequests, ecdsaRequestsLock, _keyName, _messageHash);
try {
string hashTmp = _messageHash;
if (hashTmp[0] == '0' && (hashTmp[1] == 'x' || hashTmp[1] == 'X')) {
......@@ -399,20 +400,20 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
}
if (!checkECDSAKeyName(_keyName)) {
throw SGXException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
throw SGXException(INVALID_ECDSA_SIGN_KEY_NAME, string(__FUNCTION__) + ":Invalid ECDSA sign key name");
}
if (!checkHex(hashTmp)) {
throw SGXException(INVALID_HEX, "Invalid hash");
throw SGXException(INVALID_ECDSA_SIGN_HASH, ":Invalid ECDSA sign hash");
}
if (_base <= 0 || _base > 32) {
throw SGXException(-22, "Invalid base");
throw SGXException(INVALID_ECDSA_SIGN_BASE, ":Invalid ECDSA sign base");
}
shared_ptr <string> encryptedKey = readFromDb(_keyName, "");
signatureVector = ecdsaSignHash(encryptedKey->c_str(), hashTmp.c_str(), _base);
if (signatureVector.size() != 3) {
throw SGXException(INVALID_ECSDA_SIGNATURE, "Invalid ecdsa signature");
throw SGXException(INVALID_ECSDA_SIGN_SIGNATURE, string(__FUNCTION__) + ":Invalid ecdsa signature");
}
result["signature_v"] = signatureVector.at(0);
......@@ -435,7 +436,8 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
try {
if (!checkECDSAKeyName(_keyName)) {
throw SGXException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
throw SGXException(INVALID_ECDSA_GETPKEY_KEY_NAME, string(__FUNCTION__) +
":Invalid ECDSA import key name");
}
shared_ptr <string> keyStr = readFromDb(_keyName);
publicKey = getECDSAPubKey(keyStr->c_str());
......@@ -455,11 +457,11 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t
try {
if (!checkName(_polyName, "POLY")) {
throw SGXException(INVALID_POLY_NAME,
"Invalid polynomial name, it should be like POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1");
throw SGXException(INVALID_GEN_DKG_POLY_NAME,
string(__FUNCTION__) + ":Invalid gen DKG polynomial name.");
}
if (_t <= 0 || _t > 32) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid parameter t ");
throw SGXException(GENERATE_DKG_POLY_INVALID_PARAMS, string(__FUNCTION__) + ":Invalid gen dkg param t ");
}
encrPolyHex = gen_dkg_poly(_t);
writeDataToDB(_polyName, encrPolyHex);
......@@ -476,10 +478,10 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
vector <vector<string>> verifVector;
try {
if (!checkName(_polyName, "POLY")) {
throw SGXException(INVALID_POLY_NAME, "Invalid polynomial name");
throw SGXException(INVALID_DKG_GETVV_POLY_NAME, string(__FUNCTION__) + ":Invalid polynomial name");
}
if (!check_n_t(_t, _n)) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid parameters: n or t ");
throw SGXException(INVALID_DKG_GETVV_PARAMS, string(__FUNCTION__) + ":Invalid parameters n or t ");
}
shared_ptr <string> encrPoly = readFromDb(_polyName);
......@@ -506,13 +508,13 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
try {
if (_pubKeys.size() != (uint64_t) _n) {
throw SGXException(INVALID_DKG_PARAMS, "invalid number of public keys");
throw SGXException(INVALID_DKG_GETSS_PUB_KEY_COUNT, string(__FUNCTION__) + ":Invalid pubkey count");
}
if (!checkName(_polyName, "POLY")) {
throw SGXException(INVALID_POLY_NAME, "Invalid polynomial name");
throw SGXException(INVALID_DKG_GETSS_POLY_NAME, string(__FUNCTION__) + ":Invalid polynomial name");
}
if (!check_n_t(_t, _n)) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
throw SGXException(INVALID_DKG_GETSS_POLY_NAME, string(__FUNCTION__) + ":Invalid DKG parameters: n or t ");
}
shared_ptr <string> encrPoly = readFromDb(_polyName);
......@@ -520,7 +522,7 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
vector <string> pubKeysStrs;
for (int i = 0; i < _n; i++) {
if (!checkHex(_pubKeys[i].asString(), 64)) {
throw SGXException(INVALID_HEX, "Invalid public key");
throw SGXException(INVALID_DKG_GETSS_KEY_HEX, string(__FUNCTION__) + ":Invalid public key");
}
pubKeysStrs.push_back(_pubKeys[i].asString());
}
......@@ -531,8 +533,7 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
if (encryptedSecretShare != nullptr) {
result["secretShare"] = *encryptedSecretShare.get();
} else {
string s = getSecretShares(_polyName, encrPoly->c_str(), pubKeysStrs, _t, _n);
result["secretShare"] = s;
result["secretShare"] = getSecretShares(_polyName, encrPoly->c_str(), pubKeysStrs, _t, _n);
}
} HANDLE_SGX_EXCEPTION(result)
......@@ -548,16 +549,20 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
try {
if (!checkECDSAKeyName(_ethKeyName)) {
throw SGXException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
throw SGXException(INVALID_DKG_VERIFY_ECDSA_KEY_NAME,
string(__FUNCTION__) + ":Invalid ECDSA key name");
}
if (!check_n_t(_t, _n) || _index >= _n || _index < 0) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
throw SGXException(INVALID_DKG_VERIFY_PARAMS,
string(__FUNCTION__) + ":Invalid DKG parameters: n or t ");
}
if (!checkHex(_secretShare, SECRET_SHARE_NUM_BYTES)) {
throw SGXException(INVALID_HEX, "Invalid Secret share");
throw SGXException(INVALID_DKG_VERIFY_SS_HEX,
string(__FUNCTION__) + ":Invalid Secret share");
}
if (_publicShares.length() != (uint64_t) 256 * _t) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid length of public shares");
throw SGXException(INVALID_DKG_VERIFY_PUBSHARES_LENGTH,
string(__FUNCTION__) + ":Invalid length of public shares");
}
shared_ptr <string> encryptedKeyHex_ptr = readFromDb(_ethKeyName);
......@@ -579,19 +584,24 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
try {
if (_secretShare.length() != (uint64_t) _n * 192) {
throw SGXException(INVALID_SECRET_SHARES_LENGTH, "Invalid secret share length");
throw SGXException(INVALID_CREATE_BLS_KEY_SECRET_SHARES_LENGTH,
string(__FUNCTION__) + ":Invalid secret share length");
}
if (!checkECDSAKeyName(_ethKeyName)) {
throw SGXException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
throw SGXException(INVALID_CREATE_BLS_ECDSA_KEY_NAME,
string(__FUNCTION__) + ":Invalid ECDSA key name");
}
if (!checkName(_polyName, "POLY")) {
throw SGXException(INVALID_POLY_NAME, "Invalid polynomial name");
throw SGXException(INVALID_CREATE_BLS_POLY_NAME, string(__FUNCTION__) +
":Invalid polynomial name");
}
if (!checkName(_blsKeyName, "BLS_KEY")) {
throw SGXException(INVALID_BLS_NAME, "Invalid BLS key name");
throw SGXException(INVALID_CREATE_BLS_KEY_NAME, string(__FUNCTION__) +
":Invalid BLS key name");
}
if (!check_n_t(_t, _n)) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
throw SGXException(INVALID_CREATE_BLS_DKG_PARAMS,
string(__FUNCTION__) + ":Invalid DKG parameters: n or t ");
}
vector <string> sshares_vect;
......@@ -603,7 +613,8 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
if (res) {
spdlog::info("BLS KEY SHARE CREATED ");
} else {
throw SGXException(-122, "Error while creating BLS key share");
throw SGXException(INVALID_CREATE_BLS_SHARE,
string(__FUNCTION__) + ":Error while creating BLS key share");
}
......@@ -631,7 +642,8 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
try {
if (!checkName(_blsKeyName, "BLS_KEY")) {
throw SGXException(INVALID_BLS_NAME, "Invalid BLSKey name");
throw SGXException(INVALID_GET_BLS_PUBKEY_NAME,
string(__FUNCTION__) + ":Invalid BLSKey name");
}
shared_ptr <string> encryptedKeyHex_ptr = readFromDb(_blsKeyName);
......@@ -651,24 +663,29 @@ Json::Value SGXWalletServer::calculateAllBLSPublicKeysImpl(const Json::Value &pu
try {
if (!check_n_t(t, n)) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
throw SGXException(INVALID_DKG_CALCULATE_ALL_PARAMS,
string(__FUNCTION__) + ":Invalid DKG parameters: n or t ");
}
if (!publicShares.isArray()) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid public shares format");
throw SGXException(INVALID_DKG_CALCULATE_ALL_PUBSHARES,
string(__FUNCTION__) + ":Invalid public shares format");
}
if (publicShares.size() != (uint64_t) n) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid length of public shares");
throw SGXException(INVALID_DKG_CALCULATE_ALL_PUBSHARES_SIZE,
string(__FUNCTION__) + ":Invalid length of public shares");
}
for (int i = 0; i < n; ++i) {
if (!publicShares[i].isString()) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid public shares parts format");
throw SGXException(INVALID_DKG_CALCULATE_ALL_PUBSHARES_STRING,
string(__FUNCTION__) + ":Invalid public shares string");
}
if (publicShares[i].asString().length() != (uint64_t) 256 * t) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid length of public shares parts");
throw SGXException(INVALID_DKG_CALCULATE_ALL_STRING_PUBSHARES_SLENGTH,
string(__FUNCTION__) + ";Invalid length of public shares parts");
}
}
......@@ -680,7 +697,8 @@ Json::Value SGXWalletServer::calculateAllBLSPublicKeysImpl(const Json::Value &pu
vector <string> public_keys = calculateAllBlsPublicKeys(public_shares);
if (public_keys.size() != (uint64_t) n) {
throw SGXException(UNKNOWN_ERROR, "");
throw SGXException(INVALID_DKG_CALCULATE_ALL_STRING_PUBKEYS_SIZE,
string(__FUNCTION__) + ":Invalid pubkeys array size");
}
for (int i = 0; i < n; ++i) {
......@@ -698,14 +716,15 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
try {
if (!checkName(_polyName, "POLY")) {
throw SGXException(INVALID_POLY_NAME, "Invalid polynomial name");
throw SGXException(INVALID_COMPLAINT_RESPONSE_POLY_NAME,
string(__FUNCTION__) + ":Invalid polynomial name");
}
string shareG2_name = "shareG2_" + _polyName + "_" + to_string(_ind) + ":";
shared_ptr <string> shareG2_ptr = readFromDb(shareG2_name);
string DHKey = decryptDHKey(_polyName, _ind);
shared_ptr <string> shareG2_ptr = readFromDb(shareG2_name);
CHECK_STATE(shareG2_ptr);
result["share*G2"] = *shareG2_ptr;
result["dhKey"] = DHKey;
......@@ -788,7 +807,7 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const string &name) {
result["deleted"] = false;
try {
if (!checkName(name, "BLS_KEY")) {
throw SGXException(INVALID_BLS_NAME, "Invalid BLSKey name format");
throw SGXException(DELETE_BLS_KEY_INVALID_KEYNAME, string(__FUNCTION__) + ":Invalid BLSKey name format");
}
shared_ptr <string> bls_ptr = LevelDB::getLevelDb()->readString(name);
......@@ -797,7 +816,7 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const string &name) {
result["deleted"] = true;
} else {
auto error_msg = "BLS key not found: " + name;
throw SGXException(INVALID_BLS_NAME, error_msg.c_str());
throw SGXException(DELETE_BLS_KEY_NOT_FOUND, string(__FUNCTION__)+ ":" + error_msg.c_str());
}
} HANDLE_SGX_EXCEPTION(result)
......@@ -813,13 +832,16 @@ SGXWalletServer::getSecretShareV2Impl(const string &_polyName, const Json::Value
try {
if (_pubKeys.size() != (uint64_t) _n) {
throw SGXException(INVALID_DKG_PARAMS, "invalid number of public keys");
throw SGXException(INVALID_DKG_GETSS_V2_PUBKEY_COUNT,
string(__FUNCTION__) + ":Invalid number of public keys");
}
if (!checkName(_polyName, "POLY")) {
throw SGXException(INVALID_POLY_NAME, "Invalid polynomial name");
throw SGXException(INVALID_DKG_GETSS_V2_POLY_NAME,
string(__FUNCTION__) + ":Invalid polynomial name");
}
if (!check_n_t(_t, _n)) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
throw SGXException(INVALID_DKG_GETSS_V2_PUBKEY_COUNT,
string(__FUNCTION__) + ":Invalid DKG parameters: n or t ");
}
shared_ptr <string> encrPoly = readFromDb(_polyName);
......@@ -827,7 +849,8 @@ SGXWalletServer::getSecretShareV2Impl(const string &_polyName, const Json::Value
vector <string> pubKeysStrs;
for (int i = 0; i < _n; i++) {
if (!checkHex(_pubKeys[i].asString(), 64)) {
throw SGXException(INVALID_HEX, "Invalid public key");
throw SGXException(INVALID_DKG_GETSS_V2_PUBKEY_HEX,
string(__FUNCTION__) + ":Invalid public key");
}
pubKeysStrs.push_back(_pubKeys[i].asString());
}
......@@ -855,16 +878,20 @@ Json::Value SGXWalletServer::dkgVerificationV2Impl(const string &_publicShares,
try {
if (!checkECDSAKeyName(_ethKeyName)) {
throw SGXException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
throw SGXException(INVALID_DKG_VV_V2_ECDSA_KEY_NAME,
string(__FUNCTION__) + ":Invalid ECDSA key name");
}
if (!check_n_t(_t, _n) || _index >= _n || _index < 0) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
throw SGXException(INVALID_DKG_VV_V2_PARAMS,
string(__FUNCTION__) + ":Invalid DKG parameters: n or t ");
}
if (!checkHex(_secretShare, SECRET_SHARE_NUM_BYTES)) {
throw SGXException(INVALID_HEX, "Invalid Secret share");
throw SGXException(INVALID_DKG_VV_V2_SS_HEX,
string(__FUNCTION__) + ":Invalid Secret share");
}
if (_publicShares.length() != (uint64_t) 256 * _t) {
throw SGXException(INVALID_DKG_PARAMS, "Invalid length of public shares");
throw SGXException(INVALID_DKG_VV_V2_SS_COUNT,
string(__FUNCTION__) + ":Invalid count of public shares");
}
shared_ptr <string> encryptedKeyHex_ptr = readFromDb(_ethKeyName);
......@@ -975,7 +1002,7 @@ shared_ptr <string> SGXWalletServer::readFromDb(const string &name, const string
auto dataStr = checkDataFromDb(prefix + name);
if (dataStr == nullptr) {
throw SGXException(KEY_SHARE_DOES_NOT_EXIST, "Data with this name does not exist");
throw SGXException(KEY_SHARE_DOES_NOT_EXIST, string(__FUNCTION__) + ":Data with this name does not exist");
}
return dataStr;
......@@ -989,7 +1016,7 @@ shared_ptr <string> SGXWalletServer::checkDataFromDb(const string &name, const s
void SGXWalletServer::writeKeyShare(const string &_keyShareName, const string &_value) {
if (LevelDB::getLevelDb()->readString(_keyShareName) != nullptr) {
throw SGXException(KEY_SHARE_ALREADY_EXISTS, "Key share with this name already exists");
throw SGXException(KEY_SHARE_ALREADY_EXISTS, string(__FUNCTION__) + ":Key share with this name already exists");
}
LevelDB::getLevelDb()->writeString(_keyShareName, _value);
......@@ -998,7 +1025,7 @@ void SGXWalletServer::writeKeyShare(const string &_keyShareName, const string &_
void SGXWalletServer::writeDataToDB(const string &name, const string &value) {
if (LevelDB::getLevelDb()->readString(name) != nullptr) {
throw SGXException(KEY_NAME_ALREADY_EXISTS, "Name already exists");
throw SGXException(KEY_NAME_ALREADY_EXISTS, string(__FUNCTION__) + ":Name already exists");
}
LevelDB::getLevelDb()->writeString(name, value);
}
......@@ -241,7 +241,7 @@ void TestUtils::sendRPCRequest() {
auto hash_arr = make_shared < array < uint8_t, 32 >> ();
uint64_t binLen;
if (!hex2carray(hash.c_str(), &binLen, hash_arr->data(), 32)) {
throw SGXException(INVALID_HEX, "Invalid hash");
throw SGXException(TEST_INVALID_HEX, "Invalid hash");
}
map <size_t, shared_ptr<BLSPublicKeyShare>> coeffs_pkeys_map;
......@@ -355,7 +355,7 @@ void TestUtils::sendRPCRequestV2() {
auto hash_arr = make_shared < array < uint8_t, 32 >> ();
uint64_t binLen;
if (!hex2carray(hash.c_str(), &binLen, hash_arr->data(), 32)) {
throw SGXException(INVALID_HEX, "Invalid hash");
throw SGXException(TEST_INVALID_HEX, "Invalid hash");
}
map <size_t, shared_ptr<BLSPublicKeyShare>> coeffs_pkeys_map;
......@@ -488,7 +488,7 @@ void TestUtils::doDKG(StubClient &c, int n, int t,
auto hash_arr = make_shared<array<uint8_t, 32 >>();
uint64_t binLen;
if (!hex2carray(hash.c_str(), &binLen, hash_arr->data(), 32)) {
throw SGXException(INVALID_HEX, "Invalid hash");
throw SGXException(TEST_INVALID_HEX, "Invalid hash");
}
map<size_t, shared_ptr<BLSPublicKeyShare>> pubKeyShares;
......@@ -629,7 +629,7 @@ void TestUtils::doDKGV2(StubClient &c, int n, int t,
auto hash_arr = make_shared<array<uint8_t, 32 >>();
uint64_t binLen;
if (!hex2carray(hash.c_str(), &binLen, hash_arr->data(), 32)) {
throw SGXException(INVALID_HEX, "Invalid hash");
throw SGXException(TEST_INVALID_HEX, "Invalid hash");
}
map<size_t, shared_ptr<BLSPublicKeyShare>> pubKeyShares;
......@@ -721,7 +721,6 @@ int sessionKeyRecoverDH(const char *skey_str, const char *sshare, char *common_k
mpz_clear(skey);
point_clear(pub_keyB);
point_clear(session_key);
return ret;
}
......
1.64.1
\ No newline at end of file
1.64.2
\ No newline at end of file
......@@ -67,35 +67,98 @@ extern bool autoconfirm;
#define ECDSA_ENCR_LEN 93
#define ECDSA_BIN_LEN 33
#define UNKNOWN_ERROR -1
#define PLAINTEXT_KEY_TOO_LONG -2
#define UNPADDED_KEY -3
#define NULL_KEY -4
#define INCORRECT_STRING_CONVERSION -5
#define ENCRYPTED_KEY_TOO_LONG -6
#define SEAL_KEY_FAILED -7
#define KEY_SHARE_DOES_NOT_EXIST -7
#define KEY_SHARE_ALREADY_EXISTS -8
#define COULD_NOT_ACCESS_DATABASE -9
#define NULL_DATABASE -10
#define INVALID_POLY_NAME -11
#define INVALID_DKG_PARAMS -12
#define BLS_SIGN_INVALID_KS_NAME -11
#define BLS_SIGN_INVALID_PARAMS -12
#define INVALID_SECRET_SHARES_LENGTH -13
#define INVALID_BLS_NAME -15
#define CERT_REQUEST_DOES_NOT_EXIST -14
#define BLS_IMPORT_INVALID_KEY_NAME -15
#define SEAL_KEY_FAILED -16
#define GET_VV_INVALID_POLY_HEX -17
#define GET_SS_INVALID_HEX -18
#define DECRYPT_DH_KEY_INVALID_KEY_HEX -19
#define INVALID_ECDSA_KEY_NAME -20
#define INVALID_HEX -21
#define VERIFY_SHARES_INVALID_KEY_HEX -21
#define INVALID_ECSDA_SIGNATURE -22
#define KEY_NAME_ALREADY_EXISTS -23 \
#define KEY_NAME_ALREADY_EXISTS -23
#define BLS_IMPORT_EMPTY_ENCRYPTED_KEY_SHARE -24
#define BLS_IMPORT_INVALID_KEY_SHARE -25
#define INVALID_BLS_HEX -26
#define INVALID_ECDSA_HEX -27
#define COULD_NOT_BLS_SIGN -28
#define INVALID_ECDSA_IMPORT_KEY_NAME -29
#define INVALID_ECDSA_IMPORT_HEX -30
#define ECDSA_GEN_EMPTY_KEY -31
#define INVALID_ECDSA_SIGN_KEY_NAME -32
#define ERROR_IN_ENCLAVE -33
#define INVALID_ECDSA_SIGN_HASH -34
#define INVALID_ECDSA_SIGN_BASE -35
#define INVALID_ECSDA_SIGN_SIGNATURE -36
#define INVALID_ECDSA_GETPKEY_KEY_NAME -37
#define INVALID_GEN_DKG_POLY_NAME -38
#define INVALID_GEN_DKG_PARAM_T -39
#define INVALID_VERIFY_DKG_PARAM_T -40
#define INVALID_DKG_GETVV_POLY_NAME -41
#define INVALID_DKG_GETVV_PARAMS -42
#define INVALID_DKG_GETSS_POLY_NAME -43
#define FILE_NOT_FOUND -44
#define INVALID_DKG_GETSS_PARAMS -45
#define INVALID_DKG_GETSS_PUB_KEY_COUNT -46
#define INVALID_DKG_GETSS_KEY_HEX -47
#define INVALID_DKG_VERIFY_ECDSA_KEY_NAME -48
#define INVALID_DKG_VERIFY_PARAMS -49
#define INVALID_DKG_VERIFY_SS_HEX -50
#define INVALID_DKG_VERIFY_PUBSHARES_LENGTH -51
#define INVALID_CREATE_BLS_KEY_SECRET_SHARES_LENGTH -52
#define INVALID_CREATE_BLS_ECDSA_KEY_NAME -53
#define INVALID_CREATE_BLS_POLY_NAME -54
#define FAIL_TO_CREATE_CERTIFICATE -55
#define INVALID_CREATE_BLS_KEY_NAME -56
#define INVALID_CREATE_BLS_DKG_PARAMS -57
#define INVALID_CREATE_BLS_SHARE -58
#define INVALID_GET_BLS_PUBKEY_NAME -59
#define INVALID_DKG_CALCULATE_ALL_PARAMS -60
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES -61
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES_SIZE -62
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES_STRING -63
#define INVALID_DKG_CALCULATE_ALL_STRING_PUBSHARES_SLENGTH -64
#define INVALID_DKG_CALCULATE_ALL_STRING_PUBKEYS_SIZE -65
#define INVALID_COMPLAINT_RESPONSE_POLY_NAME -66
#define INVALID_DKG_GETSS_V2_PARAMS -63
#define INVALID_DKG_GETSS_V2_POLY_NAME -64
#define INVALID_DKG_GETSS_V2_PUBKEY_COUNT -65
#define INVALID_DKG_GETSS_V2_PUBKEY_HEX -66
#define INVALID_DKG_VV_V2_ECDSA_KEY_NAME -67
#define INVALID_DKG_VV_V2_PARAMS -68
#define INVALID_DKG_VV_V2_SS_HEX -69
#define INVALID_DKG_VV_V2_SS_COUNT -70
#define EXCEPTION_IN_CONVERT_HEX_TO_DEC -71
#define GET_SS_V2_INVALID_HEX -72
#define EXCEPTION_IN_CONVERT_G2_STRING -73
#define CONVERT_G2_INCORRECT_STRING_CONVERSION -74
#define DELETE_BLS_KEY_INVALID_KEYNAME -75
#define DELETE_BLS_KEY_NOT_FOUND -76
#define VERIFY_SHARES_INVALID_PUBLIC_SHARES -77
#define VERIFY_SHARES_V2_INVALID_POLY_HEX -78
#define VERIFY_SHARES_V2_INVALID_PUBLIC_SHARES -79
#define CREATE_BLS_SHARE_INVALID_KEY_HEX -80
#define GET_BLS_PUBKEY_INVALID_KEY_HEX -81
#define GENERATE_DKG_POLY_INVALID_PARAMS -82
#define SIGN_FUNCTION_INVALID_HEX -83
#define SIGN_AES_INVALID_HASH -84
#define GET_ECDSA_PUB_KEY_INVALID_KEY_HEX -85
#define ECDSA_SIGN_INVALID_KEY_HEX -86
#define SET_SEK_INVALID_SEK_HEX -87
#define TEST_INVALID_HEX -88
#define SGX_ENCLAVE_ERROR -666
......
......@@ -825,7 +825,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
uint64_t binLen;
if (!hex2carray(hash.c_str(), &binLen, hash_arr->data(), 32)) {
throw SGXException(INVALID_HEX, "Invalid hash");
throw SGXException(TEST_INVALID_HEX, "Invalid hash");
}
map <size_t, shared_ptr<BLSPublicKeyShare>> coeffs_pkeys_map;
......@@ -991,7 +991,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG V2 test", "[aes-dkg-v2]") {
uint64_t binLen;
if (!hex2carray(hash.c_str(), &binLen, hash_arr->data(), 32)) {
throw SGXException(INVALID_HEX, "Invalid hash");
throw SGXException(TEST_INVALID_HEX, "Invalid hash");
}
map <size_t, shared_ptr<BLSPublicKeyShare>> coeffs_pkeys_map;
......
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