Writing key share

parent d0d984cc
...@@ -64,7 +64,7 @@ importBLSKeyShareImpl(int index, const std::string &_keyShare, const std::string ...@@ -64,7 +64,7 @@ importBLSKeyShareImpl(int index, const std::string &_keyShare, const std::string
result["encryptedKeyShare"] = encryptedKeyShareHex; result["encryptedKeyShare"] = encryptedKeyShareHex;
writeKeyShare(_keyShareName, encryptedKeyShareHex); writeKeyShare(_keyShareName, encryptedKeyShareHex, index, n , t);
} catch (RPCException &_e) { } catch (RPCException &_e) {
result["status"] = _e.status; result["status"] = _e.status;
...@@ -195,7 +195,7 @@ Json::Value SGXWalletServer::importECDSAKey(const std::string &key, const std::s ...@@ -195,7 +195,7 @@ Json::Value SGXWalletServer::importECDSAKey(const std::string &key, const std::s
} }
shared_ptr <string> readKeyShare(const string &_keyShareName) { shared_ptr<string> readKeyShare(const string &_keyShareName) {
auto keyShareStr = levelDb->readString("BLSKEYSHARE:" + _keyShareName); auto keyShareStr = levelDb->readString("BLSKEYSHARE:" + _keyShareName);
...@@ -207,7 +207,17 @@ shared_ptr <string> readKeyShare(const string &_keyShareName) { ...@@ -207,7 +207,17 @@ shared_ptr <string> readKeyShare(const string &_keyShareName) {
} }
void writeKeyShare(const string &_keyShareName, const string &value) { void writeKeyShare(const string &_keyShareName, const string &value, int index, int n, int t) {
Json::Value val;
Json::FastWriter writer;
val["value"] = value;
val["t"] = t;
val["index"] = index;
val["n'"] = n;
std::string json = writer.write(val);
auto key = "BLSKEYSHARE:" + _keyShareName; auto key = "BLSKEYSHARE:" + _keyShareName;
......
...@@ -29,7 +29,7 @@ public: ...@@ -29,7 +29,7 @@ public:
void writeKeyShare(const string& _keyShare, const string& value); void writeKeyShare(const string &_keyShareName, const string &value, int index, int n, int t);
shared_ptr<std::string> readKeyShare(const string& _keyShare); shared_ptr<std::string> readKeyShare(const string& _keyShare);
......
...@@ -221,7 +221,7 @@ TEST_CASE("KeysDB test", "[keys-db]") { ...@@ -221,7 +221,7 @@ TEST_CASE("KeysDB test", "[keys-db]") {
REQUIRE_THROWS(readKeyShare(key)); REQUIRE_THROWS(readKeyShare(key));
writeKeyShare(key, value); writeKeyShare(key, value, 1, 2, 1);
REQUIRE(readKeyShare(key) != nullptr); REQUIRE(readKeyShare(key) != nullptr);
......
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