SGX fixes

parent ac569b3f
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
// //
#include <memory> #include <memory>
#include "BLSCrypto.h"
#include "libff/algebra/curves/alt_bn128/alt_bn128_init.hpp" #include "libff/algebra/curves/alt_bn128/alt_bn128_init.hpp"
...@@ -15,6 +13,10 @@ ...@@ -15,6 +13,10 @@
#include <jsonrpccpp/server/connectors/httpserver.h> #include <jsonrpccpp/server/connectors/httpserver.h>
#include "BLSPrivateKeyShareSGX.h" #include "BLSPrivateKeyShareSGX.h"
#include "sgxd_common.h"
#include "BLSCrypto.h"
extern "C" void init_daemon() { extern "C" void init_daemon() {
...@@ -32,13 +34,23 @@ extern "C" void init_daemon() { ...@@ -32,13 +34,23 @@ extern "C" void init_daemon() {
bool sign(char* encryptedKeyHex, char* hashHex, size_t t, size_t n, char* _sig) { bool sign(char* _encryptedKeyHex, char* _hashHex, size_t _t, size_t _n, size_t _signerIndex,
char* _sig) {
auto keyStr = std::make_shared<std::string>(_encryptedKeyHex);
auto hash = std::make_shared<std::array<uint8_t, 32>>();
uint64_t binLen;
hex2carray(_hashHex, &binLen, hash->data());
auto keyStr = std::make_shared<std::string>(encryptedKeyHex);
auto keyShare = std::make_shared<BLSPrivateKeyShareSGX>(keyStr, _t, _n);
auto keyShare = std::make_shared<BLSPrivateKeyShareSGX>(keyStr, t, n); auto sigShare = keyShare->signWithHelperSGX(hash, _signerIndex);
return true; return true;
......
...@@ -31,7 +31,7 @@ inline int char2int(char _input) { ...@@ -31,7 +31,7 @@ inline int char2int(char _input) {
void carray2Hex(const unsigned char *d, int _len, char* _hexArray) { inline void carray2Hex(const unsigned char *d, int _len, char* _hexArray) {
static char hexval[16] = {'0', '1', '2', '3', '4', '5', '6', '7', static char hexval[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
...@@ -46,7 +46,7 @@ void carray2Hex(const unsigned char *d, int _len, char* _hexArray) { ...@@ -46,7 +46,7 @@ void carray2Hex(const unsigned char *d, int _len, char* _hexArray) {
} }
bool hex2carray(const char * _hex, uint64_t *_bin_len, inline bool hex2carray(const char * _hex, uint64_t *_bin_len,
uint8_t* _bin ) { uint8_t* _bin ) {
int len = strnlen(_hex, 2 * BUF_LEN); int len = strnlen(_hex, 2 * BUF_LEN);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment