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
63a08c85
Unverified
Commit
63a08c85
authored
Jul 20, 2021
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-4262 write key owners to db
parent
331cc90a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
14 deletions
+16
-14
LevelDB.h
LevelDB.h
+1
-4
SGXWalletServer.hpp
SGXWalletServer.hpp
+1
-4
ReqMessage.cpp
zmq_src/ReqMessage.cpp
+5
-5
ZMQMessage.cpp
zmq_src/ZMQMessage.cpp
+7
-1
ZMQMessage.h
zmq_src/ZMQMessage.h
+2
-0
No files found.
LevelDB.h
View file @
63a08c85
...
...
@@ -54,7 +54,6 @@ class LevelDB {
static
string
sgx_data_folder
;
public
:
static
void
initDataFolderAndDBs
();
...
...
@@ -104,8 +103,6 @@ public:
virtual
~
LevelDB
();
static
const
string
&
getSgxDataFolder
();
};
...
...
SGXWalletServer.hpp
View file @
63a08c85
...
...
@@ -48,12 +48,9 @@ class SGXWalletServer : public AbstractStubServer {
static
map
<
string
,
string
>
ecdsaRequests
;
static
recursive_mutex
ecdsaRequestsLock
;
static
void
checkForDuplicate
(
map
<
string
,
string
>
&
_map
,
recursive_mutex
&
_m
,
const
string
&
_key
,
const
string
&
_value
);
public
:
static
bool
verifyCert
(
string
&
_certFileName
);
...
...
zmq_src/ReqMessage.cpp
View file @
63a08c85
...
...
@@ -60,7 +60,7 @@ Json::Value importBLSReqMessage::process() {
auto
result
=
SGXWalletServer
::
importBLSKeyShareImpl
(
keyShare
,
keyName
);
if
(
result
[
"status"
]
==
0
)
{
auto
cert
=
getStringRapid
(
"cert"
);
keysByOwners
[
keyName
]
=
cert
;
addKeyByOwner
(
keyName
,
cert
)
;
}
result
[
"type"
]
=
ZMQMessage
::
IMPORT_BLS_RSP
;
return
result
;
...
...
@@ -72,7 +72,7 @@ Json::Value importECDSAReqMessage::process() {
auto
result
=
SGXWalletServer
::
importECDSAKeyImpl
(
key
,
keyName
);
if
(
result
[
"status"
]
==
0
)
{
auto
cert
=
getStringRapid
(
"cert"
);
keysByOwners
[
keyName
]
=
cert
;
addKeyByOwner
(
keyName
,
cert
)
;
}
result
[
"type"
]
=
ZMQMessage
::
IMPORT_ECDSA_RSP
;
return
result
;
...
...
@@ -83,7 +83,7 @@ Json::Value generateECDSAReqMessage::process() {
string
keyName
=
result
[
"keyName"
].
asString
();
if
(
result
[
"status"
]
==
0
)
{
auto
cert
=
getStringRapid
(
"cert"
);
keysByOwners
[
keyName
]
=
cert
;
addKeyByOwner
(
keyName
,
cert
)
;
}
result
[
"type"
]
=
ZMQMessage
::
GENERATE_ECDSA_RSP
;
return
result
;
...
...
@@ -106,7 +106,7 @@ Json::Value generateDKGPolyReqMessage::process() {
auto
result
=
SGXWalletServer
::
generateDKGPolyImpl
(
polyName
,
t
);
if
(
result
[
"status"
]
==
0
)
{
auto
cert
=
getStringRapid
(
"cert"
);
keysByOwners
[
polyName
]
=
cert
;
addKeyByOwner
(
polyName
,
cert
)
;
}
result
[
"type"
]
=
ZMQMessage
::
GENERATE_DKG_POLY_RSP
;
return
result
;
...
...
@@ -167,7 +167,7 @@ Json::Value createBLSPrivateKeyReqMessage::process() {
}
auto
result
=
SGXWalletServer
::
createBLSPrivateKeyV2Impl
(
blsKeyName
,
ethKeyName
,
polyName
,
secretShare
,
t
,
n
);
if
(
result
[
"status"
]
==
0
)
{
keysByOwners
[
blsKeyName
]
=
cert
;
addKeyByOwner
(
blsKeyName
,
cert
)
;
}
result
[
"type"
]
=
ZMQMessage
::
CREATE_BLS_PRIVATE_RSP
;
return
result
;
...
...
zmq_src/ZMQMessage.cpp
View file @
63a08c85
...
...
@@ -28,6 +28,7 @@
#include <fstream>
#include "ZMQClient.h"
#include "LevelDB.h"
#include "SGXWalletServer.hpp"
#include "ReqMessage.h"
#include "RspMessage.h"
...
...
@@ -315,7 +316,12 @@ shared_ptr <ZMQMessage> ZMQMessage::buildResponse(string &_type, shared_ptr <rap
std
::
map
<
string
,
string
>
ZMQMessage
::
keysByOwners
;
bool
ZMQMessage
::
isKeyByOwner
(
const
string
&
keyName
,
const
string
&
cert
)
{
return
keysByOwners
.
count
(
keyName
)
&&
keysByOwners
[
keyName
]
==
cert
;
auto
value
=
LevelDB
::
getLevelDb
()
->
readString
(
keyName
);
return
value
&&
*
value
==
cert
;
}
void
ZMQMessage
::
addKeyByOwner
(
const
string
&
keyName
,
const
string
&
cert
)
{
SGXWalletServer
::
writeDataToDB
(
keyName
,
cert
);
}
cache
::
lru_cache
<
string
,
pair
<
EVP_PKEY
*
,
X509
*>>
ZMQMessage
::
verifiedCerts
(
256
);
...
...
zmq_src/ZMQMessage.h
View file @
63a08c85
...
...
@@ -57,6 +57,8 @@ protected:
static
bool
isKeyByOwner
(
const
string
&
keyName
,
const
string
&
cert
);
static
void
addKeyByOwner
(
const
string
&
keyName
,
const
string
&
cert
);
public
:
static
constexpr
const
char
*
BLS_SIGN_REQ
=
"BLSSignReq"
;
...
...
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