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
fb0f498a
Unverified
Commit
fb0f498a
authored
Sep 10, 2019
by
kladkogex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing server
parent
1c8b7056
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
18 deletions
+34
-18
LevelDB.cpp
LevelDB.cpp
+1
-1
LevelDB.h
LevelDB.h
+2
-2
SGXWalletServer.cpp
SGXWalletServer.cpp
+28
-15
sgxwallet_common.h
sgxwallet_common.h
+3
-0
No files found.
LevelDB.cpp
View file @
fb0f498a
...
...
@@ -41,7 +41,7 @@ static ReadOptions readOptions;
LevelDB
*
levelDb
=
nullptr
;
std
::
shared_ptr
<
std
::
string
>
LevelDB
::
readString
(
std
::
string
&
_key
)
{
std
::
shared_ptr
<
std
::
string
>
LevelDB
::
readString
(
const
std
::
string
&
_key
)
{
auto
result
=
std
::
make_shared
<
std
::
string
>
();
...
...
LevelDB.h
View file @
fb0f498a
...
...
@@ -38,10 +38,10 @@ class LevelDB {
leveldb
::
DB
*
db
;
p
rotected
:
p
ublic
:
std
::
shared_ptr
<
std
::
string
>
readString
(
std
::
string
&
_key
);
std
::
shared_ptr
<
std
::
string
>
readString
(
const
std
::
string
&
_key
);
void
writeString
(
const
std
::
string
&
key1
,
const
std
::
string
&
value1
);
...
...
SGXWalletServer.cpp
View file @
fb0f498a
...
...
@@ -18,6 +18,8 @@
#include <stdio.h>
#include "sgxwallet_common.h"
#include "RPCException.h"
#include "LevelDB.h"
#include "SGXWalletServer.h"
...
...
@@ -50,13 +52,13 @@ public:
void
checkKeyShareDoesExist
(
const
string
&
_keyShar
e
);
void
writeKeyShare
(
const
string
&
_keyShare
,
const
string
&
valu
e
);
void
checkKeyShareDoesNotExist
(
const
string
&
_keyShare
);
shared_ptr
<
std
::
string
>
readKeyShare
(
const
string
&
_keyShare
);
void
checkECDSAKeyDoesExist
(
const
string
&
_keyShar
e
);
void
writeECDSAKey
(
const
string
&
_key
,
const
string
&
valu
e
);
void
checkECDSAKeyDoesNotExist
(
const
string
&
_keyShare
);
shared_ptr
<
std
::
string
>
readECDSAKey
(
const
string
&
_key
);
...
...
@@ -111,7 +113,7 @@ int init_server() {
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
)
{
Json
::
Value
result
;
...
...
@@ -122,7 +124,7 @@ Json::Value SGXWalletServer::importBLSKeyShare(int index, const std::string& ke
try
{
checkKeyShareDoesNotExist
(
keyShare
);
writeKeyShare
(
_keyShareName
,
_
keyShare
);
}
catch
(
RPCException
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -139,7 +141,7 @@ Json::Value SGXWalletServer::blsSignMessageHash(const std::string& keyShareName,
try
{
checkKeyShareDoesExist
(
keyShareName
);
readKeyShare
(
keyShareName
);
}
catch
(
RPCException
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -166,13 +168,13 @@ Json::Value SGXWalletServer::generateECDSAKey(const std::string& _keyName) {
result
[
"encryptedKey"
]
=
""
;
try
{
checkECDSAKeyDoesNotExist
(
_keyName
);
writeECDSAKey
(
_keyName
,
""
);
}
catch
(
RPCException
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
}
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHash
(
const
std
::
string
&
_key
Share
Name
,
const
std
::
string
&
messageHash
)
{
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHash
(
const
std
::
string
&
_keyName
,
const
std
::
string
&
messageHash
)
{
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
...
...
@@ -180,7 +182,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHash(const std::string& _keyShareN
try
{
checkECDSAKeyDoesExist
(
_keyShare
Name
);
readECDSAKey
(
_key
Name
);
}
catch
(
RPCException
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
...
...
@@ -192,19 +194,30 @@ Json::Value SGXWalletServer::ecdsaSignMessageHash(const std::string& _keyShareN
void
SGXWalletServer
::
checkKeyShareDoesExist
(
const
string
&
_keyShar
e
)
{
shared_ptr
<
string
>
SGXWalletServer
::
readKeyShare
(
const
string
&
_keyShareNam
e
)
{
auto
keyShareStr
=
levelDb
->
readString
(
"BLSKEYSHARE:"
+
_keyShareName
);
}
if
(
keyShareStr
==
nullptr
)
{
string
error
(
"Key share with this name does not exists"
);
throw
new
RPCException
(
KEY_SHARE_DOES_NOT_EXIST
,
error
);
}
void
SGXWalletServer
::
checkKeyShareDoesNotExist
(
const
string
&
_keyShare
)
{
return
keyShareStr
;
}
void
SGXWalletServer
::
checkECDSAKeyDoesExist
(
const
string
&
_keyShare
)
{
void
SGXWalletServer
::
writeKeyShare
(
const
string
&
_keyShareName
,
const
string
&
value
)
{
if
(
levelDb
->
readString
(
"BLSKEYSHARE:"
+
_keyShareName
)
!=
nullptr
)
{
string
error
(
"Key share with this name already exists"
);
throw
new
RPCException
(
KEY_SHARE_DOES_NOT_EXIST
,
error
);
}
}
shared_ptr
<
std
::
string
>
SGXWalletServer
::
readECDSAKey
(
const
string
&
_keyShare
)
{
}
void
SGXWalletServer
::
checkECDSAKeyDoesNotExist
(
const
string
&
_keyShar
e
)
{
void
SGXWalletServer
::
writeECDSAKey
(
const
string
&
_keyShare
,
const
string
&
valu
e
)
{
}
\ No newline at end of file
sgxwallet_common.h
View file @
fb0f498a
...
...
@@ -34,6 +34,9 @@
#define INCORRECT_STRING_CONVERSION -5
#define ENCRYPTED_KEY_TOO_LONG -6
#define SEAL_KEY_FAILED -7
#define KEY_SHARE_DOES_NOT_EXIST -7
#define KEY_SHARE_ALREADY_EXISTS -8
...
...
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