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
e36f45d5
Unverified
Commit
e36f45d5
authored
Aug 29, 2019
by
a72d9e2bad9edfd58d6c0248c12c953b71d409d2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding sigs
parent
b7f14fde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
6 deletions
+48
-6
BLSUtils.cpp
secure_enclave/BLSUtils.cpp
+29
-3
secure_enclave.c
secure_enclave/secure_enclave.c
+19
-3
No files found.
secure_enclave/BLSUtils.cpp
View file @
e36f45d5
...
...
@@ -22,9 +22,9 @@ std::string *stringFromKey(libff::alt_bn128_Fr *_key) {
return
new
std
::
string
(
tmp
);
}
libff
::
alt_bn128_Fr
*
keyFromString
(
std
::
string
&
_keyString
)
{
libff
::
alt_bn128_Fr
*
keyFromString
(
const
char
*
_keyString
)
{
return
new
libff
::
alt_bn128_Fr
(
_keyString
.
c_str
()
);
return
new
libff
::
alt_bn128_Fr
(
_keyString
);
}
bool
check_key
(
const
char
*
_keyString
)
{
...
...
@@ -39,7 +39,7 @@ bool check_key(const char *_keyString) {
// std::string keyString =
// "4160780231445160889237664391382223604184857153814275770598791864649971919844";
auto
key
=
keyFromString
(
ks
);
auto
key
=
keyFromString
(
ks
.
c_str
()
);
auto
s1
=
stringFromKey
(
key
);
...
...
@@ -54,3 +54,29 @@ bool check_key(const char *_keyString) {
return
true
;
}
char
*
sign
(
const
char
*
_keyString
,
const
char
*
_hashXString
,
const
char
*
_hashYString
,
const
char
*
_hashZString
)
{
auto
key
=
keyFromString
(
_keyString
);
libff
::
alt_bn128_Fq
hashX
(
_hashXString
);
libff
::
alt_bn128_Fq
hashY
(
_hashYString
);
libff
::
alt_bn128_Fq
hashZ
(
_hashZString
);
libff
::
alt_bn128_G1
hash
(
hashX
,
hashY
,
hashZ
);
libff
::
alt_bn128_G1
sign
=
key
->
as_bigint
()
*
hash
;
// sign
return
nullptr
;
}
secure_enclave/secure_enclave.c
View file @
e36f45d5
...
...
@@ -39,6 +39,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <math.h>
#define MAX_KEY_LENGTH 128
void
*
(
*
gmp_realloc_func
)(
void
*
,
size_t
,
size_t
);
void
*
(
*
oc_realloc_func
)(
void
*
,
size_t
,
size_t
);
void
(
*
gmp_free_func
)(
void
*
,
size_t
);
...
...
@@ -106,7 +109,7 @@ void encrypt_key(int *err_status, unsigned char *key,
*
err_status
=
-
1
;
if
(
strnlen
(
key
)
>=
128
)
if
(
strnlen
(
key
)
>=
MAX_KEY_LENGTH
)
return
;
*
err_status
=
-
3
;
...
...
@@ -133,7 +136,7 @@ void encrypt_key(int *err_status, unsigned char *key,
*
err_status
=
-
6
;
char
key2
[
128
];
char
key2
[
MAX_KEY_LENGTH
];
decrypt_key
(
err_status
,
encrypted_key
,
sealedLen
,
key2
);
...
...
@@ -166,4 +169,17 @@ void decrypt_key(int *err_status, unsigned char *encrypted_key,
void
sign_message
(
int
*
err_status
,
unsigned
char
*
encrypted_key
,
uint32_t
enc_len
,
unsigned
char
*
message
,
unsigned
char
*
signature
)
{}
\ No newline at end of file
unsigned
char
*
signature
)
{
uint8_t
key
[
MAX_KEY_LENGTH
];
decrypt_key
(
err_status
,
encrypted_key
,
enc_len
,
key
);
if
(
err_status
!=
0
)
{
return
;
}
}
\ No newline at end of file
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