Unverified Commit 6e7e4123 authored by Stan Kladko's avatar Stan Kladko Committed by GitHub

Merge pull request #71 from skalenetwork/bug/SKALE-2345-hw-fails

Bug/skale 2345 hw fails
parents fbec7209 1a324a2a
......@@ -47,6 +47,8 @@
#include "SGXWalletServer.h"
#include "BLSCrypto.h"
#include "BLSCrypto.hpp"
#include "ServerInit.h"
#include "RPCException.h"
......@@ -55,7 +57,7 @@
#include "common.h"
std::string *FqToString(libff::alt_bn128_Fq*_fq) {
std::string *FqToString(libff::alt_bn128_Fq *_fq) {
mpz_t t;
mpz_init(t);
......@@ -81,8 +83,7 @@ int char2int(char _input) {
}
void carray2Hex(const unsigned char *d, int _len, char* _hexArray) {
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'};
......@@ -97,8 +98,8 @@ void carray2Hex(const unsigned char *d, int _len, char* _hexArray) {
}
bool hex2carray(const char * _hex, uint64_t *_bin_len,
uint8_t* _bin ) {
bool hex2carray(const char *_hex, uint64_t *_bin_len,
uint8_t *_bin) {
int len = strnlen(_hex, 2 * BUF_LEN);
......@@ -109,8 +110,8 @@ bool hex2carray(const char * _hex, uint64_t *_bin_len,
*_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]);
int high = char2int((char) _hex[i * 2]);
int low = char2int((char) _hex[i * 2 + 1]);
if (high < 0 || low < 0) {
return false;
......@@ -123,8 +124,8 @@ bool hex2carray(const char * _hex, uint64_t *_bin_len,
}
bool hex2carray2(const char * _hex, uint64_t *_bin_len,
uint8_t* _bin, const int _max_length ) {
bool hex2carray2(const char *_hex, uint64_t *_bin_len,
uint8_t *_bin, const int _max_length) {
int len = strnlen(_hex, _max_length);//2 * BUF_LEN);
......@@ -135,8 +136,8 @@ bool hex2carray2(const char * _hex, uint64_t *_bin_len,
*_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]);
int high = char2int((char) _hex[i * 2]);
int low = char2int((char) _hex[i * 2 + 1]);
if (high < 0 || low < 0) {
return false;
......@@ -149,8 +150,8 @@ bool hex2carray2(const char * _hex, uint64_t *_bin_len,
}
bool sign(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, size_t _n, size_t _signerIndex,
char* _sig) {
bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t _n, size_t _signerIndex,
char *_sig) {
//cerr << "ENTER SIGN" << endl;
......@@ -160,19 +161,14 @@ bool sign(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, size_t
uint64_t binLen;
if (!hex2carray(_hashHex, &binLen, hash->data())){
if (!hex2carray(_hashHex, &binLen, hash->data())) {
throw RPCException(INVALID_HEX, "Invalid hash");
}
// assert(binLen == hash->size());
auto keyShare = make_shared<BLSPrivateKeyShareSGX>(keyStr, _t, _n);
//cerr << "keyShare created" << endl;
// {
auto sigShare = keyShare->signWithHelperSGX(hash, _signerIndex);
// }
auto sigShareStr = sigShare->toString();
......@@ -190,8 +186,8 @@ bool sign(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, size_t
return true;
}
bool sign_aes(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, size_t _n, size_t _signerIndex,
char* _sig) {
bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t _n, size_t _signerIndex,
char *_sig) {
//cerr << "ENTER SIGN" << endl;
......@@ -201,7 +197,7 @@ bool sign_aes(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, siz
uint64_t binLen;
if (!hex2carray(_hashHex, &binLen, hash->data())){
if (!hex2carray(_hashHex, &binLen, hash->data())) {
throw RPCException(INVALID_HEX, "Invalid hash");
}
// assert(binLen == hash->size());
......@@ -227,14 +223,14 @@ bool sign_aes(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, siz
int errStatus = 0;
string* xStr = FqToString(&(hash_with_hint.first.X));
string *xStr = FqToString(&(hash_with_hint.first.X));
if (xStr == nullptr) {
std::cerr << "Null xStr" << std::endl;
BOOST_THROW_EXCEPTION(runtime_error("Null xStr"));
}
string* yStr = FqToString(&(hash_with_hint.first.Y));
string *yStr = FqToString(&(hash_with_hint.first.Y));
if (yStr == nullptr) {
std::cerr << "Null yStr" << std::endl;
......@@ -247,7 +243,7 @@ bool sign_aes(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, siz
char xStrArg[BUF_LEN];
char yStrArg[BUF_LEN];
char signature [BUF_LEN];
char signature[BUF_LEN];
memset(xStrArg, 0, BUF_LEN);
memset(yStrArg, 0, BUF_LEN);
......@@ -273,7 +269,7 @@ bool sign_aes(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, siz
if (status != SGX_SUCCESS) {
cerr <<"SGX enclave call to bls_sign_message failed:" << status << std::endl;
cerr << "SGX enclave call to bls_sign_message failed:" << status << std::endl;
BOOST_THROW_EXCEPTION(runtime_error("SGX enclave call to bls_sign_message failed"));
}
......@@ -303,18 +299,17 @@ bool sign_aes(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, siz
return true;
}
bool bls_sign(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, size_t _n, size_t _signerIndex,
char* _sig) {
bool bls_sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t _n, size_t _signerIndex,
char *_sig) {
if (!encryptKeys){
if (!encryptKeys) {
return sign(_encryptedKeyHex, _hashHex, _t, _n, _signerIndex, _sig);
}
else{
} else {
return sign_aes(_encryptedKeyHex, _hashHex, _t, _n, _signerIndex, _sig);
}
}
char* encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key) {
shared_ptr<string> encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key) {
auto keyArray = make_shared<vector<char>>(BUF_LEN, 0);
auto encryptedKey = make_shared<vector<uint8_t>>(BUF_LEN, 0);
auto errMsg = make_shared<vector<char>>(BUF_LEN, 0);
......@@ -323,13 +318,12 @@ char* encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key)
unsigned int encryptedLen = 0;
//status = encrypt_key(eid, errStatus, errMsg, keyArray, encryptedKey, &encryptedLen);
status = encrypt_key_aes(eid, errStatus, errMsg->data(), keyArray->data(), encryptedKey->data(), &encryptedLen);
if (printDebugInfo) {
spdlog::info("errStatus is {}",*errStatus);
spdlog::info(" errMsg is ", errMsg->data() );
}
spdlog::debug("errStatus is {}", *errStatus);
spdlog::debug(" errMsg is ", errMsg->data());
if (status != SGX_SUCCESS) {
......@@ -342,11 +336,11 @@ char* encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key)
}
char *result = (char *) calloc(2 * BUF_LEN, 1);
vector<char> result(2 * BUF_LEN, 0);
carray2Hex(encryptedKey->data(), encryptedLen, result);
carray2Hex(encryptedKey->data(), encryptedLen, result.data());
return result;
return make_shared<string>(result.data());
}
char *decryptBLSKeyShareFromHex(int *errStatus, char *errMsg, const char *_encryptedKey) {
......
......@@ -30,12 +30,6 @@
#define EXTERNC
#endif
//EXTERNC void init_all();
//
//EXTERNC void init_daemon();
//
//EXTERNC void init_enclave();
EXTERNC bool bls_sign(const char* encryptedKeyHex, const char* hashHex, size_t t, size_t n,
size_t signerIndex, char* _sig);
......@@ -49,8 +43,4 @@ EXTERNC bool hex2carray2(const char * _hex, uint64_t *_bin_len,
char * encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key);
char *decryptBLSKeyShareFromHex(int *errStatus, char *errMsg, const char *_encryptedKey);
#endif //SGXWALLET_BLSCRYPTO_H
/*
Copyright (C) 2019-Present SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file BLSCrypto.hpp
@author Stan Kladko
@date 2019
*/
#ifndef SGXWALLET_BLSCRYPTO_HPP
#define SGXWALLET_BLSCRYPTO_HPP
#ifdef __cplusplus
#define EXTERNC extern "C"
#else
#define EXTERNC
#endif
using namespace std;
shared_ptr<string> encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key);
char *decryptBLSKeyShareFromHex(int *errStatus, char *errMsg, const char *_encryptedKey);
#endif //SGXWALLET_BLSCRYPTO_H
......@@ -80,10 +80,8 @@ BLSPrivateKeyShareSGX::BLSPrivateKeyShareSGX(
requiredSigners = _requiredSigners;
totalSigners = _totalSigners;
std::cerr << "ENTER BLSPrivateKeyShareSGX CONSTRUCTOR" << std::endl;
if (requiredSigners > totalSigners) {
throw std::invalid_argument("requiredSigners > totalSigners");
}
......
This diff is collapsed.
......@@ -31,11 +31,11 @@ std::string gen_dkg_poly( int _t);
std::vector <std::vector<std::string>> get_verif_vect(const char* encryptedPolyHex, int t, int n);
std::vector<std::string> SplitString(const char* koefs, const char symbol);
std::vector<std::string> splitString(const char* koefs, const char symbol);
std::string get_secret_shares(const std::string& polyName, const char* encryptedPolyHex, const std::vector<std::string>& publicKeys, int t, int n);
std::string get_secret_shares(const std::string& _polyName, const char* _encryptedPolyHex, const std::vector<std::string>& _publicKeys, int _t, int _n);
bool VerifyShares(const char* publicShares, const char* encr_sshare, const char * encryptedKeyHex, int t, int n, int ind);
bool verifyShares(const char* publicShares, const char* encr_sshare, const char * encryptedKeyHex, int t, int n, int ind);
std::string decrypt_DHKey(const std::string& polyName, int ind);
......
......@@ -34,53 +34,44 @@
#include "spdlog/spdlog.h"
static std::default_random_engine rand_gen((unsigned int) time(0));
static default_random_engine randGen((unsigned int) time(0));
std::string concatPubKeyWith0x(char* pub_key_x, char* pub_key_y){
std::string px = pub_key_x;
std::string py = pub_key_y;
std::string result = "0x" + px + py;// + std::to_string(pub_key_x) + std::to_string(pub_key_y);
string concatPubKeyWith0x(char *pub_key_x, char *pub_key_y) {
string px = pub_key_x;
string py = pub_key_y;
string result = "0x" + px + py;
return result;
}
std::vector<std::string> gen_ecdsa_key(){
char *errMsg = (char *)calloc(1024, 1);
std::vector<std::string> genECDSAKey() {
char *errMsg = (char *) calloc(1024, 1);
int err_status = 0;
uint8_t* encr_pr_key = (uint8_t *)calloc(1024, 1);
char *pub_key_x = (char *)calloc(1024, 1);
char *pub_key_y = (char *)calloc(1024, 1);
uint8_t *encr_pr_key = (uint8_t *) calloc(1024, 1);
char *pub_key_x = (char *) calloc(1024, 1);
char *pub_key_y = (char *) calloc(1024, 1);
uint32_t enc_len = 0;
if ( !encryptKeys)
status = generate_ecdsa_key(eid, &err_status, errMsg, encr_pr_key, &enc_len, pub_key_x, pub_key_y );
if (!encryptKeys)
status = generate_ecdsa_key(eid, &err_status, errMsg, encr_pr_key, &enc_len, pub_key_x, pub_key_y);
else
status = generate_ecdsa_key_aes(eid, &err_status, errMsg, encr_pr_key, &enc_len, pub_key_x, pub_key_y );
status = generate_ecdsa_key_aes(eid, &err_status, errMsg, encr_pr_key, &enc_len, pub_key_x, pub_key_y);
if ( status != SGX_SUCCESS || err_status != 0 ){
std::cerr << "RPCException thrown with status" << status << std::endl;
throw RPCException(status, errMsg) ;
if (status != SGX_SUCCESS || err_status != 0) {
spdlog::error("RPCException thrown with status {}", status);
throw RPCException(status, errMsg);
}
std::vector<std::string> keys(3);
if (printDebugInfo) {
std::cerr << "account key is " << errMsg << std::endl;
std::cerr << "enc_len is " << enc_len << std::endl;
// std::cerr << "enc_key is " << std::endl;
// for(int i = 0 ; i < 1024; i++)
// std::cerr << (int)encr_pr_key[i] << " " ;
}
char *hexEncrKey = (char *) calloc(BUF_LEN * 2, 1);
carray2Hex(encr_pr_key, enc_len, hexEncrKey);
keys.at(0) = hexEncrKey;
keys.at(1) = std::string(pub_key_x) + std::string(pub_key_y);//concatPubKeyWith0x(pub_key_x, pub_key_y);//
//std::cerr << "in ECDSACrypto encr key x " << keys.at(0) << std::endl;
//std::cerr << "in ECDSACrypto encr_len %d " << enc_len << std::endl;
unsigned long seed = rand_gen();
if (printDebugInfo) {
spdlog::info("seed is {}", seed);
std::cerr << "strlen is " << strlen(hexEncrKey) << std::endl;
}
unsigned long seed = randGen();
spdlog::debug("seed is {}", seed);
gmp_randstate_t state;
gmp_randinit_default(state);
......@@ -90,12 +81,11 @@ std::vector<std::string> gen_ecdsa_key(){
mpz_init(rand32);
mpz_urandomb(rand32, state, 256);
char arr[mpz_sizeinbase (rand32, 16) + 2];
char * rand_str = mpz_get_str(arr, 16, rand32);
char arr[mpz_sizeinbase(rand32, 16) + 2];
char *rand_str = mpz_get_str(arr, 16, rand32);
keys.at(2) = rand_str;
//std::cerr << "rand_str length is " << strlen(rand_str) << std::endl;
gmp_randclear(state);
mpz_clear(rand32);
......@@ -109,88 +99,87 @@ std::vector<std::string> gen_ecdsa_key(){
return keys;
}
std::string get_ecdsa_pubkey(const char* encryptedKeyHex){
char *errMsg = (char *)calloc(1024, 1);
std::string getECDSAPubKey(const char *_encryptedKeyHex) {
vector<char> errMsg(BUF_LEN, 0);
vector<char> pubKeyX(BUF_LEN, 0);
vector<char> pubKeyY(BUF_LEN, 0);
vector<uint8_t> encrPrKey(BUF_LEN, 0);
int err_status = 0;
char *pub_key_x = (char *)calloc(1024, 1);
char *pub_key_y = (char *)calloc(1024, 1);
uint64_t enc_len = 0;
//uint8_t encr_pr_key[BUF_LEN];
uint8_t* encr_pr_key = (uint8_t*)calloc(1024, 1);
if (!hex2carray(encryptedKeyHex, &enc_len, encr_pr_key)){
if (!hex2carray(_encryptedKeyHex, &enc_len, encrPrKey.data())) {
throw RPCException(INVALID_HEX, "Invalid encryptedKeyHex");
}
if ( !encryptKeys)
status = get_public_ecdsa_key(eid, &err_status, errMsg, encr_pr_key, enc_len, pub_key_x, pub_key_y );
else status = get_public_ecdsa_key_aes(eid, &err_status, errMsg, encr_pr_key, enc_len, pub_key_x, pub_key_y );
if (err_status != 0){
throw RPCException(-666, errMsg) ;
}
std::string pubKey = std::string(pub_key_x) + std::string(pub_key_y);//concatPubKeyWith0x(pub_key_x, pub_key_y);//
if (printDebugInfo) {
spdlog::info("enc_len is {}", enc_len);
spdlog::info("pubkey is {}", pubKey);
spdlog::info("pubkey length is {}", pubKey.length());
spdlog::info("err str is {}", errMsg);
spdlog::info("err status is {}", err_status);
if (!encryptKeys)
status = get_public_ecdsa_key(eid, &err_status, errMsg.data(), encrPrKey.data(), enc_len, pubKeyX.data(),
pubKeyY.data());
else status = get_public_ecdsa_key_aes(eid, &err_status,
errMsg.data(), encrPrKey.data(), enc_len, pubKeyX.data(), pubKeyY.data());
if (err_status != 0) {
throw RPCException(-666, errMsg.data());
}
string pubKey = string(pubKeyX.data()) + string(pubKeyY.data());//concatPubKeyWith0x(pub_key_x, pub_key_y);//
spdlog::debug("enc_len is {}", enc_len);
spdlog::debug("pubkey is {}", pubKey);
spdlog::debug("pubkey length is {}", pubKey.length());
spdlog::debug("err str is {}", errMsg.data());
spdlog::debug("err status is {}", err_status);
free(errMsg);
free(pub_key_x);
free(pub_key_y);
free(encr_pr_key);
return pubKey;
}
std::vector<std::string> ecdsa_sign_hash(const char* encryptedKeyHex, const char* hashHex, int base){
std::vector<std::string> signature_vect(3);
vector<string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, int base) {
vector<string> signature_vect(3);
char *errMsg = (char *)calloc(1024, 1);
char *errMsg = (char *) calloc(1024, 1);
int err_status = 0;
char* signature_r = (char *)calloc(1024, 1);
char* signature_s = (char *)calloc(1024, 1);
char *signature_r = (char *) calloc(1024, 1);
char *signature_s = (char *) calloc(1024, 1);
uint8_t signature_v = 0;
uint64_t dec_len = 0;
//uint8_t encr_key[BUF_LEN];
uint8_t* encr_key = (uint8_t*)calloc(1024, 1);
if (!hex2carray(encryptedKeyHex, &dec_len, encr_key)){
uint8_t *encr_key = (uint8_t *) calloc(1024, 1);
if (!hex2carray(encryptedKeyHex, &dec_len, encr_key)) {
throw RPCException(INVALID_HEX, "Invalid encryptedKeyHex");
}
if (printDebugInfo) {
spdlog::info("encryptedKeyHex: {}", encryptedKeyHex);
spdlog::info("HASH: {}", hashHex);
spdlog::info("encrypted len: {}", dec_len);
}
spdlog::debug("encryptedKeyHex: {}", encryptedKeyHex);
spdlog::debug("HASH: {}", hashHex);
spdlog::debug("encrypted len: {}", dec_len);
if (!encryptKeys)
status = ecdsa_sign1(eid, &err_status, errMsg, encr_key, ECDSA_ENCR_LEN, (unsigned char*)hashHex, signature_r, signature_s, &signature_v, base );
else status = ecdsa_sign_aes(eid, &err_status, errMsg, encr_key, dec_len, (unsigned char*)hashHex, signature_r, signature_s, &signature_v, base );
if ( err_status != 0){
throw RPCException(-666, errMsg ) ;
status = ecdsa_sign1(eid, &err_status, errMsg, encr_key, ECDSA_ENCR_LEN, (unsigned char *) hashHex, signature_r,
signature_s, &signature_v, base);
else
status = ecdsa_sign_aes(eid, &err_status, errMsg, encr_key, dec_len, (unsigned char *) hashHex, signature_r,
signature_s, &signature_v, base);
if (err_status != 0) {
throw RPCException(-666, errMsg);
}
if (printDebugInfo) {
spdlog::info("signature r in ecdsa_sign_hash: {}", signature_r);
spdlog::info("signature s in ecdsa_sign_hash: {}", signature_s);
}
if ( status != SGX_SUCCESS){
spdlog::info(" failed to sign ");
}
signature_vect.at(0) = std::to_string(signature_v);
if ( base == 16) {
signature_vect.at(1) = "0x" + std::string(signature_r);
signature_vect.at(2) = "0x" + std::string(signature_s);
spdlog::debug("signature r in ecdsa_sign_hash: {}", signature_r);
spdlog::debug("signature s in ecdsa_sign_hash: {}", signature_s);
if (status != SGX_SUCCESS) {
spdlog::error(" failed to sign ");
}
else{
signature_vect.at(1) = std::string(signature_r);
signature_vect.at(2) = std::string(signature_s);
signature_vect.at(0) = to_string(signature_v);
if (base == 16) {
signature_vect.at(1) = "0x" + string(signature_r);
signature_vect.at(2) = "0x" + string(signature_s);
} else {
signature_vect.at(1) = string(signature_r);
signature_vect.at(2) = string(signature_s);
}
free(errMsg);
......
......@@ -35,11 +35,13 @@
#define EXTERNC
#endif*/
std::vector<std::string> gen_ecdsa_key();
using namespace std;
std::string get_ecdsa_pubkey(const char* encryptedKeyHex);
vector<string> genECDSAKey();
std::vector<std::string> ecdsa_sign_hash(const char* encryptedKeyHex, const char* hashHex, int base);
string getECDSAPubKey(const char* _encryptedKeyHex);
vector<string> ecdsaSignHash(const char* encryptedKeyHex, const char* hashHex, int base);
#endif //SGXD_ECDSACRYPTO_H
/*
Copyright (C) 2018-2019 SKALE Labs
This file is part of skale-consensus.
skale-consensus is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
skale-consensus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with skale-consensus. If not, see <https://www.gnu.org/licenses/>.
@file Exception.cpp
@author Stan Kladko
@date 2018
*/
#include "Log.h"
#include "Exception.h"
void Exception::logNested(const std::exception &e, int level)
{
string prefix;
if (level == 0) {
prefix = "!Exception:";
} else {
prefix = "!Caused by:";
}
if (dynamic_cast<const std::nested_exception*>(&e) == nullptr) {
LOG(err, string(level, ' ') + prefix + e.what());
return;
} else {
LOG(err, string(level, ' ') + prefix + e.what());
}
try {
std::rethrow_if_nested(e);
} catch(const std::exception& e) {
logNested(e, level + 1);
} catch(...) {}
};
\ No newline at end of file
/*
Copyright (C) 2018-2019 SKALE Labs
This file is part of skale-consensus.
skale-consensus is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
skale-consensus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with skale-consensus. If not, see <https://www.gnu.org/licenses/>.
@file Exception.h
@author Stan Kladko
@date 2018
*/
#pragma once
class Exception : public std::exception {
public:
Exception( const std::string& _message, const std::string& _className ) {
message = _className + ":" + _message;
}
const char* what() const noexcept override {
return message.empty() ? std::exception::what() : message.c_str();
}
const std::string& getMessage() const { return message; }
bool isFatal() const { return fatal; }
private:
std::string message;
protected:
bool fatal = false;
public:
static void logNested( const std::exception& e, int level = 0 );
};
/*
Copyright (C) 2018-2019 SKALE Labs
This file is part of skale-consensus.
skale-consensus is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
skale-consensus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with skale-consensus. If not, see <https://www.gnu.org/licenses/>.
@file InvalidArgumentException.cpp
@author Stan Kladko
@date 2018
*/
#include "Log.h"
#include "InvalidArgumentException.h"
InvalidArgumentException::InvalidArgumentException(const std::string &_message, const string& _className) :
Exception(_message, _className) {
fatal = false;
}
/*
Copyright (C) 2018-2019 SKALE Labs
This file is part of skale-consensus.
skale-consensus is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
skale-consensus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with skale-consensus. If not, see <https://www.gnu.org/licenses/>.
@file InvalidArgumentException.h
@author Stan Kladko
@date 2018
*/
#pragma once
#include "Exception.h"
#include <string>
class InvalidArgumentException : public Exception {
public:
InvalidArgumentException( const std::string& _message, const std::string& _className );
};
/*
Copyright (C) 2018-2019 SKALE Labs
This file is part of skale-consensus.
skale-consensus is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
skale-consensus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with skale-consensus. If not, see <https://www.gnu.org/licenses/>.
@file InvalidStateException.cpp
@author Stan Kladko
@date 2018
*/
#include "common.h"
#include "Log.h"
#include "InvalidStateException.h"
InvalidStateException::InvalidStateException(const std::string &_message, const string& _className) :
Exception(_message, _className) {
fatal = false;
}
/*
Copyright (C) 2018-2019 SKALE Labs
This file is part of skale-consensus.
skale-consensus is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
skale-consensus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with skale-consensus. If not, see <https://www.gnu.org/licenses/>.
@file InvalidStateException.h
@author Stan Kladko
@date 2018
*/
#pragma once
#include "Exception.h"
class InvalidStateException : public Exception {
public:
InvalidStateException( const std::string& _message, const std::string& _className );
};
......@@ -62,10 +62,10 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
auto status = db->Get(readOptions, _key, &*result);
if (printDebugInfo) {
spdlog::info("key to read from db: {}",_key );
spdlog::debug("key to read from db: {}",_key );
//std::cerr << "key to read from db: " << _key << std::endl;
}
throwExceptionOnError(status);
......@@ -83,10 +83,10 @@ void LevelDB::writeString(const string &_key, const string &_value) {
throwExceptionOnError(status);
if (printDebugInfo) {
spdlog::info("written key: {}",_key );
spdlog::debug("written key: {}",_key );
// std::cerr << "written key " << _key << std::endl;
}
}
......@@ -100,10 +100,9 @@ void LevelDB::deleteDHDKGKey (const string &_key) {
throwExceptionOnError(status);
if (printDebugInfo) {
spdlog::info("key deleted: {}",full_key );
spdlog::debug("key deleted: {}",full_key );
//std::cerr << "key deleted " << full_key << std::endl;
}
}
void LevelDB::deleteTempNEK(const string &_key){
......@@ -130,10 +129,9 @@ void LevelDB::deleteKey(const string &_key){
throwExceptionOnError(status);
if (printDebugInfo) {
spdlog::info("key deleted: {}",_key );
spdlog::debug("key deleted: {}",_key );
// std::cerr << "key deleted " << _key << std::endl;
}
}
......@@ -213,16 +211,15 @@ void LevelDB::writeDataUnique(const string & Name, const string &value) {
auto key = Name;
if (readString(Name) != nullptr) {
spdlog::info("name {}",Name, " already exists");
spdlog::debug("name {}",Name, " already exists");
// std::cerr << "name " << Name << " already exists" << std::endl;
throw RPCException(KEY_SHARE_ALREADY_EXISTS, "Data with this name already exists");
}
writeString(key, value);
if (printDebugInfo) {
spdlog::info("{}",Name, " is written to db");
//std::cerr << Name << " is written to db " << std::endl;
}
spdlog::debug("{}",Name, " is written to db");
}
......@@ -273,12 +270,17 @@ bool LevelDB::isInited = false;
void LevelDB::initDataFolderAndDBs() {
if (isInited)
return;
CHECK_STATE(!isInited)
isInited = true;
spdlog::info("Initing wallet database ... ");
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd)) == NULL) {
spdlog::error("could not get cwd");
spdlog::error("could not get current workin directory");
exit(-1);
}
......@@ -286,17 +288,20 @@ void LevelDB::initDataFolderAndDBs() {
struct stat info;
if (stat(sgx_data_folder.c_str(), &info) !=0 ){
spdlog::info("going to create sgx_data folder");
std::string make_sgx_data_folder = "mkdir " + sgx_data_folder;
if (system(make_sgx_data_folder.c_str()) == 0){
spdlog::info("sgx_data folder was created");
spdlog::info("sgx_data folder does not exist. Creating ...");
if (system(("mkdir " + sgx_data_folder).c_str()) == 0){
spdlog::info("Successfully created sgx_data folder");
}
else{
spdlog::error("creating sgx_data folder failed");
spdlog::error("Couldnt create creating sgx_data folder");
exit(-1);
}
}
spdlog::info("Opening wallet databases");
auto dbName = sgx_data_folder + WALLETDB_NAME;
levelDb = make_shared<LevelDB>(dbName);
......@@ -306,6 +311,8 @@ void LevelDB::initDataFolderAndDBs() {
auto csr_status_dbname = sgx_data_folder + "CSR_STATUS_DB";
csrStatusDb = make_shared<LevelDB>(csr_status_dbname);
spdlog::info("Successfully opened databases");
}
const string &LevelDB::getSgxDataFolder() {
......
/*
Copyright (C) 2018-2019 SKALE Labs
This file is part of skale-consensus.
skale-consensus is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
skale-consensus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with skale-consensus. If not, see <https://www.gnu.org/licenses/>.
@file Log.cpp
@author Stan Kladko
@date 2018
*/
#include "spdlog/spdlog.h"
#include "sgxwallet_common.h"
#include "common.h"
#include "Log.h"
using namespace std;
void Log::setGlobalLogLevel(string &_s) {
globalLogLevel = logLevelFromString(_s);
}
level_enum Log::logLevelFromString(string &_s) {
level_enum result = trace;
if (_s == "trace")
result = trace;
else if (_s == "debug")
result = debug;
else if (_s == "info")
result = info;
else if (_s == "warn")
result = warn;
else if (_s == "err")
result = err;
else
throw InvalidArgumentException("Unknown level name " + _s, __CLASS_NAME__);
return result;
}
/*
Copyright (C) 2018-2019 SKALE Labs
This file is part of skale-consensus.
skale-consensus is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
skale-consensus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with skale-consensus. If not, see <https://www.gnu.org/licenses/>.
@file Log.h
@author Stan Kladko
@date 2018
*/
#ifndef _LOG_H
#define _LOG_H
#include <stdlib.h>
#include <iostream>
#include <map>
#include <memory>
#include "InvalidArgumentException.h"
#include "InvalidStateException.h"
#include "common.h"
using namespace std;
class Exception;
#define __CLASS_NAME__ className( __PRETTY_FUNCTION__ )
#define LOG( __SEVERITY__, __MESSAGE__ ) \
cerr << to_string(__SEVERITY__) << " " << __MESSAGE__ << " " << className( __PRETTY_FUNCTION__ ) << endl;
enum level_enum { trace, debug, info, warn, err };
class Log {
public:
level_enum globalLogLevel;
void setGlobalLogLevel( string& _s );
static level_enum logLevelFromString(string &_s);
};
#endif
......@@ -66,11 +66,13 @@ bin_PROGRAMS = sgxwallet testw cert_util
## You can't use $(wildcard ...) with automake so all source files
## have to be explicitly listed.
COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c
COMMON_SRC = InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp \
SGXWalletServer.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp RPCException.cpp BLSCrypto.cpp ECDSACrypto.cpp \
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp ServerDataChecker.cpp SEKManager.cpp \
sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c
COMMON_ENCLAVE_SRC = secure_enclave_u.c secure_enclave_u.h
sgxwallet_SOURCES = sgxwallet.c SGXWalletServer.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp RPCException.cpp BLSCrypto.cpp ECDSACrypto.cpp \
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp ServerDataChecker.cpp SEKManager.cpp $(COMMON_SRC)
sgxwallet_SOURCES = sgxwallet.c $(COMMON_SRC)
nodist_sgxwallet_SOURCES = $(COMMON_ENCLAVE_SRC)
......@@ -104,13 +106,12 @@ sgxwallet_LDADD=-l$(SGX_URTS_LIB) -l$(SGX_UAE_SERVICE_LIB) -LlibBLS/deps/deps_in
-lgnutls -lgcrypt -lcurl -lssl -lcrypto -lz -lpthread
testw_SOURCES=testw.cpp stubclient.cpp SGXWalletServer.cpp RPCException.cpp BLSCrypto.cpp ServerInit.cpp LevelDB.cpp \
DKGCrypto.cpp BLSPrivateKeyShareSGX.cpp ECDSACrypto.cpp ServerDataChecker.cpp SEKManager.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp $(COMMON_SRC)
testw_SOURCES=testw.cpp $(COMMON_SRC)
nodist_testw_SOURCES=${nodist_sgxwallet_SOURCES}
EXTRA_testw_DEPENDENCIES=${EXTRA_sgxwallet_DEPENDENCIES}
testw_LDADD= ${sgxwallet_LDADD}
cert_util_SOURCES=cert_util.cpp stubclient.cpp RPCException.cpp LevelDB.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp
cert_util_SOURCES= InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp cert_util.cpp stubclient.cpp RPCException.cpp LevelDB.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp
cert_util_LDADD=-LlibBLS/deps/deps_inst/x86_or_x64/lib -Lleveldb/build -LlibBLS/build \
-LlibBLS/build/libff/libff \
-l:libbls.a -l:libleveldb.a \
......
......@@ -227,12 +227,10 @@ void enter_SEK(){
void init_SEK(){
std::shared_ptr<std::string> encr_SEK_ptr = LevelDB::getLevelDb()->readString("SEK");
if (encr_SEK_ptr == nullptr){
spdlog::info("SEK was not created yet. Going to create SEK");
spdlog::error("SEK was not created yet. Going to create SEK");
gen_SEK();
}
else{
if (printDebugInfo)
spdlog::info("going to set SEK from db" );
set_SEK(encr_SEK_ptr);
}
}
......
......@@ -46,10 +46,10 @@
#include "spdlog/spdlog.h"
#include "common.h"
int printDebugInfo = 0;
int useHTTPS = 1;
int encryptKeys = 0;
bool autoconfirm = false;
int printDebugInfo = -1;
int useHTTPS = -1;
int encryptKeys = -1;
int autoconfirm = -1;
SGXRegistrationServer *registrationServer = nullptr;
HttpServer *httpServer2 = nullptr;
......@@ -164,13 +164,13 @@ Json::Value GetSertificateImpl(const string &hash) {
}
Json::Value SGXRegistrationServer::signCertificate(const string &csr) {
Json::Value SGXRegistrationServer::SignCertificate(const string &csr) {
spdlog::info("Enter signCertificate ");
lock_guard<recursive_mutex> lock(m);
return signCertificateImpl(csr, autoSign);
}
Json::Value SGXRegistrationServer::getCertificate(const string &hash) {
Json::Value SGXRegistrationServer::GetCertificate(const string &hash) {
lock_guard<recursive_mutex> lock(m);
return GetSertificateImpl(hash);
}
......
......@@ -42,8 +42,8 @@ public:
void set_cert_created(bool b);
virtual Json::Value signCertificate(const std::string& csr);
virtual Json::Value getCertificate(const std::string& hash);
virtual Json::Value SignCertificate(const std::string& csr);
virtual Json::Value GetCertificate(const std::string& hash);
};
......
This diff is collapsed.
......@@ -31,6 +31,8 @@
#endif
EXTERNC void setFullOptions(int _printDebugInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys);
EXTERNC void setOptions(int _printDebugInfo, int _useHTTPS, int _autoconfirm);
......
......@@ -25,9 +25,11 @@
#define SGXWALLET_SGXWALLETSERVER_HPP
#include "abstractstubserver.h"
#include <mutex>
#include "abstractstubserver.h"
#include "BLSCrypto.hpp"
using namespace jsonrpc;
using namespace std;
......@@ -112,7 +114,7 @@ public:
static Json::Value getVerificationVectorImpl(const string &_polyName, int _t, int _n);
static Json::Value getSecretShareImpl(const string &_polyName, const Json::Value &_publicKeys, int _t, int _n);
static Json::Value getSecretShareImpl(const string &_polyName, const Json::Value &_pubKeys, int _t, int _n);
static Json::Value
dkgVerificationImpl(const string &_publicShares, const string &_ethKeyName, const string &_secretShare,
......
......@@ -22,71 +22,52 @@
*/
#include <memory>
#include <iostream>
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "libff/algebra/curves/alt_bn128/alt_bn128_init.hpp"
#include "bls.h"
#include "leveldb/db.h"
#include <jsonrpccpp/server/connectors/httpserver.h>
#include "BLSPrivateKeyShareSGX.h"
#include "spdlog/spdlog.h"
#include <gmp.h>
#include <sgx_urts.h>
#include "BLSPrivateKeyShareSGX.h"
#include "sgxwallet_common.h"
#include "create_enclave.h"
#include "secure_enclave_u.h"
#include "sgx_detect.h"
#include <gmp.h>
#include <sgx_urts.h>
#include "sgxwallet.h"
#include "LevelDB.h"
#include "SGXWalletServer.h"
#include "SGXRegistrationServer.h"
#include "SEKManager.h"
#include "CSRManagerServer.h"
#include "BLSCrypto.h"
#include "ServerInit.h"
#include <iostream>
#include "spdlog/spdlog.h"
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "SGXWalletServer.hpp"
#include "SGXWALLET_VERSION"
//#include <system>
void initDaemon() {
void initUserSpace() {
libff::init_alt_bn128_params();
LevelDB::initDataFolderAndDBs();
}
void initEnclave() {
eid = 0;
updated = 0;
#ifndef SGX_HW_SIM
unsigned long support;
support = get_sgx_support();
......@@ -96,9 +77,8 @@ void initEnclave() {
}
#endif
if ( printDebugInfo) {
spdlog::info("SGX_DEBUG_FLAG = {}", SGX_DEBUG_FLAG);
}
spdlog::debug("SGX_DEBUG_FLAG = {}", SGX_DEBUG_FLAG);
status = sgx_create_enclave_search(ENCLAVE_NAME, SGX_DEBUG_FLAG, &token,
&updated, &eid, 0);
......@@ -108,13 +88,13 @@ void initEnclave() {
fprintf(stderr, "sgx_create_enclave: %s: file not found\n", ENCLAVE_NAME);
fprintf(stderr, "Did you forget to set LD_LIBRARY_PATH?\n");
} else {
spdlog::error("sgx_create_enclave_search failed");
fprintf(stderr, "%s: 0x%04x\n", ENCLAVE_NAME, status);
}
exit(1);
}
//fprintf(stderr, "Enclave launched\n");
spdlog::info( "Enclave launched");
spdlog::info("Enclave created and started successfully");
status = tgmp_init(eid);
if (status != SGX_SUCCESS) {
......@@ -122,38 +102,27 @@ void initEnclave() {
exit(1);
}
if (printDebugInfo) {
spdlog::info("libtgmp initialized");
//fprintf(stderr, "libtgmp initialized\n");
}
spdlog::info("Enclave libtgmp library initialized successfully");
}
int sgxServerInited = 0;
void initAll(bool _checkCert, bool _autoSign, void (*SEK_func)()) {
void initAll(bool _checkCert, bool _autoSign) {
cout << "Running sgxwallet version:" << SGXWALLET_VERSION << endl;
//spdlog::set_pattern("%c");
if (sgxServerInited == 1)
return;
initEnclave();
initDaemon();
//init_SEK();
SEK_func();
CHECK_STATE(sgxServerInited == 0)
sgxServerInited = 1;
initEnclave();
initUserSpace();
init_SEK();
if (useHTTPS) {
SGXWalletServer::initHttpsServer(_checkCert);
initRegistrationServer(_autoSign);
init_csrmanager_server();
}
else {
} else {
SGXWalletServer::initHttpServer();
}
//std::cerr << "enclave inited" << std::endl;
}
......@@ -30,9 +30,9 @@
#define EXTERNC
#endif
EXTERNC void initAll(bool _checkCert, bool _autoSign, void (*func)());
EXTERNC void initAll(bool _checkCert, bool _autoSign);
EXTERNC void initDaemon();
EXTERNC void initUserSpace();
EXTERNC void initEnclave();
......
......@@ -39,16 +39,16 @@ public:
inline virtual void signCertificateI(const Json::Value &request, Json::Value &response)
{
std::cerr << "signCertificateI in abstr server " << std::endl;
response = this->signCertificate( request["certificate"].asString());
response = this->SignCertificate(request["certificate"].asString());
}
inline virtual void getCertificateI(const Json::Value &request, Json::Value &response)
{
response = this->getCertificate( request["hash"].asString());
response = this->GetCertificate(request["hash"].asString());
}
virtual Json::Value signCertificate(const std::string& cert) = 0;
virtual Json::Value getCertificate(const std::string& hash) = 0;
virtual Json::Value SignCertificate(const std::string& cert) = 0;
virtual Json::Value GetCertificate(const std::string& hash) = 0;
};
......
......@@ -32,15 +32,29 @@ using namespace std;
#include <map>
#include <memory>
#define CHECK_ARGUMENT(_EXPRESSION_) \
if (!(_EXPRESSION_)) { \
auto __msg__ = string("Argument Check failed:") + #_EXPRESSION_ + "\n" + __CLASS_NAME__ + ":" + __FUNCTION__ + \
+ " " + string(__FILE__) + ":" + to_string(__LINE__); \
throw runtime_error(__msg__);}
#include "InvalidStateException.h"
inline std::string className(const std::string &prettyFunction) {
size_t colons = prettyFunction.find("::");
if (colons == std::string::npos)
return "::";
size_t begin = prettyFunction.substr(0, colons).rfind(" ") + 1;
size_t end = colons - begin;
return prettyFunction.substr(begin, end);
}
#define __CLASS_NAME__ className( __PRETTY_FUNCTION__ )
#define CHECK_STATE(_EXPRESSION_) \
if (!(_EXPRESSION_)) { \
auto __msg__ = string("State check failed::") + #_EXPRESSION_ + " " + string(__FILE__) + ":" + to_string(__LINE__); \
throw runtime_error(__msg__);}
throw InvalidStateException(__msg__, __CLASS_NAME__);}
#endif //SGXWALLET_COMMON_H
......@@ -5,25 +5,25 @@ cd /usr/src/sdk;
echo $1
if [ "$1" = -t ]; then
set -e
# ./testw [bls-key-encrypt]
# ./testw [bls-key-encrypt-decrypt]
# ./testw [dkg-gen]
# ./testw [dkg-pub_shares]
# ./testw [dkg-verify]
# ./testw [ecdsa_test]
# ./testw [test_test]
# ./testw [get_pub_ecdsa_key_test]
# ./testw [bls_dkg]
# ./testw [api_test]
# ./testw [getServerStatus_test]
# ./testw [dkg_api_test]
# ./testw [is_poly_test]
# ./testw [AES-encrypt-decrypt]
./testw [bls-key-encrypt]
#./testw [bls-key-encrypt-decrypt]
#./testw [dkg-gen]
#./testw [dkg-pub_shares]
#./testw [dkg-verify]
#./testw [ecdsa_test]
#./testw [test_test]
#./testw [get_pub_ecdsa_key_test]
#./testw [bls_dkg]
#./testw [api_test]
#./testw [getServerStatus_test]
#./testw [dkg_api_test]
#./testw [is_poly_test]
#./testw [AES-encrypt-decrypt]
#./testw [ecdsa_api_test]
#./testw [dkg-encr_sshares]
#./testw [bls_sign]
#./testw [many_threads_test]
# ./testw [aes_dkg]
#./testw [bls_sign]
#/testw [many_threads_test]
#./testw [aes_dkg]
else
./sgxwallet $1 $2 $3 $4
fi
......
......@@ -70,11 +70,7 @@ cd scripts; ./build.py; cd ..
Go to the project's top directory, then run
```bash
libtoolize --force
aclocal
autoheader
automake --force-missing --add-missing
autoconf
./autoconf.bash
./configure
make
......
version: '3'
services:
sgxwallet:
image: skalenetwork/sgxwallet:latest_commit
image: skalenetwork/sgxwallet:latest
ports:
- "1026:1026"
- "1027:1027"
......@@ -17,6 +17,7 @@ services:
max-size: "10m"
max-file: "4"
restart: unless-stopped
command: -s -d -y
command: -s
healthcheck:
test: ["CMD", "ls /dev/isg /dev/mei0"]
#!/bin/bash
cd ../skale-admin
source skale-admin/bin/activate
docker stop $(docker ps -a -q)
docker pull skalenetwork/sgxwalletsim:latest
ETH_PRIVATE_KEY=3dd85d854e41db7585080dfdb90f88a83f0c70e229c509a4a1da63d0c82d5ad0 MANAGER_BRANCH=delegation-fix bash ./scripts/deploy_manager.sh
ETH_PRIVATE_KEY=3dd85d854e41db7585080dfdb90f88a83f0c70e229c509a4a1da63d0c82d5ad0 IMA_ENDPOINT=http://localhost:1000 SCHAIN_TYPE=test2 bash ./scripts/run_tests.sh
......@@ -65,18 +65,23 @@ void printUsage() {
}
int main(int argc, char *argv[]) {
void (*SEK_initializer)();
SEK_initializer = init_SEK;
bool checkClientCert = true;
bool sign_automatically = false;
bool encryptKeysOption = false;
bool useHTTPSOption = true;
bool printDebugInfoOption = false;
bool autoconfirmOption = false;
bool checkClientCertOption = true;
bool autoSignClientCertOption = false;
int opt;
if (argc > 1 && strlen(argv[1]) == 1) {
fprintf(stderr, "option is too short %s\n", argv[1]);
printUsage();
exit(1);
}
encryptKeys = 0;
while ((opt = getopt(argc, argv, "cshd0aby")) != -1) {
switch (opt) {
......@@ -90,25 +95,25 @@ int main(int argc, char *argv[]) {
exit(1);
}
case 'c':
checkClientCert = false;
checkClientCertOption = false;
break;
case 's':
sign_automatically = true;
autoSignClientCertOption = true;
break;
case 'd':
printDebugInfo = 1;
printDebugInfoOption = true;
break;
case '0':
useHTTPS = 0;
useHTTPSOption = false;
break;
case 'a':
encryptKeys = 0;
encryptKeysOption = false;
break;
case 'b':
SEK_initializer = enter_SEK;
encryptKeysOption = false;
break;
case 'y':
autoconfirm = true;
autoconfirmOption = true;
break;
case '?':
printUsage();
......@@ -117,7 +122,10 @@ int main(int argc, char *argv[]) {
break;
}
}
initAll(checkClientCert, sign_automatically, SEK_initializer);
setFullOptions(printDebugInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption);
initAll(checkClientCertOption, autoSignClientCertOption);
while (true) {
sleep(10);
......
......@@ -30,17 +30,23 @@
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
extern int printDebugInfo;
extern int useHTTPS;
extern int encryptKeys;
extern bool autoconfirm;
extern int autoconfirm;
#define BUF_LEN 1024
#define BUF_LEN 4096
#define MAX_KEY_LENGTH 128
#define MAX_COMPONENT_LENGTH 80
......@@ -52,9 +58,6 @@ extern bool autoconfirm;
#define ADD_ENTROPY_SIZE 32
#define DKG_BUFER_LENGTH 2490//3060
#define DKG_MAX_SEALED_LEN 3050
#define SECRET_SHARE_NUM_BYTES 96
#define ECDSA_SKEY_LEN 65
......
This diff is collapsed.
#!/usr/bin/env python3
# Copyright (C) 2019-Present SKALE Labs
#
# This file is part of sgxwallet.
#
# sgxwallet is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# sgxwallet is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
#
# @file docker_test.py
# @author Stan Kladko
# @date 2020
#
import sys, getpass,os, subprocess, socket, time
username = getpass.getuser()
assert username == "root"
topDir = os.getcwd() + "/sgxwallet"
print("Starting build push")
print("Top directory is:" + topDir)
testList = ["[bls-key-encrypt]", "[dkg-gen]",
"[dkg-encr_sshares]",
"[dkg-verify]",
"[ecdsa_test]",
"[test_test]",
"[get_pub_ecdsa_key_test]",
"[bls_dkg]",
"[api_test]",
"[getServerStatus_test]",
"[many_threads_test]",
"[ecdsa_api_test]",
"[dkg_api_test]",
"[is_poly_test]",
# "[bls_sign]",
"[AES-encrypt-decrypt]"]
for t in testList:
print("Starting " + t)
assert subprocess.call(["./testw", t]) == 0
print("Ending " + t)
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