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
a0f4a55d
Unverified
Commit
a0f4a55d
authored
5 years ago
by
svetaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-1795 Add more exceptions to SGX server
parent
1b12bcfd
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
343 additions
and
146 deletions
+343
-146
DKGCrypto.cpp
DKGCrypto.cpp
+18
-30
DKGCrypto.h
DKGCrypto.h
+1
-1
Makefile.am
Makefile.am
+2
-2
SGXWalletServer.cpp
SGXWalletServer.cpp
+105
-77
SGXWalletServer.hpp
SGXWalletServer.hpp
+2
-8
ServerDataChecker.cpp
ServerDataChecker.cpp
+166
-2
ServerDataChecker.h
ServerDataChecker.h
+12
-0
abstractstubserver.h
abstractstubserver.h
+3
-3
DKGUtils.cpp
secure_enclave/DKGUtils.cpp
+4
-0
secure_enclave.c
secure_enclave/secure_enclave.c
+2
-0
sgxwallet_common.h
sgxwallet_common.h
+11
-1
spec.json
spec.json
+5
-5
stubclient.h
stubclient.h
+1
-3
testw.cpp
testw.cpp
+11
-14
No files found.
DKGCrypto.cpp
View file @
a0f4a55d
...
@@ -89,6 +89,9 @@ std::vector <std::vector<std::string>> get_verif_vect(const char* encryptedPolyH
...
@@ -89,6 +89,9 @@ std::vector <std::vector<std::string>> get_verif_vect(const char* encryptedPolyH
uint32_t
len
;
uint32_t
len
;
status
=
get_public_shares
(
eid
,
&
err_status
,
errMsg1
,
encr_dkg_poly
,
len
,
public_shares
,
t
,
n
);
status
=
get_public_shares
(
eid
,
&
err_status
,
errMsg1
,
encr_dkg_poly
,
len
,
public_shares
,
t
,
n
);
if
(
status
!=
0
){
}
std
::
cerr
<<
"err msg "
<<
errMsg1
<<
std
::
endl
;
std
::
cerr
<<
"err msg "
<<
errMsg1
<<
std
::
endl
;
std
::
cerr
<<
"public_shares:"
<<
std
::
endl
;
std
::
cerr
<<
"public_shares:"
<<
std
::
endl
;
...
@@ -140,14 +143,20 @@ std::string get_secret_shares(const std::string& polyName, const char* encrypted
...
@@ -140,14 +143,20 @@ std::string get_secret_shares(const std::string& polyName, const char* encrypted
result
+=
cur_share
;
result
+=
cur_share
;
uint32_t
enc_len
=
BUF_LEN
;
//uint32_t enc_len = BUF_LEN;
carray2Hex
(
encrypted_skey
,
enc_len
,
hexEncrKey
);
std
::
cerr
<<
"dec len is "
<<
dec_len
<<
std
::
endl
;
carray2Hex
(
encrypted_skey
,
dec_len
,
hexEncrKey
);
std
::
string
name
=
"DKG_DH_KEY_"
+
polyName
+
"_"
+
std
::
to_string
(
i
)
+
":"
;
std
::
string
DHKey_
name
=
"DKG_DH_KEY_"
+
polyName
+
"_"
+
std
::
to_string
(
i
)
+
":"
;
std
::
cerr
<<
"name to write to db is "
<<
name
<<
std
::
endl
;
std
::
cerr
<<
"name to write to db is "
<<
DHKey_
name
<<
std
::
endl
;
std
::
cerr
<<
"hexEncrKey: "
<<
hexEncrKey
<<
std
::
endl
;
std
::
cerr
<<
"hexEncrKey: "
<<
hexEncrKey
<<
std
::
endl
;
// writeDataToDB(name, hexEncrKey);
writeDataToDB
(
DHKey_name
,
hexEncrKey
);
std
::
string
shareG2_name
=
"shareG2_"
+
polyName
+
"_"
+
std
::
to_string
(
i
)
+
":"
;
std
::
cerr
<<
"name to write to db is "
<<
shareG2_name
<<
std
::
endl
;
std
::
cerr
<<
"s_shareG2: "
<<
s_shareG2
<<
std
::
endl
;
writeDataToDB
(
shareG2_name
,
s_shareG2
);
std
::
cerr
<<
errMsg1
<<
std
::
endl
<<
std
::
endl
;
std
::
cerr
<<
errMsg1
<<
std
::
endl
<<
std
::
endl
;
//std::cerr << "iteration " << i <<" result length is " << result.length() << std::endl ;
//std::cerr << "iteration " << i <<" result length is " << result.length() << std::endl ;
...
@@ -246,18 +255,11 @@ std::vector<std::string> GetBLSPubKey(const char * encryptedKeyHex){
...
@@ -246,18 +255,11 @@ std::vector<std::string> GetBLSPubKey(const char * encryptedKeyHex){
return
pub_key_vect
;
return
pub_key_vect
;
}
}
std
::
pair
<
std
::
string
,
std
::
string
>
response_to_complaint
(
const
std
::
string
&
polyName
,
const
char
*
encryptedPolyHex
,
int
n
,
int
t
,
int
ind
){
std
::
string
decrypt_DHKey
(
const
std
::
string
&
polyName
,
int
ind
){
char
*
errMsg1
=
(
char
*
)
calloc
(
1024
,
1
);
char
*
errMsg1
=
(
char
*
)
calloc
(
1024
,
1
);
int
err_status
=
0
;
int
err_status
=
0
;
uint64_t
enc_len
=
0
;
uint8_t
*
encr_dkg_poly
=
(
uint8_t
*
)
calloc
(
DKG_MAX_SEALED_LEN
,
1
);
hex2carray2
(
encryptedPolyHex
,
&
enc_len
,
encr_dkg_poly
,
6100
);
std
::
string
DH_key_name
=
polyName
+
"_"
+
std
::
to_string
(
ind
)
+
":"
;
std
::
string
DH_key_name
=
polyName
+
"_"
+
std
::
to_string
(
ind
)
+
":"
;
std
::
shared_ptr
<
std
::
string
>
hexEncrKey_ptr
=
readFromDb
(
DH_key_name
,
"DKG_DH_KEY_"
);
std
::
shared_ptr
<
std
::
string
>
hexEncrKey_ptr
=
readFromDb
(
DH_key_name
,
"DKG_DH_KEY_"
);
std
::
cerr
<<
"encr DH key is "
<<
hexEncrKey_ptr
<<
std
::
endl
;
std
::
cerr
<<
"encr DH key is "
<<
hexEncrKey_ptr
<<
std
::
endl
;
...
@@ -268,28 +270,14 @@ std::pair<std::string, std::string> response_to_complaint(const std::string& pol
...
@@ -268,28 +270,14 @@ std::pair<std::string, std::string> response_to_complaint(const std::string& pol
uint8_t
encrypted_DHkey
[
BUF_LEN
];
uint8_t
encrypted_DHkey
[
BUF_LEN
];
hex2carray
(
hexEncrKey_ptr
->
c_str
(),
&
DH_enc_len
,
encrypted_DHkey
);
hex2carray
(
hexEncrKey_ptr
->
c_str
(),
&
DH_enc_len
,
encrypted_DHkey
);
char
DHKey
[
ECDSA_SKEY_LEN
];
uint32_t
dec_len
;
decrypt_key
(
eid
,
&
err_status
,
errMsg1
,
encrypted_DHkey
,
DH_enc_len
,
DHKey
);
char
decrpyted_DHkey
[
ECDSA_SKEY_LEN
];
char
s_shareG2
[
320
];
//[257];
status
=
complaint_response
(
eid
,
&
err_status
,
errMsg1
,
encrypted_DHkey
,
encr_dkg_poly
,
&
dec_len
,
decrpyted_DHkey
,
s_shareG2
,
t
,
n
,
ind
);
std
::
pair
<
std
::
string
,
std
::
string
>
result
;
result
.
first
=
decrpyted_DHkey
;
result
.
second
=
s_shareG2
;
std
::
cerr
<<
errMsg1
<<
std
::
endl
<<
std
::
endl
;
//std::cerr << "iteration " << i <<" result length is " << result.length() << std::endl ;
//std::cerr << "iteration " << i <<" share length is " << strlen(cur_share) << std::endl;
//std::cerr << "iteration " << i <<" share is " << cur_share << std::endl;
free
(
encr_dkg_poly
);
free
(
errMsg1
);
free
(
errMsg1
);
free
(
hexEncrKey
);
free
(
hexEncrKey
);
return
result
;
return
DHKey
;
}
}
This diff is collapsed.
Click to expand it.
DKGCrypto.h
View file @
a0f4a55d
...
@@ -18,7 +18,7 @@ std::string get_secret_shares(const std::string& polyName, const char* encrypted
...
@@ -18,7 +18,7 @@ std::string get_secret_shares(const std::string& polyName, const char* encrypted
bool
VerifyShares
(
const
char
*
publicShares
,
const
char
*
encr_sshare
,
const
char
*
encryptedKeyHex
,
int
t
,
int
n
,
int
ind
);
bool
VerifyShares
(
const
char
*
publicShares
,
const
char
*
encr_sshare
,
const
char
*
encryptedKeyHex
,
int
t
,
int
n
,
int
ind
);
std
::
pair
<
std
::
string
,
std
::
string
>
response_to_complaint
(
const
std
::
string
&
polyName
,
const
char
*
encryptedPolyHex
,
int
n
,
int
t
,
int
ind
);
std
::
string
decrypt_DHKey
(
const
std
::
string
&
polyName
,
int
ind
);
bool
CreateBLSShare
(
const
std
::
string
&
BLSKeyName
,
const
char
*
s_shares
,
const
char
*
encryptedKeyHex
);
bool
CreateBLSShare
(
const
std
::
string
&
BLSKeyName
,
const
char
*
s_shares
,
const
char
*
encryptedKeyHex
);
...
...
This diff is collapsed.
Click to expand it.
Makefile.am
View file @
a0f4a55d
...
@@ -66,7 +66,7 @@ COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c
...
@@ -66,7 +66,7 @@ COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c
COMMON_ENCLAVE_SRC
=
secure_enclave_u.c secure_enclave_u.h
COMMON_ENCLAVE_SRC
=
secure_enclave_u.c secure_enclave_u.h
sgxwallet_SOURCES
=
sgxwallet.c SGXWalletServer.cpp RPCException.cpp BLSCrypto.cpp ECDSACrypto.cpp
\
sgxwallet_SOURCES
=
sgxwallet.c SGXWalletServer.cpp RPCException.cpp BLSCrypto.cpp ECDSACrypto.cpp
\
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp
$(COMMON_SRC)
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp
ServerDataChecker.cpp
$(COMMON_SRC)
nodist_sgxwallet_SOURCES
=
$(COMMON_ENCLAVE_SRC)
nodist_sgxwallet_SOURCES
=
$(COMMON_ENCLAVE_SRC)
...
@@ -98,7 +98,7 @@ sgxwallet_LDADD=-l$(SGX_URTS_LIB) -Lleveldb/build -LlibBLS/build -LlibBLS/build
...
@@ -98,7 +98,7 @@ sgxwallet_LDADD=-l$(SGX_URTS_LIB) -Lleveldb/build -LlibBLS/build -LlibBLS/build
testw_SOURCES
=
testw.cpp stubclient.cpp SGXWalletServer.cpp RPCException.cpp BLSCrypto.cpp ServerInit.cpp LevelDB.cpp
\
testw_SOURCES
=
testw.cpp stubclient.cpp SGXWalletServer.cpp RPCException.cpp BLSCrypto.cpp ServerInit.cpp LevelDB.cpp
\
DKGCrypto.cpp BLSPrivateKeyShareSGX.cpp ECDSACrypto.cpp
$(COMMON_SRC)
DKGCrypto.cpp BLSPrivateKeyShareSGX.cpp ECDSACrypto.cpp
ServerDataChecker.cpp
$(COMMON_SRC)
nodist_testw_SOURCES
=
${
nodist_sgxwallet_SOURCES
}
nodist_testw_SOURCES
=
${
nodist_sgxwallet_SOURCES
}
EXTRA_testw_DEPENDENCIES
=
${
EXTRA_sgxwallet_DEPENDENCIES
}
EXTRA_testw_DEPENDENCIES
=
${
EXTRA_sgxwallet_DEPENDENCIES
}
testw_LDADD
=
${
sgxwallet_LDADD
}
testw_LDADD
=
${
sgxwallet_LDADD
}
This diff is collapsed.
Click to expand it.
SGXWalletServer.cpp
View file @
a0f4a55d
...
@@ -29,6 +29,8 @@
...
@@ -29,6 +29,8 @@
#include "SGXWalletServer.h"
#include "SGXWalletServer.h"
#include "SGXWalletServer.hpp"
#include "SGXWalletServer.hpp"
#include "ServerDataChecker.h"
#include <algorithm>
#include <algorithm>
bool
isStringDec
(
std
::
string
&
str
){
bool
isStringDec
(
std
::
string
&
str
){
...
@@ -36,10 +38,6 @@ bool isStringDec( std::string & str){
...
@@ -36,10 +38,6 @@ bool isStringDec( std::string & str){
return
std
::
isdigit
(
c
);
return
std
::
isdigit
(
c
);
});
});
return
!
str
.
empty
()
&&
res
==
str
.
end
();
return
!
str
.
empty
()
&&
res
==
str
.
end
();
// bool res =tr
// for (int i = 0; i < str.length; i++){
// }
}
}
SGXWalletServer
::
SGXWalletServer
(
AbstractServerConnector
&
connector
,
SGXWalletServer
::
SGXWalletServer
(
AbstractServerConnector
&
connector
,
...
@@ -51,7 +49,7 @@ SGXWalletServer::SGXWalletServer(AbstractServerConnector &connector,
...
@@ -51,7 +49,7 @@ SGXWalletServer::SGXWalletServer(AbstractServerConnector &connector,
int
init_server
()
{
int
init_server
()
{
hs
=
new
HttpServer
(
102
5
);
hs
=
new
HttpServer
(
102
6
);
s
=
new
SGXWalletServer
(
*
hs
,
s
=
new
SGXWalletServer
(
*
hs
,
JSONRPC_SERVER_V2
);
// hybrid server (json-rpc 1.0 & 2.0)
JSONRPC_SERVER_V2
);
// hybrid server (json-rpc 1.0 & 2.0)
...
@@ -248,18 +246,32 @@ Json::Value ecdsaSignMessageHashImpl(int base, const std::string &_keyName, cons
...
@@ -248,18 +246,32 @@ Json::Value ecdsaSignMessageHashImpl(int base, const std::string &_keyName, cons
}
}
std
::
cerr
<<
"Hash handled "
<<
cutHash
<<
std
::
endl
;
std
::
cerr
<<
"Hash handled "
<<
cutHash
<<
std
::
endl
;
try
{
try
{
if
(
!
checkECDSAKeyName
(
_keyName
)){
throw
RPCException
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
}
if
(
!
checkHex
(
cutHash
)){
throw
RPCException
(
INVALID_HEX
,
"Invalid hash"
);
}
if
(
base
<=
0
||
base
>
32
){
throw
RPCException
(
-
22
,
"Invalid base"
);
}
std
::
shared_ptr
<
std
::
string
>
key_ptr
=
readFromDb
(
_keyName
,
""
);
std
::
shared_ptr
<
std
::
string
>
key_ptr
=
readFromDb
(
_keyName
,
""
);
// std::cerr << "read encr key" << *key_ptr << std::endl;
// std::cerr << "read encr key" << *key_ptr << std::endl;
sign_vect
=
ecdsa_sign_hash
(
key_ptr
->
c_str
(),
cutHash
.
c_str
(),
base
);
sign_vect
=
ecdsa_sign_hash
(
key_ptr
->
c_str
(),
cutHash
.
c_str
(),
base
);
std
::
cerr
<<
"got signature_s "
<<
sign_vect
.
at
(
2
)
<<
std
::
endl
;
result
[
"signature_v"
]
=
sign_vect
.
at
(
0
);
result
[
"signature_r"
]
=
sign_vect
.
at
(
1
);
result
[
"signature_s"
]
=
sign_vect
.
at
(
2
);
}
catch
(
RPCException
&
_e
)
{
}
catch
(
RPCException
&
_e
)
{
std
::
cerr
<<
"err str "
<<
_e
.
errString
<<
std
::
endl
;
std
::
cerr
<<
"err str "
<<
_e
.
errString
<<
std
::
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
}
std
::
cerr
<<
"got signature_s "
<<
sign_vect
.
at
(
2
)
<<
std
::
endl
;
result
[
"signature_v"
]
=
sign_vect
.
at
(
0
);
result
[
"signature_r"
]
=
sign_vect
.
at
(
1
);
result
[
"signature_s"
]
=
sign_vect
.
at
(
2
);
return
result
;
return
result
;
}
}
...
@@ -276,14 +288,18 @@ Json::Value getPublicECDSAKeyImpl(const std::string& keyName){
...
@@ -276,14 +288,18 @@ Json::Value getPublicECDSAKeyImpl(const std::string& keyName){
std
::
string
Pkey
;
std
::
string
Pkey
;
try
{
try
{
std
::
shared_ptr
<
std
::
string
>
key_ptr
=
readFromDb
(
keyName
,
""
);
if
(
!
checkECDSAKeyName
(
keyName
)){
throw
RPCException
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
}
std
::
shared_ptr
<
std
::
string
>
key_ptr
=
readFromDb
(
keyName
);
Pkey
=
get_ecdsa_pubkey
(
key_ptr
->
c_str
());
Pkey
=
get_ecdsa_pubkey
(
key_ptr
->
c_str
());
std
::
cerr
<<
"PublicKey"
<<
Pkey
<<
std
::
endl
;
result
[
"PublicKey"
]
=
Pkey
;
}
catch
(
RPCException
&
_e
)
{
}
catch
(
RPCException
&
_e
)
{
result
[
"status"
]
=
_e
.
status
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
}
std
::
cerr
<<
"PublicKey"
<<
Pkey
<<
std
::
endl
;
result
[
"PublicKey"
]
=
Pkey
;
//std::cerr << "in SGXWalletServer encr key x " << keys.at(0) << std::endl;
//std::cerr << "in SGXWalletServer encr key x " << keys.at(0) << std::endl;
...
@@ -300,15 +316,23 @@ Json::Value generateDKGPolyImpl(const std::string& polyName, int t) {
...
@@ -300,15 +316,23 @@ Json::Value generateDKGPolyImpl(const std::string& polyName, int t) {
std
::
string
encrPolyHex
;
std
::
string
encrPolyHex
;
try
{
try
{
if
(
!
checkPolyName
(
polyName
)){
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
if
(
t
<=
0
){
throw
RPCException
(
INVALID_DKG_PARAMS
,
"Invalid parameters: n or t "
);
}
encrPolyHex
=
gen_dkg_poly
(
t
);
encrPolyHex
=
gen_dkg_poly
(
t
);
writeDKGPoly
(
polyName
,
encrPolyHex
);
writeDataToDB
(
polyName
,
encrPolyHex
);
//writeDKGPoly(polyName, encrPolyHex);
//result["encryptedPoly"] = encrPolyHex;
}
catch
(
RPCException
&
_e
)
{
}
catch
(
RPCException
&
_e
)
{
std
::
cerr
<<
" err str "
<<
_e
.
errString
<<
std
::
endl
;
std
::
cerr
<<
" err str "
<<
_e
.
errString
<<
std
::
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
}
//result["encryptedPoly"] = encrPolyHex;
return
result
;
return
result
;
}
}
...
@@ -321,10 +345,25 @@ Json::Value getVerificationVectorImpl(const std::string& polyName, int n, int t)
...
@@ -321,10 +345,25 @@ Json::Value getVerificationVectorImpl(const std::string& polyName, int n, int t)
std
::
vector
<
std
::
vector
<
std
::
string
>>
verifVector
;
std
::
vector
<
std
::
vector
<
std
::
string
>>
verifVector
;
try
{
try
{
std
::
shared_ptr
<
std
::
string
>
encr_poly_ptr
=
readFromDb
(
polyName
,
"DKGPoly:"
);
if
(
!
checkPolyName
(
polyName
)){
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
if
(
!
check_n_t
(
n
,
t
)){
throw
RPCException
(
INVALID_DKG_PARAMS
,
"Invalid parameters: n or t "
);
}
std
::
shared_ptr
<
std
::
string
>
encr_poly_ptr
=
readFromDb
(
polyName
);
verifVector
=
get_verif_vect
(
encr_poly_ptr
->
c_str
(),
n
,
t
);
verifVector
=
get_verif_vect
(
encr_poly_ptr
->
c_str
(),
n
,
t
);
std
::
cerr
<<
"verif vect size "
<<
verifVector
.
size
()
<<
std
::
endl
;
//std::cerr << "verif vect size " << verifVector.size() << std::endl;
for
(
int
i
=
0
;
i
<
t
;
i
++
){
std
::
vector
<
std
::
string
>
cur_coef
=
verifVector
.
at
(
i
);
for
(
int
j
=
0
;
j
<
4
;
j
++
){
result
[
"Verification Vector"
][
i
][
j
]
=
cur_coef
.
at
(
j
);
}
}
}
catch
(
RPCException
&
_e
)
{
}
catch
(
RPCException
&
_e
)
{
std
::
cerr
<<
" err str "
<<
_e
.
errString
<<
std
::
endl
;
std
::
cerr
<<
" err str "
<<
_e
.
errString
<<
std
::
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"status"
]
=
_e
.
status
;
...
@@ -332,14 +371,6 @@ Json::Value getVerificationVectorImpl(const std::string& polyName, int n, int t)
...
@@ -332,14 +371,6 @@ Json::Value getVerificationVectorImpl(const std::string& polyName, int n, int t)
result
[
"Verification Vector"
]
=
""
;
result
[
"Verification Vector"
]
=
""
;
}
}
for
(
int
i
=
0
;
i
<
t
;
i
++
){
std
::
vector
<
std
::
string
>
cur_coef
=
verifVector
.
at
(
i
);
for
(
int
j
=
0
;
j
<
4
;
j
++
){
result
[
"Verification Vector"
][
i
][
j
]
=
cur_coef
.
at
(
j
);
}
}
return
result
;
return
result
;
}
}
...
@@ -354,11 +385,20 @@ Json::Value getSecretShareImpl(const std::string& polyName, const Json::Value& p
...
@@ -354,11 +385,20 @@ Json::Value getSecretShareImpl(const std::string& polyName, const Json::Value& p
result
[
"errorMessage"
]
=
"wrong number of public keys"
;
result
[
"errorMessage"
]
=
"wrong number of public keys"
;
return
result
;
return
result
;
}
}
if
(
!
checkPolyName
(
polyName
)){
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
if
(
!
check_n_t
(
n
,
t
)){
throw
RPCException
(
INVALID_DKG_PARAMS
,
"Invalid DKG parameters: n or t "
);
}
std
::
shared_ptr
<
std
::
string
>
encr_poly_ptr
=
readFromDb
(
polyName
,
"DKGPoly:"
);
std
::
shared_ptr
<
std
::
string
>
encr_poly_ptr
=
readFromDb
(
polyName
);
std
::
vector
<
std
::
string
>
pubKeys_vect
;
std
::
vector
<
std
::
string
>
pubKeys_vect
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
if
(
!
checkHex
(
publicKeys
[
i
].
asString
(),
64
)){
throw
RPCException
(
INVALID_HEX
,
"Invalid public key"
);
}
pubKeys_vect
.
push_back
(
publicKeys
[
i
].
asString
());
pubKeys_vect
.
push_back
(
publicKeys
[
i
].
asString
());
}
}
...
@@ -387,6 +427,17 @@ Json::Value DKGVerificationImpl(const std::string& publicShares, const std::stri
...
@@ -387,6 +427,17 @@ Json::Value DKGVerificationImpl(const std::string& publicShares, const std::stri
result
[
"result"
]
=
true
;
result
[
"result"
]
=
true
;
try
{
try
{
if
(
!
checkECDSAKeyName
(
EthKeyName
)){
throw
RPCException
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
}
if
(
!
check_n_t
(
n
,
t
)
||
ind
>
n
||
ind
<
0
){
throw
RPCException
(
INVALID_DKG_PARAMS
,
"Invalid DKG parameters: n or t "
);
}
if
(
!
checkHex
(
SecretShare
,
SECRET_SHARE_NUM_BYTES
)){
throw
RPCException
(
INVALID_HEX
,
"Invalid Secret share"
);
}
//std::string keyName = polyName + "_" + std::to_string(ind);
//std::string keyName = polyName + "_" + std::to_string(ind);
//std::shared_ptr<std::string> encryptedKeyHex_ptr = readFromDb(EthKeyName, "");
//std::shared_ptr<std::string> encryptedKeyHex_ptr = readFromDb(EthKeyName, "");
std
::
shared_ptr
<
std
::
string
>
encryptedKeyHex_ptr
=
readFromDb
(
EthKeyName
);
std
::
shared_ptr
<
std
::
string
>
encryptedKeyHex_ptr
=
readFromDb
(
EthKeyName
);
...
@@ -421,11 +472,23 @@ Json::Value CreateBLSPrivateKeyImpl(const std::string & BLSKeyName, const std::s
...
@@ -421,11 +472,23 @@ Json::Value CreateBLSPrivateKeyImpl(const std::string & BLSKeyName, const std::s
result
[
"errorMessage"
]
=
"wrong length of secret shares"
;
result
[
"errorMessage"
]
=
"wrong length of secret shares"
;
return
result
;
return
result
;
}
}
if
(
!
checkECDSAKeyName
(
EthKeyName
)){
throw
RPCException
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
}
if
(
!
checkName
(
polyName
,
"POLY"
)){
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
if
(
!
checkName
(
BLSKeyName
,
"BLS_KEY"
)){
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
std
::
vector
<
std
::
string
>
sshares_vect
;
std
::
vector
<
std
::
string
>
sshares_vect
;
std
::
cerr
<<
"sshares are "
<<
SecretShare
<<
std
::
endl
;
std
::
cerr
<<
"sshares are "
<<
SecretShare
<<
std
::
endl
;
char
sshares
[
192
*
n
+
1
];
char
sshares
[
192
*
n
+
1
];
for
(
int
i
=
0
;
i
<
n
;
i
++
){
for
(
int
i
=
0
;
i
<
n
;
i
++
){
std
::
string
cur_share
=
SecretShare
.
substr
(
192
*
i
,
192
*
i
+
192
);
std
::
string
cur_share
=
SecretShare
.
substr
(
192
*
i
,
192
*
i
+
192
);
if
(
!
checkHex
(
SecretShare
,
SECRET_SHARE_NUM_BYTES
)){
throw
RPCException
(
INVALID_HEX
,
"Invalid Secret share"
);
}
// std::cerr << " share " << i << " is " << cur_share << std::endl;
// std::cerr << " share " << i << " is " << cur_share << std::endl;
sshares_vect
.
push_back
(
cur_share
);
sshares_vect
.
push_back
(
cur_share
);
// std::cerr << sshares_vect[i] << " ";
// std::cerr << sshares_vect[i] << " ";
...
@@ -443,7 +506,7 @@ Json::Value CreateBLSPrivateKeyImpl(const std::string & BLSKeyName, const std::s
...
@@ -443,7 +506,7 @@ Json::Value CreateBLSPrivateKeyImpl(const std::string & BLSKeyName, const std::s
}
}
else
{
else
{
std
::
cerr
<<
"error "
<<
std
::
endl
;
throw
RPCException
(
-
122
,
"Error while creating BLS key share"
)
;
}
}
for
(
int
i
=
0
;
i
<
n
;
i
++
){
for
(
int
i
=
0
;
i
<
n
;
i
++
){
...
@@ -468,7 +531,10 @@ Json::Value GetBLSPublicKeyShareImpl(const std::string & BLSKeyName){
...
@@ -468,7 +531,10 @@ Json::Value GetBLSPublicKeyShareImpl(const std::string & BLSKeyName){
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
try
{
try
{
std
::
shared_ptr
<
std
::
string
>
encryptedKeyHex_ptr
=
readFromDb
(
BLSKeyName
,
""
);
if
(
!
checkName
(
BLSKeyName
,
"BLS_KEY"
)){
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
}
std
::
shared_ptr
<
std
::
string
>
encryptedKeyHex_ptr
=
readFromDb
(
BLSKeyName
);
std
::
cerr
<<
"encr_bls_key_share is "
<<
*
encryptedKeyHex_ptr
<<
std
::
endl
;
std
::
cerr
<<
"encr_bls_key_share is "
<<
*
encryptedKeyHex_ptr
<<
std
::
endl
;
std
::
cerr
<<
"length is "
<<
encryptedKeyHex_ptr
->
length
()
<<
std
::
endl
;
std
::
cerr
<<
"length is "
<<
encryptedKeyHex_ptr
->
length
()
<<
std
::
endl
;
std
::
vector
<
std
::
string
>
public_key_vect
=
GetBLSPubKey
(
encryptedKeyHex_ptr
->
c_str
());
std
::
vector
<
std
::
string
>
public_key_vect
=
GetBLSPubKey
(
encryptedKeyHex_ptr
->
c_str
());
...
@@ -485,17 +551,21 @@ Json::Value GetBLSPublicKeyShareImpl(const std::string & BLSKeyName){
...
@@ -485,17 +551,21 @@ Json::Value GetBLSPublicKeyShareImpl(const std::string & BLSKeyName){
return
result
;
return
result
;
}
}
Json
::
Value
ComplaintResponseImpl
(
const
std
::
string
&
polyName
,
int
n
,
int
t
,
int
ind
){
Json
::
Value
ComplaintResponseImpl
(
const
std
::
string
&
polyName
,
int
ind
){
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
try
{
try
{
std
::
shared_ptr
<
std
::
string
>
encr_poly_ptr
=
readFromDb
(
polyName
,
"DKGPoly:"
);
if
(
!
checkName
(
polyName
,
"POLY"
)){
std
::
cerr
<<
"encr_poly is "
<<
*
encr_poly_ptr
<<
std
::
endl
;
throw
RPCException
(
INVALID_POLY_NAME
,
"Invalid polynomial name"
);
std
::
pair
<
std
::
string
,
std
::
string
>
response
=
response_to_complaint
(
polyName
,
encr_poly_ptr
->
c_str
(),
n
,
t
,
ind
);
}
std
::
string
shareG2_name
=
"shareG2_"
+
polyName
+
"_"
+
std
::
to_string
(
ind
)
+
":"
;
std
::
shared_ptr
<
std
::
string
>
shareG2_ptr
=
readFromDb
(
shareG2_name
);
std
::
string
DHKey
=
decrypt_DHKey
(
polyName
,
ind
);
result
[
"share*G2"
]
=
response
.
second
;
result
[
"share*G2"
]
=
*
shareG2_ptr
;
result
[
"DHKey"
]
=
response
.
first
;
result
[
"DHKey"
]
=
DHKey
;
}
catch
(
RPCException
&
_e
)
{
}
catch
(
RPCException
&
_e
)
{
std
::
cerr
<<
" err str "
<<
_e
.
errString
<<
std
::
endl
;
std
::
cerr
<<
" err str "
<<
_e
.
errString
<<
std
::
endl
;
...
@@ -583,9 +653,9 @@ Json::Value SGXWalletServer::importECDSAKey(const std::string &key, const std::s
...
@@ -583,9 +653,9 @@ Json::Value SGXWalletServer::importECDSAKey(const std::string &key, const std::s
return
importECDSAKeyImpl
(
key
,
keyName
);
return
importECDSAKeyImpl
(
key
,
keyName
);
}
}
Json
::
Value
SGXWalletServer
::
ComplaintResponse
(
const
std
::
string
&
polyName
,
int
n
,
int
t
,
int
ind
){
Json
::
Value
SGXWalletServer
::
ComplaintResponse
(
const
std
::
string
&
polyName
,
int
ind
){
lock_guard
<
recursive_mutex
>
lock
(
m
);
lock_guard
<
recursive_mutex
>
lock
(
m
);
return
ComplaintResponseImpl
(
polyName
,
n
,
t
,
ind
);
return
ComplaintResponseImpl
(
polyName
,
ind
);
}
}
...
@@ -633,48 +703,6 @@ void writeKeyShare(const string &_keyShareName, const string &value, int index,
...
@@ -633,48 +703,6 @@ void writeKeyShare(const string &_keyShareName, const string &value, int index,
levelDb
->
writeString
(
key
,
value
);
levelDb
->
writeString
(
key
,
value
);
}
}
shared_ptr
<
std
::
string
>
readECDSAKey
(
const
string
&
_keyName
)
{
auto
keyStr
=
levelDb
->
readString
(
"ECDSAKEY:"
+
_keyName
);
if
(
keyStr
==
nullptr
)
{
throw
RPCException
(
KEY_SHARE_DOES_NOT_EXIST
,
"Key with this name does not exists"
);
}
return
keyStr
;
}
void
writeECDSAKey
(
const
string
&
_keyName
,
const
string
&
value
)
{
Json
::
Value
val
;
Json
::
FastWriter
writer
;
val
[
"value"
]
=
value
;
std
::
string
json
=
writer
.
write
(
val
);
auto
key
=
"ECDSAKEY:"
+
_keyName
;
if
(
levelDb
->
readString
(
_keyName
)
!=
nullptr
)
{
throw
RPCException
(
KEY_SHARE_ALREADY_EXISTS
,
"Key with this name already exists"
);
}
levelDb
->
writeString
(
key
,
value
);
}
void
writeDKGPoly
(
const
string
&
_polyName
,
const
string
&
value
)
{
Json
::
Value
val
;
Json
::
FastWriter
writer
;
val
[
"value"
]
=
value
;
std
::
string
json
=
writer
.
write
(
val
);
auto
key
=
"DKGPoly:"
+
_polyName
;
if
(
levelDb
->
readString
(
_polyName
)
!=
nullptr
)
{
throw
RPCException
(
KEY_SHARE_ALREADY_EXISTS
,
"Poly with this name already exists"
);
}
levelDb
->
writeString
(
key
,
value
);
}
void
writeDataToDB
(
const
string
&
Name
,
const
string
&
value
)
{
void
writeDataToDB
(
const
string
&
Name
,
const
string
&
value
)
{
Json
::
Value
val
;
Json
::
Value
val
;
Json
::
FastWriter
writer
;
Json
::
FastWriter
writer
;
...
...
This diff is collapsed.
Click to expand it.
SGXWalletServer.hpp
View file @
a0f4a55d
...
@@ -35,7 +35,7 @@ public:
...
@@ -35,7 +35,7 @@ public:
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
n
,
int
t
,
int
ind
);
virtual
Json
::
Value
ComplaintResponse
(
const
std
::
string
&
polyName
,
int
ind
);
};
};
...
@@ -45,12 +45,6 @@ void writeDataToDB(const string & Name, const string &value);
...
@@ -45,12 +45,6 @@ void writeDataToDB(const string & Name, const string &value);
void
writeKeyShare
(
const
string
&
_keyShareName
,
const
string
&
value
,
int
index
,
int
n
,
int
t
);
void
writeKeyShare
(
const
string
&
_keyShareName
,
const
string
&
value
,
int
index
,
int
n
,
int
t
);
shared_ptr
<
std
::
string
>
readKeyShare
(
const
string
&
_keyShare
);
shared_ptr
<
std
::
string
>
readKeyShare
(
const
string
&
_keyShare
);
void
writeECDSAKey
(
const
string
&
_keyName
,
const
string
&
value
);
shared_ptr
<
std
::
string
>
readECDSAKey
(
const
string
&
_key
);
void
writeDKGPoly
(
const
string
&
_polyName
,
const
string
&
value
);
Json
::
Value
importBLSKeyShareImpl
(
int
index
,
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyShareName
,
int
n
,
int
t
);
Json
::
Value
importBLSKeyShareImpl
(
int
index
,
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyShareName
,
int
n
,
int
t
);
Json
::
Value
blsSignMessageHashImpl
(
const
std
::
string
&
keyShareName
,
const
std
::
string
&
messageHash
,
int
n
,
int
t
,
int
signerIndex
);
Json
::
Value
blsSignMessageHashImpl
(
const
std
::
string
&
keyShareName
,
const
std
::
string
&
messageHash
,
int
n
,
int
t
,
int
signerIndex
);
...
@@ -66,6 +60,6 @@ Json::Value getSecretShareImpl(const std::string& polyName, const Json::Value& p
...
@@ -66,6 +60,6 @@ Json::Value getSecretShareImpl(const std::string& polyName, const Json::Value& p
Json
::
Value
DKGVerificationImpl
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
EthKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
);
Json
::
Value
DKGVerificationImpl
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
EthKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
);
Json
::
Value
CreateBLSPrivateKeyImpl
(
const
std
::
string
&
BLSKeyName
,
const
std
::
string
&
EthKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
Json
::
Value
CreateBLSPrivateKeyImpl
(
const
std
::
string
&
BLSKeyName
,
const
std
::
string
&
EthKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
);
Json
::
Value
GetBLSPublicKeyShareImpl
(
const
std
::
string
&
BLSKeyName
);
Json
::
Value
GetBLSPublicKeyShareImpl
(
const
std
::
string
&
BLSKeyName
);
Json
::
Value
ComplaintResponseImpl
(
const
std
::
string
&
polyName
,
int
n
,
int
t
,
int
ind
);
Json
::
Value
ComplaintResponseImpl
(
const
std
::
string
&
polyName
,
int
ind
);
#endif //SGXWALLET_SGXWALLETSERVER_HPP
#endif //SGXWALLET_SGXWALLETSERVER_HPP
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ServerDataChecker.cpp
View file @
a0f4a55d
...
@@ -2,7 +2,11 @@
...
@@ -2,7 +2,11 @@
// Created by kladko on 11/19/19.
// Created by kladko on 11/19/19.
//
//
std
::
vector
<
std
::
string
>
BLSutils
::
SplitString
(
std
::
string
&
str
,
const
std
::
string
&
delim
){
#include <vector>
#include "ServerDataChecker.h"
#include <gmp.h>
std
::
vector
<
std
::
string
>
SplitString
(
const
std
::
string
&
str
,
const
std
::
string
&
delim
=
":"
){
std
::
vector
<
std
::
string
>
tokens
;
std
::
vector
<
std
::
string
>
tokens
;
size_t
prev
=
0
,
pos
=
0
;
size_t
prev
=
0
,
pos
=
0
;
do
{
do
{
...
@@ -16,6 +20,166 @@ std::vector<std::string> BLSutils::SplitString(std::string& str, const std::stri
...
@@ -16,6 +20,166 @@ std::vector<std::string> BLSutils::SplitString(std::string& str, const std::stri
return
tokens
;
return
tokens
;
}
}
bool
checkPolyName
(
std
::
string
polyName
){
bool
checkECDSAKeyName
(
const
std
::
string
&
keyName
)
{
std
::
vector
<
std
::
string
>
parts
=
SplitString
(
keyName
);
if
(
parts
.
size
()
!=
2
)
{
return
false
;
}
if
(
parts
.
at
(
0
)
!=
"NEK"
)
{
return
false
;
}
if
(
parts
.
at
(
1
).
length
()
>
64
||
parts
.
at
(
1
).
length
()
<
1
){
return
false
;
}
mpz_t
num
;
mpz_init
(
num
);
if
(
mpz_set_str
(
num
,
parts
.
at
(
1
).
c_str
(),
16
)
==
-
1
){
mpz_clear
(
num
);
return
false
;
}
mpz_clear
(
num
);
return
true
;
}
bool
checkHex
(
const
std
::
string
&
hex
,
const
uint32_t
sizeInBytes
){
if
(
hex
.
length
()
>
sizeInBytes
*
2
||
hex
.
length
()
==
0
){
return
false
;
}
mpz_t
num
;
mpz_init
(
num
);
if
(
mpz_set_str
(
num
,
hex
.
c_str
(),
16
)
==
-
1
){
mpz_clear
(
num
);
return
false
;
}
mpz_clear
(
num
);
return
true
;
}
bool
checkPolyName
(
const
std
::
string
&
polyName
){
std
::
vector
<
std
::
string
>
parts
=
SplitString
(
polyName
);
if
(
parts
.
size
()
!=
7
)
{
return
false
;
}
if
(
parts
.
at
(
0
)
!=
"POLY"
)
{
return
false
;
}
if
(
parts
.
at
(
1
)
!=
"SCHAIN_ID"
){
return
false
;
}
if
(
parts
.
at
(
3
)
!=
"NODE_ID"
){
return
false
;
}
if
(
parts
.
at
(
5
)
!=
"DKG_ID"
){
return
false
;
}
if
(
parts
.
at
(
2
).
length
()
>
64
||
parts
.
at
(
2
).
length
()
<
1
){
return
false
;
}
if
(
parts
.
at
(
4
).
length
()
>
5
||
parts
.
at
(
4
).
length
()
<
1
){
return
false
;
}
if
(
parts
.
at
(
6
).
length
()
>
64
||
parts
.
at
(
6
).
length
()
<
1
){
return
false
;
}
mpz_t
num
;
mpz_init
(
num
);
if
(
mpz_set_str
(
num
,
parts
.
at
(
2
).
c_str
(),
16
)
==
-
1
){
mpz_clear
(
num
);
return
false
;
}
mpz_clear
(
num
);
mpz_init
(
num
);
if
(
mpz_set_str
(
num
,
parts
.
at
(
4
).
c_str
(),
10
)
==
-
1
){
mpz_clear
(
num
);
return
false
;
}
mpz_clear
(
num
);
mpz_init
(
num
);
if
(
mpz_set_str
(
num
,
parts
.
at
(
6
).
c_str
(),
16
)
==
-
1
){
mpz_clear
(
num
);
return
false
;
}
mpz_clear
(
num
);
return
true
;
}
bool
checkName
(
const
std
::
string
&
Name
,
const
std
::
string
&
prefix
){
std
::
vector
<
std
::
string
>
parts
=
SplitString
(
Name
);
if
(
parts
.
size
()
!=
7
)
{
return
false
;
}
if
(
parts
.
at
(
0
)
!=
prefix
)
{
return
false
;
}
if
(
parts
.
at
(
1
)
!=
"SCHAIN_ID"
){
return
false
;
}
if
(
parts
.
at
(
3
)
!=
"NODE_ID"
){
return
false
;
}
if
(
parts
.
at
(
5
)
!=
"DKG_ID"
){
return
false
;
}
if
(
parts
.
at
(
2
).
length
()
>
64
||
parts
.
at
(
2
).
length
()
<
1
){
return
false
;
}
if
(
parts
.
at
(
4
).
length
()
>
5
||
parts
.
at
(
4
).
length
()
<
1
){
return
false
;
}
if
(
parts
.
at
(
6
).
length
()
>
64
||
parts
.
at
(
6
).
length
()
<
1
){
return
false
;
}
mpz_t
num
;
mpz_init
(
num
);
if
(
mpz_set_str
(
num
,
parts
.
at
(
2
).
c_str
(),
16
)
==
-
1
){
mpz_clear
(
num
);
return
false
;
}
mpz_clear
(
num
);
mpz_init
(
num
);
if
(
mpz_set_str
(
num
,
parts
.
at
(
4
).
c_str
(),
10
)
==
-
1
){
mpz_clear
(
num
);
return
false
;
}
mpz_clear
(
num
);
mpz_init
(
num
);
if
(
mpz_set_str
(
num
,
parts
.
at
(
6
).
c_str
(),
16
)
==
-
1
){
mpz_clear
(
num
);
return
false
;
}
mpz_clear
(
num
);
return
true
;
}
bool
check_n_t
(
const
int
n
,
const
int
t
){
if
(
t
>
n
){
return
false
;
}
if
(
t
==
0
||
n
==
0
){
return
false
;
}
if
(
t
<
0
||
n
<
0
){
return
false
;
}
return
true
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ServerDataChecker.h
View file @
a0f4a55d
...
@@ -5,4 +5,16 @@
...
@@ -5,4 +5,16 @@
#ifndef SGXD_SERVERDATACHECKER_H
#ifndef SGXD_SERVERDATACHECKER_H
#define SGXD_SERVERDATACHECKER_H
#define SGXD_SERVERDATACHECKER_H
#include <string>
bool
checkECDSAKeyName
(
const
std
::
string
&
keyName
);
bool
checkHex
(
const
std
::
string
&
hash
,
const
uint32_t
sizeInBytes
=
32
);
bool
checkPolyName
(
const
std
::
string
&
polyName
);
bool
checkName
(
const
std
::
string
&
Name
,
const
std
::
string
&
prefix
);
bool
check_n_t
(
const
int
n
,
const
int
t
);
#endif // SGXD_SERVERDATACHECKER_H
#endif // SGXD_SERVERDATACHECKER_H
This diff is collapsed.
Click to expand it.
abstractstubserver.h
View file @
a0f4a55d
...
@@ -27,7 +27,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
...
@@ -27,7 +27,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"DKGVerification"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"publicShares"
,
jsonrpc
::
JSON_STRING
,
"EthKeyName"
,
jsonrpc
::
JSON_STRING
,
"SecretShare"
,
jsonrpc
::
JSON_STRING
,
"t"
,
jsonrpc
::
JSON_INTEGER
,
"n"
,
jsonrpc
::
JSON_INTEGER
,
"index"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
DKGVerificationI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"DKGVerification"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"publicShares"
,
jsonrpc
::
JSON_STRING
,
"EthKeyName"
,
jsonrpc
::
JSON_STRING
,
"SecretShare"
,
jsonrpc
::
JSON_STRING
,
"t"
,
jsonrpc
::
JSON_INTEGER
,
"n"
,
jsonrpc
::
JSON_INTEGER
,
"index"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
DKGVerificationI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"CreateBLSPrivateKey"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"BLSKeyName"
,
jsonrpc
::
JSON_STRING
,
"EthKeyName"
,
jsonrpc
::
JSON_STRING
,
"polyName"
,
jsonrpc
::
JSON_STRING
,
"SecretShare"
,
jsonrpc
::
JSON_STRING
,
"t"
,
jsonrpc
::
JSON_INTEGER
,
"n"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
CreateBLSPrivateKeyI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"CreateBLSPrivateKey"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"BLSKeyName"
,
jsonrpc
::
JSON_STRING
,
"EthKeyName"
,
jsonrpc
::
JSON_STRING
,
"polyName"
,
jsonrpc
::
JSON_STRING
,
"SecretShare"
,
jsonrpc
::
JSON_STRING
,
"t"
,
jsonrpc
::
JSON_INTEGER
,
"n"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
CreateBLSPrivateKeyI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"GetBLSPublicKeyShare"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"BLSKeyName"
,
jsonrpc
::
JSON_STRING
,
NULL
),
&
AbstractStubServer
::
GetBLSPublicKeyShareI
);
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
,
"n"
,
jsonrpc
::
JSON_INTEGER
,
"t"
,
jsonrpc
::
JSON_INTEGER
,
"ind"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
ComplaintResponseI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"ComplaintResponse"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"polyName"
,
jsonrpc
::
JSON_STRING
,
"ind"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
ComplaintResponseI
);
}
}
...
@@ -86,7 +86,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
...
@@ -86,7 +86,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
}
}
inline
virtual
void
ComplaintResponseI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
inline
virtual
void
ComplaintResponseI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
{
response
=
this
->
ComplaintResponse
(
request
[
"polyName"
].
asString
(),
request
[
"
n"
].
asInt
(),
request
[
"t"
].
asInt
(),
request
[
"
ind"
].
asInt
());
response
=
this
->
ComplaintResponse
(
request
[
"polyName"
].
asString
(),
request
[
"ind"
].
asInt
());
}
}
virtual
Json
::
Value
importBLSKeyShare
(
int
index
,
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyShareName
,
int
n
,
int
t
)
=
0
;
virtual
Json
::
Value
importBLSKeyShare
(
int
index
,
const
std
::
string
&
keyShare
,
const
std
::
string
&
keyShareName
,
int
n
,
int
t
)
=
0
;
...
@@ -103,7 +103,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
...
@@ -103,7 +103,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
virtual
Json
::
Value
DKGVerification
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
EthKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
)
=
0
;
virtual
Json
::
Value
DKGVerification
(
const
std
::
string
&
publicShares
,
const
std
::
string
&
EthKeyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
,
int
index
)
=
0
;
virtual
Json
::
Value
CreateBLSPrivateKey
(
const
std
::
string
&
BLSKeyName
,
const
std
::
string
&
EthKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
)
=
0
;
virtual
Json
::
Value
CreateBLSPrivateKey
(
const
std
::
string
&
BLSKeyName
,
const
std
::
string
&
EthKeyName
,
const
std
::
string
&
polyName
,
const
std
::
string
&
SecretShare
,
int
t
,
int
n
)
=
0
;
virtual
Json
::
Value
GetBLSPublicKeyShare
(
const
std
::
string
&
BLSKeyName
)
=
0
;
virtual
Json
::
Value
GetBLSPublicKeyShare
(
const
std
::
string
&
BLSKeyName
)
=
0
;
virtual
Json
::
Value
ComplaintResponse
(
const
std
::
string
&
polyName
,
int
n
,
int
t
,
int
ind
)
=
0
;
virtual
Json
::
Value
ComplaintResponse
(
const
std
::
string
&
polyName
,
int
ind
)
=
0
;
};
};
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
This diff is collapsed.
Click to expand it.
secure_enclave/DKGUtils.cpp
View file @
a0f4a55d
...
@@ -100,6 +100,10 @@ void gen_dkg_poly( char* secret, unsigned _t ){
...
@@ -100,6 +100,10 @@ void gen_dkg_poly( char* secret, unsigned _t ){
result
+=
":"
;
result
+=
":"
;
}
}
strncpy
(
secret
,
result
.
c_str
(),
result
.
length
()
+
1
);
strncpy
(
secret
,
result
.
c_str
(),
result
.
length
()
+
1
);
if
(
strlen
(
secret
)
==
0
){
throw
std
::
exception
();
}
}
}
libff
::
alt_bn128_Fr
PolynomialValue
(
const
std
::
vector
<
libff
::
alt_bn128_Fr
>&
pol
,
libff
::
alt_bn128_Fr
point
,
unsigned
_t
)
{
libff
::
alt_bn128_Fr
PolynomialValue
(
const
std
::
vector
<
libff
::
alt_bn128_Fr
>&
pol
,
libff
::
alt_bn128_Fr
point
,
unsigned
_t
)
{
...
...
This diff is collapsed.
Click to expand it.
secure_enclave/secure_enclave.c
View file @
a0f4a55d
...
@@ -584,6 +584,8 @@ void get_encr_sshare(int *err_status, char *err_string, uint8_t *encrypted_skey,
...
@@ -584,6 +584,8 @@ void get_encr_sshare(int *err_status, char *err_string, uint8_t *encrypted_skey,
generate_ecdsa_key
(
err_status
,
err_string
,
encrypted_skey
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
generate_ecdsa_key
(
err_status
,
err_string
,
encrypted_skey
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
// snprintf(err_string, BUF_LEN,"pub_key_x is %s", pub_key_x);
// snprintf(err_string, BUF_LEN,"pub_key_x is %s", pub_key_x);
*
dec_len
=
enc_len
;
sgx_status_t
status
=
sgx_unseal_data
(
sgx_status_t
status
=
sgx_unseal_data
(
(
const
sgx_sealed_data_t
*
)
encrypted_skey
,
NULL
,
0
,
(
uint8_t
*
)
skey
,
&
enc_len
);
(
const
sgx_sealed_data_t
*
)
encrypted_skey
,
NULL
,
0
,
(
uint8_t
*
)
skey
,
&
enc_len
);
...
...
This diff is collapsed.
Click to expand it.
sgxwallet_common.h
View file @
a0f4a55d
...
@@ -29,6 +29,8 @@
...
@@ -29,6 +29,8 @@
#define DKG_BUFER_LENGTH 2490//3060
#define DKG_BUFER_LENGTH 2490//3060
#define DKG_MAX_SEALED_LEN 3050
#define DKG_MAX_SEALED_LEN 3050
#define SECRET_SHARE_NUM_BYTES 96
#define ECDSA_SKEY_LEN 65
#define ECDSA_SKEY_LEN 65
#define ECDSA_SKEY_BASE 16
#define ECDSA_SKEY_BASE 16
#define ECDSA_ENCR_LEN 625
#define ECDSA_ENCR_LEN 625
...
@@ -46,7 +48,15 @@
...
@@ -46,7 +48,15 @@
#define COULD_NOT_ACCESS_DATABASE -9
#define COULD_NOT_ACCESS_DATABASE -9
#define NULL_DATABASE -10
#define NULL_DATABASE -10
#define WALLETDB_NAME "sgxwallet.db" //"test_sgxwallet.db"//
#define INVALID_POLY_NAME -11
#define INVALID_DKG_PARAMS -12
#define INVALID_ECDSA_KEY_NAME -20
#define INVALID_HEX -21
#define SGX_ERROR -666;
#define WALLETDB_NAME "test_sgxwallet.db"//"sgxwallet.db" //
#define ENCLAVE_NAME "secure_enclave.signed.so"
#define ENCLAVE_NAME "secure_enclave.signed.so"
...
...
This diff is collapsed.
Click to expand it.
spec.json
View file @
a0f4a55d
...
@@ -139,7 +139,7 @@
...
@@ -139,7 +139,7 @@
"name"
:
"DKGVerification"
,
"name"
:
"DKGVerification"
,
"params"
:
{
"params"
:
{
"publicShares"
:
"123"
,
"publicShares"
:
"123"
,
"EthKeyName"
:
"
key_j
"
,
"EthKeyName"
:
"
NEK:hex
"
,
"SecretShare"
:
"f_ij"
,
"SecretShare"
:
"f_ij"
,
"n"
:
3
,
"n"
:
3
,
"t"
:
3
,
"t"
:
3
,
...
@@ -154,9 +154,9 @@
...
@@ -154,9 +154,9 @@
{
{
"name"
:
"CreateBLSPrivateKey"
,
"name"
:
"CreateBLSPrivateKey"
,
"params"
:
{
"params"
:
{
"BLSKeyName"
:
"
key
"
,
"BLSKeyName"
:
"
BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID:
"
,
"EthKeyName"
:
"
key1
"
,
"EthKeyName"
:
"
NEK:hex
"
,
"polyName"
:
"
p1
"
,
"polyName"
:
"
POLY:SCHAIN_ID :NODE_ID :DKG_ID:
"
,
"SecretShare"
:
"122"
,
"SecretShare"
:
"122"
,
"n"
:
3
,
"n"
:
3
,
"t"
:
3
"t"
:
3
...
@@ -171,7 +171,7 @@
...
@@ -171,7 +171,7 @@
{
{
"name"
:
"GetBLSPublicKeyShare"
,
"name"
:
"GetBLSPublicKeyShare"
,
"params"
:
{
"params"
:
{
"BLSKeyName"
:
"
key
"
"BLSKeyName"
:
"
BLS_KEY:SCHAIN_ID :NODE_ID :DKG_ID
"
},
},
"returns"
:
{
"returns"
:
{
"status"
:
0
,
"status"
:
0
,
...
...
This diff is collapsed.
Click to expand it.
stubclient.h
View file @
a0f4a55d
...
@@ -173,12 +173,10 @@ class StubClient : public jsonrpc::Client
...
@@ -173,12 +173,10 @@ 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
ComplaintResponse
(
const
std
::
string
&
polyName
,
int
n
,
int
t
,
int
ind
)
throw
(
jsonrpc
::
JsonRpcException
)
Json
::
Value
ComplaintResponse
(
const
std
::
string
&
polyName
,
int
ind
)
throw
(
jsonrpc
::
JsonRpcException
)
{
{
Json
::
Value
p
;
Json
::
Value
p
;
p
[
"polyName"
]
=
polyName
;
p
[
"polyName"
]
=
polyName
;
p
[
"n"
]
=
n
;
p
[
"t"
]
=
t
;
p
[
"ind"
]
=
ind
;
p
[
"ind"
]
=
ind
;
Json
::
Value
result
=
this
->
CallMethod
(
"ComplaintResponse"
,
p
);
Json
::
Value
result
=
this
->
CallMethod
(
"ComplaintResponse"
,
p
);
if
(
result
.
isObject
())
if
(
result
.
isObject
())
...
...
This diff is collapsed.
Click to expand it.
testw.cpp
View file @
a0f4a55d
...
@@ -701,13 +701,6 @@ TEST_CASE("get public ECDSA key", "[get_pub_ecdsa_key_test]") {
...
@@ -701,13 +701,6 @@ TEST_CASE("get public ECDSA key", "[get_pub_ecdsa_key_test]") {
}*/
}*/
TEST_CASE
(
"dkg_complaint test1"
,
"[dkgc]"
)
{
init_daemon
();
init_enclave
();
char
*
encr_poly
=
"04000200000000000406ffffff02000000000000000000000b000000000000ff0000000000000000877a3884976af70f3de0ed7ad82b16cad2b5e69bf9976f3012a421ee7025c4b5000000f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ba090000000000000000000000000000ba090000000000000000000000000000426594165b64a693699c19f0efcbe2b1e7bde98de433a929f8fcdbc093e5f490d3f17674667de6160945584897077c401f3fa0bc05b26dc6ffea9a3d38bbcedaccb45bc39858050e97a5ae98f02ecd17ac32784d2cda930481805c1b9db38443ccef23a3c0bcc3f010a562bfc7b9d9db73fa412273ff884fdb8c0b9e72dfb114707f930bee9d44241fcfb7fd455d68b5cdf2b687afcf9fa8b568a7b17ea60258d821fbdeafdc8524db14165530836216eaccd3d7f9e03762db61d0c506f4fbb4f6d21336c8fd1e59cf6c57d91046cd0a4b0e044daab39371bb9dcbf11aa652246b6a93ff536629c8b54fa7e8074795190edc702ca162386f1c26c3601c2ea27a677194a2c183396ecad15c0d5da95a8137c4e7967c2b3f829a6d80d4fa13a53058e7aa3b807ca665770ba6495e38526f92479aac823e8224ca633982722424dc2498929bd076daea93a73d4ad60e4924496bcca55a95977139801cb7407caf4bba76ac972ea91cbee2661d18d404cd652b0df6ef09736f473d4cead9a218809e0a726bfcf2823006375d25b07c514eab9249a4d17da0f2a3f05886dc3698bba6de7b2e32beb96386a69385274dac607e2e7f7e68fa7673b83c99798298e44d64c118c42ce8a0102cb45cb892283c5d201c19ae12a38890e18ef610f87fd63c3571b8e9ba782ebd62282e14cc4bf5cb9eb4280a5cb63b4b31a88720c043fd1e0c3b916016cc46c480bab1e7fdf5a2960df8babdbe19083e17bd65c58482affb3dd549f5674eb761be49b80c16ded7f41bc1993d5af5d27a55b9be24fa20d288087978c70119bed4c441f0e109baf95d80df7623ff6ad31f28e906413d12ebeb4669f96c34931511b37b6a5be5935c905c893ed9b0518275bd5cf241c73f6d06169f30a74e65e6f240f8e2ed696a9964851fb18b827bbc15ea20738891a7a69312d85e47b42bd24dca3285876ad41a1750d53e5f919a453a91ddb11943292ced0130828dfa08c9d3cea0a50a2619af4735770df386074c72cd60b87ede0fe53885340b907c9c02d8a7fc4c7bf509c169b049ef627c33926c9247d9e1a44c27b86b722385d8e61af40919e96ed8feb2b781bfa68095d07966381bfaac7389010b45db671e3d5e7f488ad7ff69ac6fc599fb4f259c9cb9d1ee7265312ecc4dc4ad89b9850445a7e094a7a9f7e7cf71a159f4db849d0b7f9346065ac8e509fc3f7932db1f91c3a1e34604cbedd071772bbd414d4b96328aedf372ff4e4170ca0c23bbadd447b49eff0ae2c37b51052c6e1cf2a0ef0106fa892a4a18165bfeea92c565ae5aecfa8163aa12c762f40135664b467bd58470216b1124413a2a723a358a759425cf293a6cf0b42662892f42d62e6a446016365c22ab26ca4e7dbd1c404a3f2f515fb4fd2e33efc82cca453b63d6d9e8fc0369c0192684731314ab2d684f948171c1917f99603667367b8fa69d207e3bf9c05b13b4720f493642a497b403934dbb7865dd0d0c893483b5c2986baac9d7f50612abe37f2274531ad80aba90d76117d81f99cf7459097cd7a90c441339b581dcd0bf2e74a912415918546bb5c645362dd4424631588a95a0945cd723df229b1b6da93142de12084ef56c93e2f342ba524a15c94b6334ad3f8baaa05e5e55888559a0b73be9116ed2bb713eb01f188ac86ab6ff4b0228eeb7bf481369fad1b5dc8d1718e62f65eb2c4a2906539526cfd45d4ae6f1a903f88ae4cf7f9a4fb290a14db3595ac581d70daf5b020864b315c17a99d23f19f7aa255372fd5b709eacf27503e3ab8fba5785944158aeb73c5b432c65286ae05d1ee95b5c922e24a83ecef7f4d96bfe86bd7990c13db918dbba8977f3cbfe1854a8cdcc63ea73ce3f93757ef6cb77e8144c2df51a0de62eaa982a803b35f24c6f5edf2bbacce988bfe37e394ef2acb2f364c8939365c38c56d32d8c9e1600c8b521ed80f5ad82334e915b862ff3dbf343b914170be3b881a4696c6f97100b005435cbdbb7dd7ff7bec17b179ab7645166dacf59544d7cf7cfcb94ac35acde7311d2213f9aeb5734ccbd1ad800d517c0218b92310ebd9d76b96908aba2c8779111b5ed6acfa15817b4e7bbee845b1b4eb9b8daa4cdf0a0349dfde69f63355b2a32197fb2c4a504721d6857a97da303b14dc58831cbdccba06f4bb3616bc1f33e77e1df9a5419cf7613f4d363297a1c1b6f2010f5029c48fc6909076d1883ee7b21254753f9f420bd6602d49a359719a89c5a8d3c0a93337a1c937161e1490598c3b00cac95f1240b69b4080a81942e8f1900f978b16daac1c732b37083e800ca03bf8dc38d5e2cc45aac155d169050ec49070de42e1f7cdf59556788576366930f444b310e9c16ab39c0c704eabb135935dcc218ecf3327b78256674b5b43a6886ee3099d96c5a9d6d00a65b620986abed68eaafcab311da531847e9da30276ca398fee82c77293ce55c41e562cda9801bf76eac8d41345fa6b13e31dafbf774046a21e00fa07e882133b70a0853c51ab329e8c0ff5b6c93e385609a295a8d380c33e1ee9e69e812ad404d1252d56bc3ba583aaf4581f81f7ea2b34666eca35883922dde55007a0f0049149fea6d4a0911a001e48dc105020ffd84a45a7db78dd5b1e78a14a47d1ecb6d9ffc12e5183a3dc06f03e74a449e89b46ef91a74462938e6898fed3fb72b17a5a207da6ae04c1859da383a9a300ff31f3e5a668027e4f38cc35bd6c0a5a7532f8d33ee4ea2b77dd6b0d51475b263d26c3fde0ff79ccdca8b386bcf586384f18b95cc73b834d2969da753acc42c81ac171fa19be22652d5e0eadb37445dcbcf9bd3fc4220ac1977191a38cba9ced7b5a3c8defd07a1ff68dc85f2f8c88d3314ddf4f135aaf459127715de101943988add0333e38b7b85449111a6b72fa6965d1369a897508a4990d8150da9cd68f5c60f612dafb598463d23cfb6a3369418197d16709ec9b4f15dd9e85f7a4ae86152600d6bc7c1ba30516bc17e8852f087c3ef390ab05f6c57a4ab405fedbc04849a163ed292c45bb02afc2e059ca08adf3d51e2f9a79637f6cf5e222f9ea27ec37c67849c937a99e270f1d05add89ab42b6fe1648f02fcbfbefb2f176597df1e23c41c39c29ba2d48c2788ea95327657fdb41ec24aff3259631046f5a62c07288181453942a1f24f495d087522569eef5b117477349720adde22136fdceb92173741ed0ba4252ee7332e5f835a18f6708cf429167e328a8ed33518610ccea3b750c1460a140f2645bf28fa6bad57d298463e117426ea1b8b944e04032df3413391653805149ef7dba49fb4221bc64f40c039bbaf4ecaac256084402699a89bd440539e565582f2cfb0e35ab41f70326cd3f24168a3c2816553aa8ed19facb6d3a07af5ec7a5f9f80e96c9e41adbd6fa0d44bda9cb954fed933912ec9d320cf5c2fc687bd89a5c5a1ddd87b7e3db33c0138aaaa92dd4f4619c8f9dfcc269aa8fbeb7ede7e05c2f778b05d8339fa175e2447844cd86dd886b40cb3badc4ce986aa93a3d973d1c4a76b6bdc0"
;
std
::
pair
<
std
::
string
,
std
::
string
>
result
=
response_to_complaint
(
"pp2"
,
encr_poly
,
2
,
2
,
0
);
}
TEST_CASE
(
"pub_bls_key"
,
"[pub_bls]"
)
{
TEST_CASE
(
"pub_bls_key"
,
"[pub_bls]"
)
{
init_daemon
();
init_daemon
();
init_enclave
();
init_enclave
();
...
@@ -733,7 +726,7 @@ TEST_CASE("API test", "[api_test]") {
...
@@ -733,7 +726,7 @@ TEST_CASE("API test", "[api_test]") {
// JSONRPC_SERVER_V2); // hybrid server (json-rpc 1.0 & 2.0)
// JSONRPC_SERVER_V2); // hybrid server (json-rpc 1.0 & 2.0)
// s.StartListening();
// s.StartListening();
cerr
<<
"Server inited"
<<
endl
;
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:102
5
"
);
HttpClient
client
(
"http://localhost:102
6
"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
cerr
<<
"Client inited"
<<
endl
;
cerr
<<
"Client inited"
<<
endl
;
...
@@ -745,12 +738,16 @@ TEST_CASE("API test", "[api_test]") {
...
@@ -745,12 +738,16 @@ TEST_CASE("API test", "[api_test]") {
//levelDb->deleteDHDKGKey("p2_1:");
//levelDb->deleteDHDKGKey("p2_1:");
//
cout << c.generateECDSAKey() << endl;
//
cout << c.generateECDSAKey() << endl;
// cout << c.renameESDSAKey("NODE_1CHAIN_1","tmp_NEK:bcacde0d26c0ea2c7e649992e7f791e1fba2492f5b7ae63dadb799075167c7fc");
// cout << c.renameESDSAKey("NODE_1CHAIN_1","tmp_NEK:bcacde0d26c0ea2c7e649992e7f791e1fba2492f5b7ae63dadb799075167c7fc");
//cout<<c.getPublicECDSAKey("test_key1");
//cout<<c.getPublicECDSAKey("NEK:697fadfc597bdbfae9ffb7412b80939e848c9c2fec2657bb2122b6d0d4a0dca8");
//cout << c.ecdsaSignMessageHash(16, "NEK:697fadfc597bdbfae9ffb7412b80939e848c9c2fec2657bb2122b6d0d4a0dca8","0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db" );
//cout << c.ecdsaSignMessageHash(16, "known_key1","0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db" );
//cout << c.ecdsaSignMessageHash(16, "known_key1","0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db" );
// cout << c.blsSignMessageHash(TEST_BLS_KEY_NAME, "0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db", 2,2,1 );
// cout << c.blsSignMessageHash(TEST_BLS_KEY_NAME, "0x09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db", 2,2,1 );
// cout << c.generateDKGPoly("pp2", 2);
// cout << c.generateDKGPoly("pp2", 2);
// cout << c.generateDKGPoly("POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1", 2);
//cout << c.getVerificationVector("POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:2", 2, 2);
// cout << c.getVerificationVector("polyy", 5, 5);
// cout << c.getVerificationVector("polyy", 5, 5);
// cout << c.getSecretShare("p2",
// cout << c.getSecretShare("p2",
...
@@ -763,8 +760,8 @@ TEST_CASE("API test", "[api_test]") {
...
@@ -763,8 +760,8 @@ TEST_CASE("API test", "[api_test]") {
Json
::
Value
publicKeys
;
Json
::
Value
publicKeys
;
publicKeys
.
append
(
"505f55a38f9c064da744f217d1cb993a17705e9839801958cda7c884e08ab4dad7fd8d22953d3ac7f0913de24fd67d7ed36741141b8a3da152d7ba954b0f14e2"
);
publicKeys
.
append
(
"505f55a38f9c064da744f217d1cb993a17705e9839801958cda7c884e08ab4dad7fd8d22953d3ac7f0913de24fd67d7ed36741141b8a3da152d7ba954b0f14e2"
);
publicKeys
.
append
(
"378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25
e6e
"
);
publicKeys
.
append
(
"378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25"
);
// cout << c.getSecretShare("pp2
", publicKeys, 2, 2);
// cout << c.getSecretShare("POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1
", publicKeys, 2, 2);
// cout << c.generateDKGPoly("p3", 3);
// cout << c.generateDKGPoly("p3", 3);
// cout << c.getSecretShare("p3",
// cout << c.getSecretShare("p3",
// "669aa790e1c5f5199af82ab0b6f1965c382d23a2ebdda581454adba3fd082a30edab62b545f78f1e402ceef7340a0364a7046633d6151fe7e657d8b8a6352378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25e6e9d43f1c88581f53af993da1654c9f91829c1fe5344c4452ef8d2d8675c6a051c19029f6e4f82b035fb3552058cf22c5bbafd9e6456d579634987281765d130b0",
// "669aa790e1c5f5199af82ab0b6f1965c382d23a2ebdda581454adba3fd082a30edab62b545f78f1e402ceef7340a0364a7046633d6151fe7e657d8b8a6352378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25e6e9d43f1c88581f53af993da1654c9f91829c1fe5344c4452ef8d2d8675c6a051c19029f6e4f82b035fb3552058cf22c5bbafd9e6456d579634987281765d130b0",
...
@@ -798,9 +795,9 @@ TEST_CASE("API test", "[api_test]") {
...
@@ -798,9 +795,9 @@ TEST_CASE("API test", "[api_test]") {
//cout << c.CreateBLSPrivateKey( "test_blskey", EthKeyName, "JCGMt", s_share, 2, 2 );
//cout << c.CreateBLSPrivateKey( "test_blskey", EthKeyName, "JCGMt", s_share, 2, 2 );
//cout << c.GetBLSPublicKeyShare("test_blskey");
//cout << c.GetBLSPublicKeyShare("test_blskey");
cout
<<
c
.
blsSignMessageHash
(
"dOsRY"
,
"38433e5ce087dcc1be82fcc834eae83c256b3db87d34f84440d0b708daa0c6f7"
,
2
,
2
,
1
);
//
cout << c.blsSignMessageHash("dOsRY","38433e5ce087dcc1be82fcc834eae83c256b3db87d34f84440d0b708daa0c6f7", 2, 2, 1);
//cout << c.ComplaintResponse("pp2", 2, 2
, 0);
cout
<<
c
.
ComplaintResponse
(
"POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1"
,
0
);
}
catch
(
JsonRpcException
&
e
)
{
}
catch
(
JsonRpcException
&
e
)
{
cerr
<<
e
.
what
()
<<
endl
;
cerr
<<
e
.
what
()
<<
endl
;
...
...
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