Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev authored Jun 7, 2022
2 parents a6730a8 + 3407b52 commit b29f902
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 159 deletions.
51 changes: 49 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: Checkout
uses: actions/checkout@v2

- uses: actions/setup-node@v1
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'

- name: Update apt
run: sudo add-apt-repository ppa:ubuntu-toolchain-r/test; sudo apt-get update
- name: Install packages
Expand All @@ -45,26 +51,51 @@ jobs:
cd deps
./build.sh
- name: Configure all
- name: Configure
run: |
export CC=gcc-9
export CXX=g++-9
export TARGET=all
mkdir -p build && cd build
cmake ..
- name: Build all
- name: Build
run: |
export CC=gcc-9
export CXX=g++-9
export TARGET=all
cd build
make -j$(nproc)
- name: Build dependencies wasm
run: |
export CC=gcc-9
export CXX=g++-9
export TARGET=all
cd deps
./clean.sh
./build.sh WITH_EMSCRIPTEN=1
cd ..
- name: Build wasm
run: |
cd deps/emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ../..
mkdir -p build_em && cd build_em
export LIBRARIES_ROOT=../deps/deps_inst/x86_or_x64/lib
emcmake cmake -DEMSCRIPTEN=ON .. -DGMP_LIBRARY="$LIBRARIES_ROOT"/libgmp.a -DCRYPTOPP_LIBRARY="$LIBRARIES_ROOT"/libcrypto.a -DGMPXX_LIBRARY="$LIBRARIES_ROOT"/libgmpxx.a
emmake make -j$(nproc)
cd ..
cp build_em/threshold_encryption/encrypt.js node/
- name: Calculate version
run: |
export BRANCH=${GITHUB_REF##*/}
echo "Branch $BRANCH"
echo "::set-env name=BRANCH::$BRANCH"
export VERSION=$(cat VERSION.txt)
export VERSION=$(bash ./scripts/calculate_version.sh $BRANCH $VERSION)
echo "::set-env name=VERSION::$VERSION"
Expand All @@ -74,6 +105,22 @@ jobs:
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

- name: Publish on npm
if: github.ref != 'refs/heads/stable'
run: |
cd node
npm version --no-git-tag-version ${{ env.VERSION }}
npm publish --access public --tag ${{ env.BRANCH }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish on npm (stable)
if: github.ref == 'refs/heads/stable'
run: |
cd node
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create Release
id: create_release
uses: actions/create-release@latest
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ jobs:
export CC=gcc-9
export CXX=g++-9
export TARGET=all
export CMAKE_BUILD_FLAGS="-DCOVERAGE=ON"
cd deps
./build.sh WITH_EMSCRIPTEN=1
cd ..
Expand Down
15 changes: 7 additions & 8 deletions bls/BLSSigShare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ size_t BLSSigShare::getSignerIndex() const {
}

std::shared_ptr< std::string > BLSSigShare::toString() {
char str[512];

sigShare->to_affine_coordinates();
std::string ret = "";
ret += libBLS::ThresholdUtils::fieldElementToString( sigShare->X ) + ':' +
libBLS::ThresholdUtils::fieldElementToString( sigShare->Y ) + ':' + hint;

gmp_sprintf( str, "%Nd:%Nd:%s", sigShare->X.as_bigint().data, libff::alt_bn128_Fq::num_limbs,
sigShare->Y.as_bigint().data, libff::alt_bn128_Fq::num_limbs, hint.c_str() );

return std::make_shared< std::string >( str );
return std::make_shared< std::string >( ret );
}

BLSSigShare::BLSSigShare( std::shared_ptr< std::string > _sigShare, size_t _signerIndex,
Expand Down Expand Up @@ -116,9 +114,10 @@ BLSSigShare::BLSSigShare( const std::shared_ptr< libff::alt_bn128_G1 >& _sigShar
throw libBLS::ThresholdUtils::IncorrectInput( "Zero signer index" );
}

if ( _hint.length() == 0 ) {
throw libBLS::ThresholdUtils::IncorrectInput( "Empty or misformatted hint" );
if ( _hint.length() == 0 || _hint.length() > 2 * BLS_MAX_COMPONENT_LEN ) {
throw libBLS::ThresholdUtils::IncorrectInput( "Wrong BLS hint" );
}
libBLS::ThresholdUtils::ParseHint( _hint );

if ( !_sigShare->is_well_formed() ) {
throw libBLS::ThresholdUtils::IsNotWellFormed( "signature is not from G1" );
Expand Down
14 changes: 6 additions & 8 deletions bls/BLSSignature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ BLSSignature::BLSSignature( const std::shared_ptr< libff::alt_bn128_G1 > sig, st
if ( sig->is_zero() ) {
throw libBLS::ThresholdUtils::IncorrectInput( "Zero BLS signature" );
}
if ( hint.length() == 0 ) {
throw libBLS::ThresholdUtils::IncorrectInput( "Empty BLS hint" );
if ( _hint.length() == 0 || _hint.length() > 2 * BLS_MAX_COMPONENT_LEN ) {
throw libBLS::ThresholdUtils::IncorrectInput( "Wrong BLS hint" );
}
}

Expand Down Expand Up @@ -92,14 +92,12 @@ BLSSignature::BLSSignature(
}

std::shared_ptr< std::string > BLSSignature::toString() {
char str[512];

sig->to_affine_coordinates();
std::string ret = "";
ret += libBLS::ThresholdUtils::fieldElementToString( sig->X ) + ':' +
libBLS::ThresholdUtils::fieldElementToString( sig->Y ) + ':' + hint;

gmp_sprintf( str, "%Nd:%Nd:%s", sig->X.as_bigint().data, libff::alt_bn128_Fq::num_limbs,
sig->Y.as_bigint().data, libff::alt_bn128_Fq::num_limbs, hint.c_str() );

return std::make_shared< std::string >( str );
return std::make_shared< std::string >( ret );
}

std::string BLSSignature::getHint() const {
Expand Down
2 changes: 0 additions & 2 deletions bls/bls.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

#include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>

static constexpr size_t BLS_MAX_COMPONENT_LEN = 80;

static constexpr size_t BLS_MAX_SIG_LEN = 240;


Expand Down
44 changes: 0 additions & 44 deletions node/encryptTransaction.html

This file was deleted.

55 changes: 0 additions & 55 deletions node/encryptTransaction.js

This file was deleted.

32 changes: 20 additions & 12 deletions node/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
{
"name": "encryptte-test",
"version": "1.0.0",
"dependencies": {
"@babel/core": "^7.13.8",
"babel-core": "6.26.3",
"babel-loader": "8.1.0",
"web3": "1.3.0",
"webpack": "4.43.0"
},
"devDependencies": {
"webpack-cli": "^3.3.6"
}
"name": "@skalenetwork/t-encrypt",
"version": "0.1.0",
"keywords": [
"SKALE",
"blockchain",
"ethereum",
"threshold",
"cryptography",
"encryption"
],
"homepage": "https://github.com/skalenetwork/libBLS",
"license": "AGPL-3.0",
"author": "SKALE Labs and contributors",
"publishConfig": {
"access": "public"
},
"scripts": {
"version": "node -e \"console.log(require('./package.json').version);\""
}
}

25 changes: 0 additions & 25 deletions node/webpack.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion threshold_encryption/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if (BUILD_TESTS)
add_executable(te_sample_sgx ../test/te_sample_sgx.cpp)
target_include_directories(te_sample_sgx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${THIRD_PARTY_DIR})
target_link_libraries(te_sample_sgx PRIVATE te bls ${CRYPTOPP_LIBRARY} ff ${GMPXX_LIBRARY} ${GMP_LIBRARY}
jsonrpccpp-client jsonrpccpp-server jsonrpccpp-common jsoncpp curl pthread ssl crypto z)
jsonrpccpp-client jsonrpccpp-server jsonrpccpp-common jsoncpp curl pthread ssl crypto z idn2)
endif()

add_test(NAME te_wrap_tests COMMAND te_unit_test)
Expand Down
3 changes: 2 additions & 1 deletion tools/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ std::pair< libff::alt_bn128_Fq, libff::alt_bn128_Fq > ThresholdUtils::ParseHint(
const std::string& _hint ) {
auto position = _hint.find( ":" );

if ( position == std::string::npos ) {
if ( position == std::string::npos || position > BLS_MAX_COMPONENT_LEN ||
_hint.length() - position - 1 > BLS_MAX_COMPONENT_LEN ) {
throw IncorrectInput( "Misformatted hint" );
}

Expand Down
2 changes: 2 additions & 0 deletions tools/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>

static constexpr size_t BLS_MAX_COMPONENT_LEN = 77;

namespace libBLS {

class ThresholdUtils {
Expand Down

0 comments on commit b29f902

Please sign in to comment.