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
901b8103
Unverified
Commit
901b8103
authored
Sep 09, 2019
by
kladkogex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing
parent
af3fc638
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
74 deletions
+62
-74
BLSUtils.cpp
secure_enclave/BLSUtils.cpp
+60
-73
BLSUtils.h
secure_enclave/BLSUtils.h
+1
-1
secure_enclave.c
secure_enclave/secure_enclave.c
+1
-0
No files found.
secure_enclave/BLSUtils.cpp
View file @
901b8103
...
...
@@ -3,6 +3,7 @@
//
#define GMP_WITH_SGX
#include <string.h>
#include <cstdint>
#include "../sgxwallet_common.h"
...
...
@@ -27,7 +28,7 @@ std::string *stringFromKey(libff::alt_bn128_Fr *_key) {
return
new
std
::
string
(
tmp
);
}
std
::
string
*
stringFromFq
(
libff
::
alt_bn128_Fq
*
_fq
)
{
std
::
string
*
stringFromFq
(
libff
::
alt_bn128_Fq
*
_fq
)
{
mpz_t
t
;
mpz_init
(
t
);
...
...
@@ -52,18 +53,15 @@ std::string *stringFromG1(libff::alt_bn128_G1 *_g1) {
auto
sG1
=
new
std
::
string
(
*
sX
+
":"
+
*
sY
);
delete
(
sX
);
delete
(
sY
);
delete
(
sX
);
delete
(
sY
);
return
sG1
;
}
libff
::
alt_bn128_Fr
*
keyFromString
(
const
char
*
_keyString
)
{
libff
::
alt_bn128_Fr
*
keyFromString
(
const
char
*
_keyString
)
{
return
new
libff
::
alt_bn128_Fr
(
_keyString
);
}
...
...
@@ -78,10 +76,7 @@ void init() {
libff
::
init_alt_bn128_params
();
}
bool
check_key
(
int
*
err_status
,
char
*
err_string
,
const
char
*
_keyString
)
{
void
check_key
(
int
*
err_status
,
char
*
err_string
,
const
char
*
_keyString
)
{
uint64_t
keyLen
=
strnlen
(
_keyString
,
MAX_KEY_LENGTH
);
...
...
@@ -89,28 +84,28 @@ bool check_key(int *err_status, char *err_string, const char *_keyString) {
if
(
keyLen
==
MAX_KEY_LENGTH
)
{
snprintf
(
err_string
,
MAX_ERR_LEN
,
"keyLen != MAX_KEY_LENGTH"
);
return
false
;
return
;
}
*
err_status
=
-
2
;
if
(
_keyString
==
nullptr
)
{
snprintf
(
err_string
,
BUF_LEN
,
"Null key"
);
return
;
}
*
err_status
=
-
3
;
// check that key is padded with 0s
for
(
int
i
=
keyLen
;
i
<
MAX_KEY_LENGTH
;
i
++
)
{
if
(
_keyString
[
i
]
!=
0
)
{
snprintf
(
err_string
,
BUF_LEN
,
"Unpadded key"
);
return
false
;
snprintf
(
err_string
,
BUF_LEN
,
"Unpadded key"
);
}
}
*
err_status
=
-
1
;
if
(
_keyString
==
nullptr
)
return
false
;
std
::
string
ks
(
_keyString
);
// std::string keyString =
...
...
@@ -124,20 +119,13 @@ bool check_key(int *err_status, char *err_string, const char *_keyString) {
throw
std
::
exception
();
}
if
(
s1
->
size
()
<
10
)
return
false
;
if
(
s1
->
size
()
>=
100
)
return
false
;
*
err_status
=
0
;
return
true
;
return
;
}
bool
sign
(
const
char
*
_keyString
,
const
char
*
_hashXString
,
const
char
*
_hashYString
,
bool
sign
(
const
char
*
_keyString
,
const
char
*
_hashXString
,
const
char
*
_hashYString
,
char
sig
[
BUF_LEN
])
{
...
...
@@ -169,7 +157,6 @@ bool sign(const char *_keyString, const char* _hashXString, const char* _hashYSt
return
true
;
}
...
...
secure_enclave/BLSUtils.h
View file @
901b8103
...
...
@@ -13,7 +13,7 @@
#define EXTERNC
#endif
EXTERNC
bool
check_key
(
int
*
err_status
,
char
*
err_string
,
const
char
*
_keyString
);
EXTERNC
void
check_key
(
int
*
err_status
,
char
*
err_string
,
const
char
*
_keyString
);
EXTERNC
bool
sign
(
const
char
*
_keyString
,
const
char
*
_hashXString
,
const
char
*
_hashYString
,
char
*
_sig
);
...
...
secure_enclave/secure_enclave.c
View file @
901b8103
...
...
@@ -127,6 +127,7 @@ void encrypt_key(int *err_status, char *err_string, char *key,
init
();
*
err_status
=
-
1
;
memset
(
err_string
,
0
,
BUF_LEN
);
...
...
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