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
f5c170c9
Unverified
Commit
f5c170c9
authored
Dec 17, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding ZMQ
parent
de0b34bb
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
66 additions
and
20 deletions
+66
-20
BLSSignReqMessage.cpp
BLSSignReqMessage.cpp
+10
-0
BLSSignReqMessage.h
BLSSignReqMessage.h
+3
-0
ECDSASignReqMessage.cpp
ECDSASignReqMessage.cpp
+13
-0
ECDSASignReqMessage.h
ECDSASignReqMessage.h
+4
-0
Makefile.am
Makefile.am
+1
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+6
-8
SGXWalletServer.hpp
SGXWalletServer.hpp
+2
-1
ServerInit.cpp
ServerInit.cpp
+4
-0
ServerWorker.cpp
ServerWorker.cpp
+11
-3
ServerWorker.h
ServerWorker.h
+1
-1
ZMQMessage.cpp
ZMQMessage.cpp
+1
-1
ZMQMessage.h
ZMQMessage.h
+10
-5
No files found.
BLSSignReqMessage.cpp
View file @
f5c170c9
...
...
@@ -3,3 +3,13 @@
//
#include "BLSSignReqMessage.h"
#include "SGXWalletServer.hpp"
Json
::
Value
BLSSignReqMessage
::
process
()
{
auto
keyName
=
getStringRapid
(
"kn"
);
auto
hash
=
getStringRapid
(
"mh"
);
auto
t
=
getUint64Rapid
(
"t"
);
auto
n
=
getUint64Rapid
(
"n"
);
return
SGXWalletServer
::
blsSignMessageHashImpl
(
keyName
,
hash
,
t
,
n
);
}
\ No newline at end of file
BLSSignReqMessage.h
View file @
f5c170c9
...
...
@@ -10,6 +10,9 @@
class
BLSSignReqMessage
:
public
ZMQMessage
{
public
:
BLSSignReqMessage
(
shared_ptr
<
rapidjson
::
Document
>&
_d
)
:
ZMQMessage
(
_d
)
{};
virtual
Json
::
Value
process
();
};
...
...
ECDSASignReqMessage.cpp
View file @
f5c170c9
...
...
@@ -2,4 +2,17 @@
// Created by kladko on 15.12.20.
//
#include <json/value.h>
#include "SGXWalletServer.hpp"
#include "ECDSASignReqMessage.h"
Json
::
Value
ECDSASignReqMessage
::
process
()
{
auto
base
=
getUint64Rapid
(
"bs"
);
auto
keyName
=
getStringRapid
(
"kn"
);
auto
hash
=
getStringRapid
(
"mh"
);
return
SGXWalletServer
::
ecdsaSignMessageHashImpl
(
base
,
keyName
,
hash
);
}
\ No newline at end of file
ECDSASignReqMessage.h
View file @
f5c170c9
...
...
@@ -9,7 +9,11 @@
class
ECDSASignReqMessage
:
public
ZMQMessage
{
public
:
ECDSASignReqMessage
(
shared_ptr
<
rapidjson
::
Document
>
&
_d
)
:
ZMQMessage
(
_d
)
{};
virtual
Json
::
Value
process
();
};
...
...
Makefile.am
View file @
f5c170c9
...
...
@@ -69,7 +69,7 @@ bin_PROGRAMS = sgxwallet testw cert_util
## have to be explicitly listed.
## have to be explicitly listed
COMMON_SRC
=
ZMQMessage.cpp ZMQServer.cpp ServerWorker.cpp InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp
\
COMMON_SRC
=
ECDSASignReqMessage.cpp BLSSignReqMessage.cpp
ZMQMessage.cpp ZMQServer.cpp ServerWorker.cpp InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp
\
SGXWalletServer.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp BLSCrypto.cpp
\
ECDSACrypto.cpp
\
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp ServerDataChecker.cpp SEKManager.cpp
\
...
...
SGXWalletServer.cpp
View file @
f5c170c9
...
...
@@ -25,8 +25,11 @@
#include "abstractstubserver.h"
#include <jsonrpccpp/server/connectors/httpserver.h>
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <unistd.h>
#include "sgxwallet_common.h"
#include "sgxwallet.h"
...
...
@@ -42,13 +45,6 @@
#include "SGXWalletServer.hpp"
#include "ServerDataChecker.h"
#include <algorithm>
#include <stdlib.h>
#include <unistd.h>
#include "ServerInit.h"
#include "Log.h"
...
...
@@ -312,6 +308,8 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
result
[
"signatureShare"
]
=
string
(
signature
.
data
());
RETURN_SUCCESS
(
result
);
}
...
...
SGXWalletServer.hpp
View file @
f5c170c9
...
...
@@ -25,7 +25,8 @@
#define SGXWALLET_SGXWALLETSERVER_HPP
#include "mutex"
#include "memory"
#include <jsonrpccpp/server/connectors/httpserver.h>
...
...
ServerInit.cpp
View file @
f5c170c9
...
...
@@ -122,11 +122,14 @@ void initUserSpace() {
systemHealthCheck
();
#endif
#ifdef EXPERIMENTAL_ZMQ_SERVER
zmqServer
=
new
ZMQServer
();
static
std
::
thread
serverThread
(
std
::
bind
(
&
ZMQServer
::
run
,
zmqServer
));
#endif
}
void
exitZMQServer
()
{
#ifdef EXPERIMENTAL_ZMQ_SERVER
auto
doExit
=
!
exiting
.
exchange
(
true
);
...
...
@@ -137,6 +140,7 @@ void exitZMQServer() {
zmqServer
=
nullptr
;
}
#endif
}
uint64_t
initEnclave
()
{
...
...
ServerWorker.cpp
View file @
f5c170c9
...
...
@@ -2,6 +2,7 @@
// Created by kladko on 14.12.20.
//
#include "common.h"
#include <json/writer.h>
#include "ZMQMessage.h"
#include "ServerWorker.h"
...
...
@@ -21,10 +22,17 @@ void ServerWorker::work() {
memcpy
(
msgData
.
data
(),
msg
.
data
(),
msg
.
size
());
auto
parseMsg
=
ZMQMessage
::
parse
(
msgData
);
auto
parse
d
Msg
=
ZMQMessage
::
parse
(
msgData
);
copied_msg
.
copy
(
&
msg
);
worker_
.
send
(
copied_msg
);
CHECK_STATE
(
parsedMsg
);
auto
reply
=
parsedMsg
->
process
();
Json
::
FastWriter
fastWriter
;
std
::
string
replyStr
=
fastWriter
.
write
(
reply
);
zmq
::
message_t
replyMsg
(
replyStr
.
c_str
(),
replyStr
.
size
()
+
1
);
worker_
.
send
(
replyMsg
);
}
}
catch
(
std
::
exception
&
e
)
{
...
...
ServerWorker.h
View file @
f5c170c9
...
...
@@ -9,10 +9,10 @@
#include <thread>
#include <memory>
#include <functional>
#include <json/value.h>
#include <zmq.hpp>
#include "zhelpers.hpp"
#include "third_party/spdlog/spdlog.h"
#include "document.h"
...
...
ZMQMessage.cpp
View file @
f5c170c9
...
...
@@ -69,6 +69,6 @@ shared_ptr<ZMQMessage> ZMQMessage::parse(vector<uint8_t>& _msg) {
throw
SGXException
(
-
301
,
"Incorrect zmq message type: "
+
string
(
type
));
}
return
make_shared
<
ZMQMessage
>
(
d
)
;
return
result
;
}
ZMQMessage.h
View file @
f5c170c9
...
...
@@ -24,16 +24,19 @@
#pragma once
#include <memory>
#include <vector>
#include <json/value.h>
#include "document.h"
#include "SGXException.h"
using
namespace
std
;
class
ZMQMessage
{
shared_ptr
<
rapidjson
::
Document
>
d
;
shared_ptr
<
rapidjson
::
Document
>
d
;
static
constexpr
const
char
*
BLS_SIGN_REQ
=
"BLSSignReq"
;
static
constexpr
const
char
*
BLS_SIGN_RSP
=
"BLSSignRsp"
;
...
...
@@ -45,13 +48,15 @@ protected:
public
:
explicit
ZMQMessage
(
shared_ptr
<
rapidjson
::
Document
>
&
_d
)
:
d
(
_d
)
{
explicit
ZMQMessage
(
shared_ptr
<
rapidjson
::
Document
>
&
_d
)
:
d
(
_d
)
{
};
string
getStringRapid
(
const
char
*
_name
);
uint64_t
getUint64Rapid
(
const
char
*
_name
);
static
shared_ptr
<
ZMQMessage
>
parse
(
vector
<
uint8_t
>
&
_msg
);
static
shared_ptr
<
ZMQMessage
>
parse
(
vector
<
uint8_t
>
&
_msg
);
virtual
Json
::
Value
process
()
=
0
;
};
\ No newline at end of file
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