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
2c08c11b
Unverified
Commit
2c08c11b
authored
Jan 24, 2020
by
svetaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-1887 Add method IsPolyExists to SGXWalletServer
parent
964dac2b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
76 additions
and
55 deletions
+76
-55
ECDSACrypto.cpp
ECDSACrypto.cpp
+2
-9
SGXWalletServer.cpp
SGXWalletServer.cpp
+17
-0
SGXWalletServer.hpp
SGXWalletServer.hpp
+4
-0
abstractstubserver.h
abstractstubserver.h
+10
-0
secure_enclave.c
secure_enclave/secure_enclave.c
+0
-2
stubclient.cpp
stubclient.cpp
+0
-44
stubclient.h
stubclient.h
+12
-0
testw.cpp
testw.cpp
+31
-0
No files found.
ECDSACrypto.cpp
View file @
2c08c11b
...
...
@@ -62,8 +62,8 @@ std::vector<std::string> gen_ecdsa_key(){
std
::
cerr
<<
"account key is "
<<
errMsg
<<
std
::
endl
;
std
::
cerr
<<
"enc_len is "
<<
enc_len
<<
std
::
endl
;
std
::
cerr
<<
"enc_key is "
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
1024
;
i
++
)
std
::
cerr
<<
(
int
)
encr_pr_key
[
i
]
<<
" "
;
//
for(int i = 0 ; i < 1024; i++)
//
std::cerr << (int)encr_pr_key[i] << " " ;
}
char
*
hexEncrKey
=
(
char
*
)
calloc
(
BUF_LEN
,
1
);
carray2Hex
(
encr_pr_key
,
enc_len
,
hexEncrKey
);
...
...
@@ -119,13 +119,6 @@ std::string get_ecdsa_pubkey(const char* encryptedKeyHex){
throw
RPCException
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
}
spdlog
::
info
(
"encr_hex_key is {}"
,
encryptedKeyHex
);
std
::
cerr
<<
"enc_key is "
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
BUF_LEN
;
i
++
)
std
::
cerr
<<
(
int
)
encr_pr_key
[
i
]
<<
" "
;
//status = get_public_ecdsa_key(eid, &err_status, errMsg, encr_pr_key, enc_len, pub_key_x, pub_key_y );
status
=
get_public_ecdsa_key_aes
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
enc_len
,
pub_key_x
,
pub_key_y
);
if
(
err_status
!=
0
){
...
...
SGXWalletServer.cpp
View file @
2c08c11b
...
...
@@ -704,6 +704,18 @@ Json::Value MultG2Impl(const std::string& x){
return
result
;
}
Json
::
Value
IsPolyExistsImpl
(
const
std
::
string
&
polyName
){
Json
::
Value
result
;
std
::
shared_ptr
<
std
::
string
>
poly_str_ptr
=
levelDb
->
readString
(
polyName
);
result
[
"IsExist"
]
=
true
;
if
(
poly_str_ptr
==
nullptr
){
result
[
"IsExist"
]
=
false
;
}
return
result
;
}
Json
::
Value
getServerStatusImpl
()
{
Json
::
Value
result
;
...
...
@@ -801,6 +813,11 @@ Json::Value SGXWalletServer::MultG2(const std::string& x){
return
MultG2Impl
(
x
);
}
Json
::
Value
SGXWalletServer
::
IsPolyExists
(
const
std
::
string
&
polyName
){
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
IsPolyExistsImpl
(
polyName
);
}
Json
::
Value
SGXWalletServer
::
getServerStatus
()
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
getServerStatusImpl
();
...
...
SGXWalletServer.hpp
View file @
2c08c11b
...
...
@@ -61,6 +61,8 @@ public:
virtual
Json
::
Value
GetBLSPublicKeyShare
(
const
std
::
string
&
BLSKeyName
);
virtual
Json
::
Value
ComplaintResponse
(
const
std
::
string
&
polyName
,
int
ind
);
virtual
Json
::
Value
MultG2
(
const
std
::
string
&
x
);
virtual
Json
::
Value
IsPolyExists
(
const
std
::
string
&
polyName
);
virtual
Json
::
Value
getServerStatus
();
};
...
...
@@ -88,6 +90,8 @@ Json::Value CreateBLSPrivateKeyImpl(const std::string & BLSKeyName, const std::s
Json
::
Value
GetBLSPublicKeyShareImpl
(
const
std
::
string
&
BLSKeyName
);
Json
::
Value
ComplaintResponseImpl
(
const
std
::
string
&
polyName
,
int
ind
);
Json
::
Value
MultG2Impl
(
const
std
::
string
&
x
);
Json
::
Value
IsPolyExistsImpl
(
const
std
::
string
&
polyName
);
Json
::
Value
getServerStatusImpl
();
#endif //SGXWALLET_SGXWALLETSERVER_HPP
\ No newline at end of file
abstractstubserver.h
View file @
2c08c11b
...
...
@@ -29,6 +29,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"GetBLSPublicKeyShare"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"BLSKeyName"
,
jsonrpc
::
JSON_STRING
,
NULL
),
&
AbstractStubServer
::
GetBLSPublicKeyShareI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"ComplaintResponse"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"polyName"
,
jsonrpc
::
JSON_STRING
,
"ind"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
ComplaintResponseI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"MultG2"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"x"
,
jsonrpc
::
JSON_STRING
,
NULL
),
&
AbstractStubServer
::
MultG2I
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"IsPolyExists"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"polyName"
,
jsonrpc
::
JSON_STRING
,
NULL
),
&
AbstractStubServer
::
IsPolyExistsI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"getServerStatus"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
NULL
),
&
AbstractStubServer
::
getServerStatusI
);
}
...
...
@@ -41,6 +42,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
{
response
=
this
->
blsSignMessageHash
(
request
[
"keyShareName"
].
asString
(),
request
[
"messageHash"
].
asString
(),
request
[
"t"
].
asInt
(),
request
[
"n"
].
asInt
(),
request
[
"signerIndex"
].
asInt
());
}
inline
virtual
void
importECDSAKeyI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
response
=
this
->
importECDSAKey
(
request
[
"key"
].
asString
(),
request
[
"keyName"
].
asString
());
...
...
@@ -62,6 +64,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
{
response
=
this
->
ecdsaSignMessageHash
(
request
[
"base"
].
asInt
(),
request
[
"keyName"
].
asString
(),
request
[
"messageHash"
].
asString
());
}
inline
virtual
void
generateDKGPolyI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
response
=
this
->
generateDKGPoly
(
request
[
"polyName"
].
asString
(),
request
[
"t"
].
asInt
());
...
...
@@ -94,6 +97,12 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
{
response
=
this
->
MultG2
(
request
[
"x"
].
asString
());
}
inline
virtual
void
IsPolyExistsI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
response
=
this
->
IsPolyExists
(
request
[
"polyName"
].
asString
());
}
inline
virtual
void
getServerStatusI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
(
void
)
request
;
...
...
@@ -116,6 +125,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
virtual
Json
::
Value
GetBLSPublicKeyShare
(
const
std
::
string
&
BLSKeyName
)
=
0
;
virtual
Json
::
Value
ComplaintResponse
(
const
std
::
string
&
polyName
,
int
ind
)
=
0
;
virtual
Json
::
Value
MultG2
(
const
std
::
string
&
x
)
=
0
;
virtual
Json
::
Value
IsPolyExists
(
const
std
::
string
&
polyName
)
=
0
;
virtual
Json
::
Value
getServerStatus
()
=
0
;
};
...
...
secure_enclave/secure_enclave.c
View file @
2c08c11b
...
...
@@ -1281,5 +1281,3 @@ void bls_sign_message_aes(int *err_status, char *err_string, uint8_t *encrypted_
}
stubclient.cpp
deleted
100644 → 0
View file @
964dac2b
/*
Copyright (C) 2019-Present SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file stubclient.cpp
@author Stan Kladko
@date 2019
*/
#include <iostream>
#include "stubclient.h"
#include <jsonrpccpp/client/connectors/httpclient.h>
using
namespace
jsonrpc
;
using
namespace
std
;
int
init_client
()
{
HttpClient
client
(
"http://localhost:1025"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
Json
::
Value
params
;
try
{
cout
<<
c
.
generateECDSAKey
()
<<
endl
;
}
catch
(
JsonRpcException
&
e
)
{
cerr
<<
e
.
what
()
<<
endl
;
}
return
0
;
}
stubclient.h
View file @
2c08c11b
...
...
@@ -208,6 +208,18 @@ class StubClient : public jsonrpc::Client
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
Json
::
Value
IsPolyExists
(
const
std
::
string
&
polyName
)
throw
(
jsonrpc
::
JsonRpcException
)
{
Json
::
Value
p
;
p
[
"polyName"
]
=
polyName
;
Json
::
Value
result
=
this
->
CallMethod
(
"IsPolyExists"
,
p
);
if
(
result
.
isObject
())
return
result
;
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
////CSRManagerServer
...
...
testw.cpp
View file @
2c08c11b
...
...
@@ -1190,3 +1190,34 @@ TEST_CASE("dkg API test", "[dkg_api_test]") {
sgx_destroy_enclave
(
eid
);
}
TEST_CASE
(
"IsPolyExists test"
,
"[is_poly_test]"
)
{
DEBUG_PRINT
=
1
;
is_sgx_https
=
0
;
cerr
<<
"is_poly_test started"
<<
endl
;
init_all
(
false
,
false
);
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
cerr
<<
"Client inited"
<<
endl
;
reset_db
();
std
::
string
polyName
=
"POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1"
;
Json
::
Value
genPoly
=
c
.
generateDKGPoly
(
polyName
,
2
);
cout
<<
genPoly
<<
std
::
endl
;
Json
::
Value
polyExists
=
c
.
IsPolyExists
(
polyName
);
cout
<<
polyExists
<<
std
::
endl
;
REQUIRE
(
polyExists
[
"IsExist"
].
asBool
());
Json
::
Value
polyDoesNotExist
=
c
.
IsPolyExists
(
"Vasya"
);
cout
<<
polyDoesNotExist
<<
std
::
endl
;
REQUIRE
(
!
polyDoesNotExist
[
"IsExist"
].
asBool
());
}
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