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
3c1111f2
Unverified
Commit
3c1111f2
authored
Jun 29, 2020
by
Oleh Nikolaiev
Committed by
GitHub
Jun 29, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #117 from skalenetwork/bug/SKALE-2835-delete-keys
SKALE-2835 add api call to delete bls key
parents
17310b56
0010867e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
5 deletions
+56
-5
dockerimagesim.yml
.github/workflows/dockerimagesim.yml
+1
-0
LevelDB.cpp
LevelDB.cpp
+0
-1
LevelDB.h
LevelDB.h
+1
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+27
-2
SGXWalletServer.hpp
SGXWalletServer.hpp
+4
-0
abstractstubserver.h
abstractstubserver.h
+6
-0
sgxwallet_common.h
sgxwallet_common.h
+1
-0
stubclient.h
stubclient.h
+12
-0
testw.cpp
testw.cpp
+4
-1
No files found.
.github/workflows/dockerimagesim.yml
View file @
3c1111f2
...
...
@@ -30,6 +30,7 @@ jobs:
-
name
:
build container for testing
run
:
python3 scripts/docker_build.py DockerfileSimulation sgxwalletsim ${GITHUB_SHA}
-
name
:
test
if
:
contains(github.ref, 'develop')
run
:
python3 scripts/docker_test.py DockerfileSimulation sgxwalletsim
-
name
:
deploy docker image
if
:
contains(github.ref, 'develop') || contains(github.ref, 'beta') || contains(github.ref, 'master') || contains(github.ref, 'stable')
...
...
LevelDB.cpp
View file @
3c1111f2
...
...
@@ -114,7 +114,6 @@ void LevelDB::deleteKey(const string &_key) {
}
void
LevelDB
::
writeByteArray
(
const
char
*
_key
,
size_t
_keyLen
,
const
char
*
value
,
size_t
_valueLen
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
...
...
LevelDB.h
View file @
3c1111f2
...
...
@@ -118,4 +118,4 @@ public:
#endif
\ No newline at end of file
#endif
SGXWalletServer.cpp
View file @
3c1111f2
...
...
@@ -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
()
->
deleteKey
(
_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,25 @@ Json::Value SGXWalletServer::getServerVersionImpl() {
return
result
;
}
Json
::
Value
SGXWalletServer
::
deleteBlsKeyImpl
(
const
std
::
string
&
name
)
{
INIT_RESULT
(
result
)
result
[
"deleted"
]
=
false
;
try
{
if
(
!
checkName
(
name
,
"BLS_KEY"
))
{
throw
SGXException
(
INVALID_BLS_NAME
,
"Invalid BLSKey name"
);
}
std
::
shared_ptr
<
std
::
string
>
bls_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
name
);
if
(
bls_ptr
!=
nullptr
)
{
result
[
"deleted"
]
=
true
;
return
result
;
}
LevelDB
::
getLevelDb
()
->
deleteKey
(
name
);
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
}
Json
::
Value
SGXWalletServer
::
generateDKGPoly
(
const
string
&
_polyName
,
int
_t
)
{
WRITE_LOCK
(
m
)
...
...
@@ -763,6 +783,11 @@ Json::Value SGXWalletServer::getServerVersion() {
return
getServerVersionImpl
();
}
Json
::
Value
SGXWalletServer
::
deleteBlsKey
(
const
std
::
string
&
name
)
{
READ_LOCK
(
m
)
return
deleteBlsKeyImpl
(
name
);
}
shared_ptr
<
string
>
SGXWalletServer
::
readFromDb
(
const
string
&
name
,
const
string
&
prefix
)
{
auto
dataStr
=
LevelDB
::
getLevelDb
()
->
readString
(
prefix
+
name
);
...
...
SGXWalletServer.hpp
View file @
3c1111f2
...
...
@@ -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
();
...
...
abstractstubserver.h
View file @
3c1111f2
...
...
@@ -57,6 +57,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"getServerStatus"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
NULL
),
&
AbstractStubServer
::
getServerStatusI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"getServerVersion"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
NULL
),
&
AbstractStubServer
::
getServerVersionI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"deleteBlsKey"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"blsKeyName"
,
jsonrpc
::
JSON_STRING
,
NULL
),
&
AbstractStubServer
::
deleteBlsKeyI
);
}
inline
virtual
void
importBLSKeyShareI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
...
...
@@ -140,6 +141,10 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
response
=
this
->
getServerVersion
();
}
inline
virtual
void
deleteBlsKeyI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
response
=
this
->
deleteBlsKey
(
request
[
"blsKeyName"
].
asString
());
}
virtual
Json
::
Value
importBLSKeyShare
(
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyShareName
,
int
t
,
int
n
,
int
index
)
=
0
;
virtual
Json
::
Value
blsSignMessageHash
(
const
std
::
string
&
keyShareName
,
const
std
::
string
&
messageHash
,
int
t
,
int
n
,
int
signerIndex
)
=
0
;
virtual
Json
::
Value
importECDSAKey
(
const
std
::
string
&
key
,
const
std
::
string
&
keyName
)
=
0
;
...
...
@@ -160,6 +165,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
virtual
Json
::
Value
getServerStatus
()
=
0
;
virtual
Json
::
Value
getServerVersion
()
=
0
;
virtual
Json
::
Value
deleteBlsKey
(
const
std
::
string
&
name
)
=
0
;
};
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
sgxwallet_common.h
View file @
3c1111f2
...
...
@@ -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
...
...
stubclient.h
View file @
3c1111f2
...
...
@@ -220,6 +220,18 @@ class StubClient : public jsonrpc::Client
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
Json
::
Value
deleteBlsKey
(
const
std
::
string
&
polyName
)
{
Json
::
Value
p
;
p
[
"blsKeyName"
]
=
polyName
;
Json
::
Value
result
=
this
->
CallMethod
(
"deleteBlsKey"
,
p
);
if
(
result
.
isObject
())
return
result
;
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
////CSRManagerServer
...
...
testw.cpp
View file @
3c1111f2
...
...
@@ -574,8 +574,11 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
TestUtils
::
doDKG
(
c
,
16
,
5
,
ecdsaKeyNames
,
blsKeyNames
,
schainID
,
dkgID
);
}
for
(
const
auto
&
name
:
blsKeyNames
)
{
REQUIRE
(
c
.
deleteBlsKey
(
name
)[
"deleted"
]
==
true
);
}
}
TEST_CASE_METHOD
(
TestFixture
,
"Get ServerStatus"
,
"[get-server-status]"
)
{
HttpClient
client
(
RPC_ENDPOINT
);
...
...
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