diff --git a/AGENTS.md b/AGENTS.md index 16ab9ece6240..b0ce50892229 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -79,7 +79,7 @@ not checks at all: return an error, `AbortNode()`, or `InitError()`. Vendored or subtree-style code should normally be left alone: -- `src/{crc32c,dashbls,gsl,immer,leveldb,minisketch,secp256k1,univalue}` +- `src/{crc32c,gsl,immer,leveldb,mimalloc,minisketch,secp256k1,univalue}` - `src/crypto/{ctaes,x11}` `test/util/data/non-backported.txt` lists Dash-specific files used by Dash diff --git a/CLAUDE.md b/CLAUDE.md index 16ab9ece6240..b0ce50892229 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -79,7 +79,7 @@ not checks at all: return an error, `AbortNode()`, or `InitError()`. Vendored or subtree-style code should normally be left alone: -- `src/{crc32c,dashbls,gsl,immer,leveldb,minisketch,secp256k1,univalue}` +- `src/{crc32c,gsl,immer,leveldb,mimalloc,minisketch,secp256k1,univalue}` - `src/crypto/{ctaes,x11}` `test/util/data/non-backported.txt` lists Dash-specific files used by Dash diff --git a/Makefile.am b/Makefile.am index ea2cba9fd2fa..753c0f863748 100644 --- a/Makefile.am +++ b/Makefile.am @@ -170,7 +170,7 @@ LCOV_FILTER_PATTERN = \ -p "/usr/include/" \ -p "/usr/lib/" \ -p "/usr/lib64/" \ - -p "src/dashbls/" \ + -p "src/mimalloc/" \ -p "src/immer/" \ -p "src/leveldb/" \ -p "src/crc32c/" \ diff --git a/configure.ac b/configure.ac index 55b98d06336d..cd18845b68cb 100644 --- a/configure.ac +++ b/configure.ac @@ -883,18 +883,6 @@ case $host in export PKG_CONFIG_PATH="$($BREW --prefix qt@5 2>/dev/null)/lib/pkgconfig:$PKG_CONFIG_PATH" fi - gmp_prefix=$($BREW --prefix gmp 2>/dev/null) - if test "$gmp_prefix" != ""; then - if test "$suppress_external_warnings" != "no"; then - GMP_CPPFLAGS="-isystem $gmp_prefix/include" - else - GMP_CPPFLAGS="-I$gmp_prefix/include" - fi - GMP_LDFLAGS="-L$gmp_prefix/lib" - CORE_CPPFLAGS="$CORE_CPPFLAGS $GMP_CPPFLAGS" - CORE_LDFLAGS="$CORE_LDFLAGS $GMP_LDFLAGS" - fi - case $host in *aarch64*) dnl The preferred Homebrew prefix for Apple Silicon is /opt/homebrew. @@ -1695,15 +1683,9 @@ if test "$use_zmq" = "yes"; then esac fi -dnl check if libgmp is present -TEMP_CPPFLAGS="$CPPFLAGS" -TEMP_LDFLAGS="$LDFLAGS" -CPPFLAGS="$CPPFLAGS $GMP_CPPFLAGS" -LDFLAGS="$LDFLAGS $GMP_LDFLAGS" -AC_CHECK_HEADER([gmp.h],, AC_MSG_ERROR(libgmp headers missing)) -AC_CHECK_LIB([gmp], [__gmpz_init],GMP_LIBS=-lgmp, AC_MSG_ERROR(libgmp missing)) -CPPFLAGS="$TEMP_CPPFLAGS" -LDFLAGS="$TEMP_LDFLAGS" +dnl blst (BLS12-381 backend of src/bls), provided by depends or the system +AC_CHECK_HEADER([blst.h],, AC_MSG_ERROR([blst headers missing])) +AC_CHECK_LIB([blst], [blst_p1_compress], [BLST_LIBS=-lblst], AC_MSG_ERROR([libblst missing])) AM_CONDITIONAL([ENABLE_ZMQ], [test "$use_zmq" = "yes"]) @@ -2040,7 +2022,7 @@ AC_SUBST(MINIUPNPC_LIBS) AC_SUBST(BACKTRACE_FLAGS) AC_SUBST(BACKTRACE_LDFLAGS) AC_SUBST(BACKTRACE_LIBS) -AC_SUBST(GMP_LIBS) +AC_SUBST(BLST_LIBS) AC_SUBST(NATPMP_CPPFLAGS) AC_SUBST(NATPMP_LIBS) AC_SUBST(DSYMUTIL_FLAT) @@ -2081,7 +2063,7 @@ fi dnl The ECDH module is required by the wallet's Platform key provider dnl (DashPay contact request encryption, wallet/platformkeys.cpp). ac_configure_args="${ac_configure_args} --disable-shared --with-pic --enable-benchmark=no --enable-module-recovery --enable-module-ecdh --disable-openssl-tests" -AC_CONFIG_SUBDIRS([src/dashbls src/secp256k1]) +AC_CONFIG_SUBDIRS([src/secp256k1]) AC_OUTPUT diff --git a/contrib/debian/copyright b/contrib/debian/copyright index 19302d80a525..f25b3ab1ca5c 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -27,6 +27,11 @@ Files: src/qt/res/fonts/RobotoMono-Bold.ttf License: Apache-2.0 Comment: Site: https://fonts.google.com/specimen/Roboto+Mono +Files: src/mimalloc/* +Copyright: 2018-2025 Microsoft Corporation, Daan Leijen +License: Expat +Comment: Site: https://github.com/microsoft/mimalloc + License: Expat Permission is hereby granted, free of charge, to any person obtaining a diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py index effd8633aa10..fabd0e182609 100755 --- a/contrib/devtools/copyright_header.py +++ b/contrib/devtools/copyright_header.py @@ -37,7 +37,7 @@ # git subtrees "src/crc32c/", "src/crypto/ctaes/", - "src/dashbls/", + "src/mimalloc/", "src/gsl/", "src/immer/", "src/leveldb/", diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index 0c9fda7ad11d..942bc0cabd5c 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -270,7 +270,7 @@ mkdir -p "$DISTSRC" ${HOST_CXXFLAGS:+CXXFLAGS="${HOST_CXXFLAGS}"} \ ${HOST_LDFLAGS:+LDFLAGS="${HOST_LDFLAGS}"} - sed -i.old 's/-lstdc++ //g' {./,src/dashbls/,src/secp256k1/}{config.status,libtool} + sed -i.old 's/-lstdc++ //g' {./,src/secp256k1/}{config.status,libtool} # Build Dash Core diff --git a/depends/packages/blst.mk b/depends/packages/blst.mk new file mode 100644 index 000000000000..3fd4d7020734 --- /dev/null +++ b/depends/packages/blst.mk @@ -0,0 +1,24 @@ +package=blst +$(package)_version=0.3.17 +$(package)_download_path=https://github.com/supranational/blst/archive/refs/tags +$(package)_download_file=v$($(package)_version).tar.gz +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=c3fef37b566b67419703b2bbb648e15176276af9a880c22aa8f5f2e8cecc2e4d + +# build.sh takes CC/AR/RANLIB/CFLAGS from the environment. __BLST_PORTABLE__ +# selects runtime CPU dispatch instead of letting build.sh probe the builder's +# /proc/cpuinfo for ADX, which keeps the build reproducible; build.sh itself +# adds -D__BLST_NO_ASM__ on hosts other than x86_64/aarch64. +define $(package)_set_vars + $(package)_build_env=CC="$($(package)_cc)" AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CFLAGS="$($(package)_cflags) $($(package)_cppflags) -fno-builtin -fPIC -D__BLST_PORTABLE__" +endef + +define $(package)_build_cmds + ./build.sh +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/include $($(package)_staging_prefix_dir)/lib && \ + install -m 644 bindings/blst.h bindings/blst_aux.h $($(package)_staging_prefix_dir)/include && \ + install -m 644 libblst.a $($(package)_staging_prefix_dir)/lib +endef diff --git a/depends/packages/gmp.mk b/depends/packages/gmp.mk deleted file mode 100644 index 03ec302caede..000000000000 --- a/depends/packages/gmp.mk +++ /dev/null @@ -1,33 +0,0 @@ -package=gmp -$(package)_version=6.3.0 -$(package)_download_path=https://ftp.gnu.org/gnu/gmp -$(package)_file_name=gmp-$($(package)_version).tar.gz -$(package)_sha256_hash=e56fd59d76810932a0555aa15a14b61c16bed66110d3c75cc2ac49ddaa9ab24c -$(package)_patches=include_ldflags_in_configure.patch - -define $(package)_set_vars -$(package)_config_opts += --disable-shared --enable-cxx --enable-fat -$(package)_cflags_aarch64 += -march=armv8-a -$(package)_cflags_armv7l += -march=armv7-a -$(package)_cflags_x86_64 += -march=x86-64 -endef - -define $(package)_preprocess_cmds - patch -p1 < $($(package)_patch_dir)/include_ldflags_in_configure.patch -endef - -define $(package)_config_cmds - $($(package)_autoconf) -endef - -define $(package)_build_cmds - $(MAKE) -endef - -define $(package)_stage_cmds - $(MAKE) DESTDIR=$($(package)_staging_dir) install -endef - -define $(package)_postprocess_cmds - rm lib/*.la -endef diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 7e0bb2633219..ec5fcbab8f78 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -1,4 +1,4 @@ -packages:=gmp backtrace +packages:=backtrace blst boost_packages = boost diff --git a/depends/patches/gmp/include_ldflags_in_configure.patch b/depends/patches/gmp/include_ldflags_in_configure.patch deleted file mode 100644 index 8ddc304da0ec..000000000000 --- a/depends/patches/gmp/include_ldflags_in_configure.patch +++ /dev/null @@ -1,621 +0,0 @@ -Use LDFLAGS when configure is compiling test programs. - -Needed for macOS cross-compilation support using lld (ld64.lld) as -a linker, done by including '-fuse-ld=lld' in LDFLAGS. Defining it -in CC or CXX will result in unused argument warnings if the compiler -isn't expected to link files. - -diff --git a/acinclude.m4 b/acinclude.m4 -index 9cf9483..99edd43 100644 ---- a/acinclude.m4 -+++ b/acinclude.m4 -@@ -1752,7 +1752,7 @@ AC_CACHE_CHECK([if globals are prefixed by underscore], - cat >conftest.c <conftest.out - if grep "[[ ]]_gurkmacka" conftest.out >/dev/null; then -@@ -1984,7 +1984,7 @@ const int foo[[]] = {1,2,3}; - EOF - echo "Test program:" >&AC_FD_CC - cat conftest.c >&AC_FD_CC --gmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&AC_FD_CC" -+gmp_compile="$CC $CFLAGS $CPPFLAGS $LDFLAGS -S conftest.c >&AC_FD_CC" - if AC_TRY_EVAL(gmp_compile); then - echo "Compiler output:" >&AC_FD_CC - cat conftest.s >&AC_FD_CC -@@ -2382,7 +2382,7 @@ for tmp_underscore in "" "_"; do - ${tmp_gsym_prefix}main$gmp_cv_asm_label_suffix - addl $ ${tmp_underscore}_GLOBAL_OFFSET_TABLE_, %ebx - EOF -- gmp_compile="$CCAS $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.s >&AC_FD_CC && $CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.$OBJEXT >&AC_FD_CC" -+ gmp_compile="$CCAS $CFLAGS $CPPFLAGS $LDFLAGS $lt_prog_compiler_pic conftest.s >&AC_FD_CC && $CC $CFLAGS $CPPFLAGS $LDFLAGS $lt_prog_compiler_pic conftest.$OBJEXT >&AC_FD_CC" - if AC_TRY_EVAL(gmp_compile); then - if test "$tmp_underscore" = "_"; then - gmp_cv_asm_x86_got_underscore=yes -@@ -3019,7 +3019,7 @@ int *bar() { return &foo; } - EOF - echo "Test program:" >&AC_FD_CC - cat conftest.c >&AC_FD_CC --gmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&AC_FD_CC" -+gmp_compile="$CC $CFLAGS $CPPFLAGS $LDFLAGS -S conftest.c >&AC_FD_CC" - if AC_TRY_EVAL(gmp_compile); then - echo "Compiler output:" >&AC_FD_CC - cat conftest.s >&AC_FD_CC -@@ -3164,7 +3164,7 @@ AC_DEFUN([GMP_C_ATTRIBUTE_MALLOC], - [cat >conftest.c </dev/null; then - gmp_cv_c_attribute_malloc=no -@@ -3279,7 +3279,7 @@ int main(){ - return 0; - }] - EOF --gmp_compile="$CC $CFLAGS $CPPFLAGS conftest.c -o conftest$EXEEXT >&AC_FD_CC 2>&1" -+gmp_compile="$CC $CFLAGS $CPPFLAGS $LDFLAGS conftest.c -o conftest$EXEEXT >&AC_FD_CC 2>&1" - if AC_TRY_EVAL(gmp_compile); then - cat >conftest.awk <<\EOF - [ -diff --git a/configure b/configure -index 7910aa0..15121e2 100755 ---- a/configure -+++ b/configure -@@ -5885,7 +5885,7 @@ for abi in $abilist; do - choke me - #endif - EOF --gmp_compile="$cc -c conftest.c >&5" -+gmp_compile="$cc $LDFLAGS -c conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -5978,7 +5978,7 @@ if test "$gmp_prog_cc_works" = yes; then - int main () { return 0; } - EOF - echo "Test compile: " >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6032,7 +6032,7 @@ void *f() { return g(); } - int main () { return 0; } - EOF - echo "Test compile: function pointer return" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6088,7 +6088,7 @@ int cmov () { return (n >= 0 ? n : 0); } - int main () { return 0; } - EOF - echo "Test compile: cmov instruction" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6145,7 +6145,7 @@ unsigned long gcc303 () { return (unsigned long) d; } - int main () { return 0; } - EOF - echo "Test compile: double -> ulong conversion" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6200,7 +6200,7 @@ unsigned long fneg () { return -fneg_data; } - int main () { return 0; } - EOF - echo "Test compile: double negation" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6256,7 +6256,7 @@ float ftod () { return (float) ftod_data; } - int main () { return 0; } - EOF - echo "Test compile: double -> float conversion" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6341,7 +6341,7 @@ param_init () - int main () { return 0; } - EOF - echo "Test compile: gnupro alpha ev6 char spilling" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6392,7 +6392,7 @@ if test "$gmp_prog_cc_works" = yes; then - int k; int foo () { __builtin_alloca (k); } - EOF - echo "Test compile: __builtin_alloca availability" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6438,7 +6438,7 @@ int foo () - int main () { return 0; } - EOF - echo "Test compile: alloca array" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6516,7 +6516,7 @@ int f () - int main () { return 0; } - EOF - echo "Test compile: abs int -> double conversion" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6581,7 +6581,7 @@ int dummy; - int main () { return 0; } - EOF - echo "Test compile: long long reliability test 1" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6642,7 +6642,7 @@ int dummy; - int main () { return 0; } - EOF - echo "Test compile: long long reliability test 2" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6703,7 +6703,7 @@ int dummy; - int main () { return 0; } - EOF - echo "Test compile: freebsd hacked gcc" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6802,7 +6802,7 @@ main () - - EOF - echo "Test compile: mpn_lshift_com optimization" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6911,7 +6911,7 @@ main () - - EOF - echo "Test compile: mpn_lshift_com optimization 2" >&5 -- gmp_compile="$cc $cflags $cppflags conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -6970,7 +6970,7 @@ int foo; - int bar () { return foo; } - EOF - tmp_got_emitted=no --gmp_compile="$cc $cflags $cppflags -fPIC -S conftest.c >&5 2>&1" -+gmp_compile="$cc $cflags $cppflags $LDFLAGS -fPIC -S conftest.c >&5 2>&1" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7044,7 +7044,7 @@ cat >conftest.s <<\EOF - .byte 254, 220, 186, 152, 118, 84, 50, 16 - EOF - tmp_got_good=yes --gmp_compile="$cc $cflags $cppflags -fPIC -o conftest.o -c conftest.s >&5 2>&1" -+gmp_compile="$cc $cflags $cppflags $LDFLAGS -fPIC -o conftest.o -c conftest.s >&5 2>&1" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7094,7 +7094,7 @@ long long bar () { return foo; } - int main () { return 0; } - EOF - gmp_prog_cc_works=no --gmp_compile="$cc $cflags $cppflags -c conftest.c >&5" -+gmp_compile="$cc $cflags $cppflags $LDFLAGS -c conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7221,7 +7221,7 @@ result=no - cat >conftest.s <&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7256,7 +7256,7 @@ main () - } - EOF - gmp_c_testlist_sizeof=no --gmp_compile="$cc $cflags -c conftest.c >&5" -+gmp_compile="$cc $cflags $LDFLAGS -c conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7424,7 +7424,7 @@ _main: - xorl %eax, %eax - ret - EOF -- gmp_compile="$cc $cflags $cppflags conftest.s -o conftest >&5" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.s -o conftest >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7489,7 +7489,7 @@ $as_echo_n "checking compiler $cc $cflags -no-cpp-precomp... " >&6; } - cat >conftest.c <&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7522,7 +7522,7 @@ result=no - cat >conftest.c <&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7553,7 +7553,7 @@ result=no - cat >conftest.c <&5 --gmp_compile="$cc $cflags $cppflags -c conftest.c >&5 2>&1" -+gmp_compile="$cc $cflags $cppflags $LDFLAGS -c conftest.c >&5 2>&1" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7561,7 +7561,7 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - test $ac_status = 0; }; then : ; - else - # empty fails -- gmp_compile="$cc $cflags $cppflags -Wa,-oldas -c conftest.c >&5 2>&1" -+ gmp_compile="$cc $cflags $cppflags $LDFLAGS -Wa,-oldas -c conftest.c >&5 2>&1" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7597,7 +7597,7 @@ if test "$gmp_prog_cc_works" = yes; then - int main () { return 0; } - EOF - echo "Test compile: " >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7651,7 +7651,7 @@ void *f() { return g(); } - int main () { return 0; } - EOF - echo "Test compile: function pointer return" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7707,7 +7707,7 @@ int cmov () { return (n >= 0 ? n : 0); } - int main () { return 0; } - EOF - echo "Test compile: cmov instruction" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7764,7 +7764,7 @@ unsigned long gcc303 () { return (unsigned long) d; } - int main () { return 0; } - EOF - echo "Test compile: double -> ulong conversion" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7819,7 +7819,7 @@ unsigned long fneg () { return -fneg_data; } - int main () { return 0; } - EOF - echo "Test compile: double negation" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7875,7 +7875,7 @@ float ftod () { return (float) ftod_data; } - int main () { return 0; } - EOF - echo "Test compile: double -> float conversion" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -7960,7 +7960,7 @@ param_init () - int main () { return 0; } - EOF - echo "Test compile: gnupro alpha ev6 char spilling" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -8011,7 +8011,7 @@ if test "$gmp_prog_cc_works" = yes; then - int k; int foo () { __builtin_alloca (k); } - EOF - echo "Test compile: __builtin_alloca availability" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -8057,7 +8057,7 @@ int foo () - int main () { return 0; } - EOF - echo "Test compile: alloca array" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -8135,7 +8135,7 @@ int f () - int main () { return 0; } - EOF - echo "Test compile: abs int -> double conversion" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -8200,7 +8200,7 @@ int dummy; - int main () { return 0; } - EOF - echo "Test compile: long long reliability test 1" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -8261,7 +8261,7 @@ int dummy; - int main () { return 0; } - EOF - echo "Test compile: long long reliability test 2" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -8322,7 +8322,7 @@ int dummy; - int main () { return 0; } - EOF - echo "Test compile: freebsd hacked gcc" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -8421,7 +8421,7 @@ main () - - EOF - echo "Test compile: mpn_lshift_com optimization" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -8530,7 +8530,7 @@ main () - - EOF - echo "Test compile: mpn_lshift_com optimization 2" >&5 -- gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5" -+ gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -8589,7 +8589,7 @@ int foo; - int bar () { return foo; } - EOF - tmp_got_emitted=no --gmp_compile="$cc $cflags $cppflags $flag -fPIC -S conftest.c >&5 2>&1" -+gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS -fPIC -S conftest.c >&5 2>&1" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -8663,7 +8663,7 @@ cat >conftest.s <<\EOF - .byte 254, 220, 186, 152, 118, 84, 50, 16 - EOF - tmp_got_good=yes --gmp_compile="$cc $cflags $cppflags $flag -fPIC -o conftest.o -c conftest.s >&5 2>&1" -+gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS -fPIC -o conftest.o -c conftest.s >&5 2>&1" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -9974,7 +9974,7 @@ main () - return 0; - } - EOF --gmp_compile="$HOST_CC conftest.c" -+gmp_compile="$HOST_CC $LDFLAGS conftest.c" - cc_for_build_works=no - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 -@@ -10027,7 +10027,7 @@ else - fi - - else -- for i in "$CC" "$CC $CFLAGS $CPPFLAGS" cc gcc c89 c99; do -+ for i in "$CC" "$CC $CFLAGS $CPPFLAGS $LDFLAGS" cc gcc c89 c99; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system compiler $i" >&5 - $as_echo_n "checking build system compiler $i... " >&6; } - # remove anything that might look like compiler output to our "||" expression -@@ -10080,7 +10080,7 @@ else - #define FOO BAR - EOF - echo "Test compile: " >&5 -- gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS conftest.cc >&5" -+ gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS $LDFLAGS conftest.cc >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_cxxcompile\""; } >&5 - (eval $gmp_cxxcompile) 2>&5 - ac_status=$? -@@ -10570,7 +10570,7 @@ using namespace foo; - int main (void) { return 0; } - EOF - echo "Test compile: namespace" >&5 -- gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS conftest.cc >&5" -+ gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS $LDFLAGS conftest.cc >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_cxxcompile\""; } >&5 - (eval $gmp_cxxcompile) 2>&5 - ac_status=$? -@@ -10616,7 +10616,7 @@ void someoutput (void) { std::cout << 123; } - int main (void) { return 0; } - EOF - echo "Test compile: std iostream" >&5 -- gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS conftest.cc >&5" -+ gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS $LDFLAGS conftest.cc >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_cxxcompile\""; } >&5 - (eval $gmp_cxxcompile) 2>&5 - ac_status=$? -@@ -23651,7 +23651,7 @@ else - cat >conftest.c <&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -24421,7 +24421,7 @@ int main(){ - return 0; - } - EOF --gmp_compile="$CC $CFLAGS $CPPFLAGS conftest.c -o conftest$EXEEXT >&5 2>&1" -+gmp_compile="$CC $CFLAGS $CPPFLAGS $LDFLAGS conftest.c -o conftest$EXEEXT >&5 2>&1" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -25833,7 +25833,7 @@ else - cat >conftest.c <&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -25914,7 +25914,7 @@ const int foo[] = {1,2,3}; - EOF - echo "Test program:" >&5 - cat conftest.c >&5 --gmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&5" -+gmp_compile="$CC $CFLAGS $CPPFLAGS $LDFLAGS -S conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -26580,7 +26580,7 @@ int *bar() { return &foo; } - EOF - echo "Test program:" >&5 - cat conftest.c >&5 --gmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&5" -+gmp_compile="$CC $CFLAGS $CPPFLAGS $LDFLAGS -S conftest.c >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -@@ -27031,7 +27031,7 @@ for tmp_underscore in "" "_"; do - ${tmp_gsym_prefix}main$gmp_cv_asm_label_suffix - addl $ ${tmp_underscore}_GLOBAL_OFFSET_TABLE_, %ebx - EOF -- gmp_compile="$CCAS $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.s >&5 && $CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.$OBJEXT >&5" -+ gmp_compile="$CCAS $CFLAGS $CPPFLAGS $LDFLAGS $lt_prog_compiler_pic conftest.s >&5 && $CC $CFLAGS $CPPFLAGS $LDFLAGS $lt_prog_compiler_pic conftest.$OBJEXT >&5" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5 - (eval $gmp_compile) 2>&5 - ac_status=$? -diff --git a/configure.ac b/configure.ac -index 082077b..f43e1c1 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -2272,14 +2272,14 @@ for abi in $abilist; do - instrument) cflags="$cflags -finstrument-functions" ;; - esac - -- GMP_PROG_CC_WORKS($cc $cflags $cppflags,,continue) -+ GMP_PROG_CC_WORKS($cc $cflags $cppflags $LDFLAGS,,continue) - - # If we're supposed to be using a "long long" for a limb, check that - # it works. - eval limb_chosen=\"\$limb$abi1\" - test -n "$limb_chosen" || eval limb_chosen=\"\$limb$abi2\" - if test "$limb_chosen" = longlong; then -- GMP_PROG_CC_WORKS_LONGLONG($cc $cflags $cppflags,,continue) -+ GMP_PROG_CC_WORKS_LONGLONG($cc $cflags $cppflags $LDFLAGS,,continue) - fi - - # The tests to perform on this $cc, if any -@@ -2294,8 +2294,8 @@ for abi in $abilist; do - hpc-hppa-2-0) GMP_HPC_HPPA_2_0($cc,,testlist_pass=no) ;; - gcc-arm-umodsi) GMP_GCC_ARM_UMODSI($cc,,testlist_pass=no) ;; - gcc-mips-o32) GMP_GCC_MIPS_O32($cc,,testlist_pass=no) ;; -- hppa-level-2.0) GMP_HPPA_LEVEL_20($cc $cflags,,testlist_pass=no) ;; -- sizeof*) GMP_C_TEST_SIZEOF($cc $cflags,$tst,,testlist_pass=no) ;; -+ hppa-level-2.0) GMP_HPPA_LEVEL_20($cc $cflags $LDFLAGS,,testlist_pass=no) ;; -+ sizeof*) GMP_C_TEST_SIZEOF($cc $cflags $LDFLAGS,$tst,,testlist_pass=no) ;; - esac - if test $testlist_pass = no; then break; fi - done -@@ -2415,8 +2415,8 @@ if test $found_compiler = yes; then - # pentium4 case. - # - if test "$abi" = 32; then -- GMP_GCC_PENTIUM4_SSE2($cc $cflags $cppflags,, continue) -- GMP_OS_X86_XMM($cc $cflags $cppflags,, continue) -+ GMP_GCC_PENTIUM4_SSE2($cc $cflags $cppflags $LDFLAGS,, continue) -+ GMP_OS_X86_XMM($cc $cflags $cppflags $LDFLAGS,, continue) - fi - ;; - -no-cpp-precomp) -@@ -2429,19 +2429,19 @@ if test $found_compiler = yes; then - -Wa,-m*) - case $host in - alpha*-*-*) -- GMP_GCC_WA_MCPU($cc $cflags, $flag, , [continue]) -+ GMP_GCC_WA_MCPU($cc $cflags $LDFLAGS, $flag, , [continue]) - ;; - esac - ;; - -Wa,-oldas) -- GMP_GCC_WA_OLDAS($cc $cflags $cppflags, -+ GMP_GCC_WA_OLDAS($cc $cflags $cppflags $LDFLAGS, - [cflags="$cflags $flag" - break], - [continue]) - ;; - esac - -- GMP_PROG_CC_WORKS($cc $cflags $cppflags $flag, -+ GMP_PROG_CC_WORKS($cc $cflags $cppflags $flag $LDFLAGS, - [cflags="$cflags $flag" - break]) - done diff --git a/doc/build-freebsd.md b/doc/build-freebsd.md index d33629b551c8..ebe27d8d2ecb 100644 --- a/doc/build-freebsd.md +++ b/doc/build-freebsd.md @@ -24,12 +24,6 @@ git clone https://github.com/dashpay/dash.git ### 3. Install Optional Dependencies -###### GMP - -```bash -pkg install gmp -``` - It is not necessary to build wallet functionality to run either `dashd` or `dash-qt`. ###### Descriptor Wallet Support diff --git a/doc/build-netbsd.md b/doc/build-netbsd.md index 86f72e1096e4..780a048e2f1a 100644 --- a/doc/build-netbsd.md +++ b/doc/build-netbsd.md @@ -14,7 +14,7 @@ Install the required dependencies the usual way you [install software on NetBSD] The example commands below use `pkgin`. ```bash -pkgin install autoconf automake libtool pkg-config git gmake boost libevent gmp +pkgin install autoconf automake libtool pkg-config git gmake boost libevent ``` diff --git a/doc/build-openbsd.md b/doc/build-openbsd.md index 8b0ee196eb46..f6a371b9cc7e 100644 --- a/doc/build-openbsd.md +++ b/doc/build-openbsd.md @@ -10,7 +10,7 @@ This guide describes how to build dashd, command-line utilities, and GUI on Open Run the following as root to install the base dependencies for building. ```bash -pkg_add bash git gmake gmp libevent libtool boost +pkg_add bash git gmake libevent libtool boost # Select the newest version of the following packages: pkg_add autoconf automake python diff --git a/doc/build-osx.md b/doc/build-osx.md index 87914d09affc..e5e955f683c0 100644 --- a/doc/build-osx.md +++ b/doc/build-osx.md @@ -47,7 +47,7 @@ To install, run the following from your terminal: See [dependencies.md](dependencies.md) for a complete overview. ``` bash -brew install automake libtool boost gmp pkg-config libevent +brew install automake libtool boost pkg-config libevent ``` ### 4. Clone Dash repository diff --git a/doc/build-unix.md b/doc/build-unix.md index 419df8488ab1..01f1ef64bc7b 100644 --- a/doc/build-unix.md +++ b/doc/build-unix.md @@ -76,12 +76,6 @@ ZMQ dependencies (provides ZMQ API): sudo apt-get install libzmq3-dev ``` -GMP dependencies (provides platform-optimized routines): - -```sh -sudo apt-get install libgmp-dev -``` - User-Space, Statically Defined Tracing (USDT) dependencies: ```sh @@ -165,12 +159,6 @@ ZMQ dependencies (provides ZMQ API): sudo dnf install zeromq-devel ``` -GMP dependencies (provides platform-optimized routines): - -```sh -sudo dnf install gmp-devel -``` - User-Space, Statically Defined Tracing (USDT) dependencies: ```sh diff --git a/doc/dependencies.md b/doc/dependencies.md index a9be6395aaa0..40e06fe819ae 100644 --- a/doc/dependencies.md +++ b/doc/dependencies.md @@ -19,15 +19,12 @@ You can find installation instructions in the `build-*.md` file for your platfor | --- | --- | --- | --- | --- | | [Boost](../depends/packages/boost.mk) | [link](https://www.boost.org/users/download/) | 1.81.0 | [1.73.0](https://github.com/bitcoin/bitcoin/pull/29066) | No | | [libevent](../depends/packages/libevent.mk) | [link](https://github.com/libevent/libevent/releases) | [2.1.12-stable](https://github.com/bitcoin/bitcoin/pull/21991) | [2.1.8](https://github.com/bitcoin/bitcoin/pull/24681) | No | +| [blst](../depends/packages/blst.mk) | [link](https://github.com/supranational/blst/releases) | 0.3.17 | | No | | glibc | [link](https://www.gnu.org/software/libc/) | N/A | [2.31](https://github.com/bitcoin/bitcoin/pull/29987) | Yes | | Linux Kernel | [link](https://www.kernel.org/) | N/A | [3.17.0](https://github.com/bitcoin/bitcoin/pull/27699) | Yes | ## Optional -| Dependency | Releases | Version used | Minimum required | Runtime | -| --- | --- | --- | --- | --- | -| libgmp | [link](https://gmplib.org/download/gmp/)[ \* ](#note1) | 6.3.0 | [6.2.0](https://github.com/dashpay/bls-signatures/pull/92) | No | - ### GUI | Dependency | Releases | Version used | Minimum required | Runtime | | --- | --- | --- | --- | --- | @@ -52,5 +49,3 @@ You can find installation instructions in the `build-*.md` file for your platfor | --- | --- | --- | --- | --- | | [Berkeley DB](../depends/packages/bdb.mk) (legacy wallet) | [link](https://www.oracle.com/technetwork/database/database-technologies/berkeleydb/downloads/index.html) | 4.8.30 | 4.8.x | No | | [SQLite](../depends/packages/sqlite.mk) | [link](https://sqlite.org) | 3.38.5 | [3.7.17](https://github.com/bitcoin/bitcoin/pull/19077) | No | - -Note \* : The minimum supported version on macOS is 6.3.0 diff --git a/src/.bear-tidy-config b/src/.bear-tidy-config index 3512e59a781b..cd791effd273 100644 --- a/src/.bear-tidy-config +++ b/src/.bear-tidy-config @@ -6,7 +6,7 @@ "paths_to_exclude": [ "src/crc32", "src/crypto/x11", - "src/dashbls", + "src/mimalloc", "src/gsl", "src/immer", "src/leveldb", diff --git a/src/Makefile.am b/src/Makefile.am index c5b08a2e17f7..51f5e8421401 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,7 @@ endif # ENABLE_CRASH_HOOKS endif # ENABLE_STACKTRACES BITCOIN_INCLUDES=-I$(builddir) -I$(srcdir)/$(MINISKETCH_INCLUDE_DIR_INT) -I$(srcdir)/secp256k1/include -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) $(LEVELDB_CPPFLAGS) -BITCOIN_INCLUDES+=-isystem$(srcdir)/dashbls/include -isystem$(srcdir)/dashbls/depends/relic/include -isystem$(srcdir)/dashbls/depends/minialloc/include +BITCOIN_INCLUDES+=$(MIMALLOC_CPPFLAGS) BITCOIN_INCLUDES+=-isystem$(srcdir)/immer LIBBITCOIN_NODE=libbitcoin_node.a @@ -56,7 +56,6 @@ LIBBITCOIN_CLI=libbitcoin_cli.a LIBBITCOIN_UTIL=libbitcoin_util.a LIBBITCOIN_CRYPTO_BASE=crypto/libbitcoin_crypto_base.la LIBBITCOINQT=qt/libbitcoinqt.a -LIBDASHBLS=dashbls/libdashbls.la LIBSECP256K1=secp256k1/libsecp256k1.la if ENABLE_ZMQ @@ -110,9 +109,6 @@ LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_ARM_SHANI) endif noinst_LTLIBRARIES += $(LIBBITCOIN_CRYPTO) -$(LIBDASHBLS): - $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) - $(LIBSECP256K1): $(wildcard secp256k1/src/*.h) $(wildcard secp256k1/src/*.c) $(wildcard secp256k1/include/*) $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) @@ -925,6 +921,8 @@ libbitcoin_consensus_a_SOURCES = \ arith_uint256.h \ bls/bls.cpp \ bls/bls.h \ + bls/bls_legacy.cpp \ + bls/bls_legacy.h \ consensus/amount.h \ consensus/merkle.cpp \ consensus/merkle.h \ @@ -1098,12 +1096,12 @@ bitcoin_bin_ldadd = \ $(LIBBITCOIN_ZMQ) \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBDASHBLS) \ + $(BLS_LIBS) \ $(LIBLEVELDB) \ $(LIBMEMENV) \ $(LIBSECP256K1) -bitcoin_bin_ldadd += $(BACKTRACE_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) $(GMP_LIBS) +bitcoin_bin_ldadd += $(BACKTRACE_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) dashd_SOURCES = $(bitcoin_daemon_sources) init/bitcoind.cpp dashd_CPPFLAGS = $(bitcoin_bin_cppflags) @@ -1133,7 +1131,7 @@ dash_cli_LDADD = \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_UTIL) \ $(LIBBITCOIN_CRYPTO) -dash_cli_LDADD += $(BACKTRACE_LIBS) $(EVENT_LIBS) $(GMP_LIBS) +dash_cli_LDADD += $(BACKTRACE_LIBS) $(EVENT_LIBS) # # dash-tx binary # @@ -1152,10 +1150,10 @@ dash_tx_LDADD = \ $(LIBBITCOIN_UTIL) \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBDASHBLS) \ + $(BLS_LIBS) \ $(LIBSECP256K1) -dash_tx_LDADD += $(BACKTRACE_LIBS) $(GMP_LIBS) +dash_tx_LDADD += $(BACKTRACE_LIBS) # # dash-wallet binary # @@ -1172,13 +1170,12 @@ dash_wallet_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBDASHBLS) \ + $(BLS_LIBS) \ $(LIBSECP256K1) \ $(BACKTRACE_LIBS) \ $(BOOST_LIBS) \ $(BDB_LIBS) \ - $(SQLITE_LIBS) \ - $(GMP_LIBS) + $(SQLITE_LIBS) if TARGET_WINDOWS dash_wallet_SOURCES += dash-wallet-res.rc @@ -1223,8 +1220,8 @@ if BUILD_BITCOIN_KERNEL_LIB lib_LTLIBRARIES += $(LIBBITCOINKERNEL) libdashkernel_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) $(PTHREAD_FLAGS) -libdashkernel_la_LIBADD = $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) $(LIBSECP256K1) $(LIBDASHBLS) $(GMP_LIBS) -libdashkernel_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL -isystem$(srcdir)/dashbls/include -isystem$(srcdir)/dashbls/depends/relic/include -isystem$(srcdir)/dashbls/depends/minialloc/include -isystem$(srcdir)/immer $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) +libdashkernel_la_LIBADD = $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) $(LIBSECP256K1) $(BLS_LIBS) +libdashkernel_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL $(MIMALLOC_CPPFLAGS) -isystem$(srcdir)/immer $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) # libdashkernel requires default symbol visibility, explicitly specify that # here so that things still work even when user configures with @@ -1255,6 +1252,7 @@ libdashkernel_la_SOURCES = \ bech32.cpp \ blockfilter.cpp \ bls/bls.cpp \ + bls/bls_legacy.cpp \ bls/bls_worker.cpp \ chain.cpp \ chainlock/chainlock.cpp \ @@ -1408,9 +1406,9 @@ include_HEADERS = script/bitcoinconsensus.h libdashconsensus_la_SOURCES = support/cleanse.cpp $(crypto_libbitcoin_crypto_base_la_SOURCES) $(crypto_libbitcoin_crypto_sph_la_SOURCES) $(libbitcoin_consensus_a_SOURCES) libdashconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) -libdashconsensus_la_LIBADD = $(LIBDASHBLS) $(LIBSECP256K1) $(GMP_LIBS) +libdashconsensus_la_LIBADD = $(BLS_LIBS) $(LIBSECP256K1) libdashconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL -DDISABLE_OPTIMIZED_SHA256 -libdashconsensus_la_CPPFLAGS += -isystem$(srcdir)/dashbls/include -isystem$(srcdir)/dashbls/depends/relic/include -isystem$(srcdir)/dashbls/depends/minialloc/include +libdashconsensus_la_CPPFLAGS += $(MIMALLOC_CPPFLAGS) libdashconsensus_la_CPPFLAGS += -isystem$(srcdir)/immer libdashconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) @@ -1443,15 +1441,14 @@ CLEANFILES += util/*.gcda util/*.gcno CLEANFILES += wallet/*.gcda wallet/*.gcno CLEANFILES += wallet/test/*.gcda wallet/test/*.gcno CLEANFILES += zmq/*.gcda zmq/*.gcno +CLEANFILES += mimalloc/src/*.gcda mimalloc/src/*.gcno mimalloc/src/prim/*.gcda mimalloc/src/prim/*.gcno CLEANFILES += obj/build.h IMMER_DIST = immer/immer -LIBDASHBLS_DIST = dashbls EXTRA_DIST = \ $(CTAES_DIST) \ - $(IMMER_DIST) \ - $(LIBDASHBLS_DIST) + $(IMMER_DIST) config/bitcoin-config.h: config/stamp-h1 @$(MAKE) -C $(top_builddir) $(subdir)/$(@) @@ -1462,7 +1459,6 @@ $(top_srcdir)/$(subdir)/config/bitcoin-config.h.in: $(am__configure_deps) clean-local: - -$(MAKE) -C dashbls clean -$(MAKE) -C secp256k1 clean -rm -f leveldb/*/*.gcda leveldb/*/*.gcno leveldb/helpers/memenv/*.gcda leveldb/helpers/memenv/*.gcno -rm -f config.h @@ -1539,6 +1535,7 @@ include Makefile.minisketch.include include Makefile.crc32c.include include Makefile.leveldb.include +include Makefile.mimalloc.include include Makefile.test_util.include include Makefile.test_fuzz.include diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index ff20b71822bc..138444b4bcd0 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -74,7 +74,7 @@ bench_bench_dash_LDADD = \ $(LIBBITCOIN_UTIL) \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBDASHBLS) \ + $(BLS_LIBS) \ $(LIBLEVELDB) \ $(LIBMEMENV) \ $(LIBSECP256K1) \ @@ -83,7 +83,6 @@ bench_bench_dash_LDADD = \ $(EVENT_LIBS) \ $(MINIUPNPC_LIBS) \ $(NATPMP_LIBS) \ - $(GMP_LIBS) \ $(BACKTRACE_LIBS) if ENABLE_ZMQ diff --git a/src/Makefile.mimalloc.include b/src/Makefile.mimalloc.include new file mode 100644 index 000000000000..6e455dc529f4 --- /dev/null +++ b/src/Makefile.mimalloc.include @@ -0,0 +1,53 @@ +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +LIBMIMALLOC_INT = mimalloc/libmimalloc-secure.la + +noinst_LTLIBRARIES += $(LIBMIMALLOC_INT) + +# What the users of bls/ link, dependents first: mimalloc -> blst (from depends) +BLS_LIBS = $(LIBMIMALLOC_INT) $(BLST_LIBS) + +# Flags for consumers of the library (bls/bls.cpp) +MIMALLOC_CPPFLAGS = -isystem$(srcdir)/mimalloc/include + +# Flags used only when building the library itself: secure mode (guard pages, +# encrypted free lists, zeroing on free) for the BLS secret keys it holds. +MIMALLOC_CPPFLAGS_INT = +MIMALLOC_CPPFLAGS_INT += -I$(srcdir)/mimalloc/include +MIMALLOC_CPPFLAGS_INT += -I$(srcdir)/mimalloc/src +MIMALLOC_CPPFLAGS_INT += -DMI_SECURE=4 +MIMALLOC_CPPFLAGS_INT += -DNDEBUG + +MIMALLOC_H = \ + mimalloc/include/mimalloc-new-delete.h \ + mimalloc/include/mimalloc-override.h \ + mimalloc/include/mimalloc-stats.h \ + mimalloc/include/mimalloc.h \ + mimalloc/src/bitmap.h + +mimalloc_libmimalloc_secure_la_SOURCES = \ + $(MIMALLOC_H) \ + mimalloc/src/alloc-aligned.c \ + mimalloc/src/alloc-posix.c \ + mimalloc/src/alloc.c \ + mimalloc/src/arena-meta.c \ + mimalloc/src/arena.c \ + mimalloc/src/bitmap.c \ + mimalloc/src/heap.c \ + mimalloc/src/init.c \ + mimalloc/src/libc.c \ + mimalloc/src/options.c \ + mimalloc/src/os.c \ + mimalloc/src/page-map.c \ + mimalloc/src/page.c \ + mimalloc/src/random.c \ + mimalloc/src/stats.c \ + mimalloc/src/prim/prim.c + +mimalloc_libmimalloc_secure_la_CPPFLAGS = $(AM_CPPFLAGS) $(MIMALLOC_CPPFLAGS_INT) +# Specify -static in both CFLAGS and LDFLAGS so libtool will only build a +# static version of this library (same as crc32c and leveldb). +mimalloc_libmimalloc_secure_la_CFLAGS = $(AM_CFLAGS) $(PIE_FLAGS) -static +mimalloc_libmimalloc_secure_la_LDFLAGS = $(AM_LDFLAGS) -static diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 56ddd8a12156..e907e8ba629e 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -473,9 +473,9 @@ endif if ENABLE_ZMQ bitcoin_qt_ldadd += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif -bitcoin_qt_ldadd += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBDASHBLS) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \ +bitcoin_qt_ldadd += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(BLS_LIBS) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \ $(BACKTRACE_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(LIBSECP256K1) \ - $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) + $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) bitcoin_qt_ldflags = $(LDFLAGS_WRAP_EXCEPTIONS) $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) bitcoin_qt_libtoolflags = $(AM_LIBTOOLFLAGS) --tag CXX diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include index 00401c6340d7..fea4cdd08208 100644 --- a/src/Makefile.qttest.include +++ b/src/Makefile.qttest.include @@ -67,10 +67,10 @@ endif if ENABLE_ZMQ qt_test_test_dash_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif -qt_test_test_dash_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBDASHBLS) $(LIBUNIVALUE) $(LIBLEVELDB) \ +qt_test_test_dash_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(BLS_LIBS) $(LIBUNIVALUE) $(LIBLEVELDB) \ $(LIBMEMENV) $(BACKTRACE_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) \ $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(LIBSECP256K1) \ - $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) + $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) qt_test_test_dash_qt_LDFLAGS = $(LDFLAGS_WRAP_EXCEPTIONS) $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) qt_test_test_dash_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 63635c7daa66..96fb2cbb38d9 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -17,6 +17,7 @@ FUZZ_BINARY=test/fuzz/fuzz$(EXEEXT) JSON_TEST_FILES = \ test/data/blockfilters.json \ + test/data/bls_reference_vectors.json \ test/data/base58_encode_decode.json \ test/data/bip39_vectors.json \ test/data/key_io_valid.json \ @@ -49,7 +50,7 @@ FUZZ_SUITE_LD_COMMON = \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ $(LIBBITCOIN_CLI) \ - $(LIBDASHBLS) \ + $(BLS_LIBS) \ $(BDB_LIBS) \ $(SQLITE_LIBS) \ $(LIBUNIVALUE) \ @@ -59,7 +60,6 @@ FUZZ_SUITE_LD_COMMON = \ $(MINISKETCH_LIBS) \ $(EVENT_LIBS) \ $(EVENT_PTHREADS_LIBS) \ - $(GMP_LIBS) \ $(BACKTRACE_LIBS) if USE_UPNP @@ -93,6 +93,7 @@ BITCOIN_TESTS =\ test/blockmanager_tests.cpp \ test/bloom_tests.cpp \ test/bls_tests.cpp \ + test/bls_reference_vectors_tests.cpp \ test/bswap_tests.cpp \ test/checkdatasig_tests.cpp \ test/checkqueue_tests.cpp \ @@ -273,10 +274,10 @@ test_test_dash_LDADD += $(LIBBITCOIN_WALLET) test_test_dash_CPPFLAGS += $(BDB_CPPFLAGS) endif test_test_dash_LDADD += $(LIBBITCOIN_NODE) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) \ - $(LIBDASHBLS) $(LIBLEVELDB) $(LIBMEMENV) $(BACKTRACE_LIBS) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) $(MINISKETCH_LIBS) + $(BLS_LIBS) $(LIBLEVELDB) $(LIBMEMENV) $(BACKTRACE_LIBS) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) $(MINISKETCH_LIBS) test_test_dash_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -test_test_dash_LDADD += $(BDB_LIBS) $(MINIUPNPC_LIBS) $(SQLITE_LIBS) $(NATPMP_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) +test_test_dash_LDADD += $(BDB_LIBS) $(MINIUPNPC_LIBS) $(SQLITE_LIBS) $(NATPMP_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) test_test_dash_LDFLAGS = $(LDFLAGS_WRAP_EXCEPTIONS) $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) -static if ENABLE_ZMQ diff --git a/src/bls/bls.cpp b/src/bls/bls.cpp index 8d5b1b83703c..2ce87eef5911 100644 --- a/src/bls/bls.cpp +++ b/src/bls/bls.cpp @@ -1,42 +1,438 @@ -// Copyright (c) 2018-2025 The Dash Core developers +// Copyright (c) 2018-2026 The Dash Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#include +#include #include +#include #ifndef BUILD_BITCOIN_INTERNAL #include -#include #endif +#include + +#include #include #include +#include +#include +#include namespace bls { std::atomic bls_legacy_scheme = std::atomic(true); } -static const std::unique_ptr pSchemeLegacy{std::make_unique()}; -static const std::unique_ptr pScheme(std::make_unique()); +namespace { + +// --- secure memory for secret scalars --------------------------------------- +// +// Secret scalars live in memory that is wiped when released. Until BLSInit() +// runs, and always in the consensus and kernel libraries, that memory comes +// from mimalloc in secure mode; BLSInit() switches to the locked pool shared +// with the rest of the node. The choice is latched at the first allocation +// so that no block is ever released through the wrong allocator. + +enum class SecureBackend : uint8_t { UNSET, MIMALLOC, LOCKED_POOL }; +std::atomic g_secureBackend{SecureBackend::UNSET}; + +#ifndef BUILD_BITCOIN_INTERNAL +std::once_flag g_poolInitFlag; +mt_pooled_secure_allocator* g_poolInstance{nullptr}; + +void CreateLockedPool() +{ + // make sure LockedPoolManager is initialized first (ensures destruction order) + LockedPoolManager::Instance(); + + // static variable in function scope ensures it's initialized when first accessed + // and destroyed before LockedPoolManager + static mt_pooled_secure_allocator pool(sizeof(blst_scalar)); + g_poolInstance = &pool; +} + +mt_pooled_secure_allocator& LockedPool() +{ + std::call_once(g_poolInitFlag, CreateLockedPool); + return *g_poolInstance; +} +#endif + +SecureBackend ActiveSecureBackend() +{ + SecureBackend backend = g_secureBackend.load(); + if (backend == SecureBackend::UNSET) { + g_secureBackend.compare_exchange_strong(backend, SecureBackend::MIMALLOC); + backend = g_secureBackend.load(); + } + return backend; +} + +void* SecureAlloc(size_t n) +{ +#ifndef BUILD_BITCOIN_INTERNAL + if (ActiveSecureBackend() == SecureBackend::LOCKED_POOL) { + return LockedPool().allocate(n); + } +#endif + ActiveSecureBackend(); + return mi_malloc(n); +} + +void SecureFree(void* p, size_t n) +{ + memory_cleanse(p, n); +#ifndef BUILD_BITCOIN_INTERNAL + if (ActiveSecureBackend() == SecureBackend::LOCKED_POOL) { + LockedPool().deallocate(static_cast(p), n); + return; + } +#endif + mi_free(p); +} + +// --- constants --------------------------------------------------------------- + +// BLS12-381 group order r, big-endian +const uint8_t ORDER_BE[32] = { + 0x73, 0xed, 0xa7, 0x53, 0x29, 0x9d, 0x7d, 0x48, 0x33, 0x39, 0xd8, 0x08, + 0x09, 0xa1, 0xd8, 0x05, 0x53, 0xbd, 0xa4, 0x02, 0xff, 0xfe, 0x5b, 0xfe, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01}; + +// Ciphersuite of the basic scheme +const char BASIC_SCHEME_DST[] = "BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_"; + +// --- scalars ----------------------------------------------------------------- + +//! Stack storage that is wiped on scope exit +template +struct Wiped { + T v{}; + ~Wiped() { memory_cleanse(&v, sizeof(v)); } +}; + +bool ScalarIsZero(const blst_scalar& s) +{ + static const blst_scalar zero{}; + return memcmp(&s, &zero, sizeof(s)) == 0; +} + +//! A threshold id as a scalar, reduced modulo the group order +void ScalarFromId(blst_scalar& out, const uint256& id) +{ + blst_scalar_from_be_bytes(&out, id.begin(), id.size()); +} + +void P1Mult(blst_p1& out, const blst_p1& p, const blst_scalar& k) +{ + Wiped> le; + blst_lendian_from_scalar(le.v.data(), &k); + blst_p1_mult(&out, &p, le.v.data(), 256); +} + +void P2Mult(blst_p2& out, const blst_p2& p, const blst_scalar& k) +{ + Wiped> le; + blst_lendian_from_scalar(le.v.data(), &k); + blst_p2_mult(&out, &p, le.v.data(), 256); +} + +// --- points ------------------------------------------------------------------ + +//! Validity in the basic scheme: a subgroup element or the point at infinity +bool InG1OrInf(const blst_p1& p) { return blst_p1_is_inf(&p) || blst_p1_in_g1(&p); } +bool InG2OrInf(const blst_p2& p) { return blst_p2_is_inf(&p) || blst_p2_in_g2(&p); } + +void HashToG2(blst_p2& out, const uint256& hash, bool legacy) +{ + if (legacy) { + bls_legacy::HashToG2(out, hash); + } else { + blst_hash_to_g2(&out, hash.begin(), hash.size(), + reinterpret_cast(BASIC_SCHEME_DST), sizeof(BASIC_SCHEME_DST) - 1, + nullptr, 0); + } +} + +// Decoding of the basic (IETF) compressed encodings. Only the canonical +// infinity encoding is accepted; a non-infinity encoding must have the +// compression bit set, may not encode a zero x coordinate, and must decode +// to a subgroup element. +bool DecodeBasicG1(blst_p1& out, Span in) +{ + const bool tailZero = std::all_of(in.begin() + 1, in.end(), [](uint8_t c) { return c == 0; }); + if ((in[0] & 0xc0) == 0xc0) { + if (in[0] != 0xc0 || !tailZero) return false; + memset(&out, 0, sizeof(out)); + return true; + } + if ((in[0] & 0xc0) != 0x80 || tailZero) return false; + blst_p1_affine a; + if (blst_p1_uncompress(&a, in.data()) != BLST_SUCCESS) return false; + blst_p1_from_affine(&out, &a); + return InG1OrInf(out); +} + +bool DecodeBasicG2(blst_p2& out, Span in) +{ + if ((in[48] & 0xe0) != 0) return false; + const bool zerosOnly = (in[0] & 0x1f) == 0 && std::all_of(in.begin() + 1, in.end(), [](uint8_t c) { return c == 0; }); + if ((in[0] & 0xc0) == 0xc0) { + if (in[0] != 0xc0 || !zerosOnly) return false; + memset(&out, 0, sizeof(out)); + return true; + } + if ((in[0] & 0xc0) != 0x80 || zerosOnly) return false; + blst_p2_affine a; + if (blst_p2_uncompress(&a, in.data()) != BLST_SUCCESS) return false; + blst_p2_from_affine(&out, &a); + return InG2OrInf(out); +} + +// --- pairing product --------------------------------------------------------- + +// Checks e(-G, sig) * prod e(pk_i, h_i) == 1. A pair with the point at +// infinity on either side contributes the identity (relic's semantics, which +// is why blst_core_verify is not used). +bool VerifyPairing(const blst_p2& sig, const std::vector& pks, const std::vector& hashes) +{ + assert(pks.size() == hashes.size()); + std::vector g1(pks.size() + 1); + std::vector g2(pks.size() + 1); + + blst_p1 negGenerator = *blst_p1_generator(); + blst_p1_cneg(&negGenerator, true); + blst_p1_to_affine(&g1[0], &negGenerator); + blst_p2_to_affine(&g2[0], &sig); + for (size_t i = 0; i < pks.size(); i++) { + blst_p1_to_affine(&g1[i + 1], pks[i]); + blst_p2_to_affine(&g2[i + 1], &hashes[i]); + } + + blst_fp12 acc = *blst_fp12_one(); + for (size_t i = 0; i < g1.size(); i++) { + if (blst_p1_affine_is_inf(&g1[i]) || blst_p2_affine_is_inf(&g2[i])) { + continue; + } + blst_fp12 term; + blst_miller_loop(&term, &g2[i], &g1[i]); + blst_fp12_mul(&acc, &acc, &term); + } + blst_final_exp(&acc, &acc); + return blst_fp12_is_one(&acc); +} + +// --- secure aggregation ------------------------------------------------------ + +// Coefficients of the secure aggregation: the public keys are ordered by +// their encoding under the given scheme, and coefficient i is +// SHA256(i || SHA256(encodings)) reduced modulo the group order. +struct SecureAggregationOrder { + std::vector index; // input index of each sorted position + std::vector coeffs; // coefficient of each sorted position +}; + +SecureAggregationOrder SecureAggregationCoefficients(const std::vector>& encodings) +{ + const size_t n = encodings.size(); + SecureAggregationOrder ret; + ret.index.resize(n); + for (size_t i = 0; i < n; i++) ret.index[i] = i; + std::sort(ret.index.begin(), ret.index.end(), [&](size_t a, size_t b) { + return memcmp(encodings[a].data(), encodings[b].data(), BLS_CURVE_PUBKEY_SIZE) < 0; + }); + + CSHA256 all; + for (size_t i : ret.index) { + all.Write(encodings[i].data(), BLS_CURVE_PUBKEY_SIZE); + } + uint8_t pkHash[CSHA256::OUTPUT_SIZE]; + all.Finalize(pkHash); + + ret.coeffs.resize(n); + for (uint32_t i = 0; i < n; i++) { + const uint8_t prefix[4] = {uint8_t(i >> 24), uint8_t(i >> 16), uint8_t(i >> 8), uint8_t(i)}; + uint8_t digest[CSHA256::OUTPUT_SIZE]; + CSHA256().Write(prefix, sizeof(prefix)).Write(pkHash, sizeof(pkHash)).Finalize(digest); + blst_scalar_from_be_bytes(&ret.coeffs[i], digest, sizeof(digest)); + } + return ret; +} + +// --- polynomials over the scalar field --------------------------------------- + +template +struct PolyOps; + +template <> +struct PolyOps { + static void Mul(blst_scalar& out, const blst_scalar& a, const blst_scalar& x) { blst_sk_mul_n_check(&out, &a, &x); } + static void Add(blst_scalar& out, const blst_scalar& a, const blst_scalar& b) { blst_sk_add_n_check(&out, &a, &b); } +}; + +template <> +struct PolyOps { + static void Mul(blst_p1& out, const blst_p1& a, const blst_scalar& x) { P1Mult(out, a, x); } + static void Add(blst_p1& out, const blst_p1& a, const blst_p1& b) { blst_p1_add_or_double(&out, &a, &b); } +}; + +template <> +struct PolyOps { + static void Mul(blst_p2& out, const blst_p2& a, const blst_scalar& x) { P2Mult(out, a, x); } + static void Add(blst_p2& out, const blst_p2& a, const blst_p2& b) { blst_p2_add_or_double(&out, &a, &b); } +}; + +//! Horner evaluation of the polynomial with the given coefficients at the +//! point id. Requires at least two coefficients. +template +bool PolyEvaluate(T& out, size_t n, GetCoefficient coefficient, const uint256& id) +{ + if (n < 2) return false; + Wiped x; + ScalarFromId(x.v, id); + Wiped y, term; + y.v = coefficient(n - 1); + for (size_t i = n - 1; i-- > 0;) { + PolyOps::Mul(term.v, y.v, x.v); + PolyOps::Add(y.v, term.v, coefficient(i)); + } + out = y.v; + return true; +} + +//! Lagrange interpolation at zero of the polynomial through the given shares. +//! Fails for fewer than two shares, a zero id or duplicate ids. +template +bool LagrangeInterpolate(T& out, size_t k, GetShare share, const std::vector& ids) +{ + if (k < 2 || ids.size() != k) return false; + std::vector x(k); + for (size_t i = 0; i < k; i++) { + ScalarFromId(x[i], ids[i]); + } + + // delta_i = prod_j x_j / (x_i * prod_{j != i} (x_j - x_i)) + blst_scalar numerator = x[0]; + for (size_t i = 1; i < k; i++) { + blst_sk_mul_n_check(&numerator, &numerator, &x[i]); + } + if (ScalarIsZero(numerator)) return false; + + T acc{}; + for (size_t i = 0; i < k; i++) { + blst_scalar denominator = x[i]; + for (size_t j = 0; j < k; j++) { + if (j == i) continue; + blst_scalar diff; + blst_sk_sub_n_check(&diff, &x[j], &x[i]); + if (ScalarIsZero(diff)) return false; + blst_sk_mul_n_check(&denominator, &denominator, &diff); + } + blst_scalar delta; + blst_sk_inverse(&delta, &denominator); + blst_sk_mul_n_check(&delta, &numerator, &delta); + T term; + PolyOps::Mul(term, share(i), delta); + PolyOps::Add(acc, acc, term); + } + out = acc; + return true; +} + +} // namespace + +// --- CBLSSecretScalar -------------------------------------------------------- + +CBLSSecretScalar::CBLSSecretScalar(const CBLSSecretScalar& o) +{ + if (o.m_data != nullptr) { + Mutable() = *o.m_data; + } +} + +CBLSSecretScalar& CBLSSecretScalar::operator=(const CBLSSecretScalar& o) +{ + if (this != &o) { + if (o.m_data != nullptr) { + Mutable() = *o.m_data; + } else if (m_data != nullptr) { + SecureFree(m_data, sizeof(blst_scalar)); + m_data = nullptr; + } + } + return *this; +} + +CBLSSecretScalar::~CBLSSecretScalar() +{ + if (m_data != nullptr) { + SecureFree(m_data, sizeof(blst_scalar)); + } +} + +const blst_scalar& CBLSSecretScalar::Get() const +{ + static const blst_scalar zero{}; + return m_data != nullptr ? *m_data : zero; +} + +blst_scalar& CBLSSecretScalar::Mutable() +{ + if (m_data == nullptr) { + m_data = static_cast(SecureAlloc(sizeof(blst_scalar))); + if (m_data == nullptr) throw std::bad_alloc(); + memset(m_data, 0, sizeof(blst_scalar)); + } + return *m_data; +} + +bool CBLSSecretScalar::IsZero() const +{ + return m_data == nullptr || ScalarIsZero(*m_data); +} -static const std::unique_ptr& Scheme(const bool fLegacy) +bool CBLSSecretScalar::operator==(const CBLSSecretScalar& o) const { - return fLegacy ? pSchemeLegacy : pScheme; + return memcmp(&Get(), &o.Get(), sizeof(blst_scalar)) == 0; } -CBLSId::CBLSId(const uint256& nHash) : CBLSWrapper() +// --- CBLSId ------------------------------------------------------------------ + +CBLSId::CBLSId(const uint256& nHash) : CBLSWrapper() { impl = nHash; fValid = true; cachedHash.SetNull(); } +// --- CBLSSecretKey ----------------------------------------------------------- + +bool CBLSSecretKey::DecodeImpl(Span in, bool modOrder, CBLSSecretScalar& out) +{ + if (modOrder) { + blst_scalar_from_be_bytes(&out.Mutable(), in.data(), in.size()); + return true; + } + // values above the group order are rejected, the order itself is not + if (memcmp(in.data(), ORDER_BE, sizeof(ORDER_BE)) > 0) { + return false; + } + blst_scalar_from_bendian(&out.Mutable(), in.data()); + return true; +} + +void CBLSSecretKey::EncodeImpl(const CBLSSecretScalar& in, bool /*specificLegacyScheme*/, uint8_t* out) +{ + blst_bendian_from_scalar(out, &in.Get()); +} + void CBLSSecretKey::AggregateInsecure(const CBLSSecretKey& o) { assert(IsValid() && o.IsValid()); - impl = bls::PrivateKey::Aggregate({impl, o.impl}); + blst_sk_add_n_check(&impl.Mutable(), &impl.Get(), &o.impl.Get()); cachedHash.SetNull(); } @@ -46,14 +442,11 @@ CBLSSecretKey CBLSSecretKey::AggregateInsecure(Span sks) return {}; } - std::vector v; - v.reserve(sks.size()); + CBLSSecretKey ret; + blst_scalar& sum = ret.impl.Mutable(); for (const auto& sk : sks) { - v.emplace_back(sk.impl); + blst_sk_add_n_check(&sum, &sum, &sk.impl.Get()); } - - CBLSSecretKey ret; - ret.impl = bls::PrivateKey::Aggregate(v); ret.fValid = true; ret.cachedHash.SetNull(); return ret; @@ -63,20 +456,11 @@ CBLSSecretKey CBLSSecretKey::AggregateInsecure(Span sks) void CBLSSecretKey::MakeNewKey() { unsigned char buf[SerSize]; - while (true) { + do { GetStrongRandBytes({buf, sizeof(buf)}); - try { - impl = bls::PrivateKey::FromBytes(bls::Bytes(reinterpret_cast(buf), SerSize)); - if (impl == bls::PrivateKey()) { - continue; - } - break; - } catch (...) { - } - } + SetBytes(buf, false); + } while (!IsValid()); memory_cleanse(buf, sizeof(buf)); - fValid = true; - cachedHash.SetNull(); } #endif @@ -88,22 +472,17 @@ bool CBLSSecretKey::SecretKeyShare(Span msk, const CBLSId& _id) if (!_id.IsValid()) { return false; } - - std::vector mskVec; - mskVec.reserve(msk.size()); for (const CBLSSecretKey& sk : msk) { if (!sk.IsValid()) { return false; } - mskVec.emplace_back(sk.impl); } - try { - impl = bls::Threshold::PrivateKeyShare(mskVec, bls::Bytes(_id.impl.begin(), _id.impl.size())); - } catch (...) { + Wiped share; + if (!PolyEvaluate(share.v, msk.size(), [&](size_t i) -> const blst_scalar& { return msk[i].impl.Get(); }, _id.impl)) { return false; } - + impl.Mutable() = share.v; fValid = true; cachedHash.SetNull(); return true; @@ -116,7 +495,7 @@ CBLSPublicKey CBLSSecretKey::GetPublicKey() const } CBLSPublicKey pubKey; - pubKey.impl = impl.GetG1Element(); + blst_sk_to_pk_in_g1(&pubKey.impl, &impl.Get()); pubKey.fValid = true; pubKey.cachedHash.SetNull(); return pubKey; @@ -129,26 +508,34 @@ CBLSSignature CBLSSecretKey::Sign(const uint256& hash, const bool specificLegacy } CBLSSignature sigRet; - try { - sigRet.impl = Scheme(specificLegacyScheme)->Sign(impl, bls::Bytes(hash.begin(), hash.size())); - sigRet.fValid = true; - } catch (...) { - sigRet.fValid = false; - } - + blst_p2 hashPoint; + HashToG2(hashPoint, hash, specificLegacyScheme); + blst_sign_pk_in_g1(&sigRet.impl, &hashPoint, &impl.Get()); + sigRet.fValid = true; sigRet.cachedHash.SetNull(); - return sigRet; } +// --- CBLSPublicKey ----------------------------------------------------------- + +bool CBLSPublicKey::DecodeImpl(Span in, bool specificLegacyScheme, blst_p1& out) +{ + return specificLegacyScheme ? bls_legacy::DecodeG1(out, in) : DecodeBasicG1(out, in); +} + +void CBLSPublicKey::EncodeImpl(const blst_p1& in, bool specificLegacyScheme, uint8_t* out) +{ + if (specificLegacyScheme) { + bls_legacy::EncodeG1({out, BLS_CURVE_PUBKEY_SIZE}, in); + } else { + blst_p1_compress(out, &in); + } +} + void CBLSPublicKey::AggregateInsecure(const CBLSPublicKey& o) { assert(IsValid() && o.IsValid()); - try { - impl = Scheme(bls::bls_legacy_scheme.load())->Aggregate({impl, o.impl}); - } catch (...) { - fValid = false; - } + blst_p1_add_or_double(&impl, &impl, &o.impl); cachedHash.SetNull(); } @@ -158,20 +545,11 @@ CBLSPublicKey CBLSPublicKey::AggregateInsecure(Span pks) return {}; } - std::vector vecPublicKeys; - vecPublicKeys.reserve(pks.size()); - for (const auto& pk : pks) { - vecPublicKeys.emplace_back(pk.impl); - } - CBLSPublicKey ret; - try { - ret.impl = Scheme(bls::bls_legacy_scheme.load())->Aggregate(vecPublicKeys); - ret.fValid = true; - } catch (...) { - ret.fValid = false; + for (const auto& pk : pks) { + blst_p1_add_or_double(&ret.impl, &ret.impl, &pk.impl); } - + ret.fValid = true; ret.cachedHash.SetNull(); return ret; } @@ -184,22 +562,15 @@ bool CBLSPublicKey::PublicKeyShare(Span mpk, const CBLSId& _id) if (!_id.IsValid()) { return false; } - - std::vector mpkVec; - mpkVec.reserve(mpk.size()); for (const CBLSPublicKey& pk : mpk) { if (!pk.IsValid()) { return false; } - mpkVec.emplace_back(pk.impl); } - try { - impl = bls::Threshold::PublicKeyShare(mpkVec, bls::Bytes(_id.impl.begin(), _id.impl.size())); - } catch (...) { + if (!PolyEvaluate(impl, mpk.size(), [&](size_t i) -> const blst_p1& { return mpk[i].impl; }, _id.impl)) { return false; } - fValid = true; cachedHash.SetNull(); return true; @@ -213,20 +584,32 @@ bool CBLSPublicKey::DHKeyExchange(const CBLSSecretKey& sk, const CBLSPublicKey& if (!sk.IsValid() || !pk.IsValid()) { return false; } - impl = sk.impl * pk.impl; + P1Mult(impl, pk.impl, sk.impl.Get()); fValid = true; cachedHash.SetNull(); return true; } +// --- CBLSSignature ----------------------------------------------------------- + +bool CBLSSignature::DecodeImpl(Span in, bool specificLegacyScheme, blst_p2& out) +{ + return specificLegacyScheme ? bls_legacy::DecodeG2(out, in) : DecodeBasicG2(out, in); +} + +void CBLSSignature::EncodeImpl(const blst_p2& in, bool specificLegacyScheme, uint8_t* out) +{ + if (specificLegacyScheme) { + bls_legacy::EncodeG2({out, BLS_CURVE_SIG_SIZE}, in); + } else { + blst_p2_compress(out, &in); + } +} + void CBLSSignature::AggregateInsecure(const CBLSSignature& o) { assert(IsValid() && o.IsValid()); - try { - impl = Scheme(bls::bls_legacy_scheme.load())->Aggregate({impl, o.impl}); - } catch (...) { - fValid = false; - } + blst_p2_add_or_double(&impl, &impl, &o.impl); cachedHash.SetNull(); } @@ -236,20 +619,11 @@ CBLSSignature CBLSSignature::AggregateInsecure(Span sigs) return {}; } - std::vector v; - v.reserve(sigs.size()); - for (const auto& pk : sigs) { - v.emplace_back(pk.impl); - } - CBLSSignature ret; - try { - ret.impl = Scheme(bls::bls_legacy_scheme.load())->Aggregate(v); - ret.fValid = true; - } catch (...) { - ret.fValid = false; + for (const auto& sig : sigs) { + blst_p2_add_or_double(&ret.impl, &ret.impl, &sig.impl); } - + ret.fValid = true; ret.cachedHash.SetNull(); return ret; } @@ -261,27 +635,21 @@ CBLSSignature CBLSSignature::AggregateSecure(Span sigs, if (sigs.size() != pks.size() || sigs.empty()) { return {}; } + const bool legacy = bls::bls_legacy_scheme.load(); - std::vector vecPublicKeys; - vecPublicKeys.reserve(pks.size()); - for (const auto& pk : pks) { - vecPublicKeys.push_back(pk.impl); - } - - std::vector vecSignatures; - vecSignatures.reserve(pks.size()); - for (const auto& sig : sigs) { - vecSignatures.push_back(sig.impl); + std::vector> encodings(pks.size()); + for (size_t i = 0; i < pks.size(); i++) { + CBLSPublicKey::EncodeImpl(pks[i].impl, legacy, encodings[i].data()); } + const SecureAggregationOrder order = SecureAggregationCoefficients(encodings); CBLSSignature ret; - try { - ret.impl = Scheme(bls::bls_legacy_scheme.load())->AggregateSecure(vecPublicKeys, vecSignatures, bls::Bytes(hash.begin(), hash.size())); - ret.fValid = true; - } catch (...) { - ret.fValid = false; + for (size_t i = 0; i < order.index.size(); i++) { + blst_p2 term; + P2Mult(term, sigs[order.index[i]].impl, order.coeffs[i]); + blst_p2_add_or_double(&ret.impl, &ret.impl, &term); } - + ret.fValid = true; ret.cachedHash.SetNull(); return ret; } @@ -289,7 +657,9 @@ CBLSSignature CBLSSignature::AggregateSecure(Span sigs, void CBLSSignature::SubInsecure(const CBLSSignature& o) { assert(IsValid() && o.IsValid()); - impl = impl + o.impl.Negate(); + blst_p2 neg = o.impl; + blst_p2_cneg(&neg, true); + blst_p2_add_or_double(&impl, &impl, &neg); cachedHash.SetNull(); } @@ -298,12 +668,14 @@ bool CBLSSignature::VerifyInsecure(const CBLSPublicKey& pubKey, const uint256& h if (!IsValid() || !pubKey.IsValid()) { return false; } - - try { - return Scheme(specificLegacyScheme)->Verify(pubKey.impl, bls::Bytes(hash.begin(), hash.size()), impl); - } catch (...) { + // The basic scheme requires subgroup elements; the legacy scheme verifies + // whatever was decoded. + if (!specificLegacyScheme && (!InG1OrInf(pubKey.impl) || !InG2OrInf(impl))) { return false; } + std::vector hashes(1); + HashToG2(hashes[0], hash, specificLegacyScheme); + return VerifyPairing(impl, {&pubKey.impl}, hashes); } bool CBLSSignature::VerifyInsecure(const CBLSPublicKey& pubKey, const uint256& hash) const @@ -317,25 +689,38 @@ bool CBLSSignature::VerifyInsecureAggregated(Span pubKeys, Span pubKeyVec; - std::vector hashes2; - hashes2.reserve(hashes.size()); - pubKeyVec.reserve(pubKeys.size()); - for (size_t i = 0; i < pubKeys.size(); i++) { - const auto& p = pubKeys[i]; - if (!p.IsValid()) { + std::vector pks; + pks.reserve(pubKeys.size()); + for (const auto& pk : pubKeys) { + if (!pk.IsValid()) { return false; } - pubKeyVec.push_back(p.impl); - hashes2.emplace_back(hashes[i].begin(), hashes[i].size()); + pks.push_back(&pk.impl); } - try { - return Scheme(bls::bls_legacy_scheme.load())->AggregateVerify(pubKeyVec, hashes2, impl); - } catch (...) { - return false; + if (!legacy) { + // the basic scheme needs distinct messages and subgroup elements + const std::set distinct(hashes.begin(), hashes.end()); + if (distinct.size() != hashes.size()) { + return false; + } + if (!InG2OrInf(impl)) { + return false; + } + for (const blst_p1* pk : pks) { + if (!InG1OrInf(*pk)) { + return false; + } + } + } + + std::vector hashPoints(hashes.size()); + for (size_t i = 0; i < hashes.size(); i++) { + HashToG2(hashPoints[i], hashes[i], legacy); } + return VerifyPairing(impl, pks, hashPoints); } bool CBLSSignature::VerifySecureAggregated(Span pks, const uint256& hash) const @@ -343,18 +728,32 @@ bool CBLSSignature::VerifySecureAggregated(Span pks, const uint25 if (pks.empty()) { return false; } + const bool legacy = bls::bls_legacy_scheme.load(); - std::vector vecPublicKeys; - vecPublicKeys.reserve(pks.size()); - for (const auto& pk : pks) { - vecPublicKeys.push_back(pk.impl); + std::vector> encodings(pks.size()); + for (size_t i = 0; i < pks.size(); i++) { + CBLSPublicKey::EncodeImpl(pks[i].impl, legacy, encodings[i].data()); } + const SecureAggregationOrder order = SecureAggregationCoefficients(encodings); - try { - return Scheme(bls::bls_legacy_scheme.load())->VerifySecure(vecPublicKeys, impl, bls::Bytes(hash.begin(), hash.size())); - } catch (...) { + blst_p1 aggregate{}; + for (size_t i = 0; i < order.index.size(); i++) { + const blst_p1& pk = pks[order.index[i]].impl; + // the basic scheme only accepts subgroup elements + if (!legacy && !InG1OrInf(pk)) { + return false; + } + blst_p1 term; + P1Mult(term, pk, order.coeffs[i]); + blst_p1_add_or_double(&aggregate, &aggregate, &term); + } + if (!legacy && !InG2OrInf(impl)) { return false; } + + std::vector hashes(1); + HashToG2(hashes[0], hash, legacy); + return VerifyPairing(impl, {&aggregate}, hashes); } bool CBLSSignature::Recover(Span sigs, Span ids) @@ -366,74 +765,30 @@ bool CBLSSignature::Recover(Span sigs, Span ids) return false; } - std::vector sigsVec; - std::vector idsVec; - sigsVec.reserve(sigs.size()); - idsVec.reserve(sigs.size()); - + std::vector idValues; + idValues.reserve(ids.size()); for (size_t i = 0; i < sigs.size(); i++) { if (!sigs[i].IsValid() || !ids[i].IsValid()) { return false; } - sigsVec.emplace_back(sigs[i].impl); - idsVec.emplace_back(ids[i].impl.begin(), ids[i].impl.size()); + idValues.push_back(ids[i].impl); } - try { - impl = bls::Threshold::SignatureRecover(sigsVec, idsVec); - } catch (...) { + if (!LagrangeInterpolate(impl, sigs.size(), [&](size_t i) -> const blst_p2& { return sigs[i].impl; }, idValues)) { return false; } - fValid = true; cachedHash.SetNull(); return true; } -#ifndef BUILD_BITCOIN_INTERNAL - -static std::once_flag init_flag; -static mt_pooled_secure_allocator* secure_allocator_instance; -static void create_secure_allocator() -{ - // make sure LockedPoolManager is initialized first (ensures destruction order) - LockedPoolManager::Instance(); - - // static variable in function scope ensures it's initialized when first accessed - // and destroyed before LockedPoolManager - static mt_pooled_secure_allocator a(sizeof(bn_t) + sizeof(size_t)); - secure_allocator_instance = &a; -} - -static mt_pooled_secure_allocator& get_secure_allocator() -{ - std::call_once(init_flag, create_secure_allocator); - return *secure_allocator_instance; -} - -static void* secure_allocate(size_t n) -{ - uint8_t* ptr = get_secure_allocator().allocate(n + sizeof(size_t)); - *reinterpret_cast(ptr) = n; - return ptr + sizeof(size_t); -} - -static void secure_free(void* p) -{ - if (p == nullptr) { - return; - } - - uint8_t* ptr = reinterpret_cast(p) - sizeof(size_t); - size_t n = *reinterpret_cast(ptr); - return get_secure_allocator().deallocate(ptr, n); -} -#endif +// --- initialization ---------------------------------------------------------- bool BLSInit() { #ifndef BUILD_BITCOIN_INTERNAL - bls::BLS::SetSecureAllocator(secure_allocate, secure_free); + SecureBackend expected = SecureBackend::UNSET; + g_secureBackend.compare_exchange_strong(expected, SecureBackend::LOCKED_POOL); #endif return true; } diff --git a/src/bls/bls.h b/src/bls/bls.h index ae2124cd38e1..3ba73c212c5b 100644 --- a/src/bls/bls.h +++ b/src/bls/bls.h @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2025 The Dash Core developers +// Copyright (c) 2018-2026 The Dash Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -7,26 +7,25 @@ #include #include +#include #include #include -// bls-dash uses relic, which may define DEBUG and ERROR, which leads to many warnings in some build setups -#undef ERROR -#undef DEBUG -#include -#include -#include -#include -#include -#undef DOUBLE -#undef SEED +#include #include #include +#include #include #include +#include +#include namespace bls { + //! Selects the scheme used wherever no explicit flag is given (the + //! flag-less Serialize/Unserialize/GetHash overloads, aggregation and + //! aggregated verification): the legacy scheme from before the v19 hard + //! fork, or the basic (IETF) scheme after it. extern std::atomic bls_legacy_scheme; } @@ -36,9 +35,47 @@ constexpr int BLS_CURVE_SECKEY_SIZE{32}; constexpr int BLS_CURVE_PUBKEY_SIZE{48}; constexpr int BLS_CURVE_SIG_SIZE{96}; +class CBLSSecretKey; class CBLSSignature; class CBLSPublicKey; +/** + * A secret scalar kept in secure memory (see BLSInit). A default constructed + * holder stands for the zero scalar and owns no memory. + */ +class CBLSSecretScalar +{ +private: + blst_scalar* m_data{nullptr}; + +public: + CBLSSecretScalar() = default; + CBLSSecretScalar(const CBLSSecretScalar& o); + CBLSSecretScalar& operator=(const CBLSSecretScalar& o); + CBLSSecretScalar(CBLSSecretScalar&& o) noexcept : m_data(std::exchange(o.m_data, nullptr)) {} + CBLSSecretScalar& operator=(CBLSSecretScalar&& o) noexcept + { + std::swap(m_data, o.m_data); + return *this; + } + ~CBLSSecretScalar(); + + //! The scalar, or zero when nothing has been stored + const blst_scalar& Get() const; + //! Writable storage, allocated on first use + blst_scalar& Mutable(); + bool IsZero() const; + bool operator==(const CBLSSecretScalar& o) const; +}; + +/** + * Common part of the BLS objects. The derived class C provides the codec + * through four static hooks: + * bool DecodeImpl(Span in, bool specificLegacyScheme, ImplType& out) + * void EncodeImpl(const ImplType& in, bool specificLegacyScheme, uint8_t* out) + * bool IsIdentity(const ImplType& v) + * bool EqualImpl(const ImplType& a, const ImplType& b) + */ template class CBLSWrapper { @@ -47,7 +84,7 @@ class CBLSWrapper friend class CBLSSignature; protected: - ImplType impl; + ImplType impl{}; bool fValid{false}; mutable uint256 cachedHash; @@ -72,11 +109,9 @@ class CBLSWrapper return *this; } - virtual ~CBLSWrapper() = default; - bool operator==(const C& r) const { - return fValid == r.fValid && impl == r.impl; + return fValid == r.fValid && C::EqualImpl(impl, r.impl); } bool operator!=(const C& r) const { @@ -106,36 +141,31 @@ class CBLSWrapper if (std::ranges::all_of(vecBytes, [](uint8_t c) { return c == 0; })) { Reset(); + } else if (!C::DecodeImpl(vecBytes, specificLegacyScheme, impl) || C::IsIdentity(impl)) { + // neither undecodable input nor the identity element make a valid object + Reset(); } else { - try { - impl = ImplType::FromBytes(bls::Bytes(vecBytes.data(), vecBytes.size()), specificLegacyScheme); - if (impl == ImplType()) { - Reset(); - cachedHash.SetNull(); - return; - } - fValid = true; - } catch (...) { - Reset(); - } + fValid = true; } cachedHash.SetNull(); } std::vector ToByteVector(const bool specificLegacyScheme) const { - if (!fValid) { - return std::vector(SerSize, 0); + std::vector ret(SerSize, 0); + if (fValid) { + C::EncodeImpl(impl, specificLegacyScheme, ret.data()); } - return impl.Serialize(specificLegacyScheme); + return ret; } std::array ToBytes(const bool specificLegacyScheme) const { - if (!fValid) { - return std::array{}; + std::array ret{}; + if (fValid) { + C::EncodeImpl(impl, specificLegacyScheme, ret.data()); } - return impl.SerializeToArray(specificLegacyScheme); + return ret; } const uint256& GetHash() const @@ -232,29 +262,23 @@ class CBLSWrapper } }; -struct CBLSIdImplicit : public uint256 + +class CBLSId : public CBLSWrapper { - CBLSIdImplicit() = default; - // cppcheck-suppress noExplicitConstructor - CBLSIdImplicit(const uint256& id) - { - memcpy(begin(), id.begin(), sizeof(uint256)); - } - static CBLSIdImplicit FromBytes(const uint8_t* buffer, const bool fLegacy) + friend class CBLSWrapper; + + static bool DecodeImpl(Span in, bool /*specificLegacyScheme*/, uint256& out) { - CBLSIdImplicit instance; - memcpy(instance.begin(), buffer, sizeof(CBLSIdImplicit)); - return instance; + memcpy(out.begin(), in.data(), BLS_CURVE_ID_SIZE); + return true; } - [[nodiscard]] std::vector Serialize(const bool fLegacy) const + static void EncodeImpl(const uint256& in, bool /*specificLegacyScheme*/, uint8_t* out) { - return {begin(), end()}; + memcpy(out, in.begin(), BLS_CURVE_ID_SIZE); } - [[nodiscard]] std::array SerializeToArray(const bool fLegacy) const { return m_data; } -}; + static bool IsIdentity(const uint256& v) { return v.IsNull(); } + static bool EqualImpl(const uint256& a, const uint256& b) { return a == b; } -class CBLSId : public CBLSWrapper -{ public: using CBLSWrapper::operator=; using CBLSWrapper::operator==; @@ -266,8 +290,20 @@ class CBLSId : public CBLSWrapper }; //! CBLSSecretKey is invariant to BLS scheme for Creation / Serialization / Deserialization -class CBLSSecretKey : public CBLSWrapper +class CBLSSecretKey : public CBLSWrapper { + friend class CBLSWrapper; + friend class CBLSPublicKey; + friend class CBLSSignature; + + //! The flag does not select a scheme here: with it set the bytes are + //! reduced modulo the group order, without it values above the order + //! are rejected. + static bool DecodeImpl(Span in, bool modOrder, CBLSSecretScalar& out); + static void EncodeImpl(const CBLSSecretScalar& in, bool /*specificLegacyScheme*/, uint8_t* out); + static bool IsIdentity(const CBLSSecretScalar& s) { return s.IsZero(); } + static bool EqualImpl(const CBLSSecretScalar& a, const CBLSSecretScalar& b) { return a == b; } + public: using CBLSWrapper::operator=; using CBLSWrapper::operator==; @@ -298,11 +334,17 @@ class CBLSSecretKey : public CBLSWrapper +class CBLSPublicKey : public CBLSWrapper { + friend class CBLSWrapper; friend class CBLSSecretKey; friend class CBLSSignature; + static bool DecodeImpl(Span in, bool specificLegacyScheme, blst_p1& out); + static void EncodeImpl(const blst_p1& in, bool specificLegacyScheme, uint8_t* out); + static bool IsIdentity(const blst_p1& p) { return blst_p1_is_inf(&p); } + static bool EqualImpl(const blst_p1& a, const blst_p1& b) { return blst_p1_is_equal(&a, &b); } + public: using CBLSWrapper::operator=; using CBLSWrapper::operator==; @@ -338,10 +380,16 @@ class CBLSPublicKeyVersionWrapper { } }; -class CBLSSignature : public CBLSWrapper +class CBLSSignature : public CBLSWrapper { + friend class CBLSWrapper; friend class CBLSSecretKey; + static bool DecodeImpl(Span in, bool specificLegacyScheme, blst_p2& out); + static void EncodeImpl(const blst_p2& in, bool specificLegacyScheme, uint8_t* out); + static bool IsIdentity(const blst_p2& p) { return blst_p2_is_inf(&p); } + static bool EqualImpl(const blst_p2& a, const blst_p2& b) { return blst_p2_is_equal(&a, &b); } + public: using CBLSWrapper::operator==; using CBLSWrapper::operator!=; @@ -414,7 +462,6 @@ class CBLSLazyWrapper { *this = r; } - virtual ~CBLSLazyWrapper() = default; CBLSLazyWrapper& operator=(const CBLSLazyWrapper& r) { diff --git a/src/bls/bls_legacy.cpp b/src/bls/bls_legacy.cpp new file mode 100644 index 000000000000..4fb55e28ec29 --- /dev/null +++ b/src/bls/bls_legacy.cpp @@ -0,0 +1,416 @@ +// Copyright (c) 2021-2026 The Dash Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include + +#include +#include + +namespace bls_legacy { +namespace { + +// BLS12-381 base field prime p, big-endian. +const uint8_t P_BE[48] = { + 0x1a, 0x01, 0x11, 0xea, 0x39, 0x7f, 0xe6, 0x9a, 0x4b, 0x1b, 0xa7, 0xb6, + 0x43, 0x4b, 0xac, 0xd7, 0x64, 0x77, 0x4b, 0x84, 0xf3, 0x85, 0x12, 0xbf, + 0x67, 0x30, 0xd2, 0xa0, 0xf6, 0xb0, 0xf6, 0x24, 0x1e, 0xab, 0xff, 0xfe, + 0xb1, 0x53, 0xff, 0xff, 0xb9, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xaa, 0xab}; + +// (p - 1) / 2, big-endian. The legacy sign convention picks the "larger" +// root: a coordinate is flagged when it is greater than this value. +const uint8_t HALF_P_BE[48] = { + 0x0d, 0x00, 0x88, 0xf5, 0x1c, 0xbf, 0xf3, 0x4d, 0x25, 0x8d, 0xd3, 0xdb, + 0x21, 0xa5, 0xd6, 0x6b, 0xb2, 0x3b, 0xa5, 0xc2, 0x79, 0xc2, 0x89, 0x5f, + 0xb3, 0x98, 0x69, 0x50, 0x7b, 0x58, 0x7b, 0x12, 0x0f, 0x55, 0xff, 0xff, + 0x58, 0xa9, 0xff, 0xff, 0xdc, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xd5, 0x55}; + +// (2^384)^-1 mod p, big-endian. When relic failed to find a square root +// while decompressing a point whose sign bit was set, it left the raw limb +// value 1 in y, which reads back from Montgomery form as this number. +const uint8_t SQRT_FAILURE_MARKER_BE[48] = { + 0x14, 0xfe, 0xc7, 0x01, 0xe8, 0xfb, 0x0c, 0xe9, 0xed, 0x5e, 0x64, 0x27, + 0x3c, 0x4f, 0x53, 0x8b, 0x17, 0x97, 0xab, 0x14, 0x58, 0xa8, 0x8d, 0xe9, + 0x34, 0x3e, 0xa9, 0x79, 0x14, 0x95, 0x6d, 0xc8, 0x7f, 0xe1, 0x12, 0x74, + 0xd8, 0x98, 0xfa, 0xfb, 0xf4, 0xd3, 0x82, 0x59, 0x38, 0x0b, 0x48, 0x20}; + +// sqrt(-3) mod p, big-endian. +const uint8_t SQRT_M3_BE[48] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x32, 0xce, 0x5f, + 0xbe, 0xed, 0x9c, 0xa3, 0x74, 0xd3, 0x8c, 0x0e, 0xd4, 0x1e, 0xef, 0xd5, + 0xbb, 0x67, 0x52, 0x77, 0xcd, 0xf1, 0x2d, 0x11, 0xbc, 0x2f, 0xb0, 0x26, + 0xc4, 0x14, 0x00, 0x04, 0x5c, 0x03, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xfd}; + +// (sqrt(-3) - 1) / 2 mod p, big-endian. +const uint8_t SQRT_M3_MINUS_1_HALF_BE[48] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x19, 0x67, 0x2f, + 0xdf, 0x76, 0xce, 0x51, 0xba, 0x69, 0xc6, 0x07, 0x6a, 0x0f, 0x77, 0xea, + 0xdd, 0xb3, 0xa9, 0x3b, 0xe6, 0xf8, 0x96, 0x88, 0xde, 0x17, 0xd8, 0x13, + 0x62, 0x0a, 0x00, 0x02, 0x2e, 0x01, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xfe}; + +// Effective cofactor h_eff of BLS12-381 G2 (RFC 9380 section 8.8.2), +// big-endian, 636 bits. Multiplying by it is equivalent to the +// endomorphism-based cofactor clearing relic performed. +const uint8_t H_EFF_BE[80] = { + 0x0b, 0xc6, 0x9f, 0x08, 0xf2, 0xee, 0x75, 0xb3, 0x58, 0x4c, 0x6a, 0x0e, + 0xa9, 0x1b, 0x35, 0x28, 0x88, 0xe2, 0xa8, 0xe9, 0x14, 0x5a, 0xd7, 0x68, + 0x99, 0x86, 0xff, 0x03, 0x15, 0x08, 0xff, 0xe1, 0x32, 0x9c, 0x2f, 0x17, + 0x87, 0x31, 0xdb, 0x95, 0x6d, 0x82, 0xbf, 0x01, 0x5d, 0x12, 0x12, 0xb0, + 0x2e, 0xc0, 0xec, 0x69, 0xd7, 0x47, 0x7c, 0x1a, 0xe9, 0x54, 0xcb, 0xc0, + 0x66, 0x89, 0xf6, 0xa3, 0x59, 0x89, 0x4c, 0x0a, 0xde, 0xbb, 0xf6, 0xb4, + 0xe8, 0x02, 0x00, 0x05, 0xaa, 0xa9, 0x55, 0x51}; +constexpr size_t H_EFF_BITS{636}; + +void FpFromSmall(blst_fp& out, uint8_t value) +{ + uint8_t be[48]{}; + be[47] = value; + blst_fp_from_bendian(&out, be); +} + +void FpZero(blst_fp& out) +{ + memset(&out, 0, sizeof(out)); +} + +bool FpIsZero(const blst_fp& a) +{ + uint8_t be[48]; + blst_bendian_from_fp(be, &a); + for (uint8_t b : be) { + if (b != 0) return false; + } + return true; +} + +// The legacy sign test: canonical representation greater than (p-1)/2. +bool FpIsLargeRoot(const blst_fp& a) +{ + uint8_t be[48]; + blst_bendian_from_fp(be, &a); + return memcmp(be, HALF_P_BE, sizeof(be)) > 0; +} + +// The decompression-side sign test of relic's ep2_upk: c1 > (p-1)/2, with c0 +// deciding when c1 is zero. (The serialization side uses c1 alone.) +bool Fp2IsLargeRootForDecode(const blst_fp2& y) +{ + return FpIsZero(y.fp[1]) ? FpIsLargeRoot(y.fp[0]) : FpIsLargeRoot(y.fp[1]); +} + +// Reads a big-endian coordinate; a value of p or more reads as zero, which is +// what relic's fp_read_bin left behind when its range check failed. +void ReadCoordinate(blst_fp& out, const uint8_t* be) +{ + if (memcmp(be, P_BE, 48) >= 0) { + FpZero(out); + } else { + blst_fp_from_bendian(&out, be); + } +} + +// x^3 + 4 +void CurveRhsG1(blst_fp& rhs, const blst_fp& x) +{ + blst_fp four; + FpFromSmall(four, 4); + blst_fp_sqr(&rhs, &x); + blst_fp_mul(&rhs, &rhs, &x); + blst_fp_add(&rhs, &rhs, &four); +} + +// x^3 + (4 + 4i) +void CurveRhsG2(blst_fp2& rhs, const blst_fp2& x) +{ + blst_fp2 b; + FpFromSmall(b.fp[0], 4); + FpFromSmall(b.fp[1], 4); + blst_fp2_sqr(&rhs, &x); + blst_fp2_mul(&rhs, &rhs, &x); + blst_fp2_add(&rhs, &rhs, &b); +} + +// Shallue-van de Woestijne encoding of a field element into a G2 point +// (section 3 of Fouque-Tibouchi, "Indifferentiable Hashing to +// Barreto-Naehrig Curves"). Returns false when t is zero, which maps to the +// point at infinity. +bool SwEncodeG2(blst_p2_affine& out, const blst_fp2& t) +{ + if (FpIsZero(t.fp[0]) && FpIsZero(t.fp[1])) { + return false; + } + + // The "parity" of t decides the sign of y: whether t.c1 is the larger of + // the two roots {t.c1, -t.c1}. + blst_fp2 negT; + blst_fp2_cneg(&negT, &t, true); + uint8_t be1[48], be2[48]; + blst_bendian_from_fp(be1, &t.fp[1]); + blst_bendian_from_fp(be2, &negT.fp[1]); + const bool parity = memcmp(be1, be2, sizeof(be1)) > 0; + + blst_fp one; + FpFromSmall(one, 1); + blst_fp2 b; + FpFromSmall(b.fp[0], 4); + FpFromSmall(b.fp[1], 4); + + // w = t^2 + b + 1 + blst_fp2 w; + blst_fp2_sqr(&w, &t); + blst_fp2_add(&w, &w, &b); + blst_fp_add(&w.fp[0], &w.fp[0], &one); + + if (FpIsZero(w.fp[0]) && FpIsZero(w.fp[1])) { + out = *blst_p2_affine_generator(); + if (parity) { + blst_fp2_cneg(&out.y, &out.y, true); + } + return true; + } + + blst_fp2 sqrtM3, sqrtM3Minus1Half; + blst_fp_from_bendian(&sqrtM3.fp[0], SQRT_M3_BE); + FpZero(sqrtM3.fp[1]); + blst_fp_from_bendian(&sqrtM3Minus1Half.fp[0], SQRT_M3_MINUS_1_HALF_BE); + FpZero(sqrtM3Minus1Half.fp[1]); + + // w = sqrt(-3) * t / (t^2 + b + 1) + blst_fp2_inverse(&w, &w); + blst_fp2_mul(&w, &w, &sqrtM3); + blst_fp2_mul(&w, &w, &t); + + // x1 = (sqrt(-3) - 1) / 2 - t * w + blst_fp2 x1; + blst_fp2_cneg(&x1, &w, true); + blst_fp2_mul(&x1, &x1, &t); + blst_fp2_add(&x1, &x1, &sqrtM3Minus1Half); + + // x2 = -1 - x1 + blst_fp2 x2; + blst_fp2_cneg(&x2, &x1, true); + blst_fp_sub(&x2.fp[0], &x2.fp[0], &one); + + // x3 = 1 + 1 / w^2 + blst_fp2 x3; + blst_fp2_sqr(&x3, &w); + blst_fp2_inverse(&x3, &x3); + blst_fp_add(&x3.fp[0], &x3.fp[0], &one); + + // Pick the first candidate that lies on the curve, branch-free as in the paper. + blst_fp2 rhs, y; + CurveRhsG2(rhs, x1); + const int chi1 = blst_fp2_sqrt(&y, &rhs) ? 1 : -1; + CurveRhsG2(rhs, x2); + const int chi2 = blst_fp2_sqrt(&y, &rhs) ? 1 : -1; + const int index = ((((chi1 - 1) * chi2) % 3) + 3) % 3; + + out.x = index == 0 ? x1 : index == 1 ? x2 : x3; + CurveRhsG2(rhs, out.x); + const bool onCurve = blst_fp2_sqrt(&out.y, &rhs); + assert(onCurve); // guaranteed by the construction + (void)onCurve; + + // Align the sign of y with the parity of t. + blst_fp2 negY; + blst_fp2_cneg(&negY, &out.y, true); + blst_bendian_from_fp(be1, &out.y.fp[1]); + blst_bendian_from_fp(be2, &negY.fp[1]); + if ((memcmp(be1, be2, sizeof(be1)) > 0) != parity) { + out.y = negY; + } + return true; +} + +// Reduces a 64-byte big-endian number modulo p as hi * 2^256 + lo, where both +// halves are below 2^256 < p (the way relic converted a 512-bit draw). +void FpFromWideBigEndian(blst_fp& out, const uint8_t* be64) +{ + uint8_t padded[48]{}; + blst_fp hi, lo, shift; + + memcpy(padded + 16, be64, 32); + blst_fp_from_bendian(&hi, padded); + memcpy(padded + 16, be64 + 32, 32); + blst_fp_from_bendian(&lo, padded); + + memset(padded, 0, sizeof(padded)); + padded[15] = 0x01; // 2^256 + blst_fp_from_bendian(&shift, padded); + + blst_fp_mul(&out, &hi, &shift); + blst_fp_add(&out, &out, &lo); +} + +// Two SHA-256 draws of "hash || 'G2__c' || counter" for counter 0 and 1, +// concatenated into a 64-byte value. +void DrawFieldElement(blst_fp& out, const uint256& hash, char i, char j) +{ + uint8_t input[32 + 8]; + memcpy(input, hash.begin(), 32); + input[32] = 'G'; + input[33] = '2'; + input[34] = '_'; + input[35] = static_cast(i); + input[36] = '_'; + input[37] = 'c'; + input[38] = static_cast(j); + + uint8_t draw[64]; + input[39] = 0; + CSHA256().Write(input, sizeof(input)).Finalize(draw); + input[39] = 1; + CSHA256().Write(input, sizeof(input)).Finalize(draw + 32); + + FpFromWideBigEndian(out, draw); +} + +} // namespace + +bool DecodeG1(blst_p1& out, Span in) +{ + assert(in.size() == 48); + const uint8_t prefix = in[0]; + if ((prefix & 0xc0) == 0xc0) { + // only the canonical infinity encoding is accepted + if (prefix != 0xc0) return false; + for (size_t i = 1; i < in.size(); i++) { + if (in[i] != 0) return false; + } + memset(&out, 0, sizeof(out)); + return true; + } + const bool signBit = (prefix & 0x80) != 0; + + uint8_t xbytes[48]; + memcpy(xbytes, in.data(), sizeof(xbytes)); + // The G1 codec cleared all three flag bits before reading x (the G2 codec + // only clears the sign bit, and only when it is set). + xbytes[0] &= 0x1f; + + blst_p1_affine a; + ReadCoordinate(a.x, xbytes); + + blst_fp rhs; + CurveRhsG1(rhs, a.x); + if (blst_fp_sqrt(&a.y, &rhs)) { + if (FpIsLargeRoot(a.y) != signBit) { + blst_fp_cneg(&a.y, &a.y, true); + } + } else if (signBit) { + blst_fp_from_bendian(&a.y, SQRT_FAILURE_MARKER_BE); + } else { + FpZero(a.y); + } + + // Set z = 1 by hand: blst_p1_from_affine maps an all-zero pair to + // infinity, whereas relic kept such degenerate decodes as ordinary points. + out.x = a.x; + out.y = a.y; + FpFromSmall(out.z, 1); + return true; +} + +bool DecodeG2(blst_p2& out, Span in) +{ + assert(in.size() == 96); + if ((in[0] & 0xc0) == 0xc0) { + return false; + } + const bool signBit = (in[0] & 0x80) != 0; + + uint8_t c0[48], c1[48]; + memcpy(c0, in.data(), sizeof(c0)); + memcpy(c1, in.data() + 48, sizeof(c1)); + if (signBit) { + c0[0] &= 0x7f; + } + + blst_p2_affine a; + ReadCoordinate(a.x.fp[0], c0); + ReadCoordinate(a.x.fp[1], c1); + + blst_fp2 rhs; + CurveRhsG2(rhs, a.x); + if (blst_fp2_sqrt(&a.y, &rhs)) { + if (Fp2IsLargeRootForDecode(a.y) != signBit) { + blst_fp2_cneg(&a.y, &a.y, true); + } + } else { + if (signBit) { + blst_fp_from_bendian(&a.y.fp[0], SQRT_FAILURE_MARKER_BE); + } else { + FpZero(a.y.fp[0]); + } + FpZero(a.y.fp[1]); + } + + out.x = a.x; + out.y = a.y; + FpFromSmall(out.z.fp[0], 1); + FpZero(out.z.fp[1]); + return true; +} + +void EncodeG1(Span out, const blst_p1& p) +{ + assert(out.size() == 48); + if (blst_p1_is_inf(&p)) { + memset(out.data(), 0, out.size()); + out[0] = 0xc0; + return; + } + blst_p1_affine a; + blst_p1_to_affine(&a, &p); + blst_bendian_from_fp(out.data(), &a.x); + if (FpIsLargeRoot(a.y)) { + out[0] |= 0x80; + } +} + +void EncodeG2(Span out, const blst_p2& p) +{ + assert(out.size() == 96); + if (blst_p2_is_inf(&p)) { + memset(out.data(), 0, out.size()); + out[0] = 0xc0; + return; + } + blst_p2_affine a; + blst_p2_to_affine(&a, &p); + blst_bendian_from_fp(out.data(), &a.x.fp[0]); + blst_bendian_from_fp(out.data() + 48, &a.x.fp[1]); + // sign taken from c1 alone, no fallback to c0 + if (FpIsLargeRoot(a.y.fp[1])) { + out[0] |= 0x80; + } +} + +void HashToG2(blst_p2& out, const uint256& hash) +{ + blst_fp2 t0, t1; + DrawFieldElement(t0.fp[0], hash, '0', '0'); + DrawFieldElement(t0.fp[1], hash, '0', '1'); + DrawFieldElement(t1.fp[0], hash, '1', '0'); + DrawFieldElement(t1.fp[1], hash, '1', '1'); + + blst_p2 sum; + memset(&sum, 0, sizeof(sum)); // infinity + blst_p2_affine enc; + if (SwEncodeG2(enc, t0)) { + blst_p2_from_affine(&sum, &enc); + } + if (SwEncodeG2(enc, t1)) { + blst_p2_add_or_double_affine(&sum, &sum, &enc); + } + + uint8_t hEffLittleEndian[sizeof(H_EFF_BE)]; + for (size_t i = 0; i < sizeof(H_EFF_BE); i++) { + hEffLittleEndian[i] = H_EFF_BE[sizeof(H_EFF_BE) - 1 - i]; + } + blst_p2_mult(&out, &sum, hEffLittleEndian, H_EFF_BITS); +} + +} // namespace bls_legacy diff --git a/src/bls/bls_legacy.h b/src/bls/bls_legacy.h new file mode 100644 index 000000000000..037ff4959cb0 --- /dev/null +++ b/src/bls/bls_legacy.h @@ -0,0 +1,58 @@ +// Copyright (c) 2026 The Dash Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_BLS_BLS_LEGACY_H +#define BITCOIN_BLS_BLS_LEGACY_H + +#include +#include + +#include + +#include + +/** + * Point codec and hash-to-curve of the legacy (pre-v19) BLS scheme. + * + * Both reproduce, bit for bit, what the relic-based implementation did before + * the v19 hard fork, including its treatment of malformed input: relic was + * built without its CHECK option, so decoding never failed but left degenerate + * coordinates behind (an out-of-range coordinate reads as zero, a missing + * square root leaves y at zero or at a raw marker value). Every such point is + * consensus-visible through re-serialization of on-chain data, so all of it + * is kept. + */ +namespace bls_legacy { + +/** + * Deserializes a G1 point from its 48-byte legacy encoding. Returns false only + * for a non-canonical infinity encoding (top two bits set with anything but + * 0xc0 00..00). Any other input yields a point, possibly off the curve and + * outside the subgroup; the caller decides whether that is acceptable. + */ +bool DecodeG1(blst_p1& out, Span in); + +/** + * Deserializes a G2 point from its 96-byte legacy encoding (x.c0 || x.c1). + * Returns false for any input with the top two bits set: the legacy G2 codec + * rejected the infinity encoding along with everything else in that range. + */ +bool DecodeG2(blst_p2& out, Span in); + +/** Serializes a G1 point: 0xc0 00..00 for infinity, else x with bit 0x80 set iff y > (p-1)/2. */ +void EncodeG1(Span out, const blst_p1& p); + +/** Serializes a G2 point: 0xc0 00..00 for infinity, else x.c0 || x.c1 with bit 0x80 set iff y.c1 > (p-1)/2. */ +void EncodeG2(Span out, const blst_p2& p); + +/** + * Legacy hash-to-G2 of a 32-byte message hash: two Fouque-Tibouchi + * (Shallue-van de Woestijne) encodings of SHA-256 derived field elements, + * added and multiplied by the effective cofactor. + */ +void HashToG2(blst_p2& out, const uint256& hash); + +} // namespace bls_legacy + +#endif // BITCOIN_BLS_BLS_LEGACY_H diff --git a/src/dashbls/.clang-format b/src/dashbls/.clang-format deleted file mode 100644 index b2a45d802046..000000000000 --- a/src/dashbls/.clang-format +++ /dev/null @@ -1,17 +0,0 @@ -BasedOnStyle: Google -UseTab: Never -ColumnLimit: 80 -IndentWidth: 4 -TabWidth: 4 -AllowShortIfStatementsOnASingleLine: false -IndentCaseLabels: false -AccessModifierOffset: -4 -BinPackArguments: false -BinPackParameters: false -AlignAfterOpenBracket: AlwaysBreak -IndentCaseLabels: true -AllowAllParametersOfDeclarationOnNextLine: false -BreakBeforeBraces: Custom -BraceWrapping: - AfterFunction: true -PenaltyReturnTypeOnItsOwnLine: 1000 diff --git a/src/dashbls/.flake8 b/src/dashbls/.flake8 deleted file mode 100644 index ccb153056291..000000000000 --- a/src/dashbls/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -max-line-length = 120 -exclude = ./typings/**/* python-impl/fields.py -ignore = E203,W503,E501 diff --git a/src/dashbls/.github/workflows/build-binds.yml b/src/dashbls/.github/workflows/build-binds.yml deleted file mode 100644 index 43dc8b212590..000000000000 --- a/src/dashbls/.github/workflows/build-binds.yml +++ /dev/null @@ -1,96 +0,0 @@ -name: Build and test binds - -on: - push: - branches: - - main - tags: - - '**' - pull_request: - branches: - - '**' - -concurrency: - # SHA is added to the end if on `main` to let all main workflows run - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} - cancel-in-progress: true - -jobs: - build: - name: ${{ matrix.os }}, Python ${{ matrix.python }}, Go ${{ matrix.golang }}, Rust ${{ matrix.rust }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [macos-latest, ubuntu-latest] - golang: [ '1.24' ] - python: ['3.10', '3.11', '3.12', '3.13'] - rust: [ '1.91.0' ] - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - uses: chia-network/actions/setup-python@main - with: - python-version: ${{ matrix.python }} - - - name: Test Python implementation - run: | - python python-impl/impl-test.py - - - name: Install Emscripten SDK - uses: mymindstorm/setup-emsdk@v11 - - - name: Build JavaScript bindings - run: | - emcc -v - sh emsdk_build.sh - - - name: Test JavaScript bindings - run: | - sh js_test.sh - - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ^${{ matrix.golang }} - - - name: Prepare build system for Ubuntu - if: startsWith(matrix.os, 'ubuntu') - run: | - sudo apt-get update - sudo apt-get install -qq --yes valgrind libgmp-dev cmake - hash -r - cmake --version - - - name: Prepare build system for macOS - if: startsWith(matrix.os, 'macos') - run: | - ls -l - export MACOSX_DEPLOYMENT_TARGET=10.14 - brew install gmp - - - name: Build library using CMake - run: | - mkdir -p build && cd build - cmake .. -DCMAKE_BUILD_TYPE=Debug - cmake --build . -- -j 6 - - - name: Build Go bindings - run: | - cd go-bindings - make config - make - - - name: Install Rust - run: | - rustup toolchain install ${{ matrix.rust }} - rustup default ${{ matrix.rust }} - rustc --version - cargo --version - - - name: Build and test Rust bindings - run: | - cd rust-bindings/bls-dash-sys - cargo test diff --git a/src/dashbls/.github/workflows/build-test.yaml b/src/dashbls/.github/workflows/build-test.yaml deleted file mode 100644 index 90a550a5e4d2..000000000000 --- a/src/dashbls/.github/workflows/build-test.yaml +++ /dev/null @@ -1,72 +0,0 @@ -name: Build and test library - -on: - push: - branches: - - main - tags: - - '**' - pull_request: - branches: - - '**' - -concurrency: - # SHA is added to the end if on `main` to let all main workflows run - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} - cancel-in-progress: true - -jobs: - build: - name: ${{ matrix.os }}, ${{ matrix.builder }}, ${{ matrix.compiler.cc }}, ${{ matrix.backend }} backend - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ macos-latest, ubuntu-latest ] - builder: [ cmake, autotools ] - compiler: - - cc: gcc - cxx: g++ - - cc: clang - cxx: clang++ - backend: [ easy, gmp ] - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Prepare build system for Ubuntu - if: startsWith(matrix.os, 'ubuntu') - run: | - sudo apt-get update - sudo apt-get install -qq --yes valgrind libgmp-dev cmake - hash -r - cmake --version - - - name: Prepare build system for macOS - if: startsWith(matrix.os, 'macos') - run: | - ls -l - export MACOSX_DEPLOYMENT_TARGET=10.14 - brew install autoconf automake gmp libtool pkg-config - - - name: Build library using CMake - if: startsWith(matrix.builder, 'cmake') - run: | - mkdir -p build && cd build - CC=${{ matrix.compiler.cc }} CXX=${{ matrix.compiler.cxx }} cmake .. -DARITH=${{ matrix.backend }} -DBUILD_BLS_PYTHON_BINDINGS=0 -DCMAKE_BUILD_TYPE=Debug - cmake --build . -- -j 6 - mv src/runtest .. - - - name: Build library using GNU Autotools - if: startsWith(matrix.builder, 'autotools') - run: | - ./autogen.sh - CC=${{ matrix.compiler.cc }} CXX=${{ matrix.compiler.cxx }} ./configure --with-backend=${{ matrix.backend }} - make -j8 - - - name: Run tests - run: ./runtest - - - name: Run valgrind on Ubuntu - if: startsWith(matrix.os, 'ubuntu') - run: valgrind --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all ./runtest diff --git a/src/dashbls/.github/workflows/build-wheels.yml b/src/dashbls/.github/workflows/build-wheels.yml deleted file mode 100644 index 6953beebc5f8..000000000000 --- a/src/dashbls/.github/workflows/build-wheels.yml +++ /dev/null @@ -1,357 +0,0 @@ -name: build - check - upload - -on: - push: - branches: - - main - tags: - - '**' - pull_request: - branches: - - '**' - -concurrency: - # SHA is added to the end if on `main` to let all main workflows run - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }} - cancel-in-progress: true - -jobs: - build-wheels: - name: Wheel - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} - runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} - strategy: - fail-fast: false - matrix: - os: - - name: macOS - matrix: macos - runs-on: - arm: [macOS, ARM64] - intel: [macos-latest] - cibw-archs-macos: - arm: arm64 - intel: x86_64 - - name: Ubuntu - matrix: ubuntu - runs-on: - arm: [Linux, ARM64] - intel: [ubuntu-latest] - - name: Windows - matrix: windows - runs-on: - intel: [windows-latest] - python: - - major-dot-minor: '3.7' - cibw-build: 'cp37-*' - manylinux: - arch: manylinux2014 - intel: manylinux2010 - matrix: '3.7' - - major-dot-minor: '3.8' - cibw-build: 'cp38-*' - manylinux: - arch: manylinux2014 - intel: manylinux2010 - matrix: '3.8' - - major-dot-minor: '3.9' - cibw-build: 'cp39-*' - manylinux: - arch: manylinux2014 - intel: manylinux2010 - matrix: '3.9' - - major-dot-minor: '3.10' - cibw-build: 'cp310-*' - manylinux: - arch: manylinux2014 - intel: manylinux2010 - matrix: '3.10' - - major-dot-minor: '3.11' - cibw-build: 'cp311-*' - manylinux: - arch: manylinux2014 - intel: manylinux2014 - matrix: '3.11' - arch: - - name: ARM - matrix: arm - - name: Intel - matrix: intel - exclude: - # Only partial entries are required here by GitHub Actions so generally I - # only specify the `matrix:` entry. The super linter complains so for now - # all entries are included to avoid that. Reported at - # https://github.com/github/super-linter/issues/3016 - - os: - name: Windows - matrix: windows - runs-on: - intel: [windows-latest] - arch: - name: ARM - matrix: arm - - os: - name: macOS - matrix: macos - runs-on: - arm: [macOS, ARM64] - intel: [macos-latest] - python: - major-dot-minor: '3.7' - cibw-build: 'cp37-*' - matrix: '3.7' - arch: - name: ARM - matrix: arm - - os: - name: macOS - matrix: macos - runs-on: - arm: [macOS, ARM64] - intel: [macos-latest] - python: - major-dot-minor: '3.8' - cibw-build: 'cp38-*' - matrix: '3.8' - arch: - name: ARM - matrix: arm - - steps: - - name: Clean workspace - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: chia-network/actions/setup-python@main - with: - python-version: ${{ matrix.python.major-dot-minor }} - - - name: Install pipx - run: | - pip install pipx - - - name: Build and test - env: - CIBW_PRERELEASE_PYTHONS: True - CIBW_BUILD_VERBOSITY_MACOS: 0 - CIBW_BUILD_VERBOSITY_LINUX: 0 - CIBW_BUILD_VERBOSITY_WINDOWS: 0 - CIBW_BUILD: ${{ matrix.python.cibw-build }} - CIBW_SKIP: '*-manylinux_i686 *-win32 *-musllinux_*' - CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.python.manylinux['arm'] }} - CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.python.manylinux['intel'] }} - CIBW_ENVIRONMENT_LINUX: "PATH=/project/cmake-3.14.3-Linux-`uname -m`/bin:$PATH" - CIBW_BEFORE_ALL_LINUX: > - yum -y install epel-release - && echo "epel-release installed" - && yum -y install lzip - && echo "lzip installed" - && curl -L https://github.com/Kitware/CMake/releases/download/v3.14.3/cmake-3.14.3-Linux-`uname -m`.sh > cmake.sh - && yes | sh cmake.sh | cat - && rm -f /usr/bin/cmake - && curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz | tar x --lzip - && cp contrib/gmp-patch-6.2.1/longlong.h gmp-6.2.1/ - && cp contrib/gmp-patch-6.2.1/compat.c gmp-6.2.1/ - && cd gmp-6.2.1 && ./configure --enable-fat - && make && make install && cd .. && rm -rf gmp-6.2.1 - && cmake --version - && uname -a - CIBW_BEFORE_BUILD_LINUX: > - python -m pip install --upgrade pip - CIBW_ARCHS_MACOS: ${{ matrix.os.cibw-archs-macos[matrix.arch.matrix] }} - CIBW_BEFORE_ALL_MACOS: > - brew install gmp boost cmake - CIBW_BEFORE_BUILD_MACOS: > - python -m pip install --upgrade pip - CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=10.14" - CIBW_REPAIR_WHEEL_COMMAND_MACOS: > - pip uninstall -y delocate && pip install git+https://github.com/Chia-Network/delocate.git - && delocate-listdeps {wheel} && delocate-wheel -v {wheel} - && cp {wheel} {dest_dir} - CIBW_BEFORE_ALL_WINDOWS: > - curl -L https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip > libsodium-1.0.18-stable-msvc.zip - && 7z x libsodium-1.0.18-stable-msvc.zip - && git clone https://github.com/Chia-Network/relic_ietf_64.git - && ls -l relic_ietf_64 - && git clone https://github.com/Chia-Network/mpir_gc_x64.git - && ls -l mpir_gc_x64 - CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: > - ls -l mpir_gc_x64 && pip uninstall -y delocate - && pip install git+https://github.com/Chia-Network/delocate.git - && delocate-wheel -v -i mpir_gc_x64/mpir.dll {wheel} - && delocate-wheel -v -i mpir_gc_x64/mpir_gc.dll {wheel} - && delocate-wheel -v -i mpir_gc_x64/mpir_broadwell.dll {wheel} - && delocate-wheel -v -i mpir_gc_x64/mpir_broadwell_avx.dll {wheel} - && delocate-wheel -v -i mpir_gc_x64/mpir_bulldozer.dll {wheel} - && delocate-wheel -v -i mpir_gc_x64/mpir_haswell.dll {wheel} - && delocate-wheel -v -i mpir_gc_x64/mpir_piledriver.dll {wheel} - && delocate-wheel -v -i mpir_gc_x64/mpir_sandybridge.dll {wheel} - && delocate-wheel -v -i mpir_gc_x64/mpir_skylake_avx.dll {wheel} - && cp {wheel} {dest_dir} - CIBW_TEST_REQUIRES: pytest - CIBW_TEST_COMMAND: py.test -v {project}/python-bindings/test.py - run: - pipx run --spec='cibuildwheel==2.9.0' cibuildwheel --output-dir dist 2>&1 - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: packages - path: ./dist - - build-sdist: - name: sdist - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} - runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} - strategy: - fail-fast: false - matrix: - os: - - name: Ubuntu - matrix: ubuntu - runs-on: - arm: [Linux, ARM64] - intel: [ubuntu-latest] - python: - - major-dot-minor: '3.9' - matrix: '3.9' - arch: - - name: Intel - matrix: intel - - steps: - - name: Clean workspace - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: Chia-Network/actions/setup-python@main - with: - python-version: ${{ matrix.python.major-dot-minor }} - - - name: Build source distribution - run: | - pip install build - python -m build --sdist --outdir dist . - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: packages - path: ./dist - - check: - name: Check - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} - runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} - strategy: - fail-fast: false - matrix: - os: - - name: Ubuntu - matrix: ubuntu - runs-on: - arm: [Linux, ARM64] - intel: [ubuntu-latest] - python: - - major-dot-minor: '3.9' - matrix: '3.9' - arch: - - name: Intel - matrix: intel - - steps: - - name: Clean workspace - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: Chia-Network/actions/setup-python@main - with: - python-version: ${{ matrix.python.major-dot-minor }} - - - name: flake8 - run: | - pip install flake8 - flake8 src setup.py python-bindings python-impl - - name: mypy - run: | - pip install mypy - mypy --config-file mypi.ini python-bindings python-impl - upload: - name: Upload to PyPI - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} - runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} - needs: - - build-wheels - - build-sdist - - check - strategy: - fail-fast: false - matrix: - os: - - name: Ubuntu - matrix: ubuntu - runs-on: - arm: [Linux, ARM64] - intel: [ubuntu-latest] - python: - - major-dot-minor: '3.9' - matrix: '3.9' - arch: - - name: Intel - matrix: intel - - steps: - - name: Clean workspace - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: Chia-Network/actions/setup-python@main - with: - python-version: ${{ matrix.python.major-dot-minor }} - - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: packages - path: ./dist - - - name: Test for secrets access - id: check_secrets - shell: bash - run: | - unset HAS_SECRET - if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi - echo ::set-output name=HAS_SECRET::${HAS_SECRET} - env: - SECRET: "${{ secrets.test_pypi_password }}" - - - name: Install twine - run: pip install twine - - - name: Publish distribution to PyPI - if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET - env: - TWINE_USERNAME: __token__ - TWINE_NON_INTERACTIVE: 1 - TWINE_PASSWORD: ${{ secrets.pypi_password }} - run: twine upload --non-interactive --skip-existing --verbose 'dist/*' - - - name: Publish distribution to Test PyPI - if: steps.check_secrets.outputs.HAS_SECRET - env: - TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ - TWINE_USERNAME: __token__ - TWINE_NON_INTERACTIVE: 1 - TWINE_PASSWORD: ${{ secrets.test_pypi_password }} - run: twine upload --non-interactive --skip-existing --verbose 'dist/*' diff --git a/src/dashbls/.github/workflows/js-bindings.yml b/src/dashbls/.github/workflows/js-bindings.yml deleted file mode 100644 index 887c8df3d628..000000000000 --- a/src/dashbls/.github/workflows/js-bindings.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Build & Publish JS Bindings - -on: - push: - branches: - - main - tags: - - '**' - pull_request: - branches: - - '**' - -concurrency: - # SHA is added to the end if on `main` to let all main workflows run - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} - cancel-in-progress: true - -jobs: - js_bindings: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: actions/setup-node@v3 - with: - node-version: 16 - - - name: Install emsdk - uses: mymindstorm/setup-emsdk@v11 - - - name: Get the version - id: version_info - run: echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} - - - name: Update version in package.json - if: startsWith(github.ref, 'refs/tags/') - working-directory: ${{ github.workspace }}/js-bindings - env: - SOURCE_TAG: ${{ steps.version_info.outputs.SOURCE_TAG }} - run: | - jq --arg VER "$SOURCE_TAG" '.version=$VER' package.json > temp.json && mv temp.json package.json - - - name: Build JS - run: ./js_build.sh - - - name: Publish - if: startsWith(github.ref, 'refs/tags/') - working-directory: ${{ github.workspace }}/js_build/js-bindings - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: | - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc - npm publish --access public - - - name: Cleanup - if: always() - run: - rm ${{ github.workspace }}/js_build/js-bindings/.npmrc || true diff --git a/src/dashbls/.github/workflows/relic-nightly.yml b/src/dashbls/.github/workflows/relic-nightly.yml deleted file mode 100644 index 2a9ef67153cc..000000000000 --- a/src/dashbls/.github/workflows/relic-nightly.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Build and Test with Relic Nightly - -on: - schedule: - - cron: "0 11 * * *" - workflow_dispatch: - -concurrency: - # SHA is added to the end if on `main` to let all main workflows run - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} - cancel-in-progress: true - -jobs: - build_wheels: - name: Build and Test with Relic Nightly - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [macos-latest, ubuntu-latest] - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Ubuntu build C++ and test Relic at origin/main - if: startsWith(matrix.os, 'ubuntu') - run: | - echo "Relic origin/main commit:" - curl -H "application/vnd.github.v3.sha" \ - https://api.github.com/repos/relic-toolkit/relic/commits/main | \ - head -10 - sudo apt-get update - sudo apt-get install snap -y - sudo apt-get remove --purge cmake -y - sudo snap install cmake --classic - hash -r - cmake --version - export RELIC_MAIN=1 - mkdir -p build - cd build - cmake ../ - cmake --build . -- -j 6 - echo "Running ./src/runtest" - ./src/runtest - - - name: Mac OS build C++ and test - if: startsWith(matrix.os, 'macos') - run: | - ls -l - export MACOSX_DEPLOYMENT_TARGET=10.14 - export RELIC_MAIN=1 - mkdir -p build - ls -l build - cd build - cmake ../ - cmake --build . -- -j 6 - echo "Running ./src/runtest" - ./src/runtest - - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.8' - - - name: Test pure python implementation - run: | - python python-impl/impl-test.py - - - name: Install emsdk - uses: mymindstorm/setup-emsdk@v11 - - - name: Test javascript bindings - run: | - emcc -v - export RELIC_MAIN=1 - sh emsdk_build.sh - sh js_test.sh diff --git a/src/dashbls/.github/workflows/stale-issue.yml b/src/dashbls/.github/workflows/stale-issue.yml deleted file mode 100755 index e3668dba6984..000000000000 --- a/src/dashbls/.github/workflows/stale-issue.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: 'Close stale issues' -on: - schedule: - - cron: '0 11 * * *' - -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: chia-network/stale@main - with: - operations-per-run: 10000 - ascending: true - days-before-issue-stale: 14 - days-before-issue-close: 7 - days-before-pr-stale: 60 - days-before-pr-close: -1 - exempt-all-pr-milestones: true - exempt-all-issue-milestones: true - exempt-all-assignees: true - stale-issue-label: stale-issue - stale-pr-label: stale-pr - remove-stale-when-updated: true - stale-issue-message: > - 'This issue has been flagged as stale as there has been no - activity on it in 14 days. If this issue is still affecting you - and in need of review, please update it to keep it open.' - close-issue-message: > - 'This issue was automatically closed because it has been flagged - as stale and subsequently passed 7 days with no further activity.' - stale-pr-message: > - 'This PR has been flagged as stale due to no activity for over 60 - days. It will not be automatically closed, but it has been given - a stale-pr label and should be manually reviewed.' diff --git a/src/dashbls/.gitignore b/src/dashbls/.gitignore deleted file mode 100644 index bec3896a5c07..000000000000 --- a/src/dashbls/.gitignore +++ /dev/null @@ -1,117 +0,0 @@ -CMakeCache.txt -CMakeFiles -cmake_install.cmake -Makefile -src/bench -src/test -src/MakefilE -src/cmake_install.cmake -src/CMakeFile -build/* -blspy.egg-info -dist -python-impl/__pycache__/ -blspy.*.so -.mypy_cache/ -.pytest_chache/ -.eggs/ -cmake-build-debug/ - -js_build -node_modules - -main -.o -obj/ -src/*.o -depends/relic/CTestTestfile.cmake -depends/relic/bench/CTestTestfile.cmake -depends/relic/bin -depends/relic/include/relic_conf.h -depends/relic/include/relic_conf.h.in -depends/relic/include/relic_conf.h.old -depends/relic/include/stamp-h1 -depends/relic/test/CTestTestfile.cmake -contrib/gmp-6.1.2/ - -.idea -.vscode -runtest -runtest.* -runbench -runbench.* - -.dirstamp -.libs -.*.swp -*.*~* -*.bak -*.rej -*.orig -*.pyc -*.o -*.o-* -*.patch -*.a -*.pb.cc -*.pb.h -*.lo -*.la - -**/.DS_Store - -*.whl -venv -env/ -yarn-error.log - -.vs/ -out/ - -target - -Makefile.in -/ar-lib -/mdate-sh -/py-compile -/test-driver -/ylwrap -.deps/ -.dirstamp -aclocal.m4 -autom4te.cache/ -build-aux/config.guess -build-aux/config.sub -build-aux/depcomp -build-aux/install-sh -build-aux/ltmain.sh -build-aux/m4/libtool.m4 -build-aux/m4/lt~obsolete.m4 -build-aux/m4/ltoptions.m4 -build-aux/m4/ltsugar.m4 -build-aux/m4/ltversion.m4 -build-aux/missing -build-aux/compile -build-aux/test-driver -configure -libtool - -autom4te.cache -/autoscan.log -/autoscan-*.log -/aclocal.m4 -/compile -/config.cache -/config.guess -/config.h.in -/config.log -/config.status -/config.sub -/configure -/configure.scan -/depcomp -/install-sh -/missing -/stamp-h1 -/ltmain.sh -/texinfo.tex diff --git a/src/dashbls/CMakeLists.txt b/src/dashbls/CMakeLists.txt deleted file mode 100644 index f413f97cc7a9..000000000000 --- a/src/dashbls/CMakeLists.txt +++ /dev/null @@ -1,150 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.14.0 FATAL_ERROR) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_C_STANDARD 99) - -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" - CACHE STRING "Possible values are empty, Debug, Release, RelWithDebInfo, MinSizeRel, ..." - FORCE - ) -endif() - -project(BLS) - -set(BUILD_BLS_JS_BINDINGS "1" CACHE STRING "") -set(BUILD_BLS_PYTHON_BINDINGS "1" CACHE STRING "") -set(BUILD_BLS_TESTS "1" CACHE STRING "") -set(BUILD_BLS_BENCHMARKS "1" CACHE STRING "") - -message(STATUS "Build python bindings: ${BUILD_BLS_PYTHON_BINDINGS}") -message(STATUS "Build tests: ${BUILD_BLS_TESTS}") -message(STATUS "Build benchmarks: ${BUILD_BLS_BENCHMARKS}") - -# Add path for custom modules -set(CMAKE_MODULE_PATH - ${CMAKE_MODULE_PATH} - ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules -) - -# Relic related options - -set(STBIN "off" CACHE STRING "Relic - Build static binaries") - -find_package(gmp) -if (GMP_FOUND) - message(STATUS "Found libgmp") - set(ARITH "gmp" CACHE STRING "") -else() - set(ARITH "easy" CACHE STRING "") -endif() - -if(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(WSIZE "32" CACHE STRING "Relic - Processor word size") -else() - set(WSIZE "64" CACHE STRING "Relic - Processor word size") -endif() - -if(EMSCRIPTEN) - # emscripten needs arch set to be none since it can't compile assembly - set(ARCH "" CACHE STRING "") - # emscripten is a 32 bit compiler - set(WSIZE "32" CACHE STRING "Relic - Processor word size") -endif() - -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - set(TIMER "ANSI" CACHE STRING "") - set(MULTI "OPENMP" CACHE STRING "") -else() - set(TIMER "CYCLE" CACHE STRING "") - set(MULTI "PTHREAD" CACHE STRING "") -endif() - -set(CHECK "off" CACHE STRING "") -set(VERBS "off" CACHE STRING "") -set(ALLOC "AUTO" CACHE STRING "") -set(SHLIB "off" CACHE STRING "") -set(DOCUM "off" CACHE STRING "") -set(FP_PRIME "381" CACHE STRING "Relic - Prime modulus size") - -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(SEED "UDEV" CACHE STRING "") - set(FP_QNRES "off" CACHE STRING "") -elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - set(SEED "WCGR" CACHE STRING "") - set(FP_QNRES "on" CACHE STRING "") -else() - set(SEED "UDEV" CACHE STRING "") - set(FP_QNRES "on" CACHE STRING "") -endif() - -set(FP_METHD "INTEG;INTEG;INTEG;MONTY;LOWER;SLIDE" CACHE STRING "") - -if(MSVC) - set(COMP_FLAGS "" CACHE STRING "") -else() - set(COMP_FLAGS "-O3 -funroll-loops -fomit-frame-pointer" CACHE STRING "") -endif() - -set(FP_PMERS "off" CACHE STRING "") -set(FPX_METHD "INTEG;INTEG;LAZYR" CACHE STRING "") -set(EP_PLAIN "off" CACHE STRING "") -set(EP_SUPER "off" CACHE STRING "") -# Disable relic tests and benchmarks -set(TESTS "0" CACHE STRING "Relic - Number of times each test is ran") -set(BENCH "0" CACHE STRING "Relic - Number of times each benchmark is ran") - -set(QUIET "on" CACHE STRING "Relic - Build with printing disabled") - -set(PP_EXT "LAZYR" CACHE STRING "") -set(PP_METHD "LAZYR;OATEP" CACHE STRING "") - -# Disable mimalloc shared libraries and tests, enable secure mode -set(MI_SECURE "on" CACHE STRING "") - -set(MI_BUILD_SHARED "off" CACHE STRING "") -set(MI_BUILD_TESTS "off" CACHE STRING "") -set(MI_OVERRIDE "off" CACHE STRING "") - -add_subdirectory(depends/relic) -add_subdirectory(depends/mimalloc) - -#message(STATUS "Patching Relic to make setjmp.h inclusion conditional") -# -#execute_process( -# COMMAND bash -c "git apply ${CMAKE_SOURCE_DIR}/setjmp_patch.diff" -# WORKING_DIRECTORY ${RELIC_SRC} -#) - -add_subdirectory(src) - - -# Write include paths for rust binding -if(EMSCRIPTEN) - file(APPEND "${CMAKE_CURRENT_LIST_DIR}/build/include_paths.txt" "${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}/c++/v1/;") -endif() - -file(APPEND "${CMAKE_CURRENT_LIST_DIR}/build/include_paths.txt" "${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES};") - -if(GMP_INCLUDES) - file(APPEND "${CMAKE_CURRENT_LIST_DIR}/build/include_paths.txt" "${GMP_INCLUDES};") -endif() - -# Write gmp library path for rust binding -if(GMP_LIBRARIES) - file(APPEND "${CMAKE_CURRENT_LIST_DIR}/build/gmp_libraries.txt" "${GMP_LIBRARIES}") -endif() - -if(EMSCRIPTEN) - if(BUILD_BLS_JS_BINDINGS) - add_subdirectory(js-bindings) - endif() -else() - # emscripten can't build python bindings, it produces only javascript - # add_subdirectory(contrib/pybind11) - if(BUILD_BLS_PYTHON_BINDINGS) - add_subdirectory(python-bindings) - endif() -endif() diff --git a/src/dashbls/LICENSE b/src/dashbls/LICENSE deleted file mode 100644 index f433b1a53f5b..000000000000 --- a/src/dashbls/LICENSE +++ /dev/null @@ -1,177 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS diff --git a/src/dashbls/MANIFEST.in b/src/dashbls/MANIFEST.in deleted file mode 100644 index 3063e7883b3c..000000000000 --- a/src/dashbls/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include README.md LICENSE -global-include CMakeLists.txt *.cmake -recursive-include cmake_modules * -recursive-include src * -recursive-include python-bindings * -recursive-include contrib * \ No newline at end of file diff --git a/src/dashbls/Makefile.am b/src/dashbls/Makefile.am deleted file mode 100644 index 1c1e5d19d594..000000000000 --- a/src/dashbls/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) 2013-2016 The Bitcoin Core developers -# Copyright (c) 2022 The Dash Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. - -print-%: FORCE - @echo '$*'='$($*)' - -ACLOCAL_AMFLAGS = -I build-aux/m4 -.PHONY: deploy FORCE - -AM_LDFLAGS = $(HARDENED_LDFLAGS) $(CORE_LDFLAGS) $(GMP_LDFLAGS) -AM_CFLAGS = $(DEBUG_FLAGS) $(HARDENED_FLAGS) $(CORE_FLAGS) $(WARN_FLAGS) $(NOWARN_FLAGS) -AM_CPPFLAGS = $(CORE_CPPFLAGS) $(GMP_CPPFLAGS) -AM_CXXFLAGS = $(DEBUG_FLAGS) $(HARDENED_FLAGS) $(CORE_FLAGS) $(WARN_FLAGS) $(NOWARN_FLAGS) -PTHREAD_FLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) - -EXTRA_LIBRARIES = - -lib_LTLIBRARIES = -noinst_LTLIBRARIES = - -bin_PROGRAMS = -noinst_PROGRAMS = -EXTRA_DIST = - -CLEANFILES = - -include Makefile.bls.include - -CLEANFILES += $(LIBRELIC) $(LIBDASHBLS) $(LIBMIMALLOC) - -if USE_TESTS -CLEANFILES += $(DASHBLS_RUNTEST) -endif - -if USE_BENCH -CLEANFILES += $(DASHBLS_RUNBENCH) -endif diff --git a/src/dashbls/Makefile.bench.include b/src/dashbls/Makefile.bench.include deleted file mode 100644 index f584102a3294..000000000000 --- a/src/dashbls/Makefile.bench.include +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2021 The PIVX developers -# Copyright (c) 2022 The Dash Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. - -DASHBLS_RUNBENCH = runbench - -runbench_SOURCES = \ - src/test-bench.cpp \ - src/test-utils.hpp - -runbench_SOURCES += \ - $(RELIC_H) \ - $(DASHBLS_H) - -runbench_CPPFLAGS = $(AM_CPPFLAGS) $(DASHBLS_INCLUDES) $(RELIC_INCLUDES) -runbench_CXXFLAGS = $(AM_CXXFLAGS) -runbench_LDFLAGS = -static $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) - -runbench_LDADD = $(LIBDASHBLS) - -noinst_PROGRAMS += $(DASHBLS_RUNBENCH) diff --git a/src/dashbls/Makefile.bls.include b/src/dashbls/Makefile.bls.include deleted file mode 100644 index 7c35b3ced764..000000000000 --- a/src/dashbls/Makefile.bls.include +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (c) 2021 The PIVX developers -# Copyright (c) 2022 The Dash Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. - -LIBDASHBLS = libdashbls.la - -DASHBLS_CPPFLAGS = -DBLSALLOC_MIMALLOC=1 - -DASHBLS_INCLUDES = \ - -I$(builddir) \ - -I$(builddir)/obj \ - -I$(top_srcdir)/include/dashbls - -DASHBLS_H = \ - src/bls.hpp \ - src/chaincode.hpp \ - src/elements.hpp \ - src/extendedprivatekey.hpp \ - src/extendedpublickey.hpp \ - src/hdkeys.hpp \ - src/hkdf.hpp \ - src/legacy.hpp \ - src/privatekey.hpp \ - src/schemes.hpp \ - src/test-utils.hpp \ - src/threshold.hpp \ - src/util.hpp - -libdashbls_la_SOURCES = \ - src/bls.cpp \ - src/chaincode.cpp \ - src/elements.cpp \ - src/extendedprivatekey.cpp \ - src/extendedpublickey.cpp \ - src/legacy.cpp \ - src/privatekey.cpp \ - src/schemes.cpp \ - src/threshold.cpp - -libdashbls_la_SOURCES += \ - $(DASHBLS_H) \ - $(MIMALLOC_H) \ - $(RELIC_H) - -libdashbls_la_LIBADD = \ - $(LIBMIMALLOC) \ - $(LIBRELIC) \ - $(GMP_LIBS) - -libdashbls_la_CPPFLAGS = $(AM_CPPFLAGS) $(RELIC_INCLUDES) $(MIMALLOC_INCLUDES) $(DASHBLS_INCLUDES) $(DASHBLS_CPPFLAGS) -libdashbls_la_CXXFLAGS = $(AM_CXXFLAGS) -libdashbls_la_LDFLAGS = $(AM_LDFLAGS) - -include Makefile.mimalloc.include -include Makefile.relic.include - -if USE_TESTS -include Makefile.test.include -endif - -if USE_BENCH -include Makefile.bench.include -endif - -lib_LTLIBRARIES += $(LIBDASHBLS) diff --git a/src/dashbls/Makefile.mimalloc.include b/src/dashbls/Makefile.mimalloc.include deleted file mode 100644 index fada5fe32819..000000000000 --- a/src/dashbls/Makefile.mimalloc.include +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2022-2025 The Dash Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. - -LIBMIMALLOC = libmimalloc-secure.la - -MIMALLOC_CPPFLAGS = \ - -DMI_SECURE=4 \ - -DNDEBUG - -MIMALLOC_INCLUDES = \ - -I$(top_srcdir)/depends/mimalloc/include \ - -I$(top_srcdir)/depends/mimalloc/src - -MIMALLOC_H = \ - depends/mimalloc/include/mimalloc-new-delete.h \ - depends/mimalloc/include/mimalloc-override.h \ - depends/mimalloc/include/mimalloc-stats.h \ - depends/mimalloc/include/mimalloc.h \ - depends/mimalloc/src/bitmap.h - -libmimalloc_secure_la_SOURCES = \ - $(MIMALLOC_H) \ - depends/mimalloc/src/alloc-aligned.c \ - depends/mimalloc/src/alloc-posix.c \ - depends/mimalloc/src/alloc.c \ - depends/mimalloc/src/arena-meta.c \ - depends/mimalloc/src/arena.c \ - depends/mimalloc/src/bitmap.c \ - depends/mimalloc/src/heap.c \ - depends/mimalloc/src/init.c \ - depends/mimalloc/src/libc.c \ - depends/mimalloc/src/options.c \ - depends/mimalloc/src/os.c \ - depends/mimalloc/src/page-map.c \ - depends/mimalloc/src/page.c \ - depends/mimalloc/src/random.c \ - depends/mimalloc/src/stats.c \ - depends/mimalloc/src/prim/prim.c - -libmimalloc_secure_la_CPPFLAGS = $(AM_CPPFLAGS) $(MIMALLOC_CPPFLAGS) $(MIMALLOC_INCLUDES) -libmimalloc_secure_la_CXXFLAGS = $(AM_CXXFLAGS) -libmimalloc_secure_la_CFLAGS = $(AM_CFLAGS) -libmimalloc_secure_la_LDFLAGS = $(AM_LDFLAGS) - -noinst_LTLIBRARIES += $(LIBMIMALLOC) diff --git a/src/dashbls/Makefile.relic.include b/src/dashbls/Makefile.relic.include deleted file mode 100644 index 92bd7c7e8f5b..000000000000 --- a/src/dashbls/Makefile.relic.include +++ /dev/null @@ -1,470 +0,0 @@ -# Copyright (c) 2021 The PIVX developers -# Copyright (c) 2022 The Dash Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. - -LIBRELIC = librelic.la - -RELIC_INCLUDES = \ - -I$(top_srcdir)/depends/relic/include \ - -I$(top_srcdir)/depends/relic/include/low \ - -I$(top_srcdir)/depends/relic/src/tmpl - -RELIC_H = \ - depends/relic/include/relic.h \ - depends/relic/include/relic_alloc.h \ - depends/relic/include/relic_arch.h \ - depends/relic/include/relic_bc.h \ - depends/relic/include/relic_bench.h \ - depends/relic/include/relic_bn.h \ - depends/relic/include/relic_conf.h \ - depends/relic/include/relic_core.h \ - depends/relic/include/relic_cp.h \ - depends/relic/include/relic_dv.h \ - depends/relic/include/relic_eb.h \ - depends/relic/include/relic_ec.h \ - depends/relic/include/relic_ed.h \ - depends/relic/include/relic_ep.h \ - depends/relic/include/relic_epx.h \ - depends/relic/include/relic_err.h \ - depends/relic/include/relic_fb.h \ - depends/relic/include/relic_fbx.h \ - depends/relic/include/relic_fp.h \ - depends/relic/include/relic_fpx.h \ - depends/relic/include/relic_label.h \ - depends/relic/include/relic_md.h \ - depends/relic/include/relic_mpc.h \ - depends/relic/include/relic_multi.h \ - depends/relic/include/relic_pc.h \ - depends/relic/include/relic_pp.h \ - depends/relic/include/relic_rand.h \ - depends/relic/include/relic_test.h \ - depends/relic/include/relic_types.h \ - depends/relic/include/relic_util.h \ - depends/relic/include/low/relic_bn_low.h \ - depends/relic/include/low/relic_dv_low.h \ - depends/relic/include/low/relic_fb_low.h \ - depends/relic/include/low/relic_fp_low.h \ - depends/relic/include/low/relic_fpx_low.h \ - depends/relic/src/arch/lzcnt.inc \ - depends/relic/src/tmpl/relic_tmpl_map.h - -RELIC_SOURCES = \ - depends/relic/src/relic_err.c \ - depends/relic/src/relic_core.c \ - depends/relic/src/relic_conf.c \ - depends/relic/src/relic_util.c - -BN_SOURCES = \ - depends/relic/src/bn/relic_bn_add.c \ - depends/relic/src/bn/relic_bn_cmp.c \ - depends/relic/src/bn/relic_bn_div.c \ - depends/relic/src/bn/relic_bn_factor.c \ - depends/relic/src/bn/relic_bn_gcd.c \ - depends/relic/src/bn/relic_bn_inv.c \ - depends/relic/src/bn/relic_bn_lcm.c \ - depends/relic/src/bn/relic_bn_mem.c \ - depends/relic/src/bn/relic_bn_mod.c \ - depends/relic/src/bn/relic_bn_mul.c \ - depends/relic/src/bn/relic_bn_mxp.c \ - depends/relic/src/bn/relic_bn_prime.c \ - depends/relic/src/bn/relic_bn_rec.c \ - depends/relic/src/bn/relic_bn_shift.c \ - depends/relic/src/bn/relic_bn_smb.c \ - depends/relic/src/bn/relic_bn_sqr.c \ - depends/relic/src/bn/relic_bn_srt.c \ - depends/relic/src/bn/relic_bn_util.c - -FP_SOURCES = \ - depends/relic/src/fp/relic_fp_add.c \ - depends/relic/src/fp/relic_fp_cmp.c \ - depends/relic/src/fp/relic_fp_exp.c \ - depends/relic/src/fp/relic_fp_inv.c \ - depends/relic/src/fp/relic_fp_mul.c \ - depends/relic/src/fp/relic_fp_param.c \ - depends/relic/src/fp/relic_fp_prime.c \ - depends/relic/src/fp/relic_fp_rdc.c \ - depends/relic/src/fp/relic_fp_shift.c \ - depends/relic/src/fp/relic_fp_sqr.c \ - depends/relic/src/fp/relic_fp_srt.c \ - depends/relic/src/fp/relic_fp_util.c - -FPX_SOURCES = \ - depends/relic/src/fpx/relic_fp2_mul.c \ - depends/relic/src/fpx/relic_fp2_sqr.c \ - depends/relic/src/fpx/relic_fp3_mul.c \ - depends/relic/src/fpx/relic_fp3_sqr.c \ - depends/relic/src/fpx/relic_fp4_mul.c \ - depends/relic/src/fpx/relic_fp4_sqr.c \ - depends/relic/src/fpx/relic_fp6_mul.c \ - depends/relic/src/fpx/relic_fp6_sqr.c \ - depends/relic/src/fpx/relic_fp8_mul.c \ - depends/relic/src/fpx/relic_fp8_sqr.c \ - depends/relic/src/fpx/relic_fp9_mul.c \ - depends/relic/src/fpx/relic_fp9_sqr.c \ - depends/relic/src/fpx/relic_fp12_mul.c \ - depends/relic/src/fpx/relic_fp12_sqr.c \ - depends/relic/src/fpx/relic_fp18_mul.c \ - depends/relic/src/fpx/relic_fp18_sqr.c \ - depends/relic/src/fpx/relic_fp24_mul.c \ - depends/relic/src/fpx/relic_fp24_sqr.c \ - depends/relic/src/fpx/relic_fp48_mul.c \ - depends/relic/src/fpx/relic_fp48_sqr.c \ - depends/relic/src/fpx/relic_fp54_mul.c \ - depends/relic/src/fpx/relic_fp54_sqr.c \ - depends/relic/src/fpx/relic_fpx_add.c \ - depends/relic/src/fpx/relic_fpx_cmp.c \ - depends/relic/src/fpx/relic_fpx_cyc.c \ - depends/relic/src/fpx/relic_fpx_exp.c \ - depends/relic/src/fpx/relic_fpx_field.c \ - depends/relic/src/fpx/relic_fpx_frb.c \ - depends/relic/src/fpx/relic_fpx_inv.c \ - depends/relic/src/fpx/relic_fpx_pck.c \ - depends/relic/src/fpx/relic_fpx_rdc.c \ - depends/relic/src/fpx/relic_fpx_srt.c \ - depends/relic/src/fpx/relic_fpx_util.c - -FB_SOURCES = \ - depends/relic/src/fb/relic_fb_add.c \ - depends/relic/src/fb/relic_fb_cmp.c \ - depends/relic/src/fb/relic_fb_exp.c \ - depends/relic/src/fb/relic_fb_inv.c \ - depends/relic/src/fb/relic_fb_itr.c \ - depends/relic/src/fb/relic_fb_mul.c \ - depends/relic/src/fb/relic_fb_param.c \ - depends/relic/src/fb/relic_fb_poly.c \ - depends/relic/src/fb/relic_fb_rdc.c \ - depends/relic/src/fb/relic_fb_shift.c \ - depends/relic/src/fb/relic_fb_slv.c \ - depends/relic/src/fb/relic_fb_sqr.c \ - depends/relic/src/fb/relic_fb_srt.c \ - depends/relic/src/fb/relic_fb_trc.c \ - depends/relic/src/fb/relic_fb_util.c - -EP_SOURCES = \ - depends/relic/src/ep/relic_ep_add.c \ - depends/relic/src/ep/relic_ep_cmp.c \ - depends/relic/src/ep/relic_ep_curve.c \ - depends/relic/src/ep/relic_ep_dbl.c \ - depends/relic/src/ep/relic_ep_map.c \ - depends/relic/src/ep/relic_ep_mul.c \ - depends/relic/src/ep/relic_ep_mul_fix.c \ - depends/relic/src/ep/relic_ep_mul_sim.c \ - depends/relic/src/ep/relic_ep_neg.c \ - depends/relic/src/ep/relic_ep_norm.c \ - depends/relic/src/ep/relic_ep_param.c \ - depends/relic/src/ep/relic_ep_pck.c \ - depends/relic/src/ep/relic_ep_psi.c \ - depends/relic/src/ep/relic_ep_util.c - -EPX_SOURCES = \ - depends/relic/src/epx/relic_ep2_add.c \ - depends/relic/src/epx/relic_ep2_cmp.c \ - depends/relic/src/epx/relic_ep2_curve.c \ - depends/relic/src/epx/relic_ep2_dbl.c \ - depends/relic/src/epx/relic_ep2_frb.c \ - depends/relic/src/epx/relic_ep2_map.c \ - depends/relic/src/epx/relic_ep2_mul.c \ - depends/relic/src/epx/relic_ep2_mul_cof.c \ - depends/relic/src/epx/relic_ep2_mul_fix.c \ - depends/relic/src/epx/relic_ep2_mul_sim.c \ - depends/relic/src/epx/relic_ep2_neg.c \ - depends/relic/src/epx/relic_ep2_norm.c \ - depends/relic/src/epx/relic_ep2_pck.c \ - depends/relic/src/epx/relic_ep2_util.c \ - depends/relic/src/epx/relic_ep4_add.c \ - depends/relic/src/epx/relic_ep4_cmp.c \ - depends/relic/src/epx/relic_ep4_curve.c \ - depends/relic/src/epx/relic_ep4_dbl.c \ - depends/relic/src/epx/relic_ep4_frb.c \ - depends/relic/src/epx/relic_ep4_map.c \ - depends/relic/src/epx/relic_ep4_mul.c \ - depends/relic/src/epx/relic_ep4_mul_cof.c \ - depends/relic/src/epx/relic_ep4_mul_fix.c \ - depends/relic/src/epx/relic_ep4_mul_sim.c \ - depends/relic/src/epx/relic_ep4_neg.c \ - depends/relic/src/epx/relic_ep4_norm.c \ - depends/relic/src/epx/relic_ep4_util.c - -EB_SOURCES = \ - depends/relic/src/eb/relic_eb_add.c \ - depends/relic/src/eb/relic_eb_cmp.c \ - depends/relic/src/eb/relic_eb_curve.c \ - depends/relic/src/eb/relic_eb_dbl.c \ - depends/relic/src/eb/relic_eb_frb.c \ - depends/relic/src/eb/relic_eb_hlv.c \ - depends/relic/src/eb/relic_eb_map.c \ - depends/relic/src/eb/relic_eb_mul.c \ - depends/relic/src/eb/relic_eb_mul_fix.c \ - depends/relic/src/eb/relic_eb_mul_sim.c \ - depends/relic/src/eb/relic_eb_neg.c \ - depends/relic/src/eb/relic_eb_norm.c \ - depends/relic/src/eb/relic_eb_param.c \ - depends/relic/src/eb/relic_eb_pck.c \ - depends/relic/src/eb/relic_eb_util.c - -ED_SOURCES = \ - depends/relic/src/ed/relic_ed_add.c \ - depends/relic/src/ed/relic_ed_cmp.c \ - depends/relic/src/ed/relic_ed_curve.c \ - depends/relic/src/ed/relic_ed_dbl.c \ - depends/relic/src/ed/relic_ed_map.c \ - depends/relic/src/ed/relic_ed_mul.c \ - depends/relic/src/ed/relic_ed_mul_fix.c \ - depends/relic/src/ed/relic_ed_mul_sim.c \ - depends/relic/src/ed/relic_ed_neg.c \ - depends/relic/src/ed/relic_ed_norm.c \ - depends/relic/src/ed/relic_ed_param.c \ - depends/relic/src/ed/relic_ed_pck.c \ - depends/relic/src/ed/relic_ed_util.c - -PP_SOURCES = \ - depends/relic/src/pp/relic_pp_add_k2.c \ - depends/relic/src/pp/relic_pp_add_k8.c \ - depends/relic/src/pp/relic_pp_add_k12.c \ - depends/relic/src/pp/relic_pp_add_k24.c \ - depends/relic/src/pp/relic_pp_add_k48.c \ - depends/relic/src/pp/relic_pp_add_k54.c \ - depends/relic/src/pp/relic_pp_dbl_k2.c \ - depends/relic/src/pp/relic_pp_dbl_k8.c \ - depends/relic/src/pp/relic_pp_dbl_k12.c \ - depends/relic/src/pp/relic_pp_dbl_k24.c \ - depends/relic/src/pp/relic_pp_dbl_k48.c \ - depends/relic/src/pp/relic_pp_dbl_k54.c \ - depends/relic/src/pp/relic_pp_exp_k2.c \ - depends/relic/src/pp/relic_pp_exp_k8.c \ - depends/relic/src/pp/relic_pp_exp_k12.c \ - depends/relic/src/pp/relic_pp_exp_k24.c \ - depends/relic/src/pp/relic_pp_exp_k48.c \ - depends/relic/src/pp/relic_pp_exp_k54.c \ - depends/relic/src/pp/relic_pp_map.c \ - depends/relic/src/pp/relic_pp_map_k2.c \ - depends/relic/src/pp/relic_pp_map_k8.c \ - depends/relic/src/pp/relic_pp_map_k12.c \ - depends/relic/src/pp/relic_pp_map_k24.c \ - depends/relic/src/pp/relic_pp_map_k48.c \ - depends/relic/src/pp/relic_pp_map_k54.c \ - depends/relic/src/pp/relic_pp_norm.c - -PC_SOURCES = \ - depends/relic/src/pc/relic_pc_core.c \ - depends/relic/src/pc/relic_pc_exp.c \ - depends/relic/src/pc/relic_pc_util.c - -MD_SOURCES = \ - depends/relic/src/md/blake2.h \ - depends/relic/src/md/blake2-impl.h \ - depends/relic/src/md/blake2s-ref.c \ - depends/relic/src/md/relic_md_blake2s.c \ - depends/relic/src/md/relic_md_hmac.c \ - depends/relic/src/md/relic_md_kdf.c \ - depends/relic/src/md/relic_md_mgf.c \ - depends/relic/src/md/relic_md_sha224.c \ - depends/relic/src/md/relic_md_sha256.c \ - depends/relic/src/md/relic_md_sha384.c \ - depends/relic/src/md/relic_md_sha512.c \ - depends/relic/src/md/relic_md_xmd.c \ - depends/relic/src/md/sha.h \ - depends/relic/src/md/sha224-256.c \ - depends/relic/src/md/sha384-512.c \ - depends/relic/src/md/sha_private.h - -EXTRA_DIST += \ - depends/relic/src/arch/relic_arch_arm.c \ - depends/relic/src/arch/relic_arch_none.c \ - depends/relic/src/arch/relic_arch_x64.c \ - depends/relic/src/arch/relic_arch_x86.c - -RELIC_SOURCES += \ - depends/relic/src/arch/relic_arch_@CPU_ARCH@.c \ - depends/relic/src/rand/relic_rand_call.c \ - depends/relic/src/rand/relic_rand_core.c \ - depends/relic/src/rand/relic_rand_hashd.c \ - depends/relic/src/rand/relic_rand_udev.c - -if WITH_DV -RELIC_SOURCES += \ - depends/relic/src/dv/relic_dv_mem.c \ - depends/relic/src/dv/relic_dv_util.c -endif - -if ARITH_EASY -if WITH_BN -RELIC_SOURCES += $(BN_SOURCES) \ - depends/relic/src/low/easy/relic_bn_add_low.c \ - depends/relic/src/low/easy/relic_bn_div_low.c \ - depends/relic/src/low/easy/relic_bn_mod_low.c \ - depends/relic/src/low/easy/relic_bn_mul_low.c \ - depends/relic/src/low/easy/relic_bn_shift_low.c \ - depends/relic/src/low/easy/relic_bn_sqr_low.c -endif - -if WITH_FP -RELIC_SOURCES += $(FP_SOURCES) \ - depends/relic/src/low/easy/relic_fp_add_low.c \ - depends/relic/src/low/easy/relic_fp_inv_low.c \ - depends/relic/src/low/easy/relic_fp_mul_low.c \ - depends/relic/src/low/easy/relic_fp_rdc_low.c \ - depends/relic/src/low/easy/relic_fp_shift_low.c \ - depends/relic/src/low/easy/relic_fp_sqr_low.c -endif - -if WITH_FPX -RELIC_SOURCES += $(FPX_SOURCES) \ - depends/relic/src/low/easy/relic_fpx_add_low.c \ - depends/relic/src/low/easy/relic_fpx_mul_low.c \ - depends/relic/src/low/easy/relic_fpx_rdc_low.c \ - depends/relic/src/low/easy/relic_fpx_sqr_low.c -endif - -if WITH_FB -RELIC_SOURCES += $(FB_SOURCES) \ - depends/relic/src/low/easy/relic_fb_add_low.c \ - depends/relic/src/low/easy/relic_fb_inv_low.c \ - depends/relic/src/low/easy/relic_fb_itr_low.c \ - depends/relic/src/low/easy/relic_fb_mul_low.c \ - depends/relic/src/low/easy/relic_fb_rdc_low.c \ - depends/relic/src/low/easy/relic_fb_shift_low.c \ - depends/relic/src/low/easy/relic_fb_slv_low.c \ - depends/relic/src/low/easy/relic_fb_sqr_low.c \ - depends/relic/src/low/easy/relic_fb_srt_low.c \ - depends/relic/src/low/easy/relic_fb_trc_low.c -endif -endif - -if ARITH_GMP -if WITH_BN -RELIC_SOURCES += $(BN_SOURCES) \ - depends/relic/src/low/gmp/relic_bn_add_low.c \ - depends/relic/src/low/gmp/relic_bn_div_low.c \ - depends/relic/src/low/gmp/relic_bn_mod_low.c \ - depends/relic/src/low/gmp/relic_bn_mul_low.c \ - depends/relic/src/low/gmp/relic_bn_shift_low.c \ - depends/relic/src/low/gmp/relic_bn_sqr_low.c -endif - -if WITH_FP -RELIC_SOURCES += $(FP_SOURCES) \ - depends/relic/src/low/gmp/relic_fp_add_low.c \ - depends/relic/src/low/gmp/relic_fp_inv_low.c \ - depends/relic/src/low/gmp/relic_fp_mul_low.c \ - depends/relic/src/low/gmp/relic_fp_rdc_low.c \ - depends/relic/src/low/gmp/relic_fp_shift_low.c \ - depends/relic/src/low/gmp/relic_fp_sqr_low.c -endif - -if WITH_FPX -RELIC_SOURCES += $(FPX_SOURCES) \ - depends/relic/src/low/easy/relic_fpx_add_low.c \ - depends/relic/src/low/easy/relic_fpx_mul_low.c \ - depends/relic/src/low/easy/relic_fpx_rdc_low.c \ - depends/relic/src/low/easy/relic_fpx_sqr_low.c -endif - -if WITH_FB -RELIC_SOURCES += $(FB_SOURCES) \ - depends/relic/src/low/gmp/relic_fb_add_low.c \ - depends/relic/src/low/easy/relic_fb_inv_low.c \ - depends/relic/src/low/easy/relic_fb_itr_low.c \ - depends/relic/src/low/easy/relic_fb_mul_low.c \ - depends/relic/src/low/easy/relic_fb_rdc_low.c \ - depends/relic/src/low/gmp/relic_fb_shift_low.c \ - depends/relic/src/low/easy/relic_fb_slv_low.c \ - depends/relic/src/low/easy/relic_fb_sqr_low.c \ - depends/relic/src/low/easy/relic_fb_srt_low.c \ - depends/relic/src/low/easy/relic_fb_trc_low.c -endif -endif - -if WITH_FBX -RELIC_SOURCES += \ - depends/relic/src/fbx/relic_fb2_inv.c \ - depends/relic/src/fbx/relic_fb2_mul.c \ - depends/relic/src/fbx/relic_fb2_slv.c \ - depends/relic/src/fbx/relic_fb2_sqr.c -endif - -if WITH_EP -RELIC_SOURCES += $(EP_SOURCES) -endif - -if WITH_EPX -RELIC_SOURCES += $(EPX_SOURCES) -endif - -if WITH_EB -RELIC_SOURCES += $(EB_SOURCES) -endif - -if WITH_ED -RELIC_SOURCES += $(ED_SOURCES) -endif - -if WITH_PP -RELIC_SOURCES += $(PP_SOURCES) -endif - -if WITH_PC -RELIC_SOURCES += $(PC_SOURCES) -endif - -if WITH_CP -RELIC_SOURCES += \ - depends/relic/src/cp/relic_cp_bbs.c \ - depends/relic/src/cp/relic_cp_bdpe.c \ - depends/relic/src/cp/relic_cp_bgn.c \ - depends/relic/src/cp/relic_cp_bls.c \ - depends/relic/src/cp/relic_cp_cls.c \ - depends/relic/src/cp/relic_cp_cmlhs.c \ - depends/relic/src/cp/relic_cp_ecdh.c \ - depends/relic/src/cp/relic_cp_ecdsa.c \ - depends/relic/src/cp/relic_cp_ecies.c \ - depends/relic/src/cp/relic_cp_ecmqv.c \ - depends/relic/src/cp/relic_cp_ecss.c \ - depends/relic/src/cp/relic_cp_ers.c \ - depends/relic/src/cp/relic_cp_etrs.c \ - depends/relic/src/cp/relic_cp_ghpe.c \ - depends/relic/src/cp/relic_cp_ibe.c \ - depends/relic/src/cp/relic_cp_mklhs.c \ - depends/relic/src/cp/relic_cp_mpss.c \ - depends/relic/src/cp/relic_cp_pcdel.c \ - depends/relic/src/cp/relic_cp_phpe.c \ - depends/relic/src/cp/relic_cp_pok.c \ - depends/relic/src/cp/relic_cp_pss.c \ - depends/relic/src/cp/relic_cp_rabin.c \ - depends/relic/src/cp/relic_cp_rsa.c \ - depends/relic/src/cp/relic_cp_sok.c \ - depends/relic/src/cp/relic_cp_sokaka.c \ - depends/relic/src/cp/relic_cp_vbnn.c \ - depends/relic/src/cp/relic_cp_zss.c -endif - -if WITH_BC -RELIC_SOURCES += \ - depends/relic/src/bc/relic_bc_aes.c \ - depends/relic/src/bc/rijndael-alg-fst.c \ - depends/relic/src/bc/rijndael-alg-fst.h \ - depends/relic/src/bc/rijndael-api-fst.c \ - depends/relic/src/bc/rijndael-api-fst.h -endif - -if WITH_MD -RELIC_SOURCES += $(MD_SOURCES) -endif - -if WITH_MPC -RELIC_SOURCES += \ - depends/relic/src/mpc/relic_mt_mpc.c \ - depends/relic/src/mpc/relic_pc_mpc.c -endif - -librelic_la_SOURCES = \ - $(RELIC_SOURCES) \ - $(RELIC_H) - -librelic_la_CPPFLAGS = $(AM_CPPFLAGS) $(RELIC_CPPFLAGS) $(RELIC_INCLUDES) -librelic_la_CXXFLAGS = $(AM_CXXFLAGS) -librelic_la_CFLAGS = $(AM_CFLAGS) -librelic_la_LDFLAGS = $(AM_LDFLAGS) - -noinst_LTLIBRARIES += $(LIBRELIC) diff --git a/src/dashbls/Makefile.test.include b/src/dashbls/Makefile.test.include deleted file mode 100644 index a8ec86cb59d1..000000000000 --- a/src/dashbls/Makefile.test.include +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2021 The PIVX developers -# Copyright (c) 2022 The Dash Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING.MIT or http://www.opensource.org/licenses/mit-license.php. - -DASHBLS_RUNTEST = runtest - -RUNTEST_INCLUDES = \ - -I$(top_srcdir)/depends/catch2/include - -RUNTEST_H = \ - depends/catch2/include/catch2/catch.hpp - -runtest_SOURCES = \ - $(DASHBLS_H) \ - $(RELIC_H) \ - $(RUNTEST_H) \ - src/test.cpp \ - src/test-utils.hpp - -runtest_CPPFLAGS = $(AM_CPPFLAGS) $(DASHBLS_INCLUDES) $(RELIC_INCLUDES) $(RUNTEST_INCLUDES) -runtest_CXXFLAGS = $(AM_CXXFLAGS) -runtest_LDFLAGS = -static $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) - -runtest_LDADD = $(LIBDASHBLS) - -noinst_PROGRAMS += $(DASHBLS_RUNTEST) diff --git a/src/dashbls/README.md b/src/dashbls/README.md deleted file mode 100644 index 8460ac818ea7..000000000000 --- a/src/dashbls/README.md +++ /dev/null @@ -1,299 +0,0 @@ -# BLS Signatures implementation - -[![Build and Test C++, Javascript, and Python](https://github.com/Chia-Network/bls-signatures/actions/workflows/build-test.yaml/badge.svg)](https://github.com/Chia-Network/bls-signatures/actions/workflows/build-test.yaml) -![PyPI](https://img.shields.io/pypi/v/blspy?logo=pypi) -![PyPI - Format](https://img.shields.io/pypi/format/blspy?logo=pypi) -![GitHub](https://img.shields.io/github/license/Chia-Network/bls-signatures?logo=Github) - -[![Total alerts](https://img.shields.io/lgtm/alerts/g/Chia-Network/bls-signatures.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Chia-Network/bls-signatures/alerts/) -[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Chia-Network/bls-signatures.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Chia-Network/bls-signatures/context:javascript) -[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/Chia-Network/bls-signatures.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Chia-Network/bls-signatures/context:python) -[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/Chia-Network/bls-signatures.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Chia-Network/bls-signatures/context:cpp) - -NOTE: THIS LIBRARY IS NOT YET FORMALLY REVIEWED FOR SECURITY - -NOTE: THIS LIBRARY WAS SHIFTED TO THE IETF BLS SPECIFICATION ON 7/16/20 - -Implements BLS signatures with aggregation using [relic toolkit](https://github.com/relic-toolkit/relic) -for cryptographic primitives (pairings, EC, hashing) according to the -[IETF BLS RFC](https://datatracker.ietf.org/doc/draft-irtf-cfrg-bls-signature/) -with [these curve parameters](https://datatracker.ietf.org/doc/draft-irtf-cfrg-pairing-friendly-curves/) -for BLS12-381. - -Features: - -* Non-interactive signature aggregation following IETF specification -* Works on Windows, Mac, Linux, BSD -* Efficient verification using Proof of Posssesion (only one pairing per distinct message) -* Aggregate public keys and private keys -* [EIP-2333](https://eips.ethereum.org/EIPS/eip-2333) key derivation (including unhardened BIP-32-like keys) -* Key and signature serialization -* Batch verification -* [Python bindings](https://github.com/Chia-Network/bls-signatures/tree/main/python-bindings) -* [Pure python bls12-381 and signatures](https://github.com/Chia-Network/bls-signatures/tree/main/python-impl) -* [JavaScript bindings](https://github.com/Chia-Network/bls-signatures/tree/main/js-bindings) - -## Before you start - -This library uses minimum public key sizes (MPL). A G2Element is a signature (96 bytes), and a G1Element is a public key (48 bytes). A private key is a 32 byte integer. There are three schemes: Basic, Augmented, and ProofOfPossession. Augmented should be enough for most use cases, and ProofOfPossession can be used where verification must be fast. - -## Import the library - -```c++ -#include "bls.hpp" -using namespace bls; -``` - -## Creating keys and signatures - -```c++ -// Example seed, used to generate private key. Always use -// a secure RNG with sufficient entropy to generate a seed (at least 32 bytes). -vector seed = {0, 50, 6, 244, 24, 199, 1, 25, 52, 88, 192, - 19, 18, 12, 89, 6, 220, 18, 102, 58, 209, 82, - 12, 62, 89, 110, 182, 9, 44, 20, 254, 22}; - -PrivateKey sk = AugSchemeMPL().KeyGen(seed); -G1Element pk = sk.GetG1Element(); - -vector message = {1, 2, 3, 4, 5}; // Message is passed in as a byte vector -G2Element signature = AugSchemeMPL().Sign(sk, message); - -// Verify the signature -bool ok = AugSchemeMPL().Verify(pk, message, signature); -``` - -## Serializing keys and signatures to bytes - -```c++ -vector skBytes = sk.Serialize(); -vector pkBytes = pk.Serialize(); -vector signatureBytes = signature.Serialize(); - -cout << Util::HexStr(skBytes) << endl; // 32 bytes printed in hex -cout << Util::HexStr(pkBytes) << endl; // 48 bytes printed in hex -cout << Util::HexStr(signatureBytes) << endl; // 96 bytes printed in hex -``` - -## Loading keys and signatures from bytes - -```c++ -// Takes vector of 32 bytes -PrivateKey skc = PrivateKey::FromByteVector(skBytes); - -// Takes vector of 48 bytes -pk = G1Element::FromByteVector(pkBytes); - -// Takes vector of 96 bytes -signature = G2Element::FromByteVector(signatureBytes); -``` - -## Create aggregate signatures - -```c++ -// Generate some more private keys -seed[0] = 1; -PrivateKey sk1 = AugSchemeMPL().KeyGen(seed); -seed[0] = 2; -PrivateKey sk2 = AugSchemeMPL().KeyGen(seed); -vector message2 = {1, 2, 3, 4, 5, 6, 7}; - -// Generate first sig -G1Element pk1 = sk1.GetG1Element(); -G2Element sig1 = AugSchemeMPL().Sign(sk1, message); - -// Generate second sig -G1Element pk2 = sk2.GetG1Element(); -G2Element sig2 = AugSchemeMPL().Sign(sk2, message2); - -// Signatures can be non-interactively combined by anyone -G2Element aggSig = AugSchemeMPL().Aggregate({sig1, sig2}); - -ok = AugSchemeMPL().AggregateVerify({pk1, pk2}, {message, message2}, aggSig); -``` - -## Arbitrary trees of aggregates - -```c++ -seed[0] = 3; -PrivateKey sk3 = AugSchemeMPL().KeyGen(seed); -G1Element pk3 = sk3.GetG1Element(); -vector message3 = {100, 2, 254, 88, 90, 45, 23}; -G2Element sig3 = AugSchemeMPL().Sign(sk3, message3); - - -G2Element aggSigFinal = AugSchemeMPL().Aggregate({aggSig, sig3}); -ok = AugSchemeMPL().AggregateVerify({pk1, pk2, pk3}, {message, message2, message3}, aggSigFinal); - -``` - -## Very fast verification with Proof of Possession scheme - -```c++ -// If the same message is signed, you can use Proof of Posession (PopScheme) for efficiency -// A proof of possession MUST be passed around with the PK to ensure security. - -G2Element popSig1 = PopSchemeMPL().Sign(sk1, message); -G2Element popSig2 = PopSchemeMPL().Sign(sk2, message); -G2Element popSig3 = PopSchemeMPL().Sign(sk3, message); -G2Element pop1 = PopSchemeMPL().PopProve(sk1); -G2Element pop2 = PopSchemeMPL().PopProve(sk2); -G2Element pop3 = PopSchemeMPL().PopProve(sk3); - -ok = PopSchemeMPL().PopVerify(pk1, pop1); -ok = PopSchemeMPL().PopVerify(pk2, pop2); -ok = PopSchemeMPL().PopVerify(pk3, pop3); -G2Element popSigAgg = PopSchemeMPL().Aggregate({popSig1, popSig2, popSig3}); - -ok = PopSchemeMPL().FastAggregateVerify({pk1, pk2, pk3}, message, popSigAgg); - -// Aggregate public key, indistinguishable from a single public key -G1Element popAggPk = pk1 + pk2 + pk3; -ok = PopSchemeMPL().Verify(popAggPk, message, popSigAgg); - -// Aggregate private keys -PrivateKey aggSk = PrivateKey::Aggregate({sk1, sk2, sk3}); -ok = (PopSchemeMPL().Sign(aggSk, message) == popSigAgg); -``` - -## HD keys using [EIP-2333](https://github.com/ethereum/EIPs/pull/2333) - -```c++ -// You can derive 'child' keys from any key, to create arbitrary trees. 4 byte indeces are used. -// Hardened (more secure, but no parent pk -> child pk) -PrivateKey masterSk = AugSchemeMPL().KeyGen(seed); -PrivateKey child = AugSchemeMPL().DeriveChildSk(masterSk, 152); -PrivateKey grandChild = AugSchemeMPL().DeriveChildSk(child, 952) - -// Unhardened (less secure, but can go from parent pk -> child pk), BIP32 style -G1Element masterPk = masterSk.GetG1Element(); -PrivateKey childU = AugSchemeMPL().DeriveChildSkUnhardened(masterSk, 22); -PrivateKey grandchildU = AugSchemeMPL().DeriveChildSkUnhardened(childU, 0); - -G1Element childUPk = AugSchemeMPL().DeriveChildPkUnhardened(masterPk, 22); -G1Element grandchildUPk = AugSchemeMPL().DeriveChildPkUnhardened(childUPk, 0); - -ok = (grandchildUPk == grandchildU.GetG1Element(); -``` - -## Build - -Cmake 3.14+, a c++ compiler, and python3 (for bindings) are required for building. - -```bash -mkdir build -cd build -cmake ../ -cmake --build . -- -j 6 -``` - -### Run tests - -```bash -./build/src/runtest -``` - -### Run benchmarks - -```bash -./build/src/runbench -``` - -On a 3.5 GHz i7 Mac, verification takes about 1.1ms per signature, and signing takes 1.3ms. - -### Link the library to use it - -```bash -g++ -Wl,-no_pie -std=c++11 -Ibls-signatures/depends/relic/include -Ibls-signatures/build/depends/relic/include -Ibls-signatures/src -L./bls-signatures/build/ -l bls yourapp.cpp -``` - -## Notes on dependencies - -We use Libsodium and have GMP as an optional dependency: libsodium gives secure memory -allocation, and GMP speeds up the library by ~ 3x. MPIR is used on Windows via -GitHub Actions instead. To install them, either download them from github and -follow the instructions for each repo, or use a package manager like APT or -brew. You can follow the recipe used to build python wheels for multiple -platforms in `.github/workflows/`. - -## Discussion - -Discussion about this library and other Chia related development is in the #dev -channel of Chia's [public Keybase channels](https://keybase.io/team/chia_network.public). - -## Code style - -* Always use vector for bytes -* Use size_t for size variables -* Uppercase method names -* Prefer static constructors -* Avoid using templates -* Objects allocate and free their own memory -* Use cpplint with default rules -* Use SecAlloc and SecFree when handling secrets - -## ci Building - -The primary build process for this repository is to use GitHub Actions to -build binary wheels for MacOS, Linux (x64 and aarch64), and Windows and publish -them with a source wheel on PyPi. MacOS ARM64 is supported but not automated -due to a lack of M1 CI runners. See `.github/workflows/build.yml`. CMake uses -[FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) -to download [pybind11](https://github.com/pybind/pybind11) for the Python -bindings and relic from a chia relic forked repository for Windows. Building -is then managed by [cibuildwheel](https://github.com/joerick/cibuildwheel). -Further installation is then available via `pip install blspy` e.g. The ci -builds include GMP and a statically linked libsodium. - -## Contributing and workflow - -Contributions are welcome and more details are available in chia-blockchain's -[CONTRIBUTING.md](https://github.com/Chia-Network/chia-blockchain/blob/main/CONTRIBUTING.md). - -The main branch is usually the currently released latest version on PyPI. -Note that at times bls-signatures/blspy will be ahead of the release version -that chia-blockchain requires in it's main/release version in preparation -for a new chia-blockchain release. Please branch or fork main and then create -a pull request to the main branch. Linear merging is enforced on main and -merging requires a completed review. PRs will kick off a GitHub actions ci -build and analysis of bls-signatures at -[lgtm.com](https://lgtm.com/projects/g/Chia-Network/bls-signatures/?mode=list). -Please make sure your build is passing and that it does not increase alerts -at lgtm. - -## Specification and test vectors - -The [IETF bls draft](https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/) -is followed. Test vectors can also be seen in the python and cpp test files. - -## Libsodium license - -The libsodium static library is licensed under the ISC license which requires -the following copyright notice. - ->ISC License -> ->Copyright (c) 2013-2020 ->Frank Denis \ -> ->Permission to use, copy, modify, and/or distribute this software for any ->purpose with or without fee is hereby granted, provided that the above ->copyright notice and this permission notice appear in all copies. -> ->THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ->WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ->MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ->ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ->WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ->ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ->OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -## GMP license - -GMP is distributed under the -[GNU LGPL v3 license](https://www.gnu.org/licenses/lgpl-3.0.html) - -## Relic license - -Relic is used with the -[Apache 2.0 license](https://github.com/relic-toolkit/relic/blob/master/LICENSE.Apache-2.0) diff --git a/src/dashbls/apple.rust.deps.sh b/src/dashbls/apple.rust.deps.sh deleted file mode 100755 index b2ebc41a4ff2..000000000000 --- a/src/dashbls/apple.rust.deps.sh +++ /dev/null @@ -1,374 +0,0 @@ -#!/bin/sh -set -x -set -e -# "x86_64-apple-ios" -# "aarch64-apple-ios" -# "aarch64-apple-ios-sim" -# "x86_64-apple-darwin" -# "aarch64-apple-darwin" -# TODO: it's probably needs to be optimized in order to increase better build velocity -# TODO: so we need to combine multiple targets -TARGET=$1 -git submodule update --init -MIN_IOS="13.0" -MIN_WATCHOS="5.0" -MIN_TVOS=$MIN_IOS -MIN_MACOS="10.15" - -IPHONEOS=iphoneos -IPHONESIMULATOR=iphonesimulator -WATCHOS=watchos -WATCHSIMULATOR=watchsimulator -TVOS=appletvos -TVSIMULATOR=appletvsimulator -MACOS=macosx - -LOGICALCPU_MAX=$(sysctl -n hw.logicalcpu_max) -BUILD=build - -version_min_flag() { - PLATFORM=$1 - FLAG="" - # shellcheck disable=SC2039 - # shellcheck disable=SC2053 - if [[ $PLATFORM = $IPHONEOS ]]; then - FLAG="-miphoneos-version-min=${MIN_IOS}" - elif [[ $PLATFORM = $IPHONESIMULATOR ]]; then - FLAG="-mios-simulator-version-min=${MIN_IOS}" - elif [[ $PLATFORM = $WATCHOS ]]; then - FLAG="-mwatchos-version-min=${MIN_WATCHOS}" - elif [[ $PLATFORM = $WATCHSIMULATOR ]]; then - FLAG="-mwatchos-simulator-version-min=${MIN_WATCHOS}" - elif [[ $PLATFORM = $TVOS ]]; then - FLAG="-mtvos-version-min=${MIN_TVOS}" - elif [[ $PLATFORM = $TVSIMULATOR ]]; then - FLAG="-mtvos-simulator-version-min=${MIN_TVOS}" - elif [[ $PLATFORM = $MACOS ]]; then - FLAG="-mmacosx-version-min=${MIN_MACOS}" - fi - echo $FLAG -} - - -prepare() { - download_gmp() { - GMP_VERSION="6.3.0" - CURRENT_DIR=$(pwd) - echo "$CURRENT_DIR" - # shellcheck disable=SC2039,SC2164 - pushd ${BUILD} - mkdir -p "contrib" - if [ ! -s "contrib/gmp-${GMP_VERSION}.tar.bz2" ]; then - curl -L -o "contrib/gmp-${GMP_VERSION}.tar.bz2" https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.bz2 - fi - rm -rf "contrib/gmp" - # shellcheck disable=SC2039,SC2164 - pushd contrib - tar xfj "gmp-${GMP_VERSION}.tar.bz2" - mv gmp-${GMP_VERSION} gmp - # shellcheck disable=SC2039,SC2164 - popd #contrib - # shellcheck disable=SC2039,SC2164 - popd #build - } - - download_cmake_toolchain() { - if [ ! -s "${BUILD}/ios.toolchain.cmake" ]; then - SHA256_HASH="d02857ff6bd64f1d7109ca59c3e4f3b2f89d0663c412146e6977c679801b3243" - curl -o "${BUILD}/ios.toolchain.cmake" https://raw.githubusercontent.com/leetal/ios-cmake/c55677a4445b138c9ef2650d3c21f22cc78c2357/ios.toolchain.cmake - DOWNLOADED_HASH=$(shasum -a 256 ${BUILD}/ios.toolchain.cmake | cut -f 1 -d " ") - if [ $SHA256_HASH != "$DOWNLOADED_HASH" ]; then - echo "Error: sha256 checksum of ios.toolchain.cmake mismatch" >&2 - exit 1 - fi - fi - } - - download_relic() { - CURRENT_DIR=$(pwd) - echo "$CURRENT_DIR" - mkdir -p "${CURRENT_DIR}/${BUILD}/depends" - if [ ! -s "${CURRENT_DIR}/${BUILD}/depends/relic" ]; then - # shellcheck disable=SC2039,SC2164 - pushd "${CURRENT_DIR}/${BUILD}/depends" - git clone --depth 1 --branch "feat/ios-support" https://github.com/pankcuf/relic - # shellcheck disable=SC2039,SC2164 - pushd relic - git fetch --depth 1 origin 19fb6d79a77ade4ae8cd70d2b0ef7aab8720d1ae - git checkout 19fb6d79a77ade4ae8cd70d2b0ef7aab8720d1ae - # shellcheck disable=SC2039,SC2164 - popd #relic - # shellcheck disable=SC2039,SC2164 - popd #depends - fi - } - rm -rf ${BUILD} - mkdir -p ${BUILD} - download_relic - download_gmp - download_cmake_toolchain -} - -build_gmp_arch() { - PLATFORM=$1 - ARCH=$2 - PFX=${PLATFORM}-${ARCH} - # why this works with this host only? - HOST=aarch64-apple-darwin - # shellcheck disable=SC2039,SC2164 - pushd ${BUILD} - SDK=$(xcrun --sdk "$PLATFORM" --show-sdk-path) - PLATFORM_PATH=$(xcrun --sdk "$PLATFORM" --show-sdk-platform-path) - CLANG=$(xcrun --sdk "$PLATFORM" --find clang) - DEVELOPER=$(xcode-select --print-path) - CURRENT_DIR=$(pwd) - export PATH="${PLATFORM_PATH}/Developer/usr/bin:${DEVELOPER}/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin" - mkdir gmplib-"${PLATFORM}"-"${ARCH}" - CFLAGS="-Wno-unused-value -fembed-bitcode -arch ${ARCH} --sysroot=${SDK} $(version_min_flag "$PLATFORM")" - CONFIGURESCRIPT="gmp_configure_script.sh" - # shellcheck disable=SC2039,SC2164 - pushd contrib - # shellcheck disable=SC2039,SC2164 - pushd gmp - make clean || true - make distclean || true - echo "HOST: $HOST" - echo "PREFIX: ${CURRENT_DIR}/gmplib-${PFX}" - - cat >"$CONFIGURESCRIPT" << EOF -#!/bin/sh -./configure \ -CC="$CLANG" CFLAGS="$CFLAGS" CPPFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" \ ---host=${HOST} --prefix="${CURRENT_DIR}/gmplib-${PFX}" \ ---disable-shared --enable-static --disable-assembly -v -EOF - - chmod a+x "$CONFIGURESCRIPT" - sh "$CONFIGURESCRIPT" - rm "$CONFIGURESCRIPT" - - # shellcheck disable=SC2039 - mkdir -p "${CURRENT_DIR}/log" - # shellcheck disable=SC2039 - make -j "$LOGICALCPU_MAX" &> "${CURRENT_DIR}"/log/gmplib-"${PFX}"-build.log - # shellcheck disable=SC2039 - make install &> "${CURRENT_DIR}"/log/gmplib-"${PFX}"-install.log - #make check - #exit 1 - # shellcheck disable=SC2039,SC2164 - popd # gmp - # shellcheck disable=SC2039,SC2164 - popd # contrib - # shellcheck disable=SC2039,SC2164 - popd # build -} - -build_relic_arch() { - PLATFORM=$1 - ARCH=$2 - PFX=${PLATFORM}-${ARCH} - - # shellcheck disable=SC2039,SC2164 - pushd ${BUILD} - - SDK=$(xcrun --sdk "$PLATFORM" --show-sdk-path) - - BUILDDIR=relic-"${PFX}" - TOOLCHAIN=$(pwd)/ios.toolchain.cmake - GMP_PFX=$(pwd)/gmplib-${PFX} - rm -rf "$BUILDDIR" - mkdir "$BUILDDIR" - # shellcheck disable=SC2039,SC2164 - pushd "$BUILDDIR" - - unset CC - # shellcheck disable=SC2155 - export CC=$(xcrun --sdk "${PLATFORM}" --find clang) - - WSIZE=0 - IOS_PLATFORM="" - OPTIMIZATIONFLAGS="" - DEPLOYMENT_TARGET="" - - # shellcheck disable=SC2039 - # shellcheck disable=SC2053 - if [[ $PLATFORM = $IPHONEOS ]]; then - if [[ $ARCH = "arm64" ]] || [[ $ARCH = "arm64e" ]]; then - IOS_PLATFORM=OS64 - DEPLOYMENT_TARGET=$MIN_IOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - else - IOS_PLATFORM=OS - WSIZE=32 - fi - elif [[ $PLATFORM = $IPHONESIMULATOR ]]; then - if [[ $ARCH = "x86_64" ]]; then - IOS_PLATFORM=SIMULATOR64 - DEPLOYMENT_TARGET=$MIN_IOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - elif [[ $ARCH = "arm64" ]]; then - IOS_PLATFORM=SIMULATORARM64 - DEPLOYMENT_TARGET=$MIN_IOS - WSIZE=64 - else - IOS_PLATFORM=SIMULATOR - WSIZE=32 - fi - elif [[ $PLATFORM = $WATCHOS ]]; then - IOS_PLATFORM=WATCHOS - DEPLOYMENT_TARGET=$MIN_WATCHOS - WSIZE=32 - elif [[ $PLATFORM = $WATCHSIMULATOR ]]; then - IOS_PLATFORM=SIMULATOR_WATCHOS - DEPLOYMENT_TARGET=$MIN_WATCHOS - WSIZE=32 - elif [[ $PLATFORM = $TVOS ]]; then - IOS_PLATFORM=TVOS - DEPLOYMENT_TARGET=$MIN_TVOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - elif [[ $PLATFORM = $TVSIMULATOR ]]; then - IOS_PLATFORM=SIMULATOR_TVOS - #TODO - if [[ $ARCH = "arm64" ]] - then - IOS_PLATFORM=OS64 - fi - DEPLOYMENT_TARGET=$MIN_TVOS - WSIZE=64 - OPTIMIZATIONFLAGS=-fomit-frame-pointer - elif [[ $PLATFORM = $MACOS ]]; then - WSIZE=64 - IOS_PLATFORM=MAC - if [[ $ARCH = "arm64" ]] - then - IOS_PLATFORM=MAC_ARM64 - fi - DEPLOYMENT_TARGET=$MIN_MACOS - OPTIMIZATIONFLAGS=-fomit-frame-pointer - fi - - COMPILER_ARGS="$(version_min_flag "$PLATFORM") -Wno-unused-functions" - - EXTRA_ARGS="-DOPSYS=NONE -DPLATFORM=$IOS_PLATFORM -DDEPLOYMENT_TARGET=$DEPLOYMENT_TARGET -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN" - - # shellcheck disable=SC2039 - if [[ $ARCH = "i386" ]]; then - EXTRA_ARGS+=" -DARCH=X86" - elif [[ $ARCH = "x86_64" ]]; then - EXTRA_ARGS+=" -DARCH=X64" - elif [[ $ARCH = "arm64" ]]; then - # Relic doesn't support aarch64 yet, "ARCH=ARM" is for ARM 32-bit architecture only - EXTRA_ARGS+=" -DIOS_ARCH=arm64 -DARCH=" - elif [[ $ARCH = "armv7s" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=armv7s -DARCH=ARM" - elif [[ $ARCH = "armv7k" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=armv7k -DARCH=ARM" - elif [[ $ARCH = "arm64_32" ]]; then - EXTRA_ARGS+=" -DIOS_ARCH=arm64_32 -DARCH=ARM" - fi - - CURRENT_DIR=$(pwd) - cmake -DCMAKE_PREFIX_PATH:PATH="${GMP_PFX}" -DTESTS=0 -DBENCH=0 -DBUILD_BLS_JS_BINDINGS=0 -DBUILD_BLS_PYTHON_BINDINGS=0 \ - -DBUILD_BLS_BENCHMARKS=0 -DBUILD_BLS_TESTS=0 -DCHECK=off -DARITH=gmp -DTIMER=HPROC -DFP_PRIME=381 -DMULTI=PTHREAD \ - -DFP_QNRES=on -DFP_METHD="INTEG;INTEG;INTEG;MONTY;EXGCD;SLIDE" -DFPX_METHD="INTEG;INTEG;LAZYR" -DPP_METHD="LAZYR;OATEP" \ - -DCOMP_FLAGS="-pipe -std=c99 -O3 -funroll-loops $OPTIMIZATIONFLAGS -isysroot $SDK -arch $ARCH -fembed-bitcode ${COMPILER_ARGS}" \ - -DWSIZE=$WSIZE -DVERBS=off -DSHLIB=off -DALLOC="AUTO" -DEP_PLAIN=off -DEP_SUPER=off -DPP_EXT="LAZYR" \ - -DWITH="DV;BN;MD;FP;EP;FPX;EPX;PP;PC;CP" -DBN_METHD="COMBA;COMBA;MONTY;SLIDE;STEIN;BASIC" ${EXTRA_ARGS} ../../ - - make -j "$LOGICALCPU_MAX" - # shellcheck disable=SC2039,SC2164 - popd # "$BUILDDIR" - # shellcheck disable=SC2039,SC2164 - popd # depends/relic -} - -build_bls_arch() { - # shellcheck disable=SC2039 - BLS_FILES=( "bls" "chaincode" "elements" "extendedprivatekey" "extendedpublickey" "legacy" "privatekey" "schemes" "threshold" ) - # shellcheck disable=SC2039 - ALL_BLS_OBJ_FILES=$(printf "%s.o " "${BLS_FILES[@]}") - - PLATFORM=$1 - ARCH=$2 - PFX=${PLATFORM}-${ARCH} - SDK=$(xcrun --sdk "$PLATFORM" --show-sdk-path) - - BUILDDIR=${BUILD}/bls-"${PFX}" - rm -rf "$BUILDDIR" - mkdir "$BUILDDIR" - # shellcheck disable=SC2039,SC2164 - pushd "$BUILDDIR" - - EXTRA_ARGS="$(version_min_flag "$PLATFORM")" - - CURRENT_DIR=$(pwd) - - # shellcheck disable=SC2039 - for F in "${BLS_FILES[@]}" - do - clang -I"../contrib/relic/include" \ - -I"../../depends/relic/include" \ - -I"../../include/dashbls" \ - -I"../relic-${PFX}/depends/relic/include" \ - -I"../../src/" \ - -I"../gmplib-${PFX}/include" \ - -x c++ -std=c++14 -stdlib=libc++ -fembed-bitcode -arch "${ARCH}" -isysroot "${SDK}" "${EXTRA_ARGS}" \ - -c "../../src/${F}.cpp" -o "${F}.o" - done - - # shellcheck disable=SC2086 - xcrun -sdk "$PLATFORM" ar -cvq libbls.a $ALL_BLS_OBJ_FILES - - # shellcheck disable=SC2039,SC2164 - popd # "$BUILDDIR" -} - -build_all_arch() { - PLATFORM=$1 - ARCH=$2 - build_gmp_arch "$PLATFORM" "$ARCH" - build_relic_arch "$PLATFORM" "$ARCH" - build_bls_arch "$PLATFORM" "$ARCH" -} - -build_target() { - BUILD_IN=$1 - echo "Build target: $BUILD_IN" - ARCH="" - PLATFORM="" - # shellcheck disable=SC2039 - if [[ $BUILD_IN = "x86_64-apple-ios" ]]; then - ARCH=x86_64 - PLATFORM=$IPHONESIMULATOR - elif [[ $BUILD_IN = "aarch64-apple-ios" ]]; then - ARCH=arm64 - PLATFORM=$IPHONEOS - elif [[ $BUILD_IN = "aarch64-apple-ios-sim" ]]; then - ARCH=arm64 - PLATFORM=$IPHONESIMULATOR - elif [[ $BUILD_IN = "x86_64-apple-darwin" ]]; then - ARCH=x86_64 - PLATFORM=$MACOS - elif [[ $BUILD_IN = "aarch64-apple-darwin" ]]; then - ARCH=arm64 - PLATFORM=$MACOS - fi - build_all_arch "$PLATFORM" "$ARCH" - PFX="${PLATFORM}"-"${ARCH}" - rm -rf "build/artefacts/${BUILD_IN}" - mkdir -p "build/artefacts/${BUILD_IN}" - cp "build/gmplib-${PFX}/lib/libgmp.a" "build/artefacts/${BUILD_IN}" - cp "build/relic-${PFX}/depends/relic/lib/librelic_s.a" "build/artefacts/${BUILD_IN}" -# cp "build/relic-${PFX}/depends/sodium/libsodium.a" "build/artefacts/${BUILD_IN}" - cp "build/bls-${PFX}/libbls.a" "build/artefacts/${BUILD_IN}" -# cp -rf build/bls-"${PFX}"/*.o build/artefacts/"${BUILD_IN}"/include -# cp -rf src/*.hpp build/artefacts/"${BUILD_IN}"/include -# cp -rf build/gmplib-"${PFX}"/include/gmp.h build/artefacts/"${BUILD_IN}"/include -# cp -rf build/relic-"${PFX}"/_deps/relic-build/include/*.h build/artefacts/"${BUILD_IN}"/include -} - -prepare -build_target "$TARGET" diff --git a/src/dashbls/autogen.sh b/src/dashbls/autogen.sh deleted file mode 100755 index de4600499e09..000000000000 --- a/src/dashbls/autogen.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -export LC_ALL=C -set -e -srcdir="$(dirname "$0")" -cd "$srcdir" -if [ -z "${LIBTOOLIZE}" ] && GLIBTOOLIZE="$(command -v glibtoolize)"; then - LIBTOOLIZE="${GLIBTOOLIZE}" - export LIBTOOLIZE -fi -command -v autoreconf >/dev/null || \ - (echo "configuration failed, please install autoconf first" && exit 1) -autoreconf --install --force --warnings=all diff --git a/src/dashbls/build-aux/m4/ax_check_compile_flag.m4 b/src/dashbls/build-aux/m4/ax_check_compile_flag.m4 deleted file mode 100644 index bd753b34d7dc..000000000000 --- a/src/dashbls/build-aux/m4/ax_check_compile_flag.m4 +++ /dev/null @@ -1,53 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the current language's compiler -# or gives an error. (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the current language's default -# flags (e.g. CFLAGS) when the check is done. The check is thus made with -# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to -# force the compiler to issue an error when a bad flag is given. -# -# INPUT gives an alternative input source to AC_COMPILE_IFELSE. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 6 - -AC_DEFUN([AX_CHECK_COMPILE_FLAG], -[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ - ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" - AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) -AS_VAR_IF(CACHEVAR,yes, - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_COMPILE_FLAGS diff --git a/src/dashbls/build-aux/m4/ax_check_link_flag.m4 b/src/dashbls/build-aux/m4/ax_check_link_flag.m4 deleted file mode 100644 index 03a30ce4c739..000000000000 --- a/src/dashbls/build-aux/m4/ax_check_link_flag.m4 +++ /dev/null @@ -1,53 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the linker or gives an error. -# (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the linker's default flags -# when the check is done. The check is thus made with the flags: "LDFLAGS -# EXTRA-FLAGS FLAG". This can for example be used to force the linker to -# issue an error when a bad flag is given. -# -# INPUT gives an alternative input source to AC_LINK_IFELSE. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 6 - -AC_DEFUN([AX_CHECK_LINK_FLAG], -[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl -AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS $4 $1" - AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - LDFLAGS=$ax_check_save_flags]) -AS_VAR_IF(CACHEVAR,yes, - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_LINK_FLAGS diff --git a/src/dashbls/build-aux/m4/ax_cxx_compile_stdcxx.m4 b/src/dashbls/build-aux/m4/ax_cxx_compile_stdcxx.m4 deleted file mode 100644 index 51a35054d08c..000000000000 --- a/src/dashbls/build-aux/m4/ax_cxx_compile_stdcxx.m4 +++ /dev/null @@ -1,1005 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) -# -# DESCRIPTION -# -# Check for baseline language coverage in the compiler for the specified -# version of the C++ standard. If necessary, add switches to CXX and -# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for -# the respective C++ standard version. -# -# The second argument, if specified, indicates whether you insist on an -# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. -# -std=c++11). If neither is specified, you get whatever works, with -# preference for no added switch, and then for an extended mode. -# -# The third argument, if specified 'mandatory' or if left unspecified, -# indicates that baseline support for the specified C++ standard is -# required and that the macro should error out if no mode with that -# support is found. If specified 'optional', then configuration proceeds -# regardless, after defining HAVE_CXX${VERSION} if and only if a -# supporting mode is found. -# -# LICENSE -# -# Copyright (c) 2008 Benjamin Kosnik -# Copyright (c) 2012 Zack Weinberg -# Copyright (c) 2013 Roy Stogner -# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov -# Copyright (c) 2015 Paul Norman -# Copyright (c) 2015 Moritz Klammler -# Copyright (c) 2016, 2018 Krzesimir Nowak -# Copyright (c) 2019 Enji Cooper -# Copyright (c) 2020 Jason Merrill -# Copyright (c) 2021 Jörn Heusipp -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 14 - -dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro -dnl (serial version number 13). - -AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl - m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], - [$1], [14], [ax_cxx_compile_alternatives="14 1y"], - [$1], [17], [ax_cxx_compile_alternatives="17 1z"], - [$1], [20], [ax_cxx_compile_alternatives="20"], - [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$2], [], [], - [$2], [ext], [], - [$2], [noext], [], - [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], - [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], - [$3], [optional], [ax_cxx_compile_cxx$1_required=false], - [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) - AC_LANG_PUSH([C++])dnl - ac_success=no - - m4_if([$2], [], [dnl - AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, - ax_cv_cxx_compile_cxx$1, - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [ax_cv_cxx_compile_cxx$1=yes], - [ax_cv_cxx_compile_cxx$1=no])]) - if test x$ax_cv_cxx_compile_cxx$1 = xyes; then - ac_success=yes - fi]) - - m4_if([$2], [noext], [], [dnl - if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - switch="-std=gnu++${alternative}" - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, - $cachevar, - [ac_save_CXX="$CXX" - CXX="$CXX $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXX="$ac_save_CXX"]) - if eval test x\$$cachevar = xyes; then - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" - fi - ac_success=yes - break - fi - done - fi]) - - m4_if([$2], [ext], [], [dnl - if test x$ac_success = xno; then - dnl HP's aCC needs +std=c++11 according to: - dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf - dnl Cray's crayCC needs "-h std=c++11" - for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, - $cachevar, - [ac_save_CXX="$CXX" - CXX="$CXX $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXX="$ac_save_CXX"]) - if eval test x\$$cachevar = xyes; then - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" - fi - ac_success=yes - break - fi - done - if test x$ac_success = xyes; then - break - fi - done - fi]) - AC_LANG_POP([C++]) - if test x$ax_cxx_compile_cxx$1_required = xtrue; then - if test x$ac_success = xno; then - AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) - fi - fi - if test x$ac_success = xno; then - HAVE_CXX$1=0 - AC_MSG_NOTICE([No compiler with C++$1 support was found]) - else - HAVE_CXX$1=1 - AC_DEFINE(HAVE_CXX$1,1, - [define if the compiler supports basic C++$1 syntax]) - fi - AC_SUBST(HAVE_CXX$1) -]) - - -dnl Test body for checking C++11 support - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 -) - -dnl Test body for checking C++14 support - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 -) - -dnl Test body for checking C++17 support - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 -) - -dnl Test body for checking C++20 support - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_20 -) - - -dnl Tests for new features in C++11 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ - -// If the compiler admits that it is not ready for C++11, why torture it? -// Hopefully, this will speed up the test. - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 201103L - -#error "This is not a C++11 compiler" - -#else - -namespace cxx11 -{ - - namespace test_static_assert - { - - template - struct check - { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); - }; - - } - - namespace test_final_override - { - - struct Base - { - virtual ~Base() {} - virtual void f() {} - }; - - struct Derived : public Base - { - virtual ~Derived() override {} - virtual void f() override {} - }; - - } - - namespace test_double_right_angle_brackets - { - - template < typename T > - struct check {}; - - typedef check single_type; - typedef check> double_type; - typedef check>> triple_type; - typedef check>>> quadruple_type; - - } - - namespace test_decltype - { - - int - f() - { - int a = 1; - decltype(a) b = 2; - return a + b; - } - - } - - namespace test_type_deduction - { - - template < typename T1, typename T2 > - struct is_same - { - static const bool value = false; - }; - - template < typename T > - struct is_same - { - static const bool value = true; - }; - - template < typename T1, typename T2 > - auto - add(T1 a1, T2 a2) -> decltype(a1 + a2) - { - return a1 + a2; - } - - int - test(const int c, volatile int v) - { - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == false, ""); - auto ac = c; - auto av = v; - auto sumi = ac + av + 'x'; - auto sumf = ac + av + 1.0; - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == true, ""); - return (sumf > 0.0) ? sumi : add(c, v); - } - - } - - namespace test_noexcept - { - - int f() { return 0; } - int g() noexcept { return 0; } - - static_assert(noexcept(f()) == false, ""); - static_assert(noexcept(g()) == true, ""); - - } - - namespace test_constexpr - { - - template < typename CharT > - unsigned long constexpr - strlen_c_r(const CharT *const s, const unsigned long acc) noexcept - { - return *s ? strlen_c_r(s + 1, acc + 1) : acc; - } - - template < typename CharT > - unsigned long constexpr - strlen_c(const CharT *const s) noexcept - { - return strlen_c_r(s, 0UL); - } - - static_assert(strlen_c("") == 0UL, ""); - static_assert(strlen_c("1") == 1UL, ""); - static_assert(strlen_c("example") == 7UL, ""); - static_assert(strlen_c("another\0example") == 7UL, ""); - - } - - namespace test_rvalue_references - { - - template < int N > - struct answer - { - static constexpr int value = N; - }; - - answer<1> f(int&) { return answer<1>(); } - answer<2> f(const int&) { return answer<2>(); } - answer<3> f(int&&) { return answer<3>(); } - - void - test() - { - int i = 0; - const int c = 0; - static_assert(decltype(f(i))::value == 1, ""); - static_assert(decltype(f(c))::value == 2, ""); - static_assert(decltype(f(0))::value == 3, ""); - } - - } - - namespace test_uniform_initialization - { - - struct test - { - static const int zero {}; - static const int one {1}; - }; - - static_assert(test::zero == 0, ""); - static_assert(test::one == 1, ""); - - } - - namespace test_lambdas - { - - void - test1() - { - auto lambda1 = [](){}; - auto lambda2 = lambda1; - lambda1(); - lambda2(); - } - - int - test2() - { - auto a = [](int i, int j){ return i + j; }(1, 2); - auto b = []() -> int { return '0'; }(); - auto c = [=](){ return a + b; }(); - auto d = [&](){ return c; }(); - auto e = [a, &b](int x) mutable { - const auto identity = [](int y){ return y; }; - for (auto i = 0; i < a; ++i) - a += b--; - return x + identity(a + b); - }(0); - return a + b + c + d + e; - } - - int - test3() - { - const auto nullary = [](){ return 0; }; - const auto unary = [](int x){ return x; }; - using nullary_t = decltype(nullary); - using unary_t = decltype(unary); - const auto higher1st = [](nullary_t f){ return f(); }; - const auto higher2nd = [unary](nullary_t f1){ - return [unary, f1](unary_t f2){ return f2(unary(f1())); }; - }; - return higher1st(nullary) + higher2nd(nullary)(unary); - } - - } - - namespace test_variadic_templates - { - - template - struct sum; - - template - struct sum - { - static constexpr auto value = N0 + sum::value; - }; - - template <> - struct sum<> - { - static constexpr auto value = 0; - }; - - static_assert(sum<>::value == 0, ""); - static_assert(sum<1>::value == 1, ""); - static_assert(sum<23>::value == 23, ""); - static_assert(sum<1, 2>::value == 3, ""); - static_assert(sum<5, 5, 11>::value == 21, ""); - static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); - - } - - // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae - // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function - // because of this. - namespace test_template_alias_sfinae - { - - struct foo {}; - - template - using member = typename T::member_type; - - template - void func(...) {} - - template - void func(member*) {} - - void test(); - - void test() { func(0); } - - } - -} // namespace cxx11 - -#endif // __cplusplus >= 201103L - -]]) - - -dnl Tests for new features in C++14 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ - -// If the compiler admits that it is not ready for C++14, why torture it? -// Hopefully, this will speed up the test. - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 201402L - -#error "This is not a C++14 compiler" - -#else - -namespace cxx14 -{ - - namespace test_polymorphic_lambdas - { - - int - test() - { - const auto lambda = [](auto&&... args){ - const auto istiny = [](auto x){ - return (sizeof(x) == 1UL) ? 1 : 0; - }; - const int aretiny[] = { istiny(args)... }; - return aretiny[0]; - }; - return lambda(1, 1L, 1.0f, '1'); - } - - } - - namespace test_binary_literals - { - - constexpr auto ivii = 0b0000000000101010; - static_assert(ivii == 42, "wrong value"); - - } - - namespace test_generalized_constexpr - { - - template < typename CharT > - constexpr unsigned long - strlen_c(const CharT *const s) noexcept - { - auto length = 0UL; - for (auto p = s; *p; ++p) - ++length; - return length; - } - - static_assert(strlen_c("") == 0UL, ""); - static_assert(strlen_c("x") == 1UL, ""); - static_assert(strlen_c("test") == 4UL, ""); - static_assert(strlen_c("another\0test") == 7UL, ""); - - } - - namespace test_lambda_init_capture - { - - int - test() - { - auto x = 0; - const auto lambda1 = [a = x](int b){ return a + b; }; - const auto lambda2 = [a = lambda1(x)](){ return a; }; - return lambda2(); - } - - } - - namespace test_digit_separators - { - - constexpr auto ten_million = 100'000'000; - static_assert(ten_million == 100000000, ""); - - } - - namespace test_return_type_deduction - { - - auto f(int& x) { return x; } - decltype(auto) g(int& x) { return x; } - - template < typename T1, typename T2 > - struct is_same - { - static constexpr auto value = false; - }; - - template < typename T > - struct is_same - { - static constexpr auto value = true; - }; - - int - test() - { - auto x = 0; - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); - return x; - } - - } - -} // namespace cxx14 - -#endif // __cplusplus >= 201402L - -]]) - - -dnl Tests for new features in C++17 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ - -// If the compiler admits that it is not ready for C++17, why torture it? -// Hopefully, this will speed up the test. - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 201703L - -#error "This is not a C++17 compiler" - -#else - -#include -#include -#include - -namespace cxx17 -{ - - namespace test_constexpr_lambdas - { - - constexpr int foo = [](){return 42;}(); - - } - - namespace test::nested_namespace::definitions - { - - } - - namespace test_fold_expression - { - - template - int multiply(Args... args) - { - return (args * ... * 1); - } - - template - bool all(Args... args) - { - return (args && ...); - } - - } - - namespace test_extended_static_assert - { - - static_assert (true); - - } - - namespace test_auto_brace_init_list - { - - auto foo = {5}; - auto bar {5}; - - static_assert(std::is_same, decltype(foo)>::value); - static_assert(std::is_same::value); - } - - namespace test_typename_in_template_template_parameter - { - - template typename X> struct D; - - } - - namespace test_fallthrough_nodiscard_maybe_unused_attributes - { - - int f1() - { - return 42; - } - - [[nodiscard]] int f2() - { - [[maybe_unused]] auto unused = f1(); - - switch (f1()) - { - case 17: - f1(); - [[fallthrough]]; - case 42: - f1(); - } - return f1(); - } - - } - - namespace test_extended_aggregate_initialization - { - - struct base1 - { - int b1, b2 = 42; - }; - - struct base2 - { - base2() { - b3 = 42; - } - int b3; - }; - - struct derived : base1, base2 - { - int d; - }; - - derived d1 {{1, 2}, {}, 4}; // full initialization - derived d2 {{}, {}, 4}; // value-initialized bases - - } - - namespace test_general_range_based_for_loop - { - - struct iter - { - int i; - - int& operator* () - { - return i; - } - - const int& operator* () const - { - return i; - } - - iter& operator++() - { - ++i; - return *this; - } - }; - - struct sentinel - { - int i; - }; - - bool operator== (const iter& i, const sentinel& s) - { - return i.i == s.i; - } - - bool operator!= (const iter& i, const sentinel& s) - { - return !(i == s); - } - - struct range - { - iter begin() const - { - return {0}; - } - - sentinel end() const - { - return {5}; - } - }; - - void f() - { - range r {}; - - for (auto i : r) - { - [[maybe_unused]] auto v = i; - } - } - - } - - namespace test_lambda_capture_asterisk_this_by_value - { - - struct t - { - int i; - int foo() - { - return [*this]() - { - return i; - }(); - } - }; - - } - - namespace test_enum_class_construction - { - - enum class byte : unsigned char - {}; - - byte foo {42}; - - } - - namespace test_constexpr_if - { - - template - int f () - { - if constexpr(cond) - { - return 13; - } - else - { - return 42; - } - } - - } - - namespace test_selection_statement_with_initializer - { - - int f() - { - return 13; - } - - int f2() - { - if (auto i = f(); i > 0) - { - return 3; - } - - switch (auto i = f(); i + 4) - { - case 17: - return 2; - - default: - return 1; - } - } - - } - - namespace test_template_argument_deduction_for_class_templates - { - - template - struct pair - { - pair (T1 p1, T2 p2) - : m1 {p1}, - m2 {p2} - {} - - T1 m1; - T2 m2; - }; - - void f() - { - [[maybe_unused]] auto p = pair{13, 42u}; - } - - } - - namespace test_non_type_auto_template_parameters - { - - template - struct B - {}; - - B<5> b1; - B<'a'> b2; - - } - - namespace test_structured_bindings - { - - int arr[2] = { 1, 2 }; - std::pair pr = { 1, 2 }; - - auto f1() -> int(&)[2] - { - return arr; - } - - auto f2() -> std::pair& - { - return pr; - } - - struct S - { - int x1 : 2; - volatile double y1; - }; - - S f3() - { - return {}; - } - - auto [ x1, y1 ] = f1(); - auto& [ xr1, yr1 ] = f1(); - auto [ x2, y2 ] = f2(); - auto& [ xr2, yr2 ] = f2(); - const auto [ x3, y3 ] = f3(); - - } - - namespace test_exception_spec_type_system - { - - struct Good {}; - struct Bad {}; - - void g1() noexcept; - void g2(); - - template - Bad - f(T*, T*); - - template - Good - f(T1*, T2*); - - static_assert (std::is_same_v); - - } - - namespace test_inline_variables - { - - template void f(T) - {} - - template inline T g(T) - { - return T{}; - } - - template<> inline void f<>(int) - {} - - template<> int g<>(int) - { - return 5; - } - - } - -} // namespace cxx17 - -#endif // __cplusplus < 201703L - -]]) - - -dnl Tests for new features in C++20 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[ - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 202002L - -#error "This is not a C++20 compiler" - -#else - -#include - -namespace cxx20 -{ - -// As C++20 supports feature test macros in the standard, there is no -// immediate need to actually test for feature availability on the -// Autoconf side. - -} // namespace cxx20 - -#endif // __cplusplus < 202002L - -]]) diff --git a/src/dashbls/build-aux/m4/ax_pthread.m4 b/src/dashbls/build-aux/m4/ax_pthread.m4 deleted file mode 100644 index 9f35d139149f..000000000000 --- a/src/dashbls/build-aux/m4/ax_pthread.m4 +++ /dev/null @@ -1,522 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_pthread.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -# -# DESCRIPTION -# -# This macro figures out how to build C programs using POSIX threads. It -# sets the PTHREAD_LIBS output variable to the threads library and linker -# flags, and the PTHREAD_CFLAGS output variable to any special C compiler -# flags that are needed. (The user can also force certain compiler -# flags/libs to be tested by setting these environment variables.) -# -# Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is -# needed for multi-threaded programs (defaults to the value of CC -# respectively CXX otherwise). (This is necessary on e.g. AIX to use the -# special cc_r/CC_r compiler alias.) -# -# NOTE: You are assumed to not only compile your program with these flags, -# but also to link with them as well. For example, you might link with -# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS -# $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS -# -# If you are only building threaded programs, you may wish to use these -# variables in your default LIBS, CFLAGS, and CC: -# -# LIBS="$PTHREAD_LIBS $LIBS" -# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" -# CC="$PTHREAD_CC" -# CXX="$PTHREAD_CXX" -# -# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant -# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to -# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). -# -# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the -# PTHREAD_PRIO_INHERIT symbol is defined when compiling with -# PTHREAD_CFLAGS. -# -# ACTION-IF-FOUND is a list of shell commands to run if a threads library -# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it -# is not found. If ACTION-IF-FOUND is not specified, the default action -# will define HAVE_PTHREAD. -# -# Please let the authors know if this macro fails on any platform, or if -# you have any other suggestions or comments. This macro was based on work -# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help -# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by -# Alejandro Forero Cuervo to the autoconf macro repository. We are also -# grateful for the helpful feedback of numerous users. -# -# Updated for Autoconf 2.68 by Daniel Richard G. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2011 Daniel Richard G. -# Copyright (c) 2019 Marc Stevens -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program 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 General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 31 - -AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) -AC_DEFUN([AX_PTHREAD], [ -AC_REQUIRE([AC_CANONICAL_HOST]) -AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([AC_PROG_SED]) -AC_LANG_PUSH([C]) -ax_pthread_ok=no - -# We used to check for pthread.h first, but this fails if pthread.h -# requires special compiler flags (e.g. on Tru64 or Sequent). -# It gets checked for in the link test anyway. - -# First of all, check if the user has set any of the PTHREAD_LIBS, -# etcetera environment variables, and if threads linking works using -# them: -if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then - ax_pthread_save_CC="$CC" - ax_pthread_save_CFLAGS="$CFLAGS" - ax_pthread_save_LIBS="$LIBS" - AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) - AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"]) - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) - AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes]) - AC_MSG_RESULT([$ax_pthread_ok]) - if test "x$ax_pthread_ok" = "xno"; then - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" - fi - CC="$ax_pthread_save_CC" - CFLAGS="$ax_pthread_save_CFLAGS" - LIBS="$ax_pthread_save_LIBS" -fi - -# We must check for the threads library under a number of different -# names; the ordering is very important because some systems -# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -# libraries is broken (non-POSIX). - -# Create a list of thread flags to try. Items with a "," contain both -# C compiler flags (before ",") and linker flags (after ","). Other items -# starting with a "-" are C compiler flags, and remaining items are -# library names, except for "none" which indicates that we try without -# any flags at all, and "pthread-config" which is a program returning -# the flags for the Pth emulation library. - -ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" - -# The ordering *is* (sometimes) important. Some notes on the -# individual items follow: - -# pthreads: AIX (must check this before -lpthread) -# none: in case threads are in libc; should be tried before -Kthread and -# other compiler flags to prevent continual compiler warnings -# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 -# (Note: HP C rejects this with "bad form for `-t' option") -# -pthreads: Solaris/gcc (Note: HP C also rejects) -# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -# doesn't hurt to check since this sometimes defines pthreads and -# -D_REENTRANT too), HP C (must be checked before -lpthread, which -# is present but should not be used directly; and before -mthreads, -# because the compiler interprets this as "-mt" + "-hreads") -# -mthreads: Mingw32/gcc, Lynx/gcc -# pthread: Linux, etcetera -# --thread-safe: KAI C++ -# pthread-config: use pthread-config program (for GNU Pth library) - -case $host_os in - - freebsd*) - - # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) - # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) - - ax_pthread_flags="-kthread lthread $ax_pthread_flags" - ;; - - hpux*) - - # From the cc(1) man page: "[-mt] Sets various -D flags to enable - # multi-threading and also sets -lpthread." - - ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" - ;; - - openedition*) - - # IBM z/OS requires a feature-test macro to be defined in order to - # enable POSIX threads at all, so give the user a hint if this is - # not set. (We don't define these ourselves, as they can affect - # other portions of the system API in unpredictable ways.) - - AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING], - [ -# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) - AX_PTHREAD_ZOS_MISSING -# endif - ], - [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])]) - ;; - - solaris*) - - # On Solaris (at least, for some versions), libc contains stubbed - # (non-functional) versions of the pthreads routines, so link-based - # tests will erroneously succeed. (N.B.: The stubs are missing - # pthread_cleanup_push, or rather a function called by this macro, - # so we could check for that, but who knows whether they'll stub - # that too in a future libc.) So we'll check first for the - # standard Solaris way of linking pthreads (-mt -lpthread). - - ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags" - ;; -esac - -# Are we compiling with Clang? - -AC_CACHE_CHECK([whether $CC is Clang], - [ax_cv_PTHREAD_CLANG], - [ax_cv_PTHREAD_CLANG=no - # Note that Autoconf sets GCC=yes for Clang as well as GCC - if test "x$GCC" = "xyes"; then - AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], - [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ -# if defined(__clang__) && defined(__llvm__) - AX_PTHREAD_CC_IS_CLANG -# endif - ], - [ax_cv_PTHREAD_CLANG=yes]) - fi - ]) -ax_pthread_clang="$ax_cv_PTHREAD_CLANG" - - -# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) - -# Note that for GCC and Clang -pthread generally implies -lpthread, -# except when -nostdlib is passed. -# This is problematic using libtool to build C++ shared libraries with pthread: -# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460 -# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333 -# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555 -# To solve this, first try -pthread together with -lpthread for GCC - -AS_IF([test "x$GCC" = "xyes"], - [ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"]) - -# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first - -AS_IF([test "x$ax_pthread_clang" = "xyes"], - [ax_pthread_flags="-pthread,-lpthread -pthread"]) - - -# The presence of a feature test macro requesting re-entrant function -# definitions is, on some systems, a strong hint that pthreads support is -# correctly enabled - -case $host_os in - darwin* | hpux* | linux* | osf* | solaris*) - ax_pthread_check_macro="_REENTRANT" - ;; - - aix*) - ax_pthread_check_macro="_THREAD_SAFE" - ;; - - *) - ax_pthread_check_macro="--" - ;; -esac -AS_IF([test "x$ax_pthread_check_macro" = "x--"], - [ax_pthread_check_cond=0], - [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) - - -if test "x$ax_pthread_ok" = "xno"; then -for ax_pthread_try_flag in $ax_pthread_flags; do - - case $ax_pthread_try_flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - *,*) - PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"` - PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"` - AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"]) - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) - PTHREAD_CFLAGS="$ax_pthread_try_flag" - ;; - - pthread-config) - AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) - AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) - PTHREAD_CFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) - PTHREAD_LIBS="-l$ax_pthread_try_flag" - ;; - esac - - ax_pthread_save_CFLAGS="$CFLAGS" - ax_pthread_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include -# if $ax_pthread_check_cond -# error "$ax_pthread_check_macro must be defined" -# endif - static void *some_global = NULL; - static void routine(void *a) - { - /* To avoid any unused-parameter or - unused-but-set-parameter warning. */ - some_global = a; - } - static void *start_routine(void *a) { return a; }], - [pthread_t th; pthread_attr_t attr; - pthread_create(&th, 0, start_routine, 0); - pthread_join(th, 0); - pthread_attr_init(&attr); - pthread_cleanup_push(routine, 0); - pthread_cleanup_pop(0) /* ; */])], - [ax_pthread_ok=yes], - []) - - CFLAGS="$ax_pthread_save_CFLAGS" - LIBS="$ax_pthread_save_LIBS" - - AC_MSG_RESULT([$ax_pthread_ok]) - AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi - - -# Clang needs special handling, because older versions handle the -pthread -# option in a rather... idiosyncratic way - -if test "x$ax_pthread_clang" = "xyes"; then - - # Clang takes -pthread; it has never supported any other flag - - # (Note 1: This will need to be revisited if a system that Clang - # supports has POSIX threads in a separate library. This tends not - # to be the way of modern systems, but it's conceivable.) - - # (Note 2: On some systems, notably Darwin, -pthread is not needed - # to get POSIX threads support; the API is always present and - # active. We could reasonably leave PTHREAD_CFLAGS empty. But - # -pthread does define _REENTRANT, and while the Darwin headers - # ignore this macro, third-party headers might not.) - - # However, older versions of Clang make a point of warning the user - # that, in an invocation where only linking and no compilation is - # taking place, the -pthread option has no effect ("argument unused - # during compilation"). They expect -pthread to be passed in only - # when source code is being compiled. - # - # Problem is, this is at odds with the way Automake and most other - # C build frameworks function, which is that the same flags used in - # compilation (CFLAGS) are also used in linking. Many systems - # supported by AX_PTHREAD require exactly this for POSIX threads - # support, and in fact it is often not straightforward to specify a - # flag that is used only in the compilation phase and not in - # linking. Such a scenario is extremely rare in practice. - # - # Even though use of the -pthread flag in linking would only print - # a warning, this can be a nuisance for well-run software projects - # that build with -Werror. So if the active version of Clang has - # this misfeature, we search for an option to squash it. - - AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread], - [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG], - [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown - # Create an alternate version of $ac_link that compiles and - # links in two steps (.c -> .o, .o -> exe) instead of one - # (.c -> exe), because the warning occurs only in the second - # step - ax_pthread_save_ac_link="$ac_link" - ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' - ax_pthread_link_step=`AS_ECHO(["$ac_link"]) | sed "$ax_pthread_sed"` - ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" - ax_pthread_save_CFLAGS="$CFLAGS" - for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do - AS_IF([test "x$ax_pthread_try" = "xunknown"], [break]) - CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" - ac_link="$ax_pthread_save_ac_link" - AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], - [ac_link="$ax_pthread_2step_ac_link" - AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], - [break]) - ]) - done - ac_link="$ax_pthread_save_ac_link" - CFLAGS="$ax_pthread_save_CFLAGS" - AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no]) - ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" - ]) - - case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in - no | unknown) ;; - *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; - esac - -fi # $ax_pthread_clang = yes - - - -# Various other checks: -if test "x$ax_pthread_ok" = "xyes"; then - ax_pthread_save_CFLAGS="$CFLAGS" - ax_pthread_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - - # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. - AC_CACHE_CHECK([for joinable pthread attribute], - [ax_cv_PTHREAD_JOINABLE_ATTR], - [ax_cv_PTHREAD_JOINABLE_ATTR=unknown - for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], - [int attr = $ax_pthread_attr; return attr /* ; */])], - [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break], - []) - done - ]) - AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ - test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ - test "x$ax_pthread_joinable_attr_defined" != "xyes"], - [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], - [$ax_cv_PTHREAD_JOINABLE_ATTR], - [Define to necessary symbol if this constant - uses a non-standard name on your system.]) - ax_pthread_joinable_attr_defined=yes - ]) - - AC_CACHE_CHECK([whether more special flags are required for pthreads], - [ax_cv_PTHREAD_SPECIAL_FLAGS], - [ax_cv_PTHREAD_SPECIAL_FLAGS=no - case $host_os in - solaris*) - ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" - ;; - esac - ]) - AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ - test "x$ax_pthread_special_flags_added" != "xyes"], - [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" - ax_pthread_special_flags_added=yes]) - - AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], - [ax_cv_PTHREAD_PRIO_INHERIT], - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[int i = PTHREAD_PRIO_INHERIT; - return i;]])], - [ax_cv_PTHREAD_PRIO_INHERIT=yes], - [ax_cv_PTHREAD_PRIO_INHERIT=no]) - ]) - AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ - test "x$ax_pthread_prio_inherit_defined" != "xyes"], - [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.]) - ax_pthread_prio_inherit_defined=yes - ]) - - CFLAGS="$ax_pthread_save_CFLAGS" - LIBS="$ax_pthread_save_LIBS" - - # More AIX lossage: compile with *_r variant - if test "x$GCC" != "xyes"; then - case $host_os in - aix*) - AS_CASE(["x/$CC"], - [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], - [#handle absolute path differently from PATH based program lookup - AS_CASE(["x$CC"], - [x/*], - [ - AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"]) - AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])]) - ], - [ - AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC]) - AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])]) - ] - ) - ]) - ;; - esac - fi -fi - -test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" -test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" - -AC_SUBST([PTHREAD_LIBS]) -AC_SUBST([PTHREAD_CFLAGS]) -AC_SUBST([PTHREAD_CC]) -AC_SUBST([PTHREAD_CXX]) - -# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -if test "x$ax_pthread_ok" = "xyes"; then - ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) - : -else - ax_pthread_ok=no - $2 -fi -AC_LANG_POP -])dnl AX_PTHREAD diff --git a/src/dashbls/cmake_modules/BrewHelper.cmake b/src/dashbls/cmake_modules/BrewHelper.cmake deleted file mode 100644 index 6a1738fa1c17..000000000000 --- a/src/dashbls/cmake_modules/BrewHelper.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2018 The Bitcoin developers - -find_program(BREW brew) - -function(find_brew_prefix VAR NAME) - if(NOT BREW) - return() - endif() - - if(DEFINED ${VAR}) - return() - endif() - - execute_process( - COMMAND ${BREW} --prefix ${NAME} - OUTPUT_VARIABLE PREFIX - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - set(${VAR} ${PREFIX} PARENT_SCOPE) -endfunction() diff --git a/src/dashbls/cmake_modules/Findgmp.cmake b/src/dashbls/cmake_modules/Findgmp.cmake deleted file mode 100644 index 3e59ede0a4f3..000000000000 --- a/src/dashbls/cmake_modules/Findgmp.cmake +++ /dev/null @@ -1,103 +0,0 @@ -# Try to find the GMP library -# https://gmplib.org/ -# -# This module supports requiring a minimum version, e.g. you can do -# find_package(GMP 6.0.0) -# to require version 6.0.0 to newer of GMP. -# -# Once done this will define -# -# GMP_FOUND - system has GMP lib with correct version -# GMP_INCLUDES - the GMP include directory -# GMP_LIBRARIES - the GMP library -# GMP_VERSION - GMP version -# -# Copyright (c) 2016 Jack Poulson, -# Redistribution and use is allowed according to the terms of the BSD license. - -include(BrewHelper) -find_brew_prefix(_GMP_BREW_HINT gmp) - -find_path(GMP_INCLUDES - NAMES - gmp.h - PATHS - $ENV{GMPDIR} ${INCLUDE_INSTALL_DIR} - PATH_SUFFIXES - include - HINTS - ${_GMP_BREW_HINT} -) - -# Set GMP_FIND_VERSION to 5.1.0 if no minimum version is specified -if(NOT GMP_FIND_VERSION) - if(NOT GMP_FIND_VERSION_MAJOR) - set(GMP_FIND_VERSION_MAJOR 5) - endif() - if(NOT GMP_FIND_VERSION_MINOR) - set(GMP_FIND_VERSION_MINOR 1) - endif() - if(NOT GMP_FIND_VERSION_PATCH) - set(GMP_FIND_VERSION_PATCH 0) - endif() - set(GMP_FIND_VERSION - "${GMP_FIND_VERSION_MAJOR}.${GMP_FIND_VERSION_MINOR}.${GMP_FIND_VERSION_PATCH}") -endif() - -message("GMP_INCLUDES=${GMP_INCLUDES}") -if(GMP_INCLUDES) - # Since the GMP version macros may be in a file included by gmp.h of the form - # gmp-.*[_]?.*.h (e.g., gmp-x86_64.h), we search each of them. - file(GLOB GMP_HEADERS "${GMP_INCLUDES}/gmp.h" "${GMP_INCLUDES}/gmp-*.h") - foreach(gmp_header_filename ${GMP_HEADERS}) - file(READ "${gmp_header_filename}" _gmp_version_header) - string(REGEX MATCH - "define[ \t]+__GNU_MP_VERSION[ \t]+([0-9]+)" _gmp_major_version_match - "${_gmp_version_header}") - if(_gmp_major_version_match) - set(GMP_MAJOR_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+__GNU_MP_VERSION_MINOR[ \t]+([0-9]+)" - _gmp_minor_version_match "${_gmp_version_header}") - set(GMP_MINOR_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+__GNU_MP_VERSION_PATCHLEVEL[ \t]+([0-9]+)" - _gmp_patchlevel_version_match "${_gmp_version_header}") - set(GMP_PATCHLEVEL_VERSION "${CMAKE_MATCH_1}") - set(GMP_VERSION - ${GMP_MAJOR_VERSION}.${GMP_MINOR_VERSION}.${GMP_PATCHLEVEL_VERSION}) - endif() - endforeach() - - # Check whether found version exists and exceeds the minimum requirement - if(NOT GMP_VERSION) - set(GMP_VERSION_OK FALSE) - message(STATUS "GMP version was not detected") - elseif(${GMP_VERSION} VERSION_LESS ${GMP_FIND_VERSION}) - set(GMP_VERSION_OK FALSE) - message(STATUS "GMP version ${GMP_VERSION} found in ${GMP_INCLUDES}, " - "but at least version ${GMP_FIND_VERSION} is required") - else() - set(GMP_VERSION_OK TRUE) - endif() -endif() - -if(STBIN) - set(_gmp_lib_name libgmp.a) -else() - set(_gmp_lib_name libgmp.so) -endif() - -find_library(GMP_LIBRARIES - NAMES - ${_gmp_lib_name} gmp.lib libgmp-10 libgmp gmp - HINTS - ${_GMP_BREW_HINT} - INCLUDE_DIRS - ${GMP_INCLUDES} - PATHS - $ENV{GMPDIR} ${LIB_INSTALL_DIR} -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(gmp DEFAULT_MSG - GMP_INCLUDES GMP_LIBRARIES GMP_VERSION_OK) -mark_as_advanced(GMP_INCLUDES GMP_LIBRARIES) diff --git a/src/dashbls/cmake_modules/Findsodium.cmake b/src/dashbls/cmake_modules/Findsodium.cmake deleted file mode 100644 index 0350b67fce9b..000000000000 --- a/src/dashbls/cmake_modules/Findsodium.cmake +++ /dev/null @@ -1,294 +0,0 @@ -# Written in 2016 by Henrik Steffen Gaßmann -# -# To the extent possible under law, the author(s) have dedicated all -# copyright and related and neighboring rights to this software to the -# public domain worldwide. This software is distributed without any warranty. -# -# You should have received a copy of the CC0 Public Domain Dedication -# along with this software. If not, see -# -# http://creativecommons.org/publicdomain/zero/1.0/ -# -######################################################################## -# Tries to find the local libsodium installation. -# -# On Windows the sodium_DIR environment variable is used as a default -# hint which can be overridden by setting the corresponding cmake variable. -# -# Once done the following variables will be defined: -# -# sodium_FOUND -# sodium_INCLUDE_DIR -# sodium_LIBRARY_DEBUG -# sodium_LIBRARY_RELEASE -# -# -# Furthermore an imported "sodium" target is created. -# - -if (CMAKE_C_COMPILER_ID STREQUAL "GNU" - OR CMAKE_C_COMPILER_ID STREQUAL "Clang") - set(_GCC_COMPATIBLE 1) -endif() - -# static library option -if (NOT DEFINED sodium_USE_STATIC_LIBS) - option(sodium_USE_STATIC_LIBS "enable to statically link against sodium" OFF) -endif() -if(NOT (sodium_USE_STATIC_LIBS EQUAL sodium_USE_STATIC_LIBS_LAST)) - unset(sodium_LIBRARY CACHE) - unset(sodium_LIBRARY_DEBUG CACHE) - unset(sodium_LIBRARY_RELEASE CACHE) - unset(sodium_DLL_DEBUG CACHE) - unset(sodium_DLL_RELEASE CACHE) - set(sodium_USE_STATIC_LIBS_LAST ${sodium_USE_STATIC_LIBS} CACHE INTERNAL "internal change tracking variable") -endif() - - -######################################################################## -# UNIX -if (UNIX) - # import pkg-config - find_package(PkgConfig QUIET) - if (PKG_CONFIG_FOUND) - pkg_check_modules(sodium_PKG QUIET libsodium) - endif() - - if(sodium_USE_STATIC_LIBS) - foreach(_libname ${sodium_PKG_STATIC_LIBRARIES}) - if (NOT _libname MATCHES "^lib.*\\.a$") # ignore strings already ending with .a - list(INSERT sodium_PKG_STATIC_LIBRARIES 0 "lib${_libname}.a") - endif() - endforeach() - list(REMOVE_DUPLICATES sodium_PKG_STATIC_LIBRARIES) - - # if pkgconfig for libsodium doesn't provide - # static lib info, then override PKG_STATIC here.. - if (NOT sodium_PKG_STATIC_FOUND) - set(sodium_PKG_STATIC_LIBRARIES libsodium.a) - endif() - - set(XPREFIX sodium_PKG_STATIC) - else() - if (NOT sodium_PKG_FOUND) - set(sodium_PKG_LIBRARIES sodium) - endif() - - set(XPREFIX sodium_PKG) - endif() - - find_path(sodium_INCLUDE_DIR sodium.h - HINTS ${${XPREFIX}_INCLUDE_DIRS} - ) - find_library(sodium_LIBRARY_DEBUG NAMES ${${XPREFIX}_LIBRARIES} - HINTS ${${XPREFIX}_LIBRARY_DIRS} - ) - find_library(sodium_LIBRARY_RELEASE NAMES ${${XPREFIX}_LIBRARIES} - HINTS ${${XPREFIX}_LIBRARY_DIRS} - ) - - -######################################################################## -# Windows -elseif (WIN32) - set(sodium_DIR "$ENV{sodium_DIR}" CACHE FILEPATH "sodium install directory") - mark_as_advanced(sodium_DIR) - - find_path(sodium_INCLUDE_DIR sodium.h - HINTS ${sodium_DIR} - PATH_SUFFIXES include - ) - - if (MSVC) - # detect target architecture - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" [=[ - #if defined _M_IX86 - #error ARCH_VALUE x86_32 - #elif defined _M_X64 - #error ARCH_VALUE x86_64 - #endif - #error ARCH_VALUE unknown - ]=]) - try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" - OUTPUT_VARIABLE _COMPILATION_LOG - ) - string(REGEX REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*" "\\1" _TARGET_ARCH "${_COMPILATION_LOG}") - - # construct library path - if (_TARGET_ARCH STREQUAL "x86_32") - string(APPEND _PLATFORM_PATH "Win32") - elseif(_TARGET_ARCH STREQUAL "x86_64") - string(APPEND _PLATFORM_PATH "x64") - else() - message(FATAL_ERROR "the ${_TARGET_ARCH} architecture is not supported by Findsodium.cmake.") - endif() - string(APPEND _PLATFORM_PATH "/$$CONFIG$$") - - if (MSVC_VERSION LESS 1900) - math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60") - else() - math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50") - endif() - string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}") - - if (sodium_USE_STATIC_LIBS) - string(APPEND _PLATFORM_PATH "/static") - else() - string(APPEND _PLATFORM_PATH "/dynamic") - endif() - - string(REPLACE "$$CONFIG$$" "Debug" _DEBUG_PATH_SUFFIX "${_PLATFORM_PATH}") - string(REPLACE "$$CONFIG$$" "Release" _RELEASE_PATH_SUFFIX "${_PLATFORM_PATH}") - - find_library(sodium_LIBRARY_DEBUG libsodium.lib - HINTS ${sodium_DIR} - PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX} - ) - find_library(sodium_LIBRARY_RELEASE libsodium.lib - HINTS ${sodium_DIR} - PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX} - ) - if (NOT sodium_USE_STATIC_LIBS) - set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES}) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll") - find_library(sodium_DLL_DEBUG libsodium - HINTS ${sodium_DIR} - PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX} - ) - find_library(sodium_DLL_RELEASE libsodium - HINTS ${sodium_DIR} - PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX} - ) - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK}) - endif() - - elseif(_GCC_COMPATIBLE) - if (sodium_USE_STATIC_LIBS) - find_library(sodium_LIBRARY_DEBUG libsodium.a - HINTS ${sodium_DIR} - PATH_SUFFIXES lib - ) - find_library(sodium_LIBRARY_RELEASE libsodium.a - HINTS ${sodium_DIR} - PATH_SUFFIXES lib - ) - else() - find_library(sodium_LIBRARY_DEBUG libsodium.dll.a - HINTS ${sodium_DIR} - PATH_SUFFIXES lib - ) - find_library(sodium_LIBRARY_RELEASE libsodium.dll.a - HINTS ${sodium_DIR} - PATH_SUFFIXES lib - ) - - file(GLOB _DLL - LIST_DIRECTORIES false - RELATIVE "${sodium_DIR}/bin" - "${sodium_DIR}/bin/libsodium*.dll" - ) - find_library(sodium_DLL_DEBUG ${_DLL} libsodium - HINTS ${sodium_DIR} - PATH_SUFFIXES bin - ) - find_library(sodium_DLL_RELEASE ${_DLL} libsodium - HINTS ${sodium_DIR} - PATH_SUFFIXES bin - ) - endif() - else() - message(FATAL_ERROR "this platform is not supported by FindSodium.cmake") - endif() - - -######################################################################## -# unsupported -else() - message(FATAL_ERROR "this platform is not supported by FindSodium.cmake") -endif() - - -######################################################################## -# common stuff - -# extract sodium version -if (sodium_INCLUDE_DIR) - set(_VERSION_HEADER "${_INCLUDE_DIR}/sodium/version.h") - if (EXISTS _VERSION_HEADER) - file(READ "${_VERSION_HEADER}" _VERSION_HEADER_CONTENT) - string(REGEX REPLACE ".*#[ \t]*define[ \t]*SODIUM_VERSION_STRING[ \t]*\"([^\n]*)\".*" "\\1" - sodium_VERSION "${_VERSION_HEADER_CONTENT}") - set(sodium_VERSION "${sodium_VERSION}" PARENT_SCOPE) - endif() -endif() - -# communicate results -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - sodium # The name must be either uppercase or match the filename case. - REQUIRED_VARS - sodium_LIBRARY_RELEASE - sodium_LIBRARY_DEBUG - sodium_INCLUDE_DIR - VERSION_VAR - sodium_VERSION -) - -if(Sodium_FOUND) - set(sodium_LIBRARIES - optimized ${sodium_LIBRARY_RELEASE} debug ${sodium_LIBRARY_DEBUG}) -endif() - -# mark file paths as advanced -mark_as_advanced(sodium_INCLUDE_DIR) -mark_as_advanced(sodium_LIBRARY_DEBUG) -mark_as_advanced(sodium_LIBRARY_RELEASE) -if (WIN32) - mark_as_advanced(sodium_DLL_DEBUG) - mark_as_advanced(sodium_DLL_RELEASE) -endif() - -# create imported target -if(sodium_USE_STATIC_LIBS) - set(_LIB_TYPE STATIC) -else() - set(_LIB_TYPE SHARED) -endif() -add_library(sodium ${_LIB_TYPE} IMPORTED) - -set_target_properties(sodium PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${sodium_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" -) - -if (sodium_USE_STATIC_LIBS) - set_target_properties(sodium PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "SODIUM_STATIC" - IMPORTED_LOCATION "${sodium_LIBRARY_RELEASE}" - IMPORTED_LOCATION_DEBUG "${sodium_LIBRARY_DEBUG}" - ) -else() - if (UNIX) - set_target_properties(sodium PROPERTIES - IMPORTED_LOCATION "${sodium_LIBRARY_RELEASE}" - IMPORTED_LOCATION_DEBUG "${sodium_LIBRARY_DEBUG}" - ) - elseif (WIN32) - set_target_properties(sodium PROPERTIES - IMPORTED_IMPLIB "${sodium_LIBRARY_RELEASE}" - IMPORTED_IMPLIB_DEBUG "${sodium_LIBRARY_DEBUG}" - ) - if (NOT (sodium_DLL_DEBUG MATCHES ".*-NOTFOUND")) - set_target_properties(sodium PROPERTIES - IMPORTED_LOCATION_DEBUG "${sodium_DLL_DEBUG}" - ) - endif() - if (NOT (sodium_DLL_RELEASE MATCHES ".*-NOTFOUND")) - set_target_properties(sodium PROPERTIES - IMPORTED_LOCATION_RELWITHDEBINFO "${sodium_DLL_RELEASE}" - IMPORTED_LOCATION_MINSIZEREL "${sodium_DLL_RELEASE}" - IMPORTED_LOCATION_RELEASE "${sodium_DLL_RELEASE}" - ) - endif() - endif() -endif() diff --git a/src/dashbls/configure.ac b/src/dashbls/configure.ac deleted file mode 100644 index 56b8a78339e0..000000000000 --- a/src/dashbls/configure.ac +++ /dev/null @@ -1,913 +0,0 @@ -AC_PREREQ([2.60]) -AC_INIT([libdashbls],[2.0]) -AC_CONFIG_AUX_DIR([build-aux]) -AC_CONFIG_MACRO_DIR([build-aux/m4]) - -dnl Unless the user specified ARFLAGS, force it to be cr -AC_ARG_VAR(ARFLAGS, [Flags for the archiver, defaults to if not set]) -if test "x${ARFLAGS+set}" != "xset"; then - ARFLAGS="qc" -fi - -AC_CANONICAL_HOST - -AH_TOP([#ifndef RLC_CONF_H]) -AH_TOP([#define RLC_CONF_H]) -AH_BOTTOM([#endif /*RLC_CONF_H*/]) -AM_INIT_AUTOMAKE([foreign no-define subdir-objects]) - -dnl faketime messes with timestamps and causes configure to be re-run. -dnl --disable-maintainer-mode can be used to bypass this. -AM_MAINTAINER_MODE([enable]) - -dnl make the compilation flags quiet unless V=1 is used -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -dnl Compiler checks (here before libtool). -if test "x${CFLAGS+set}" = "xset"; then - CFLAGS_overridden=yes -else - CFLAGS_overridden=no -fi -if test "x${CXXFLAGS+set}" = "xset"; then - CXXFLAGS_overridden=yes -else - CXXFLAGS_overridden=no -fi - -AC_PROG_CC - -AC_PROG_CXX - -dnl By default, libtool for mingw refuses to link static libs into a dll for -dnl fear of mixing pic/non-pic objects, and import/export complications. Since -dnl we have those under control, re-enable that functionality. -case $host in - *mingw*) - lt_cv_deplibs_check_method="pass_all" - ;; -esac -dnl Require C++14 compiler (no GNU extensions) -AX_CXX_COMPILE_STDCXX([14], [noext], [mandatory], [nodefault]) - -dnl Libtool init checks. -LT_INIT([pic-only]) - -AC_PATH_TOOL(AR, ar) -AC_PATH_TOOL(RANLIB, ranlib) -AC_PATH_TOOL(STRIP, strip) - -AM_PROG_AS - -AC_ARG_ENABLE([tests], - [AS_HELP_STRING([--enable-tests], - [Compile with tests [default=yes]])], - [use_tests=$enableval], - [use_tests=yes]) - -AC_ARG_ENABLE([bench], - [AS_HELP_STRING([--enable-bench], - [Compile with benchmarks [default=yes]])], - [use_bench=$enableval], - [use_bench=yes]) - -AC_ARG_ENABLE([hardening], - [AS_HELP_STRING([--enable-hardening], - [Enable hardening flags and arguments [default=auto]])], - [use_hardening=$enableval], - [use_hardening=auto]) - -AC_ARG_ENABLE([optimizations], - [AS_HELP_STRING([--enable-optimizations], - [Enable compiler and library optimizations [default=yes]])], - [use_optimizations=$enableval], - [use_optimizations=yes]) - -AC_ARG_ENABLE([debug], - [AS_HELP_STRING([--enable-debug], - [Build with debugging support [default=no]])], - [use_debug=$enableval], - [use_debug=no]) - -AC_LANG_PUSH([C]) - -dnl Check for a flag to turn compiler warnings into errors. This is helpful for checks which may -dnl appear to succeed because by default they merely emit warnings when they fail. -dnl -dnl Note that this is not necessarily a check to see if -Werror is supported, but rather to see if -dnl a compile with -Werror can succeed. This is important because the compiler may already be -dnl warning about something unrelated, for example about some path issue. If that is the case, -dnl -Werror cannot be used because all of those warnings would be turned into errors. -AX_CHECK_COMPILE_FLAG([-Werror], [FLAG_WERROR="-Werror"], [FLAG_WERROR=""]) - -if test x"$use_debug" = x"yes" -o x"$use_optimizations" = x"no"; then - dnl Clear default -g -O2 flags - if test x"$CFLAGS_overridden" = x"no"; then - CFLAGS="" - fi - if test x"$CXXFLAGS_overridden" = x"no"; then - CXXFLAGS="" - fi - - dnl Disable optimizations - AX_CHECK_COMPILE_FLAG([-O0], [[DEBUG_FLAGS="$DEBUG_FLAGS -O0"]], [], [[$FLAG_WERROR]]) - - if test x"$use_debug" = x"yes"; then - dnl Prefer -g3, fall back to -g if that is unavailable. - AX_CHECK_COMPILE_FLAG( - [-g3], - [[DEBUG_FLAGS="$DEBUG_FLAGS -g3"]], - [AX_CHECK_COMPILE_FLAG([-g],[[DEBUG_FLAGS="$DEBUG_FLAGS -g"]])], [[$FLAG_WERROR]]) - - AX_CHECK_COMPILE_FLAG([-ftrapv],[DEBUG_FLAGS="$DEBUG_FLAGS -ftrapv"], [], [[$FLAG_WERROR]]) - else - dnl Reintroduce -g flag deleted during C(XX)FLAGS reset - AX_CHECK_COMPILE_FLAG([-g],[[DEBUG_FLAGS="$DEBUG_FLAGS -g"]], [], [[$FLAG_WERROR]]) - - dnl -ftrapv and -fwrapv conflict, so we only set this if use_debug=no - AX_CHECK_COMPILE_FLAG([-fwrapv],[DEBUG_FLAGS="$DEBUG_FLAGS -fwrapv"], [], [[$FLAG_WERROR]]) - fi -fi - -dnl Define enum mappings for relic config -AC_DEFINE([RLC_VERSION], ["0.5.0"], [Relic Version]) - -dnl dashbls: Library processor architecture -AC_DEFINE([AVR], [1], [Atmel AVR ATMega128 8-bit architecture.]) -AC_DEFINE([MSP], [2], [MSP430 16-bit architecture.]) -AC_DEFINE([ARM], [3], [ARM 32-bit architecture.]) -AC_DEFINE([X86], [4], [Intel x86-compatible 32-bit architecture.]) -AC_DEFINE([X64], [5], [AMD64-compatible 64-bit architecture.]) - -dnl Relic: Generic options -AC_DEFINE([RELIC_NONE], [0], [Unknown or unrecognized parameter.]) - -dnl Relic: Arithmetic backends -AC_DEFINE([EASY], [1], [Easy C-only backend.]) -AC_DEFINE([GMP], [2], [Backend based on GNU Multiple Precision library.]) -AC_DEFINE([GMP_SEC], [3], [Backend based on GNU Multiple Precision library, but using constant-time code.]) - -AC_DEFUN([GMP_CHECK],[ - AC_REQUIRE([AC_PROG_CC]) - - CPPFLAGS_TEMP="$CPPFLAGS" - CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS" - LIBS_TEMP="$LIBS" - LIBS="$GMP_LDFLAGS $LIBS" - - AC_CHECK_HEADER( - gmp.h, - [AC_CHECK_LIB(gmp, __gmpz_init, [], [gmp_fail_reason="libgmp not found or unusable"; has_gmp=no;])], - [gmp_fail_reason="gmp header not found"; has_gmp=no;] - ) - - if test x"$has_gmp" != x"no"; then - # Proper support for macOS aarch64 was introduced in 6.3.0, but LTS distros - # like Ubuntu 20.04 (focal) use 6.2.0, so, the minimum supported version is - # determined by platform and architecture. - case $host in - *darwin*) - case $host_cpu in - aarch*) - gmp_major_version=6 - gmp_minor_version=3 - ;; - esac - ;; - *) - gmp_major_version=6 - gmp_minor_version=2 - ;; - esac - AC_MSG_CHECKING([gmp version >= $gmp_major_version.$gmp_minor_version]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[@%:@include ]], - [[ - @%:@if __GNU_MP_VERSION < $gmp_major_version || __GNU_MP_VERSION_MINOR < $gmp_minor_version - @%:@error Unsupported GMP version - @%:@endif]])], - [AC_MSG_RESULT([yes]); GMP_LIBS="-lgmp"; has_gmp=yes;], - [AC_MSG_RESULT([no]); gmp_fail_reason="unsupported gmp version"; has_gmp=no;] - ) - fi - - if test x"$want_backend" = x"gmp" && test x"$has_gmp" = x"no"; then - AC_MSG_ERROR([$gmp_fail_reason]) - fi - - CPPFLAGS="$CPPFLAGS_TEMP" - LIBS="$LIBS_TEMP" -]) - -AC_ARG_WITH([backend], - [AS_HELP_STRING([--with-backend=auto|easy|gmp], - [backend implementation to use [default=auto]])], - [want_backend=$withval], - [want_backend=auto] -) - -case $host in - *darwin*) - AC_PATH_PROG([BREW],brew,) - if test x$BREW != x; then - # These Homebrew packages may be keg-only, meaning that they won't be found - # in expected paths because they may conflict with system files. Ask - # Homebrew where each one is located, then adjust paths accordingly. - gmp_prefix=`$BREW --prefix gmp 2>/dev/null` - if test x$gmp_prefix != x; then - GMP_CPPFLAGS="-I$gmp_prefix/include" - GMP_LDFLAGS="-L$gmp_prefix/lib" - fi - fi - ;; - *freebsd*) - GMP_CPPFLAGS="-I/usr/local/include" - GMP_LDFLAGS="-L/usr/local/lib" - ;; -esac - -if test x"$want_backend" = x"auto"; then - if test x"$use_optimizations" = x"no"; then - want_backend=easy - else - GMP_CHECK - if test x"$has_gmp" = x"yes"; then - want_backend=gmp - else - want_backend=easy - fi - fi -else - case $want_backend in - gmp) - dnl GMP_CHECK will report the reason if and why the backend cannot be used. - GMP_CHECK - ;; - easy) - ;; - *) - AC_MSG_ERROR([invalid backend explicitly requested]) - ;; - esac -fi - -case $want_backend in -gmp) - AC_DEFINE(ARITH, GMP, [Define if GNU MP backend is requested]) - ;; -easy) - AC_DEFINE(ARITH, EASY, [Define if C-only backend is requested].) - ;; -*) - AC_MSG_ERROR([invalid backend explicitly requested]) - ;; -esac - -dnl Relic: Multithreading APIs -AC_DEFINE([OPENMP], [1], [OpenMP multithreading support.]) -AC_DEFINE([PTHREAD], [2], [POSIX multithreading support.]) - -dnl Relic: Supported operating systems -AC_DEFINE([LINUX], [1], [GNU/Linux operating system.]) -AC_DEFINE([FREEBSD], [2], [FreeBSD operating system.]) -AC_DEFINE([MACOSX], [3], [MacOS operating system.]) -AC_DEFINE([WINDOWS], [4], [Windows operating system.]) -AC_DEFINE([DROID], [5], [Android operating system.]) -AC_DEFINE([DUINO], [6], [Arduino platform.]) -dnl AC_DEFINE([OPENBSD], [7], [OpenBSD operating system.]) - -dnl Relic: Supported timers -AC_DEFINE([HREAL], [1], [Per-process high-resolution timer.]) -AC_DEFINE([HPROC], [2], [Per-process high-resolution timer.]) -AC_DEFINE([HTHRD], [3], [Per-thread high-resolution timer.]) -AC_DEFINE([ANSI], [5], [ANSI-compatible timer.]) -AC_DEFINE([POSIX], [4], [POSIX-compatible timer.]) -AC_DEFINE([CYCLE], [6], [Cycle-counting timer.]) -AC_DEFINE([PERF], [7], [Performance monitoring framework.]) - -dnl Relic: Memory-allocation policies -AC_DEFINE([AUTO], [1], [Automatic memory allocation.]) -AC_DEFINE([DYNAMIC], [2], [Dynamic memory allocation.]) - -dnl Relic (CP): Support for faster CRT-based exponentiation in factoring-based cryptosystems -AC_DEFINE([PKCS1], [2], [RSA PKCS#1 v1.5 padding.]) -AC_DEFINE([PKCS2], [3], [RSA PKCS#1 v2.1 padding.]) - -dnl Relic (MD): Available hash functions -AC_DEFINE([SH224], [2], [SHA-224 hash function.]) -AC_DEFINE([SH256], [3], [SHA-256 hash function.]) -AC_DEFINE([SH384], [4], [SHA-384 hash function.]) -AC_DEFINE([SH512], [5], [SHA-512 hash function.]) -AC_DEFINE([B2S160], [6], [BLAKE2s-160 hash function.]) -AC_DEFINE([B2S256], [7], [BLAKE2s-256 hash function.]) - -dnl Relic (RAND): Available pseudo-random number generators -AC_DEFINE([HASHD], [1], [NIST HASH-DRBG generator.]) -AC_DEFINE([RDRND], [2], [Intel RdRand instruction.]) -AC_DEFINE([UDEV], [3], [Operating system underlying generator.]) -AC_DEFINE([CALL], [4], [Override library generator with the callback.]) - -dnl Relic (RAND): Available random number generator seeders -AC_DEFINE([LIBC], [1], [Standard C library generator.]) -dnl AC_DEFINE([RDRND], [2], [Intel RdRand instruction.]) -dnl AC_DEFINE([UDEV], [3], [Operating system underlying generator.]) -AC_DEFINE([WCGR], [4], [Use Windows' CryptGenRandom.]) - -dnl Relic (BN): Options for the multiple precision -AC_DEFINE([SINGLE], [1], [A multiple precision integer can store w words.]) -AC_DEFINE([CARRY], [2], [A multiple precision integer can store the result of an addition.]) -AC_DEFINE([DOUBLE], [3], [A multiple precision integer can store the result of a multiplication.]) - -AC_DEFINE([BASIC], [1], [Basic method.]) -AC_DEFINE([PRIME], [1], [Prime curves.]) -AC_DEFINE([TATEP], [1], [Tate pairing.]) -AC_DEFINE([COMBA], [2], [Comba method.]) -AC_DEFINE([LEHME], [2], [Lehmer's fast GCD Algorithm.]) -AC_DEFINE([SAFEP], [2], [Safe prime generation.]) -AC_DEFINE([QUICK], [2], [Fast reduction modulo special form prime.]) -AC_DEFINE([BINAR], [2], [Binary inversion.]) -AC_DEFINE([LAZYR], [2], [Lazy-reduced extension field arithmetic.]) -AC_DEFINE([LODAH], [2], [Lopez-Dahab multiplication.]) -AC_DEFINE([SLIDE], [2], [Sliding window modular exponentiation.]) -AC_DEFINE([PROJC], [2], [Projective coordinates.]) -AC_DEFINE([COMBS], [2], [Single-table comb method.]) -AC_DEFINE([TRICK], [2], [Shamir's trick.]) -AC_DEFINE([CHAR2], [2], [Binary curves.]) -AC_DEFINE([WEILP], [2], [Weil pairing.]) -AC_DEFINE([MONTY], [3], [Montgomery method.]) -AC_DEFINE([STEIN], [3], [Stein's binary GCD Algorithm.]) -AC_DEFINE([STRON], [3], [Strong prime generation.]) -AC_DEFINE([INTEG], [3], [Integrated modular addtion.]) -AC_DEFINE([INTER], [3], [Interleaving of w-(T)NAFs.]) -AC_DEFINE([ALMOS], [3], [Almost inverse algorithm.]) -AC_DEFINE([JACOB], [3], [Jacobian coordinates.]) -AC_DEFINE([COMBD], [3], [Double-table comb method.]) -AC_DEFINE([HALVE], [3], [Halving.]) -AC_DEFINE([EDDIE], [3], [Edwards curves.]) -AC_DEFINE([EXTND], [3], [Extended projective twisted Edwards coordinates.]) -AC_DEFINE([OATEP], [3], [Optimal ate pairing.]) -AC_DEFINE([PMERS], [4], [Pseudo-Mersenne method.]) -AC_DEFINE([MULTP], [4], [Reuse multiplication for squaring.]) -AC_DEFINE([EXGCD], [4], [Extended Euclidean algorithm.]) -AC_DEFINE([LWNAF], [4], [Left-to-right Width-w NAF.]) -AC_DEFINE([JOINT], [4], [Joint sparse form.]) -AC_DEFINE([DIVST], [5], [Constant-time inversion by Bernstein-Yang division steps.]) -AC_DEFINE([ITOHT], [5], [Itoh-Tsuji inversion.]) -AC_DEFINE([LWREG], [5], [Left-to-right Width-w NAF.]) -AC_DEFINE([BRUCH], [6], [Hardware-friendly inversion by Brunner-Curiger-Hofstetter.]) -AC_DEFINE([CTAIA], [7], [Constant-time version of almost inverse.]) -AC_DEFINE([LOWER], [8], [Use implementation provided by the lower layer.]) - -if test x"$use_debug" = x"yes"; then - AC_DEFINE([DEBUG], [1], [Define this symbol if debugging support is enabled]) -fi - -dnl Define relic switches -AC_ARG_ENABLE([profiling], - [AS_HELP_STRING([--enable-profiling], - [Build with profiling support [default=no]])], - [use_profiling=$enableval], - [use_profiling=no]) - -if test x$use_profiling = xyes; then - AC_DEFINE([PROFL], [1], [Define this symbol if profiling support is enabled]) -fi - -AC_ARG_ENABLE([check], - [AS_HELP_STRING([--enable-check], - [Build with error-checking support [default=no]])], - [use_check=$enableval], - [use_check=no]) - -if test x$use_check = xyes; then - AC_DEFINE([CHECK], [1], [Define this symbol if error-checking support is enabled]) -fi - -AC_ARG_ENABLE([verbs], - [AS_HELP_STRING([--enable-verbs], - [Build with detailed error messages [default=no]])], - [use_verbs=$enableval], - [use_verbs=no]) - -if test x$use_verbs = xyes; then - AC_DEFINE([VERBS], [1], [Define this symbol if detailed error messages are enabled]) -fi - -AC_ARG_ENABLE([overhead], - [AS_HELP_STRING([--enable-overhead], - [Build with overhead estimation [default=no]])], - [use_overhead=$enableval], - [use_overhead=no]) - -if test x$use_overhead = xyes; then - AC_DEFINE([OVERH], [1], [Define this symbol if overhead estimation is enabled]) -fi - -AC_ARG_ENABLE([quiet], - [AS_HELP_STRING([--enable-quiet], - [Build with printing disabled [default=yes]])], - [use_quiet=$enableval], - [use_quiet=yes]) - -if test x$use_quiet = xyes; then - AC_DEFINE([QUIET], [1], [Define this symbol if printing is disabled]) -fi - -AC_ARG_ENABLE([color], - [AS_HELP_STRING([--enable-color], - [Build with colored output support [default=yes]])], - [use_color=$enableval], - [use_color=yes]) - -if test x$use_color = xyes; then - AC_DEFINE([COLOR], [1], [Define this symbol if colored output is enabled]) -fi - -AC_ARG_ENABLE([big_endian], - [AS_HELP_STRING([--enable-big-endian], - [Build with big-endian support [default=no]])], - [use_big_endian=$enableval], - [use_big_endian=no]) - -if test x$use_big_endian = xyes; then - AC_DEFINE([BIGED], [1], [Define this symbol if big-endian support is enabled]) -fi - -use_pkgconfig=yes - -if test x"$use_optimizations" = x"yes"; then - case $host_cpu in - amd64 | x86_64) - dnl Support for AMD64 (also known as x86_64 on some platforms) processors - CPU_ARCH="x64" - AC_DEFINE([ARCH], [X64], [Architecture.]) - AC_DEFINE([WSIZE], [64], [Size of word in this architecture.]) - ;; - aarch*) - dnl Support for 64-bit ARM processors - dnl Relic does not support aarch64 yet, set CPU_ARCH to none and ARCH to RELIC_NONE. - CPU_ARCH="none" - AC_DEFINE([ARCH], [RELIC_NONE], [Architecture.]) - AC_DEFINE([WSIZE], [64], [Size of word in this architecture.]) - ;; - i?86) - dnl Support for Intel x86 processors - CPU_ARCH="x86" - AC_DEFINE([ARCH], [X86], [Architecture.]) - AC_DEFINE([WSIZE], [32], [Size of word in this architecture.]) - ;; - arm*) - dnl Support for 32-bit native ARM processors - CPU_ARCH="arm" - AC_DEFINE([ARCH], [ARM], [Architecture.]) - AC_DEFINE([WSIZE], [32], [Size of word in this architecture.]) - ;; - *64*) - dnl Support for an undefined 64-bit architecture - CPU_ARCH="none" - AC_DEFINE([ARCH], [RELIC_NONE], [Architecture.]) - AC_DEFINE([WSIZE], [64], [Size of word in this architecture.]) - ;; - *32*) - dnl Support for an undefined 32-bit architecture - CPU_ARCH="none" - AC_DEFINE([ARCH], [RELIC_NONE], [Architecture.]) - AC_DEFINE([WSIZE], [32], [Size of word in this architecture.]) - ;; - *) - AC_MSG_ERROR([Unable to determine host architecture, may not be supported!]) - ;; - esac -else - case $host_cpu in - *64*) - dnl Support for an undefined 64-bit architecture - CPU_ARCH="none" - AC_DEFINE([ARCH], [RELIC_NONE], [Architecture.]) - AC_DEFINE([WSIZE], [64], [Size of word in this architecture.]) - ;; - *32* | arm* | i?86) - dnl Support for an undefined 32-bit architecture - CPU_ARCH="none" - AC_DEFINE([ARCH], [RELIC_NONE], [Architecture.]) - AC_DEFINE([WSIZE], [32], [Size of word in this architecture.]) - ;; - *) - AC_MSG_ERROR([Unable to determine host architecture, may not be supported!]) - ;; - esac -fi - -case $host in - *darwin*) - AC_DEFINE([OPSYS], [MACOSX], [Detected operation system.]) - TARGET_OS=darwin - - AC_PATH_PROG([BREW],brew,) - if test x$BREW = x; then - AC_PATH_PROG([PORT],port,) - # If homebrew isn't installed and macports is, add the macports default paths - # as a last resort. - if test x$PORT != x; then - CPPFLAGS="$CPPFLAGS -isystem /opt/local/include" - LDFLAGS="$LDFLAGS -L/opt/local/lib" - fi - fi - ;; - *mingw*) - AC_DEFINE([OPSYS], [WINDOWS], [Detected operation system.]) - TARGET_OS=windows - - use_pkgconfig=no - LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static" - - dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against. - dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override - dnl its command here, with the predeps/postdeps removed, and -static inserted. Postdeps are - dnl also overridden to prevent their insertion later. - dnl This should only affect dll's. - archive_cmds_CXX="\$CC -shared \$libobjs \$deplibs \$compiler_flags -static -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib" - postdeps_CXX= - ;; - *linux*) - AC_DEFINE([OPSYS], [LINUX], [Detected operation system.]) - TARGET_OS=linux - - RELIC_CPPFLAGS="-D_GNU_SOURCE" - ;; - *android*) - AC_DEFINE([OPSYS], [DROID], [Detected operation system.]) - TARGET_OS=android - ;; - *freebsd*) - AC_DEFINE([OPSYS], [FREEBSD], [Detected operation system.]) - TARGET_OS=freebsd - ;; - *netbsd*) - AC_DEFINE([OPSYS], [NETBSD], [Detected operation system.]) - TARGET_OS=netbsd - ;; - *) - AC_DEFINE([OPSYS], [RELIC_NONE], [Detected operation system.]) - ;; -esac - -case $host in - *darwin*) - dnl Relic: Don't define FP_QNRES on Darwin - AC_DEFINE([SEED], [UDEV], [Chosen random generator seeder.]) - ;; - *mingw*) - AC_DEFINE([FP_QNRES], [], [Use -1 as quadratic non-residue.]) - AC_DEFINE([SEED], [WCGR], [Chosen random generator seeder.]) - ;; - *) - AC_DEFINE([FP_QNRES], [], [Use -1 as quadratic non-residue.]) - AC_DEFINE([SEED], [UDEV], [Chosen random generator seeder.]) - ;; -esac - -if test x$use_pkgconfig = xyes; then - m4_ifndef([PKG_PROG_PKG_CONFIG], [AC_MSG_ERROR(PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh.)]) - m4_ifdef([PKG_PROG_PKG_CONFIG], [ - PKG_PROG_PKG_CONFIG - if test x"$PKG_CONFIG" = "x"; then - AC_MSG_ERROR(pkg-config not found.) - fi - ]) -fi - -saved_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -pipe" -AC_MSG_CHECKING([if ${CC} supports -pipe]) -AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], - [ AC_MSG_RESULT([yes]) ], - [ AC_MSG_RESULT([no]) - CFLAGS="$saved_CFLAGS" - ]) - -saved_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -fomit-frame-pointer" -AC_MSG_CHECKING([if ${CC} supports -fomit-frame-pointer]) -AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], - [ AC_MSG_RESULT([yes]) ], - [ AC_MSG_RESULT([no]) - CFLAGS="$saved_CFLAGS" - ]) - -if test x"$CFLAGS_overridden" = x"no" -a x"$CXXFLAGS_overridden" = x"no"; then - dnl Enable warnings - AX_CHECK_COMPILE_FLAG([-Wall],[WARN_FLAGS="$WARN_FLAGS -Wall"], [], [[$FLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wcast-align],[WARN_FLAGS="$WARN_FLAGS -Wcast-align"], [], [[$FLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wextra],[WARN_FLAGS="$WARN_FLAGS -Wextra"], [], [[$FLAG_WERROR]]) - - dnl Exclude known warnings - AX_CHECK_COMPILE_FLAG([-Wlong-long],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-long-long"], [], [[$FLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wshadow],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-shadow"], [], [[$FLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wsign-compare],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-sign-compare"], [], [[$FLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-strict-prototypes"], [], [[$FLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wunused-function],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-unused-function"], [], [[$FLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[NOWARN_FLAGS="$NOWARN_FLAGS -Wno-unused-parameter"], [], [[$FLAG_WERROR]]) -fi - -dnl set default settings for relic -AC_DEFINE([ALIGN], [1], [Byte boundary to align digit vectors.]) - -AC_DEFINE(WITH_BN,, Build multiple precision integer module.) -AC_DEFINE(WITH_DV,, Temporary double-precision digit vectors.) -AC_DEFINE(WITH_FP,, Build prime field module.) -AC_DEFINE(WITH_FPX,, Build prime field extension module.) -AC_DEFINE(WITH_FB,, Build binary field module.) -AC_DEFINE(WITH_FBX,, Build binary field extension module.) -AC_DEFINE(WITH_EP,, Build prime elliptic curve module.) -AC_DEFINE(WITH_EPX,, Build prime field extension elliptic curve module.) -AC_DEFINE(WITH_EB,, Build binary elliptic curve module.) -AC_DEFINE(WITH_ED,, Build elliptic Edwards curve module.) -AC_DEFINE(WITH_EC,, Build elliptic curve cryptography module.) -AC_DEFINE(WITH_PP,, Build pairings over prime curves module.) -AC_DEFINE(WITH_PC,, Build pairing-based cryptography module.) -AC_DEFINE(WITH_BC,, Build block ciphers.) -AC_DEFINE(WITH_MD,, Build hash functions.) -AC_DEFINE(WITH_CP,, Build cryptographic protocols.) -AC_DEFINE(WITH_MPC,, Build Multi-party computation primitives.) - -AC_DEFINE(BN_PRECI, 1024, Required precision in bits.) -AC_DEFINE(BN_KARAT, 0, Number of Karatsuba steps.) -AC_DEFINE(BN_MAGNI, [DOUBLE], Effective size of a multiple precision integer.) - -AC_DEFINE(BN_METHD, "COMBA;COMBA;MONTY;SLIDE;BASIC;BASIC", Multiple precision arithmetic method.) -AC_DEFINE(BN_MUL, COMBA, Chosen multiple precision multiplication method.) -AC_DEFINE(BN_SQR, COMBA, Chosen multiple precision multiplication method.) -AC_DEFINE(BN_MOD, MONTY, Chosen multiple precision modular reduction method.) -AC_DEFINE(BN_MXP, SLIDE, Chosen multiple precision modular exponentiation method.) -AC_DEFINE(BN_GCD, BASIC, Chosen multiple precision greatest common divisor method.) -AC_DEFINE(BN_GEN, BASIC, Chosen prime generation algorithm.) - -AC_DEFINE(FP_PRIME, 381, Prime field size in bits.) -AC_DEFINE(FP_METHD, "INTEG;INTEG;INTEG;MONTY;LOWER;SLIDE", Prime field arithmetic method.) -AC_DEFINE(FP_KARAT, 0, Number of Karatsuba steps.) -AC_DEFINE(FP_WIDTH, 4, Width of window processing for exponentiation methods.) -AC_DEFINE(FP_ADD, INTEG, Chosen prime field multiplication method.) -AC_DEFINE(FP_MUL, INTEG, Chosen prime field multiplication method.) -AC_DEFINE(FP_SQR, INTEG, Chosen prime field multiplication method.) -AC_DEFINE(FP_RDC, MONTY, Chosen prime field reduction method.) -AC_DEFINE(FP_INV, LOWER, Chosen prime field inversion method.) -AC_DEFINE(FP_EXP, SLIDE, Chosen multiple precision modular exponentiation method.) - -AC_DEFINE(FPX_METHD, "INTEG;INTEG;LAZYR", Prime extension field arithmetic method.) -AC_DEFINE(FPX_QDR, INTEG, Chosen extension field arithmetic method.) -AC_DEFINE(FPX_CBC, INTEG, Chosen extension field arithmetic method.) -AC_DEFINE(FPX_RDC, LAZYR, Chosen extension field arithmetic method.) - -AC_DEFINE(FB_METHD, "LODAH;QUICK;QUICK;QUICK;QUICK;QUICK;EXGCD;SLIDE;QUICK", Binary field arithmetic method) -AC_DEFINE(FB_POLYN, 283, Irreducible polynomial size in bits.) -AC_DEFINE(FB_KARAT, 0, Number of Karatsuba levels.) -AC_DEFINE(FB_TRINO,, Prefer trinomials over pentanomials.) -AC_DEFINE(FB_PRECO,, Precompute multiplication table for sqrt(z).) -AC_DEFINE(FB_WIDTH, 4, Width of window processing for exponentiation methods.) -AC_DEFINE(FB_MUL, LODAH, Chosen binary field multiplication method.) -AC_DEFINE(FB_SQR, QUICK, Chosen binary field squaring method.) -AC_DEFINE(FB_RDC, QUICK, Chosen binary field modular reduction method.) -AC_DEFINE(FB_SRT, QUICK, Chosen binary field modular reduction method.) -AC_DEFINE(FB_TRC, QUICK, Chosen trace computation method.) -AC_DEFINE(FB_SLV, QUICK, Chosen method to solve a quadratic equation.) -AC_DEFINE(FB_INV, EXGCD, Chosen binary field inversion method.) -AC_DEFINE(FB_EXP, SLIDE, Chosen multiple precision modular exponentiation method.) -AC_DEFINE(FB_ITR, QUICK, Chosen method to solve a quadratic equation.) - -AC_DEFINE(EP_METHD, "PROJC;LWNAF;COMBS;INTER", Prime elliptic curve arithmetic method.) -AC_DEFINE(EP_ENDOM,, Support for prime curves with efficient endormorphisms.) -AC_DEFINE(EP_MIXED,, Use mixed coordinates.) -AC_DEFINE(EP_PRECO,, Build precomputation table for generator.) -AC_DEFINE(EP_CTMAP,, Enable isogeny map for SSWU map-to-curve.) -AC_DEFINE(EP_DEPTH, 4, Width of precomputation table for fixed point methods.) -AC_DEFINE(EP_WIDTH, 4, Width of window processing for unknown point methods.) -AC_DEFINE(EP_ADD, PROJC, Chosen prime elliptic curve coordinate method.) -AC_DEFINE(EP_MUL, LWNAF, Chosen prime elliptic curve point multiplication method.) -AC_DEFINE(EP_FIX, COMBS, Chosen prime elliptic curve point multiplication method.) -AC_DEFINE(EP_SIM, INTER, Chosen prime elliptic curve simulteanous point multiplication method.) - -AC_DEFINE(EB_METHD, "PROJC;LWNAF;COMBS;INTER", Binary elliptic curve arithmetic method.) -AC_DEFINE(EB_PLAIN,, Support for ordinary curves without endormorphisms.) -AC_DEFINE(EB_KBLTZ,, Support for Koblitz anomalous binary curves.) -AC_DEFINE(EB_MIXED,, Use mixed coordinates.) -AC_DEFINE(EB_PRECO,, Build precomputation table for generator.) -AC_DEFINE(EB_DEPTH, 4, Width of precomputation table for fixed point methods.) -AC_DEFINE(EB_WIDTH, 4, Width of window processing for unknown point methods.) -AC_DEFINE(EB_ADD, PROJC, Chosen binary elliptic curve coordinate method.) -AC_DEFINE(EB_MUL, LWNAF, Chosen binary elliptic curve point multiplication method.) -AC_DEFINE(EB_FIX, COMBS, Chosen binary elliptic curve point multiplication method.) -AC_DEFINE(EB_SIM, INTER, Chosen binary elliptic curve simulteanous point multiplication method.) - -AC_DEFINE(ED_METHD, "PROJC;LWNAF;COMBS;INTER", Edwards elliptic curve arithmetic method.) -AC_DEFINE(ED_PRECO,, Build precomputation table for generator.) -AC_DEFINE(ED_DEPTH, 4, Width of precomputation table for fixed point methods.) -AC_DEFINE(ED_WIDTH, 4, Width of window processing for unknown point methods.) -AC_DEFINE(ED_ADD, PROJC, Chosen binary elliptic curve coordinate method.) -AC_DEFINE(ED_MUL, LWNAF, Chosen prime elliptic twisted Edwards curve point multiplication method.) -AC_DEFINE(ED_FIX, COMBS, Chosen prime elliptic twisted Edwards curve point multiplication method.) -AC_DEFINE(ED_SIM, INTER, Chosen prime elliptic curve simulteanous point multiplication method.) - -AC_DEFINE(EC_METHD, "PRIME", Chosen elliptic curve cryptography method.) -AC_DEFINE(EC_CUR, PRIME, Chosen elliptic curve type.) - -AC_DEFINE(PP_METHD, "LAZYR;OATEP", Bilinear pairing method.) -AC_DEFINE(PP_EXT, LAZYR, Chosen extension field arithmetic method.) -AC_DEFINE(PP_MAP, OATEP, Chosen pairing method over prime elliptic curves.) - -AC_DEFINE(MD_METHD, "SH256", Choice of hash function.) -AC_DEFINE(MD_MAP, SH256, Chosen hash function.) - -AC_DEFINE(CP_CRT,, Support for faster CRT-based exponentiation in factoring-based cryptosystems.) -AC_DEFINE(CP_RSAPD, PKCS2, Chosen RSA padding method.) - -AC_DEFINE(ALLOC, AUTO, Chosen memory allocation policy.) -AC_DEFINE(RAND, HASHD, Chosen random generator.) -AC_DEFINE(MULTI, PTHREAD, Chosen multithreading API.) -AC_DEFINE(TIMER, CYCLE, Chosen timer.) - -dnl Check for pthread compile/link requirements -AX_PTHREAD - -AC_SEARCH_LIBS([clock_gettime],[rt]) - -if test "$TARGET_OS" != "windows"; then - dnl All windows code is PIC, forcing it on just adds useless compile warnings - AX_CHECK_COMPILE_FLAG([-fPIC], [HARDENED_FLAGS="$HARDENED_FLAGS -fPIC"], [], [[$FLAG_WERROR]]) -fi - -dnl All versions of gcc that we commonly use for building are subject to bug -dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348. To work around that, set -dnl -fstack-reuse=none for all gcc builds. (Only gcc understands this flag) -AX_CHECK_COMPILE_FLAG([-fstack-reuse=none], [HARDENED_FLAGS="$HARDENED_FLAGS -fstack-reuse=none"], [], [[$FLAG_WERROR]]) -if test "$use_hardening" != "no"; then - use_hardening=yes - AX_CHECK_COMPILE_FLAG([-Wstack-protector], [HARDENED_FLAGS="$HARDENED_FLAGS -Wstack-protector"]) - AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [HARDENED_FLAGS="$HARDENED_FLAGS -fstack-protector-all"], [], [[$FLAG_WERROR]]) - - AX_CHECK_COMPILE_FLAG([-fcf-protection=full], [HARDENED_FLAGS="$HARDENED_FLAGS -fcf-protection=full"], [], [[$FLAG_WERROR]]) - - case $host in - *mingw*) - dnl stack-clash-protection doesn't currently work, and likely should just be skipped for Windows. - dnl See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458 for more details. - ;; - *) - AX_CHECK_COMPILE_FLAG([-fstack-clash-protection], [HARDENED_FLAGS="$HARDENED_FLAGS -fstack-clash-protection"], [], [[$FLAG_WERROR]]) - ;; - esac - - case $host in - *aarch64*) - AX_CHECK_COMPILE_FLAG([-mbranch-protection=bti], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -mbranch-protection=bti"], [], [[$CXXFLAG_WERROR]]) - ;; - esac - - AX_CHECK_LINK_FLAG([-Wl,--enable-reloc-section], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--enable-reloc-section"], [], []) - AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"], [], []) - AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"], [], []) - AX_CHECK_LINK_FLAG([-Wl,--high-entropy-va], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"], [], []) - AX_CHECK_LINK_FLAG([-Wl,-z,relro], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"], [], []) - AX_CHECK_LINK_FLAG([-Wl,-z,now], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"], [], []) - AX_CHECK_LINK_FLAG([-Wl,-z,separate-code], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,separate-code"], [], []) - AX_CHECK_LINK_FLAG([-fPIE -pie], [HARDENED_FLAGS="$HARDENED_FLAGS -fPIE"; HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"], [], []) -fi - -CORE_CPPFLAGS="$CORE_CPPFLAGS -DHAVE_BUILD_INFO" - -case $host in - *mingw*) - AC_CHECK_LIB([user32], [main], [], [AC_MSG_ERROR([libuser32 missing])]) - AC_CHECK_LIB([shell32], [SHGetSpecialFolderPathW], [], [AC_MSG_ERROR([libshell32 missing])]) - AC_CHECK_LIB([advapi32], [CryptAcquireContextW], [], [AC_MSG_ERROR([libadvapi32 missing])]) - AC_CHECK_LIB([psapi], [GetProcessMemoryInfo], [], [AC_MSG_ERROR([libpsapi missing])]) - AC_CHECK_LIB([bcrypt], [main], [], [AC_MSG_ERROR([libbcrypt missing])]) - - dnl -static is interpreted by libtool, where it has a different meaning. - dnl In libtool-speak, it's -all-static. - AX_CHECK_LINK_FLAG([-static], [LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"]) - - CORE_CPPFLAGS="$CORE_CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN" - dnl Prevent the definition of min/max macros. - dnl We always want to use the standard library. - CORE_CPPFLAGS="$CORE_CPPFLAGS -DNOMINMAX" - - dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against. - dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override - dnl its command here, with the predeps/postdeps removed, and -static inserted. Postdeps are - dnl also overridden to prevent their insertion later. - dnl This should only affect dll's. - archive_cmds_CXX="\$CC -shared \$libobjs \$deplibs \$compiler_flags -static -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib" - postdeps_CXX= - - dnl We require Windows 7 (NT 6.1) or later - AX_CHECK_LINK_FLAG([-Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1"], [], []) - ;; - *darwin*) - AX_CHECK_LINK_FLAG([-Wl,-headerpad_max_install_names], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-headerpad_max_install_names"], [], []) - CORE_CPPFLAGS="$CORE_CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0" - OBJCXXFLAGS="$CXXFLAGS" - ;; -esac - -dnl These flags are specific to ld64, and may cause issues with other linkers. -dnl For example: GNU ld will interpret -dead_strip as -de and then try and use -dnl "ad_strip" as the symbol for the entry point. -if test "$TARGET_OS" = "darwin"; then - AX_CHECK_LINK_FLAG([-Wl,-dead_strip], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip"], [], []) - AX_CHECK_LINK_FLAG([-Wl,-dead_strip_dylibs], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip_dylibs"], [], []) - AX_CHECK_LINK_FLAG([-Wl,-bind_at_load], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-bind_at_load"], [], []) -fi - -dnl Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review. -AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers], [CORE_FLAGS="$CORE_FLAGS -fno-extended-identifiers"], [], [[$FLAG_WERROR]]) - -AC_LANG_POP([C]) - -AC_MSG_CHECKING([whether to build runtest]) -if test x$use_tests = xyes; then - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi - -AC_MSG_CHECKING([whether to build runbench]) -if test x$use_bench = xyes; then - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi - -AM_CONDITIONAL([TARGET_DARWIN], [test "$TARGET_OS" = "darwin"]) -AM_CONDITIONAL([TARGET_LINUX], [test "$TARGET_OS" = "linux"]) -AM_CONDITIONAL([TARGET_WINDOWS], [test "$TARGET_OS" = "windows"]) - -AM_CONDITIONAL(WITH_BN, test 1 -eq 1) -AM_CONDITIONAL(WITH_FP, test 1 -eq 1) -AM_CONDITIONAL(WITH_FPX, test 1 -eq 1) -AM_CONDITIONAL(WITH_FB, test 1 -eq 1) -AM_CONDITIONAL(WITH_EP, test 1 -eq 1) -AM_CONDITIONAL(WITH_EPX, test 1 -eq 1) -AM_CONDITIONAL(WITH_EB, test 1 -eq 1) -AM_CONDITIONAL(WITH_ED, test 1 -eq 1) -AM_CONDITIONAL(WITH_EC, test 1 -eq 1) -AM_CONDITIONAL(WITH_PP, test 1 -eq 1) -AM_CONDITIONAL(WITH_PC, test 1 -eq 1) -AM_CONDITIONAL(WITH_BC, test 1 -eq 1) -AM_CONDITIONAL(WITH_MD, test 1 -eq 1) -AM_CONDITIONAL(WITH_CP, test 1 -eq 1) -AM_CONDITIONAL(WITH_MPC, test 1 -eq 1) -AM_CONDITIONAL(WITH_DV, test 1 -eq 1) -AM_CONDITIONAL(WITH_FBX, test 1 -eq 1) - -AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" = x"yes"]) -AM_CONDITIONAL([USE_BENCH], [test x"$use_bench" = x"yes"]) -AM_CONDITIONAL([HARDEN], [test "$use_hardening" = "yes"]) -AM_CONDITIONAL([OPTIMIZE], [test "$use_optimizations" = "yes"]) - -AM_CONDITIONAL([ARITH_EASY], [test "$want_backend" = "easy"]) -AM_CONDITIONAL([ARITH_GMP], [test "$want_backend" = "gmp"]) - -AC_SUBST(CPU_ARCH) -AC_SUBST(DEBUG_FLAGS) -AC_SUBST(RAND_PATH, hashd) -AC_SUBST(RELIC_CPPFLAGS) -AC_SUBST(WARN_FLAGS) -AC_SUBST(NOWARN_FLAGS) -AC_SUBST(LIBTOOL_APP_LDFLAGS) -AC_SUBST(HARDENED_FLAGS) -AC_SUBST(HARDENED_LDFLAGS) -AC_SUBST(CORE_LDFLAGS) -AC_SUBST(CORE_CPPFLAGS) -AC_SUBST(CORE_FLAGS) - -AC_SUBST(GMP_LDFLAGS) -AC_SUBST(GMP_CPPFLAGS) -AC_SUBST(GMP_LIBS) - -AC_CONFIG_HEADERS([depends/relic/include/relic_conf.h]) -AC_CONFIG_FILES([Makefile]) - -AC_OUTPUT - -dnl Peplace conflict-prone PACKAGE-prefixed macros with DASHBLS -sed -i.old 's/PACKAGE/DASHBLS/g' depends/relic/include/relic_conf.h -sed -i.old 's/PACKAGE/DASHBLS/g' config.status - -echo -echo "Options used to compile and link:" -echo " target os = $TARGET_OS" -echo " backend = $want_backend" -echo " build bench = $use_tests" -echo " build test = $use_bench" -echo " use debug = $use_debug" -echo " use hardening = $use_hardening" -echo " use optimizations = $use_optimizations" -echo -echo " LDFLAGS = $HARDENED_LDFLAGS $CORE_LDFLAGS $GMP_LDFLAGS" -echo " CFLAGS = $DEBUG_FLAGS $HARDENED_FLAGS $CORE_FLAGS $WARN_FLAGS $NOWARN_FLAGS" -echo " CPPFLAGS = $CORE_CPPFLAGS $GMP_CPPFLAGS" -echo " CXXFLAGS = $DEBUG_FLAGS $HARDENED_FLAGS $CORE_FLAGS $WARN_FLAGS $NOWARN_FLAGS" -echo " PTHREAD_FLAGS = $PTHREAD_CFLAGS $PTHREAD_LIBS" -echo diff --git a/src/dashbls/depends/catch2/CMakeLists.txt b/src/dashbls/depends/catch2/CMakeLists.txt deleted file mode 100644 index 8c26a03af581..000000000000 --- a/src/dashbls/depends/catch2/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.14.0 FATAL_ERROR) - -set(PROJECT_NAME "catch2") - -project( - ${PROJECT_NAME} - VERSION 2.13 - LANGUAGES CXX -) - -set( - ${PROJECT_NAME}_HEADERS - catch2/catch.hpp -) - -list( - TRANSFORM ${PROJECT_NAME}_HEADERS - PREPEND "${CMAKE_CURRENT_LIST_DIR}/include/" -) - -add_library( - ${PROJECT_NAME} - INTERFACE -) - -target_sources( - ${PROJECT_NAME} - INTERFACE - "${${PROJECT_NAME}_HEADERS}" -) - -target_include_directories( - ${PROJECT_NAME} - INTERFACE - "$" - "$" -) diff --git a/src/dashbls/depends/catch2/include/catch2/catch.hpp b/src/dashbls/depends/catch2/include/catch2/catch.hpp deleted file mode 100644 index 9b309bddc6bc..000000000000 --- a/src/dashbls/depends/catch2/include/catch2/catch.hpp +++ /dev/null @@ -1,17976 +0,0 @@ -/* - * Catch v2.13.10 - * Generated: 2022-10-16 11:01:23.452308 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2022 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -// start catch.hpp - - -#define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 13 -#define CATCH_VERSION_PATCH 10 - -#ifdef __clang__ -# pragma clang system_header -#elif defined __GNUC__ -# pragma GCC system_header -#endif - -// start catch_suppress_warnings.h - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif -#elif defined __GNUC__ - // Because REQUIREs trigger GCC's -Wparentheses, and because still - // supported version of g++ have only buggy support for _Pragmas, - // Wparentheses have to be suppressed globally. -# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details - -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic ignored "-Wpadded" -#endif -// end catch_suppress_warnings.h -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL -# define CATCH_CONFIG_ALL_PARTS -#endif - -// In the impl file, we want to have access to all parts of the headers -// Can also be used to sanely support PCHs -#if defined(CATCH_CONFIG_ALL_PARTS) -# define CATCH_CONFIG_EXTERNAL_INTERFACES -# if defined(CATCH_CONFIG_DISABLE_MATCHERS) -# undef CATCH_CONFIG_DISABLE_MATCHERS -# endif -# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) -# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -# endif -#endif - -#if !defined(CATCH_CONFIG_IMPL_ONLY) -// start catch_platform.h - -// See e.g.: -// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html -#ifdef __APPLE__ -# include -# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ - (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) -# define CATCH_PLATFORM_MAC -# elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) -# define CATCH_PLATFORM_IPHONE -# endif - -#elif defined(linux) || defined(__linux) || defined(__linux__) -# define CATCH_PLATFORM_LINUX - -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) -# define CATCH_PLATFORM_WINDOWS -#endif - -// end catch_platform.h - -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - -// start catch_user_interfaces.h - -namespace Catch { - unsigned int rngSeed(); -} - -// end catch_user_interfaces.h -// start catch_tag_alias_autoregistrar.h - -// start catch_common.h - -// start catch_compiler_capabilities.h - -// Detect a number of compiler features - by compiler -// The following features are defined: -// -// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? -// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? -// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? -// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? -// **************** -// Note to maintainers: if new toggles are added please document them -// in configuration.md, too -// **************** - -// In general each macro has a _NO_ form -// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -#ifdef __cplusplus - -# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -# define CATCH_CPP14_OR_GREATER -# endif - -# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define CATCH_CPP17_OR_GREATER -# endif - -#endif - -// Only GCC compiler should be used in this block, so other compilers trying to -// mask themselves as GCC should be ignored. -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) - -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) - -#endif - -#if defined(__clang__) - -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) - -// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug -// which results in calls to destructors being emitted for each temporary, -// without a matching initialization. In practice, this can result in something -// like `std::string::~string` being called on an uninitialized value. -// -// For example, this code will likely segfault under IBM XL: -// ``` -// REQUIRE(std::string("12") + "34" == "1234") -// ``` -// -// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. -# if !defined(__ibmxl__) && !defined(__CUDACC__) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ -# endif - -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ - _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") - -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) - -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// Assume that non-Windows platforms support posix signals by default -#if !defined(CATCH_PLATFORM_WINDOWS) - #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS -#endif - -//////////////////////////////////////////////////////////////////////////////// -// We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) - #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -#endif - -#ifdef __OS400__ -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -# define CATCH_CONFIG_COLOUR_NONE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Android somehow still does not support std::to_string -#if defined(__ANDROID__) -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING -# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Not all Windows environments support SEH properly -#if defined(__MINGW32__) -# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH -#endif - -//////////////////////////////////////////////////////////////////////////////// -// PS4 -#if defined(__ORBIS__) -# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Cygwin -#ifdef __CYGWIN__ - -// Required for some versions of Cygwin to declare gettimeofday -// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin -# define _BSD_SOURCE -// some versions of cygwin (most) do not support std::to_string. Use the libstd check. -// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 -# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ - && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) - -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING - -# endif -#endif // __CYGWIN__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#if defined(_MSC_VER) - -// Universal Windows platform does not support SEH -// Or console colours (or console at all...) -# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) -# define CATCH_CONFIG_COLOUR_NONE -# else -# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH -# endif - -# if !defined(__clang__) // Handle Clang masquerading for msvc - -// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ -// _MSVC_TRADITIONAL == 0 means new conformant preprocessor -// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor -# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) -# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -# endif // MSVC_TRADITIONAL - -// Only do this if we're not using clang on Windows, which uses `diagnostic push` & `diagnostic pop` -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) -# endif // __clang__ - -#endif // _MSC_VER - -#if defined(_REENTRANT) || defined(_MSC_VER) -// Enable async processing, as -pthread is specified or no additional linking is required -# define CATCH_INTERNAL_CONFIG_USE_ASYNC -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// -// Check if we are compiled with -fno-exceptions or equivalent -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) -# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED -#endif - -//////////////////////////////////////////////////////////////////////////////// -// DJGPP -#ifdef __DJGPP__ -# define CATCH_INTERNAL_CONFIG_NO_WCHAR -#endif // __DJGPP__ - -//////////////////////////////////////////////////////////////////////////////// -// Embarcadero C++Build -#if defined(__BORLANDC__) - #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// Use of __COUNTER__ is suppressed during code analysis in -// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly -// handled by it. -// Otherwise all supported compilers support COUNTER macro, -// but user still might want to turn it off -#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) - #define CATCH_INTERNAL_CONFIG_COUNTER -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// RTX is a special version of Windows that is real time. -// This means that it is detected as Windows, but does not provide -// the same set of capabilities as real Windows does. -#if defined(UNDER_RTSS) || defined(RTX64_BUILD) - #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH - #define CATCH_INTERNAL_CONFIG_NO_ASYNC - #define CATCH_CONFIG_COLOUR_NONE -#endif - -#if !defined(_GLIBCXX_USE_C99_MATH_TR1) -#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Various stdlib support checks that require __has_include -#if defined(__has_include) - // Check if string_view is available and usable - #if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW - #endif - - // Check if optional is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if byte is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # include - # if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0) - # define CATCH_INTERNAL_CONFIG_CPP17_BYTE - # endif - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if variant is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # if defined(__clang__) && (__clang_major__ < 8) - // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 - // fix should be in clang 8, workaround in libstdc++ 8.2 - # include - # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # define CATCH_CONFIG_NO_CPP17_VARIANT - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__clang__) && (__clang_major__ < 8) - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // defined(__has_include) - -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) -# define CATCH_CONFIG_COUNTER -#endif -#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) -# define CATCH_CONFIG_WINDOWS_SEH -#endif -// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. -#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_CONFIG_POSIX_SIGNALS -#endif -// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. -#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) -# define CATCH_CONFIG_WCHAR -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) -# define CATCH_CONFIG_CPP11_TO_STRING -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) -# define CATCH_CONFIG_CPP17_OPTIONAL -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) -# define CATCH_CONFIG_CPP17_STRING_VIEW -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) -# define CATCH_CONFIG_CPP17_VARIANT -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) -# define CATCH_CONFIG_CPP17_BYTE -#endif - -#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) -# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) -# define CATCH_CONFIG_NEW_CAPTURE -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -# define CATCH_CONFIG_DISABLE_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) -# define CATCH_CONFIG_POLYFILL_ISNAN -#endif - -#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) -# define CATCH_CONFIG_USE_ASYNC -#endif - -#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) -# define CATCH_CONFIG_ANDROID_LOGWRITE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) -# define CATCH_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Even if we do not think the compiler has that warning, we still have -// to provide a macro that can be used by the code. -#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS -#endif - -// The goal of this macro is to avoid evaluation of the arguments, but -// still have the compiler warn on problems inside... -#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) -#endif - -#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#elif defined(__clang__) && (__clang_major__ < 5) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -#define CATCH_TRY if ((true)) -#define CATCH_CATCH_ALL if ((false)) -#define CATCH_CATCH_ANON(type) if ((false)) -#else -#define CATCH_TRY try -#define CATCH_CATCH_ALL catch (...) -#define CATCH_CATCH_ANON(type) catch (type) -#endif - -#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) -#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#endif - -// end catch_compiler_capabilities.h -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif - -#include -#include -#include - -// We need a dummy global operator<< so we can bring it into Catch namespace later -struct Catch_global_namespace_dummy {}; -std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); - -namespace Catch { - - struct CaseSensitive { enum Choice { - Yes, - No - }; }; - - class NonCopyable { - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; - - protected: - NonCopyable(); - virtual ~NonCopyable(); - }; - - struct SourceLineInfo { - - SourceLineInfo() = delete; - SourceLineInfo( char const* _file, std::size_t _line ) noexcept - : file( _file ), - line( _line ) - {} - - SourceLineInfo( SourceLineInfo const& other ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo( SourceLineInfo&& ) noexcept = default; - SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; - - bool empty() const noexcept { return file[0] == '\0'; } - bool operator == ( SourceLineInfo const& other ) const noexcept; - bool operator < ( SourceLineInfo const& other ) const noexcept; - - char const* file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // Bring in operator<< from global namespace into Catch namespace - // This is necessary because the overload of operator<< above makes - // lookup stop at namespace Catch - using ::operator<<; - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() const; - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } -} - -#define CATCH_INTERNAL_LINEINFO \ - ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) - -// end catch_common.h -namespace Catch { - - struct RegistrarForTagAliases { - RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - }; - -} // end namespace Catch - -#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - -// end catch_tag_alias_autoregistrar.h -// start catch_test_registry.h - -// start catch_interfaces_testcase.h - -#include - -namespace Catch { - - class TestSpec; - - struct ITestInvoker { - virtual void invoke () const = 0; - virtual ~ITestInvoker(); - }; - - class TestCase; - struct IConfig; - - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; - - bool isThrowSafe( TestCase const& testCase, IConfig const& config ); - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - -} - -// end catch_interfaces_testcase.h -// start catch_stringref.h - -#include -#include -#include -#include - -namespace Catch { - - /// A non-owning string class (similar to the forthcoming std::string_view) - /// Note that, because a StringRef may be a substring of another string, - /// it may not be null terminated. - class StringRef { - public: - using size_type = std::size_t; - using const_iterator = const char*; - - private: - static constexpr char const* const s_empty = ""; - - char const* m_start = s_empty; - size_type m_size = 0; - - public: // construction - constexpr StringRef() noexcept = default; - - StringRef( char const* rawChars ) noexcept; - - constexpr StringRef( char const* rawChars, size_type size ) noexcept - : m_start( rawChars ), - m_size( size ) - {} - - StringRef( std::string const& stdString ) noexcept - : m_start( stdString.c_str() ), - m_size( stdString.size() ) - {} - - explicit operator std::string() const { - return std::string(m_start, m_size); - } - - public: // operators - auto operator == ( StringRef const& other ) const noexcept -> bool; - auto operator != (StringRef const& other) const noexcept -> bool { - return !(*this == other); - } - - auto operator[] ( size_type index ) const noexcept -> char { - assert(index < m_size); - return m_start[index]; - } - - public: // named queries - constexpr auto empty() const noexcept -> bool { - return m_size == 0; - } - constexpr auto size() const noexcept -> size_type { - return m_size; - } - - // Returns the current start pointer. If the StringRef is not - // null-terminated, throws std::domain_exception - auto c_str() const -> char const*; - - public: // substrings and searches - // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, size()). - // If start > size(), then the substring is empty. - auto substr( size_type start, size_type length ) const noexcept -> StringRef; - - // Returns the current start pointer. May not be null-terminated. - auto data() const noexcept -> char const*; - - constexpr auto isNullTerminated() const noexcept -> bool { - return m_start[m_size] == '\0'; - } - - public: // iterators - constexpr const_iterator begin() const { return m_start; } - constexpr const_iterator end() const { return m_start + m_size; } - }; - - auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; - auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; - - constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { - return StringRef( rawChars, size ); - } -} // namespace Catch - -constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { - return Catch::StringRef( rawChars, size ); -} - -// end catch_stringref.h -// start catch_preprocessor.hpp - - -#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ -#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) - -#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ -// MSVC needs more evaluations -#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) -#else -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) -#endif - -#define CATCH_REC_END(...) -#define CATCH_REC_OUT - -#define CATCH_EMPTY() -#define CATCH_DEFER(id) id CATCH_EMPTY() - -#define CATCH_REC_GET_END2() 0, CATCH_REC_END -#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 -#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 -#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT -#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) -#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) - -#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) - -#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) - -// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, -// and passes userdata as the first parameter to each invocation, -// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) -#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) -#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ -#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ -#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) -#else -// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) -#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) -#endif - -#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ -#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) - -#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) - -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) -#else -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) -#endif - -#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ - CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) - -#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) -#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) -#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) -#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) -#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) -#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) -#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) -#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) -#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) -#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) -#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) - -#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N - -#define INTERNAL_CATCH_TYPE_GEN\ - template struct TypeList {};\ - template\ - constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ - template class...> struct TemplateTypeList{};\ - template class...Cs>\ - constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ - template\ - struct append;\ - template\ - struct rewrap;\ - template class, typename...>\ - struct create;\ - template class, typename>\ - struct convert;\ - \ - template \ - struct append { using type = T; };\ - template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ - struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ - template< template class L1, typename...E1, typename...Rest>\ - struct append, TypeList, Rest...> { using type = L1; };\ - \ - template< template class Container, template class List, typename...elems>\ - struct rewrap, List> { using type = TypeList>; };\ - template< template class Container, template class List, class...Elems, typename...Elements>\ - struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ - \ - template