Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
sgxwallet
Commits
47a2b90b
Unverified
Commit
47a2b90b
authored
Jul 02, 2020
by
Oleh Nikolaiev
Committed by
GitHub
Jul 02, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #119 from skalenetwork/bug/SKALE-2844-backup-key
Bug/skale 2844 backup key
parents
8f8749a3
a852dfff
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
50 additions
and
15 deletions
+50
-15
LevelDB.cpp
LevelDB.cpp
+4
-3
SEKManager.cpp
SEKManager.cpp
+8
-2
SGXWalletServer.cpp
SGXWalletServer.cpp
+7
-3
TestUtils.cpp
TestUtils.cpp
+1
-1
VERSION
VERSION
+1
-1
backup-procedure.md
docs/backup-procedure.md
+5
-0
DKGUtils.cpp
secure_enclave/DKGUtils.cpp
+1
-2
testw.cpp
testw.cpp
+21
-3
testw.py
testw.py
+2
-0
No files found.
LevelDB.cpp
View file @
47a2b90b
...
...
@@ -53,14 +53,15 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
throw
SGXException
(
NULL_DATABASE
,
"Null db"
);
}
auto
status
=
db
->
Get
(
readOptions
,
_key
,
&*
result
);
spdlog
::
info
(
"key to read from db: {}"
,
_key
);
spdlog
::
debug
(
"key to read from db: {}"
,
_key
);
auto
status
=
db
->
Get
(
readOptions
,
_key
,
&*
result
);
throwExceptionOnError
(
status
);
if
(
status
.
IsNotFound
())
if
(
status
.
IsNotFound
())
{
return
nullptr
;
}
return
result
;
}
...
...
SEKManager.cpp
View file @
47a2b90b
...
...
@@ -26,6 +26,7 @@
#include "BLSCrypto.h"
#include "LevelDB.h"
#include <fstream>
#include <iostream>
#include <algorithm>
...
...
@@ -130,8 +131,13 @@ 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 WRITTEN INTO backup_key.txt.
\n
"
<<
"PLEASE COPY IT TO THE SAFE PLACE AND THEN DELETE THE FILE MANUALLY BY RUNNING THE FOLLOWING COMMAND:
\n
"
<<
"`sudo apt-get install secure-delete && srm -vz backup_key.txt`"
<<
endl
;
sek_file
<<
SEK
;
if
(
!
autoconfirm
)
{
std
::
string
confirm_str
=
"I confirm"
;
...
...
SGXWalletServer.cpp
View file @
47a2b90b
...
...
@@ -667,14 +667,18 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) {
result
[
"deleted"
]
=
false
;
try
{
if
(
!
checkName
(
name
,
"BLS_KEY"
))
{
throw
SGXException
(
INVALID_BLS_NAME
,
"Invalid BLSKey name"
);
throw
SGXException
(
INVALID_BLS_NAME
,
"Invalid BLSKey name
format
"
);
}
std
::
shared_ptr
<
std
::
string
>
bls_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
name
);
std
::
string
key
=
"BLSKEYSHARE:"
+
name
;
std
::
shared_ptr
<
std
::
string
>
bls_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
key
);
if
(
bls_ptr
!=
nullptr
)
{
result
[
"deleted"
]
=
true
;
return
result
;
}
}
else
{
std
::
string
error_msg
=
"BLS key with such name not found: "
+
name
;
throw
SGXException
(
INVALID_BLS_NAME
,
error_msg
.
c_str
());
}
LevelDB
::
getLevelDb
()
->
deleteKey
(
name
);
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
...
...
TestUtils.cpp
View file @
47a2b90b
...
...
@@ -424,4 +424,4 @@ void TestUtils::doDKG(StubClient &c, int n, int t,
cerr
<<
i
<<
endl
;
}
\ No newline at end of file
}
VERSION
View file @
47a2b90b
1.52.0
\ No newline at end of file
1.53.0
docs/backup-procedure.md
View file @
47a2b90b
...
...
@@ -4,6 +4,11 @@
When SGXWallet is initialized, the server will print the backup key.
**This key must be securely recorded and stored.**
Be sure to store this key in a safe place, then securely remove it with the following command:
```
bash
sudo
apt-get
install
secure-delete
&&
srm
-vz
backup_key.txt
```
Master-Slave replication is recommended to support the SGXWallet backup strategy. Below are general instructions for a basic backup and recovery process.
...
...
secure_enclave/DKGUtils.cpp
View file @
47a2b90b
...
...
@@ -57,8 +57,7 @@ string stringFromFr(libff::alt_bn128_Fr& _el) {
return
string
(
tmp
);
}
template
<
class
T
>
string
ConvertToString
(
T
field_elem
,
int
base
=
10
)
{
template
<
class
T
>
string
ConvertToString
(
T
field_elem
,
int
base
=
10
)
{
mpz_t
t
;
mpz_init
(
t
);
...
...
testw.cpp
View file @
47a2b90b
...
...
@@ -573,11 +573,29 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
dkgID
=
TestUtils
::
randGen
();
TestUtils
::
doDKG
(
c
,
16
,
5
,
ecdsaKeyNames
,
blsKeyNames
,
schainID
,
dkgID
);
}
for
(
const
auto
&
name
:
blsKeyNames
)
{
REQUIRE
(
c
.
deleteBlsKey
(
name
)[
"deleted"
]
==
true
);
}
TEST_CASE_METHOD
(
TestFixture
,
"Delete Bls Key"
,
"[delete-bls-key]"
)
{
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
std
::
string
name
=
"BLS_KEY:SCHAIN_ID:123456789:NODE_ID:0:DKG_ID:0"
;
libff
::
alt_bn128_Fr
key
=
libff
::
alt_bn128_Fr
(
"6507625568967977077291849236396320012317305261598035438182864059942098934847"
);
std
::
string
key_str
=
TestUtils
::
stringFromFr
(
key
);
c
.
importBLSKeyShare
(
key_str
,
name
,
1
,
2
,
1
);
REQUIRE
(
c
.
deleteBlsKey
(
name
)[
"deleted"
]
==
true
);
}
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]"
)
{
...
...
testw.py
View file @
47a2b90b
...
...
@@ -32,6 +32,8 @@ print("Top directory is:" + topDir)
testList
=
[
"[cert-sign]"
,
"[get-server-status]"
,
"[get-server-version]"
,
"[backup-key]"
,
"[delete-bls-key]"
,
"[ecdsa-key-gen]"
,
"[ecdsa-aes-key-gen]"
,
"[ecdsa-key-sig-gen]"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment