Skip to content

Commit

Permalink
re-enable macos support
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev committed Dec 15, 2024
1 parent c598594 commit 932308e
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 55 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,42 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.info
osx_build_and_test:
runs-on: macos-13
steps:
- name: Extract repo name
run: echo ::set-env name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F /
'{print $2}')
shell: bash
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: Checkout
uses: actions/checkout@v2
- name: Install packages
run: |
brew install yasm texinfo shtool libtool coreutils
- name: Build dependencies
run: |
cd deps
./build.sh
- name: Configure all
run: |
mkdir -p build && cd build
cmake ..
- name: Build all
run: |
cd build
make -j$(sysctl -n hw.ncpu)
- name: Run tests
run: |
cp scripts/parameters.json build/
cd build
./bls_unit_test
./dkg_unit_test
./bls_test
./threshold_encryption/te_unit_test
./threshold_encryption/te_test
./dkg_attack
linux_build_with_emscripten:
runs-on: ubuntu-22.04
strategy:
Expand Down
68 changes: 34 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,48 +91,48 @@ endif()
set( CLANG_FORMAT_EXCLUDE_PATTERNS
${CMAKE_BINARY_DIR}
${DEPS_SOURCES_ROOT}
)
)
include( BlsFindClangFormat )

set( TOOLS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tools/")
set( DKG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dkg/")

set(sourses_bls
bls/bls.cpp
bls/BLSPrivateKeyShare.cpp
bls/BLSPrivateKey.cpp
bls/BLSPublicKeyShare.cpp
bls/BLSPublicKey.cpp
bls/BLSSignature.cpp
bls/BLSSigShare.cpp
bls/BLSSigShareSet.cpp
dkg/dkg.cpp
dkg/DKGBLSWrapper.cpp
dkg/DKGBLSSecret.cpp
third_party/cryptlite/base64.cpp
tools/utils.cpp
)
bls/bls.cpp
bls/BLSPrivateKeyShare.cpp
bls/BLSPrivateKey.cpp
bls/BLSPublicKeyShare.cpp
bls/BLSPublicKey.cpp
bls/BLSSignature.cpp
bls/BLSSigShare.cpp
bls/BLSSigShareSet.cpp
dkg/dkg.cpp
dkg/DKGBLSWrapper.cpp
dkg/DKGBLSSecret.cpp
third_party/cryptlite/base64.cpp
tools/utils.cpp
)

set(headers_bls
libBLS.h
bls/bls.h
bls/BLSPrivateKeyShare.h
bls/BLSPrivateKey.h
bls/BLSPublicKeyShare.h
bls/BLSPublicKey.h
bls/BLSSignature.h
bls/BLSSigShare.h
bls/BLSSigShareSet.h
dkg/dkg.h
dkg/DKGBLSWrapper.h
dkg/DKGBLSSecret.h
third_party/json.hpp
third_party/cryptlite/sha256.h
third_party/cryptlite/sha1.h
third_party/cryptlite/hmac.h
third_party/cryptlite/base64.h
tools/utils.h
)
libBLS.h
bls/bls.h
bls/BLSPrivateKeyShare.h
bls/BLSPrivateKey.h
bls/BLSPublicKeyShare.h
bls/BLSPublicKey.h
bls/BLSSignature.h
bls/BLSSigShare.h
bls/BLSSigShareSet.h
dkg/dkg.h
dkg/DKGBLSWrapper.h
dkg/DKGBLSSecret.h
third_party/json.hpp
third_party/cryptlite/sha256.h
third_party/cryptlite/sha1.h
third_party/cryptlite/hmac.h
third_party/cryptlite/base64.h
tools/utils.h
)

set(PROJECT_VERSION 0.2.0)
add_definitions(-DBLS_VERSION=${PROJECT_VERSION})
Expand Down
8 changes: 8 additions & 0 deletions bls/bls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ std::pair< libff::alt_bn128_Fr, libff::alt_bn128_G2 > Bls::KeysRecover(
throw ThresholdUtils::IncorrectInput( "not enough participants in the threshold group" );
}

if ( shares.size() > this->n_ || coeffs.size() > this->n_ ) {
throw ThresholdUtils::IncorrectInput( "too many participants in the threshold group" );
}

libff::alt_bn128_Fr secret_key = libff::alt_bn128_Fr::zero();

for ( size_t i = 0; i < this->t_; ++i ) {
Expand All @@ -365,6 +369,10 @@ libff::alt_bn128_G1 Bls::SignatureRecover( const std::vector< libff::alt_bn128_G
throw ThresholdUtils::IncorrectInput( "not enough participants in the threshold group" );
}

if ( shares.size() > this->n_ || coeffs.size() > this->n_ ) {
throw ThresholdUtils::IncorrectInput( "too many participants in the threshold group" );
}

libff::alt_bn128_G1 sign = libff::alt_bn128_G1::zero();

for ( size_t i = 0; i < this->t_; ++i ) {
Expand Down
36 changes: 24 additions & 12 deletions deps/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -565,17 +565,24 @@ then
then
env_restore
cd "$SOURCES_ROOT"
if [ ! -d "boost_1_68_0" ];
BOOST_NAME="boost_1_68_0"
BOOST_VERSION="1.68.0"
if [ "$UNIX_SYSTEM_NAME" = "Darwin" ];
then
BOOST_NAME="boost_1_82_0"
BOOST_VERSION="1.82.0"
fi
if [ ! -d "${BOOST_NAME}" ];
then
if [ ! -f "boost_1_68_0.tar.bz2" ];
if [ ! -f "${BOOST_NAME}.tar.bz2" ];
then
eval echo -e "${COLOR_INFO}downloading it${COLOR_DOTS}...${COLOR_RESET}"
eval "$WGET" https://sourceforge.net/projects/boost/files/boost/1.68.0/boost_1_68_0.tar.bz2
eval "$WGET" https://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/${BOOST_NAME}.tar.bz2
fi
echo -e "${COLOR_INFO}unpacking it${COLOR_DOTS}...${COLOR_RESET}"
tar -xf boost_1_68_0.tar.bz2
tar -xf ${BOOST_NAME}.tar.bz2
fi
cd boost_1_68_0
cd ${BOOST_NAME}
echo -e "${COLOR_INFO}configuring and building it${COLOR_DOTS}...${COLOR_RESET}"
if [[ "${WITH_EMSCRIPTEN}" -eq 1 ]];
then
Expand All @@ -592,7 +599,7 @@ then
else
if [ "$UNIX_SYSTEM_NAME" = "Darwin" ];
then
eval ./b2 cxxflags=-fPIC toolset=clang cxxstd=14 cflags=-fPIC "${PARALLEL_MAKE_OPTIONS}" --prefix="$INSTALL_ROOT" --layout=system variant=debug link=static threading=multi install
eval ./b2 cxxflags=-fPIC toolset=clang cxxstd=17 cflags=-fPIC "${PARALLEL_MAKE_OPTIONS}" --prefix="$INSTALL_ROOT" --layout=system variant=debug link=static threading=multi install
else
if [[ "${WITH_EMSCRIPTEN}" -eq 1 ]];
then
Expand Down Expand Up @@ -681,21 +688,26 @@ then
# requiired for libff
env_restore
cd "$SOURCES_ROOT"
if [ ! -d "gmp-6.1.2" ];
GMP_NAME="gmp-6.1.2"
if [ "$UNIX_SYSTEM_NAME" = "Darwin" ];
then
GMP_NAME="gmp-6.3.0"
fi
if [ ! -d "${GMP_NAME}" ];
then
if [ ! -f "gmp-6.1.2.tar.xz" ];
if [ ! -f ""${GMP_NAME}".tar.xz" ];
then
echo -e "${COLOR_INFO}getting it from gmp website${COLOR_DOTS}...${COLOR_RESET}"
eval "$WGET" https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz
eval "$WGET" https://ftp.gnu.org/gnu/gmp/"${GMP_NAME}".tar.xz
fi
echo -e "${COLOR_INFO}unpacking it${COLOR_DOTS}...${COLOR_RESET}"
eval tar -xf gmp-6.1.2.tar.xz
eval tar -xf "${GMP_NAME}".tar.xz
fi
cd gmp-6.1.2
cd "${GMP_NAME}"
echo -e "${COLOR_INFO}configuring it${COLOR_DOTS}...${COLOR_RESET}"
if [ "$UNIX_SYSTEM_NAME" = "Darwin" ];
then
eval ./configure "${CONF_CROSSCOMPILING_OPTS_GENERIC}" "${CONF_DEBUG_OPTIONS}" --enable-cxx --enable-static --disable-shared --build=x86_64-apple-darwin#{OS.kernel_version.major} --prefix="$INSTALL_ROOT"
eval ./configure "${CONF_CROSSCOMPILING_OPTS_GENERIC}" "${CONF_DEBUG_OPTIONS}" --enable-cxx --enable-static --disable-shared --disable-assembly --build=x86_64-apple-darwin#{OS.kernel_version.major} --prefix="$INSTALL_ROOT"
else
if [[ "${WITH_EMSCRIPTEN}" -eq 1 ]];
then
Expand Down
11 changes: 2 additions & 9 deletions deps/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,17 @@ rm -f ./*.tar.bz2
rm -f ./*.zip
echo "Cleaning upacked library folders..."
rm -rf ./libiconv-1.15
rm -rf ./zlib
rm -rf ./openssl
rm -rf ./curl
rm -rf ./libuv
rm -rf ./libwebsockets
rm -rf ./boost_1_68_0
rm -rf ./argtable2
rm -rf ./nettle-2.0
rm -rf ./nettle-3.4.1
rm -rf ./gnutls-3.6.5
rm -rf ./boost*
rm -rf ./libmicrohttpd
rm -rf ./jsoncpp
rm -rf ./libjson-rpc-cpp
rm -rf ./libcryptopp
rm -rf ./gmp-6.1.2
rm -rf ./gmp-6*
rm -rf ./libff
rm -rf ./emsdk
rm -rf ./jsoncpp
rm -rf ./libjson-rpc-cpp*
rm -rf ./zlib
rm -rf ./argtable2
Expand Down

0 comments on commit 932308e

Please sign in to comment.