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
d0c753aa
Unverified
Commit
d0c753aa
authored
Aug 14, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3067-cleanup-sgx
parent
725a9722
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
20 deletions
+31
-20
ECDSACrypto.cpp
ECDSACrypto.cpp
+1
-0
EnclaveCommon.cpp
secure_enclave/EnclaveCommon.cpp
+27
-18
EnclaveCommon.h
secure_enclave/EnclaveCommon.h
+3
-0
secure_enclave.c
secure_enclave/secure_enclave.c
+0
-2
No files found.
ECDSACrypto.cpp
View file @
d0c753aa
...
@@ -67,6 +67,7 @@ vector <string> genECDSAKey() {
...
@@ -67,6 +67,7 @@ vector <string> genECDSAKey() {
vector
<
string
>
keys
(
3
);
vector
<
string
>
keys
(
3
);
vector
<
char
>
hexEncrKey
(
BUF_LEN
*
2
,
0
);
vector
<
char
>
hexEncrKey
(
BUF_LEN
*
2
,
0
);
carray2Hex
(
encr_pr_key
.
data
(),
enc_len
,
hexEncrKey
.
data
());
carray2Hex
(
encr_pr_key
.
data
(),
enc_len
,
hexEncrKey
.
data
());
keys
.
at
(
0
)
=
hexEncrKey
.
data
();
keys
.
at
(
0
)
=
hexEncrKey
.
data
();
keys
.
at
(
1
)
=
string
(
pub_key_x
.
data
())
+
string
(
pub_key_y
.
data
());
keys
.
at
(
1
)
=
string
(
pub_key_x
.
data
())
+
string
(
pub_key_y
.
data
());
...
...
secure_enclave/EnclaveCommon.cpp
View file @
d0c753aa
...
@@ -44,47 +44,56 @@ uint8_t *getThreadLocalDecryptedDkgPoly() {
...
@@ -44,47 +44,56 @@ uint8_t *getThreadLocalDecryptedDkgPoly() {
string
*
stringFromKey
(
libff
::
alt_bn128_Fr
*
_key
)
{
string
*
stringFromKey
(
libff
::
alt_bn128_Fr
*
_key
)
{
try
{
string
*
ret
=
nullptr
;
mpz_t
t
;
mpz_t
t
;
mpz_init
(
t
);
mpz_init
(
t
);
_key
->
as_bigint
().
to_mpz
(
t
);
SAFE_CHAR_BUF
(
arr
,
BUF_LEN
);
char
arr
[
mpz_sizeinbase
(
t
,
10
)
+
2
];
try
{
_key
->
as_bigint
().
to_mpz
(
t
);
char
*
tmp
=
mpz_get_str
(
arr
,
10
,
t
);
char
*
tmp
=
mpz_get_str
(
arr
,
10
,
t
);
mpz_clear
(
t
);
return
new
string
(
tmp
);
ret
=
new
string
(
tmp
);
goto
clean
;
}
catch
(
exception
&
e
)
{
}
catch
(
exception
&
e
)
{
LOG_ERROR
(
e
.
what
());
LOG_ERROR
(
e
.
what
());
return
nullptr
;
goto
clean
;
}
catch
(...)
{
}
catch
(...)
{
LOG_ERROR
(
"Unknown throwable"
);
LOG_ERROR
(
"Unknown throwable"
);
return
nullptr
;
goto
clean
;
}
}
clean:
mpz_clear
(
t
);
return
ret
;
}
}
string
*
stringFromFq
(
libff
::
alt_bn128_Fq
*
_fq
)
{
string
*
stringFromFq
(
libff
::
alt_bn128_Fq
*
_fq
)
{
string
*
ret
=
nullptr
;
mpz_t
t
;
mpz_init
(
t
);
SAFE_CHAR_BUF
(
arr
,
BUF_LEN
);
try
{
try
{
mpz_t
t
;
mpz_init
(
t
);
_fq
->
as_bigint
().
to_mpz
(
t
);
_fq
->
as_bigint
().
to_mpz
(
t
);
char
arr
[
mpz_sizeinbase
(
t
,
10
)
+
2
];
char
*
tmp
=
mpz_get_str
(
arr
,
10
,
t
);
char
*
tmp
=
mpz_get_str
(
arr
,
10
,
t
);
mpz_clear
(
t
);
ret
=
new
string
(
tmp
);
return
new
string
(
tmp
);
}
catch
(
exception
&
e
)
{
}
catch
(
exception
&
e
)
{
LOG_ERROR
(
e
.
what
());
LOG_ERROR
(
e
.
what
());
return
nullptr
;
goto
clean
;
}
catch
(...)
{
}
catch
(...)
{
LOG_ERROR
(
"Unknown throwable"
);
LOG_ERROR
(
"Unknown throwable"
);
return
nullptr
;
goto
clean
;
}
}
clean:
mpz_clear
(
t
);
return
ret
;
}
}
string
*
stringFromG1
(
libff
::
alt_bn128_G1
*
_g1
)
{
string
*
stringFromG1
(
libff
::
alt_bn128_G1
*
_g1
)
{
...
...
secure_enclave/EnclaveCommon.h
View file @
d0c753aa
...
@@ -64,5 +64,8 @@ extern unsigned char* globalRandom;
...
@@ -64,5 +64,8 @@ extern unsigned char* globalRandom;
extern
domain_parameters
curve
;
extern
domain_parameters
curve
;
#define SAFE_FREE(__X__) if (!__X__) {free(__X__); __X__ = NULL;}
#define SAFE_CHAR_BUF(__X__, __Y__) ;char __X__ [ __Y__ ]; memset(__X__, 0, __Y__);
#endif //SGXWALLET_ENCLAVECOMMON_H
#endif //SGXWALLET_ENCLAVECOMMON_H
secure_enclave/secure_enclave.c
View file @
d0c753aa
...
@@ -56,8 +56,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...
@@ -56,8 +56,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "EnclaveConstants.h"
#include "EnclaveConstants.h"
#include "EnclaveCommon.h"
#include "EnclaveCommon.h"
#define SAFE_FREE(__X__) if (!__X__) {free(__X__); __X__ = NULL;}
#define SAFE_CHAR_BUF(__X__, __Y__) ;char __X__ [ __Y__ ]; memset(__X__, 0, __Y__);
#define STRINGIFY(x) #x
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define TOSTRING(x) STRINGIFY(x)
...
...
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