SKALE-2977 clean up

parent 8a5f3dd0
#include "secure_enclave/Point.c"
#include "secure_enclave/DomainParameters.c"
#include "secure_enclave/NumberTheory.c"
#include "secure_enclave/Signature.c"
#include "secure_enclave/Curves.c"
......@@ -21,13 +21,11 @@
@date 2019
*/
#include <stdexcept>
#include <memory>
#include <string>
#include <iostream>
#include "leveldb/db.h"
#include "sgxwallet_common.h"
......@@ -53,9 +51,10 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
throw SGXException(NULL_DATABASE, "Null db");
}
spdlog::debug("key to read from db: {}",_key );
spdlog::debug("key to read from db: {}", _key);
auto status = db->Get(readOptions, _key, &*result);
auto status = db->Get(readOptions, _key, result.get());
spdlog::debug("SUCCESS READING");
throwExceptionOnError(status);
......@@ -73,11 +72,11 @@ void LevelDB::writeString(const string &_key, const string &_value) {
throwExceptionOnError(status);
spdlog::debug("written key: {}",_key );
spdlog::debug("written key: {}", _key);
}
void LevelDB::deleteDHDKGKey (const string &_key) {
void LevelDB::deleteDHDKGKey(const string &_key) {
std::lock_guard<std::recursive_mutex> lock(mutex);
string full_key = "DKG_DH_KEY_" + _key;
......@@ -86,7 +85,7 @@ void LevelDB::deleteDHDKGKey (const string &_key) {
throwExceptionOnError(status);
spdlog::debug("key deleted: {}",full_key );
spdlog::debug("key deleted: {}", full_key);
}
void LevelDB::deleteTempNEK(const string &_key) {
......@@ -101,7 +100,7 @@ void LevelDB::deleteTempNEK(const string &_key) {
throwExceptionOnError(status);
std::cerr << "key deleted " << _key << std::endl;
spdlog::debug("key deleted: {}", _key);
}
void LevelDB::deleteKey(const string &_key) {
......@@ -111,7 +110,7 @@ void LevelDB::deleteKey(const string &_key) {
throwExceptionOnError(status);
spdlog::debug("key deleted: {}",_key );
spdlog::debug("key deleted: {}", _key);
}
......
......@@ -66,10 +66,11 @@ bin_PROGRAMS = sgxwallet testw cert_util
## have to be explicitly listed.
COMMON_SRC = InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp \
SGXWalletServer.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp BLSCrypto.cpp ECDSACrypto.cpp \
SGXWalletServer.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp BLSCrypto.cpp \
ECDSACrypto.cpp \
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp ServerDataChecker.cpp SEKManager.cpp \
third_party/intel/sgx_stub.c third_party/intel/sgx_detect_linux.c third_party/intel/create_enclave.c third_party/intel/oc_alloc.c \
TestUtils.cpp sgxwallet.c
ECDSAImpl.c TestUtils.cpp sgxwallet.c
COMMON_ENCLAVE_SRC = secure_enclave_u.c secure_enclave_u.h
sgxwallet_SOURCES = sgxwall.cpp $(COMMON_SRC)
......
......@@ -353,7 +353,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
throw SGXException(-22, "Invalid base");
}
shared_ptr <string> encryptedKey = readFromDb(_keyName, "");
shared_ptr <string> encryptedKey = readFromDb(_keyName);
signatureVector = ecdsaSignHash(encryptedKey->c_str(), hashTmp.c_str(), _base);
if (signatureVector.size() != 3) {
......@@ -795,17 +795,9 @@ void SGXWalletServer::writeKeyShare(const string &_keyShareName, const string &_
LevelDB::getLevelDb()->writeString(_keyShareName, _value);
}
void SGXWalletServer::writeDataToDB(const string &Name, const string &value) {
Json::Value val;
Json::FastWriter writer;
val["value"] = value;
writer.write(val);
auto key = Name;
if (LevelDB::getLevelDb()->readString(Name) != nullptr) {
spdlog::info("name {}", Name, " already exists");
void SGXWalletServer::writeDataToDB(const string &key, const string &value) {
if (LevelDB::getLevelDb()->readString(key) != nullptr) {
spdlog::info("name {}", key, " already exists");
throw SGXException(KEY_SHARE_ALREADY_EXISTS, "Key share already exists");
}
......
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