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
ac359040
Unverified
Commit
ac359040
authored
Jun 29, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2835 add api call to delete bls key
parent
17310b56
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
3 deletions
+39
-3
LevelDB.cpp
LevelDB.cpp
+10
-0
LevelDB.h
LevelDB.h
+3
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+21
-2
SGXWalletServer.hpp
SGXWalletServer.hpp
+4
-0
sgxwallet_common.h
sgxwallet_common.h
+1
-0
No files found.
LevelDB.cpp
View file @
ac359040
...
...
@@ -113,6 +113,16 @@ void LevelDB::deleteKey(const string &_key) {
spdlog
::
debug
(
"key deleted: {}"
,
_key
);
}
void
LevelDB
::
deleteDkgPoly
(
const
std
::
string
&
name
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Delete
(
writeOptions
,
Slice
(
name
));
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"key deleted: {}"
,
name
);
}
void
LevelDB
::
writeByteArray
(
const
char
*
_key
,
size_t
_keyLen
,
const
char
*
value
,
...
...
LevelDB.h
View file @
ac359040
...
...
@@ -87,6 +87,8 @@ public:
void
deleteKey
(
const
string
&
_key
);
void
deleteDkgPoly
(
const
std
::
string
&
name
);
public
:
...
...
@@ -118,4 +120,4 @@ public:
#endif
\ No newline at end of file
#endif
SGXWalletServer.cpp
View file @
ac359040
...
...
@@ -546,7 +546,7 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
throw
SGXException
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
if
(
!
checkName
(
_blsKeyName
,
"BLS_KEY"
))
{
throw
SGXException
(
INVALID_
POLY
_NAME
,
"Invalid BLS key name"
);
throw
SGXException
(
INVALID_
BLS
_NAME
,
"Invalid BLS key name"
);
}
if
(
!
check_n_t
(
_t
,
_n
))
{
throw
SGXException
(
INVALID_DKG_PARAMS
,
"Invalid DKG parameters: n or t "
);
...
...
@@ -569,6 +569,7 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
LevelDB
::
getLevelDb
()
->
deleteDHDKGKey
(
name
);
string
shareG2_name
=
"shareG2_"
+
_polyName
+
"_"
+
to_string
(
i
)
+
":"
;
LevelDB
::
getLevelDb
()
->
deleteKey
(
shareG2_name
);
LevelDB
::
getLevelDb
()
->
deleteDkgPoly
(
_polyName
`
);
}
}
HANDLE_SGX_EXCEPTION
(
result
)
...
...
@@ -581,7 +582,7 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
try
{
if
(
!
checkName
(
_blsKeyName
,
"BLS_KEY"
))
{
throw
SGXException
(
INVALID_
POLY
_NAME
,
"Invalid BLSKey name"
);
throw
SGXException
(
INVALID_
BLS
_NAME
,
"Invalid BLSKey name"
);
}
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
_blsKeyName
);
spdlog
::
debug
(
"encr_bls_key_share is {}"
,
*
encryptedKeyHex_ptr
);
...
...
@@ -660,6 +661,19 @@ Json::Value SGXWalletServer::getServerVersionImpl() {
return
result
;
}
Json
::
Value
SGXWalletServer
::
deleteBlsKeyImpl
(
const
std
::
string
&
name
)
{
INIT_RESULT
(
result
)
result
[
"deleted"
]
=
false
;
try
{
if
(
!
checkName
(
_blsKeyName
,
"BLS_KEY"
))
{
throw
SGXException
(
INVALID_BLS_NAME
,
"Invalid BLSKey name"
);
}
LevelDB
::
getLevelDb
()
->
deleteBlsKey
(
name
);
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
}
Json
::
Value
SGXWalletServer
::
generateDKGPoly
(
const
string
&
_polyName
,
int
_t
)
{
WRITE_LOCK
(
m
)
...
...
@@ -763,6 +777,11 @@ Json::Value SGXWalletServer::getServerVersion() {
return
getServerVersionImpl
();
}
Json
::
Value
SGXWalletServer
::
deleteBlsKey
()
{
READ_LOCK
(
m
)
return
deleteBlsKeyImpl
();
}
shared_ptr
<
string
>
SGXWalletServer
::
readFromDb
(
const
string
&
name
,
const
string
&
prefix
)
{
auto
dataStr
=
LevelDB
::
getLevelDb
()
->
readString
(
prefix
+
name
);
...
...
SGXWalletServer.hpp
View file @
ac359040
...
...
@@ -103,6 +103,8 @@ public:
virtual
Json
::
Value
getServerVersion
();
virtual
Json
::
Value
deleteBlsKey
(
const
std
::
string
&
name
);
static
shared_ptr
<
string
>
readFromDb
(
const
string
&
name
,
const
string
&
prefix
=
""
);
static
void
writeDataToDB
(
const
string
&
Name
,
const
string
&
value
);
...
...
@@ -154,6 +156,8 @@ public:
static
Json
::
Value
getServerVersionImpl
();
static
Json
::
Value
deleteBlsKeyImpl
(
const
std
::
string
&
name
);
static
void
printDB
();
static
int
initHttpServer
();
...
...
sgxwallet_common.h
View file @
ac359040
...
...
@@ -80,6 +80,7 @@ extern int autoconfirm;
#define INVALID_POLY_NAME -11
#define INVALID_DKG_PARAMS -12
#define INVALID_SECRET_SHARES_LENGTH -13
#define INVALID_BLS_NAME -15
#define CERT_REQUEST_DOES_NOT_EXIST -14
...
...
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