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
91168a5e
Unverified
Commit
91168a5e
authored
Jan 24, 2020
by
svetaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2003 Add gen_dkg_poly_aes method
parent
e45107a8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
1 deletion
+76
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+11
-1
secure_enclave.c
secure_enclave/secure_enclave.c
+21
-0
secure_enclave.edl
secure_enclave/secure_enclave.edl
+11
-0
testw.cpp
testw.cpp
+33
-0
No files found.
SGXWalletServer.cpp
View file @
91168a5e
...
@@ -706,11 +706,21 @@ Json::Value MultG2Impl(const std::string& x){
...
@@ -706,11 +706,21 @@ Json::Value MultG2Impl(const std::string& x){
Json
::
Value
IsPolyExistsImpl
(
const
std
::
string
&
polyName
){
Json
::
Value
IsPolyExistsImpl
(
const
std
::
string
&
polyName
){
Json
::
Value
result
;
Json
::
Value
result
;
try
{
std
::
shared_ptr
<
std
::
string
>
poly_str_ptr
=
levelDb
->
readString
(
polyName
);
std
::
shared_ptr
<
std
::
string
>
poly_str_ptr
=
levelDb
->
readString
(
polyName
);
result
[
"IsExist"
]
=
true
;
result
[
"IsExist"
]
=
true
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
if
(
poly_str_ptr
==
nullptr
){
if
(
poly_str_ptr
==
nullptr
){
result
[
"IsExist"
]
=
false
;
result
[
"IsExist"
]
=
false
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
}
}
catch
(
RPCException
&
_e
)
{
std
::
cerr
<<
" err str "
<<
_e
.
errString
<<
std
::
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"IsExist"
]
=
false
;
}
}
return
result
;
return
result
;
...
...
secure_enclave/secure_enclave.c
View file @
91168a5e
...
@@ -1276,8 +1276,29 @@ void bls_sign_message_aes(int *err_status, char *err_string, uint8_t *encrypted_
...
@@ -1276,8 +1276,29 @@ void bls_sign_message_aes(int *err_status, char *err_string, uint8_t *encrypted_
*
err_status
=
-
1
;
*
err_status
=
-
1
;
return
;
return
;
}
}
}
void
gen_dkg_secret_aes
(
int
*
err_status
,
char
*
err_string
,
uint8_t
*
encrypted_dkg_secret
,
uint32_t
*
enc_len
,
size_t
_t
){
char
*
dkg_secret
=
(
char
*
)
calloc
(
DKG_BUFER_LENGTH
,
1
);
if
(
gen_dkg_poly
(
dkg_secret
,
_t
)
!=
0
){
*
err_status
=
-
1
;
return
;
}
snprintf
(
err_string
,
BUF_LEN
,
"poly is %s "
,
dkg_secret
);
int
status
=
AES_encrypt
(
dkg_secret
,
encrypted_dkg_secret
);
if
(
status
!=
SGX_SUCCESS
)
{
snprintf
(
err_string
,
BUF_LEN
,
"SGX AES encrypt DKG poly failed"
);
*
err_status
=
status
;
return
;
}
*
enc_len
=
strlen
(
dkg_secret
)
+
SGX_AESGCM_MAC_SIZE
+
SGX_AESGCM_IV_SIZE
;
free
(
dkg_secret
);
}
}
secure_enclave/secure_enclave.edl
View file @
91168a5e
...
@@ -213,6 +213,7 @@ enclave {
...
@@ -213,6 +213,7 @@ enclave {
uint32_t enc_len,
uint32_t enc_len,
[out, count = 1024] char* key );
[out, count = 1024] char* key );
public void bls_sign_message_aes (
public void bls_sign_message_aes (
[user_check] int *err_status,
[user_check] int *err_status,
[out, count = 1024] char* err_string,
[out, count = 1024] char* err_string,
...
@@ -221,6 +222,16 @@ enclave {
...
@@ -221,6 +222,16 @@ enclave {
[in, count = 1024] char* hashX ,
[in, count = 1024] char* hashX ,
[in, count = 1024] char* hashY ,
[in, count = 1024] char* hashY ,
[out, count = 1024] char* signature);
[out, count = 1024] char* signature);
public void gen_dkg_secret_aes (
[user_check] int *err_status,
[out, count = 1024] char* err_string,
[out, count = 3050] uint8_t* encrypted_dkg_secret,
[user_check] uint32_t * enc_len,
size_t _t);
};
};
...
...
testw.cpp
View file @
91168a5e
...
@@ -1217,7 +1217,40 @@ TEST_CASE("IsPolyExists test", "[is_poly_test]") {
...
@@ -1217,7 +1217,40 @@ TEST_CASE("IsPolyExists test", "[is_poly_test]") {
cout
<<
polyDoesNotExist
<<
std
::
endl
;
cout
<<
polyDoesNotExist
<<
std
::
endl
;
REQUIRE
(
!
polyDoesNotExist
[
"IsExist"
].
asBool
());
REQUIRE
(
!
polyDoesNotExist
[
"IsExist"
].
asBool
());
}
TEST_CASE
(
"AES_DKG test"
,
"[aes_dkg]"
)
{
is_sgx_https
=
0
;
DEBUG_PRINT
=
1
;
std
::
cerr
<<
"test started"
<<
std
::
endl
;
init_all
(
false
,
false
);
cerr
<<
"Server inited"
<<
endl
;
HttpClient
client
(
"http://localhost:1029"
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
cerr
<<
"Client inited"
<<
endl
;
reset_db
();
int
n
=
4
,
t
=
4
;
Json
::
Value
EthKeys
[
n
];
Json
::
Value
VerifVects
[
n
];
Json
::
Value
pubEthKeys
;
Json
::
Value
secretShares
[
n
];
Json
::
Value
pubBLSKeys
[
n
];
Json
::
Value
BLSSigShares
[
n
];
std
::
vector
<
std
::
string
>
pubShares
(
n
);
std
::
vector
<
std
::
string
>
poly_names
(
n
);
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
EthKeys
[
i
]
=
c
.
generateECDSAKey
();
std
::
string
polyName
=
"POLY:SCHAIN_ID:1:NODE_ID:"
+
std
::
to_string
(
i
)
+
":DKG_ID:0"
;
cout
<<
c
.
generateDKGPoly
(
polyName
,
t
);
// poly_names[i] = polyName;
// VerifVects[i] = c.getVerificationVector(polyName, t, n);
// cout << "VV " << i << " " << VerifVects[i] << std::endl;
// pubEthKeys.append(EthKeys[i]["PublicKey"]);
}
}
}
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