SKALE-2844 write backup key to file on the disk

parent 8f8749a3
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "BLSCrypto.h" #include "BLSCrypto.h"
#include "LevelDB.h" #include "LevelDB.h"
#include <fstream>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
...@@ -130,8 +131,12 @@ void gen_SEK(){ ...@@ -130,8 +131,12 @@ void gen_SEK(){
carray2Hex(encr_SEK.data(), enc_len, hexEncrKey.data()); carray2Hex(encr_SEK.data(), enc_len, hexEncrKey.data());
cout << "ATTENTION! THIS IS YOUR KEY FOR BACK UP. PLEASE COPY IT TO THE SAFE PLACE" << endl; std::ofstream sek_file("backup_key.txt");
cout << "YOUR KEY IS " << SEK << endl; sek_file.clear();
cout << "ATTENTION! YOUR BACKUP KEY WILL BE WROTE INTO backup_key.txt.\n" <<
"PLEASE COPY IT TO THE SAFE PLACE AND THEN DELETE THE FILE MANUALLY" << endl;
sek_file << SEK;
if (!autoconfirm) { if (!autoconfirm) {
std::string confirm_str = "I confirm"; std::string confirm_str = "I confirm";
......
...@@ -580,6 +580,18 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") { ...@@ -580,6 +580,18 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
} }
TEST_CASE_METHOD(TestFixture, "Backup Key", "[backup-key]") {
HttpClient client(RPC_ENDPOINT);
StubClient c(client, JSONRPC_CLIENT_V2);
std::ifstream sek_file("backup_key.txt");
REQUIRE(sek_file.good());
std::string sek;
sek_file >> sek;
REQUIRE(sek.size() == 32);
}
TEST_CASE_METHOD(TestFixture, "Get ServerStatus", "[get-server-status]") { TEST_CASE_METHOD(TestFixture, "Get ServerStatus", "[get-server-status]") {
HttpClient client(RPC_ENDPOINT); HttpClient client(RPC_ENDPOINT);
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
......
...@@ -32,6 +32,7 @@ print("Top directory is:" + topDir) ...@@ -32,6 +32,7 @@ print("Top directory is:" + topDir)
testList = [ "[cert-sign]", testList = [ "[cert-sign]",
"[get-server-status]", "[get-server-status]",
"[get-server-version]", "[get-server-version]",
"[backup-key]",
"[ecdsa-key-gen]", "[ecdsa-key-gen]",
"[ecdsa-aes-key-gen]", "[ecdsa-aes-key-gen]",
"[ecdsa-key-sig-gen]", "[ecdsa-key-sig-gen]",
......
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