Fixes

parent 8f8f6a37
...@@ -95,7 +95,7 @@ void LevelDB::writeByteArray(std::string &_key, const char *value, ...@@ -95,7 +95,7 @@ void LevelDB::writeByteArray(std::string &_key, const char *value,
void LevelDB::throwExceptionOnError(Status _status) { void LevelDB::throwExceptionOnError(Status _status) {
if (_status.IsNotFound()) if (_status.IsNotFound())
return; return;
git
if (!_status.ok()) { if (!_status.ok()) {
throw RPCException(COULD_NOT_ACCESS_DATABASE, ("Could not access database database:" + _status.ToString()).c_str()); throw RPCException(COULD_NOT_ACCESS_DATABASE, ("Could not access database database:" + _status.ToString()).c_str());
} }
......
...@@ -137,13 +137,15 @@ Json::Value blsSignMessageHashImpl(const std::string& keyShareName, const std::s ...@@ -137,13 +137,15 @@ Json::Value blsSignMessageHashImpl(const std::string& keyShareName, const std::s
try { try {
value = readKeyShare(keyShareName); value = readKeyShare(keyShareName);
} catch (RPCException& _e) { } catch (RPCException _e) {
result["status"] = _e.status; result["status"] = _e.status;
result["errorMessage"] = _e.errString; result["errorMessage"] = _e.errString;
return result; return result;
} catch (...) { } catch (...) {
std::exception_ptr p = std::current_exception();
printf("Exception %s \n", p.__cxa_exception_type()->name());
result["status"] = -1; result["status"] = -1;
result["errorMessage"] = "Read key share has thrown exception"; result["errorMessage"] = "Read key share has thrown exception:";
return result; return result;
} }
...@@ -244,7 +246,7 @@ shared_ptr<string> readKeyShare(const string& _keyShareName) { ...@@ -244,7 +246,7 @@ shared_ptr<string> readKeyShare(const string& _keyShareName) {
auto keyShareStr = levelDb->readString("BLSKEYSHARE:" + _keyShareName); auto keyShareStr = levelDb->readString("BLSKEYSHARE:" + _keyShareName);
if (keyShareStr == nullptr) { if (keyShareStr == nullptr) {
throw new RPCException(KEY_SHARE_DOES_NOT_EXIST, "Key share with this name does not exists"); throw RPCException(KEY_SHARE_DOES_NOT_EXIST, "Key share with this name does not exists");
} }
return keyShareStr; return keyShareStr;
......
...@@ -65,8 +65,6 @@ sgx_enclave_id_t eid; ...@@ -65,8 +65,6 @@ sgx_enclave_id_t eid;
sgx_status_t status; sgx_status_t status;
int updated; int updated;
#define TEST_BLS_KEY_SHARE "4160780231445160889237664391382223604184857153814275770598791864649971919844" #define TEST_BLS_KEY_SHARE "4160780231445160889237664391382223604184857153814275770598791864649971919844"
#define TEST_BLS_KEY_NAME "SCHAIN:17:INDEX:5:KEY:1" #define TEST_BLS_KEY_NAME "SCHAIN:17:INDEX:5:KEY:1"
...@@ -183,14 +181,15 @@ TEST_CASE("Server BLS sign test", "[bls-server-sign]") { ...@@ -183,14 +181,15 @@ TEST_CASE("Server BLS sign test", "[bls-server-sign]") {
init_all(); init_all();
char* encryptedKeyHex = encryptTestKey(); auto result = importBLSKeyShareImpl(1, TEST_BLS_KEY_SHARE, TEST_BLS_KEY_NAME, 2, 2);
REQUIRE(encryptedKeyHex != nullptr); REQUIRE(result["status"] == 0);
REQUIRE(result["encryptedKeyShare"] != "");
const char *hexHash = "001122334455667788" "001122334455667788" "001122334455667788" "001122334455667788"; const char *hexHash = "001122334455667788" "001122334455667788" "001122334455667788" "001122334455667788";
Json::Value result;
REQUIRE_NOTHROW(result = blsSignMessageHashImpl(TEST_BLS_KEY_NAME, hexHash)); REQUIRE_NOTHROW(result = blsSignMessageHashImpl(TEST_BLS_KEY_NAME, hexHash));
......
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