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
0da61e57
Unverified
Commit
0da61e57
authored
Sep 03, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3213
parent
0684b96a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
13 deletions
+11
-13
BLSCrypto.cpp
BLSCrypto.cpp
+8
-13
common.h
common.h
+3
-0
No files found.
BLSCrypto.cpp
View file @
0da61e57
...
...
@@ -54,7 +54,7 @@ string *FqToString(libff::alt_bn128_Fq *_fq) {
_fq
->
as_bigint
().
to_mpz
(
t
);
char
arr
[
mpz_sizeinbase
(
t
,
10
)
+
2
]
;
SAFE_CHAR_BUF
(
arr
,
mpz_sizeinbase
(
t
,
10
)
+
2
)
;
mpz_get_str
(
arr
,
10
,
t
);
mpz_clear
(
t
);
...
...
@@ -181,15 +181,11 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
BOOST_THROW_EXCEPTION
(
runtime_error
(
"Null yStr"
));
}
char
errMsg
[
BUF_LEN
];
memset
(
errMsg
,
0
,
BUF_LEN
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
char
xStrArg
[
BUF_LEN
];
char
yStrArg
[
BUF_LEN
];
char
signature
[
BUF_LEN
];
memset
(
xStrArg
,
0
,
BUF_LEN
);
memset
(
yStrArg
,
0
,
BUF_LEN
);
SAFE_CHAR_BUF
(
xStrArg
,
BUF_LEN
);
SAFE_CHAR_BUF
(
yStrArg
,
BUF_LEN
);
SAFE_CHAR_BUF
(
signature
,
BUF_LEN
);
strncpy
(
xStrArg
,
xStr
->
c_str
(),
BUF_LEN
);
strncpy
(
yStrArg
,
yStr
->
c_str
(),
BUF_LEN
);
...
...
@@ -199,20 +195,19 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
size_t
sz
=
0
;
uint8_t
encryptedKey
[
BUF_LEN
]
;
SAFE_UINT8_BUF
(
encryptedKey
,
BUF_LEN
)
;
bool
result
=
hex2carray
(
_encryptedKeyHex
,
&
sz
,
encryptedKey
);
if
(
!
result
)
{
cerr
<<
"Invalid hex encrypted key"
<<
endl
;
BOOST_THROW_EXCEPTION
(
invalid_argument
(
"Invalid hex encrypted key"
));
}
int
errStatus
=
0
;
sgx_status_t
status
=
trustedBlsSignMessageAES
(
eid
,
&
errStatus
,
errMsg
,
encryptedKey
,
trustedBlsSignMessageAES
(
eid
,
&
errStatus
,
errMsg
.
data
()
,
encryptedKey
,
sz
,
xStrArg
,
yStrArg
,
signature
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
);
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
()
);
string
hint
=
BLSutils
::
ConvertToString
(
hash_with_hint
.
first
.
Y
)
+
":"
+
hash_with_hint
.
second
;
...
...
common.h
View file @
0da61e57
...
...
@@ -76,5 +76,8 @@ BOOST_THROW_EXCEPTION(runtime_error(__ERR_STRING__)); \
}
#define SAFE_CHAR_BUF(__X__, __Y__) ;char __X__ [ __Y__ ]; memset(__X__, 0, __Y__);
#define SAFE_UINT8_BUF(__X__, __Y__) ;uint8_t __X__ [ __Y__ ]; memset(__X__, 0, __Y__);
#endif //SGXWALLET_COMMON_H
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