Unverified Commit 8465cb08 authored by Stan Kladko's avatar Stan Kladko Committed by GitHub

Merge pull request #78 from skalenetwork/SKALE-2274-review-disabled-tests

Skale 2274 review disabled tests
parents c2cde3e9 86e8b271
...@@ -27,23 +27,25 @@ ...@@ -27,23 +27,25 @@
#include <string> #include <string>
#include <vector> #include <vector>
std::string gen_dkg_poly( int _t); using namespace std;
std::vector <std::vector<std::string>> get_verif_vect(const char* encryptedPolyHex, int t, int n); string gen_dkg_poly( int _t);
std::vector<std::string> splitString(const char* coeffs, const char symbol); vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int n);
std::string trustedGetSecretShares(const std::string& _polyName, const char* _encryptedPolyHex, const std::vector<std::string>& _publicKeys, int _t, int _n); vector<string> splitString(const char* coeffs, const char symbol);
string trustedGetSecretShares(const string& _polyName, const char* _encryptedPolyHex, const vector<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 decryptDHKey(const std::string& polyName, int ind); string decryptDHKey(const string& polyName, int ind);
bool CreateBLSShare( const std::string& blsKeyName, const char * s_shares, const char * encryptedKeyHex); bool CreateBLSShare( const string& blsKeyName, const char * s_shares, const char * encryptedKeyHex);
std::vector<std::string> GetBLSPubKey(const char * encryptedKeyHex); vector<string> GetBLSPubKey(const char * encryptedKeyHex);
std::vector<std::string> mult_G2(const std::string& x); vector<string> mult_G2(const string& x);
......
...@@ -29,7 +29,7 @@ RUN apt update && \ ...@@ -29,7 +29,7 @@ RUN apt update && \
make -s -j$(nproc) sdk_install_pkg psw_install_pkg && \ make -s -j$(nproc) sdk_install_pkg psw_install_pkg && \
./linux/installer/bin/sgx_linux_x64_sdk_2.5.100.49891.bin --prefix=/opt/intel && \ ./linux/installer/bin/sgx_linux_x64_sdk_2.5.100.49891.bin --prefix=/opt/intel && \
./linux/installer/bin/sgx_linux_x64_psw_2.5.100.49891.bin && \ ./linux/installer/bin/sgx_linux_x64_psw_2.5.100.49891.bin && \
cd .. && rm -rf linux-sgx/ && cd scripts && ./build.py && \ cd .. && rm -rf linux-sgx/ && cd scripts && ./build_deps.py && \
wget --progress=dot:mega -O - https://github.com/intel/dynamic-application-loader-host-interface/archive/072d233296c15d0dcd1fb4570694d0244729f87b.tar.gz | tar -xz && \ wget --progress=dot:mega -O - https://github.com/intel/dynamic-application-loader-host-interface/archive/072d233296c15d0dcd1fb4570694d0244729f87b.tar.gz | tar -xz && \
cd dynamic-application-loader-host-interface-072d233296c15d0dcd1fb4570694d0244729f87b && \ cd dynamic-application-loader-host-interface-072d233296c15d0dcd1fb4570694d0244729f87b && \
cmake . -DCMAKE_BUILD_TYPE=Release -DINIT_SYSTEM=SysVinit && \ cmake . -DCMAKE_BUILD_TYPE=Release -DINIT_SYSTEM=SysVinit && \
......
...@@ -24,20 +24,15 @@ ...@@ -24,20 +24,15 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "sgxwallet_common.h" #include "sgxwallet_common.h"
#include "common.h" #include "common.h"
#include "SGXException.h"
#include "Log.h" #include "Log.h"
using namespace std; using namespace std;
void Log::setGlobalLogLevel(string &_s) { void Log::setGlobalLogLevel(string &_s) {
globalLogLevel = logLevelFromString(_s); globalLogLevel = logLevelFromString(_s);
} }
level_enum Log::logLevelFromString(string &_s) { level_enum Log::logLevelFromString(string &_s) {
level_enum result = trace; level_enum result = trace;
...@@ -58,6 +53,11 @@ level_enum Log::logLevelFromString(string &_s) { ...@@ -58,6 +53,11 @@ level_enum Log::logLevelFromString(string &_s) {
} }
void Log::handleSGXException(Json::Value& _result, SGXException& _e ) {
spdlog::error("Responding with JSON error:" + _e.errString);
_result["status"] = _e.status;
_result["errorMessage"] = _e.errString;
}
...@@ -30,7 +30,11 @@ ...@@ -30,7 +30,11 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include "json/json.h"
#include "spdlog/spdlog.h"
#include "SGXException.h"
#include "InvalidArgumentException.h" #include "InvalidArgumentException.h"
#include "InvalidStateException.h" #include "InvalidStateException.h"
...@@ -39,21 +43,18 @@ ...@@ -39,21 +43,18 @@
using namespace std; using namespace std;
class Exception; class Exception;
#define __CLASS_NAME__ className( __PRETTY_FUNCTION__ ) #define __CLASS_NAME__ className( __PRETTY_FUNCTION__ )
#define LOG( __SEVERITY__, __MESSAGE__ ) \ #define LOG(__SEVERITY__, __MESSAGE__) \
cerr << to_string(__SEVERITY__) << " " << __MESSAGE__ << " " << className( __PRETTY_FUNCTION__ ) << endl; cerr << to_string(__SEVERITY__) << " " << __MESSAGE__ << " " << className( __PRETTY_FUNCTION__ ) << endl;
enum level_enum {
trace, debug, info, warn, err
enum level_enum { trace, debug, info, warn, err }; };
class Log { class Log {
...@@ -62,8 +63,16 @@ public: ...@@ -62,8 +63,16 @@ public:
level_enum globalLogLevel; level_enum globalLogLevel;
void setGlobalLogLevel( string& _s ); void setGlobalLogLevel(string &_s);
static level_enum logLevelFromString(string &_s); static level_enum logLevelFromString(string &_s);
static void handleSGXException(Json::Value &_result, SGXException &_e);
}; };
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; __RESULT__["status"] = 0; __RESULT__["errorMessage"] = "";
#define HANDLE_SGX_EXCEPTION(_RESULT_) catch (SGXException &__e) { Log::handleSGXException(_RESULT_, __e);}
#define LOCK(__M__) lock_guard<recursive_mutex> lock(__M__);
#endif #endif
#define SGXWALLET_VERSION "1.47.1" #define SGXWALLET_VERSION "1.48.1"
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
...@@ -106,10 +106,12 @@ void initEnclave(uint32_t _logLevel) { ...@@ -106,10 +106,12 @@ void initEnclave(uint32_t _logLevel) {
} }
int sgxServerInited = 0;
void initAll(uint32_t _logLevel, bool _checkCert, bool _autoSign) { void initAll(uint32_t _logLevel, bool _checkCert, bool _autoSign) {
static int sgxServerInited;
cout << "Running sgxwallet version:" << SGXWALLET_VERSION << endl; cout << "Running sgxwallet version:" << SGXWALLET_VERSION << endl;
CHECK_STATE(sgxServerInited == 0) CHECK_STATE(sgxServerInited == 0)
sgxServerInited = 1; sgxServerInited = 1;
......
# Building SGX wallet from source # Building SGX wallet from source
### Install Intel SGX SDK
The Intel SGX SDK is required for both Intel SGX hardware platform and Intel SGX simulator mode.
The following instructions download the Intel SGX SDK 2.5 and installs it in
`/opt/intel/sgxsdk/` :
```bash
sudo mkdir -p /opt/intel
cd /opt/intel
sudo wget https://download.01.org/intel-sgx/linux-2.5/rhel7.4-server/sgx_linux_x64_psw_2.5.100.49891.bin
echo "yes" | sudo bash ./sgx_linux_x64_sdk_2.5.100.49891.bin
```
This installs the Intel SGX SDK in the recommended location,
`/opt/intel/sgxsdk` .
The Intel SGX OpenSSL library expects the SDK to be here by default.
After installing, source the Intel SGX SDK activation script to set
`$SGX_SDK`, `$PATH`, `$PKG_CONFIG_PATH`, and `$LD_LIBRARY_PATH`.
Append this line to your login shell script (`~/.bashrc` or similar):
```bash
source /opt/intel/sgxsdk/environment
echo "source /opt/intel/sgxsdk/environment" >>~/.bashrc
```
To learn more about Intel SGX read the
[Intel SGX SDK documentation](https://software.intel.com/en-us/sgx-sdk/documentation)
or visit the [Intel SGX homepage](https://software.intel.com/en-us/sgx).
Downloads are listed at
[Intel SGX Downloads for Linux](https://01.org/intel-software-guard-extensions/downloads).
<!-- SPDX-License-Identifier: (AGPL-3.0-only OR CC-BY-4.0) -->
This document describes how to build sgxwallet on Ubuntu 18.04.
## Clone this repository and its submodules ## Clone this repository and its submodules
`git clone --recurse-submodules https://github.com/skalenetwork/sgxwallet.git` `git clone --recurse-submodules https://github.com/skalenetwork/sgxwallet.git`
## Install Prerequisites
```bash
sudo apt-get install build-essential make cmake gcc g++ yasm python libprotobuf10 flex bison automake libtool texinfo libgcrypt20-dev libgnutls28-dev
```
## Install required debian packages ## Install required debian packages
```bash ```bash
cd scripts; sudo ./install_packages.sh; cd .. cd scripts; sudo ./install_packages.sh; cd ..
``` ```
## Build dependencies ## Build dependencies
Dependencies only need to be built once. Dependencies only need to be built once.
```bash ```bash
cd scripts; ./build.py; cd .. cd scripts; ./build_deps.py; cd ..
```
## Set SGX environment variables
```bash
source sgx-sdk-build/sgxsdk/environment
``` ```
## Configure and build sgxwallet ## Configure and build sgxwallet
...@@ -80,7 +40,7 @@ Note: to run in simulation mode, add --enable-sgx-simulation flag when you run c ...@@ -80,7 +40,7 @@ Note: to run in simulation mode, add --enable-sgx-simulation flag when you run c
```bash ```bash
./configure --enable-sgx-simulation ./configure --enable-sgx-simulation
make
``` ```
## Build base Docker container ## Build base Docker container
......
...@@ -71,6 +71,8 @@ JSON_LIBS_DIR = topDir + "/jsonrpc" ...@@ -71,6 +71,8 @@ JSON_LIBS_DIR = topDir + "/jsonrpc"
#subprocess.call(["git", "submodule", "update", "--init"]) #subprocess.call(["git", "submodule", "update", "--init"])
print("Cleaning")
subprocess.call(["rm", "-f", "install-sh"]) subprocess.call(["rm", "-f", "install-sh"])
subprocess.call(["rm", "-f", "compile"]) subprocess.call(["rm", "-f", "compile"])
subprocess.call(["rm", "-f", "missing"]) subprocess.call(["rm", "-f", "missing"])
...@@ -85,24 +87,37 @@ subprocess.call(["rm", "-rf", SDK_DIR]) ...@@ -85,24 +87,37 @@ subprocess.call(["rm", "-rf", SDK_DIR])
assert subprocess.call(["cp", "configure.gmp", GMP_DIR + "/configure"]) == 0 assert subprocess.call(["cp", "configure.gmp", GMP_DIR + "/configure"]) == 0
print("Build LevelDB");
os.chdir(LEVELDB_DIR) os.chdir(LEVELDB_DIR)
assert subprocess.call(["bash", "-c", "mkdir -p build"]) == 0 assert subprocess.call(["bash", "-c", "mkdir -p build"]) == 0
os.chdir(LEVELDB_BUILD_DIR) os.chdir(LEVELDB_BUILD_DIR)
assert subprocess.call(["bash", "-c", "cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build ."]) == 0 assert subprocess.call(["bash", "-c", "cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build ."]) == 0
print("Build LibBLS");
os.chdir(BLS_DIR + "/deps") os.chdir(BLS_DIR + "/deps")
assert subprocess.call(["bash", "-c", "./build.sh"]) == 0 assert subprocess.call(["bash", "-c", "./build.sh"]) == 0
os.chdir(BLS_DIR) os.chdir(BLS_DIR)
assert subprocess.call(["bash", "-c", "cmake -H. -Bbuild"]) == 0 assert subprocess.call(["bash", "-c", "cmake -H. -Bbuild"]) == 0
os.chdir(BLS_DIR + "/build") os.chdir(BLS_DIR + "/build")
assert subprocess.call(["bash", "-c", "make"]) == 0 assert subprocess.call(["bash", "-c", "make"]) == 0
print("Build JSON");
os.chdir(JSON_LIBS_DIR) os.chdir(JSON_LIBS_DIR)
assert subprocess.call(["bash", "-c", "./build.sh"]) == 0 assert subprocess.call(["bash", "-c", "./build.sh"]) == 0
print("Install Linux SDK");
os.chdir(SCRIPTS_DIR) os.chdir(SCRIPTS_DIR)
assert subprocess.call(["bash", "-c", "./sgx_linux_x64_sdk_2.5.100.49891.bin --prefix=" + topDir + "/sgx-sdk-build"]) == 0 assert subprocess.call(["bash", "-c", "./sgx_linux_x64_sdk_2.5.100.49891.bin --prefix=" + topDir + "/sgx-sdk-build"]) == 0
print("Make GMP");
os.chdir(GMP_DIR) os.chdir(GMP_DIR)
assert subprocess.call(["bash", "-c", "./configure --prefix=" + TGMP_BUILD_DIR + " --disable-shared --enable-static --with-pic --enable-sgx --with-sgxsdk=" + SDK_DIR + "/sgxsdk"]) == 0 assert subprocess.call(["bash", "-c", "./configure --prefix=" + TGMP_BUILD_DIR + " --disable-shared --enable-static --with-pic --enable-sgx --with-sgxsdk=" + SDK_DIR + "/sgxsdk"]) == 0
......
#!/bin/bash #!/bin/bash
sudo dpkg -i *.deb sudo dpkg -i *.deb
sudo apt install ccache cmake flex bison yasm ccache autoconf texinfo libgcrypt20-dev libgnutls28-dev libtool pkg-config sudo apt install -y build-essential make gcc g++ yasm python libprotobuf10 flex bison automake
sudo apt install -y ccache cmake ccache autoconf texinfo libgcrypt20-dev libgnutls28-dev libtool pkg-config
This diff is collapsed.
//
// Created by kladko on 06.05.20.
//
#ifndef SGXWALLET_TESTW_H
#define SGXWALLET_TESTW_H
#define TEST_BLS_KEY_SHARE "4160780231445160889237664391382223604184857153814275770598791864649971919844"
#define TEST_BLS_KEY_NAME "SCHAIN:17:INDEX:5:KEY:1"
#define SAMPLE_HASH "09c6137b97cdf159b9950f1492ee059d1e2b10eaf7d51f3a97d61f2eee2e81db"
#define SAMPLE_HEX_HASH "3F891FDA3704F0368DAB65FA81EBE616F4AA2A0854995DA4DC0B59D2CADBD64F"
#define SAMPLE_KEY_NAME "tmp_NEK:8abc8e8280fb060988b65da4b8cb00779a1e816ec42f8a40ae2daa520e484a01"
#define SAMPLE_AES_KEY "123456789"
#define SAMPLE_POLY_NAME "POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1"
#define RPC_ENDPOINT "http://localhost:1029"
#define SAMPLE_PUBLIC_KEY_B "c0152c48bf640449236036075d65898fded1e242c00acb45519ad5f788ea7cbf9a5df1559e7fc87932eee5478b1b9023de19df654395574a690843988c3ff475"
#define SAMPLE_DKG_PUB_KEY_1 "505f55a38f9c064da744f217d1cb993a17705e9839801958cda7c884e08ab4dad7fd8d22953d3ac7f0913de24fd67d7ed36741141b8a3da152d7ba954b0f14e2"
#define SAMPLE_DKG_PUB_KEY_2 "378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25"
#endif //SGXWALLET_TESTW_H
...@@ -35,21 +35,23 @@ print("Starting build push") ...@@ -35,21 +35,23 @@ print("Starting build push")
print("Top directory is:" + topDir) print("Top directory is:" + topDir)
testList = ["[bls-key-encrypt]", "[dkg-gen]", testList = ["[get-server-status]",
"[ecdsa-key-gen]",
"[ecdsa-key-sig-gen]",
"[ecdsa-get-pub-key]",
"[ecdsa-key-gen-api]",
"[ecdsa-key-gen-sign-api]",
"[bls-key-encrypt]",
"[dkg-gen]",
"[dkg-encr-sshares]", "[dkg-encr-sshares]",
"[dkg-verify]", "[dkg-verify]",
"[ecdsa]",
"[test]",
"[get-pub-ecdsa-key-test]",
"[bls-dkg]",
"[api]",
"[get-server-status]",
"[many-threads]",
"[ecdsa-api]",
"[dkg-api]", "[dkg-api]",
"[is-poly]", "[dkg-bls]",
# "[bls-sign]", "[dkg-poly-exists]",
"[aes-encrypt-decrypt]"] "[dkg-pub-shares]",
"[many-threads-crypto]",
"[aes-encrypt-decrypt]",
"[aes-dkg]"]
for t in testList: for t in testList:
......
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