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
80a0bde9
Unverified
Commit
80a0bde9
authored
Jan 26, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2077 Fixed Naming
parent
7e252ab9
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
156 additions
and
157 deletions
+156
-157
DKGCrypto.cpp
DKGCrypto.cpp
+3
-3
DKGCrypto.h
DKGCrypto.h
+1
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+35
-35
SGXWalletServer.hpp
SGXWalletServer.hpp
+12
-13
abstractstubserver.h
abstractstubserver.h
+26
-26
spec.json
spec.json
+16
-16
stubclient.h
stubclient.h
+19
-19
testw.cpp
testw.cpp
+44
-44
No files found.
DKGCrypto.cpp
View file @
80a0bde9
...
@@ -270,7 +270,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
...
@@ -270,7 +270,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
return
result
;
return
result
;
}
}
bool
CreateBLSShare
(
const
string
&
BLS
KeyName
,
const
char
*
s_shares
,
const
char
*
encryptedKeyHex
){
bool
CreateBLSShare
(
const
string
&
bls
KeyName
,
const
char
*
s_shares
,
const
char
*
encryptedKeyHex
){
if
(
DEBUG_PRINT
)
{
if
(
DEBUG_PRINT
)
{
spdlog
::
info
(
"ENTER CreateBLSShare"
);
spdlog
::
info
(
"ENTER CreateBLSShare"
);
}
}
...
@@ -299,10 +299,10 @@ bool CreateBLSShare( const string& BLSKeyName, const char * s_shares, const char
...
@@ -299,10 +299,10 @@ bool CreateBLSShare( const string& BLSKeyName, const char * s_shares, const char
//cerr << "enc_bls_len " << enc_bls_len << endl;
//cerr << "enc_bls_len " << enc_bls_len << endl;
carray2Hex
(
encr_bls_key
,
enc_bls_len
,
hexBLSKey
);
carray2Hex
(
encr_bls_key
,
enc_bls_len
,
hexBLSKey
);
// cerr << "BEFORE WRITE BLS KEY TO DB" << endl;
// cerr << "BEFORE WRITE BLS KEY TO DB" << endl;
writeDataToDB
(
BLS
KeyName
,
hexBLSKey
);
writeDataToDB
(
bls
KeyName
,
hexBLSKey
);
if
(
DEBUG_PRINT
)
{
if
(
DEBUG_PRINT
)
{
spdlog
::
info
(
"hexBLSKey length is {}"
,
char_traits
<
char
>::
length
(
hexBLSKey
));
spdlog
::
info
(
"hexBLSKey length is {}"
,
char_traits
<
char
>::
length
(
hexBLSKey
));
spdlog
::
info
(
"bls key {}"
,
BLS
KeyName
,
" is "
,
hexBLSKey
);
spdlog
::
info
(
"bls key {}"
,
bls
KeyName
,
" is "
,
hexBLSKey
);
}
}
free
(
hexBLSKey
);
free
(
hexBLSKey
);
return
true
;
return
true
;
...
...
DKGCrypto.h
View file @
80a0bde9
...
@@ -39,7 +39,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
...
@@ -39,7 +39,7 @@ bool VerifyShares(const char* publicShares, const char* encr_sshare, const char
std
::
string
decrypt_DHKey
(
const
std
::
string
&
polyName
,
int
ind
);
std
::
string
decrypt_DHKey
(
const
std
::
string
&
polyName
,
int
ind
);
bool
CreateBLSShare
(
const
std
::
string
&
BLS
KeyName
,
const
char
*
s_shares
,
const
char
*
encryptedKeyHex
);
bool
CreateBLSShare
(
const
std
::
string
&
bls
KeyName
,
const
char
*
s_shares
,
const
char
*
encryptedKeyHex
);
std
::
vector
<
std
::
string
>
GetBLSPubKey
(
const
char
*
encryptedKeyHex
);
std
::
vector
<
std
::
string
>
GetBLSPubKey
(
const
char
*
encryptedKeyHex
);
...
...
SGXWalletServer.cpp
View file @
80a0bde9
...
@@ -274,8 +274,8 @@ Json::Value generateECDSAKeyImpl() {
...
@@ -274,8 +274,8 @@ Json::Value generateECDSAKeyImpl() {
writeDataToDB
(
keyName
,
keys
.
at
(
0
));
writeDataToDB
(
keyName
,
keys
.
at
(
0
));
result
[
"encryptedKey"
]
=
keys
.
at
(
0
);
result
[
"encryptedKey"
]
=
keys
.
at
(
0
);
result
[
"
P
ublicKey"
]
=
keys
.
at
(
1
);
result
[
"
p
ublicKey"
]
=
keys
.
at
(
1
);
result
[
"
K
eyName"
]
=
keyName
;
result
[
"
k
eyName"
]
=
keyName
;
}
catch
(
RPCException
&
_e
)
{
}
catch
(
RPCException
&
_e
)
{
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
...
@@ -388,7 +388,7 @@ Json::Value getPublicECDSAKeyImpl(const string& keyName){
...
@@ -388,7 +388,7 @@ Json::Value getPublicECDSAKeyImpl(const string& keyName){
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
result
[
"
P
ublicKey"
]
=
""
;
result
[
"
p
ublicKey"
]
=
""
;
spdlog
::
info
(
"Calling method getPublicECDSAKey"
);
spdlog
::
info
(
"Calling method getPublicECDSAKey"
);
...
@@ -404,7 +404,7 @@ Json::Value getPublicECDSAKeyImpl(const string& keyName){
...
@@ -404,7 +404,7 @@ Json::Value getPublicECDSAKeyImpl(const string& keyName){
spdlog
::
info
(
"PublicKey {}"
,
Pkey
);
spdlog
::
info
(
"PublicKey {}"
,
Pkey
);
spdlog
::
info
(
"PublicKey length {}"
,
Pkey
.
length
());
spdlog
::
info
(
"PublicKey length {}"
,
Pkey
.
length
());
}
}
result
[
"
P
ublicKey"
]
=
Pkey
;
result
[
"
p
ublicKey"
]
=
Pkey
;
}
catch
(
RPCException
&
_e
)
{
}
catch
(
RPCException
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"status"
]
=
_e
.
status
;
...
@@ -509,22 +509,22 @@ Json::Value getSecretShareImpl(const string& polyName, const Json::Value& public
...
@@ -509,22 +509,22 @@ Json::Value getSecretShareImpl(const string& polyName, const Json::Value& public
string
s
=
get_secret_shares
(
polyName
,
encr_poly_ptr
->
c_str
(),
pubKeys_vect
,
t
,
n
);
string
s
=
get_secret_shares
(
polyName
,
encr_poly_ptr
->
c_str
(),
pubKeys_vect
,
t
,
n
);
//cerr << "result is " << s << endl;
//cerr << "result is " << s << endl;
result
[
"
S
ecretShare"
]
=
s
;
result
[
"
s
ecretShare"
]
=
s
;
}
catch
(
RPCException
&
_e
)
{
}
catch
(
RPCException
&
_e
)
{
//cerr << " err str " << _e.errString << endl;
//cerr << " err str " << _e.errString << endl;
result
[
"status"
]
=
_e
.
status
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"
S
ecretShare"
]
=
""
;
result
[
"
s
ecretShare"
]
=
""
;
}
}
return
result
;
return
result
;
}
}
Json
::
Value
DKGVerificationImpl
(
const
string
&
publicShares
,
const
string
&
E
thKeyName
,
Json
::
Value
dkgVerificationImpl
(
const
string
&
publicShares
,
const
string
&
e
thKeyName
,
const
string
&
SecretShare
,
int
t
,
int
n
,
int
ind
){
const
string
&
SecretShare
,
int
t
,
int
n
,
int
ind
){
spdlog
::
info
(
"enter
DKG
VerificationImpl"
);
spdlog
::
info
(
"enter
dkg
VerificationImpl"
);
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
...
@@ -533,7 +533,7 @@ Json::Value DKGVerificationImpl(const string& publicShares, const string& EthKey
...
@@ -533,7 +533,7 @@ Json::Value DKGVerificationImpl(const string& publicShares, const string& EthKey
try
{
try
{
if
(
!
checkECDSAKeyName
(
E
thKeyName
)){
if
(
!
checkECDSAKeyName
(
e
thKeyName
)){
throw
RPCException
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
throw
RPCException
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
}
}
if
(
!
check_n_t
(
t
,
n
)
||
ind
>
n
||
ind
<
0
){
if
(
!
check_n_t
(
t
,
n
)
||
ind
>
n
||
ind
<
0
){
...
@@ -546,7 +546,7 @@ Json::Value DKGVerificationImpl(const string& publicShares, const string& EthKey
...
@@ -546,7 +546,7 @@ Json::Value DKGVerificationImpl(const string& publicShares, const string& EthKey
throw
RPCException
(
INVALID_DKG_PARAMS
,
"Invalid length of public shares"
);
throw
RPCException
(
INVALID_DKG_PARAMS
,
"Invalid length of public shares"
);
}
}
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
E
thKeyName
);
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
e
thKeyName
);
if
(
!
VerifyShares
(
publicShares
.
c_str
(),
SecretShare
.
c_str
(),
encryptedKeyHex_ptr
->
c_str
(),
t
,
n
,
ind
)){
if
(
!
VerifyShares
(
publicShares
.
c_str
(),
SecretShare
.
c_str
(),
encryptedKeyHex_ptr
->
c_str
(),
t
,
n
,
ind
)){
result
[
"result"
]
=
false
;
result
[
"result"
]
=
false
;
...
@@ -562,9 +562,9 @@ Json::Value DKGVerificationImpl(const string& publicShares, const string& EthKey
...
@@ -562,9 +562,9 @@ Json::Value DKGVerificationImpl(const string& publicShares, const string& EthKey
return
result
;
return
result
;
}
}
Json
::
Value
CreateBLSPrivateKeyImpl
(
const
string
&
BLSKeyName
,
const
string
&
E
thKeyName
,
const
string
&
polyName
,
const
string
&
SecretShare
,
int
t
,
int
n
){
Json
::
Value
createBLSPrivateKeyImpl
(
const
string
&
blsKeyName
,
const
string
&
e
thKeyName
,
const
string
&
polyName
,
const
string
&
SecretShare
,
int
t
,
int
n
){
spdlog
::
info
(
"
C
reateBLSPrivateKeyImpl entered"
);
spdlog
::
info
(
"
c
reateBLSPrivateKeyImpl entered"
);
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
...
@@ -577,13 +577,13 @@ Json::Value CreateBLSPrivateKeyImpl(const string & BLSKeyName, const string& Eth
...
@@ -577,13 +577,13 @@ Json::Value CreateBLSPrivateKeyImpl(const string & BLSKeyName, const string& Eth
spdlog
::
info
(
"secret shares - {}"
,
SecretShare
);
spdlog
::
info
(
"secret shares - {}"
,
SecretShare
);
throw
RPCException
(
INVALID_SECRET_SHARES_LENGTH
,
"Invalid secret share length"
);
throw
RPCException
(
INVALID_SECRET_SHARES_LENGTH
,
"Invalid secret share length"
);
}
}
if
(
!
checkECDSAKeyName
(
E
thKeyName
)){
if
(
!
checkECDSAKeyName
(
e
thKeyName
)){
throw
RPCException
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
throw
RPCException
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
}
}
if
(
!
checkName
(
polyName
,
"POLY"
)){
if
(
!
checkName
(
polyName
,
"POLY"
)){
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
}
if
(
!
checkName
(
BLS
KeyName
,
"BLS_KEY"
)){
if
(
!
checkName
(
bls
KeyName
,
"BLS_KEY"
)){
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid BLS key name"
);
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid BLS key name"
);
}
}
if
(
!
check_n_t
(
t
,
n
)){
if
(
!
check_n_t
(
t
,
n
)){
...
@@ -594,9 +594,9 @@ Json::Value CreateBLSPrivateKeyImpl(const string & BLSKeyName, const string& Eth
...
@@ -594,9 +594,9 @@ Json::Value CreateBLSPrivateKeyImpl(const string & BLSKeyName, const string& Eth
spdlog
::
info
(
"secret shares from json are - {}"
,
SecretShare
);
spdlog
::
info
(
"secret shares from json are - {}"
,
SecretShare
);
}
}
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
E
thKeyName
);
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
e
thKeyName
);
bool
res
=
CreateBLSShare
(
BLS
KeyName
,
SecretShare
.
c_str
(),
encryptedKeyHex_ptr
->
c_str
());
bool
res
=
CreateBLSShare
(
bls
KeyName
,
SecretShare
.
c_str
(),
encryptedKeyHex_ptr
->
c_str
());
if
(
res
){
if
(
res
){
spdlog
::
info
(
"BLS KEY SHARE CREATED "
);
spdlog
::
info
(
"BLS KEY SHARE CREATED "
);
}
}
...
@@ -621,17 +621,17 @@ Json::Value CreateBLSPrivateKeyImpl(const string & BLSKeyName, const string& Eth
...
@@ -621,17 +621,17 @@ Json::Value CreateBLSPrivateKeyImpl(const string & BLSKeyName, const string& Eth
return
result
;
return
result
;
}
}
Json
::
Value
GetBLSPublicKeyShareImpl
(
const
string
&
BLS
KeyName
){
Json
::
Value
getBLSPublicKeyShareImpl
(
const
string
&
bls
KeyName
){
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
try
{
try
{
if
(
!
checkName
(
BLS
KeyName
,
"BLS_KEY"
)){
if
(
!
checkName
(
bls
KeyName
,
"BLS_KEY"
)){
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid BLSKey name"
);
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid BLSKey name"
);
}
}
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
BLS
KeyName
);
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
bls
KeyName
);
if
(
DEBUG_PRINT
)
{
if
(
DEBUG_PRINT
)
{
spdlog
::
info
(
"encr_bls_key_share is {}"
,
*
encryptedKeyHex_ptr
);
spdlog
::
info
(
"encr_bls_key_share is {}"
,
*
encryptedKeyHex_ptr
);
spdlog
::
info
(
"length is {}"
,
encryptedKeyHex_ptr
->
length
());
spdlog
::
info
(
"length is {}"
,
encryptedKeyHex_ptr
->
length
());
...
@@ -654,7 +654,7 @@ Json::Value GetBLSPublicKeyShareImpl(const string & BLSKeyName){
...
@@ -654,7 +654,7 @@ Json::Value GetBLSPublicKeyShareImpl(const string & BLSKeyName){
return
result
;
return
result
;
}
}
Json
::
Value
C
omplaintResponseImpl
(
const
string
&
polyName
,
int
ind
){
Json
::
Value
c
omplaintResponseImpl
(
const
string
&
polyName
,
int
ind
){
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
...
@@ -680,12 +680,12 @@ Json::Value ComplaintResponseImpl(const string& polyName, int ind){
...
@@ -680,12 +680,12 @@ Json::Value ComplaintResponseImpl(const string& polyName, int ind){
}
}
Json
::
Value
M
ultG2Impl
(
const
string
&
x
){
Json
::
Value
m
ultG2Impl
(
const
string
&
x
){
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
try
{
try
{
spdlog
::
info
(
"
M
ultG2Impl try "
);
spdlog
::
info
(
"
m
ultG2Impl try "
);
vector
<
string
>
xG2_vect
=
mult_G2
(
x
);
vector
<
string
>
xG2_vect
=
mult_G2
(
x
);
for
(
uint8_t
i
=
0
;
i
<
4
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
4
;
i
++
)
{
result
[
"x*G2"
][
i
]
=
xG2_vect
.
at
(
i
);
result
[
"x*G2"
][
i
]
=
xG2_vect
.
at
(
i
);
...
@@ -700,7 +700,7 @@ Json::Value MultG2Impl(const string& x){
...
@@ -700,7 +700,7 @@ Json::Value MultG2Impl(const string& x){
return
result
;
return
result
;
}
}
Json
::
Value
I
sPolyExistsImpl
(
const
string
&
polyName
){
Json
::
Value
i
sPolyExistsImpl
(
const
string
&
polyName
){
Json
::
Value
result
;
Json
::
Value
result
;
shared_ptr
<
string
>
poly_str_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
polyName
);
shared_ptr
<
string
>
poly_str_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
polyName
);
...
@@ -738,19 +738,19 @@ Json::Value SGXWalletServer::getSecretShare(const string& polyName, const Json::
...
@@ -738,19 +738,19 @@ Json::Value SGXWalletServer::getSecretShare(const string& polyName, const Json::
return
getSecretShareImpl
(
polyName
,
publicKeys
,
t
,
n
);
return
getSecretShareImpl
(
polyName
,
publicKeys
,
t
,
n
);
}
}
Json
::
Value
SGXWalletServer
::
DKGVerification
(
const
string
&
publicShares
,
const
string
&
E
thKeyName
,
const
string
&
SecretShare
,
int
t
,
int
n
,
int
index
){
Json
::
Value
SGXWalletServer
::
dkgVerification
(
const
string
&
publicShares
,
const
string
&
e
thKeyName
,
const
string
&
SecretShare
,
int
t
,
int
n
,
int
index
){
lock_guard
<
recursive_mutex
>
lock
(
m
);
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
DKGVerificationImpl
(
publicShares
,
E
thKeyName
,
SecretShare
,
t
,
n
,
index
);
return
dkgVerificationImpl
(
publicShares
,
e
thKeyName
,
SecretShare
,
t
,
n
,
index
);
}
}
Json
::
Value
SGXWalletServer
::
CreateBLSPrivateKey
(
const
string
&
BLSKeyName
,
const
string
&
E
thKeyName
,
const
string
&
polyName
,
const
string
&
SecretShare
,
int
t
,
int
n
){
Json
::
Value
SGXWalletServer
::
createBLSPrivateKey
(
const
string
&
blsKeyName
,
const
string
&
e
thKeyName
,
const
string
&
polyName
,
const
string
&
SecretShare
,
int
t
,
int
n
){
lock_guard
<
recursive_mutex
>
lock
(
m
);
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
CreateBLSPrivateKeyImpl
(
BLSKeyName
,
E
thKeyName
,
polyName
,
SecretShare
,
t
,
n
);
return
createBLSPrivateKeyImpl
(
blsKeyName
,
e
thKeyName
,
polyName
,
SecretShare
,
t
,
n
);
}
}
Json
::
Value
SGXWalletServer
::
GetBLSPublicKeyShare
(
const
string
&
BLS
KeyName
){
Json
::
Value
SGXWalletServer
::
getBLSPublicKeyShare
(
const
string
&
bls
KeyName
){
lock_guard
<
recursive_mutex
>
lock
(
m
);
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
GetBLSPublicKeyShareImpl
(
BLS
KeyName
);
return
getBLSPublicKeyShareImpl
(
bls
KeyName
);
}
}
...
@@ -799,19 +799,19 @@ Json::Value SGXWalletServer::importECDSAKey(const string &key, const string &key
...
@@ -799,19 +799,19 @@ Json::Value SGXWalletServer::importECDSAKey(const string &key, const string &key
return
importECDSAKeyImpl
(
key
,
keyName
);
return
importECDSAKeyImpl
(
key
,
keyName
);
}
}
Json
::
Value
SGXWalletServer
::
C
omplaintResponse
(
const
string
&
polyName
,
int
ind
){
Json
::
Value
SGXWalletServer
::
c
omplaintResponse
(
const
string
&
polyName
,
int
ind
){
lock_guard
<
recursive_mutex
>
lock
(
m
);
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
C
omplaintResponseImpl
(
polyName
,
ind
);
return
c
omplaintResponseImpl
(
polyName
,
ind
);
}
}
Json
::
Value
SGXWalletServer
::
M
ultG2
(
const
string
&
x
){
Json
::
Value
SGXWalletServer
::
m
ultG2
(
const
string
&
x
){
lock_guard
<
recursive_mutex
>
lock
(
m
);
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
M
ultG2Impl
(
x
);
return
m
ultG2Impl
(
x
);
}
}
Json
::
Value
SGXWalletServer
::
I
sPolyExists
(
const
string
&
polyName
){
Json
::
Value
SGXWalletServer
::
i
sPolyExists
(
const
string
&
polyName
){
lock_guard
<
recursive_mutex
>
lock
(
m
);
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
I
sPolyExistsImpl
(
polyName
);
return
i
sPolyExistsImpl
(
polyName
);
}
}
Json
::
Value
SGXWalletServer
::
getServerStatus
()
{
Json
::
Value
SGXWalletServer
::
getServerStatus
()
{
...
...
SGXWalletServer.hpp
View file @
80a0bde9
...
@@ -56,13 +56,12 @@ public:
...
@@ -56,13 +56,12 @@ public:
virtual
Json
::
Value
generateDKGPoly
(
const
std
::
string
&
polyName
,
int
t
);
virtual
Json
::
Value
generateDKGPoly
(
const
std
::
string
&
polyName
,
int
t
);
virtual
Json
::
Value
getVerificationVector
(
const
std
::
string
&
polyName
,
int
t
,
int
n
);
virtual
Json
::
Value
getVerificationVector
(
const
std
::
string
&
polyName
,
int
t
,
int
n
);
virtual
Json
::
Value
getSecretShare
(
const
std
::
string
&
polyName
,
const
Json
::
Value
&
publicKeys
,
int
t
,
int
n
);
virtual
Json
::
Value
getSecretShare
(
const
std
::
string
&
polyName
,
const
Json
::
Value
&
publicKeys
,
int
t
,
int
n
);
virtual
Json
::
Value
DKGVerification
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
EthKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
);
virtual
Json
::
Value
dkgVerification
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
);
virtual
Json
::
Value
CreateBLSPrivateKey
(
const
std
::
string
&
BLSKeyName
,
const
std
::
string
&
EthKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
virtual
Json
::
Value
createBLSPrivateKey
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
ethKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
virtual
Json
::
Value
GetBLSPublicKeyShare
(
const
std
::
string
&
BLSKeyName
);
virtual
Json
::
Value
getBLSPublicKeyShare
(
const
std
::
string
&
blsKeyName
);
virtual
Json
::
Value
ComplaintResponse
(
const
std
::
string
&
polyName
,
int
ind
);
virtual
Json
::
Value
complaintResponse
(
const
std
::
string
&
polyName
,
int
ind
);
virtual
Json
::
Value
MultG2
(
const
std
::
string
&
x
);
virtual
Json
::
Value
multG2
(
const
std
::
string
&
x
);
virtual
Json
::
Value
IsPolyExists
(
const
std
::
string
&
polyName
);
virtual
Json
::
Value
isPolyExists
(
const
std
::
string
&
polyName
);
virtual
Json
::
Value
getServerStatus
();
virtual
Json
::
Value
getServerStatus
();
};
};
...
@@ -85,12 +84,12 @@ Json::Value getPublicECDSAKeyImpl(const std::string& keyName);
...
@@ -85,12 +84,12 @@ Json::Value getPublicECDSAKeyImpl(const std::string& keyName);
Json
::
Value
generateDKGPolyImpl
(
const
std
::
string
&
polyName
,
int
t
);
Json
::
Value
generateDKGPolyImpl
(
const
std
::
string
&
polyName
,
int
t
);
Json
::
Value
getVerificationVectorImpl
(
const
std
::
string
&
polyName
,
int
t
,
int
n
);
Json
::
Value
getVerificationVectorImpl
(
const
std
::
string
&
polyName
,
int
t
,
int
n
);
Json
::
Value
getSecretShareImpl
(
const
std
::
string
&
polyName
,
const
Json
::
Value
&
publicKeys
,
int
t
,
int
n
);
Json
::
Value
getSecretShareImpl
(
const
std
::
string
&
polyName
,
const
Json
::
Value
&
publicKeys
,
int
t
,
int
n
);
Json
::
Value
DKGVerificationImpl
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
E
thKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
);
Json
::
Value
dkgVerificationImpl
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
e
thKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
);
Json
::
Value
CreateBLSPrivateKeyImpl
(
const
std
::
string
&
BLSKeyName
,
const
std
::
string
&
E
thKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
Json
::
Value
createBLSPrivateKeyImpl
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
e
thKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
Json
::
Value
GetBLSPublicKeyShareImpl
(
const
std
::
string
&
BLS
KeyName
);
Json
::
Value
getBLSPublicKeyShareImpl
(
const
std
::
string
&
bls
KeyName
);
Json
::
Value
C
omplaintResponseImpl
(
const
std
::
string
&
polyName
,
int
ind
);
Json
::
Value
c
omplaintResponseImpl
(
const
std
::
string
&
polyName
,
int
ind
);
Json
::
Value
M
ultG2Impl
(
const
std
::
string
&
x
);
Json
::
Value
m
ultG2Impl
(
const
std
::
string
&
x
);
Json
::
Value
I
sPolyExistsImpl
(
const
std
::
string
&
polyName
);
Json
::
Value
i
sPolyExistsImpl
(
const
std
::
string
&
polyName
);
Json
::
Value
getServerStatusImpl
();
Json
::
Value
getServerStatusImpl
();
...
...
abstractstubserver.h
View file @
80a0bde9
This diff is collapsed.
Click to expand it.
spec.json
View file @
80a0bde9
...
@@ -50,8 +50,8 @@
...
@@ -50,8 +50,8 @@
"status"
:
0
,
"status"
:
0
,
"errorMessage"
:
"12345"
,
"errorMessage"
:
"12345"
,
"encryptedKey"
:
"12345"
,
"encryptedKey"
:
"12345"
,
"
K
eyName"
:
"tmp:123"
,
"
k
eyName"
:
"tmp:123"
,
"
P
ublicKey"
:
"12345"
"
p
ublicKey"
:
"12345"
}
}
},
},
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
"name"
:
"renameECDSAKey"
,
"name"
:
"renameECDSAKey"
,
"params"
:
{
"params"
:
{
"tempKeyName"
:
"key1"
,
"tempKeyName"
:
"key1"
,
"
K
eyName"
:
"key2"
"
k
eyName"
:
"key2"
},
},
"returns"
:
{
"returns"
:
{
"status"
:
0
,
"status"
:
0
,
...
@@ -75,7 +75,7 @@
...
@@ -75,7 +75,7 @@
"returns"
:
{
"returns"
:
{
"status"
:
0
,
"status"
:
0
,
"errorMessage"
:
"12345"
,
"errorMessage"
:
"12345"
,
"
P
ublicKey"
:
"12345"
"
p
ublicKey"
:
"12345"
}
}
},
},
...
@@ -132,15 +132,15 @@
...
@@ -132,15 +132,15 @@
"returns"
:
{
"returns"
:
{
"status"
:
0
,
"status"
:
0
,
"errorMessage"
:
"12345"
,
"errorMessage"
:
"12345"
,
"
S
ecretShare"
:
"123"
"
s
ecretShare"
:
"123"
}
}
},
},
{
{
"name"
:
"
DKG
Verification"
,
"name"
:
"
dkg
Verification"
,
"params"
:
{
"params"
:
{
"publicShares"
:
"123"
,
"publicShares"
:
"123"
,
"
E
thKeyName"
:
"NEK:hex"
,
"
e
thKeyName"
:
"NEK:hex"
,
"
S
ecretShare"
:
"f_ij"
,
"
s
ecretShare"
:
"f_ij"
,
"n"
:
3
,
"n"
:
3
,
"t"
:
3
,
"t"
:
3
,
"index"
:
2
"index"
:
2
...
@@ -152,26 +152,26 @@
...
@@ -152,26 +152,26 @@
}
}
},
},
{
{
"name"
:
"
C
reateBLSPrivateKey"
,
"name"
:
"
c
reateBLSPrivateKey"
,
"params"
:
{
"params"
:
{
"
BLS
KeyName"
:
"BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID: "
,
"
bls
KeyName"
:
"BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID: "
,
"
E
thKeyName"
:
"NEK:hex"
,
"
e
thKeyName"
:
"NEK:hex"
,
"polyName"
:
"POLY:SCHAIN_ID :NODE_ID :DKG_ID: "
,
"polyName"
:
"POLY:SCHAIN_ID :NODE_ID :DKG_ID: "
,
"
S
ecretShare"
:
"122"
,
"
s
ecretShare"
:
"122"
,
"n"
:
3
,
"n"
:
3
,
"t"
:
3
"t"
:
3
},
},
"returns"
:
{
"returns"
:
{
"status"
:
0
,
"status"
:
0
,
"errorMessage"
:
"12345"
,
"errorMessage"
:
"12345"
,
"
BLS
KeyName"
:
"key"
"
bls
KeyName"
:
"key"
}
}
},
},
{
{
"name"
:
"
G
etBLSPublicKeyShare"
,
"name"
:
"
g
etBLSPublicKeyShare"
,
"params"
:
{
"params"
:
{
"
BLS
KeyName"
:
"BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID"
"
bls
KeyName"
:
"BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID"
},
},
"returns"
:
{
"returns"
:
{
"status"
:
0
,
"status"
:
0
,
...
@@ -181,7 +181,7 @@
...
@@ -181,7 +181,7 @@
},
},
{
{
"name"
:
"
C
omplaintResponse"
,
"name"
:
"
c
omplaintResponse"
,
"params"
:
{
"params"
:
{
"polyName"
:
"p1"
,
"polyName"
:
"p1"
,
"n"
:
3
,
"n"
:
3
,
...
...
stubclient.h
View file @
80a0bde9
...
@@ -68,7 +68,7 @@ class StubClient : public jsonrpc::Client
...
@@ -68,7 +68,7 @@ class StubClient : public jsonrpc::Client
Json
::
Value
renameECDSAKey
(
const
std
::
string
&
KeyName
,
const
std
::
string
&
tempKeyName
)
throw
(
jsonrpc
::
JsonRpcException
)
Json
::
Value
renameECDSAKey
(
const
std
::
string
&
KeyName
,
const
std
::
string
&
tempKeyName
)
throw
(
jsonrpc
::
JsonRpcException
)
{
{
Json
::
Value
p
;
Json
::
Value
p
;
p
[
"
K
eyName"
]
=
KeyName
;
p
[
"
k
eyName"
]
=
KeyName
;
p
[
"tempKeyName"
]
=
tempKeyName
;
p
[
"tempKeyName"
]
=
tempKeyName
;
Json
::
Value
result
=
this
->
CallMethod
(
"renameECDSAKey"
,
p
);
Json
::
Value
result
=
this
->
CallMethod
(
"renameECDSAKey"
,
p
);
if
(
result
.
isObject
())
if
(
result
.
isObject
())
...
@@ -140,80 +140,80 @@ class StubClient : public jsonrpc::Client
...
@@ -140,80 +140,80 @@ class StubClient : public jsonrpc::Client
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
}
Json
::
Value
DKGVerification
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
E
thKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
)
throw
(
jsonrpc
::
JsonRpcException
)
Json
::
Value
dkgVerification
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
e
thKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
)
throw
(
jsonrpc
::
JsonRpcException
)
{
{
Json
::
Value
p
;
Json
::
Value
p
;
p
[
"
EthKeyName"
]
=
E
thKeyName
;
p
[
"
ethKeyName"
]
=
e
thKeyName
;
p
[
"
S
ecretShare"
]
=
SecretShare
;
p
[
"
s
ecretShare"
]
=
SecretShare
;
p
[
"index"
]
=
index
;
p
[
"index"
]
=
index
;
p
[
"n"
]
=
n
;
p
[
"n"
]
=
n
;
p
[
"publicShares"
]
=
publicShares
;
p
[
"publicShares"
]
=
publicShares
;
p
[
"t"
]
=
t
;
p
[
"t"
]
=
t
;
Json
::
Value
result
=
this
->
CallMethod
(
"
DKG
Verification"
,
p
);
Json
::
Value
result
=
this
->
CallMethod
(
"
dkg
Verification"
,
p
);
if
(
result
.
isObject
())
if
(
result
.
isObject
())
return
result
;
return
result
;
else
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
}
Json
::
Value
CreateBLSPrivateKey
(
const
std
::
string
&
BLSKeyName
,
const
std
::
string
&
E
thKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
)
throw
(
jsonrpc
::
JsonRpcException
)
Json
::
Value
createBLSPrivateKey
(
const
std
::
string
&
blsKeyName
,
const
std
::
string
&
e
thKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
)
throw
(
jsonrpc
::
JsonRpcException
)
{
{
Json
::
Value
p
;
Json
::
Value
p
;
p
[
"
BLSKeyName"
]
=
BLS
KeyName
;
p
[
"
blsKeyName"
]
=
bls
KeyName
;
p
[
"
EthKeyName"
]
=
E
thKeyName
;
p
[
"
ethKeyName"
]
=
e
thKeyName
;
p
[
"polyName"
]
=
polyName
;
p
[
"polyName"
]
=
polyName
;
p
[
"
S
ecretShare"
]
=
SecretShare
;
p
[
"
s
ecretShare"
]
=
SecretShare
;
p
[
"n"
]
=
n
;
p
[
"n"
]
=
n
;
p
[
"t"
]
=
t
;
p
[
"t"
]
=
t
;
Json
::
Value
result
=
this
->
CallMethod
(
"
C
reateBLSPrivateKey"
,
p
);
Json
::
Value
result
=
this
->
CallMethod
(
"reateBLSPrivateKey"
,
p
);
if
(
result
.
isObject
())
if
(
result
.
isObject
())
return
result
;
return
result
;
else
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
}
Json
::
Value
GetBLSPublicKeyShare
(
const
std
::
string
&
BLS
KeyName
)
throw
(
jsonrpc
::
JsonRpcException
)
Json
::
Value
getBLSPublicKeyShare
(
const
std
::
string
&
bls
KeyName
)
throw
(
jsonrpc
::
JsonRpcException
)
{
{
Json
::
Value
p
;
Json
::
Value
p
;
p
[
"
BLSKeyName"
]
=
BLS
KeyName
;
p
[
"
blsKeyName"
]
=
bls
KeyName
;
Json
::
Value
result
=
this
->
CallMethod
(
"
G
etBLSPublicKeyShare"
,
p
);
Json
::
Value
result
=
this
->
CallMethod
(
"
g
etBLSPublicKeyShare"
,
p
);
if
(
result
.
isObject
())
if
(
result
.
isObject
())
return
result
;
return
result
;
else
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
}
Json
::
Value
C
omplaintResponse
(
const
std
::
string
&
polyName
,
int
ind
)
throw
(
jsonrpc
::
JsonRpcException
)
Json
::
Value
c
omplaintResponse
(
const
std
::
string
&
polyName
,
int
ind
)
throw
(
jsonrpc
::
JsonRpcException
)
{
{
Json
::
Value
p
;
Json
::
Value
p
;
p
[
"polyName"
]
=
polyName
;
p
[
"polyName"
]
=
polyName
;
p
[
"ind"
]
=
ind
;
p
[
"ind"
]
=
ind
;
Json
::
Value
result
=
this
->
CallMethod
(
"
C
omplaintResponse"
,
p
);
Json
::
Value
result
=
this
->
CallMethod
(
"
c
omplaintResponse"
,
p
);
if
(
result
.
isObject
())
if
(
result
.
isObject
())
return
result
;
return
result
;
else
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
}
Json
::
Value
M
ultG2
(
const
std
::
string
&
x
)
throw
(
jsonrpc
::
JsonRpcException
)
Json
::
Value
m
ultG2
(
const
std
::
string
&
x
)
throw
(
jsonrpc
::
JsonRpcException
)
{
{
Json
::
Value
p
;
Json
::
Value
p
;
p
[
"x"
]
=
x
;
p
[
"x"
]
=
x
;
Json
::
Value
result
=
this
->
CallMethod
(
"
M
ultG2"
,
p
);
Json
::
Value
result
=
this
->
CallMethod
(
"
m
ultG2"
,
p
);
if
(
result
.
isObject
())
if
(
result
.
isObject
())
return
result
;
return
result
;
else
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
}
Json
::
Value
I
sPolyExists
(
const
std
::
string
&
polyName
)
throw
(
jsonrpc
::
JsonRpcException
)
Json
::
Value
i
sPolyExists
(
const
std
::
string
&
polyName
)
throw
(
jsonrpc
::
JsonRpcException
)
{
{
Json
::
Value
p
;
Json
::
Value
p
;
p
[
"polyName"
]
=
polyName
;
p
[
"polyName"
]
=
polyName
;
Json
::
Value
result
=
this
->
CallMethod
(
"
I
sPolyExists"
,
p
);
Json
::
Value
result
=
this
->
CallMethod
(
"
i
sPolyExists"
,
p
);
if
(
result
.
isObject
())
if
(
result
.
isObject
())
return
result
;
return
result
;
else
else
...
...
testw.cpp
View file @
80a0bde9
This diff is collapsed.
Click to expand it.
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