SKALE-2844 write backup key to file on the disk

parent 8f8749a3
......@@ -26,6 +26,7 @@
#include "BLSCrypto.h"
#include "LevelDB.h"
#include <fstream>
#include <iostream>
#include <algorithm>
......@@ -130,8 +131,12 @@ void gen_SEK(){
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;
cout << "YOUR KEY IS " << SEK << endl;
std::ofstream sek_file("backup_key.txt");
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) {
std::string confirm_str = "I confirm";
......
......@@ -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]") {
HttpClient client(RPC_ENDPOINT);
StubClient c(client, JSONRPC_CLIENT_V2);
......
......@@ -32,6 +32,7 @@ print("Top directory is:" + topDir)
testList = [ "[cert-sign]",
"[get-server-status]",
"[get-server-version]",
"[backup-key]",
"[ecdsa-key-gen]",
"[ecdsa-aes-key-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