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
fb830e75
Unverified
Commit
fb830e75
authored
Jun 05, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2002 add tests
parent
f4c89a31
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
181 additions
and
34 deletions
+181
-34
BLSCrypto.cpp
BLSCrypto.cpp
+0
-23
testw.cpp
testw.cpp
+175
-11
testw.py
testw.py
+6
-0
No files found.
BLSCrypto.cpp
View file @
fb830e75
...
...
@@ -56,7 +56,6 @@
std
::
string
*
FqToString
(
libff
::
alt_bn128_Fq
*
_fq
)
{
mpz_t
t
;
mpz_init
(
t
);
...
...
@@ -82,7 +81,6 @@ int char2int(char _input) {
void
carray2Hex
(
const
unsigned
char
*
d
,
int
_len
,
char
*
_hexArray
)
{
char
hexval
[
16
]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
...
...
@@ -92,13 +90,11 @@ void carray2Hex(const unsigned char *d, int _len, char *_hexArray) {
}
_hexArray
[
_len
*
2
]
=
0
;
}
bool
hex2carray
(
const
char
*
_hex
,
uint64_t
*
_bin_len
,
uint8_t
*
_bin
)
{
int
len
=
strnlen
(
_hex
,
2
*
BUF_LEN
);
...
...
@@ -119,12 +115,10 @@ bool hex2carray(const char *_hex, uint64_t *_bin_len,
}
return
true
;
}
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);
...
...
@@ -145,12 +139,10 @@ bool hex2carray2(const char *_hex, uint64_t *_bin_len,
}
return
true
;
}
bool
sign
(
const
char
*
_encryptedKeyHex
,
const
char
*
_hashHex
,
size_t
_t
,
size_t
_n
,
size_t
_signerIndex
,
char
*
_sig
)
{
auto
keyStr
=
make_shared
<
string
>
(
_encryptedKeyHex
);
auto
hash
=
make_shared
<
array
<
uint8_t
,
32
>>
();
...
...
@@ -161,9 +153,6 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
}
auto
keyShare
=
make_shared
<
BLSPrivateKeyShareSGX
>
(
keyStr
,
_t
,
_n
);
auto
sigShare
=
keyShare
->
signWithHelperSGX
(
hash
,
_signerIndex
);
...
...
@@ -184,7 +173,6 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t
bool
sign_aes
(
const
char
*
_encryptedKeyHex
,
const
char
*
_hashHex
,
size_t
_t
,
size_t
_n
,
size_t
_signerIndex
,
char
*
_sig
)
{
auto
keyStr
=
make_shared
<
string
>
(
_encryptedKeyHex
);
auto
hash
=
make_shared
<
array
<
uint8_t
,
32
>>
();
...
...
@@ -195,8 +183,6 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
}
// auto keyShare = make_shared<BLSPrivateKeyShareSGX>(keyStr, _t, _n);
//
// auto sigShare = keyShare->signWithHelperSGX(hash, _signerIndex);
...
...
@@ -243,7 +229,6 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
size_t
sz
=
0
;
uint8_t
encryptedKey
[
BUF_LEN
];
bool
result
=
hex2carray
(
_encryptedKeyHex
,
&
sz
,
encryptedKey
);
...
...
@@ -257,17 +242,14 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
trustedBlsSignMessageAES
(
eid
,
&
errStatus
,
errMsg
,
encryptedKey
,
sz
,
xStrArg
,
yStrArg
,
signature
);
if
(
status
!=
SGX_SUCCESS
)
{
cerr
<<
"SGX enclave call to trustedBlsSignMessage failed:"
<<
status
<<
std
::
endl
;
BOOST_THROW_EXCEPTION
(
runtime_error
(
"SGX enclave call to trustedBlsSignMessage failed"
));
}
std
::
string
hint
=
BLSutils
::
ConvertToString
(
hash_with_hint
.
first
.
Y
)
+
":"
+
hash_with_hint
.
second
;
std
::
string
sig
=
signature
;
sig
.
append
(
":"
);
...
...
@@ -289,7 +271,6 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
bool
bls_sign
(
const
char
*
_encryptedKeyHex
,
const
char
*
_hashHex
,
size_t
_t
,
size_t
_n
,
size_t
_signerIndex
,
char
*
_sig
)
{
return
sign_aes
(
_encryptedKeyHex
,
_hashHex
,
_t
,
_n
,
_signerIndex
,
_sig
);
}
...
...
@@ -327,8 +308,6 @@ char *encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key)
}
char
*
decryptBLSKeyShareFromHex
(
int
*
errStatus
,
char
*
errMsg
,
const
char
*
_encryptedKey
)
{
*
errStatus
=
-
1
;
uint64_t
decodedLen
=
0
;
...
...
@@ -341,7 +320,6 @@ char *decryptBLSKeyShareFromHex(int *errStatus, char *errMsg, const char *_encry
char
*
plaintextKey
=
(
char
*
)
calloc
(
BUF_LEN
,
1
);
//status = trustedDecryptKey(eid, errStatus, errMsg, decoded, decodedLen, plaintextKey);
status
=
trustedDecryptKeyAES
(
eid
,
errStatus
,
errMsg
,
decoded
,
decodedLen
,
plaintextKey
);
if
(
status
!=
SGX_SUCCESS
)
{
...
...
@@ -353,5 +331,4 @@ char *decryptBLSKeyShareFromHex(int *errStatus, char *errMsg, const char *_encry
}
return
plaintextKey
;
}
testw.cpp
View file @
fb830e75
This diff is collapsed.
Click to expand it.
testw.py
View file @
fb830e75
...
...
@@ -33,18 +33,24 @@ testList = [ "[cert-sign]",
"[get-server-status]"
,
"[get-server-version]"
,
"[ecdsa-key-gen]"
,
"[ecdsa-aes-key-gen]"
,
"[ecdsa-key-sig-gen]"
,
"[ecdsa-aes-key-sig-gen]"
,
"[ecdsa-get-pub-key]"
,
"[ecdsa-aes-get-pub-key]"
,
"[ecdsa-key-gen-api]"
,
"[ecdsa-key-gen-sign-api]"
,
"[bls-key-encrypt]"
,
"[dkg-gen]"
,
#"[dkg-aes-gen]", <- fix it
"[dkg-encr-sshares]"
,
"[dkg-aes-encr-sshares]"
,
"[dkg-verify]"
,
"[dkg-api]"
,
"[dkg-bls]"
,
"[dkg-poly-exists]"
,
"[dkg-pub-shares]"
,
#"[dkg-aes-pub-shares]", <- fix it
"[many-threads-crypto]"
,
"[aes-encrypt-decrypt]"
,
"[sgx-encrypt-decrypt]"
,
...
...
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