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
c81d1128
Unverified
Commit
c81d1128
authored
Mar 24, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2341 Added tags for older commits
parent
641e3e57
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
148 additions
and
292 deletions
+148
-292
BLSPrivateKeyShareSGX.cpp
BLSPrivateKeyShareSGX.cpp
+0
-2
DKGCrypto.cpp
DKGCrypto.cpp
+85
-109
DKGCrypto.h
DKGCrypto.h
+3
-3
ECDSACrypto.cpp
ECDSACrypto.cpp
+8
-13
SGXWalletServer.cpp
SGXWalletServer.cpp
+9
-10
SGXWalletServer.hpp
SGXWalletServer.hpp
+1
-1
start.sh
docker/start.sh
+19
-19
sgxwallet_common.h
sgxwallet_common.h
+1
-4
testw.cpp
testw.cpp
+22
-131
No files found.
BLSPrivateKeyShareSGX.cpp
View file @
c81d1128
...
@@ -80,10 +80,8 @@ BLSPrivateKeyShareSGX::BLSPrivateKeyShareSGX(
...
@@ -80,10 +80,8 @@ BLSPrivateKeyShareSGX::BLSPrivateKeyShareSGX(
requiredSigners
=
_requiredSigners
;
requiredSigners
=
_requiredSigners
;
totalSigners
=
_totalSigners
;
totalSigners
=
_totalSigners
;
std
::
cerr
<<
"ENTER BLSPrivateKeyShareSGX CONSTRUCTOR"
<<
std
::
endl
;
if
(
requiredSigners
>
totalSigners
)
{
if
(
requiredSigners
>
totalSigners
)
{
throw
std
::
invalid_argument
(
"requiredSigners > totalSigners"
);
throw
std
::
invalid_argument
(
"requiredSigners > totalSigners"
);
}
}
...
...
DKGCrypto.cpp
View file @
c81d1128
This diff is collapsed.
Click to expand it.
DKGCrypto.h
View file @
c81d1128
...
@@ -31,11 +31,11 @@ std::string gen_dkg_poly( int _t);
...
@@ -31,11 +31,11 @@ std::string gen_dkg_poly( int _t);
std
::
vector
<
std
::
vector
<
std
::
string
>>
get_verif_vect
(
const
char
*
encryptedPolyHex
,
int
t
,
int
n
);
std
::
vector
<
std
::
vector
<
std
::
string
>>
get_verif_vect
(
const
char
*
encryptedPolyHex
,
int
t
,
int
n
);
std
::
vector
<
std
::
string
>
S
plitString
(
const
char
*
koefs
,
const
char
symbol
);
std
::
vector
<
std
::
string
>
s
plitString
(
const
char
*
koefs
,
const
char
symbol
);
std
::
string
get_secret_shares
(
const
std
::
string
&
polyName
,
const
char
*
encryptedPolyHex
,
const
std
::
vector
<
std
::
string
>&
publicKeys
,
int
t
,
int
n
);
std
::
string
get_secret_shares
(
const
std
::
string
&
_polyName
,
const
char
*
_encryptedPolyHex
,
const
std
::
vector
<
std
::
string
>&
_publicKeys
,
int
_t
,
int
_
n
);
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
::
string
decrypt_DHKey
(
const
std
::
string
&
polyName
,
int
ind
);
std
::
string
decrypt_DHKey
(
const
std
::
string
&
polyName
,
int
ind
);
...
...
ECDSACrypto.cpp
View file @
c81d1128
...
@@ -34,12 +34,12 @@
...
@@ -34,12 +34,12 @@
#include "spdlog/spdlog.h"
#include "spdlog/spdlog.h"
static
std
::
default_random_engine
randGen
((
unsigned
int
)
time
(
0
));
static
default_random_engine
randGen
((
unsigned
int
)
time
(
0
));
st
d
::
st
ring
concatPubKeyWith0x
(
char
*
pub_key_x
,
char
*
pub_key_y
)
{
string
concatPubKeyWith0x
(
char
*
pub_key_x
,
char
*
pub_key_y
)
{
st
d
::
st
ring
px
=
pub_key_x
;
string
px
=
pub_key_x
;
st
d
::
st
ring
py
=
pub_key_y
;
string
py
=
pub_key_y
;
st
d
::
string
result
=
"0x"
+
px
+
py
;
// + std::to_string(pub_key_x) + std::to_string(pub_key_y)
;
st
ring
result
=
"0x"
+
px
+
py
;
return
result
;
return
result
;
}
}
...
@@ -57,25 +57,21 @@ std::vector<std::string> genECDSAKey() {
...
@@ -57,25 +57,21 @@ std::vector<std::string> genECDSAKey() {
status
=
generate_ecdsa_key_aes
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
status
=
generate_ecdsa_key_aes
(
eid
,
&
err_status
,
errMsg
,
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
if
(
status
!=
SGX_SUCCESS
||
err_status
!=
0
)
{
if
(
status
!=
SGX_SUCCESS
||
err_status
!=
0
)
{
s
td
::
cerr
<<
"RPCException thrown with status"
<<
status
<<
std
::
endl
;
s
pdlog
::
error
(
"RPCException thrown with status {}"
,
status
)
;
throw
RPCException
(
status
,
errMsg
);
throw
RPCException
(
status
,
errMsg
);
}
}
std
::
vector
<
std
::
string
>
keys
(
3
);
std
::
vector
<
std
::
string
>
keys
(
3
);
std
::
cerr
<<
"account key is "
<<
errMsg
<<
std
::
endl
;
std
::
cerr
<<
"enc_len is "
<<
enc_len
<<
std
::
endl
;
char
*
hexEncrKey
=
(
char
*
)
calloc
(
BUF_LEN
*
2
,
1
);
char
*
hexEncrKey
=
(
char
*
)
calloc
(
BUF_LEN
*
2
,
1
);
carray2Hex
(
encr_pr_key
,
enc_len
,
hexEncrKey
);
carray2Hex
(
encr_pr_key
,
enc_len
,
hexEncrKey
);
keys
.
at
(
0
)
=
hexEncrKey
;
keys
.
at
(
0
)
=
hexEncrKey
;
keys
.
at
(
1
)
=
std
::
string
(
pub_key_x
)
+
std
::
string
(
pub_key_y
);
//concatPubKeyWith0x(pub_key_x, pub_key_y);//
keys
.
at
(
1
)
=
std
::
string
(
pub_key_x
)
+
std
::
string
(
pub_key_y
);
//concatPubKeyWith0x(pub_key_x, pub_key_y);//
//std::cerr << "in ECDSACrypto encr key x " << keys.at(0) << std::endl;
//std::cerr << "in ECDSACrypto encr_len %d " << enc_len << std::endl;
unsigned
long
seed
=
randGen
();
unsigned
long
seed
=
randGen
();
spdlog
::
debug
(
"seed is {}"
,
seed
);
spdlog
::
debug
(
"seed is {}"
,
seed
);
std
::
cerr
<<
"strlen is "
<<
strlen
(
hexEncrKey
)
<<
std
::
endl
;
gmp_randstate_t
state
;
gmp_randstate_t
state
;
gmp_randinit_default
(
state
);
gmp_randinit_default
(
state
);
...
@@ -90,7 +86,6 @@ std::vector<std::string> genECDSAKey() {
...
@@ -90,7 +86,6 @@ std::vector<std::string> genECDSAKey() {
keys
.
at
(
2
)
=
rand_str
;
keys
.
at
(
2
)
=
rand_str
;
//std::cerr << "rand_str length is " << strlen(rand_str) << std::endl;
gmp_randclear
(
state
);
gmp_randclear
(
state
);
mpz_clear
(
rand32
);
mpz_clear
(
rand32
);
...
...
SGXWalletServer.cpp
View file @
c81d1128
...
@@ -47,9 +47,9 @@
...
@@ -47,9 +47,9 @@
void
setFullOptions
(
int
_printDebugInfo
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_encryptKeys
)
{
void
setFullOptions
(
int
_printDebugInfo
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_encryptKeys
)
{
if
(
_printDebugInfo
)
if
(
_printDebugInfo
)
spdlog
::
set_level
(
spdlog
::
level
::
info
);
else
{
spdlog
::
set_level
(
spdlog
::
level
::
debug
);
spdlog
::
set_level
(
spdlog
::
level
::
debug
);
else
{
spdlog
::
set_level
(
spdlog
::
level
::
info
);
}
}
printDebugInfo
=
_printDebugInfo
;
printDebugInfo
=
_printDebugInfo
;
useHTTPS
=
_useHTTPS
;
useHTTPS
=
_useHTTPS
;
...
@@ -481,13 +481,13 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
...
@@ -481,13 +481,13 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
return
result
;
return
result
;
}
}
Json
::
Value
SGXWalletServer
::
getSecretShareImpl
(
const
string
&
_polyName
,
const
Json
::
Value
&
_pub
lic
Keys
,
int
_t
,
int
_n
)
{
Json
::
Value
SGXWalletServer
::
getSecretShareImpl
(
const
string
&
_polyName
,
const
Json
::
Value
&
_pubKeys
,
int
_t
,
int
_n
)
{
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
try
{
try
{
if
(
_pub
lic
Keys
.
size
()
!=
(
uint64_t
)
_n
)
{
if
(
_pubKeys
.
size
()
!=
(
uint64_t
)
_n
)
{
throw
RPCException
(
INVALID_DKG_PARAMS
,
"invalid number of public keys"
);
throw
RPCException
(
INVALID_DKG_PARAMS
,
"invalid number of public keys"
);
}
}
if
(
!
checkName
(
_polyName
,
"POLY"
))
{
if
(
!
checkName
(
_polyName
,
"POLY"
))
{
...
@@ -499,16 +499,15 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
...
@@ -499,16 +499,15 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
shared_ptr
<
string
>
encr_poly_ptr
=
readFromDb
(
_polyName
);
shared_ptr
<
string
>
encr_poly_ptr
=
readFromDb
(
_polyName
);
vector
<
string
>
pubKeys
_vect
;
vector
<
string
>
pubKeys
Strs
;
for
(
int
i
=
0
;
i
<
_n
;
i
++
)
{
for
(
int
i
=
0
;
i
<
_n
;
i
++
)
{
std
::
cerr
<<
"publicKeys "
<<
i
<<
" is "
<<
_publicKeys
[
i
].
asString
()
<<
std
::
endl
;
if
(
!
checkHex
(
_pubKeys
[
i
].
asString
(),
64
))
{
if
(
!
checkHex
(
_publicKeys
[
i
].
asString
(),
64
))
{
throw
RPCException
(
INVALID_HEX
,
"Invalid public key"
);
throw
RPCException
(
INVALID_HEX
,
"Invalid public key"
);
}
}
pubKeys
_vect
.
push_back
(
_public
Keys
[
i
].
asString
());
pubKeys
Strs
.
push_back
(
_pub
Keys
[
i
].
asString
());
}
}
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
Strs
,
_t
,
_n
);
//cerr << "result is " << s << endl;
//cerr << "result is " << s << endl;
result
[
"secretShare"
]
=
s
;
result
[
"secretShare"
]
=
s
;
...
@@ -547,7 +546,7 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
...
@@ -547,7 +546,7 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
_ethKeyName
);
shared_ptr
<
string
>
encryptedKeyHex_ptr
=
readFromDb
(
_ethKeyName
);
if
(
!
V
erifyShares
(
_publicShares
.
c_str
(),
_secretShare
.
c_str
(),
encryptedKeyHex_ptr
->
c_str
(),
_t
,
_n
,
_index
))
{
if
(
!
v
erifyShares
(
_publicShares
.
c_str
(),
_secretShare
.
c_str
(),
encryptedKeyHex_ptr
->
c_str
(),
_t
,
_n
,
_index
))
{
result
[
"result"
]
=
false
;
result
[
"result"
]
=
false
;
}
}
...
...
SGXWalletServer.hpp
View file @
c81d1128
...
@@ -112,7 +112,7 @@ public:
...
@@ -112,7 +112,7 @@ public:
static
Json
::
Value
getVerificationVectorImpl
(
const
string
&
_polyName
,
int
_t
,
int
_n
);
static
Json
::
Value
getVerificationVectorImpl
(
const
string
&
_polyName
,
int
_t
,
int
_n
);
static
Json
::
Value
getSecretShareImpl
(
const
string
&
_polyName
,
const
Json
::
Value
&
_pub
lic
Keys
,
int
_t
,
int
_n
);
static
Json
::
Value
getSecretShareImpl
(
const
string
&
_polyName
,
const
Json
::
Value
&
_pubKeys
,
int
_t
,
int
_n
);
static
Json
::
Value
static
Json
::
Value
dkgVerificationImpl
(
const
string
&
_publicShares
,
const
string
&
_ethKeyName
,
const
string
&
_secretShare
,
dkgVerificationImpl
(
const
string
&
_publicShares
,
const
string
&
_ethKeyName
,
const
string
&
_secretShare
,
...
...
docker/start.sh
View file @
c81d1128
...
@@ -5,25 +5,25 @@ cd /usr/src/sdk;
...
@@ -5,25 +5,25 @@ cd /usr/src/sdk;
echo
$1
echo
$1
if
[
"
$1
"
=
-t
]
;
then
if
[
"
$1
"
=
-t
]
;
then
set
-e
set
-e
#
./testw [bls-key-encrypt]
./testw
[
bls-key-encrypt]
#
./testw [bls-key-encrypt-decrypt]
./testw
[
bls-key-encrypt-decrypt]
#
./testw [dkg-gen]
./testw
[
dkg-gen]
#
./testw [dkg-pub_shares]
./testw
[
dkg-pub_shares]
#
./testw [dkg-verify]
./testw
[
dkg-verify]
#
./testw [ecdsa_test]
./testw
[
ecdsa_test]
#
./testw [test_test]
./testw
[
test_test]
#
./testw [get_pub_ecdsa_key_test]
./testw
[
get_pub_ecdsa_key_test]
#
./testw [bls_dkg]
./testw
[
bls_dkg]
#
./testw [api_test]
./testw
[
api_test]
#
./testw [getServerStatus_test]
./testw
[
getServerStatus_test]
#
./testw [dkg_api_test]
./testw
[
dkg_api_test]
#
./testw [is_poly_test]
./testw
[
is_poly_test]
#
./testw [AES-encrypt-decrypt]
./testw
[
AES-encrypt-decrypt]
#
./testw [ecdsa_api_test]
./testw
[
ecdsa_api_test]
#
./testw [dkg-encr_sshares]
./testw
[
dkg-encr_sshares]
#./testw [bls_sign]
#./testw [bls_sign]
#.
/testw [many_threads_test]
/testw
[
many_threads_test]
#
./testw [aes_dkg]
./testw
[
aes_dkg]
else
else
./sgxwallet
$1
$2
$3
$4
./sgxwallet
$1
$2
$3
$4
fi
fi
...
...
sgxwallet_common.h
View file @
c81d1128
...
@@ -46,7 +46,7 @@ extern int autoconfirm;
...
@@ -46,7 +46,7 @@ extern int autoconfirm;
#define BUF_LEN
1024
#define BUF_LEN
4096
#define MAX_KEY_LENGTH 128
#define MAX_KEY_LENGTH 128
#define MAX_COMPONENT_LENGTH 80
#define MAX_COMPONENT_LENGTH 80
...
@@ -58,9 +58,6 @@ extern int autoconfirm;
...
@@ -58,9 +58,6 @@ extern int autoconfirm;
#define ADD_ENTROPY_SIZE 32
#define ADD_ENTROPY_SIZE 32
#define DKG_BUFER_LENGTH 2490//3060
#define DKG_MAX_SEALED_LEN 3050
#define SECRET_SHARE_NUM_BYTES 96
#define SECRET_SHARE_NUM_BYTES 96
#define ECDSA_SKEY_LEN 65
#define ECDSA_SKEY_LEN 65
...
...
testw.cpp
View file @
c81d1128
...
@@ -179,23 +179,22 @@ TEST_CASE("DKG gen test", "[dkg-gen]") {
...
@@ -179,23 +179,22 @@ TEST_CASE("DKG gen test", "[dkg-gen]") {
initAll
(
false
,
true
);
initAll
(
false
,
true
);
vector
<
uint8_t
>
encrypted
_dkg_secret
(
DKG_MAX_SEALED
_LEN
,
0
);
vector
<
uint8_t
>
encrypted
DKGSecret
(
BUF
_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
int
err_status
=
0
;
int
err_status
=
0
;
uint32_t
enc_len
=
0
;
uint32_t
enc_len
=
0
;
status
=
gen_dkg_secret
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted
_dkg_s
ecret
.
data
(),
&
enc_len
,
32
);
status
=
gen_dkg_secret
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted
DKGS
ecret
.
data
(),
&
enc_len
,
32
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
// printf("gen_dkg_secret completed with status: %d %s \n", err_status, errMsg.data());
// printf("gen_dkg_secret completed with status: %d %s \n", err_status, errMsg.data());
// printf("\n Length: %d \n", enc_len);
// printf("\n Length: %d \n", enc_len);
vector
<
char
>
secret
(
DKG_BUFER_LENGTH
,
0
);
vector
<
char
>
secret
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg1
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg1
(
BUF_LEN
,
0
);
uint32_t
dec_len
;
uint32_t
dec_len
;
status
=
decrypt_dkg_secret
(
eid
,
&
err_status
,
errMsg1
.
data
(),
encrypted
_dkg_s
ecret
.
data
(),
status
=
decrypt_dkg_secret
(
eid
,
&
err_status
,
errMsg1
.
data
(),
encrypted
DKGS
ecret
.
data
(),
(
uint8_t
*
)
secret
.
data
(),
&
dec_len
);
(
uint8_t
*
)
secret
.
data
(),
&
dec_len
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
...
@@ -270,7 +269,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub_shares]") {
...
@@ -270,7 +269,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub_shares]") {
libff
::
init_alt_bn128_params
();
libff
::
init_alt_bn128_params
();
vector
<
uint8_t
>
encrypted_dkg_secret
(
DKG_MAX_SEALED
_LEN
,
0
);
vector
<
uint8_t
>
encrypted_dkg_secret
(
BUF
_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
int
err_status
=
0
;
int
err_status
=
0
;
...
@@ -295,17 +294,17 @@ TEST_CASE("DKG public shares test", "[dkg-pub_shares]") {
...
@@ -295,17 +294,17 @@ TEST_CASE("DKG public shares test", "[dkg-pub_shares]") {
// printf(" LEN: %d \n", (int) strlen(public_shares.data()));
// printf(" LEN: %d \n", (int) strlen(public_shares.data()));
// printf(" result: %s \n", public_shares.data());
// printf(" result: %s \n", public_shares.data());
vector
<
string
>
G2_strings
=
S
plitString
(
public_shares
.
data
(),
','
);
vector
<
string
>
G2_strings
=
s
plitString
(
public_shares
.
data
(),
','
);
vector
<
libff
::
alt_bn128_G2
>
pub_shares_G2
;
vector
<
libff
::
alt_bn128_G2
>
pub_shares_G2
;
for
(
u_int64_t
i
=
0
;
i
<
G2_strings
.
size
();
i
++
)
{
for
(
u_int64_t
i
=
0
;
i
<
G2_strings
.
size
();
i
++
)
{
vector
<
string
>
koef_str
=
S
plitString
(
G2_strings
.
at
(
i
).
c_str
(),
':'
);
vector
<
string
>
koef_str
=
s
plitString
(
G2_strings
.
at
(
i
).
c_str
(),
':'
);
//libff::alt_bn128_G2 el = VectStringToG2(koef_str);
//libff::alt_bn128_G2 el = VectStringToG2(koef_str);
//cerr << "pub_share G2 " << i+1 << " : " << endl;
//cerr << "pub_share G2 " << i+1 << " : " << endl;
//el.print_coordinates();
//el.print_coordinates();
pub_shares_G2
.
push_back
(
VectStringToG2
(
koef_str
));
pub_shares_G2
.
push_back
(
VectStringToG2
(
koef_str
));
}
}
vector
<
char
>
secret
(
DKG_MAX_SEALED
_LEN
,
0
);
vector
<
char
>
secret
(
BUF
_LEN
,
0
);
status
=
decrypt_dkg_secret
(
eid
,
&
err_status
,
errMsg1
.
data
(),
encrypted_dkg_secret
.
data
(),
status
=
decrypt_dkg_secret
(
eid
,
&
err_status
,
errMsg1
.
data
(),
encrypted_dkg_secret
.
data
(),
(
uint8_t
*
)
secret
.
data
(),
&
enc_len
);
(
uint8_t
*
)
secret
.
data
(),
&
enc_len
);
...
@@ -348,7 +347,7 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr_sshares]") {
...
@@ -348,7 +347,7 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr_sshares]") {
int
err_status
=
0
;
int
err_status
=
0
;
uint32_t
enc_len
=
0
;
uint32_t
enc_len
=
0
;
vector
<
uint8_t
>
encrypted_dkg_secret
(
DKG_MAX_SEALED
_LEN
,
0
);
vector
<
uint8_t
>
encrypted_dkg_secret
(
BUF
_LEN
,
0
);
status
=
gen_dkg_secret
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
2
);
status
=
gen_dkg_secret
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
2
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
// cerr << " poly generated" << endl;
// cerr << " poly generated" << endl;
...
@@ -385,7 +384,7 @@ TEST_CASE("DKG verification test", "[dkg-verify]") {
...
@@ -385,7 +384,7 @@ TEST_CASE("DKG verification test", "[dkg-verify]") {
int
err_status
=
0
;
int
err_status
=
0
;
uint32_t
enc_len
=
0
;
uint32_t
enc_len
=
0
;
vector
<
uint8_t
>
encrypted_dkg_secret
(
DKG_MAX_SEALED_LEN
,
1
);
vector
<
uint8_t
>
encrypted_dkg_secret
(
BUF_LEN
,
0
);
status
=
gen_dkg_secret
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
2
);
status
=
gen_dkg_secret
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
2
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
...
@@ -485,31 +484,24 @@ TEST_CASE("get public ECDSA key", "[get_pub_ecdsa_key_test]") {
...
@@ -485,31 +484,24 @@ TEST_CASE("get public ECDSA key", "[get_pub_ecdsa_key_test]") {
setOptions
(
false
,
false
,
true
);
setOptions
(
false
,
false
,
true
);
initAll
(
false
,
true
);
initAll
(
false
,
true
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
enc
r_pr_k
ey
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
enc
PrivK
ey
(
BUF_LEN
,
0
);
vector
<
char
>
pub
_key_x
(
BUF_LEN
,
0
);
vector
<
char
>
pub
KeyX
(
BUF_LEN
,
0
);
vector
<
char
>
pub
_key_y
(
BUF_LEN
,
0
);
vector
<
char
>
pub
KeyY
(
BUF_LEN
,
0
);
uint32_t
enc
_l
en
=
0
;
uint32_t
enc
L
en
=
0
;
status
=
generate_ecdsa_key
(
eid
,
&
err_status
,
errMsg
.
data
(),
encr_pr_key
.
data
(),
&
enc_len
,
pub_key_x
.
data
(),
status
=
generate_ecdsa_key
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encPrivKey
.
data
(),
&
encLen
,
pubKeyX
.
data
(),
pub_key_y
.
data
());
pubKeyY
.
data
());
// printf("\nerrMsg %s\n", errMsg.data());
REQUIRE
(
status
==
SGX_SUCCESS
);
//printf("\nwas pub_key_x %s length %d: \n", pub_key_x.data(), (int) strlen(pub_key_x.data()));
REQUIRE
(
status
==
SGX_SUCCESS
);
//printf("\nwas pub_key_y %s length %d: \n", pub_key_y.data(), (int) strlen(pub_key_y.data()));
/*printf("\nencr priv_key %s: \n");
for ( int i = 0; i < BUF_LEN ; i++)
printf("%u ", encr_pr_key[i]);*/
vector
<
char
>
got_pub_key_x
(
BUF_LEN
,
0
);
vector
<
char
>
receivedPubKeyX
(
BUF_LEN
,
0
);
vector
<
char
>
got_pub_key_y
(
BUF_LEN
,
0
);
vector
<
char
>
receivedPubKeyY
(
BUF_LEN
,
0
);
status
=
get_public_ecdsa_key
(
eid
,
&
err
_status
,
errMsg
.
data
(),
encr_pr_key
.
data
(),
enc_len
,
got_pub_key_x
.
data
(),
status
=
get_public_ecdsa_key
(
eid
,
&
err
Status
,
errMsg
.
data
(),
encPrivKey
.
data
(),
encLen
,
receivedPubKeyX
.
data
(),
got_pub_key_y
.
data
());
receivedPubKeyY
.
data
());
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
//printf("\nnow pub_key_x %s: \n", got_pub_key_x.data());
//printf("\nnow pub_key_x %s: \n", got_pub_key_x.data());
//printf("\nnow pub_key_y %s: \n", got_pub_key_y.data());
//printf("\nnow pub_key_y %s: \n", got_pub_key_y.data());
...
@@ -825,20 +817,10 @@ void SendRPCRequest() {
...
@@ -825,20 +817,10 @@ void SendRPCRequest() {
BLSSigShare
sig
(
sig_share_ptr
,
i
+
1
,
t
,
n
);
BLSSigShare
sig
(
sig_share_ptr
,
i
+
1
,
t
,
n
);
sigShareSet
.
addSigShare
(
make_shared
<
BLSSigShare
>
(
sig
));
sigShareSet
.
addSigShare
(
make_shared
<
BLSSigShare
>
(
sig
));
// vector<string> pubKey_vect;
// for ( uint8_t j = 0; j < 4; j++){
// pubKey_vect.push_back(pubBLSKeys[i]["blsPublicKeyShare"][j].asString());
// }
// BLSPublicKeyShare pubKey(make_shared<vector<string>>(pubKey_vect), t, n);
// REQUIRE( pubKey.VerifySigWithHelper(hash_arr, make_shared<BLSSigShare>(sig) , t, n));
//koefs_pkeys_map[i+1] = make_shared<BLSPublicKeyShare>(pubKey);
}
}
shared_ptr
<
BLSSignature
>
commonSig
=
sigShareSet
.
merge
();
shared_ptr
<
BLSSignature
>
commonSig
=
sigShareSet
.
merge
();
// BLSPublicKey common_public(make_shared<map<size_t, shared_ptr<BLSPublicKeyShare>>>(koefs_pkeys_map), t, n);
// REQUIRE( common_public.VerifySigWithHelper(hash_arr, commonSig, t, n) );
}
}
...
@@ -1185,95 +1167,4 @@ TEST_CASE("AES encrypt/decrypt", "[AES-encrypt-decrypt]") {
...
@@ -1185,95 +1167,4 @@ TEST_CASE("AES encrypt/decrypt", "[AES-encrypt-decrypt]") {
}
}
//TEST_CASE("BLS key import", "[bls-key-import]") {
// reset_db();
// init_all(false, true);
//
//
//
// auto result = importBLSKeyShareImpl(TEST_BLS_KEY_SHARE, TEST_BLS_KEY_NAME, 2, 2, 1);
//
// REQUIRE(result["status"] == 0);
//
// REQUIRE(result["encryptedKeyShare"] != "");
//
//
//TEST_CASE("BLS sign test", "[bls-sign]") {
//
// //init_all();
// init_enclave();
//
// char* encryptedKeyHex ="04000200000000000406ffffff02000000000000000000000b000000000000ff0000000000000000813f8390f6228a568e181a4dadb6508e3e66f5247175d65dbd0d8c7fbfa4df45000000f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000008000000000000000000000000000000000dc044ae0cd79faaf41e8a7abb412790476738a98b5b6ce95fa1a32db5551b0a0d867305f4de558c64fee730a1f62394633c7d4ca65e3a40b7883e89c2801c61918b01c5de8624a52963df6f4de8581bcbdd2f9b69720d4cc764e03a04c7a99314bfdb5d2d55deda2ca40cd691f093fb2ecbae24cdacdd4d5de93189c6dfd6792d7b95bd5e330aec3538e7a85d15793"; //encryptTestKey();
//
// REQUIRE(encryptedKeyHex != nullptr);
//
//
// // const char *hexHash = "001122334455667788" "001122334455667788" "001122334455667788" "001122334455667788";
// const char *hexHash = "3F891FDA3704F0368DAB65FA81EBE616F4AA2A0854995DA4DC0B59D2CADBD64F";
//
// char* hexHashBuf = (char*) calloc(BUF_LEN, 1);
//
// strncpy(hexHashBuf, hexHash, BUF_LEN);
//
// char sig[BUF_LEN];
// auto result = sign(encryptedKeyHex, hexHashBuf, 2, 2, 1, sig);
//
// REQUIRE(result == true);
// printf("Signature is: %s \n", sig );
//
//}
//
//TEST_CASE("Server BLS sign test", "[bls-server-sign]") {
//
// reset_db();
//
// init_all(false, true);
//
//
// auto result = importBLSKeyShareImpl( TEST_BLS_KEY_SHARE, TEST_BLS_KEY_NAME, 2, 2, 1);
//
// REQUIRE(result["status"] == 0);
//
// REQUIRE(result["encryptedKeyShare"] != "");
//
// const char *hexHash = "001122334455667788" "001122334455667788" "001122334455667788" "001122334455667788";
//
// REQUIRE_NOTHROW(result = blsSignMessageHashImpl(TEST_BLS_KEY_NAME, hexHash,2,2,1));
//
// if (result["status"] != 0) {
// printf("Error message: %s", result["errorMessage"].asString().c_str());
// }
//
//
// REQUIRE(result["status"] == 0);
// REQUIRE(result["signatureShare"] != "");
//
// printf("Signature is: %s \n", result["signatureShare"].asString().c_str());
//
//}
//TEST_CASE("KeysDB test", "[keys-db]") {
//
//
//
// reset_db();
// init_all();
//
//
// string key = TEST_BLS_KEY_SHARE;
// string value = TEST_BLS_KEY_SHARE;
//
//
//
// REQUIRE_THROWS(readKeyShare(key));
//
//
// writeKeyShare(key, value, 1, 2, 1);
//
// REQUIRE(readKeyShare(key) != nullptr);
//
//
//// put your test here
//}
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