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
cf6c9982
Unverified
Commit
cf6c9982
authored
Jun 03, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2002 fix memory leaks
parent
8548f065
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
18 deletions
+24
-18
DHDkg.c
secure_enclave/DHDkg.c
+1
-1
DKGUtils.cpp
secure_enclave/DKGUtils.cpp
+4
-16
secure_enclave.c
secure_enclave/secure_enclave.c
+19
-1
No files found.
secure_enclave/DHDkg.c
View file @
cf6c9982
...
...
@@ -61,7 +61,7 @@ void gen_session_key(char *skey_str, char* pb_keyB, char* common_key){
point_multiplication
(
session_key
,
skey
,
pub_keyB
,
curve
);
char
arr_x
[
mpz_sizeinbase
(
session_key
->
x
,
16
)
+
2
];
char
*
x
=
mpz_get_str
(
arr_x
,
16
,
session_key
->
x
);
mpz_get_str
(
arr_x
,
16
,
session_key
->
x
);
int
n_zeroes
=
64
-
strlen
(
arr_x
);
for
(
int
i
=
0
;
i
<
n_zeroes
;
i
++
){
common_key
[
i
]
=
'0'
;
...
...
secure_enclave/DKGUtils.cpp
View file @
cf6c9982
...
...
@@ -194,10 +194,6 @@ void calc_secret_shareG2_old(const char* decrypted_coeffs, char * s_shareG2,
libff
::
init_alt_bn128_params
();
char
symbol
=
':'
;
vector
<
libff
::
alt_bn128_Fr
>
poly
=
SplitStringToFr
(
decrypted_coeffs
,
symbol
);
// if ( poly.size() != _t){
// //"t != poly.size()" +
// //strncpy(s_shareG2, to_string(poly.size()).c_str(), 18);
// }
libff
::
alt_bn128_Fr
secret_share
=
PolynomialValue
(
poly
,
libff
::
alt_bn128_Fr
(
ind
),
_t
);
...
...
@@ -232,6 +228,8 @@ int calc_secret_shareG2(const char* s_share, char * s_shareG2){
strncpy
(
s_shareG2
,
secret_shareG2_str
.
c_str
(),
secret_shareG2_str
.
length
()
+
1
);
mpz_clear
(
share
);
return
0
;
}
...
...
@@ -299,17 +297,6 @@ int Verification ( char * public_shares, mpz_t decr_secret_share, int _t, int in
pub_share
.
Y
.
c1
=
libff
::
alt_bn128_Fq
(
y_c1_str
.
c_str
());
pub_share
.
Z
=
libff
::
alt_bn128_Fq2
::
one
();
//for ( int j = 0; j < 4; j++) {
//uint64_t pos0 = share_length * j;
//string coord = ConvertHexToDec(pub_shares_str.substr(pos0 + j * coord_length, coord_length));
// if ( i == 0) {
// memset(public_shares, 0, strlen(public_shares));
// string coord = ConvertToString(pub_share.Y.c1);
// strncpy(public_shares, coord.c_str(), coord.length());
// }
//}
pub_shares
.
push_back
(
pub_share
);
}
...
...
@@ -361,7 +348,8 @@ int calc_bls_public_key(char* skey_hex, char* pub_key){
mpz_t
skey
;
mpz_init
(
skey
);
if
(
mpz_set_str
(
skey
,
skey_hex
,
16
)
==
-
1
){
if
(
mpz_set_str
(
skey
,
skey_hex
,
16
)
==
-
1
)
{
mpz_clear
(
skey
);
return
1
;
}
...
...
secure_enclave/secure_enclave.c
View file @
cf6c9982
...
...
@@ -979,6 +979,11 @@ void trustedGenerateEcdsaKeyAES(int *errStatus, char *errString,
if
(
stat
!=
0
)
{
snprintf
(
errString
,
BUF_LEN
,
"ecdsa private key encryption failed"
);
*
errStatus
=
stat
;
mpz_clear
(
skey
);
domain_parameters_clear
(
curve
);
point_clear
(
Pkey
);
return
;
}
...
...
@@ -1010,6 +1015,9 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
if
(
status
!=
0
)
{
snprintf
(
errString
,
BUF_LEN
,
"AES_decrypt failed with status %d"
,
status
);
*
errStatus
=
status
;
domain_parameters_clear
(
curve
);
return
;
}
...
...
@@ -1022,7 +1030,10 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
if
(
mpz_set_str
(
privateKeyMpz
,
skey
,
ECDSA_SKEY_BASE
)
==
-
1
)
{
snprintf
(
errString
,
BUF_LEN
,
"wrong string to init private key - %s"
,
skey
);
*
errStatus
=
-
10
;
mpz_clear
(
privateKeyMpz
);
domain_parameters_clear
(
curve
);
return
;
}
...
...
@@ -1037,6 +1048,11 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
if
(
!
point_cmp
(
Pkey
,
Pkey_test
))
{
snprintf
(
errString
,
BUF_LEN
,
"Points are not equal"
);
*
errStatus
=
-
11
;
mpz_clear
(
privateKeyMpz
);
domain_parameters_clear
(
curve
);
point_clear
(
Pkey
);
return
;
}
...
...
@@ -1120,11 +1136,13 @@ void trustedEcdsaSignAES(int *errStatus, char *errString, uint8_t *encryptedPriv
if
(
!
signature_verify
(
msgMpz
,
sign
,
Pkey
,
curve
))
{
*
errStatus
=
-
2
;
snprintf
(
errString
,
BUF_LEN
,
"signature is not verified! "
);
mpz_clear
(
privateKeyMpz
);
mpz_clear
(
msgMpz
);
domain_parameters_clear
(
curve
);
signature_free
(
sign
);
point_clear
(
Pkey
);
return
;
}
...
...
@@ -1264,7 +1282,7 @@ void
trustedGenDkgSecretAES
(
int
*
errStatus
,
char
*
errString
,
uint8_t
*
encrypted_dkg_secret
,
uint32_t
*
enc_len
,
size_t
_t
)
{
LOG_DEBUG
(
__FUNCTION__
);
char
dkg_secret
[
DKG_BUFER_LENGTH
];
// = (char*)calloc(DKG_BUFER_LENGTH, 1);
char
dkg_secret
[
DKG_BUFER_LENGTH
];
memset
(
dkg_secret
,
0
,
DKG_BUFER_LENGTH
);
if
(
gen_dkg_poly
(
dkg_secret
,
_t
)
!=
0
)
{
...
...
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