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
97dc071c
Unverified
Commit
97dc071c
authored
Sep 24, 2019
by
svetaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add signing to api
parent
d6943929
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
14 deletions
+13
-14
ECDSACrypto.cpp
ECDSACrypto.cpp
+7
-4
ECDSACrypto.h
ECDSACrypto.h
+1
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+2
-3
spec.json
spec.json
+1
-1
testw.cpp
testw.cpp
+2
-5
No files found.
ECDSACrypto.cpp
View file @
97dc071c
...
@@ -15,7 +15,7 @@ std::vector<std::string> gen_ecdsa_key(){
...
@@ -15,7 +15,7 @@ std::vector<std::string> gen_ecdsa_key(){
char
*
pub_key_y
=
(
char
*
)
calloc
(
1024
,
1
);
char
*
pub_key_y
=
(
char
*
)
calloc
(
1024
,
1
);
uint32_t
enc_len
=
0
;
uint32_t
enc_len
=
0
;
status
=
generate_ecdsa_key
(
eid
,
&
err_status
,
errMsg
,
(
uint8_t
*
)
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
status
=
generate_ecdsa_key
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
std
::
vector
<
std
::
string
>
keys
(
2
);
std
::
vector
<
std
::
string
>
keys
(
2
);
char
*
hexEncrKey
=
(
char
*
)
calloc
(
2
*
BUF_LEN
,
1
);
char
*
hexEncrKey
=
(
char
*
)
calloc
(
2
*
BUF_LEN
,
1
);
...
@@ -26,7 +26,7 @@ std::vector<std::string> gen_ecdsa_key(){
...
@@ -26,7 +26,7 @@ std::vector<std::string> gen_ecdsa_key(){
return
keys
;
return
keys
;
}
}
std
::
vector
<
std
::
string
>
ecdsa_sign_hash
(
const
char
*
encryptedKey
,
const
char
*
hashHex
){
std
::
vector
<
std
::
string
>
ecdsa_sign_hash
(
const
char
*
encryptedKey
Hex
,
const
char
*
hashHex
){
std
::
vector
<
std
::
string
>
signature_vect
(
3
);
std
::
vector
<
std
::
string
>
signature_vect
(
3
);
char
*
errMsg
=
(
char
*
)
calloc
(
1024
,
1
);
char
*
errMsg
=
(
char
*
)
calloc
(
1024
,
1
);
...
@@ -34,9 +34,12 @@ std::vector<std::string> ecdsa_sign_hash(const char* encryptedKey, const char* h
...
@@ -34,9 +34,12 @@ std::vector<std::string> ecdsa_sign_hash(const char* encryptedKey, const char* h
char
*
signature_r
=
(
char
*
)
malloc
(
1024
);
char
*
signature_r
=
(
char
*
)
malloc
(
1024
);
char
*
signature_s
=
(
char
*
)
malloc
(
1024
);
char
*
signature_s
=
(
char
*
)
malloc
(
1024
);
char
*
signature_v
=
(
char
*
)
calloc
(
4
,
1
);
char
*
signature_v
=
(
char
*
)
calloc
(
4
,
1
);
uint
32
_t
dec_len
=
0
;
uint
64
_t
dec_len
=
0
;
status
=
ecdsa_sign1
(
eid
,
&
err_status
,
errMsg
,
(
uint8_t
*
)
encryptedKey
,
dec_len
,
(
unsigned
char
*
)
hashHex
,
signature_r
,
signature_s
,
signature_v
);
uint8_t
encr_key
[
BUF_LEN
];
hex2carray
(
encryptedKeyHex
,
&
dec_len
,
encr_key
);
status
=
ecdsa_sign1
(
eid
,
&
err_status
,
errMsg
,
encr_key
,
dec_len
,
(
unsigned
char
*
)
hashHex
,
signature_r
,
signature_s
,
signature_v
);
signature_vect
.
at
(
0
)
=
signature_v
;
signature_vect
.
at
(
0
)
=
signature_v
;
signature_vect
.
at
(
1
)
=
"0x"
+
std
::
string
(
signature_r
);
signature_vect
.
at
(
1
)
=
"0x"
+
std
::
string
(
signature_r
);
...
...
ECDSACrypto.h
View file @
97dc071c
...
@@ -18,6 +18,6 @@
...
@@ -18,6 +18,6 @@
std
::
vector
<
std
::
string
>
gen_ecdsa_key
();
std
::
vector
<
std
::
string
>
gen_ecdsa_key
();
std
::
vector
<
std
::
string
>
ecdsa_sign_hash
(
const
char
*
encryptedKey
,
const
char
*
hashHex
);
std
::
vector
<
std
::
string
>
ecdsa_sign_hash
(
const
char
*
encryptedKey
Hex
,
const
char
*
hashHex
);
#endif //SGXD_ECDSACRYPTO_H
#endif //SGXD_ECDSACRYPTO_H
SGXWalletServer.cpp
View file @
97dc071c
...
@@ -186,8 +186,7 @@ Json::Value ecdsaSignMessageHashImpl(const std::string &_keyName, const std::str
...
@@ -186,8 +186,7 @@ Json::Value ecdsaSignMessageHashImpl(const std::string &_keyName, const std::str
result
[
"signature_r"
]
=
""
;
result
[
"signature_r"
]
=
""
;
result
[
"signature_s"
]
=
""
;
result
[
"signature_s"
]
=
""
;
std
::
vector
<
std
::
string
>
sign_vect
;
std
::
vector
<
std
::
string
>
sign_vect
(
3
);
try
{
try
{
std
::
shared_ptr
<
std
::
string
>
key_ptr
=
readECDSAKey
(
_keyName
);
std
::
shared_ptr
<
std
::
string
>
key_ptr
=
readECDSAKey
(
_keyName
);
...
@@ -263,7 +262,7 @@ void writeKeyShare(const string &_keyShareName, const string &value, int index,
...
@@ -263,7 +262,7 @@ void writeKeyShare(const string &_keyShareName, const string &value, int index,
}
}
shared_ptr
<
std
::
string
>
readECDSAKey
(
const
string
&
_keyName
)
{
shared_ptr
<
std
::
string
>
readECDSAKey
(
const
string
&
_keyName
)
{
auto
keyStr
=
levelDb
->
readString
(
"ECDSAKEY:
:
"
+
_keyName
);
auto
keyStr
=
levelDb
->
readString
(
"ECDSAKEY:"
+
_keyName
);
if
(
keyStr
==
nullptr
)
{
if
(
keyStr
==
nullptr
)
{
throw
RPCException
(
KEY_SHARE_DOES_NOT_EXIST
,
"Key share with this name does not exists"
);
throw
RPCException
(
KEY_SHARE_DOES_NOT_EXIST
,
"Key share with this name does not exists"
);
...
...
spec.json
View file @
97dc071c
...
@@ -61,7 +61,7 @@
...
@@ -61,7 +61,7 @@
{
{
"name"
:
"ecdsaSignMessageHash"
,
"name"
:
"ecdsaSignMessageHash"
,
"params"
:
{
"params"
:
{
"key
Share
Name"
:
"key1"
,
"keyName"
:
"key1"
,
"messageHash"
:
"1122334455"
"messageHash"
:
"1122334455"
},
},
"returns"
:
{
"returns"
:
{
...
...
testw.cpp
View file @
97dc071c
...
@@ -427,15 +427,12 @@ TEST_CASE("API test", "[api_test]") {
...
@@ -427,15 +427,12 @@ TEST_CASE("API test", "[api_test]") {
cerr
<<
"Client inited"
<<
endl
;
cerr
<<
"Client inited"
<<
endl
;
try
{
try
{
cout
<<
c
.
generateECDSAKey
(
"test_key1"
)
<<
endl
;
//cout << c.generateECDSAKey("test_key") << endl;
cout
<<
c
.
ecdsaSignMessageHash
(
"test_key"
,
"38433e5ce087dcc1be82fcc834eae83c256b3db87d34f84440d0b708daa0c6f7"
);
}
catch
(
JsonRpcException
&
e
)
{
}
catch
(
JsonRpcException
&
e
)
{
cerr
<<
e
.
what
()
<<
endl
;
cerr
<<
e
.
what
()
<<
endl
;
}
}
/* shared_ptr <std::string> key_ptr = readECDSAKey("test_key");
if (key_ptr == nullptr) cerr<< " key is null" << endl;
else cerr << "key is " << *key_ptr << endl;*/
}
}
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