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
3ca52107
Unverified
Commit
3ca52107
authored
Jan 25, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed add README toc
parent
840852b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
40 deletions
+21
-40
DKGCrypto.cpp
DKGCrypto.cpp
+12
-29
SEKManager.cpp
SEKManager.cpp
+9
-11
No files found.
DKGCrypto.cpp
View file @
3ca52107
...
...
@@ -76,37 +76,26 @@ string ConvertToString(T field_elem, int base = 10) {
}
string
gen_dkg_poly
(
int
_t
){
char
*
errMsg
=
(
char
*
)
calloc
(
1024
,
1
);
vector
<
char
>
errMsg
(
1024
,
0
);
int
err_status
=
0
;
uint8_t
*
encrypted_dkg_secret
=
(
uint8_t
*
)
calloc
(
DKG_MAX_SEALED_LEN
,
1
);
;
vector
<
uint8_t
>
encrypted_dkg_secret
(
DKG_MAX_SEALED_LEN
,
0
)
;
uint32_t
enc_len
=
0
;
status
=
gen_dkg_secret
(
eid
,
&
err_status
,
errMsg
,
encrypted_dkg_secret
,
&
enc_len
,
_t
);
status
=
gen_dkg_secret
(
eid
,
&
err_status
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
()
,
&
enc_len
,
_t
);
if
(
err_status
!=
0
){
throw
RPCException
(
-
666
,
errMsg
)
;
throw
RPCException
(
-
666
,
errMsg
.
data
()
)
;
}
if
(
DEBUG_PRINT
)
{
spdlog
::
info
(
"gen_dkg_secret, status {}"
,
err_status
,
" err msg "
,
errMsg
);
/* cerr << "encr raw poly: " << endl;
for ( int i = 0 ; i < 3050; i++)
printf(" %d ", encrypted_dkg_secret[i] );*/
spdlog
::
info
(
"gen_dkg_secret, status {}"
,
err_status
,
" err msg "
,
errMsg
.
data
());
spdlog
::
info
(
"in DKGCrypto encr len is {}"
,
enc_len
);
}
char
*
hexEncrPoly
=
(
char
*
)
calloc
(
DKG_MAX_SEALED_LEN
*
2
+
1
,
1
);
//(4*BUF_LEN, 1);
carray2Hex
(
encrypted_dkg_secret
,
DKG_MAX_SEALED_LEN
,
hexEncrPoly
);
string
result
(
hexEncrPoly
);
vector
<
char
>
hexEncrPoly
(
DKG_MAX_SEALED_LEN
*
2
+
1
,
0
);
//(4*BUF_LEN, 1);
free
(
errMsg
);
free
(
encrypted_dkg_secret
);
free
(
hexEncrPoly
);
carray2Hex
(
encrypted_dkg_secret
.
data
(),
DKG_MAX_SEALED_LEN
,
hexEncrPoly
.
data
());
string
result
(
hexEncrPoly
.
data
());
return
result
;
}
...
...
@@ -137,7 +126,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
printf(" %d ", encr_dkg_poly[i] );*/
}
uint32_t
len
;
uint32_t
len
=
0
;
status
=
get_public_shares
(
eid
,
&
err_status
,
errMsg1
,
encr_dkg_poly
,
len
,
public_shares
,
t
,
n
);
if
(
err_status
!=
0
){
throw
RPCException
(
-
666
,
errMsg1
);
...
...
@@ -331,8 +320,6 @@ vector<string> GetBLSPubKey(const char * encryptedKeyHex){
if
(
!
hex2carray
(
encryptedKeyHex
,
&
dec_key_len
,
encr_key
)){
throw
RPCException
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
}
// for ( int i = 0; i < BUF_LEN; i++ )
// cerr << encr_key[i] << " ";
char
pub_key
[
320
];
if
(
DEBUG_PRINT
)
{
...
...
@@ -355,7 +342,7 @@ vector<string> GetBLSPubKey(const char * encryptedKeyHex){
string
decrypt_DHKey
(
const
string
&
polyName
,
int
ind
){
char
*
errMsg1
=
(
char
*
)
calloc
(
1024
,
1
);
vector
<
char
>
errMsg1
(
1024
,
0
);
int
err_status
=
0
;
string
DH_key_name
=
polyName
+
"_"
+
to_string
(
ind
)
+
":"
;
...
...
@@ -364,7 +351,7 @@ string decrypt_DHKey(const string& polyName, int ind){
spdlog
::
info
(
"encr DH key is {}"
,
*
hexEncrKey_ptr
);
}
char
*
hexEncrKey
=
(
char
*
)
calloc
(
2
*
BUF_LEN
,
1
);
vector
<
char
>
hexEncrKey
(
2
*
BUF_LEN
,
0
);
uint64_t
DH_enc_len
=
0
;
uint8_t
encrypted_DHkey
[
BUF_LEN
];
...
...
@@ -374,15 +361,11 @@ string decrypt_DHKey(const string& polyName, int ind){
char
DHKey
[
ECDSA_SKEY_LEN
];
decrypt_key
(
eid
,
&
err_status
,
errMsg1
,
encrypted_DHkey
,
DH_enc_len
,
DHKey
);
decrypt_key
(
eid
,
&
err_status
,
errMsg1
.
data
()
,
encrypted_DHkey
,
DH_enc_len
,
DHKey
);
if
(
err_status
!=
0
){
free
(
hexEncrKey
);
throw
RPCException
(
ERROR_IN_ENCLAVE
,
"decrypt key failed in enclave"
);
}
free
(
errMsg1
);
free
(
hexEncrKey
);
return
DHKey
;
}
...
...
SEKManager.cpp
View file @
3ca52107
...
...
@@ -34,25 +34,23 @@
void
generate_SEK
(){
char
*
errMsg
=
(
char
*
)
calloc
(
1024
,
1
);
vector
<
char
>
errMsg
(
1024
,
0
);
int
err_status
=
0
;
uint8_t
*
encr_SEK
=
(
uint8_t
*
)
calloc
(
1024
,
1
);
vector
<
uint8_t
>
encr_SEK
(
1024
,
0
);
uint32_t
enc_len
=
0
;
status
=
generate_SEK
(
eid
,
&
err_status
,
errMsg
,
encr_SEK
,
&
enc_len
);
status
=
generate_SEK
(
eid
,
&
err_status
,
errMsg
.
data
(),
encr_SEK
.
data
()
,
&
enc_len
);
if
(
err_status
!=
0
){
cerr
<<
"RPCException thrown"
<<
endl
;
throw
RPCException
(
-
666
,
errMsg
)
;
throw
RPCException
(
-
666
,
errMsg
.
data
()
)
;
}
char
*
hexEncrKey
=
(
char
*
)
calloc
(
2
*
enc_len
+
1
,
1
);
carray2Hex
(
encr_SEK
,
enc_len
,
hexEncrKey
);
vector
<
char
>
hexEncrKey
(
2
*
enc_len
+
1
,
0
);
c
err
<<
"key is "
<<
errMsg
<<
endl
;
c
array2Hex
(
encr_SEK
.
data
(),
enc_len
,
hexEncrKey
.
data
())
;
LevelDB
::
getLevelDb
()
->
writeDataUnique
(
"SEK"
,
hexEncrKey
);
cerr
<<
"key is "
<<
errMsg
.
data
()
<<
endl
;
LevelDB
::
getLevelDb
()
->
writeDataUnique
(
"SEK"
,
hexEncrKey
.
data
());
free
(
errMsg
);
free
(
encr_SEK
);
free
(
hexEncrKey
);
}
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