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
fc88b9c4
Unverified
Commit
fc88b9c4
authored
Sep 15, 2021
by
Oleh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-4262 add registerKeyOwner
parent
97f46332
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
2 deletions
+51
-2
SGXWalletServer.cpp
SGXWalletServer.cpp
+22
-0
SGXWalletServer.hpp
SGXWalletServer.hpp
+2
-0
sgxwallet_common.h
sgxwallet_common.h
+2
-0
ReqMessage.cpp
zmq_src/ReqMessage.cpp
+8
-0
ReqMessage.h
zmq_src/ReqMessage.h
+7
-0
ZMQMessage.cpp
zmq_src/ZMQMessage.cpp
+6
-0
ZMQMessage.h
zmq_src/ZMQMessage.h
+4
-2
No files found.
SGXWalletServer.cpp
View file @
fc88b9c4
...
...
@@ -1009,6 +1009,28 @@ Json::Value SGXWalletServer::getDecryptionShareImpl(const std::string& blsKeyNam
RETURN_SUCCESS
(
result
)
}
Json
::
Value
SGXWalletServer
::
registerKeyOwnerImpl
(
const
std
::
string
&
keyName
,
const
std
::
string
&
cert
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
try
{
if
(
!
checkName
(
keyName
,
"BLS_KEY"
)
&&
!
checkECDSAKeyName
(
keyName
))
{
throw
SGXException
(
INVALID_KEY_FORMAT
,
string
(
__FUNCTION__
)
+
":Invalid key format"
);
}
std
::
string
ownerKeyName
=
keyName
+
":OWNER"
;
if
(
!
LevelDB
::
getLevelDb
()
->
readString
(
ownerKeyName
)
)
{
spdlog
::
info
(
"Cert {} registers key {}"
,
cert
,
keyName
);
LevelDB
::
getLevelDb
()
->
writeString
(
ownerKeyName
,
cert
);
}
else
{
spdlog
::
error
(
"The key {} already registered"
,
keyName
);
throw
SGXException
(
KEY_ALREADY_REGISTERED
,
string
(
__FUNCTION__
)
+
":The key is already registered"
);
}
}
HANDLE_SGX_EXCEPTION
(
result
)
RETURN_SUCCESS
(
result
)
}
Json
::
Value
SGXWalletServer
::
generateDKGPoly
(
const
string
&
_polyName
,
int
_t
)
{
return
generateDKGPolyImpl
(
_polyName
,
_t
);
}
...
...
SGXWalletServer.hpp
View file @
fc88b9c4
...
...
@@ -175,6 +175,8 @@ public:
static
Json
::
Value
getDecryptionShareImpl
(
const
std
::
string
&
KeyName
,
const
std
::
string
&
publicDecryptionValue
);
static
Json
::
Value
registerKeyOwnerImpl
(
const
std
::
string
&
keyName
,
const
std
::
string
&
cert
);
static
void
printDB
();
static
void
initHttpServer
();
...
...
sgxwallet_common.h
View file @
fc88b9c4
...
...
@@ -185,6 +185,8 @@ extern bool autoconfirm;
#define CORRUPT_DATABASE -112
#define INVALID_SEK -113
#define INVALID_DECRYPTION_VALUE_FORMAT -114
#define INVALID_KEY_FORMAT -115
#define KEY_ALREADY_REGISTERED -116
#define SGX_ENCLAVE_ERROR -666
...
...
zmq_src/ReqMessage.cpp
View file @
fc88b9c4
...
...
@@ -261,3 +261,11 @@ Json::Value GetDecryptionShareReqMessage::process() {
result
[
"type"
]
=
ZMQMessage
::
GET_DECRYPTION_SHARE_RSP
;
return
result
;
}
Json
::
Value
RegisterKeyOwnerReqMessage
::
process
()
{
auto
keyName
=
getStringRapid
(
"keyName"
);
auto
cert
=
getStringRapid
(
"cert"
);
auto
result
=
SGXWalletServer
::
getDecryptionShareImpl
(
keyName
,
cert
);
result
[
"type"
]
=
ZMQMessage
::
REGISTER_KEY_OWNER_RSP
;
return
result
;
}
zmq_src/ReqMessage.h
View file @
fc88b9c4
...
...
@@ -185,4 +185,11 @@ public:
virtual
Json
::
Value
process
();
};
class
RegisterKeyOwnerReqMessage
:
public
ZMQMessage
{
public
:
RegisterKeyOwnerReqMessage
(
shared_ptr
<
rapidjson
::
Document
>&
_d
)
:
ZMQMessage
(
_d
)
{};
virtual
Json
::
Value
process
();
};
#endif //SGXWALLET_REQMESSAGE_H
zmq_src/ZMQMessage.cpp
View file @
fc88b9c4
...
...
@@ -230,6 +230,9 @@ shared_ptr <ZMQMessage> ZMQMessage::buildRequest(string &_type, shared_ptr <rapi
case
ENUM_GET_DECRYPTION_SHARE_REQ
:
ret
=
make_shared
<
GetDecryptionShareReqMessage
>
(
_d
);
break
;
case
ENUM_REGISTER_KEY_OWNER_REQ
:
ret
=
make_shared
<
RegisterKeyOwnerReqMessage
>
(
_d
);
break
;
default
:
break
;
}
...
...
@@ -314,6 +317,9 @@ shared_ptr <ZMQMessage> ZMQMessage::buildResponse(string &_type, shared_ptr <rap
case
ENUM_GET_DECRYPTION_SHARE_RSP
:
ret
=
make_shared
<
GetDecryptionShareRspMessage
>
(
_d
);
break
;
case
ENUM_REGISTER_KEY_OWNER_RSP
:
ret
=
make_shared
<
RegisterKeyOwnerRspMessage
>
(
_d
);
break
;
default
:
break
;
}
...
...
zmq_src/ZMQMessage.h
View file @
fc88b9c4
...
...
@@ -99,6 +99,8 @@ public:
static
constexpr
const
char
*
DELETE_BLS_KEY_RSP
=
"deleteBLSKeyRsp"
;
static
constexpr
const
char
*
GET_DECRYPTION_SHARE_REQ
=
"getDecryptionShareReq"
;
static
constexpr
const
char
*
GET_DECRYPTION_SHARE_RSP
=
"getDecryptionShareRsp"
;
static
constexpr
const
char
*
REGISTER_KEY_OWNER_REQ
=
"registerKeyOwnerReq"
;
static
constexpr
const
char
*
REGISTER_KEY_OWNER_RSP
=
"registerKeyOwnerRsp"
;
static
const
std
::
map
<
string
,
int
>
requests
;
static
const
std
::
map
<
string
,
int
>
responses
;
...
...
@@ -106,11 +108,11 @@ public:
enum
Requests
{
ENUM_BLS_SIGN_REQ
,
ENUM_ECDSA_SIGN_REQ
,
ENUM_IMPORT_BLS_REQ
,
ENUM_IMPORT_ECDSA_REQ
,
ENUM_GENERATE_ECDSA_REQ
,
ENUM_GET_PUBLIC_ECDSA_REQ
,
ENUM_GENERATE_DKG_POLY_REQ
,
ENUM_GET_VV_REQ
,
ENUM_GET_SECRET_SHARE_REQ
,
ENUM_DKG_VERIFY_REQ
,
ENUM_CREATE_BLS_PRIVATE_REQ
,
ENUM_GET_BLS_PUBLIC_REQ
,
ENUM_GET_ALL_BLS_PUBLIC_REQ
,
ENUM_COMPLAINT_RESPONSE_REQ
,
ENUM_MULT_G2_REQ
,
ENUM_IS_POLY_EXISTS_REQ
,
ENUM_GET_SERVER_STATUS_REQ
,
ENUM_GET_SERVER_VERSION_REQ
,
ENUM_DELETE_BLS_KEY_REQ
,
ENUM_GET_DECRYPTION_SHARE_REQ
};
ENUM_GET_SERVER_STATUS_REQ
,
ENUM_GET_SERVER_VERSION_REQ
,
ENUM_DELETE_BLS_KEY_REQ
,
ENUM_GET_DECRYPTION_SHARE_REQ
,
ENUM_REGISTER_KEY_OWNER_REQ
};
enum
Responses
{
ENUM_BLS_SIGN_RSP
,
ENUM_ECDSA_SIGN_RSP
,
ENUM_IMPORT_BLS_RSP
,
ENUM_IMPORT_ECDSA_RSP
,
ENUM_GENERATE_ECDSA_RSP
,
ENUM_GET_PUBLIC_ECDSA_RSP
,
ENUM_GENERATE_DKG_POLY_RSP
,
ENUM_GET_VV_RSP
,
ENUM_GET_SECRET_SHARE_RSP
,
ENUM_DKG_VERIFY_RSP
,
ENUM_CREATE_BLS_PRIVATE_RSP
,
ENUM_GET_BLS_PUBLIC_RSP
,
ENUM_GET_ALL_BLS_PUBLIC_RSP
,
ENUM_COMPLAINT_RESPONSE_RSP
,
ENUM_MULT_G2_RSP
,
ENUM_IS_POLY_EXISTS_RSP
,
ENUM_GET_SERVER_STATUS_RSP
,
ENUM_GET_SERVER_VERSION_RSP
,
ENUM_DELETE_BLS_KEY_RSP
,
ENUM_GET_DECRYPTION_SHARE_RSP
};
ENUM_GET_SERVER_STATUS_RSP
,
ENUM_GET_SERVER_VERSION_RSP
,
ENUM_DELETE_BLS_KEY_RSP
,
ENUM_GET_DECRYPTION_SHARE_RSP
,
ENUM_REGISTER_KEY_OWNER_RSP
};
explicit
ZMQMessage
(
shared_ptr
<
rapidjson
::
Document
>
&
_d
)
:
d
(
_d
)
{};
...
...
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