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
cc59f448
Unverified
Commit
cc59f448
authored
Sep 03, 2019
by
a72d9e2bad9edfd58d6c0248c12c953b71d409d2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing SGX
parent
ae8dbfcd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
54 deletions
+72
-54
BLSCrypto.cpp
BLSCrypto.cpp
+54
-1
BLSCrypto.h
BLSCrypto.h
+4
-0
BLSPrivateKeyShareSGX.cpp
BLSPrivateKeyShareSGX.cpp
+2
-0
BLSUtils.cpp
secure_enclave/BLSUtils.cpp
+4
-0
BLSUtils.h
secure_enclave/BLSUtils.h
+8
-0
sgxd_common.h
sgxd_common.h
+0
-53
No files found.
BLSCrypto.cpp
View file @
cc59f448
...
...
@@ -17,8 +17,61 @@
#include "BLSCrypto.h"
int
char2int
(
char
_input
)
{
if
(
_input
>=
'0'
&&
_input
<=
'9'
)
return
_input
-
'0'
;
if
(
_input
>=
'A'
&&
_input
<=
'F'
)
return
_input
-
'A'
+
10
;
if
(
_input
>=
'a'
&&
_input
<=
'f'
)
return
_input
-
'a'
+
10
;
return
-
1
;
}
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'
};
for
(
int
j
=
0
;
j
<
_len
;
j
++
)
{
_hexArray
[
j
*
2
]
=
hexval
[((
d
[
j
]
>>
4
)
&
0xF
)];
_hexArray
[
j
*
2
+
1
]
=
hexval
[(
d
[
j
])
&
0x0F
];
}
_hexArray
[
_len
*
2
]
=
0
;
}
bool
hex2carray
(
const
char
*
_hex
,
uint64_t
*
_bin_len
,
uint8_t
*
_bin
)
{
int
len
=
strnlen
(
_hex
,
2
*
BUF_LEN
);
if
(
len
==
0
&&
len
%
2
==
1
)
return
false
;
*
_bin_len
=
len
/
2
;
for
(
int
i
=
0
;
i
<
len
/
2
;
i
++
)
{
int
high
=
char2int
((
char
)
_hex
[
i
*
2
]);
int
low
=
char2int
((
char
)
_hex
[
i
*
2
+
1
]);
if
(
high
<
0
||
low
<
0
)
{
return
false
;
}
_bin
[
i
]
=
(
unsigned
char
)
(
high
*
16
+
low
);
}
return
true
;
}
extern
"C"
void
init_daemon
()
{
void
init_daemon
()
{
libff
::
init_alt_bn128_params
();
...
...
BLSCrypto.h
View file @
cc59f448
...
...
@@ -15,7 +15,11 @@ EXTERNC void init_daemon();
EXTERNC
bool
sign
(
char
*
encryptedKeyHex
,
char
*
hashHex
,
size_t
t
,
size_t
n
,
char
*
_sig
);
EXTERNC
int
char2int
(
char
_input
);
EXTERNC
void
carray2Hex
(
const
unsigned
char
*
d
,
int
_len
,
char
*
_hexArray
);
EXTERNC
bool
hex2carray
(
const
char
*
_hex
,
uint64_t
*
_bin_len
,
uint8_t
*
_bin
);
...
...
BLSPrivateKeyShareSGX.cpp
View file @
cc59f448
...
...
@@ -31,6 +31,8 @@ using namespace std;
#include "sgxd_common.h"
#include "sgxd.h"
#include "BLSCrypto.h"
#include "BLSPrivateKeyShareSGX.h"
...
...
secure_enclave/BLSUtils.cpp
View file @
cc59f448
...
...
@@ -128,3 +128,7 @@ bool sign(const char *_keyString, const char* _hashXString, const char* _hashYSt
}
secure_enclave/BLSUtils.h
View file @
cc59f448
...
...
@@ -19,4 +19,12 @@ EXTERNC bool sign(const char *_keyString, const char* _hashXString, const char*
char
*
_sig
);
EXTERNC
int
char2int
(
char
_input
);
EXTERNC
void
carray2Hex
(
const
unsigned
char
*
d
,
int
_len
,
char
*
_hexArray
);
EXTERNC
bool
hex2carray
(
const
char
*
_hex
,
uint64_t
*
_bin_len
,
uint8_t
*
_bin
);
#endif //SGXD_BLSUTILS_H
sgxd_common.h
View file @
cc59f448
...
...
@@ -26,59 +26,6 @@
#define ADD_ENTROPY_SIZE 32
inline
int
char2int
(
char
_input
)
{
if
(
_input
>=
'0'
&&
_input
<=
'9'
)
return
_input
-
'0'
;
if
(
_input
>=
'A'
&&
_input
<=
'F'
)
return
_input
-
'A'
+
10
;
if
(
_input
>=
'a'
&&
_input
<=
'f'
)
return
_input
-
'a'
+
10
;
return
-
1
;
}
inline
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'
};
for
(
int
j
=
0
;
j
<
_len
;
j
++
)
{
_hexArray
[
j
*
2
]
=
hexval
[((
d
[
j
]
>>
4
)
&
0xF
)];
_hexArray
[
j
*
2
+
1
]
=
hexval
[(
d
[
j
])
&
0x0F
];
}
_hexArray
[
_len
*
2
]
=
0
;
}
inline
bool
hex2carray
(
const
char
*
_hex
,
uint64_t
*
_bin_len
,
uint8_t
*
_bin
)
{
int
len
=
strnlen
(
_hex
,
2
*
BUF_LEN
);
if
(
len
==
0
&&
len
%
2
==
1
)
return
false
;
*
_bin_len
=
len
/
2
;
for
(
int
i
=
0
;
i
<
len
/
2
;
i
++
)
{
int
high
=
char2int
((
char
)
_hex
[
i
*
2
]);
int
low
=
char2int
((
char
)
_hex
[
i
*
2
+
1
]);
if
(
high
<
0
||
low
<
0
)
{
return
false
;
}
_bin
[
i
]
=
(
unsigned
char
)
(
high
*
16
+
low
);
}
return
true
;
}
#endif //SGXD_SGXD_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