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
c5084a4b
Unverified
Commit
c5084a4b
authored
Aug 13, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3067-cleanup-sgx
parent
1897419d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
42 deletions
+20
-42
SGXWalletServer.cpp
SGXWalletServer.cpp
+20
-42
No files found.
SGXWalletServer.cpp
View file @
c5084a4b
...
...
@@ -166,19 +166,15 @@ int SGXWalletServer::initHttpServer() { //without ssl
Json
::
Value
SGXWalletServer
::
importBLSKeyShareImpl
(
const
string
&
_keyShare
,
const
string
&
_keyShareName
,
int
t
,
int
n
,
int
_index
)
{
Json
::
Value
result
;
int
errStatus
=
UNKNOWN_ERROR
;
string
errMsg
(
BUF_LEN
,
'\0'
);
INIT_RESULT
(
result
);
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"encryptedKeyShare"
]
=
""
;
string
encryptedKeyShareHex
;
try
{
encryptedKeyShareHex
=
encryptBLSKeyShare2Hex
(
&
errStatus
,
&
errMsg
.
front
(),
_keyShare
.
c_str
());
encryptedKeyShareHex
=
encryptBLSKeyShare2Hex
(
&
errStatus
,
(
char
*
)
errMsg
.
data
(),
_keyShare
.
c_str
());
if
(
errStatus
!=
0
)
{
throw
SGXException
(
errStatus
,
errMsg
.
data
());
...
...
@@ -196,18 +192,20 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
result
[
"errorMessage"
]
=
_e
.
errString
;
}
return
result
;
RETURN_SUCCESS
(
result
)
;
}
Json
::
Value
SGXWalletServer
::
blsSignMessageHashImpl
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
t
,
int
n
,
int
_signerIndex
)
{
Json
::
Value
result
;
INIT_RESULT
(
result
)
result
[
"status"
]
=
-
1
;
result
[
"errorMessage"
]
=
"Unknown server error"
;
result
[
"signatureShare"
]
=
""
;
string
signature
(
BUF_LEN
,
'\0'
);
vector
<
char
>
signature
(
BUF_LEN
,
0
);
shared_ptr
<
string
>
value
=
nullptr
;
...
...
@@ -228,49 +226,29 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
}
value
=
readFromDb
(
_keyShareName
);
}
catch
(
SGXException
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
return
result
;
}
catch
(...)
{
exception_ptr
p
=
current_exception
();
printf
(
"Exception %s
\n
"
,
p
.
__cxa_exception_type
()
->
name
());
result
[
"status"
]
=
-
1
;
result
[
"errorMessage"
]
=
"Read key share has thrown exception:"
;
return
result
;
}
try
{
if
(
!
bls_sign
(
value
->
c_str
(),
_messageHash
.
c_str
(),
t
,
n
,
_signerIndex
,
&
signature
.
front
()))
{
if
(
!
bls_sign
(
value
->
c_str
(),
_messageHash
.
c_str
(),
t
,
n
,
_signerIndex
,
signature
.
data
()))
{
result
[
"status"
]
=
-
1
;
result
[
"errorMessage"
]
=
"Could not sign"
;
return
result
;
}
}
catch
(...)
{
result
[
"status"
]
=
-
1
;
result
[
"errorMessage"
]
=
"Sign has thrown exception"
;
return
result
;
}
}
HANDLE_SGX_EXCEPTION
(
result
)
result
[
"signatureShare"
]
=
string
(
signature
.
data
());
RETURN_SUCCESS
(
result
);
auto
it
=
std
::
find
(
signature
.
begin
(),
signature
.
end
(),
'\0'
);
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"signatureShare"
]
=
std
::
string
(
signature
.
begin
(),
it
);
return
result
;
}
Json
::
Value
SGXWalletServer
::
importECDSAKeyImpl
(
const
string
&
_key
,
const
string
&
_keyName
)
{
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
INIT_RESULT
(
result
)
result
[
"encryptedKey"
]
=
""
;
RETURN_SUCCESS
(
result
)
return
result
;
}
Json
::
Value
SGXWalletServer
::
generateECDSAKeyImpl
()
{
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
INIT_RESULT
(
result
)
result
[
"encryptedKey"
]
=
""
;
vector
<
string
>
keys
;
...
...
@@ -295,7 +273,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
result
[
"keyName"
]
=
keyName
;
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
;
}
Json
::
Value
SGXWalletServer
::
renameECDSAKeyImpl
(
const
string
&
_keyName
,
const
string
&
_tempKeyName
)
{
...
...
@@ -322,7 +300,7 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
LevelDB
::
getLevelDb
()
->
deleteTempNEK
(
_tempKeyName
);
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
;
}
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHashImpl
(
int
_base
,
const
string
&
_keyName
,
const
string
&
_messageHash
)
{
...
...
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