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
8bd21997
Unverified
Commit
8bd21997
authored
4 years ago
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2794 clean up code
parent
fc1458a2
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
102 additions
and
181 deletions
+102
-181
BLSCrypto.cpp
BLSCrypto.cpp
+5
-38
BLSCrypto.h
BLSCrypto.h
+0
-2
BLSPrivateKeyShareSGX.h
BLSPrivateKeyShareSGX.h
+0
-4
CSRManagerServer.cpp
CSRManagerServer.cpp
+0
-9
DKGCrypto.h
DKGCrypto.h
+0
-3
SEKManager.h
SEKManager.h
+0
-4
DHDkg.h
secure_enclave/DHDkg.h
+0
-2
EnclaveCommon.h
secure_enclave/EnclaveCommon.h
+0
-10
secure_enclave.c
secure_enclave/secure_enclave.c
+0
-7
secure_enclave.edl
secure_enclave/secure_enclave.edl
+97
-102
No files found.
BLSCrypto.cpp
View file @
8bd21997
...
...
@@ -119,7 +119,7 @@ bool hex2carray(const char *_hex, uint64_t *_bin_len,
bool
hex2carray2
(
const
char
*
_hex
,
uint64_t
*
_bin_len
,
uint8_t
*
_bin
,
const
int
_max_length
)
{
int
len
=
strnlen
(
_hex
,
_max_length
);
//2 * BUF_LEN);
int
len
=
strnlen
(
_hex
,
_max_length
);
if
(
len
==
0
&&
len
%
2
==
1
)
...
...
@@ -161,13 +161,6 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t
strncpy
(
_sig
,
sigShareStr
->
c_str
(),
BUF_LEN
);
//string sigShareStr = keyShare->signWithHelperSGXstr(hash, _signerIndex);
//strncpy(_sig, sigShareStr.c_str(), BUF_LEN);
// string test_sig = "8175162913343900215959836578795929492705714455632345516427532159927644835012:15265825550804683171644566522808807137117748565649051208189914766494241035855:9810286616503120081238481858289626967170509983220853777870754480048381194141:5";
// auto sig_ptr = make_shared<string>(test_sig);
// strncpy(_sig, sig_ptr->c_str(), BUF_LEN);
return
true
;
}
...
...
@@ -269,44 +262,18 @@ char *encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key)
spdlog
::
debug
(
"errStatus is {}"
,
*
errStatus
);
spdlog
::
debug
(
" errMsg is "
,
errMsg
->
data
());
if
(
*
errStatus
!=
0
)
{
throw
SGXException
(
-
666
,
errMsg
->
data
());
}
if
(
status
!=
SGX_SUCCESS
)
{
*
errStatus
=
-
1
;
return
nullptr
;
}
if
(
*
errStatus
!=
0
)
{
throw
SGXException
(
-
666
,
errMsg
->
data
());
}
char
*
result
=
(
char
*
)
calloc
(
2
*
BUF_LEN
,
1
);
carray2Hex
(
encryptedKey
->
data
(),
encryptedLen
,
result
);
return
result
;
}
char
*
decryptBLSKeyShareFromHex
(
int
*
errStatus
,
char
*
errMsg
,
const
char
*
_encryptedKey
)
{
*
errStatus
=
-
1
;
uint64_t
decodedLen
=
0
;
uint8_t
decoded
[
BUF_LEN
];
if
(
!
(
hex2carray
(
_encryptedKey
,
&
decodedLen
,
decoded
)))
{
return
nullptr
;
}
char
*
plaintextKey
=
(
char
*
)
calloc
(
BUF_LEN
,
1
);
status
=
trustedDecryptKeyAES
(
eid
,
errStatus
,
errMsg
,
decoded
,
decodedLen
,
plaintextKey
);
if
(
status
!=
SGX_SUCCESS
)
{
return
nullptr
;
}
if
(
*
errStatus
!=
0
)
{
return
nullptr
;
}
return
plaintextKey
;
}
This diff is collapsed.
Click to expand it.
BLSCrypto.h
View file @
8bd21997
...
...
@@ -48,6 +48,4 @@ EXTERNC bool hex2carray2(const char * _hex, uint64_t *_bin_len,
char
*
encryptBLSKeyShare2Hex
(
int
*
errStatus
,
char
*
err_string
,
const
char
*
_key
);
char
*
decryptBLSKeyShareFromHex
(
int
*
errStatus
,
char
*
errMsg
,
const
char
*
_encryptedKey
);
#endif //SGXWALLET_BLSCRYPTO_H
This diff is collapsed.
Click to expand it.
BLSPrivateKeyShareSGX.h
View file @
8bd21997
...
...
@@ -29,13 +29,11 @@
#include "BLSPrivateKeyShare.h"
class
BLSPrivateKeyShareSGX
{
size_t
requiredSigners
;
size_t
totalSigners
;
std
::
shared_ptr
<
std
::
string
>
encryptedKeyHex
;
public
:
std
::
shared_ptr
<
BLSSigShare
>
signWithHelperSGX
(
std
::
shared_ptr
<
std
::
array
<
uint8_t
,
32
>>
_hash
,
...
...
@@ -47,8 +45,6 @@ public:
BLSPrivateKeyShareSGX
(
std
::
shared_ptr
<
std
::
string
>
_encryptedKeyHex
,
size_t
_requiredSigners
,
size_t
_totalSigners
);
};
#endif // LIBBLS_BLSPRIVATEKEYSHARE_H
This diff is collapsed.
Click to expand it.
CSRManagerServer.cpp
View file @
8bd21997
...
...
@@ -21,29 +21,21 @@
@date 2019
*/
#include <iostream>
#include <fstream>
#include <jsonrpccpp/server/connectors/httpserver.h>
#include "CSRManagerServer.h"
#include "SGXException.h"
#include "sgxwallet_common.h"
#include "Log.h"
#include "common.h"
shared_ptr
<
CSRManagerServer
>
CSRManagerServer
::
cs
=
nullptr
;
shared_ptr
<
jsonrpc
::
HttpServer
>
CSRManagerServer
::
hs3
=
nullptr
;
CSRManagerServer
::
CSRManagerServer
(
AbstractServerConnector
&
connector
,
serverVersion_t
type
)
:
abstractCSRManagerServer
(
connector
,
type
)
{}
...
...
@@ -113,7 +105,6 @@ Json::Value signByHashImpl(const string &hash, int status) {
return
result
;
}
Json
::
Value
CSRManagerServer
::
getUnsignedCSRs
()
{
LOCK
(
m
)
return
getUnsignedCSRsImpl
();
...
...
This diff is collapsed.
Click to expand it.
DKGCrypto.h
View file @
8bd21997
...
...
@@ -47,9 +47,6 @@ vector<string> GetBLSPubKey(const char * encryptedKeyHex);
vector
<
string
>
mult_G2
(
const
string
&
x
);
bool
TestCreateBLSShare
(
const
char
*
s_shares
);
#endif //SGXD_DKGCRYPTO_H
This diff is collapsed.
Click to expand it.
SEKManager.h
View file @
8bd21997
...
...
@@ -24,14 +24,11 @@
#ifndef SGXD_SEKMANAGER_H
#define SGXD_SEKMANAGER_H
#ifdef __cplusplus
#include <string>
#include <memory>
#endif
void
gen_SEK
();
#ifdef __cplusplus
...
...
@@ -48,5 +45,4 @@ EXTERNC void enter_SEK();
EXTERNC
void
initSEK
();
#endif //SGXD_SEKMANAGER_H
This diff is collapsed.
Click to expand it.
secure_enclave/DHDkg.h
View file @
8bd21997
...
...
@@ -24,7 +24,6 @@
#ifndef SGXD_DRIVE_KEY_DKG_H
#define SGXD_DRIVE_KEY_DKG_H
//void gen_session_keys(mpz_t skey, char* pub_key);
void
gen_session_key
(
char
*
skey
,
char
*
pub_keyB
,
char
*
common_key
);
void
session_key_recover
(
const
char
*
skey_str
,
const
char
*
sshare
,
char
*
common_key
);
...
...
@@ -33,5 +32,4 @@ void xor_encrypt(char* key, char* message, char* cypher);
void
xor_decrypt
(
char
*
key
,
char
*
cypher
,
char
*
message
);
#endif //SGXD_DRIVE_KEY_DKG_H
This diff is collapsed.
Click to expand it.
secure_enclave/EnclaveCommon.h
View file @
8bd21997
...
...
@@ -24,20 +24,14 @@
#ifndef SGXWALLET_ENCLAVECOMMON_H
#define SGXWALLET_ENCLAVECOMMON_H
#ifdef __cplusplus
#define EXTERNC extern "C"
#else
#define EXTERNC
#endif
//#include <stdint.h>
EXTERNC
void
check_key
(
int
*
errStatus
,
char
*
err_string
,
const
char
*
_keyString
);
EXTERNC
bool
enclave_sign
(
const
char
*
_keyString
,
const
char
*
_hashXString
,
const
char
*
_hashYString
,
char
*
_sig
);
EXTERNC
int
char2int
(
char
_input
);
...
...
@@ -49,16 +43,12 @@ EXTERNC bool hex2carray2(const char * _hex, uint64_t *_bin_len,
uint8_t
*
_bin
,
const
int
_max_length
);
EXTERNC
void
enclave_init
();
EXTERNC
void
LOG_INFO
(
char
*
msg
);
EXTERNC
void
LOG_WARN
(
char
*
_msg
);
EXTERNC
void
LOG_ERROR
(
char
*
_msg
);
EXTERNC
void
LOG_DEBUG
(
char
*
_msg
);
EXTERNC
void
LOG_TRACE
(
char
*
_msg
);
extern
uint32_t
globalLogLevel_
;
#endif //SGXWALLET_ENCLAVECOMMON_H
This diff is collapsed.
Click to expand it.
secure_enclave/secure_enclave.c
View file @
8bd21997
...
...
@@ -58,7 +58,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
uint8_t
decryptedDkgPoly
[
DKG_BUFER_LENGTH
];
void
*
(
*
gmp_realloc_func
)(
void
*
,
size_t
,
size_t
);
void
*
(
*
oc_realloc_func
)(
void
*
,
size_t
,
size_t
);
...
...
@@ -71,16 +70,11 @@ void *reallocate_function(void *, size_t, size_t);
void
free_function
(
void
*
,
size_t
);
void
trustedEnclaveInit
(
uint32_t
_logLevel
)
{
LOG_DEBUG
(
__FUNCTION__
);
globalLogLevel_
=
_logLevel
;
oc_realloc_func
=
&
reallocate_function
;
oc_free_func
=
&
free_function
;
...
...
@@ -136,7 +130,6 @@ void trustedEMpzDiv(mpz_t *c_un, mpz_t *a_un, mpz_t *b_un) {}
void
trustedEMpfDiv
(
mpf_t
*
c_un
,
mpf_t
*
a_un
,
mpf_t
*
b_un
)
{}
void
trustedGenerateEcdsaKey
(
int
*
errStatus
,
char
*
errString
,
uint8_t
*
encryptedPrivateKey
,
uint32_t
*
enc_len
,
char
*
pub_key_x
,
char
*
pub_key_y
)
{
LOG_DEBUG
(
__FUNCTION__
);
...
...
This diff is collapsed.
Click to expand it.
secure_enclave/secure_enclave.edl
View file @
8bd21997
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