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
bd4f9c28
Unverified
Commit
bd4f9c28
authored
Sep 10, 2019
by
kladkogex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes
parent
0e2db9b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
7 deletions
+26
-7
RPCException.h
RPCException.h
+1
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+25
-6
No files found.
RPCException.h
View file @
bd4f9c28
...
@@ -16,7 +16,7 @@ public:
...
@@ -16,7 +16,7 @@ public:
int32_t
status
;
int32_t
status
;
std
::
string
errString
;
std
::
string
errString
;
RPCException
(
int32_t
_status
,
std
::
string
&
_errString
)
:
status
(
_status
),
errString
(
_errString
)
{}
RPCException
(
int32_t
_status
,
const
char
*
_errString
)
:
status
(
_status
),
errString
(
_errString
)
{}
};
};
...
...
SGXWalletServer.cpp
View file @
bd4f9c28
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "RPCException.h"
#include "RPCException.h"
#include "LevelDB.h"
#include "LevelDB.h"
#include "BLSCrypto.h"
#include "SGXWalletServer.h"
#include "SGXWalletServer.h"
#include "SGXWalletServer.hpp"
#include "SGXWalletServer.hpp"
...
@@ -83,6 +84,9 @@ int init_server() {
...
@@ -83,6 +84,9 @@ int init_server() {
Json
::
Value
importBLSKeyShareImpl
(
int
index
,
const
std
::
string
&
_keyShare
,
const
std
::
string
&
_keyShareName
,
int
n
,
int
t
)
{
Json
::
Value
importBLSKeyShareImpl
(
int
index
,
const
std
::
string
&
_keyShare
,
const
std
::
string
&
_keyShareName
,
int
n
,
int
t
)
{
Json
::
Value
result
;
Json
::
Value
result
;
int
errStatus
=
UNKNOWN_ERROR
;
char
*
errMsg
=
(
char
*
)
calloc
(
BUF_LEN
,
1
);
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
...
@@ -90,8 +94,22 @@ Json::Value importBLSKeyShareImpl(int index, const std::string& _keyShare, cons
...
@@ -90,8 +94,22 @@ Json::Value importBLSKeyShareImpl(int index, const std::string& _keyShare, cons
result
[
"encryptedKeyShare"
]
=
""
;
result
[
"encryptedKeyShare"
]
=
""
;
try
{
try
{
writeKeyShare
(
_keyShareName
,
_keyShare
);
char
*
encryptedKeyShareHex
=
encryptBLSKeyShare2Hex
(
&
errStatus
,
errMsg
,
_keyShare
.
c_str
());
if
(
encryptedKeyShareHex
==
nullptr
)
{
throw
RPCException
(
UNKNOWN_ERROR
,
""
);
}
if
(
errStatus
!=
0
)
{
throw
RPCException
(
errStatus
,
errMsg
);
}
writeKeyShare
(
_keyShareName
,
encryptedKeyShareHex
);
}
catch
(
RPCException
&
_e
)
{
}
catch
(
RPCException
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
@@ -144,6 +162,8 @@ Json::Value generateECDSAKeyImpl(const std::string& _keyName) {
...
@@ -144,6 +162,8 @@ Json::Value generateECDSAKeyImpl(const std::string& _keyName) {
result
[
"status"
]
=
_e
.
status
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
}
return
result
;
}
}
...
@@ -171,7 +191,7 @@ Json::Value SGXWalletServer::generateECDSAKey(const std::string& _keyName) {
...
@@ -171,7 +191,7 @@ Json::Value SGXWalletServer::generateECDSAKey(const std::string& _keyName) {
}
}
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHash
(
const
std
::
string
&
_keyName
,
const
std
::
string
&
messageHash
)
{
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHash
(
const
std
::
string
&
_keyName
,
const
std
::
string
&
messageHash
)
{
ecdsaSignMessageHashImpl
(
_keyName
,
messageHash
);
return
ecdsaSignMessageHashImpl
(
_keyName
,
messageHash
);
}
}
Json
::
Value
SGXWalletServer
::
importBLSKeyShare
(
int
index
,
const
std
::
string
&
_keyShare
,
const
std
::
string
&
_keyShareName
,
int
n
,
int
t
)
{
Json
::
Value
SGXWalletServer
::
importBLSKeyShare
(
int
index
,
const
std
::
string
&
_keyShare
,
const
std
::
string
&
_keyShareName
,
int
n
,
int
t
)
{
...
@@ -195,8 +215,7 @@ shared_ptr<string> readKeyShare(const string& _keyShareName) {
...
@@ -195,8 +215,7 @@ shared_ptr<string> readKeyShare(const string& _keyShareName) {
auto
keyShareStr
=
levelDb
->
readString
(
"BLSKEYSHARE:"
+
_keyShareName
);
auto
keyShareStr
=
levelDb
->
readString
(
"BLSKEYSHARE:"
+
_keyShareName
);
if
(
keyShareStr
==
nullptr
)
{
if
(
keyShareStr
==
nullptr
)
{
string
error
(
"Key share with this name does not exists"
);
throw
new
RPCException
(
KEY_SHARE_DOES_NOT_EXIST
,
"Key share with this name does not exists"
);
throw
new
RPCException
(
KEY_SHARE_DOES_NOT_EXIST
,
error
);
}
}
return
keyShareStr
;
return
keyShareStr
;
...
@@ -208,14 +227,14 @@ void writeKeyShare(const string& _keyShareName, const string& value) {
...
@@ -208,14 +227,14 @@ void writeKeyShare(const string& _keyShareName, const string& value) {
auto
key
=
"BLSKEYSHARE:"
+
_keyShareName
;
auto
key
=
"BLSKEYSHARE:"
+
_keyShareName
;
if
(
levelDb
->
readString
(
_keyShareName
)
!=
nullptr
)
{
if
(
levelDb
->
readString
(
_keyShareName
)
!=
nullptr
)
{
string
error
(
"Key share with this name already exists"
);
throw
new
RPCException
(
KEY_SHARE_DOES_NOT_EXIST
,
"Key share with this name already exists"
);
throw
new
RPCException
(
KEY_SHARE_DOES_NOT_EXIST
,
error
);
}
}
levelDb
->
writeString
(
key
,
value
);
levelDb
->
writeString
(
key
,
value
);
}
}
shared_ptr
<
std
::
string
>
readECDSAKey
(
const
string
&
_keyShare
)
{
shared_ptr
<
std
::
string
>
readECDSAKey
(
const
string
&
_keyShare
)
{
return
nullptr
;
}
}
...
...
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