From d8dc5e0fa4ab27c60a3cf6bc2c715770149455f0 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Fri, 12 Jul 2024 21:40:17 +0000 Subject: [PATCH 001/162] Add FreeBSD build support --- depends/Makefile | 2 + depends/builders/freebsd.mk | 2 + depends/hosts/freebsd.mk | 31 ++++++++ depends/packages/bdb.mk | 1 + depends/packages/boost.mk | 7 +- depends/packages/googletest.mk | 1 + depends/packages/libevent.mk | 4 + depends/packages/openssl.mk | 3 + depends/packages/rust.mk | 6 +- depends/packages/zeromq.mk | 1 + .../detect-arch4random_addrandom-fix.patch | 43 +++++++++++ .../detect-arch4random_addrandom.patch | 77 +++++++++++++++++++ 12 files changed, 173 insertions(+), 5 deletions(-) create mode 100644 depends/builders/freebsd.mk create mode 100644 depends/hosts/freebsd.mk create mode 100644 depends/patches/libevent/detect-arch4random_addrandom-fix.patch create mode 100644 depends/patches/libevent/detect-arch4random_addrandom.patch diff --git a/depends/Makefile b/depends/Makefile index aa07755f0..ec5b77b92 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -38,6 +38,7 @@ build_vendor=$(word 2,$(subst -, ,$(build))) full_build_os:=$(subst $(build_arch)-$(build_vendor)-,,$(build)) build_os:=$(findstring linux,$(full_build_os)) build_os+=$(findstring darwin,$(full_build_os)) +build_os+=$(findstring freebsd,$(full_build_os)) build_os:=$(strip $(build_os)) ifeq ($(build_os),) build_os=$(full_build_os) @@ -48,6 +49,7 @@ host_vendor=$(word 2,$(subst -, ,$(canonical_host))) full_host_os:=$(subst $(host_arch)-$(host_vendor)-,,$(canonical_host)) host_os:=$(findstring linux,$(full_host_os)) host_os+=$(findstring darwin,$(full_host_os)) +host_os+=$(findstring freebsd,$(full_host_os)) host_os+=$(findstring mingw32,$(full_host_os)) host_os:=$(strip $(host_os)) ifeq ($(host_os),) diff --git a/depends/builders/freebsd.mk b/depends/builders/freebsd.mk new file mode 100644 index 000000000..fb2fefe2a --- /dev/null +++ b/depends/builders/freebsd.mk @@ -0,0 +1,2 @@ +build_freebsd_SHA256SUM = shasum -a 256 +build_freebsd_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o diff --git a/depends/hosts/freebsd.mk b/depends/hosts/freebsd.mk new file mode 100644 index 000000000..07436aef8 --- /dev/null +++ b/depends/hosts/freebsd.mk @@ -0,0 +1,31 @@ +freebsd_CFLAGS=-pipe +freebsd_CXXFLAGS=$(freebsd_CFLAGS) + +freebsd_release_CFLAGS=-O1 +freebsd_release_CXXFLAGS=$(freebsd_release_CFLAGS) + +freebsd_debug_CFLAGS=-O1 +freebsd_debug_CXXFLAGS=$(freebsd_debug_CFLAGS) + +freebsd_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC + +ifeq (86,$(findstring 86,$(build_arch))) +i686_freebsd_CC=gcc -m32 +i686_freebsd_CXX=g++ -m32 +i686_freebsd_AR=ar +i686_freebsd_RANLIB=ranlib +i686_freebsd_NM=nm +i686_freebsd_STRIP=strip + +x86_64_freebsd_CC=gcc -m64 +x86_64_freebsd_CXX=g++ -m64 +x86_64_freebsd_AR=ar +x86_64_freebsd_RANLIB=ranlib +x86_64_freebsd_NM=nm +x86_64_freebsd_STRIP=strip +else +i686_freebsd_CC=$(default_host_CC) -m32 +i686_freebsd_CXX=$(default_host_CXX) -m32 +x86_64_freebsd_CC=$(default_host_CC) -m64 +x86_64_freebsd_CXX=$(default_host_CXX) -m64 +endif diff --git a/depends/packages/bdb.mk b/depends/packages/bdb.mk index 21019aeb7..bb9074823 100644 --- a/depends/packages/bdb.mk +++ b/depends/packages/bdb.mk @@ -9,6 +9,7 @@ define $(package)_set_vars $(package)_config_opts=--disable-shared --enable-cxx --disable-replication $(package)_config_opts_mingw32=--enable-mingw $(package)_config_opts_linux=--with-pic +$(package)_config_opts_freebsd=--with-pic $(package)_config_opts_aarch64=--disable-atomicsupport $(package)_cxxflags=-std=c++11 endef diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index a5c90cece..1300dc1f6 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -7,7 +7,7 @@ $(package)_sha256_hash=430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00 define $(package)_set_vars $(package)_config_opts_release=variant=release $(package)_config_opts_debug=variant=debug -$(package)_config_opts=--layout=system --user-config=user-config.jam +$(package)_config_opts=--layout=system $(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1 $(package)_config_opts_linux=threadapi=pthread runtime-link=shared $(package)_config_opts_darwin=--toolset=darwin-4.2.1 runtime-link=shared @@ -22,14 +22,15 @@ $(package)_archiver_darwin=$($(package)_libtool) $(package)_config_libraries=chrono,filesystem,program_options,system,thread,test $(package)_cxxflags=-std=c++11 -fvisibility=hidden $(package)_cxxflags_linux=-fPIC +$(package)_cxxflags_freebsd=-fPIC endef define $(package)_preprocess_cmds - echo "using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : \"$($(package)_cxxflags) $($(package)_cppflags)\" \"$($(package)_ldflags)\" \"$(boost_archiver_$(host_os))\" \"$(host_STRIP)\" \"$(host_RANLIB)\" \"$(host_WINDRES)\" : ;" > user-config.jam endef define $(package)_config_cmds - ./bootstrap.sh --without-icu --with-libraries=$(boost_config_libraries) + ./bootstrap.sh --without-icu --with-toolset=$($(package)_toolset_$(host_os)) --with-libraries=$($(package)_config_libraries) && \ + sed -i -e "s|using gcc ;|using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : \"$($(package)_cxxflags) $($(package)_cppflags)\" \"$($(package)_ldflags)\" \"$(boost_archiver_$(host_os))\" \"$(host_STRIP)\" \"$(host_RANLIB)\" \"$(host_WINDRES)\" : ;|" project-config.jam endef define $(package)_build_cmds diff --git a/depends/packages/googletest.mk b/depends/packages/googletest.mk index ad42d5b9c..3e4a72fca 100644 --- a/depends/packages/googletest.mk +++ b/depends/packages/googletest.mk @@ -8,6 +8,7 @@ $(package)_sha256_hash=58a6f4277ca2bc8565222b3bbd58a177609e9c488e8a72649359ba514 define $(package)_set_vars $(package)_cxxflags+=-std=c++11 $(package)_cxxflags_linux=-fPIC +$(package)_cxxflags_freebsd=-fPIC endef define $(package)_build_cmds diff --git a/depends/packages/libevent.mk b/depends/packages/libevent.mk index 2a1125fda..7119176f2 100644 --- a/depends/packages/libevent.mk +++ b/depends/packages/libevent.mk @@ -4,8 +4,11 @@ $(package)_download_path=https://github.com/libevent/libevent/archive/ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_download_file=release-$($(package)_version)-stable.tar.gz $(package)_sha256_hash=316ddb401745ac5d222d7c529ef1eada12f58f6376a66c1118eee803cb70f83d +$(package)_patches=detect-arch4random_addrandom.patch detect-arch4random_addrandom-fix.patch define $(package)_preprocess_cmds + patch -p1 <$($(package)_patch_dir)/detect-arch4random_addrandom.patch && \ + patch -p1 <$($(package)_patch_dir)/detect-arch4random_addrandom-fix.patch && \ ./autogen.sh endef @@ -13,6 +16,7 @@ define $(package)_set_vars $(package)_config_opts=--disable-shared --disable-openssl --disable-libevent-regress $(package)_config_opts_release=--disable-debug-mode $(package)_config_opts_linux=--with-pic + $(package)_config_opts_freebsd=--with-pic endef define $(package)_config_cmds diff --git a/depends/packages/openssl.mk b/depends/packages/openssl.mk index a1d5439aa..f2d792bc1 100644 --- a/depends/packages/openssl.mk +++ b/depends/packages/openssl.mk @@ -80,6 +80,7 @@ $(package)_config_opts+=$($(package)_cflags) $($(package)_cppflags) $(package)_config_opts+=-DPURIFY $(package)_config_opts_linux=-fPIC -Wa,--noexecstack $(package)_config_opts_x86_64_linux=linux-x86_64 +$(package)_config_opts_freebsd=-fPIC -Wa,--noexecstack $(package)_config_opts_i686_linux=linux-generic32 $(package)_config_opts_arm_linux=linux-generic32 $(package)_config_opts_aarch64_linux=linux-generic64 @@ -87,6 +88,8 @@ $(package)_config_opts_mipsel_linux=linux-generic32 $(package)_config_opts_mips_linux=linux-generic32 $(package)_config_opts_powerpc_linux=linux-generic32 $(package)_config_opts_x86_64_darwin=darwin64-x86_64-cc +$(package)_config_opts_x86_64_freebsd=BSD-x86_64 +$(package)_config_opts_i686_freebsd=BSD-generic32 $(package)_config_opts_x86_64_mingw32=mingw64 $(package)_config_opts_i686_mingw32=mingw endef diff --git a/depends/packages/rust.mk b/depends/packages/rust.mk index b892d8b72..72f7778bd 100644 --- a/depends/packages/rust.mk +++ b/depends/packages/rust.mk @@ -5,6 +5,8 @@ $(package)_file_name_linux=rust-$($(package)_version)-x86_64-unknown-linux-gnu.t $(package)_sha256_hash_linux=e024698320d76b74daf0e6e71be3681a1e7923122e3ebd03673fcac3ecc23810 $(package)_file_name_darwin=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz $(package)_sha256_hash_darwin=f0dfba507192f9b5c330b5984ba71d57d434475f3d62bd44a39201e36fa76304 +$(package)_file_name_freebsd=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz +$(package)_sha256_hash_freebsd=20d062493d01f1816014fe9dbe883bda06f1828a6ddbfb7ee5e4f1df20eb1c3a # Mapping from GCC canonical hosts to Rust targets # If a mapping is not present, we assume they are identical @@ -38,12 +40,12 @@ define $(package)_extract_cmds endef define $(package)_stage_cmds - ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig && \ + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig && \ ../$(canonical_host)/install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig endef else define $(package)_stage_cmds - ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig endef endif diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index 79373f09a..fee9e6e26 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -7,6 +7,7 @@ $(package)_sha256_hash=bcbabe1e2c7d0eec4ed612e10b94b112dd5f06fcefa994a0c79a45d83 define $(package)_set_vars $(package)_config_opts=--without-documentation --disable-shared --disable-curve $(package)_config_opts_linux=--with-pic + $(package)_config_opts_freebsd=--with-pic $(package)_cxxflags=-std=c++11 endef diff --git a/depends/patches/libevent/detect-arch4random_addrandom-fix.patch b/depends/patches/libevent/detect-arch4random_addrandom-fix.patch new file mode 100644 index 000000000..14ce2edb8 --- /dev/null +++ b/depends/patches/libevent/detect-arch4random_addrandom-fix.patch @@ -0,0 +1,43 @@ +From 266f43af7798befa3d27bfabaa9ae699259c3924 Mon Sep 17 00:00:00 2001 +From: Azat Khuzhin +Date: Mon, 27 Mar 2017 15:50:23 +0300 +Subject: [PATCH] Fix arc4random_addrandom() detecting and fallback + (regression) + +But this is kind of hot-fix, we definitelly need more sane arc4random +compat layer. + +Fixes: #488 +Introduced-in: 6541168 ("Detect arch4random_addrandom() existence") +--- + event-config.h.cmake | 3 +++ + include/event2/util.h | 2 +- + 2 files changed, 4 insertions(+), 1 deletion(-) + +diff --git a/event-config.h.cmake b/event-config.h.cmake +index b7f0be57c..5c233a3d9 100644 +--- a/event-config.h.cmake ++++ b/event-config.h.cmake +@@ -53,6 +53,9 @@ + /* Define to 1 if you have the `arc4random_buf' function. */ + #cmakedefine EVENT__HAVE_ARC4RANDOM_BUF 1 + ++/* Define to 1 if you have the `arc4random_addrandom' function. */ ++#cmakedefine EVENT__HAVE_ARC4RANDOM_ADDRANDOM 1 ++ + /* Define if clock_gettime is available in libc */ + #cmakedefine EVENT__DNS_USE_CPU_CLOCK_FOR_ID 1 + +diff --git a/include/event2/util.h b/include/event2/util.h +index c4af2bd60..ca4048944 100644 +--- a/include/event2/util.h ++++ b/include/event2/util.h +@@ -842,7 +842,7 @@ int evutil_secure_rng_init(void); + EVENT2_EXPORT_SYMBOL + int evutil_secure_rng_set_urandom_device_file(char *fname); + +-#ifdef EVENT__HAVE_ARC4RANDOM_ADDRANDOM ++#if !defined(EVENT__HAVE_ARC4RANDOM) || defined(EVENT__HAVE_ARC4RANDOM_ADDRANDOM) + /** Seed the random number generator with extra random bytes. + + You should almost never need to call this function; it should be diff --git a/depends/patches/libevent/detect-arch4random_addrandom.patch b/depends/patches/libevent/detect-arch4random_addrandom.patch new file mode 100644 index 000000000..1f480715f --- /dev/null +++ b/depends/patches/libevent/detect-arch4random_addrandom.patch @@ -0,0 +1,77 @@ +From 6541168d7037457b8e5c51cc354f11bd94e618b6 Mon Sep 17 00:00:00 2001 +From: Marek Sebera +Date: Mon, 6 Mar 2017 00:55:16 +0300 +Subject: [PATCH] Detect arch4random_addrandom() existence + +Refs: #370 +Refs: #475 +--- + CMakeLists.txt | 1 + + configure.ac | 1 + + evutil_rand.c | 2 ++ + include/event2/util.h | 2 ++ + 4 files changed, 6 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a861e7d96..f609d02d0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -338,6 +338,7 @@ CHECK_FUNCTION_EXISTS_EX(sysctl EVENT__HAVE_SYSCTL) + CHECK_FUNCTION_EXISTS_EX(accept4 EVENT__HAVE_ACCEPT4) + CHECK_FUNCTION_EXISTS_EX(arc4random EVENT__HAVE_ARC4RANDOM) + CHECK_FUNCTION_EXISTS_EX(arc4random_buf EVENT__HAVE_ARC4RANDOM_BUF) ++CHECK_FUNCTION_EXISTS_EX(arc4random_addrandom EVENT__HAVE_ARC4RANDOM_ADDRANDOM) + CHECK_FUNCTION_EXISTS_EX(epoll_create1 EVENT__HAVE_EPOLL_CREATE1) + CHECK_FUNCTION_EXISTS_EX(getegid EVENT__HAVE_GETEGID) + CHECK_FUNCTION_EXISTS_EX(geteuid EVENT__HAVE_GETEUID) +diff --git a/configure.ac b/configure.ac +index a127bbc91..e73c29b14 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -342,6 +342,7 @@ AC_CHECK_FUNCS([ \ + accept4 \ + arc4random \ + arc4random_buf \ ++ arc4random_addrandom \ + eventfd \ + epoll_create1 \ + fcntl \ +diff --git a/evutil_rand.c b/evutil_rand.c +index 046a14b07..4be0b1c5e 100644 +--- a/evutil_rand.c ++++ b/evutil_rand.c +@@ -192,12 +192,14 @@ evutil_secure_rng_get_bytes(void *buf, size_t n) + ev_arc4random_buf(buf, n); + } + ++#if !defined(EVENT__HAVE_ARC4RANDOM) || defined(EVENT__HAVE_ARC4RANDOM_ADDRANDOM) + void + evutil_secure_rng_add_bytes(const char *buf, size_t n) + { + arc4random_addrandom((unsigned char*)buf, + n>(size_t)INT_MAX ? INT_MAX : (int)n); + } ++#endif + + void + evutil_free_secure_rng_globals_(void) +diff --git a/include/event2/util.h b/include/event2/util.h +index dd4bbb69d..c4af2bd60 100644 +--- a/include/event2/util.h ++++ b/include/event2/util.h +@@ -842,6 +842,7 @@ int evutil_secure_rng_init(void); + EVENT2_EXPORT_SYMBOL + int evutil_secure_rng_set_urandom_device_file(char *fname); + ++#ifdef EVENT__HAVE_ARC4RANDOM_ADDRANDOM + /** Seed the random number generator with extra random bytes. + + You should almost never need to call this function; it should be +@@ -858,6 +859,7 @@ int evutil_secure_rng_set_urandom_device_file(char *fname); + */ + EVENT2_EXPORT_SYMBOL + void evutil_secure_rng_add_bytes(const char *dat, size_t datlen); ++#endif + + #ifdef __cplusplus + } From b4d8cf53d66500c678af42a65d14af6345182891 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Fri, 12 Jul 2024 21:49:54 +0000 Subject: [PATCH 002/162] depends: Boost 1.74.0 --- depends/packages/boost.mk | 8 +++++--- depends/patches/boost/signals2-noise.patch | 23 ++++++++++++++++++++++ src/gtest/test_deprecation.cpp | 1 + src/httpserver.cpp | 1 + src/scheduler.cpp | 3 ++- src/test/scheduler_tests.cpp | 2 +- src/validationinterface.cpp | 2 ++ 7 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 depends/patches/boost/signals2-noise.patch diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 1300dc1f6..1258e6edd 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,8 +1,9 @@ package=boost -$(package)_version=1_70_0 -$(package)_download_path=https://dl.bintray.com/boostorg/release/1.70.0/source +$(package)_version=1_74_0 +$(package)_download_path=https://dl.bintray.com/boostorg/release/1.74.0/source $(package)_file_name=$(package)_$($(package)_version).tar.bz2 -$(package)_sha256_hash=430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778 +$(package)_sha256_hash=83bfc1507731a0906e387fc28b7ef5417d591429e51e788417fe9ff025e116b1 +$(package)_patches=signals2-noise.patch define $(package)_set_vars $(package)_config_opts_release=variant=release @@ -26,6 +27,7 @@ $(package)_cxxflags_freebsd=-fPIC endef define $(package)_preprocess_cmds + patch -p2 < $($(package)_patch_dir)/signals2-noise.patch endef define $(package)_config_cmds diff --git a/depends/patches/boost/signals2-noise.patch b/depends/patches/boost/signals2-noise.patch new file mode 100644 index 000000000..51d71516e --- /dev/null +++ b/depends/patches/boost/signals2-noise.patch @@ -0,0 +1,23 @@ +From fd27423fea5537bc857c1fa14bb0c25b994f77b3 Mon Sep 17 00:00:00 2001 +From: Frank Mori Hess +Date: Mon, 20 Jul 2020 14:17:05 -0400 +Subject: [PATCH] Fix warning about deprecated + boost/function_output_iterator.hpp + +--- + include/boost/signals2/detail/null_output_iterator.hpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/boost/signals2/detail/null_output_iterator.hpp b/include/boost/signals2/detail/null_output_iterator.hpp +index 9e986959..dee4373c 100644 +--- a/include/boost/signals2/detail/null_output_iterator.hpp ++++ b/include/boost/signals2/detail/null_output_iterator.hpp +@@ -11,7 +11,7 @@ + #ifndef BOOST_SIGNALS2_NULL_OUTPUT_ITERATOR_HPP + #define BOOST_SIGNALS2_NULL_OUTPUT_ITERATOR_HPP + +-#include ++#include + + namespace boost + { diff --git a/src/gtest/test_deprecation.cpp b/src/gtest/test_deprecation.cpp index d84e160a0..fb18d94f0 100644 --- a/src/gtest/test_deprecation.cpp +++ b/src/gtest/test_deprecation.cpp @@ -12,6 +12,7 @@ #include #include +using namespace boost::placeholders; using ::testing::StrictMock; static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION); diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 9227e26bb..21172e1c1 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -12,6 +12,7 @@ #include "sync.h" #include "ui_interface.h" +#include #include #include #include diff --git a/src/scheduler.cpp b/src/scheduler.cpp index ecd904cde..f511610ce 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -7,9 +7,10 @@ #include "reverselock.h" #include -#include #include +#include + CScheduler::CScheduler() : nThreadsServicingQueue(0), stopRequested(false), stopWhenEmpty(false) { } diff --git a/src/test/scheduler_tests.cpp b/src/test/scheduler_tests.cpp index 3bc0be7ae..26d705160 100644 --- a/src/test/scheduler_tests.cpp +++ b/src/test/scheduler_tests.cpp @@ -7,7 +7,7 @@ #include "test/test_bitcoin.h" -#include +#include #include #include #include diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index 405359347..d5e070de7 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -16,6 +16,8 @@ #include #include +using namespace boost::placeholders; + static CMainSignals g_signals; CMainSignals& GetMainSignals() From a0ff581fe771dc0cf896fda29e1499400526c32b Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Fri, 12 Jul 2024 21:50:17 +0000 Subject: [PATCH 003/162] depends: native_ccache 3.7.12 --- depends/packages/native_ccache.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/depends/packages/native_ccache.mk b/depends/packages/native_ccache.mk index b63c18b90..4c5dde76d 100644 --- a/depends/packages/native_ccache.mk +++ b/depends/packages/native_ccache.mk @@ -1,8 +1,8 @@ package=native_ccache -$(package)_version=3.3.1 -$(package)_download_path=https://www.samba.org/ftp/ccache -$(package)_file_name=ccache-$($(package)_version).tar.bz2 -$(package)_sha256_hash=cb6e4bafbb19ba0a2ec43386b123a5f92a20e1e3384c071d5d13e0cb3c84bf73 +$(package)_version=3.7.12 +$(package)_download_path=https://github.com/ccache/ccache/releases/download/v$($(package)_version) +$(package)_file_name=ccache-$($(package)_version).tar.gz +$(package)_sha256_hash=d2abe88d4c283ce960e233583061127b156ffb027c6da3cf10770fc0c7244194 define $(package)_set_vars $(package)_config_opts= From 0a10338f736a3d43891306b386ab760f0dae21ec Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Fri, 12 Jul 2024 22:04:23 +0000 Subject: [PATCH 004/162] depends: libgmp 6.1.2 --- depends/packages/libgmp.mk | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/depends/packages/libgmp.mk b/depends/packages/libgmp.mk index c43b99bd7..ad5289ede 100644 --- a/depends/packages/libgmp.mk +++ b/depends/packages/libgmp.mk @@ -1,11 +1,9 @@ package=libgmp -$(package)_download_path=https://github.com/z-classic/$(package)/archive/ -$(package)_file_name=$(package)-$($(package)_git_commit).tar.gz -$(package)_download_file=$($(package)_git_commit).tar.gz -$(package)_sha256_hash=59b2c2b5d58fdf5943bfde1fa709e9eb53e7e072c9699d28dc1c2cbb3c8cc32c -$(package)_git_commit=aece03c7b6967f91f3efdac8c673f55adff53ab1 -$(package)_dependencies= -$(package)_config_opts=--enable-cxx --disable-shared +$(package)_version=6.1.2 +$(package)_download_path=https://gmplib.org/download/gmp/ +$(package)_file_name=gmp-$($(package)_version).tar.bz2 +$(package)_sha256_hash=5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d73d8fb2 +$(package)_config_opts=--enable-cxx --disable-shared --with-pic define $(package)_config_cmds $($(package)_autoconf) --host=$(host) --build=$(build) From 306499e78b689206e2aabef8c2decc26b62db64f Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Fri, 12 Jul 2024 22:36:17 +0000 Subject: [PATCH 005/162] fix: libgmp missing --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 7f0df9106..f8946ea89 100644 --- a/configure.ac +++ b/configure.ac @@ -693,7 +693,7 @@ if test x$use_pkgconfig = xyes; then ) else # BUG: Fix this: - echo 'BUG: configure does not yet check for the following dependencies if pkg-config is not on the system: libcrypto++, libgmp' + echo 'BUG: configure does not yet check for the following dependencies if pkg-config is not on the system: libcrypto++' AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing)) AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing)) @@ -736,7 +736,7 @@ fi # These packages don't provide pkgconfig config files across all # platforms, so we use older autoconf detection mechanisms: AC_CHECK_HEADER([gmp.h],,AC_MSG_ERROR(libgmp headers missing)) -AC_CHECK_LIB([gmp],[[__gmpn_sub_n]],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing)]) +AC_CHECK_LIB([gmp],[__gmpn_sub_n],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing)]) AC_CHECK_HEADER([gmpxx.h],,AC_MSG_ERROR(libgmpxx headers missing)) AC_CHECK_LIB([gmpxx],[main],GMPXX_LIBS=-lgmpxx, [AC_MSG_ERROR(libgmpxx missing)]) From 0ed461be4eaffdde23cf762133b88ebf731340bb Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Fri, 12 Jul 2024 22:54:42 +0000 Subject: [PATCH 006/162] clang-format: Delete ForEachMacros --- src/.clang-format | 1 - 1 file changed, 1 deletion(-) diff --git a/src/.clang-format b/src/.clang-format index 6314e210f..401a4272e 100644 --- a/src/.clang-format +++ b/src/.clang-format @@ -21,7 +21,6 @@ ContinuationIndentWidth: 4 Cpp11BracedListStyle: true DerivePointerAlignment: false DisableFormat: false -ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, BOOST_REVERSE_FOREACH ] IndentCaseLabels: false IndentFunctionDeclarationAfterType: false IndentWidth: 4 From 68ce74cb3ec52a53823443c1a9023676612eac17 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Fri, 12 Jul 2024 23:04:43 +0000 Subject: [PATCH 007/162] scripted-diff: Fully remove BOOST_FOREACH -BEGIN VERIFY SCRIPT- sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp src/zcash/*/*.tcc ; -END VERIFY SCRIPT- --- src/alert.cpp | 6 +- src/bitcoin-tx.cpp | 2 +- src/bloom.cpp | 2 +- src/checkqueue.h | 4 +- src/coins.cpp | 8 +- src/coins.h | 6 +- src/core_write.cpp | 2 +- src/gtest/test_joinsplit.cpp | 2 +- src/gtest/test_merkletree.cpp | 4 +- src/httpserver.cpp | 8 +- src/init.cpp | 22 ++--- src/main.cpp | 110 ++++++++++----------- src/miner.cpp | 6 +- src/net.cpp | 74 +++++++------- src/net.h | 4 +- src/rest.cpp | 6 +- src/rpc/blockchain.cpp | 16 ++-- src/rpc/mining.cpp | 4 +- src/rpc/misc.cpp | 2 +- src/rpc/net.cpp | 22 ++--- src/rpc/rawtransaction.cpp | 16 ++-- src/rpc/server.cpp | 6 +- src/script/sign.cpp | 8 +- src/script/standard.cpp | 4 +- src/sendalert.cpp | 4 +- src/sync.cpp | 10 +- src/test/accounting_tests.cpp | 2 +- src/test/alert_tests.cpp | 4 +- src/test/bip32_tests.cpp | 2 +- src/test/coins_tests.cpp | 2 +- src/test/getarg_tests.cpp | 2 +- src/test/miner_tests.cpp | 2 +- src/test/mruset_tests.cpp | 6 +- src/test/multisig_tests.cpp | 2 +- src/test/prevector_tests.cpp | 4 +- src/test/script_tests.cpp | 6 +- src/test/transaction_tests.cpp | 2 +- src/timedata.cpp | 4 +- src/torcontrol.cpp | 6 +- src/txmempool.cpp | 38 ++++---- src/util.cpp | 2 +- src/wallet/asyncrpcoperation_sendmany.cpp | 2 +- src/wallet/crypter.cpp | 6 +- src/wallet/rpcdump.cpp | 2 +- src/wallet/rpcwallet.cpp | 42 ++++---- src/wallet/test/wallet_tests.cpp | 2 +- src/wallet/wallet.cpp | 112 +++++++++++----------- src/wallet/wallet_ismine.cpp | 2 +- src/wallet/walletdb.cpp | 12 +-- src/zcash/IncrementalMerkleTree.cpp | 10 +- src/zcash/circuit/utils.tcc | 2 +- 51 files changed, 317 insertions(+), 317 deletions(-) diff --git a/src/alert.cpp b/src/alert.cpp index d7668453d..8fbc0045c 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -47,10 +47,10 @@ void CUnsignedAlert::SetNull() std::string CUnsignedAlert::ToString() const { std::string strSetCancel; - BOOST_FOREACH(int n, setCancel) + for (int n : setCancel) strSetCancel += strprintf("%d ", n); std::string strSetSubVer; - BOOST_FOREACH(const std::string& str, setSubVer) + for (const std::string& str : setSubVer) strSetSubVer += "\"" + str + "\" "; return strprintf( "CAlert(\n" @@ -222,7 +222,7 @@ bool CAlert::ProcessAlert(const std::vector& alertKey, bool fThre } // Check if this alert has been cancelled - BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts) + for (PAIRTYPE(const uint256, CAlert)& item : mapAlerts) { const CAlert& alert = item.second; if (alert.Cancels(*this)) diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 73f8f4bd7..9885f3102 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -483,7 +483,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& strInput) ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata, consensusBranchId); // ... and merge in other signatures: - BOOST_FOREACH(const CTransaction& txv, txVariants) + for (const CTransaction& txv : txVariants) sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i), consensusBranchId); UpdateTransaction(mergedTx, i, sigdata); diff --git a/src/bloom.cpp b/src/bloom.cpp index 49dc5da69..ab4210601 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -181,7 +181,7 @@ bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx) if (fFound) return true; - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) { // Match if the filter contains an outpoint tx spends if (contains(txin.prevout)) diff --git a/src/checkqueue.h b/src/checkqueue.h index 157b72c3a..861d263bb 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -119,7 +119,7 @@ class CCheckQueue fOk = fAllOk; } // execute work - BOOST_FOREACH (T& check, vChecks) + for (T& check : vChecks) if (fOk) fOk = check(); vChecks.clear(); @@ -146,7 +146,7 @@ class CCheckQueue void Add(std::vector& vChecks) { boost::unique_lock lock(mutex); - BOOST_FOREACH (T& check, vChecks) { + for (T& check : vChecks) { queue.push_back(T()); check.swap(queue.back()); } diff --git a/src/coins.cpp b/src/coins.cpp index 6194595e2..a4be3d6bd 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -566,9 +566,9 @@ bool CCoinsViewCache::HaveShieldedRequirements(const CTransaction& tx) const { boost::unordered_map intermediates; - BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) + for (const JSDescription &joinsplit : tx.vJoinSplit) { - BOOST_FOREACH(const uint256& nullifier, joinsplit.nullifiers) + for (const uint256& nullifier : joinsplit.nullifiers) { if (GetNullifier(nullifier, SPROUT)) { // If the nullifier is set, this transaction @@ -585,7 +585,7 @@ bool CCoinsViewCache::HaveShieldedRequirements(const CTransaction& tx) const return false; } - BOOST_FOREACH(const uint256& commitment, joinsplit.commitments) + for (const uint256& commitment : joinsplit.commitments) { tree.append(commitment); } @@ -636,7 +636,7 @@ double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight) const // FIXME: this logic is partially duplicated between here and CreateNewBlock in miner.cpp. double dResult = 0.0; - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) { const CCoins* coins = AccessCoins(txin.prevout.hash); assert(coins); diff --git a/src/coins.h b/src/coins.h index c29c13315..b908d3b00 100644 --- a/src/coins.h +++ b/src/coins.h @@ -119,7 +119,7 @@ class CCoins } void ClearUnspendable() { - BOOST_FOREACH(CTxOut &txout, vout) { + for (CTxOut &txout : vout) { if (txout.scriptPubKey.IsUnspendable()) txout.SetNull(); } @@ -227,7 +227,7 @@ class CCoins //! check whether the entire CCoins is spent //! note that only !IsPruned() CCoins can be serialized bool IsPruned() const { - BOOST_FOREACH(const CTxOut &out, vout) + for (const CTxOut &out : vout) if (!out.IsNull()) return false; return true; @@ -235,7 +235,7 @@ class CCoins size_t DynamicMemoryUsage() const { size_t ret = memusage::DynamicUsage(vout); - BOOST_FOREACH(const CTxOut &out, vout) { + for (const CTxOut &out : vout) { ret += RecursiveDynamicUsage(out.scriptPubKey); } return ret; diff --git a/src/core_write.cpp b/src/core_write.cpp index 89a545a99..f93fbac8c 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -156,7 +156,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry) entry.pushKV("locktime", (int64_t)tx.nLockTime); UniValue vin(UniValue::VARR); - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { UniValue in(UniValue::VOBJ); if (tx.IsCoinBase()) in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); diff --git a/src/gtest/test_joinsplit.cpp b/src/gtest/test_joinsplit.cpp index c54f07823..50abea3f0 100644 --- a/src/gtest/test_joinsplit.cpp +++ b/src/gtest/test_joinsplit.cpp @@ -314,7 +314,7 @@ for test_input in TEST_VECTORS: } }; - BOOST_FOREACH(std::vector& v, tests) { + for (std::vector& v : tests) { auto expected = ZCJoinSplit::h_sig( uint256S(v[0]), {uint256S(v[1]), uint256S(v[2])}, diff --git a/src/gtest/test_merkletree.cpp b/src/gtest/test_merkletree.cpp index 23c39c044..3d58e32d0 100644 --- a/src/gtest/test_merkletree.cpp +++ b/src/gtest/test_merkletree.cpp @@ -104,7 +104,7 @@ void test_tree( expect_ser_test_vector(ser_tests[i], tree, tree); bool first = true; // The first witness can never form a path - BOOST_FOREACH(Witness& wit, witnesses) + for (Witness& wit : witnesses) { // Append the same commitment to all the witnesses wit.append(test_commitment); @@ -179,7 +179,7 @@ void test_tree( // Tree should be full now ASSERT_THROW(tree.append(uint256()), std::runtime_error); - BOOST_FOREACH(Witness& wit, witnesses) + for (Witness& wit : witnesses) { ASSERT_THROW(wit.append(uint256()), std::runtime_error); } diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 21172e1c1..81103fb01 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -194,7 +194,7 @@ static bool ClientAllowed(const CNetAddr& netaddr) { if (!netaddr.IsValid()) return false; - BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets) + for (const CSubNet& subnet : rpc_allow_subnets) if (subnet.Match(netaddr)) return true; return false; @@ -208,7 +208,7 @@ static bool InitHTTPAllowList() rpc_allow_subnets.push_back(CSubNet("::1")); // always allow IPv6 localhost if (mapMultiArgs.count("-rpcallowip")) { const std::vector& vAllow = mapMultiArgs["-rpcallowip"]; - BOOST_FOREACH (std::string strAllow, vAllow) { + for (std::string strAllow : vAllow) { CSubNet subnet(strAllow); if (!subnet.IsValid()) { uiInterface.ThreadSafeMessageBox( @@ -220,7 +220,7 @@ static bool InitHTTPAllowList() } } std::string strAllowed; - BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets) + for (const CSubNet& subnet : rpc_allow_subnets) strAllowed += subnet.ToString() + " "; LogPrint("http", "Allowing HTTP connections from: %s\n", strAllowed); return true; @@ -460,7 +460,7 @@ void InterruptHTTPServer() LogPrint("http", "Interrupting HTTP server\n"); if (eventHTTP) { // Unlisten sockets - BOOST_FOREACH (evhttp_bound_socket *socket, boundSockets) { + for (evhttp_bound_socket *socket : boundSockets) { evhttp_del_accept_socket(eventHTTP, socket); } // Reject requests on current connections diff --git a/src/init.cpp b/src/init.cpp index 70c159a75..b183ea9eb 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -596,7 +596,7 @@ void CleanupBlockRevFiles() // keeping a separate counter. Once we hit a gap (or if 0 doesn't exist) // start removing block files. int nContigCounter = 0; - BOOST_FOREACH(const PAIRTYPE(string, path)& item, mapBlockFiles) { + for (const PAIRTYPE(string, path)& item : mapBlockFiles) { if (atoi(item.first) == nContigCounter) { nContigCounter++; continue; @@ -647,7 +647,7 @@ void ThreadImport(std::vector vImportFiles) } // -loadblock= - BOOST_FOREACH(const boost::filesystem::path& path, vImportFiles) { + for (const boost::filesystem::path& path : vImportFiles) { FILE *file = fopen(path.string().c_str(), "rb"); if (file) { CImportingNow imp; @@ -1300,7 +1300,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // sanitize comments per BIP-0014, format user agent and check total size std::vector uacomments; - BOOST_FOREACH(string cmt, mapMultiArgs["-uacomment"]) + for (string cmt : mapMultiArgs["-uacomment"]) { if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT)) return InitError(strprintf("User Agent comment (%s) contains unsafe characters.", cmt)); @@ -1314,7 +1314,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (mapArgs.count("-onlynet")) { std::set nets; - BOOST_FOREACH(const std::string& snet, mapMultiArgs["-onlynet"]) { + for (const std::string& snet : mapMultiArgs["-onlynet"]) { enum Network net = ParseNetwork(snet); if (net == NET_UNROUTABLE) return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet)); @@ -1328,7 +1328,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } if (mapArgs.count("-whitelist")) { - BOOST_FOREACH(const std::string& net, mapMultiArgs["-whitelist"]) { + for (const std::string& net : mapMultiArgs["-whitelist"]) { CSubNet subnet(net); if (!subnet.IsValid()) return InitError(strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net)); @@ -1377,13 +1377,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) bool fBound = false; if (fListen) { if (mapArgs.count("-bind") || mapArgs.count("-whitebind")) { - BOOST_FOREACH(const std::string& strBind, mapMultiArgs["-bind"]) { + for (const std::string& strBind : mapMultiArgs["-bind"]) { CService addrBind; if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind)); fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR)); } - BOOST_FOREACH(const std::string& strBind, mapMultiArgs["-whitebind"]) { + for (const std::string& strBind : mapMultiArgs["-whitebind"]) { CService addrBind; if (!Lookup(strBind.c_str(), addrBind, 0, false)) return InitError(strprintf(_("Cannot resolve -whitebind address: '%s'"), strBind)); @@ -1403,7 +1403,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } if (mapArgs.count("-externalip")) { - BOOST_FOREACH(const std::string& strAddr, mapMultiArgs["-externalip"]) { + for (const std::string& strAddr : mapMultiArgs["-externalip"]) { CService addrLocal(strAddr, GetListenPort(), fNameLookup); if (!addrLocal.IsValid()) return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr)); @@ -1411,7 +1411,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } } - BOOST_FOREACH(const std::string& strDest, mapMultiArgs["-seednode"]) + for (const std::string& strDest : mapMultiArgs["-seednode"]) AddOneShot(strDest); #if ENABLE_ZMQ @@ -1766,7 +1766,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) { CWalletDB walletdb(strWalletFile); - BOOST_FOREACH(const CWalletTx& wtxOld, vWtx) + for (const CWalletTx& wtxOld : vWtx) { uint256 hash = wtxOld.GetHash(); std::map::iterator mi = pwalletMain->mapWallet.find(hash); @@ -1861,7 +1861,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) std::vector vImportFiles; if (mapArgs.count("-loadblock")) { - BOOST_FOREACH(const std::string& strFile, mapMultiArgs["-loadblock"]) + for (const std::string& strFile : mapMultiArgs["-loadblock"]) vImportFiles.push_back(strFile); } threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles)); diff --git a/src/main.cpp b/src/main.cpp index c812bc79d..a607603ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -334,7 +334,7 @@ void FinalizeNode(NodeId nodeid) { AddressCurrentlyConnected(state->address); } - BOOST_FOREACH(const QueuedBlock& entry, state->vBlocksInFlight) + for (const QueuedBlock& entry : state->vBlocksInFlight) mapBlocksInFlight.erase(entry.hash); EraseOrphansFor(nodeid); nPreferredDownload -= state->fPreferredDownload; @@ -483,7 +483,7 @@ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vectorIsValid(BLOCK_VALID_TREE)) { // We consider the chain that this peer is on invalid. return; @@ -523,7 +523,7 @@ bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) { stats.nMisbehavior = state->nMisbehavior; stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1; stats.nCommonHeight = state->pindexLastCommonBlock ? state->pindexLastCommonBlock->nHeight : -1; - BOOST_FOREACH(const QueuedBlock& queue, state->vBlocksInFlight) { + for (const QueuedBlock& queue : state->vBlocksInFlight) { if (queue.pindex) stats.vHeightInFlight.push_back(queue.pindex->nHeight); } @@ -551,7 +551,7 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals) CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator) { // Find the first block the caller has in the main chain - BOOST_FOREACH(const uint256& hash, locator.vHave) { + for (const uint256& hash : locator.vHave) { BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) { @@ -596,7 +596,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(c mapOrphanTransactions[hash].tx = tx; mapOrphanTransactions[hash].fromPeer = peer; - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash); LogPrint("mempool", "stored orphan tx %s (mapsz %u prevsz %u)\n", hash.ToString(), @@ -609,7 +609,7 @@ void static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) map::iterator it = mapOrphanTransactions.find(hash); if (it == mapOrphanTransactions.end()) return; - BOOST_FOREACH(const CTxIn& txin, it->second.tx.vin) + for (const CTxIn& txin : it->second.tx.vin) { map >::iterator itPrev = mapOrphanTransactionsByPrev.find(txin.prevout.hash); if (itPrev == mapOrphanTransactionsByPrev.end()) @@ -680,7 +680,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const CChainParams& ch } } - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) { // Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed // keys. (remember the 520 byte limit on redeemScript size) That works @@ -701,7 +701,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const CChainParams& ch unsigned int nDataOut = 0; txnouttype whichType; - BOOST_FOREACH(const CTxOut& txout, tx.vout) { + for (const CTxOut& txout : tx.vout) { if (!::IsStandard(txout.scriptPubKey, whichType)) { reason = "scriptpubkey"; return false; @@ -733,7 +733,7 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime) return true; if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) return true; - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) if (!txin.IsFinal()) return false; return true; @@ -854,11 +854,11 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, unsigned int GetLegacySigOpCount(const CTransaction& tx) { unsigned int nSigOps = 0; - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) { nSigOps += txin.scriptSig.GetSigOpCount(false); } - BOOST_FOREACH(const CTxOut& txout, tx.vout) + for (const CTxOut& txout : tx.vout) { nSigOps += txout.scriptPubKey.GetSigOpCount(false); } @@ -1080,7 +1080,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, return false; } else { // Ensure that zk-SNARKs verify - BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) { + for (const JSDescription &joinsplit : tx.vJoinSplit) { if (!joinsplit.Verify(*pzcashParams, verifier, tx.joinSplitPubKey)) { return state.DoS(100, error("CheckTransaction(): joinsplit does not verify"), REJECT_INVALID, "bad-txns-joinsplit-verification-failed"); @@ -1156,7 +1156,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio // Check for negative or overflow output values CAmount nValueOut = 0; - BOOST_FOREACH(const CTxOut& txout, tx.vout) + for (const CTxOut& txout : tx.vout) { if (txout.nValue < 0) return state.DoS(100, error("CheckTransaction(): txout.nValue negative"), @@ -1193,7 +1193,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio } // Ensure that joinsplit values are well-formed - BOOST_FOREACH(const JSDescription& joinsplit, tx.vJoinSplit) + for (const JSDescription& joinsplit : tx.vJoinSplit) { if (joinsplit.vpub_old < 0) { return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_old negative"), @@ -1257,7 +1257,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio // Check for duplicate inputs set vInOutPoints; - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) { if (vInOutPoints.count(txin.prevout)) return state.DoS(100, error("CheckTransaction(): duplicate inputs"), @@ -1268,9 +1268,9 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio // Check for duplicate joinsplit nullifiers in this transaction { set vJoinSplitNullifiers; - BOOST_FOREACH(const JSDescription& joinsplit, tx.vJoinSplit) + for (const JSDescription& joinsplit : tx.vJoinSplit) { - BOOST_FOREACH(const uint256& nf, joinsplit.nullifiers) + for (const uint256& nf : joinsplit.nullifiers) { if (vJoinSplitNullifiers.count(nf)) return state.DoS(100, error("CheckTransaction(): duplicate nullifiers"), @@ -1284,7 +1284,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio // Check for duplicate sapling nullifiers in this transaction { set vSaplingNullifiers; - BOOST_FOREACH(const SpendDescription& spend_desc, tx.vShieldedSpend) + for (const SpendDescription& spend_desc : tx.vShieldedSpend) { if (vSaplingNullifiers.count(spend_desc.nullifier)) return state.DoS(100, error("CheckTransaction(): duplicate nullifiers"), @@ -1315,7 +1315,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio } else { - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) if (txin.prevout.IsNull()) return state.DoS(10, error("CheckTransaction(): prevout is null"), REJECT_INVALID, "bad-txns-prevout-null"); @@ -1430,8 +1430,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return false; } } - BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) { - BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) { + for (const JSDescription &joinsplit : tx.vJoinSplit) { + for (const uint256 &nf : joinsplit.nullifiers) { if (pool.nullifierExists(nf, SPROUT)) { return false; } @@ -1461,7 +1461,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // do all inputs exist? // Note that this does not check for the presence of actual outputs (see the next check for that), // and only helps with filling in pfMissingInputs (to determine missing vs spent). - BOOST_FOREACH(const CTxIn txin, tx.vin) { + for (const CTxIn txin : tx.vin) { if (!view.HaveCoins(txin.prevout.hash)) { if (pfMissingInputs) *pfMissingInputs = true; @@ -1512,7 +1512,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Keep track of transactions that spend a coinbase, which we re-scan // during reorgs to ensure COINBASE_MATURITY is still met. bool fSpendsCoinbase = false; - BOOST_FOREACH(const CTxIn &txin, tx.vin) { + for (const CTxIn &txin : tx.vin) { const CCoins *coins = view.AccessCoins(txin.prevout.hash); if (coins->IsCoinBase()) { fSpendsCoinbase = true; @@ -1716,7 +1716,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, const Consensus::P if (pindexSlow) { CBlock block; if (ReadBlockFromDisk(block, pindexSlow, consensusParams)) { - BOOST_FOREACH(const CTransaction &tx, block.vtx) { + for (const CTransaction &tx : block.vtx) { if (tx.GetHash() == hash) { txOut = tx; hashBlock = pindexSlow->GetBlockHash(); @@ -1996,7 +1996,7 @@ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txund // mark inputs spent if (!tx.IsCoinBase()) { txundo.vprevout.reserve(tx.vin.size()); - BOOST_FOREACH(const CTxIn &txin, tx.vin) { + for (const CTxIn &txin : tx.vin) { CCoinsModifier coins = inputs.ModifyCoins(txin.prevout.hash); unsigned nPos = txin.prevout.n; @@ -2644,7 +2644,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // Do not allow blocks that contain transactions which 'overwrite' older transactions, // unless those are already completely spent. - BOOST_FOREACH(const CTransaction& tx, block.vtx) { + for (const CTransaction& tx : block.vtx) { const CCoins* coins = view.AccessCoins(tx.GetHash()); if (coins && !coins->IsPruned()) return state.DoS(100, error("ConnectBlock(): tried to overwrite transaction"), @@ -2801,15 +2801,15 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } UpdateCoins(tx, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->nHeight); - BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) { - BOOST_FOREACH(const uint256 ¬e_commitment, joinsplit.commitments) { + for (const JSDescription &joinsplit : tx.vJoinSplit) { + for (const uint256 ¬e_commitment : joinsplit.commitments) { // Insert the note commitments into our temporary tree. sprout_tree.append(note_commitment); } } - BOOST_FOREACH(const OutputDescription &outputDescription, tx.vShieldedOutput) { + for (const OutputDescription &outputDescription : tx.vShieldedOutput) { sapling_tree.append(outputDescription.cm); } @@ -3108,7 +3108,7 @@ bool static DisconnectTip(CValidationState &state, const CChainParams& chainpara if (!fBare) { // Resurrect mempool transactions from the disconnected block. - BOOST_FOREACH(const CTransaction &tx, block.vtx) { + for (const CTransaction &tx : block.vtx) { // ignore validation errors in resurrected transactions list removed; CValidationState stateDummy; @@ -3484,7 +3484,7 @@ bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, nBlockEstimate = Checkpoints::GetTotalBlocksEstimate(chainparams.Checkpoints()); { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (chainActive.Height() > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) pnode->PushInventory(CInv(MSG_BLOCK, hashNewTip)); } @@ -3906,12 +3906,12 @@ bool CheckBlock(const CBlock& block, CValidationState& state, REJECT_INVALID, "bad-cb-multiple"); // Check transactions - BOOST_FOREACH(const CTransaction& tx, block.vtx) + for (const CTransaction& tx : block.vtx) if (!CheckTransaction(tx, state, verifier)) return error("CheckBlock(): CheckTransaction failed"); unsigned int nSigOps = 0; - BOOST_FOREACH(const CTransaction& tx, block.vtx) + for (const CTransaction& tx : block.vtx) { nSigOps += GetLegacySigOpCount(tx); } @@ -3978,7 +3978,7 @@ bool ContextualCheckBlock( const Consensus::Params& consensusParams = chainparams.GetConsensus(); // Check that all transactions are finalized - BOOST_FOREACH(const CTransaction& tx, block.vtx) { + for (const CTransaction& tx : block.vtx) { // Check transaction contextually against consensus rules at block height if (!ContextualCheckTransaction(tx, state, chainparams, nHeight, 100)) { @@ -4011,7 +4011,7 @@ bool ContextualCheckBlock( // reward to a community fee script. if (nHeight >= Params().GetCommunityFeeStartHeight()) { bool found = false; - BOOST_FOREACH(const CTxOut& output, block.vtx[0].vout) { + for (const CTxOut& output : block.vtx[0].vout) { if (output.scriptPubKey == chainparams.GetCommunityFeeScriptAtHeight(nHeight)) { if (output.nValue == (GetBlockSubsidy(nHeight, consensusParams) * 0.05)) { found = true; @@ -4223,7 +4223,7 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, uint64_t CalculateCurrentUsage() { uint64_t retval = 0; - BOOST_FOREACH(const CBlockFileInfo &file, vinfoBlockFile) { + for (const CBlockFileInfo &file : vinfoBlockFile) { retval += file.nSize + file.nUndoSize; } return retval; @@ -4399,13 +4399,13 @@ bool static LoadBlockIndexDB() // Calculate nChainWork vector > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); - BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex) + for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) { CBlockIndex* pindex = item.second; vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex)); } sort(vSortedByHeight.begin(), vSortedByHeight.end()); - BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight) + for (const PAIRTYPE(int, CBlockIndex*)& item : vSortedByHeight) { CBlockIndex* pindex = item.second; pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex); @@ -4491,7 +4491,7 @@ bool static LoadBlockIndexDB() // Check presence of blk files LogPrintf("Checking all blk files are present...\n"); set setBlkDataFiles; - BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex) + for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) { CBlockIndex* pindex = item.second; if (pindex->nStatus & BLOCK_HAVE_DATA) { @@ -4529,7 +4529,7 @@ bool static LoadBlockIndexDB() fTimestampIndex = fInsightExplorer; // Fill in-memory data - BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex) + for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) { CBlockIndex* pindex = item.second; // - This relationship will always be true even if pprev has multiple @@ -4834,7 +4834,7 @@ void UnloadBlockIndex() mapNodeState.clear(); recentRejects.reset(NULL); - BOOST_FOREACH(BlockMap::value_type& entry, mapBlockIndex) { + for (BlockMap::value_type& entry : mapBlockIndex) { delete entry.second; } mapBlockIndex.clear(); @@ -5293,7 +5293,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam // Thus, the protocol spec specified allows for us to provide duplicate txn here, // however we MUST always provide at least what the remote peer needs typedef std::pair PairType; - BOOST_FOREACH(PairType& pair, merkleBlock.vMatchedTxn) + for (PairType& pair : merkleBlock.vMatchedTxn) if (!pfrom->setInventoryKnown.count(CInv(MSG_TX, pair.second))) pfrom->PushMessage("tx", block.vtx[pair.first]); } @@ -5501,7 +5501,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // Relay alerts { LOCK(cs_mapAlerts); - BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts) + for (PAIRTYPE(const uint256, CAlert)& item : mapAlerts) item.second.RelayTo(pfrom); } @@ -5576,7 +5576,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, vector vAddrOk; int64_t nNow = GetAdjustedTime(); int64_t nSince = nNow - 10 * 60; - BOOST_FOREACH(CAddress& addr, vAddr) + for (CAddress& addr : vAddr) { boost::this_thread::interruption_point(); @@ -5598,7 +5598,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, uint256 hashRand = ArithToUint256(UintToArith256(hashSalt) ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/(24*60*60))); hashRand = Hash(BEGIN(hashRand), END(hashRand)); multimap mapMix; - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) { if (pnode->nVersion < CADDR_TIME_VERSION) continue; @@ -5878,7 +5878,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } - BOOST_FOREACH(uint256 hash, vEraseQueue) + for (uint256 hash : vEraseQueue) EraseOrphanTx(hash); } // TODO: currently, prohibit joinsplits and shielded spends/outputs from entering mapOrphans @@ -5955,7 +5955,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } CBlockIndex *pindexLast = NULL; - BOOST_FOREACH(const CBlockHeader& header, headers) { + for (const CBlockHeader& header : headers) { CValidationState state; if (pindexLast != NULL && header.hashPrevBlock != pindexLast->GetBlockHash()) { Misbehaving(pfrom->GetId(), 20); @@ -6032,7 +6032,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->vAddrToSend.clear(); vector vAddr = addrman.GetAddr(); - BOOST_FOREACH(const CAddress &addr, vAddr) + for (const CAddress &addr : vAddr) pfrom->PushAddress(addr); } @@ -6046,7 +6046,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, std::vector vtxid; mempool.queryHashes(vtxid); vector vInv; - BOOST_FOREACH(uint256& hash, vtxid) { + for (uint256& hash : vtxid) { CTransaction tx; bool fInMemPool = mempool.lookup(hash, tx); if (fInMemPool && IsExpiringSoonTx(tx, currentHeight + 1)) { @@ -6163,7 +6163,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->setKnown.insert(alertHash); { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) alert.RelayTo(pnode); } } @@ -6452,7 +6452,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (!IsInitialBlockDownload(chainParams) && (GetTime() - nLastRebroadcast > 24 * 60 * 60)) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) { // Periodically clear addrKnown to allow refresh broadcasts if (nLastRebroadcast) @@ -6472,7 +6472,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) { vector vAddr; vAddr.reserve(pto->vAddrToSend.size()); - BOOST_FOREACH(const CAddress& addr, pto->vAddrToSend) + for (const CAddress& addr : pto->vAddrToSend) { if (!pto->addrKnown.contains(addr.GetKey())) { @@ -6507,7 +6507,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) state.fShouldBan = false; } - BOOST_FOREACH(const CBlockReject& reject, state.rejects) + for (const CBlockReject& reject : state.rejects) pto->PushMessage("reject", (string)"block", reject.chRejectCode, reject.strRejectReason, reject.hashBlock); state.rejects.clear(); @@ -6543,7 +6543,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) LOCK(pto->cs_inventory); vInv.reserve(pto->vInventoryToSend.size()); vInvWait.reserve(pto->vInventoryToSend.size()); - BOOST_FOREACH(const CInv& inv, pto->vInventoryToSend) + for (const CInv& inv : pto->vInventoryToSend) { if (pto->setInventoryKnown.count(inv)) continue; @@ -6622,7 +6622,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) vector vToDownload; NodeId staller = -1; FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller); - BOOST_FOREACH(CBlockIndex *pindex, vToDownload) { + for (CBlockIndex *pindex : vToDownload) { vGetData.push_back(CInv(MSG_BLOCK, pindex->GetBlockHash())); MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), consensusParams, pindex); LogPrint("net", "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(), diff --git a/src/miner.cpp b/src/miner.cpp index 19e54ec67..763eecdbf 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -178,7 +178,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s double dPriority = 0; CAmount nTotalIn = 0; bool fMissingInputs = false; - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) { // Read prev transaction if (!view.HaveCoins(txin.prevout.hash)) @@ -354,7 +354,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s UpdateCoins(tx, view, nHeight); - BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { + for (const OutputDescription &outDescription : tx.vShieldedOutput) { sapling_tree.append(outDescription.cm); } @@ -376,7 +376,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s // Add transactions that depend on this one to the priority queue if (mapDependers.count(hash)) { - BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) + for (COrphan* porphan : mapDependers[hash]) { if (!porphan->setDependsOn.empty()) { diff --git a/src/net.cpp b/src/net.cpp index fa2e83710..5446c053b 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -320,7 +320,7 @@ CCriticalSection CNode::cs_totalBytesSent; CNode* FindNode(const CNetAddr& ip) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if ((CNetAddr)pnode->addr == ip) return (pnode); return NULL; @@ -329,7 +329,7 @@ CNode* FindNode(const CNetAddr& ip) CNode* FindNode(const CSubNet& subNet) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (subNet.Match((CNetAddr)pnode->addr)) return (pnode); return NULL; @@ -338,7 +338,7 @@ CNode* FindNode(const CSubNet& subNet) CNode* FindNode(const std::string& addrName) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (pnode->addrName == addrName) return (pnode); return NULL; @@ -347,7 +347,7 @@ CNode* FindNode(const std::string& addrName) CNode* FindNode(const CService& addr) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if ((CService)pnode->addr == addr) return (pnode); return NULL; @@ -524,7 +524,7 @@ CCriticalSection CNode::cs_vWhitelistedRange; bool CNode::IsWhitelistedRange(const CNetAddr &addr) { LOCK(cs_vWhitelistedRange); - BOOST_FOREACH(const CSubNet& subnet, vWhitelistedRange) { + for (const CSubNet& subnet : vWhitelistedRange) { if (subnet.Match(addr)) return true; } @@ -796,7 +796,7 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) { { LOCK(cs_vNodes); - BOOST_FOREACH(CNode *node, vNodes) { + for (CNode *node : vNodes) { if (node->fWhitelisted) continue; if (!node->fInbound) @@ -871,7 +871,7 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) { unsigned int nMostConnections = 0; int64_t nMostConnectionsTime = 0; std::map, std::vector > mapAddrCounts; - BOOST_FOREACH(const CNodeRef &node, vEvictionCandidates) { + for (const CNodeRef &node : vEvictionCandidates) { mapAddrCounts[node->addr.GetGroup()].push_back(node); int64_t grouptime = mapAddrCounts[node->addr.GetGroup()][0]->nTimeConnected; size_t groupsize = mapAddrCounts[node->addr.GetGroup()].size(); @@ -913,7 +913,7 @@ static void AcceptConnection(const ListenSocket& hListenSocket) { bool whitelisted = hListenSocket.whitelisted || CNode::IsWhitelistedRange(addr); { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (pnode->fInbound) nInbound++; } @@ -983,7 +983,7 @@ void ThreadSocketHandler() LOCK(cs_vNodes); // Disconnect unused nodes vector vNodesCopy = vNodes; - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) { if (pnode->fDisconnect || (pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->nSendSize == 0 && pnode->ssSend.empty())) @@ -1007,7 +1007,7 @@ void ThreadSocketHandler() { // Delete disconnected nodes list vNodesDisconnectedCopy = vNodesDisconnected; - BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy) + for (CNode* pnode : vNodesDisconnectedCopy) { // wait until threads are done using it if (pnode->GetRefCount() <= 0) @@ -1055,7 +1055,7 @@ void ThreadSocketHandler() SOCKET hSocketMax = 0; bool have_fds = false; - BOOST_FOREACH(const ListenSocket& hListenSocket, vhListenSocket) { + for (const ListenSocket& hListenSocket : vhListenSocket) { FD_SET(hListenSocket.socket, &fdsetRecv); hSocketMax = max(hSocketMax, hListenSocket.socket); have_fds = true; @@ -1063,7 +1063,7 @@ void ThreadSocketHandler() { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) { if (pnode->hSocket == INVALID_SOCKET) continue; @@ -1124,7 +1124,7 @@ void ThreadSocketHandler() // // Accept new connections // - BOOST_FOREACH(const ListenSocket& hListenSocket, vhListenSocket) + for (const ListenSocket& hListenSocket : vhListenSocket) { if (hListenSocket.socket != INVALID_SOCKET && FD_ISSET(hListenSocket.socket, &fdsetRecv)) { @@ -1139,10 +1139,10 @@ void ThreadSocketHandler() { LOCK(cs_vNodes); vNodesCopy = vNodes; - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) pnode->AddRef(); } - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) { boost::this_thread::interruption_point(); @@ -1232,7 +1232,7 @@ void ThreadSocketHandler() } { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) pnode->Release(); } } @@ -1258,7 +1258,7 @@ void ThreadDNSAddressSeed() LogPrintf("Loading addresses from DNS seeds (could take a while)\n"); - BOOST_FOREACH(const CDNSSeedData &seed, vSeeds) { + for (const CDNSSeedData &seed : vSeeds) { if (HaveNameProxy()) { AddOneShot(seed.host); } else { @@ -1266,7 +1266,7 @@ void ThreadDNSAddressSeed() vector vAdd; if (LookupHost(seed.host.c_str(), vIPs)) { - BOOST_FOREACH(const CNetAddr& ip, vIPs) + for (const CNetAddr& ip : vIPs) { int nOneDay = 24*3600; CAddress addr = CAddress(CService(ip, Params().GetDefaultPort())); @@ -1330,7 +1330,7 @@ void ThreadOpenConnections() for (int64_t nLoop = 0;; nLoop++) { ProcessOneShot(); - BOOST_FOREACH(const std::string& strAddr, mapMultiArgs["-connect"]) + for (const std::string& strAddr : mapMultiArgs["-connect"]) { CAddress addr; OpenNetworkConnection(addr, NULL, strAddr.c_str()); @@ -1375,7 +1375,7 @@ void ThreadOpenConnections() set > setConnected; { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (!pnode->fInbound) { setConnected.insert(pnode->addr.GetGroup()); nOutbound++; @@ -1433,10 +1433,10 @@ void ThreadOpenAddedConnections() list lAddresses(0); { LOCK(cs_vAddedNodes); - BOOST_FOREACH(const std::string& strAddNode, vAddedNodes) + for (const std::string& strAddNode : vAddedNodes) lAddresses.push_back(strAddNode); } - BOOST_FOREACH(const std::string& strAddNode, lAddresses) { + for (const std::string& strAddNode : lAddresses) { CAddress addr; CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(addr, &grant, strAddNode.c_str()); @@ -1451,19 +1451,19 @@ void ThreadOpenAddedConnections() list lAddresses(0); { LOCK(cs_vAddedNodes); - BOOST_FOREACH(const std::string& strAddNode, vAddedNodes) + for (const std::string& strAddNode : vAddedNodes) lAddresses.push_back(strAddNode); } list > lservAddressesToAdd(0); - BOOST_FOREACH(const std::string& strAddNode, lAddresses) { + for (const std::string& strAddNode : lAddresses) { vector vservNode(0); if(Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0)) { lservAddressesToAdd.push_back(vservNode); { LOCK(cs_setservAddNodeAddresses); - BOOST_FOREACH(const CService& serv, vservNode) + for (const CService& serv : vservNode) setservAddNodeAddresses.insert(serv); } } @@ -1472,9 +1472,9 @@ void ThreadOpenAddedConnections() // (keeping in mind that addnode entries can have many IPs if fNameLookup) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) for (list >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++) - BOOST_FOREACH(const CService& addrNode, *(it)) + for (const CService& addrNode : *(it)) if (pnode->addr == addrNode) { it = lservAddressesToAdd.erase(it); @@ -1482,7 +1482,7 @@ void ThreadOpenAddedConnections() break; } } - BOOST_FOREACH(vector& vserv, lservAddressesToAdd) + for (vector& vserv : lservAddressesToAdd) { CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant); @@ -1534,7 +1534,7 @@ void ThreadMessageHandler() { LOCK(cs_vNodes); vNodesCopy = vNodes; - BOOST_FOREACH(CNode* pnode, vNodesCopy) { + for (CNode* pnode : vNodesCopy) { pnode->AddRef(); } } @@ -1546,7 +1546,7 @@ void ThreadMessageHandler() bool fSleep = true; - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) { if (pnode->fDisconnect) continue; @@ -1581,7 +1581,7 @@ void ThreadMessageHandler() { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) pnode->Release(); } @@ -1706,7 +1706,7 @@ void static Discover(boost::thread_group& threadGroup) vector vaddr; if (LookupHost(pszHostName, vaddr)) { - BOOST_FOREACH (const CNetAddr &addr, vaddr) + for (const CNetAddr &addr : vaddr) { if (AddLocal(addr, LOCAL_IF)) LogPrintf("%s: %s - %s\n", __func__, pszHostName, addr.ToString()); @@ -1818,18 +1818,18 @@ static class CNetCleanup ~CNetCleanup() { // Close sockets - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (pnode->hSocket != INVALID_SOCKET) CloseSocket(pnode->hSocket); - BOOST_FOREACH(ListenSocket& hListenSocket, vhListenSocket) + for (ListenSocket& hListenSocket : vhListenSocket) if (hListenSocket.socket != INVALID_SOCKET) if (!CloseSocket(hListenSocket.socket)) LogPrintf("CloseSocket(hListenSocket) failed with error %s\n", NetworkErrorString(WSAGetLastError())); // clean up some globals (to help leak detection) - BOOST_FOREACH(CNode *pnode, vNodes) + for (CNode *pnode : vNodes) delete pnode; - BOOST_FOREACH(CNode *pnode, vNodesDisconnected) + for (CNode *pnode : vNodesDisconnected) delete pnode; vNodes.clear(); vNodesDisconnected.clear(); @@ -1878,7 +1878,7 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss) vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv)); } LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) { if(!pnode->fRelayTxes) continue; diff --git a/src/net.h b/src/net.h index 63b21f2ca..d042f11ea 100644 --- a/src/net.h +++ b/src/net.h @@ -360,7 +360,7 @@ class CNode unsigned int GetTotalRecvSize() { unsigned int total = 0; - BOOST_FOREACH(const CNetMessage &msg, vRecvMsg) + for (const CNetMessage &msg : vRecvMsg) total += msg.vRecv.size() + 24; return total; } @@ -372,7 +372,7 @@ class CNode void SetRecvVersion(int nVersionIn) { nRecvVersion = nVersionIn; - BOOST_FOREACH(CNetMessage &msg, vRecvMsg) + for (CNetMessage &msg : vRecvMsg) msg.SetVersion(nVersionIn); } diff --git a/src/rest.cpp b/src/rest.cpp index 08f217815..fab8eb713 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -153,7 +153,7 @@ static bool rest_headers(HTTPRequest* req, } CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION); - BOOST_FOREACH(const CBlockIndex *pindex, headers) { + for (const CBlockIndex *pindex : headers) { ssHeader << pindex->GetBlockHeader(); } @@ -173,7 +173,7 @@ static bool rest_headers(HTTPRequest* req, } case RF_JSON: { UniValue jsonHeaders(UniValue::VARR); - BOOST_FOREACH(const CBlockIndex *pindex, headers) { + for (const CBlockIndex *pindex : headers) { jsonHeaders.push_back(blockheaderToJSON(pindex)); } string strJSON = jsonHeaders.write() + "\n"; @@ -562,7 +562,7 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart) objGetUTXOResponse.push_back(Pair("bitmap", bitmapStringRepresentation)); UniValue utxos(UniValue::VARR); - BOOST_FOREACH (const CCoin& coin, outs) { + for (const CCoin& coin : outs) { UniValue utxo(UniValue::VOBJ); utxo.push_back(Pair("txvers", (int32_t)coin.nTxVer)); utxo.push_back(Pair("height", (int32_t)coin.nHeight)); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 1550b7a9d..9b3d4ce24 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -230,7 +230,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); result.push_back(Pair("finalsaplingroot", block.hashFinalSaplingRoot.GetHex())); UniValue txs(UniValue::VARR); - BOOST_FOREACH(const CTransaction&tx, block.vtx) + for (const CTransaction&tx : block.vtx) { if(txDetails) { @@ -320,7 +320,7 @@ UniValue mempoolToJSON(bool fVerbose = false) { LOCK(mempool.cs); UniValue o(UniValue::VOBJ); - BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) + for (const CTxMemPoolEntry& e : mempool.mapTx) { const uint256& hash = e.GetTx().GetHash(); UniValue info(UniValue::VOBJ); @@ -332,14 +332,14 @@ UniValue mempoolToJSON(bool fVerbose = false) info.push_back(Pair("currentpriority", e.GetPriority(chainActive.Height()))); const CTransaction& tx = e.GetTx(); set setDepends; - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) { if (mempool.exists(txin.prevout.hash)) setDepends.insert(txin.prevout.hash.ToString()); } UniValue depends(UniValue::VARR); - BOOST_FOREACH(const string& dep, setDepends) + for (const string& dep : setDepends) { depends.push_back(dep); } @@ -355,7 +355,7 @@ UniValue mempoolToJSON(bool fVerbose = false) mempool.queryHashes(vtxid); UniValue a(UniValue::VARR); - BOOST_FOREACH(const uint256& hash, vtxid) + for (const uint256& hash : vtxid) a.push_back(hash.ToString()); return a; @@ -1161,9 +1161,9 @@ UniValue getchaintips(const UniValue& params, bool fHelp) known blocks, and successively remove blocks that appear as pprev of another block. */ std::set setTips; - BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) + for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex) setTips.insert(item.second); - BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) + for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex) { const CBlockIndex* pprev = item.second->pprev; if (pprev) @@ -1175,7 +1175,7 @@ UniValue getchaintips(const UniValue& params, bool fHelp) /* Construct the output array. */ UniValue res(UniValue::VARR); - BOOST_FOREACH(const CBlockIndex* block, setTips) + for (const CBlockIndex* block : setTips) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("height", block->nHeight)); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index fbe889ab7..c6b9a99ae 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -645,7 +645,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) UniValue transactions(UniValue::VARR); map setTxIndex; int i = 0; - BOOST_FOREACH (const CTransaction& tx, pblock->vtx) { + for (const CTransaction& tx : pblock->vtx) { uint256 txHash = tx.GetHash(); setTxIndex[txHash] = i++; @@ -659,7 +659,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) entry.push_back(Pair("hash", txHash.GetHex())); UniValue deps(UniValue::VARR); - BOOST_FOREACH (const CTxIn &in, tx.vin) + for (const CTxIn &in : tx.vin) { if (setTxIndex.count(in.prevout.hash)) deps.push_back(setTxIndex[in.prevout.hash]); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index a7e618d6c..b074ac13f 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -472,7 +472,7 @@ UniValue setmocktime(const UniValue& params, bool fHelp) SetMockTime(params[0].get_int64()); uint64_t t = GetTime(); - BOOST_FOREACH(CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { pnode->nLastSend = pnode->nLastRecv = t; } diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 9180fe2fb..c5f4ad987 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -55,7 +55,7 @@ UniValue ping(const UniValue& params, bool fHelp) // Request that each node send a ping during next message processing pass LOCK2(cs_main, cs_vNodes); - BOOST_FOREACH(CNode* pNode, vNodes) { + for (CNode* pNode : vNodes) { pNode->fPingQueued = true; } @@ -68,7 +68,7 @@ static void CopyNodeStats(std::vector& vstats) LOCK(cs_vNodes); vstats.reserve(vNodes.size()); - BOOST_FOREACH(CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { CNodeStats stats; pnode->copyStats(stats); vstats.push_back(stats); @@ -122,7 +122,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp) UniValue ret(UniValue::VARR); - BOOST_FOREACH(const CNodeStats& stats, vstats) { + for (const CNodeStats& stats : vstats) { UniValue obj(UniValue::VOBJ); CNodeStateStats statestats; bool fStateStats = GetNodeStateStats(stats.nodeid, statestats); @@ -152,7 +152,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("synced_headers", statestats.nSyncHeight)); obj.push_back(Pair("synced_blocks", statestats.nCommonHeight)); UniValue heights(UniValue::VARR); - BOOST_FOREACH(int height, statestats.vHeightInFlight) { + for (int height : statestats.vHeightInFlight) { heights.push_back(height); } obj.push_back(Pair("inflight", heights)); @@ -276,14 +276,14 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp) if (params.size() == 1) { LOCK(cs_vAddedNodes); - BOOST_FOREACH(const std::string& strAddNode, vAddedNodes) + for (const std::string& strAddNode : vAddedNodes) laddedNodes.push_back(strAddNode); } else { string strNode = params[1].get_str(); LOCK(cs_vAddedNodes); - BOOST_FOREACH(const std::string& strAddNode, vAddedNodes) { + for (const std::string& strAddNode : vAddedNodes) { if (strAddNode == strNode) { laddedNodes.push_back(strAddNode); @@ -297,7 +297,7 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp) UniValue ret(UniValue::VARR); if (!fDns) { - BOOST_FOREACH (const std::string& strAddNode, laddedNodes) { + for (const std::string& strAddNode : laddedNodes) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("addednode", strAddNode)); ret.push_back(obj); @@ -306,7 +306,7 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp) } list > > laddedAddreses(0); - BOOST_FOREACH(const std::string& strAddNode, laddedNodes) { + for (const std::string& strAddNode : laddedNodes) { vector vservNode(0); if(Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0)) laddedAddreses.push_back(make_pair(strAddNode, vservNode)); @@ -328,11 +328,11 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp) UniValue addresses(UniValue::VARR); bool fConnected = false; - BOOST_FOREACH(const CService& addrNode, it->second) { + for (const CService& addrNode : it->second) { bool fFound = false; UniValue node(UniValue::VOBJ); node.push_back(Pair("address", addrNode.ToString())); - BOOST_FOREACH(CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (pnode->addr == addrNode) { fFound = true; @@ -479,7 +479,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp) UniValue localAddresses(UniValue::VARR); { LOCK(cs_mapLocalHost); - BOOST_FOREACH(const PAIRTYPE(CNetAddr, LocalServiceInfo) &item, mapLocalHost) + for (const PAIRTYPE(CNetAddr, LocalServiceInfo) &item : mapLocalHost) { UniValue rec(UniValue::VOBJ); rec.push_back(Pair("address", item.first.ToString())); diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 135f1217d..424109bf1 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -74,7 +74,7 @@ UniValue TxJoinSplitToJSON(const CTransaction& tx) { { UniValue nullifiers(UniValue::VARR); - BOOST_FOREACH(const uint256 nf, jsdescription.nullifiers) { + for (const uint256 nf : jsdescription.nullifiers) { nullifiers.push_back(nf.GetHex()); } joinsplit.push_back(Pair("nullifiers", nullifiers)); @@ -82,7 +82,7 @@ UniValue TxJoinSplitToJSON(const CTransaction& tx) { { UniValue commitments(UniValue::VARR); - BOOST_FOREACH(const uint256 commitment, jsdescription.commitments) { + for (const uint256 commitment : jsdescription.commitments) { commitments.push_back(commitment.GetHex()); } joinsplit.push_back(Pair("commitments", commitments)); @@ -93,7 +93,7 @@ UniValue TxJoinSplitToJSON(const CTransaction& tx) { { UniValue macs(UniValue::VARR); - BOOST_FOREACH(const uint256 mac, jsdescription.macs) { + for (const uint256 mac : jsdescription.macs) { macs.push_back(mac.GetHex()); } joinsplit.push_back(Pair("macs", macs)); @@ -161,7 +161,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) entry.push_back(Pair("expiryheight", (int64_t)tx.nExpiryHeight)); } UniValue vin(UniValue::VARR); - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { UniValue in(UniValue::VOBJ); if (tx.IsCoinBase()) in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); @@ -435,7 +435,7 @@ UniValue gettxoutproof(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); unsigned int ntxFound = 0; - BOOST_FOREACH(const CTransaction&tx, block.vtx) + for (const CTransaction&tx : block.vtx) if (setTxids.count(tx.GetHash())) ntxFound++; if (ntxFound != setTxids.size()) @@ -476,7 +476,7 @@ UniValue verifytxoutproof(const UniValue& params, bool fHelp) if (!mapBlockIndex.count(merkleBlock.header.GetHash()) || !chainActive.Contains(mapBlockIndex[merkleBlock.header.GetHash()])) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain"); - BOOST_FOREACH(const uint256& hash, vMatch) + for (const uint256& hash : vMatch) res.push_back(hash.GetHex()); return res; } @@ -861,7 +861,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp) CCoinsViewMemPool viewMempool(&viewChain, mempool); view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view - BOOST_FOREACH(const CTxIn& txin, mergedTx.vin) { + for (const CTxIn& txin : mergedTx.vin) { const uint256& prevHash = txin.prevout.hash; CCoins coins; view.AccessCoins(prevHash); // this is certainly allowed to fail @@ -1005,7 +1005,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp) ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata, consensusBranchId); // ... and merge in other signatures: - BOOST_FOREACH(const CMutableTransaction& txv, txVariants) { + for (const CMutableTransaction& txv : txVariants) { sigdata = CombineSignatures(prevPubKey, TransactionSignatureChecker(&txConst, i, amount), sigdata, DataFromTransaction(txv, i), consensusBranchId); } diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index ff812d582..2b097a4ce 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -74,7 +74,7 @@ void RPCTypeCheck(const UniValue& params, bool fAllowNull) { size_t i = 0; - BOOST_FOREACH(UniValue::VType t, typesExpected) + for (UniValue::VType t : typesExpected) { if (params.size() <= i) break; @@ -94,7 +94,7 @@ void RPCTypeCheckObj(const UniValue& o, const map& typesExpected, bool fAllowNull) { - BOOST_FOREACH(const PAIRTYPE(string, UniValue::VType)& t, typesExpected) + for (const PAIRTYPE(string, UniValue::VType)& t : typesExpected) { const UniValue& v = find_value(o, t.first); if (!fAllowNull && v.isNull()) @@ -175,7 +175,7 @@ std::string CRPCTable::help(const std::string& strCommand) const vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second)); sort(vCommands.begin(), vCommands.end()); - BOOST_FOREACH(const PAIRTYPE(string, const CRPCCommand*)& command, vCommands) + for (const PAIRTYPE(string, const CRPCCommand*)& command : vCommands) { const CRPCCommand *pcmd = command.second; string strMethod = pcmd->name; diff --git a/src/script/sign.cpp b/src/script/sign.cpp index a6434e80c..c2b871db0 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -117,7 +117,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP static CScript PushAll(const vector& values) { CScript result; - BOOST_FOREACH(const valtype& v, values) { + for (const valtype& v : values) { if (v.size() == 0) { result << OP_0; } else if (v.size() == 1 && v[0] >= 1 && v[0] <= 16) { @@ -210,12 +210,12 @@ static vector CombineMultisig(const CScript& scriptPubKey, const BaseSi { // Combine all the signatures we've got: set allsigs; - BOOST_FOREACH(const valtype& v, sigs1) + for (const valtype& v : sigs1) { if (!v.empty()) allsigs.insert(v); } - BOOST_FOREACH(const valtype& v, sigs2) + for (const valtype& v : sigs2) { if (!v.empty()) allsigs.insert(v); @@ -226,7 +226,7 @@ static vector CombineMultisig(const CScript& scriptPubKey, const BaseSi unsigned int nSigsRequired = vSolutions.front()[0]; unsigned int nPubKeys = vSolutions.size()-2; map sigs; - BOOST_FOREACH(const valtype& sig, allsigs) + for (const valtype& sig : allsigs) { for (unsigned int i = 0; i < nPubKeys; i++) { diff --git a/src/script/standard.cpp b/src/script/standard.cpp index a2bc5c576..b9f31252b 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -70,7 +70,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector& keys) CScript script; script << CScript::EncodeOP_N(nRequired); - BOOST_FOREACH(const CPubKey& key, keys) + for (const CPubKey& key : keys) script << ToByteVector(key); script << CScript::EncodeOP_N(keys.size()) << OP_CHECKMULTISIG; return script; diff --git a/src/sendalert.cpp b/src/sendalert.cpp index b7ebff8c6..8e5d9ed5e 100644 --- a/src/sendalert.cpp +++ b/src/sendalert.cpp @@ -99,7 +99,7 @@ void ThreadSendAlert() // alert.setSubVer.insert(std::string("/MagicBean:0.7.2/")); const std::vector useragents = {}; //{"MagicBean", "BeanStalk", "AppleSeed", "EleosZcash"}; - BOOST_FOREACH(const std::string& useragent, useragents) { + for (const std::string& useragent : useragents) { } // Sanity check @@ -161,7 +161,7 @@ void ThreadSendAlert() int nSent = 0; { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) { if (alert2.RelayTo(pnode)) { diff --git a/src/sync.cpp b/src/sync.cpp index 91a6745c0..100798308 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -76,7 +76,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, LogPrintf("POTENTIAL DEADLOCK DETECTED\n"); LogPrintf("Previous lock order was:\n"); - BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s2) { + for (const PAIRTYPE(void*, CLockLocation) & i : s2) { if (i.first == mismatch.first) { LogPrintf(" (1)"); if (!firstLocked && secondLocked && i.second.fTry) @@ -94,7 +94,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, firstLocked = false; secondLocked = false; LogPrintf("Current lock order is:\n"); - BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s1) { + for (const PAIRTYPE(void*, CLockLocation) & i : s1) { if (i.first == mismatch.first) { LogPrintf(" (1)"); if (!firstLocked && secondLocked && i.second.fTry) @@ -122,7 +122,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry) (*lockstack).push_back(std::make_pair(c, locklocation)); if (!fTry) { - BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, (*lockstack)) { + for (const PAIRTYPE(void*, CLockLocation) & i : (*lockstack)) { if (i.first == c) break; @@ -159,14 +159,14 @@ void LeaveCritical() std::string LocksHeld() { std::string result; - BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, *lockstack) + for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack) result += i.second.ToString() + std::string("\n"); return result; } void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs) { - BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, *lockstack) + for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack) if (i.first == cs) return; fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str()); diff --git a/src/test/accounting_tests.cpp b/src/test/accounting_tests.cpp index dcf28ed85..8538479cc 100644 --- a/src/test/accounting_tests.cpp +++ b/src/test/accounting_tests.cpp @@ -24,7 +24,7 @@ GetResults(CWalletDB& walletdb, std::map& results) results.clear(); BOOST_CHECK(walletdb.ReorderTransactions(pwalletMain) == DB_LOAD_OK); walletdb.ListAccountCreditDebit("", aes); - BOOST_FOREACH(CAccountingEntry& ae, aes) + for (CAccountingEntry& ae : aes) { results[ae.nOrderPos] = ae; } diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index fee95cacd..0c84c5d7e 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -289,7 +289,7 @@ BOOST_AUTO_TEST_CASE(AlertApplies) SetMockTime(11); const std::vector& alertKey = Params(CBaseChainParams::MAIN).AlertKey(); - BOOST_FOREACH(const CAlert& alert, alerts) + for (const CAlert& alert : alerts) { BOOST_CHECK(alert.CheckSignature(alertKey)); } @@ -335,7 +335,7 @@ BOOST_AUTO_TEST_CASE(AlertNotify) mapArgs["-alertnotify"] = std::string("echo %s >> ") + temp.string(); - BOOST_FOREACH(CAlert alert, alerts) + for (CAlert alert : alerts) alert.ProcessAlert(alertKey, false); std::vector r = read_lines(temp); diff --git a/src/test/bip32_tests.cpp b/src/test/bip32_tests.cpp index 104173b19..b19ed1d08 100644 --- a/src/test/bip32_tests.cpp +++ b/src/test/bip32_tests.cpp @@ -84,7 +84,7 @@ void RunTest(const TestVector &test) { CExtPubKey pubkey; key.SetMaster(&seed[0], seed.size()); pubkey = key.Neuter(); - BOOST_FOREACH(const TestDerivation &derive, test.vDerive) { + for (const TestDerivation &derive : test.vDerive) { unsigned char data[74]; key.Encode(data); pubkey.Encode(data); diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index cd7b21441..3932dafe0 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -836,7 +836,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test) missed_an_entry = true; } } - BOOST_FOREACH(const CCoinsViewCacheTest *test, stack) { + for (const CCoinsViewCacheTest *test : stack) { test->SelfTest(); } } diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp index acc1adab7..99ec100f9 100644 --- a/src/test/getarg_tests.cpp +++ b/src/test/getarg_tests.cpp @@ -25,7 +25,7 @@ static void ResetArgs(const std::string& strArg) // Convert to char*: std::vector vecChar; - BOOST_FOREACH(std::string& s, vecArg) + for (std::string& s : vecArg) vecChar.push_back(s.c_str()); ParseParameters(vecChar.size(), &vecChar[0]); diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index c88a53c13..3f7f13b73 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -447,7 +447,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) SetMockTime(0); mempool.clear(); - BOOST_FOREACH(CTransaction *tx, txFirst) + for (CTransaction *tx : txFirst) delete tx; fCheckpointsEnabled = true; diff --git a/src/test/mruset_tests.cpp b/src/test/mruset_tests.cpp index 04f2f9b05..0ac799de4 100644 --- a/src/test/mruset_tests.cpp +++ b/src/test/mruset_tests.cpp @@ -53,18 +53,18 @@ BOOST_AUTO_TEST_CASE(mruset_test) mruset mru2 = mru; // Also try making a copy // Check that all elements that should be in there, are in there. - BOOST_FOREACH(int x, rep) { + for (int x : rep) { BOOST_CHECK(mru.count(x)); BOOST_CHECK(mru2.count(x)); } // Check that all elements that are in there, should be in there. - BOOST_FOREACH(int x, mru) { + for (int x : mru) { BOOST_CHECK(all.count(x)); } // Check that all elements that are in there, should be in there. - BOOST_FOREACH(int x, mru2) { + for (int x : mru2) { BOOST_CHECK(all.count(x)); } diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp index 506575f1a..116c1ce4f 100644 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -34,7 +34,7 @@ sign_multisig(CScript scriptPubKey, vector keys, CTransaction transaction, CScript result; result << OP_0; // CHECKMULTISIG bug workaround - BOOST_FOREACH(const CKey &key, keys) + for (const CKey &key : keys) { vector vchSig; BOOST_CHECK(key.Sign(hash, vchSig)); diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index 7e93d4248..723fd3e62 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -39,13 +39,13 @@ class prevector_tester { BOOST_CHECK(pretype(real_vector.begin(), real_vector.end()) == pre_vector); BOOST_CHECK(pretype(pre_vector.begin(), pre_vector.end()) == pre_vector); size_t pos = 0; - BOOST_FOREACH(const T& v, pre_vector) { + for (const T& v : pre_vector) { BOOST_CHECK(v == real_vector[pos++]); } BOOST_REVERSE_FOREACH(const T& v, pre_vector) { BOOST_CHECK(v == real_vector[--pos]); } - BOOST_FOREACH(const T& v, const_pre_vector) { + for (const T& v : const_pre_vector) { BOOST_CHECK(v == real_vector[pos++]); } BOOST_REVERSE_FOREACH(const T& v, const_pre_vector) { diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 2b2ec3fbf..147c135c1 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -547,7 +547,7 @@ BOOST_AUTO_TEST_CASE(script_build) std::string strGood; std::string strBad; - BOOST_FOREACH(TestBuilder& test, good) { + for (TestBuilder& test : good) { test.Test(true); std::string str = test.GetJSON().write(); #ifndef UPDATE_JSON_TESTS @@ -557,7 +557,7 @@ BOOST_AUTO_TEST_CASE(script_build) #endif strGood += str + ",\n"; } - BOOST_FOREACH(TestBuilder& test, bad) { + for (TestBuilder& test : bad) { test.Test(false); std::string str = test.GetJSON().write(); #ifndef UPDATE_JSON_TESTS @@ -688,7 +688,7 @@ sign_multisig(CScript scriptPubKey, std::vector keys, CTransaction transac // and vice-versa) // result << OP_0; - BOOST_FOREACH(const CKey &key, keys) + for (const CKey &key : keys) { vector vchSig; BOOST_CHECK(key.Sign(hash, vchSig)); diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 3d888b323..d05bacf89 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -65,7 +65,7 @@ unsigned int ParseScriptFlags(string strFlags) vector words; boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(",")); - BOOST_FOREACH(string word, words) + for (string word : words) { if (!mapFlagNames.count(word)) BOOST_ERROR("Bad test: unknown verification flag '" << word << "'"); diff --git a/src/timedata.cpp b/src/timedata.cpp index 4bd9f47ce..f281e5222 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -93,7 +93,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) { // If nobody has a time different than ours but within 5 minutes of ours, give a warning bool fMatch = false; - BOOST_FOREACH(int64_t nOffset, vSorted) + for (int64_t nOffset : vSorted) if (nOffset != 0 && abs64(nOffset) < 5 * 60) fMatch = true; @@ -108,7 +108,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) } } if (fDebug) { - BOOST_FOREACH(int64_t n, vSorted) + for (int64_t n : vSorted) LogPrintf("%+d ", n); LogPrintf("| "); } diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index 4618042a5..a5c98a87d 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -488,7 +488,7 @@ void TorController::add_onion_cb(TorControlConnection& conn, const TorControlRep { if (reply.code == 250) { LogPrint("tor", "tor: ADD_ONION successful\n"); - BOOST_FOREACH(const std::string &s, reply.lines) { + for (const std::string &s : reply.lines) { std::map m = ParseTorReplyMapping(s); std::map::iterator i; if ((i = m.find("ServiceID")) != m.end()) @@ -618,7 +618,7 @@ void TorController::protocolinfo_cb(TorControlConnection& conn, const TorControl * 250-AUTH METHODS=NULL * 250-AUTH METHODS=HASHEDPASSWORD */ - BOOST_FOREACH(const std::string &s, reply.lines) { + for (const std::string &s : reply.lines) { std::pair l = SplitTorReplyLine(s); if (l.first == "AUTH") { std::map m = ParseTorReplyMapping(l.second); @@ -635,7 +635,7 @@ void TorController::protocolinfo_cb(TorControlConnection& conn, const TorControl } } } - BOOST_FOREACH(const std::string &s, methods) { + for (const std::string &s : methods) { LogPrint("tor", "tor: Supported authentication method: %s\n", s); } // Prefer NULL, otherwise SAFECOOKIE. If a password is provided, use HASHEDPASSWORD diff --git a/src/txmempool.cpp b/src/txmempool.cpp index ead7e2068..3c48422dc 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -108,8 +108,8 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, nRecentlyAddedSequence += 1; for (unsigned int i = 0; i < tx.vin.size(); i++) mapNextTx[tx.vin[i].prevout] = CInPoint(&tx, i); - BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) { - BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) { + for (const JSDescription &joinsplit : tx.vJoinSplit) { + for (const uint256 &nf : joinsplit.nullifiers) { mapSproutNullifiers[nf] = &tx; } } @@ -266,10 +266,10 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list& rem } } mapRecentlyAddedTx.erase(hash); - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) mapNextTx.erase(txin.prevout); - BOOST_FOREACH(const JSDescription& joinsplit, tx.vJoinSplit) { - BOOST_FOREACH(const uint256& nf, joinsplit.nullifiers) { + for (const JSDescription& joinsplit : tx.vJoinSplit) { + for (const uint256& nf : joinsplit.nullifiers) { mapSproutNullifiers.erase(nf); } } @@ -302,7 +302,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem if (!CheckFinalTx(tx, flags)) { transactionsToRemove.push_back(tx); } else if (it->GetSpendsCoinbase()) { - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash); if (it2 != mapTx.end()) continue; @@ -315,7 +315,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem } } } - BOOST_FOREACH(const CTransaction& tx, transactionsToRemove) { + for (const CTransaction& tx : transactionsToRemove) { list removed; remove(tx, removed, true); } @@ -335,7 +335,7 @@ void CTxMemPool::removeWithAnchor(const uint256 &invalidRoot, ShieldedType type) const CTransaction& tx = it->GetTx(); switch (type) { case SPROUT: - BOOST_FOREACH(const JSDescription& joinsplit, tx.vJoinSplit) { + for (const JSDescription& joinsplit : tx.vJoinSplit) { if (joinsplit.anchor == invalidRoot) { transactionsToRemove.push_back(tx); break; @@ -343,7 +343,7 @@ void CTxMemPool::removeWithAnchor(const uint256 &invalidRoot, ShieldedType type) } break; case SAPLING: - BOOST_FOREACH(const SpendDescription& spendDescription, tx.vShieldedSpend) { + for (const SpendDescription& spendDescription : tx.vShieldedSpend) { if (spendDescription.anchor == invalidRoot) { transactionsToRemove.push_back(tx); break; @@ -356,7 +356,7 @@ void CTxMemPool::removeWithAnchor(const uint256 &invalidRoot, ShieldedType type) } } - BOOST_FOREACH(const CTransaction& tx, transactionsToRemove) { + for (const CTransaction& tx : transactionsToRemove) { list removed; remove(tx, removed, true); } @@ -367,7 +367,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list // Remove transactions which depend on inputs of tx, recursively list result; LOCK(cs); - BOOST_FOREACH(const CTxIn &txin, tx.vin) { + for (const CTxIn &txin : tx.vin) { std::map::iterator it = mapNextTx.find(txin.prevout); if (it != mapNextTx.end()) { const CTransaction &txConflict = *it->second.ptx; @@ -378,8 +378,8 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list } } - BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) { - BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) { + for (const JSDescription &joinsplit : tx.vJoinSplit) { + for (const uint256 &nf : joinsplit.nullifiers) { std::map::iterator it = mapSproutNullifiers.find(nf); if (it != mapSproutNullifiers.end()) { const CTransaction &txConflict = *it->second; @@ -427,7 +427,7 @@ void CTxMemPool::removeForBlock(const std::vector& vtx, unsigned i { LOCK(cs); std::vector entries; - BOOST_FOREACH(const CTransaction& tx, vtx) + for (const CTransaction& tx : vtx) { uint256 hash = tx.GetHash(); @@ -435,7 +435,7 @@ void CTxMemPool::removeForBlock(const std::vector& vtx, unsigned i if (i != mapTx.end()) entries.push_back(*i); } - BOOST_FOREACH(const CTransaction& tx, vtx) + for (const CTransaction& tx : vtx) { std::list dummy; remove(tx, dummy, false); @@ -502,7 +502,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const innerUsage += it->DynamicMemoryUsage(); const CTransaction& tx = it->GetTx(); bool fDependsWait = false; - BOOST_FOREACH(const CTxIn &txin, tx.vin) { + for (const CTxIn &txin : tx.vin) { // Check that every mempool transaction's inputs refer to available coins, or other mempool tx's. indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash); if (it2 != mapTx.end()) { @@ -523,8 +523,8 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const boost::unordered_map intermediates; - BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) { - BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) { + for (const JSDescription &joinsplit : tx.vJoinSplit) { + for (const uint256 &nf : joinsplit.nullifiers) { assert(!pcoins->GetNullifier(nf, SPROUT)); } @@ -536,7 +536,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const assert(pcoins->GetSproutAnchorAt(joinsplit.anchor, tree)); } - BOOST_FOREACH(const uint256& commitment, joinsplit.commitments) + for (const uint256& commitment : joinsplit.commitments) { tree.append(commitment); } diff --git a/src/util.cpp b/src/util.cpp index af32ef66e..ef633dba8 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -369,7 +369,7 @@ void ParseParameters(int argc, const char* const argv[]) } // New 0.6 features: - BOOST_FOREACH(const PAIRTYPE(string,string)& entry, mapArgs) + for (const PAIRTYPE(string,string)& entry : mapArgs) { // interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set InterpretNegativeSetting(entry.first, mapArgs); diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 91f620e5a..d5a2a0a79 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -907,7 +907,7 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) { pwalletMain->AvailableCoins(vecOutputs, false, NULL, true, fAcceptCoinbase); - BOOST_FOREACH(const COutput& out, vecOutputs) { + for (const COutput& out : vecOutputs) { if (!out.fSpendable) { continue; } diff --git a/src/wallet/crypter.cpp b/src/wallet/crypter.cpp index 1d9bd2848..0c39825bc 100644 --- a/src/wallet/crypter.cpp +++ b/src/wallet/crypter.cpp @@ -564,7 +564,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn) } hdSeed = HDSeed(); } - BOOST_FOREACH(KeyMap::value_type& mKey, mapKeys) + for (KeyMap::value_type& mKey : mapKeys) { const CKey &key = mKey.second; CPubKey vchPubKey = key.GetPubKey(); @@ -578,7 +578,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn) } } mapKeys.clear(); - BOOST_FOREACH(SproutSpendingKeyMap::value_type& mSproutSpendingKey, mapSproutSpendingKeys) + for (SproutSpendingKeyMap::value_type& mSproutSpendingKey : mapSproutSpendingKeys) { const libzcash::SproutSpendingKey &sk = mSproutSpendingKey.second; CSecureDataStream ss(SER_NETWORK, PROTOCOL_VERSION); @@ -595,7 +595,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn) } mapSproutSpendingKeys.clear(); //! Sapling key support - BOOST_FOREACH(SaplingSpendingKeyMap::value_type& mSaplingSpendingKey, mapSaplingSpendingKeys) + for (SaplingSpendingKeyMap::value_type& mSaplingSpendingKey : mapSaplingSpendingKeys) { const auto &sk = mSaplingSpendingKey.second; CSecureDataStream ss(SER_NETWORK, PROTOCOL_VERSION); diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index e2d093a5e..276552772 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -50,7 +50,7 @@ int64_t static DecodeDumpTime(const std::string &str) { std::string static EncodeDumpString(const std::string &str) { std::stringstream ret; - BOOST_FOREACH(unsigned char c, str) { + for (unsigned char c : str) { if (c <= 32 || c >= 128 || c == '%') { ret << '%' << HexStr(&c, &c + 1); } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fd9b79857..b57376a19 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -98,12 +98,12 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) uint256 hash = wtx.GetHash(); entry.push_back(Pair("txid", hash.GetHex())); UniValue conflicts(UniValue::VARR); - BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts()) + for (const uint256& conflict : wtx.GetConflicts()) conflicts.push_back(conflict.GetHex()); entry.push_back(Pair("walletconflicts", conflicts)); entry.push_back(Pair("time", wtx.GetTxTime())); entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived)); - BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue) + for (const PAIRTYPE(string,string)& item : wtx.mapValue) entry.push_back(Pair(item.first, item.second)); entry.push_back(Pair("vJoinSplit", TxJoinSplitToJSON(wtx))); @@ -175,7 +175,7 @@ CTxDestination GetAccountAddress(std::string strAccount, bool bForceNew=false) ++it) { const CWalletTx& wtx = (*it).second; - BOOST_FOREACH(const CTxOut& txout, wtx.vout) + for (const CTxOut& txout : wtx.vout) if (txout.scriptPubKey == scriptPubKey) bKeyUsed = true; } @@ -628,7 +628,7 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp) if (wtx.IsCoinBase() || !CheckFinalTx(wtx)) continue; - BOOST_FOREACH(const CTxOut& txout, wtx.vout) + for (const CTxOut& txout : wtx.vout) if (txout.scriptPubKey == scriptPubKey) if (wtx.GetDepthInMainChain() >= nMinDepth) nAmount += txout.nValue; @@ -682,7 +682,7 @@ UniValue getreceivedbyaccount(const UniValue& params, bool fHelp) if (wtx.IsCoinBase() || !CheckFinalTx(wtx)) continue; - BOOST_FOREACH(const CTxOut& txout, wtx.vout) + for (const CTxOut& txout : wtx.vout) { CTxDestination address; if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwalletMain, address) && setAddress.count(address)) @@ -782,10 +782,10 @@ UniValue getbalance(const UniValue& params, bool fHelp) wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount, filter); if (wtx.GetDepthInMainChain() >= nMinDepth) { - BOOST_FOREACH(const COutputEntry& r, listReceived) + for (const COutputEntry& r : listReceived) nBalance += r.amount; } - BOOST_FOREACH(const COutputEntry& s, listSent) + for (const COutputEntry& s : listSent) nBalance -= s.amount; nBalance -= allFee; } @@ -1161,7 +1161,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) if (nDepth < nMinDepth) continue; - BOOST_FOREACH(const CTxOut& txout, wtx.vout) + for (const CTxOut& txout : wtx.vout) { CTxDestination address; if (!ExtractDestination(txout.scriptPubKey, address)) @@ -1219,7 +1219,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) UniValue transactions(UniValue::VARR); if (it != mapTally.end()) { - BOOST_FOREACH(const uint256& item, (*it).second.txids) + for (const uint256& item : (*it).second.txids) { transactions.push_back(item.GetHex()); } @@ -1343,7 +1343,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe // Sent if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount)) { - BOOST_FOREACH(const COutputEntry& s, listSent) + for (const COutputEntry& s : listSent) { UniValue entry(UniValue::VOBJ); if(involvesWatchonly || (::IsMine(*pwalletMain, s.destination) & ISMINE_WATCH_ONLY)) @@ -1364,7 +1364,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe // Received if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) { - BOOST_FOREACH(const COutputEntry& r, listReceived) + for (const COutputEntry& r : listReceived) { string account; if (pwalletMain->mapAddressBook.count(r.destination)) @@ -1578,7 +1578,7 @@ UniValue listaccounts(const UniValue& params, bool fHelp) includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY; map mapAccountBalances; - BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& entry, pwalletMain->mapAddressBook) { + for (const PAIRTYPE(CTxDestination, CAddressBookData)& entry : pwalletMain->mapAddressBook) { if (IsMine(*pwalletMain, entry.first) & includeWatchonly) // This address belongs to me mapAccountBalances[entry.second.name] = 0; } @@ -1595,11 +1595,11 @@ UniValue listaccounts(const UniValue& params, bool fHelp) continue; wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, includeWatchonly); mapAccountBalances[strSentAccount] -= nFee; - BOOST_FOREACH(const COutputEntry& s, listSent) + for (const COutputEntry& s : listSent) mapAccountBalances[strSentAccount] -= s.amount; if (nDepth >= nMinDepth) { - BOOST_FOREACH(const COutputEntry& r, listReceived) + for (const COutputEntry& r : listReceived) if (pwalletMain->mapAddressBook.count(r.destination)) mapAccountBalances[pwalletMain->mapAddressBook[r.destination].name] += r.amount; else @@ -1609,11 +1609,11 @@ UniValue listaccounts(const UniValue& params, bool fHelp) list acentries; CWalletDB(pwalletMain->strWalletFile).ListAccountCreditDebit("*", acentries); - BOOST_FOREACH(const CAccountingEntry& entry, acentries) + for (const CAccountingEntry& entry : acentries) mapAccountBalances[entry.strAccount] += entry.nCreditDebit; UniValue ret(UniValue::VOBJ); - BOOST_FOREACH(const PAIRTYPE(string, CAmount)& accountBalance, mapAccountBalances) { + for (const PAIRTYPE(string, CAmount)& accountBalance : mapAccountBalances) { ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); } return ret; @@ -2224,7 +2224,7 @@ UniValue listlockunspent(const UniValue& params, bool fHelp) UniValue ret(UniValue::VARR); - BOOST_FOREACH(COutPoint &outpt, vOutpts) { + for (COutPoint &outpt : vOutpts) { UniValue o(UniValue::VOBJ); o.push_back(Pair("txid", outpt.hash.GetHex())); @@ -2326,7 +2326,7 @@ UniValue resendwallettransactions(const UniValue& params, bool fHelp) std::vector txids = pwalletMain->ResendWalletTransactionsBefore(GetTime()); UniValue result(UniValue::VARR); - BOOST_FOREACH(const uint256& txid, txids) + for (const uint256& txid : txids) { result.push_back(txid.ToString()); } @@ -2407,7 +2407,7 @@ UniValue listunspent(const UniValue& params, bool fHelp) assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); - BOOST_FOREACH(const COutput& out, vecOutputs) { + for (const COutput& out : vecOutputs) { if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) continue; @@ -3263,7 +3263,7 @@ CAmount getBalanceTaddr(std::string transparentAddress, int minDepth=1, bool ign pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); - BOOST_FOREACH(const COutput& out, vecOutputs) { + for (const COutput& out : vecOutputs) { if (out.nDepth < minDepth) { continue; } @@ -4377,7 +4377,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) pwalletMain->AvailableCoins(vecOutputs, true, NULL, false, true); // Find unspent coinbase utxos and update estimated size - BOOST_FOREACH(const COutput& out, vecOutputs) { + for (const COutput& out : vecOutputs) { if (!out.fSpendable) { continue; } diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 5807600b3..bed4d53d6 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -54,7 +54,7 @@ static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = fa static void empty_wallet(void) { - BOOST_FOREACH(COutput output, vCoins) + for (COutput output : vCoins) delete output.tx; vCoins.clear(); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c8f634b5d..31b184c15 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -515,7 +515,7 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase) { LOCK(cs_wallet); - BOOST_FOREACH(const MasterKeyMap::value_type& pMasterKey, mapMasterKeys) + for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys) { if(!crypter.SetKeyFromPassphrase(strWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) return false; @@ -544,7 +544,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, CCrypter crypter; CKeyingMaterial vMasterKey; - BOOST_FOREACH(MasterKeyMap::value_type& pMasterKey, mapMasterKeys) + for (MasterKeyMap::value_type& pMasterKey : mapMasterKeys) { if(!crypter.SetKeyFromPassphrase(strOldWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) return false; @@ -796,7 +796,7 @@ set CWallet::GetConflicts(const uint256& txid) const std::pair range; - BOOST_FOREACH(const CTxIn& txin, wtx.vin) + for (const CTxIn& txin : wtx.vin) { if (mapTxSpends.count(txin.prevout) <= 1) continue; // No conflict if zero or one spends @@ -1375,7 +1375,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, } acentries.clear(); walletdb.ListAccountCreditDebit(strAccount, acentries); - BOOST_FOREACH(CAccountingEntry& entry, acentries) + for (CAccountingEntry& entry : acentries) { txOrdered.insert(make_pair(entry.nOrderPos, TxPair((CWalletTx*)0, &entry))); } @@ -1387,7 +1387,7 @@ void CWallet::MarkDirty() { { LOCK(cs_wallet); - BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) + for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) item.second.MarkDirty(); } } @@ -1741,7 +1741,7 @@ void CWallet::MarkAffectedTransactionsDirty(const CTransaction& tx) // If a transaction changes 'conflicted' state, that changes the balance // available of the outputs it spends. So force those to be // recomputed, also: - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) { if (mapWallet.count(txin.prevout.hash)) mapWallet[txin.prevout.hash].MarkDirty(); @@ -2053,7 +2053,7 @@ CAmount CWallet::GetChange(const CTxOut& txout) const bool CWallet::IsMine(const CTransaction& tx) const { - BOOST_FOREACH(const CTxOut& txout, tx.vout) + for (const CTxOut& txout : tx.vout) if (IsMine(txout)) return true; return false; @@ -2082,7 +2082,7 @@ bool CWallet::IsFromMe(const CTransaction& tx) const CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) const { CAmount nDebit = 0; - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) { nDebit += GetDebit(txin, filter); if (!MoneyRange(nDebit)) @@ -2094,7 +2094,7 @@ CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) co CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) const { CAmount nCredit = 0; - BOOST_FOREACH(const CTxOut& txout, tx.vout) + for (const CTxOut& txout : tx.vout) { nCredit += GetCredit(txout, filter); if (!MoneyRange(nCredit)) @@ -2106,7 +2106,7 @@ CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) c CAmount CWallet::GetChange(const CTransaction& tx) const { CAmount nChange = 0; - BOOST_FOREACH(const CTxOut& txout, tx.vout) + for (const CTxOut& txout : tx.vout) { nChange += GetChange(txout); if (!MoneyRange(nChange)) @@ -2513,13 +2513,13 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, CAmount& nReceived, if (strAccount == strSentAccount) { - BOOST_FOREACH(const COutputEntry& s, listSent) + for (const COutputEntry& s : listSent) nSent += s.amount; nFee = allFee; } { LOCK(pwallet->cs_wallet); - BOOST_FOREACH(const COutputEntry& r, listReceived) + for (const COutputEntry& r : listReceived) { if (pwallet->mapAddressBook.count(r.destination)) { @@ -2553,22 +2553,22 @@ void CWallet::WitnessNoteCommitment(std::vector commitments, CBlock block; ReadBlockFromDisk(block, pindex, Params().GetConsensus()); - BOOST_FOREACH(const CTransaction& tx, block.vtx) + for (const CTransaction& tx : block.vtx) { - BOOST_FOREACH(const JSDescription& jsdesc, tx.vJoinSplit) + for (const JSDescription& jsdesc : tx.vJoinSplit) { - BOOST_FOREACH(const uint256 ¬e_commitment, jsdesc.commitments) + for (const uint256 ¬e_commitment : jsdesc.commitments) { tree.append(note_commitment); - BOOST_FOREACH(boost::optional& wit, witnesses) { + for (boost::optional& wit : witnesses) { if (wit) { wit->append(note_commitment); } } size_t i = 0; - BOOST_FOREACH(uint256& commitment, commitments) { + for (uint256& commitment : commitments) { if (note_commitment == commitment) { witnesses.at(i) = tree.witness(); } @@ -2591,7 +2591,7 @@ void CWallet::WitnessNoteCommitment(std::vector commitments, // TODO: #93; Select a root via some heuristic. final_anchor = tree.root(); - BOOST_FOREACH(boost::optional& wit, witnesses) { + for (boost::optional& wit : witnesses) { if (wit) { assert(final_anchor == wit->root()); } @@ -2631,7 +2631,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) CBlock block; ReadBlockFromDisk(block, pindex, Params().GetConsensus()); - BOOST_FOREACH(CTransaction& tx, block.vtx) + for (CTransaction& tx : block.vtx) { if (AddToWalletIfInvolvingMe(tx, &block, fUpdate)) { myTxHashes.push_back(tx.GetHash()); @@ -2685,7 +2685,7 @@ void CWallet::ReacceptWalletTransactions() std::map mapSorted; // Sort pending wallet transactions based on their initial wallet insertion order - BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) + for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) { const uint256& wtxid = item.first; CWalletTx& wtx = item.second; @@ -2699,7 +2699,7 @@ void CWallet::ReacceptWalletTransactions() } // Try to add wallet transactions to memory pool - BOOST_FOREACH(PAIRTYPE(const int64_t, CWalletTx*)& item, mapSorted) + for (PAIRTYPE(const int64_t, CWalletTx*)& item : mapSorted) { CWalletTx& wtx = *(item.second); @@ -2908,7 +2908,7 @@ bool CWalletTx::IsTrusted() const return false; // Trusted if all inputs are from us and are in the mempool: - BOOST_FOREACH(const CTxIn& txin, vin) + for (const CTxIn& txin : vin) { // Transactions not sent by us: not trusted const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash); @@ -2928,7 +2928,7 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime) LOCK(cs_wallet); // Sort them in chronological order multimap mapSorted; - BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) + for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) { CWalletTx& wtx = item.second; // Don't rebroadcast if newer than nTime: @@ -2936,7 +2936,7 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime) continue; mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx)); } - BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted) + for (PAIRTYPE(const unsigned int, CWalletTx*)& item : mapSorted) { CWalletTx& wtx = *item.second; if (wtx.RelayWalletTransaction()) @@ -3173,7 +3173,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); - BOOST_FOREACH(const COutput &output, vCoins) + for (const COutput &output : vCoins) { if (!output.fSpendable) continue; @@ -3295,7 +3295,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set return all selected outputs (we want all selected to go into the transaction for sure) if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs) { - BOOST_FOREACH(const COutput& out, vCoins) + for (const COutput& out : vCoins) { if (!out.fSpendable) continue; @@ -3312,7 +3312,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set vPresetInputs; if (coinControl) coinControl->ListSelected(vPresetInputs); - BOOST_FOREACH(const COutPoint& outpoint, vPresetInputs) + for (const COutPoint& outpoint : vPresetInputs) { map::const_iterator it = mapWallet.find(outpoint.hash); if (it != mapWallet.end()) @@ -3355,7 +3355,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC vector vecSend; // Turn the txout set into a CRecipient vector - BOOST_FOREACH(const CTxOut& txOut, tx.vout) + for (const CTxOut& txOut : tx.vout) { CRecipient recipient = {txOut.scriptPubKey, txOut.nValue, false}; vecSend.push_back(recipient); @@ -3364,7 +3364,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC CCoinControl coinControl; coinControl.fAllowOtherInputs = true; coinControl.fAllowWatchOnly = includeWatching; - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) coinControl.Select(txin.prevout); CReserveKey reservekey(this); @@ -3377,10 +3377,10 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC tx.vout.insert(tx.vout.begin() + nChangePosRet, wtx.vout[nChangePosRet]); // Add new txins (keeping original txin scriptSig/order) - BOOST_FOREACH(const CTxIn& txin, wtx.vin) + for (const CTxIn& txin : wtx.vin) { bool found = false; - BOOST_FOREACH(const CTxIn& origTxIn, tx.vin) + for (const CTxIn& origTxIn : tx.vin) { if (txin.prevout.hash == origTxIn.prevout.hash && txin.prevout.n == origTxIn.prevout.n) { @@ -3400,7 +3400,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt { CAmount nValue = 0; unsigned int nSubtractFeeFromAmount = 0; - BOOST_FOREACH (const CRecipient& recipient, vecSend) + for (const CRecipient& recipient : vecSend) { if (nValue < 0 || recipient.nAmount < 0) { @@ -3476,7 +3476,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt nTotalValue += nFeeRet; double dPriority = 0; // vouts to the payees - BOOST_FOREACH (const CRecipient& recipient, vecSend) + for (const CRecipient& recipient : vecSend) { CTxOut txout(recipient.nAmount, recipient.scriptPubKey); @@ -3523,7 +3523,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt } return false; } - BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) + for (PAIRTYPE(const CWalletTx*, unsigned int) pcoin : setCoins) { CAmount nCredit = pcoin.first->vout[pcoin.second].nValue; //The coin age after the next block (depth+1) is used instead of the current, @@ -3616,7 +3616,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt // // Note how the sequence number is set to max()-1 so that the // nLockTime set above actually works. - BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins) + for (const PAIRTYPE(const CWalletTx*,unsigned int)& coin : setCoins) txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(), std::numeric_limits::max()-1)); @@ -3642,7 +3642,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt // Sign int nIn = 0; CTransaction txNewConst(txNew); - BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins) + for (const PAIRTYPE(const CWalletTx*,unsigned int)& coin : setCoins) { bool signSuccess; const CScript& scriptPubKey = coin.first->vout[coin.second].scriptPubKey; @@ -3667,7 +3667,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt // Remove scriptSigs if we used dummy signatures for fee calculation if (!sign) { - BOOST_FOREACH (CTxIn& vin, txNew.vin) + for (CTxIn& vin : txNew.vin) vin.scriptSig = CScript(); } @@ -3745,7 +3745,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, boost::optional // Notify that old coins are spent set setCoins; - BOOST_FOREACH(const CTxIn& txin, wtxNew.vin) + for (const CTxIn& txin : wtxNew.vin) { CWalletTx &coin = mapWallet[txin.prevout.hash]; coin.BindWallet(this); @@ -3881,7 +3881,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address) { // Delete destdata tuples associated with address std::string strAddress = EncodeDestination(address); - BOOST_FOREACH(const PAIRTYPE(string, string) &item, mapAddressBook[address].destdata) + for (const PAIRTYPE(string, string) &item : mapAddressBook[address].destdata) { CWalletDB(strWalletFile).EraseDestData(strAddress, item.first); } @@ -3917,7 +3917,7 @@ bool CWallet::NewKeyPool() { LOCK(cs_wallet); CWalletDB walletdb(strWalletFile); - BOOST_FOREACH(int64_t nIndex, setKeyPool) + for (int64_t nIndex : setKeyPool) walletdb.ErasePool(nIndex); setKeyPool.clear(); @@ -4051,7 +4051,7 @@ std::map CWallet::GetAddressBalances() { LOCK(cs_wallet); - BOOST_FOREACH(PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet) + for (PAIRTYPE(uint256, CWalletTx) walletEntry : mapWallet) { CWalletTx *pcoin = &walletEntry.second; @@ -4091,7 +4091,7 @@ set< set > CWallet::GetAddressGroupings() set< set > groupings; set grouping; - BOOST_FOREACH(PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet) + for (PAIRTYPE(uint256, CWalletTx) walletEntry : mapWallet) { CWalletTx *pcoin = &walletEntry.second; @@ -4099,7 +4099,7 @@ set< set > CWallet::GetAddressGroupings() { bool any_mine = false; // group all input addresses with each other - BOOST_FOREACH(CTxIn txin, pcoin->vin) + for (CTxIn txin : pcoin->vin) { CTxDestination address; if(!IsMine(txin)) /* If this input isn't mine, ignore it */ @@ -4113,7 +4113,7 @@ set< set > CWallet::GetAddressGroupings() // group change with input addresses if (any_mine) { - BOOST_FOREACH(CTxOut txout, pcoin->vout) + for (CTxOut txout : pcoin->vout) if (IsChange(txout)) { CTxDestination txoutAddr; @@ -4144,18 +4144,18 @@ set< set > CWallet::GetAddressGroupings() set< set* > uniqueGroupings; // a set of pointers to groups of addresses map< CTxDestination, set* > setmap; // map addresses to the unique group containing it - BOOST_FOREACH(set grouping, groupings) + for (set grouping : groupings) { // make a set of all the groups hit by this new group set< set* > hits; map< CTxDestination, set* >::iterator it; - BOOST_FOREACH(CTxDestination address, grouping) + for (CTxDestination address : grouping) if ((it = setmap.find(address)) != setmap.end()) hits.insert((*it).second); // merge all hit groups into a new single group and delete old groups set* merged = new set(grouping); - BOOST_FOREACH(set* hit, hits) + for (set* hit : hits) { merged->insert(hit->begin(), hit->end()); uniqueGroupings.erase(hit); @@ -4164,12 +4164,12 @@ set< set > CWallet::GetAddressGroupings() uniqueGroupings.insert(merged); // update setmap - BOOST_FOREACH(CTxDestination element, *merged) + for (CTxDestination element : *merged) setmap[element] = merged; } set< set > ret; - BOOST_FOREACH(set* uniqueGrouping, uniqueGroupings) + for (set* uniqueGrouping : uniqueGroupings) { ret.insert(*uniqueGrouping); delete uniqueGrouping; @@ -4182,7 +4182,7 @@ std::set CWallet::GetAccountAddresses(const std::string& strAcco { LOCK(cs_wallet); set result; - BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, mapAddressBook) + for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : mapAddressBook) { const CTxDestination& address = item.first; const string& strName = item.second.name; @@ -4232,7 +4232,7 @@ void CWallet::GetAllReserveKeys(set& setAddress) const CWalletDB walletdb(strWalletFile); LOCK2(cs_main, cs_wallet); - BOOST_FOREACH(const int64_t& id, setKeyPool) + for (const int64_t& id : setKeyPool) { CKeyPool keypool; if (!walletdb.ReadPool(id, keypool)) @@ -4388,7 +4388,7 @@ class CAffectedKeysVisitor : public boost::static_visitor { std::vector vDest; int nRequired; if (ExtractDestinations(script, type, vDest, nRequired)) { - BOOST_FOREACH(const CTxDestination &dest, vDest) + for (const CTxDestination &dest : vDest) boost::apply_visitor(*this, dest); } } @@ -4421,7 +4421,7 @@ void CWallet::GetKeyBirthTimes(std::map &mapKeyBirth) const { std::map mapKeyFirstBlock; std::set setKeys; GetKeys(setKeys); - BOOST_FOREACH(const CKeyID &keyid, setKeys) { + for (const CKeyID &keyid : setKeys) { if (mapKeyBirth.count(keyid) == 0) mapKeyFirstBlock[keyid] = pindexMax; } @@ -4440,10 +4440,10 @@ void CWallet::GetKeyBirthTimes(std::map &mapKeyBirth) const { if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) { // ... which are already in a block int nHeight = blit->second->nHeight; - BOOST_FOREACH(const CTxOut &txout, wtx.vout) { + for (const CTxOut &txout : wtx.vout) { // iterate over all their outputs CAffectedKeysVisitor(*this, vAffected).Process(txout.scriptPubKey); - BOOST_FOREACH(const CKeyID &keyid, vAffected) { + for (const CKeyID &keyid : vAffected) { // ... and all their affected keys std::map::iterator rit = mapKeyFirstBlock.find(keyid); if (rit != mapKeyFirstBlock.end() && nHeight < rit->second->nHeight) @@ -4661,7 +4661,7 @@ bool CWallet::GetDestData(const CTxDestination &dest, const std::string &key, st // if (GetBoolArg("-zapwallettxes", false) && GetArg("-zapwallettxes", "1") != "2") // { // CWalletDB walletdb(walletFile); -// BOOST_FOREACH(const CWalletTx& wtxOld, vWtx) +// for (const CWalletTx& wtxOld : vWtx) // { // uint256 hash = wtxOld.GetHash(); // std::map::iterator mi = walletInstance->mapWallet.find(hash); diff --git a/src/wallet/wallet_ismine.cpp b/src/wallet/wallet_ismine.cpp index 7631f1d91..bbb93032e 100644 --- a/src/wallet/wallet_ismine.cpp +++ b/src/wallet/wallet_ismine.cpp @@ -20,7 +20,7 @@ typedef vector valtype; unsigned int HaveKeys(const vector& pubkeys, const CKeyStore& keystore) { unsigned int nResult = 0; - BOOST_FOREACH(const valtype& pubkey, pubkeys) + for (const valtype& pubkey : pubkeys) { CKeyID keyID = CPubKey(pubkey).GetID(); if (keystore.HaveKey(keyID)) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 076fbb26c..491d925c4 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -306,7 +306,7 @@ CAmount CWalletDB::GetAccountCreditDebit(const string& strAccount) ListAccountCreditDebit(strAccount, entries); CAmount nCreditDebit = 0; - BOOST_FOREACH (const CAccountingEntry& entry, entries) + for (const CAccountingEntry& entry : entries) nCreditDebit += entry.nCreditDebit; return nCreditDebit; @@ -373,7 +373,7 @@ DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet) } list acentries; ListAccountCreditDebit("", acentries); - BOOST_FOREACH(CAccountingEntry& entry, acentries) + for (CAccountingEntry& entry : acentries) { txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry))); } @@ -404,7 +404,7 @@ DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet) else { int64_t nOrderPosOff = 0; - BOOST_FOREACH(const int64_t& nOffsetStart, nOrderPosOffsets) + for (const int64_t& nOffsetStart : nOrderPosOffsets) { if (nOrderPos >= nOffsetStart) ++nOrderPosOff; @@ -982,7 +982,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) if ((wss.nKeys + wss.nCKeys) != wss.nKeyMeta) pwallet->nTimeFirstKey = 1; // 0 would be considered 'no value' - BOOST_FOREACH(uint256 hash, wss.vWalletUpgrade) + for (uint256 hash : wss.vWalletUpgrade) WriteTx(hash, pwallet->mapWallet[hash]); // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc: @@ -1082,7 +1082,7 @@ DBErrors CWalletDB::ZapWalletTx(CWallet* pwallet, vector& vWtx) return err; // erase each wallet TX - BOOST_FOREACH (uint256& hash, vTxHash) { + for (uint256& hash : vTxHash) { if (!EraseTx(hash)) return DB_CORRUPT; } @@ -1238,7 +1238,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, const std::string& filename, bool fOnlyKe CWalletScanState wss; DbTxn* ptxn = dbenv.TxnBegin(); - BOOST_FOREACH(CDBEnv::KeyValPair& row, salvagedData) + for (CDBEnv::KeyValPair& row : salvagedData) { if (fOnlyKeys) { diff --git a/src/zcash/IncrementalMerkleTree.cpp b/src/zcash/IncrementalMerkleTree.cpp index f8d5fad61..e23cc93c6 100644 --- a/src/zcash/IncrementalMerkleTree.cpp +++ b/src/zcash/IncrementalMerkleTree.cpp @@ -178,7 +178,7 @@ bool IncrementalMerkleTree::is_complete(size_t depth) const { return false; } - BOOST_FOREACH(const boost::optional& parent, parents) { + for (const boost::optional& parent : parents) { if (!parent) { return false; } @@ -209,7 +209,7 @@ size_t IncrementalMerkleTree::next_depth(size_t skip) const { size_t d = 1; - BOOST_FOREACH(const boost::optional& parent, parents) { + for (const boost::optional& parent : parents) { if (!parent) { if (skip) { skip--; @@ -237,7 +237,7 @@ Hash IncrementalMerkleTree::root(size_t depth, size_t d = 1; - BOOST_FOREACH(const boost::optional& parent, parents) { + for (const boost::optional& parent : parents) { if (parent) { root = Hash::combine(*parent, root, d); } else { @@ -280,7 +280,7 @@ MerklePath IncrementalMerkleTree::path(std::deque filler_hash size_t d = 1; - BOOST_FOREACH(const boost::optional& parent, parents) { + for (const boost::optional& parent : parents) { if (parent) { index.push_back(true); path.push_back(*parent); @@ -299,7 +299,7 @@ MerklePath IncrementalMerkleTree::path(std::deque filler_hash } std::vector> merkle_path; - BOOST_FOREACH(Hash b, path) + for (Hash b : path) { std::vector hashv(b.begin(), b.end()); diff --git a/src/zcash/circuit/utils.tcc b/src/zcash/circuit/utils.tcc index fa7ae324a..83fed3646 100644 --- a/src/zcash/circuit/utils.tcc +++ b/src/zcash/circuit/utils.tcc @@ -4,7 +4,7 @@ template pb_variable_array from_bits(std::vector bits, pb_variable& ZERO) { pb_variable_array acc; - BOOST_FOREACH(bool bit, bits) { + for(bool bit : bits) { acc.emplace_back(bit ? ONE : ZERO); } From aeb2e59d898455f86876812baf5e582a7997531b Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Fri, 12 Jul 2024 23:22:10 +0000 Subject: [PATCH 008/162] scripted-diff: Remove PAIRTYPE -BEGIN VERIFY SCRIPT- sed -i 's/PAIRTYPE(\([^,]*\), \([^\)]*\))/std::pair<\1, \2>/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; sed -i ':a;N;$!ba;s/#define std::pair std::pair\n//' ./src/utilstrencodings.h ; -END VERIFY SCRIPT- --- src/alert.cpp | 2 +- src/init.cpp | 2 +- src/main.cpp | 10 +- src/rpc/blockchain.cpp | 4 +- src/rpc/net.cpp | 2 +- src/rpc/server.cpp | 4 +- src/script/standard.cpp | 2 +- src/sync.cpp | 10 +- src/univalue/configure~ | 19224 +++++++++++++++++++++++++++++++++++++ src/util.cpp | 2 +- src/utilstrencodings.h | 3 - src/wallet/rpcwallet.cpp | 6 +- src/wallet/wallet.cpp | 24 +- 13 files changed, 19258 insertions(+), 37 deletions(-) create mode 100755 src/univalue/configure~ diff --git a/src/alert.cpp b/src/alert.cpp index 8fbc0045c..bec18e559 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -222,7 +222,7 @@ bool CAlert::ProcessAlert(const std::vector& alertKey, bool fThre } // Check if this alert has been cancelled - for (PAIRTYPE(const uint256, CAlert)& item : mapAlerts) + for (std::pair& item : mapAlerts) { const CAlert& alert = item.second; if (alert.Cancels(*this)) diff --git a/src/init.cpp b/src/init.cpp index b183ea9eb..9092a8fa4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -596,7 +596,7 @@ void CleanupBlockRevFiles() // keeping a separate counter. Once we hit a gap (or if 0 doesn't exist) // start removing block files. int nContigCounter = 0; - for (const PAIRTYPE(string, path)& item : mapBlockFiles) { + for (const std::pair& item : mapBlockFiles) { if (atoi(item.first) == nContigCounter) { nContigCounter++; continue; diff --git a/src/main.cpp b/src/main.cpp index a607603ea..c60143492 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4399,13 +4399,13 @@ bool static LoadBlockIndexDB() // Calculate nChainWork vector > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); - for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) + for (const std::pair& item : mapBlockIndex) { CBlockIndex* pindex = item.second; vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex)); } sort(vSortedByHeight.begin(), vSortedByHeight.end()); - for (const PAIRTYPE(int, CBlockIndex*)& item : vSortedByHeight) + for (const std::pair& item : vSortedByHeight) { CBlockIndex* pindex = item.second; pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex); @@ -4491,7 +4491,7 @@ bool static LoadBlockIndexDB() // Check presence of blk files LogPrintf("Checking all blk files are present...\n"); set setBlkDataFiles; - for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) + for (const std::pair& item : mapBlockIndex) { CBlockIndex* pindex = item.second; if (pindex->nStatus & BLOCK_HAVE_DATA) { @@ -4529,7 +4529,7 @@ bool static LoadBlockIndexDB() fTimestampIndex = fInsightExplorer; // Fill in-memory data - for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) + for (const std::pair& item : mapBlockIndex) { CBlockIndex* pindex = item.second; // - This relationship will always be true even if pprev has multiple @@ -5501,7 +5501,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // Relay alerts { LOCK(cs_mapAlerts); - for (PAIRTYPE(const uint256, CAlert)& item : mapAlerts) + for (std::pair& item : mapAlerts) item.second.RelayTo(pfrom); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 9b3d4ce24..c06940e02 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1161,9 +1161,9 @@ UniValue getchaintips(const UniValue& params, bool fHelp) known blocks, and successively remove blocks that appear as pprev of another block. */ std::set setTips; - for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex) + for (const std::pair& item : mapBlockIndex) setTips.insert(item.second); - for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex) + for (const std::pair& item : mapBlockIndex) { const CBlockIndex* pprev = item.second->pprev; if (pprev) diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index c5f4ad987..079b8ed4b 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -479,7 +479,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp) UniValue localAddresses(UniValue::VARR); { LOCK(cs_mapLocalHost); - for (const PAIRTYPE(CNetAddr, LocalServiceInfo) &item : mapLocalHost) + for (const std::pair &item : mapLocalHost) { UniValue rec(UniValue::VOBJ); rec.push_back(Pair("address", item.first.ToString())); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 2b097a4ce..91b181bbe 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -94,7 +94,7 @@ void RPCTypeCheckObj(const UniValue& o, const map& typesExpected, bool fAllowNull) { - for (const PAIRTYPE(string, UniValue::VType)& t : typesExpected) + for (const std::pair& t : typesExpected) { const UniValue& v = find_value(o, t.first); if (!fAllowNull && v.isNull()) @@ -175,7 +175,7 @@ std::string CRPCTable::help(const std::string& strCommand) const vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second)); sort(vCommands.begin(), vCommands.end()); - for (const PAIRTYPE(string, const CRPCCommand*)& command : vCommands) + for (const std::pair& command : vCommands) { const CRPCCommand *pcmd = command.second; string strMethod = pcmd->name; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index b9f31252b..fe9c49e6f 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -70,7 +70,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector& tplate : mTemplates) { const CScript& script2 = tplate.second; vSolutionsRet.clear(); diff --git a/src/sync.cpp b/src/sync.cpp index 100798308..dd231ef61 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -76,7 +76,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, LogPrintf("POTENTIAL DEADLOCK DETECTED\n"); LogPrintf("Previous lock order was:\n"); - for (const PAIRTYPE(void*, CLockLocation) & i : s2) { + for (const std::pair & i : s2) { if (i.first == mismatch.first) { LogPrintf(" (1)"); if (!firstLocked && secondLocked && i.second.fTry) @@ -94,7 +94,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, firstLocked = false; secondLocked = false; LogPrintf("Current lock order is:\n"); - for (const PAIRTYPE(void*, CLockLocation) & i : s1) { + for (const std::pair & i : s1) { if (i.first == mismatch.first) { LogPrintf(" (1)"); if (!firstLocked && secondLocked && i.second.fTry) @@ -122,7 +122,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry) (*lockstack).push_back(std::make_pair(c, locklocation)); if (!fTry) { - for (const PAIRTYPE(void*, CLockLocation) & i : (*lockstack)) { + for (const std::pair & i : (*lockstack)) { if (i.first == c) break; @@ -159,14 +159,14 @@ void LeaveCritical() std::string LocksHeld() { std::string result; - for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack) + for (const std::pair & i : *lockstack) result += i.second.ToString() + std::string("\n"); return result; } void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs) { - for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack) + for (const std::pair & i : *lockstack) if (i.first == cs) return; fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str()); diff --git a/src/univalue/configure~ b/src/univalue/configure~ new file mode 100755 index 000000000..6d1ba687d --- /dev/null +++ b/src/univalue/configure~ @@ -0,0 +1,19224 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.71 for univalue 1.0.3. +# +# Report bugs to . +# +# +# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, +# Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +as_nop=: +if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 +then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else $as_nop + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + + +# Reset variables that may have inherited troublesome values from +# the environment. + +# IFS needs to be set, to space, tab, and newline, in precisely that order. +# (If _AS_PATH_WALK were called with IFS unset, it would have the +# side effect of setting IFS to empty, thus disabling word splitting.) +# Quoting is to prevent editors from complaining about space-tab. +as_nl=' +' +export as_nl +IFS=" "" $as_nl" + +PS1='$ ' +PS2='> ' +PS4='+ ' + +# Ensure predictable behavior from utilities with locale-dependent output. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# We cannot yet rely on "unset" to work, but we need these variables +# to be unset--not just set to an empty or harmless value--now, to +# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct +# also avoids known problems related to "unset" and subshell syntax +# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). +for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH +do eval test \${$as_var+y} \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done + +# Ensure that fds 0, 1, and 2 are open. +if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi +if (exec 3>&2) ; then :; else exec 2>/dev/null; fi + +# The user is always right. +if ${PATH_SEPARATOR+false} :; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + test -r "$as_dir$0" && as_myself=$as_dir$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="as_nop=: +if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 +then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else \$as_nop + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ) +then : + +else \$as_nop + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +blah=\$(echo \$(echo blah)) +test x\"\$blah\" = xblah || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 + + test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( + ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + PATH=/empty FPATH=/empty; export PATH FPATH + test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ + || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null +then : + as_have_required=yes +else $as_nop + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null +then : + +else $as_nop + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null +then : + CONFIG_SHELL=$as_shell as_have_required=yes + if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null +then : + break 2 +fi +fi + done;; + esac + as_found=false +done +IFS=$as_save_IFS +if $as_found +then : + +else $as_nop + if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null +then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi +fi + + + if test "x$CONFIG_SHELL" != x +then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno +then : + printf "%s\n" "$0: This script requires a shell more modern than all" + printf "%s\n" "$0: the shells that I found on your system." + if test ${ZSH_VERSION+y} ; then + printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" + printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." + else + printf "%s\n" "$0: Please tell bug-autoconf@gnu.org and +$0: http://github.com/jgarzik/univalue/ about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit +# as_fn_nop +# --------- +# Do nothing but, unlike ":", preserve the value of $?. +as_fn_nop () +{ + return $? +} +as_nop=as_fn_nop + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null +then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else $as_nop + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null +then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else $as_nop + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + +# as_fn_nop +# --------- +# Do nothing but, unlike ":", preserve the value of $?. +as_fn_nop () +{ + return $? +} +as_nop=as_fn_nop + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + printf "%s\n" "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +# Determine whether it's possible to make 'echo' print without a newline. +# These variables are no longer used directly by Autoconf, but are AC_SUBSTed +# for compatibility with existing Makefiles. +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +# For backward compatibility with old third-party macros, we provide +# the shell variables $as_echo and $as_echo_n. New code should use +# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. +as_echo='printf %s\n' +as_echo_n='printf %s' + + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + +SHELL=${CONFIG_SHELL-/bin/sh} + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='univalue' +PACKAGE_TARNAME='univalue' +PACKAGE_VERSION='1.0.3' +PACKAGE_STRING='univalue 1.0.3' +PACKAGE_BUGREPORT='http://github.com/jgarzik/univalue/' +PACKAGE_URL='' + +ac_unique_file="lib/univalue.cpp" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_STDIO_H +# include +#endif +#ifdef HAVE_STDLIB_H +# include +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_header_c_list= +ac_subst_vars='am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +LIBOBJS +BUILD_EXEEXT +LIBTOOL_APP_LDFLAGS +CXXCPP +am__fastdepCXX_FALSE +am__fastdepCXX_TRUE +CXXDEPMODE +ac_ct_CXX +CXXFLAGS +CXX +LT_SYS_LIBRARY_PATH +OTOOL64 +OTOOL +LIPO +NMEDIT +DSYMUTIL +MANIFEST_TOOL +RANLIB +ac_ct_AR +AR +DLLTOOL +OBJDUMP +LN_S +NM +ac_ct_DUMPBIN +DUMPBIN +LD +FGREP +EGREP +GREP +SED +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +am__nodep +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +LIBTOOL +LIBUNIVALUE_AGE +LIBUNIVALUE_REVISION +LIBUNIVALUE_CURRENT +CSCOPE +ETAGS +CTAGS +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +AM_BACKSLASH +AM_DEFAULT_VERBOSITY +AM_DEFAULT_V +AM_V +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +runstatedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL +am__quote' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_silent_rules +enable_shared +enable_static +with_pic +enable_fast_install +with_aix_soname +enable_dependency_tracking +with_gnu_ld +with_sysroot +enable_libtool_lock +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +LT_SYS_LIBRARY_PATH +CXX +CXXFLAGS +CCC +CXXCPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: \`$ac_useropt'" + ac_useropt_orig=$ac_useropt + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: \`$ac_useropt'" + ac_useropt_orig=$ac_useropt + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: \`$ac_useropt'" + ac_useropt_orig=$ac_useropt + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: \`$ac_useropt'" + ac_useropt_orig=$ac_useropt + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir runstatedir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures univalue 1.0.3 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/univalue] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of univalue 1.0.3:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-silent-rules less verbose build output (undo: "make V=1") + --disable-silent-rules verbose build output (undo: "make V=0") + --enable-shared[=PKGS] build shared libraries [default=yes] + --enable-static[=PKGS] build static libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --enable-dependency-tracking + do not reject slow dependency extractors + --disable-dependency-tracking + speeds up one-time build + --disable-libtool-lock avoid locking (might break parallel builds) + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use + both] + --with-aix-soname=aix|svr4|both + shared library versioning (aka "SONAME") variant to + provide on AIX, [default=aix]. + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-sysroot[=DIR] Search for dependent libraries within DIR (or the + compiler's sysroot if not specified). + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + LT_SYS_LIBRARY_PATH + User-defined run-time library search path. + CXX C++ compiler command + CXXFLAGS C++ compiler flags + CXXCPP C++ preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for configure.gnu first; this name is used for a wrapper for + # Metaconfig's "Configure" on case-insensitive file systems. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +univalue configure 1.0.3 +generated by GNU Autoconf 2.71 + +Copyright (C) 2021 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest.beam + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + } +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +printf %s "checking for $2... " >&6; } +if eval test \${$3+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + eval "$3=yes" +else $as_nop + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +eval ac_res=\$$3 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +printf %s "checking for $2... " >&6; } +if eval test \${$3+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. */ + +#include +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main (void) +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + eval "$3=yes" +else $as_nop + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func + +# ac_fn_cxx_try_compile LINENO +# ---------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest.beam + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_compile + +# ac_fn_cxx_try_cpp LINENO +# ------------------------ +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || + test ! -s conftest.err + } +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_cpp + +# ac_fn_cxx_try_link LINENO +# ------------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + } +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_link +ac_configure_args_raw= +for ac_arg +do + case $ac_arg in + *\'*) + ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append ac_configure_args_raw " '$ac_arg'" +done + +case $ac_configure_args_raw in + *$as_nl*) + ac_safe_unquote= ;; + *) + ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. + ac_unsafe_a="$ac_unsafe_z#~" + ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" + ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; +esac + +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by univalue $as_me 1.0.3, which was +generated by GNU Autoconf 2.71. Invocation command line was + + $ $0$ac_configure_args_raw + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + printf "%s\n" "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Sanitize IFS. + IFS=" "" $as_nl" + # Save into config.log some information that might help in debugging. + { + echo + + printf "%s\n" "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + printf "%s\n" "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + printf "%s\n" "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + printf "%s\n" "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + printf "%s\n" "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + printf "%s\n" "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + printf "%s\n" "$as_me: caught signal $ac_signal" + printf "%s\n" "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +printf "%s\n" "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h + +printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h + +printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h + +printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h + +printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h + +printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +if test -n "$CONFIG_SITE"; then + ac_site_files="$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + ac_site_files="$prefix/share/config.site $prefix/etc/config.site" +else + ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" +fi + +for ac_site_file in $ac_site_files +do + case $ac_site_file in #( + */*) : + ;; #( + *) : + ac_site_file=./$ac_site_file ;; +esac + if test -f "$ac_site_file" && test -r "$ac_site_file"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +printf "%s\n" "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +printf "%s\n" "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Test code for whether the C compiler supports C89 (global declarations) +ac_c_conftest_c89_globals=' +/* Does the compiler advertise C89 conformance? + Do not test the value of __STDC__, because some compilers set it to 0 + while being otherwise adequately conformant. */ +#if !defined __STDC__ +# error "Compiler does not advertise C89 conformance" +#endif + +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ +struct buf { int x; }; +struct buf * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not \xHH hex character constants. + These do not provoke an error unfortunately, instead are silently treated + as an "x". The following induces an error, until -std is added to get + proper ANSI mode. Curiously \x00 != x always comes out true, for an + array size at least. It is necessary to write \x00 == 0 to get something + that is true only with -std. */ +int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) '\''x'\'' +int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), + int, int);' + +# Test code for whether the C compiler supports C89 (body of main). +ac_c_conftest_c89_main=' +ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]); +' + +# Test code for whether the C compiler supports C99 (global declarations) +ac_c_conftest_c99_globals=' +// Does the compiler advertise C99 conformance? +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L +# error "Compiler does not advertise C99 conformance" +#endif + +#include +extern int puts (const char *); +extern int printf (const char *, ...); +extern int dprintf (int, const char *, ...); +extern void *malloc (size_t); + +// Check varargs macros. These examples are taken from C99 6.10.3.5. +// dprintf is used instead of fprintf to avoid needing to declare +// FILE and stderr. +#define debug(...) dprintf (2, __VA_ARGS__) +#define showlist(...) puts (#__VA_ARGS__) +#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) +static void +test_varargs_macros (void) +{ + int x = 1234; + int y = 5678; + debug ("Flag"); + debug ("X = %d\n", x); + showlist (The first, second, and third items.); + report (x>y, "x is %d but y is %d", x, y); +} + +// Check long long types. +#define BIG64 18446744073709551615ull +#define BIG32 4294967295ul +#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) +#if !BIG_OK + #error "your preprocessor is broken" +#endif +#if BIG_OK +#else + #error "your preprocessor is broken" +#endif +static long long int bignum = -9223372036854775807LL; +static unsigned long long int ubignum = BIG64; + +struct incomplete_array +{ + int datasize; + double data[]; +}; + +struct named_init { + int number; + const wchar_t *name; + double average; +}; + +typedef const char *ccp; + +static inline int +test_restrict (ccp restrict text) +{ + // See if C++-style comments work. + // Iterate through items via the restricted pointer. + // Also check for declarations in for loops. + for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) + continue; + return 0; +} + +// Check varargs and va_copy. +static bool +test_varargs (const char *format, ...) +{ + va_list args; + va_start (args, format); + va_list args_copy; + va_copy (args_copy, args); + + const char *str = ""; + int number = 0; + float fnumber = 0; + + while (*format) + { + switch (*format++) + { + case '\''s'\'': // string + str = va_arg (args_copy, const char *); + break; + case '\''d'\'': // int + number = va_arg (args_copy, int); + break; + case '\''f'\'': // float + fnumber = va_arg (args_copy, double); + break; + default: + break; + } + } + va_end (args_copy); + va_end (args); + + return *str && number && fnumber; +} +' + +# Test code for whether the C compiler supports C99 (body of main). +ac_c_conftest_c99_main=' + // Check bool. + _Bool success = false; + success |= (argc != 0); + + // Check restrict. + if (test_restrict ("String literal") == 0) + success = true; + char *restrict newvar = "Another string"; + + // Check varargs. + success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234); + test_varargs_macros (); + + // Check flexible array members. + struct incomplete_array *ia = + malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); + ia->datasize = 10; + for (int i = 0; i < ia->datasize; ++i) + ia->data[i] = i * 1.234; + + // Check named initializers. + struct named_init ni = { + .number = 34, + .name = L"Test wide string", + .average = 543.34343, + }; + + ni.number = 58; + + int dynamic_array[ni.number]; + dynamic_array[0] = argv[0][0]; + dynamic_array[ni.number - 1] = 543; + + // work around unused variable warnings + ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\'' + || dynamic_array[ni.number - 1] != 543); +' + +# Test code for whether the C compiler supports C11 (global declarations) +ac_c_conftest_c11_globals=' +// Does the compiler advertise C11 conformance? +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L +# error "Compiler does not advertise C11 conformance" +#endif + +// Check _Alignas. +char _Alignas (double) aligned_as_double; +char _Alignas (0) no_special_alignment; +extern char aligned_as_int; +char _Alignas (0) _Alignas (int) aligned_as_int; + +// Check _Alignof. +enum +{ + int_alignment = _Alignof (int), + int_array_alignment = _Alignof (int[100]), + char_alignment = _Alignof (char) +}; +_Static_assert (0 < -_Alignof (int), "_Alignof is signed"); + +// Check _Noreturn. +int _Noreturn does_not_return (void) { for (;;) continue; } + +// Check _Static_assert. +struct test_static_assert +{ + int x; + _Static_assert (sizeof (int) <= sizeof (long int), + "_Static_assert does not work in struct"); + long int y; +}; + +// Check UTF-8 literals. +#define u8 syntax error! +char const utf8_literal[] = u8"happens to be ASCII" "another string"; + +// Check duplicate typedefs. +typedef long *long_ptr; +typedef long int *long_ptr; +typedef long_ptr long_ptr; + +// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. +struct anonymous +{ + union { + struct { int i; int j; }; + struct { int k; long int l; } w; + }; + int m; +} v1; +' + +# Test code for whether the C compiler supports C11 (body of main). +ac_c_conftest_c11_main=' + _Static_assert ((offsetof (struct anonymous, i) + == offsetof (struct anonymous, w.k)), + "Anonymous union alignment botch"); + v1.i = 2; + v1.w.k = 5; + ok |= v1.i != 5; +' + +# Test code for whether the C compiler supports C11 (complete). +ac_c_conftest_c11_program="${ac_c_conftest_c89_globals} +${ac_c_conftest_c99_globals} +${ac_c_conftest_c11_globals} + +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_c_conftest_c89_main} + ${ac_c_conftest_c99_main} + ${ac_c_conftest_c11_main} + return ok; +} +" + +# Test code for whether the C compiler supports C99 (complete). +ac_c_conftest_c99_program="${ac_c_conftest_c89_globals} +${ac_c_conftest_c99_globals} + +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_c_conftest_c89_main} + ${ac_c_conftest_c99_main} + return ok; +} +" + +# Test code for whether the C compiler supports C89 (complete). +ac_c_conftest_c89_program="${ac_c_conftest_c89_globals} + +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_c_conftest_c89_main} + return ok; +} +" + +as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H" +as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H" +as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H" +as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H" +as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H" +as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H" +as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" +as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" +as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" +# Test code for whether the C++ compiler supports C++98 (global declarations) +ac_cxx_conftest_cxx98_globals=' +// Does the compiler advertise C++98 conformance? +#if !defined __cplusplus || __cplusplus < 199711L +# error "Compiler does not advertise C++98 conformance" +#endif + +// These inclusions are to reject old compilers that +// lack the unsuffixed header files. +#include +#include + +// and are *not* freestanding headers in C++98. +extern void assert (int); +namespace std { + extern int strcmp (const char *, const char *); +} + +// Namespaces, exceptions, and templates were all added after "C++ 2.0". +using std::exception; +using std::strcmp; + +namespace { + +void test_exception_syntax() +{ + try { + throw "test"; + } catch (const char *s) { + // Extra parentheses suppress a warning when building autoconf itself, + // due to lint rules shared with more typical C programs. + assert (!(strcmp) (s, "test")); + } +} + +template struct test_template +{ + T const val; + explicit test_template(T t) : val(t) {} + template T add(U u) { return static_cast(u) + val; } +}; + +} // anonymous namespace +' + +# Test code for whether the C++ compiler supports C++98 (body of main) +ac_cxx_conftest_cxx98_main=' + assert (argc); + assert (! argv[0]); +{ + test_exception_syntax (); + test_template tt (2.0); + assert (tt.add (4) == 6.0); + assert (true && !false); +} +' + +# Test code for whether the C++ compiler supports C++11 (global declarations) +ac_cxx_conftest_cxx11_globals=' +// Does the compiler advertise C++ 2011 conformance? +#if !defined __cplusplus || __cplusplus < 201103L +# error "Compiler does not advertise C++11 conformance" +#endif + +namespace cxx11test +{ + constexpr int get_val() { return 20; } + + struct testinit + { + int i; + double d; + }; + + class delegate + { + public: + delegate(int n) : n(n) {} + delegate(): delegate(2354) {} + + virtual int getval() { return this->n; }; + protected: + int n; + }; + + class overridden : public delegate + { + public: + overridden(int n): delegate(n) {} + virtual int getval() override final { return this->n * 2; } + }; + + class nocopy + { + public: + nocopy(int i): i(i) {} + nocopy() = default; + nocopy(const nocopy&) = delete; + nocopy & operator=(const nocopy&) = delete; + private: + int i; + }; + + // for testing lambda expressions + template Ret eval(Fn f, Ret v) + { + return f(v); + } + + // for testing variadic templates and trailing return types + template auto sum(V first) -> V + { + return first; + } + template auto sum(V first, Args... rest) -> V + { + return first + sum(rest...); + } +} +' + +# Test code for whether the C++ compiler supports C++11 (body of main) +ac_cxx_conftest_cxx11_main=' +{ + // Test auto and decltype + auto a1 = 6538; + auto a2 = 48573953.4; + auto a3 = "String literal"; + + int total = 0; + for (auto i = a3; *i; ++i) { total += *i; } + + decltype(a2) a4 = 34895.034; +} +{ + // Test constexpr + short sa[cxx11test::get_val()] = { 0 }; +} +{ + // Test initializer lists + cxx11test::testinit il = { 4323, 435234.23544 }; +} +{ + // Test range-based for + int array[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, + 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; + for (auto &x : array) { x += 23; } +} +{ + // Test lambda expressions + using cxx11test::eval; + assert (eval ([](int x) { return x*2; }, 21) == 42); + double d = 2.0; + assert (eval ([&](double x) { return d += x; }, 3.0) == 5.0); + assert (d == 5.0); + assert (eval ([=](double x) mutable { return d += x; }, 4.0) == 9.0); + assert (d == 5.0); +} +{ + // Test use of variadic templates + using cxx11test::sum; + auto a = sum(1); + auto b = sum(1, 2); + auto c = sum(1.0, 2.0, 3.0); +} +{ + // Test constructor delegation + cxx11test::delegate d1; + cxx11test::delegate d2(); + cxx11test::delegate d3(45); +} +{ + // Test override and final + cxx11test::overridden o1(55464); +} +{ + // Test nullptr + char *c = nullptr; +} +{ + // Test template brackets + test_template<::test_template> v(test_template(12)); +} +{ + // Unicode literals + char const *utf8 = u8"UTF-8 string \u2500"; + char16_t const *utf16 = u"UTF-8 string \u2500"; + char32_t const *utf32 = U"UTF-32 string \u2500"; +} +' + +# Test code for whether the C compiler supports C++11 (complete). +ac_cxx_conftest_cxx11_program="${ac_cxx_conftest_cxx98_globals} +${ac_cxx_conftest_cxx11_globals} + +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_cxx_conftest_cxx98_main} + ${ac_cxx_conftest_cxx11_main} + return ok; +} +" + +# Test code for whether the C compiler supports C++98 (complete). +ac_cxx_conftest_cxx98_program="${ac_cxx_conftest_cxx98_globals} +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_cxx_conftest_cxx98_main} + return ok; +} +" + + +# Auxiliary files required by this configure script. +ac_aux_files="compile config.guess config.sub ltmain.sh missing install-sh" + +# Locations in which to look for auxiliary files. +ac_aux_dir_candidates="${srcdir}/build-aux" + +# Search for a directory containing all of the required auxiliary files, +# $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates. +# If we don't find one directory that contains all the files we need, +# we report the set of missing files from the *first* directory in +# $ac_aux_dir_candidates and give up. +ac_missing_aux_files="" +ac_first_candidate=: +printf "%s\n" "$as_me:${as_lineno-$LINENO}: looking for aux files: $ac_aux_files" >&5 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in $ac_aux_dir_candidates +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + as_found=: + + printf "%s\n" "$as_me:${as_lineno-$LINENO}: trying $as_dir" >&5 + ac_aux_dir_found=yes + ac_install_sh= + for ac_aux in $ac_aux_files + do + # As a special case, if "install-sh" is required, that requirement + # can be satisfied by any of "install-sh", "install.sh", or "shtool", + # and $ac_install_sh is set appropriately for whichever one is found. + if test x"$ac_aux" = x"install-sh" + then + if test -f "${as_dir}install-sh"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install-sh found" >&5 + ac_install_sh="${as_dir}install-sh -c" + elif test -f "${as_dir}install.sh"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install.sh found" >&5 + ac_install_sh="${as_dir}install.sh -c" + elif test -f "${as_dir}shtool"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}shtool found" >&5 + ac_install_sh="${as_dir}shtool install -c" + else + ac_aux_dir_found=no + if $ac_first_candidate; then + ac_missing_aux_files="${ac_missing_aux_files} install-sh" + else + break + fi + fi + else + if test -f "${as_dir}${ac_aux}"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}${ac_aux} found" >&5 + else + ac_aux_dir_found=no + if $ac_first_candidate; then + ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}" + else + break + fi + fi + fi + done + if test "$ac_aux_dir_found" = yes; then + ac_aux_dir="$as_dir" + break + fi + ac_first_candidate=false + + as_found=false +done +IFS=$as_save_IFS +if $as_found +then : + +else $as_nop + as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 +fi + + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +if test -f "${ac_aux_dir}config.guess"; then + ac_config_guess="$SHELL ${ac_aux_dir}config.guess" +fi +if test -f "${ac_aux_dir}config.sub"; then + ac_config_sub="$SHELL ${ac_aux_dir}config.sub" +fi +if test -f "$ac_aux_dir/configure"; then + ac_configure="$SHELL ${ac_aux_dir}configure" +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' + and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +# Check whether --enable-silent-rules was given. +if test ${enable_silent_rules+y} +then : + enableval=$enable_silent_rules; +fi + +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=0;; +esac +am_make=${MAKE-make} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +printf %s "checking whether $am_make supports nested variables... " >&6; } +if test ${am_cv_make_support_nested_variables+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if printf "%s\n" 'TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +printf "%s\n" "$am_cv_make_support_nested_variables" >&6; } +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AM_BACKSLASH='\' + + + + + + +ac_config_headers="$ac_config_headers univalue-config.h" + +am__api_version='1.16' + + + + # Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +printf %s "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if test ${ac_cv_path_install+y} +then : + printf %s "(cached) " >&6 +else $as_nop + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + # Account for fact that we put trailing slashes in our PATH walk. +case $as_dir in #(( + ./ | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir/" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test ${ac_cv_path_install+y}; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +printf "%s\n" "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +printf %s "checking whether build environment is sane... " >&6; } +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; +esac +case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) + as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; +esac + +# Do 'set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken + alias in your environment" "$LINENO" 5 + fi + if test "$2" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done + test "$2" = conftest.file + ) +then + # Ok. + : +else + as_fn_error $? "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi + +rm -f conftest.file + +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`printf "%s\n" "$program_transform_name" | sed "$ac_script"` + + +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` + + + if test x"${MISSING+set}" != xset; then + MISSING="\${SHELL} '$am_aux_dir/missing'" +fi +# Use eval to expand $SHELL +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " +else + am_missing_run= + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 +printf "%s\n" "$as_me: WARNING: 'missing' script is too old or missing" >&2;} +fi + +if test x"${install_sh+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the 'STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +printf "%s\n" "$STRIP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +printf "%s\n" "$ac_ct_STRIP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a race-free mkdir -p" >&5 +printf %s "checking for a race-free mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if test ${ac_cv_path_mkdir+y} +then : + printf %s "(cached) " >&6 +else $as_nop + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext" || continue + case `"$as_dir$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir ('*'coreutils) '* | \ + 'BusyBox '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + test -d ./--version && rmdir ./--version + if test ${ac_cv_path_mkdir+y}; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + MKDIR_P="$ac_install_sh -d" + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +printf "%s\n" "$MKDIR_P" >&6; } + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_AWK+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +printf "%s\n" "$AWK" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +printf %s "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval test \${ac_cv_prog_make_${ac_make}_set+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + SET_MAKE= +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='univalue' + VERSION='1.0.3' + + +printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h + + +printf "%s\n" "#define VERSION \"$VERSION\"" >>confdefs.h + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +mkdir_p='$(MKDIR_P)' + +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. +# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AMTAR='$${TAR-tar}' + + +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar pax cpio none' + +am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' + + + + + +# Variables for tags utilities; see am/tags.am +if test -z "$CTAGS"; then + CTAGS=ctags +fi + +if test -z "$ETAGS"; then + ETAGS=etags +fi + +if test -z "$CSCOPE"; then + CSCOPE=cscope +fi + + + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 + fi +fi + + +LIBUNIVALUE_MAJOR_VERSION=1 +LIBUNIVALUE_MINOR_VERSION=1 +LIBUNIVALUE_MICRO_VERSION=3 +LIBUNIVALUE_INTERFACE_AGE=3 + +# ABI version +# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +LIBUNIVALUE_CURRENT=100 +LIBUNIVALUE_REVISION=3 +LIBUNIVALUE_AGE=100 + + + + + +case `pwd` in + *\ * | *\ *) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 +printf "%s\n" "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; +esac + + + +macro_version='2.4.6' +macro_revision='2.4.6' + + + + + + + + + + + + + + +ltmain=$ac_aux_dir/ltmain.sh + + + + # Make sure we can run config.sub. +$SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5 + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +printf %s "checking build system type... " >&6; } +if test ${ac_cv_build+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +printf "%s\n" "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +printf %s "checking host system type... " >&6; } +if test ${ac_cv_host+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || + as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +printf "%s\n" "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 +printf %s "checking how to print strings... " >&6; } +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "" +} + +case $ECHO in + printf*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: printf" >&5 +printf "%s\n" "printf" >&6; } ;; + print*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 +printf "%s\n" "print -r" >&6; } ;; + *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: cat" >&5 +printf "%s\n" "cat" >&6; } ;; +esac + + + + + + + + + + + + + + + + + + + + + + + +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 +printf %s "checking whether ${MAKE-make} supports the include directive... " >&6; } +cat > confinc.mk << 'END' +am__doit: + @echo this is the am__doit target >confinc.out +.PHONY: am__doit +END +am__include="#" +am__quote= +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 + (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + case $?:`cat confinc.out 2>/dev/null` in #( + '0:this is the am__doit target') : + case $s in #( + BSD) : + am__include='.include' am__quote='"' ;; #( + *) : + am__include='include' am__quote='' ;; +esac ;; #( + *) : + ;; +esac + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 +printf "%s\n" "${_am_result}" >&6; } + +# Check whether --enable-dependency-tracking was given. +if test ${enable_dependency_tracking+y} +then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +printf "%s\n" "$ac_ct_CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +printf "%s\n" "$ac_ct_CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. +set dummy ${ac_tool_prefix}clang; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}clang" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "clang", so it can be a program name with args. +set dummy clang; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="clang" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +printf "%s\n" "$ac_ct_CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +fi + + +test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion -version; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +printf %s "checking whether the C compiler works... " >&6; } +ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else $as_nop + ac_file='' +fi +if test -z "$ac_file" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +printf %s "checking for C compiler default output file name... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +printf "%s\n" "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +printf %s "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else $as_nop + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +printf "%s\n" "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +printf %s "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +printf "%s\n" "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +printf %s "checking for suffix of object files... " >&6; } +if test ${ac_cv_objext+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +printf "%s\n" "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 +printf %s "checking whether the compiler supports GNU C... " >&6; } +if test ${ac_cv_c_compiler_gnu+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_compiler_gnu=yes +else $as_nop + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+y} +ac_save_CFLAGS=$CFLAGS +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +printf %s "checking whether $CC accepts -g... " >&6; } +if test ${ac_cv_prog_cc_g+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_g=yes +else $as_nop + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + +else $as_nop + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +printf "%s\n" "$ac_cv_prog_cc_g" >&6; } +if test $ac_test_CFLAGS; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +ac_prog_cc_stdc=no +if test x$ac_prog_cc_stdc = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 +printf %s "checking for $CC option to enable C11 features... " >&6; } +if test ${ac_cv_prog_cc_c11+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cc_c11=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_c_conftest_c11_program +_ACEOF +for ac_arg in '' -std=gnu11 +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_c11=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cc_c11" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC +fi + +if test "x$ac_cv_prog_cc_c11" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cc_c11" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 +printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } + CC="$CC $ac_cv_prog_cc_c11" +fi + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 + ac_prog_cc_stdc=c11 +fi +fi +if test x$ac_prog_cc_stdc = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 +printf %s "checking for $CC option to enable C99 features... " >&6; } +if test ${ac_cv_prog_cc_c99+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cc_c99=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_c_conftest_c99_program +_ACEOF +for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_c99=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cc_c99" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC +fi + +if test "x$ac_cv_prog_cc_c99" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cc_c99" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 +printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } + CC="$CC $ac_cv_prog_cc_c99" +fi + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 + ac_prog_cc_stdc=c99 +fi +fi +if test x$ac_prog_cc_stdc = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 +printf %s "checking for $CC option to enable C89 features... " >&6; } +if test ${ac_cv_prog_cc_c89+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_c_conftest_c89_program +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC +fi + +if test "x$ac_cv_prog_cc_c89" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cc_c89" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } + CC="$CC $ac_cv_prog_cc_c89" +fi + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 + ac_prog_cc_stdc=c89 +fi +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 +printf %s "checking whether $CC understands -c and -o together... " >&6; } +if test ${am_cv_prog_cc_c_o+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 + ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +printf "%s\n" "$am_cv_prog_cc_c_o" >&6; } +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +depcc="$CC" am_compiler_list= + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +printf %s "checking dependency style of $depcc... " >&6; } +if test ${am_cv_CC_dependencies_compiler_type+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +printf "%s\n" "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +printf %s "checking for a sed that does not truncate output... " >&6; } +if test ${ac_cv_path_SED+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + { ac_script=; unset ac_script;} + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in sed gsed + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_SED" || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_SED_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi +else + ac_cv_path_SED=$SED +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +printf "%s\n" "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed + +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" + + + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +printf %s "checking for grep that handles long lines and -e... " >&6; } +if test ${ac_cv_path_GREP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in grep ggrep + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +printf "%s\n" "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +printf %s "checking for egrep... " >&6; } +if test ${ac_cv_path_EGREP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in egrep + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +printf "%s\n" "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 +printf %s "checking for fgrep... " >&6; } +if test ${ac_cv_path_FGREP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 + then ac_cv_path_FGREP="$GREP -F" + else + if test -z "$FGREP"; then + ac_path_FGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in fgrep + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_FGREP="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_FGREP" || continue +# Check for GNU ac_path_FGREP and select it if it is found. + # Check for GNU $ac_path_FGREP +case `"$ac_path_FGREP" --version 2>&1` in +*GNU*) + ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" 'FGREP' >> "conftest.nl" + "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_FGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_FGREP="$ac_path_FGREP" + ac_path_FGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_FGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_FGREP"; then + as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_FGREP=$FGREP +fi + + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 +printf "%s\n" "$ac_cv_path_FGREP" >&6; } + FGREP="$ac_cv_path_FGREP" + + +test -z "$GREP" && GREP=grep + + + + + + + + + + + + + + + + + + + +# Check whether --with-gnu-ld was given. +if test ${with_gnu_ld+y} +then : + withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes +else $as_nop + with_gnu_ld=no +fi + +ac_prog=ld +if test yes = "$GCC"; then + # Check if gcc -print-prog-name=ld gives a path. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +printf %s "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return, which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD=$ac_prog + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test yes = "$with_gnu_ld"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +printf %s "checking for GNU ld... " >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +printf %s "checking for non-GNU ld... " >&6; } +fi +if test ${lt_cv_path_LD+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -z "$LD"; then + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD=$ac_dir/$ac_prog + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +printf "%s\n" "$LD" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +printf %s "checking if the linker ($LD) is GNU ld... " >&6; } +if test ${lt_cv_prog_gnu_ld+y} +then : + printf %s "(cached) " >&6 +else $as_nop + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 +printf %s "checking for BSD- or MS-compatible name lister (nm)... " >&6; } +if test ${lt_cv_path_NM+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM=$NM +else + lt_nm_to_check=${ac_tool_prefix}nm + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + tmp_nm=$ac_dir/$lt_tmp_nm + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the 'sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + case $build_os in + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac + case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break 2 + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break 2 + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS=$lt_save_ifs + done + : ${lt_cv_path_NM=no} +fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 +printf "%s\n" "$lt_cv_path_NM" >&6; } +if test no != "$lt_cv_path_NM"; then + NM=$lt_cv_path_NM +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$DUMPBIN"; then : + # Let the user override the test. + else + if test -n "$ac_tool_prefix"; then + for ac_prog in dumpbin "link -dump" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_DUMPBIN+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$DUMPBIN"; then + ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DUMPBIN=$ac_cv_prog_DUMPBIN +if test -n "$DUMPBIN"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 +printf "%s\n" "$DUMPBIN" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$DUMPBIN" && break + done +fi +if test -z "$DUMPBIN"; then + ac_ct_DUMPBIN=$DUMPBIN + for ac_prog in dumpbin "link -dump" +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_DUMPBIN+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_DUMPBIN"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN +if test -n "$ac_ct_DUMPBIN"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 +printf "%s\n" "$ac_ct_DUMPBIN" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$ac_ct_DUMPBIN" && break +done + + if test "x$ac_ct_DUMPBIN" = x; then + DUMPBIN=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DUMPBIN=$ac_ct_DUMPBIN + fi +fi + + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols -headers" + ;; + *) + DUMPBIN=: + ;; + esac + fi + + if test : != "$DUMPBIN"; then + NM=$DUMPBIN + fi +fi +test -z "$NM" && NM=nm + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 +printf %s "checking the name lister ($NM) interface... " >&6; } +if test ${lt_cv_nm_interface+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&5 + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&5 + (eval echo "\"\$as_me:$LINENO: output\"" >&5) + cat conftest.out >&5 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest* +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 +printf "%s\n" "$lt_cv_nm_interface" >&6; } + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +printf %s "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +printf "%s\n" "no, using $LN_S" >&6; } +fi + +# find the maximum length of command line arguments +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 +printf %s "checking the maximum length of command line arguments... " >&6; } +if test ${lt_cv_sys_max_cmd_len+y} +then : + printf %s "(cached) " >&6 +else $as_nop + i=0 + teststring=ABCD + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + mint*) + # On MiNT this can take a long time and run out of memory. + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test X`env echo "$teststring$teststring" 2>/dev/null` \ + = "X$teststring$teststring"; } >/dev/null 2>&1 && + test 17 != "$i" # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac + +fi + +if test -n "$lt_cv_sys_max_cmd_len"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 +printf "%s\n" "$lt_cv_sys_max_cmd_len" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5 +printf "%s\n" "none" >&6; } +fi +max_cmd_len=$lt_cv_sys_max_cmd_len + + + + + + +: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi + + + + + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 +printf %s "checking how to convert $build file names to $host format... " >&6; } +if test ${lt_cv_to_host_file_cmd+y} +then : + printf %s "(cached) " >&6 +else $as_nop + case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac + +fi + +to_host_file_cmd=$lt_cv_to_host_file_cmd +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 +printf "%s\n" "$lt_cv_to_host_file_cmd" >&6; } + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 +printf %s "checking how to convert $build file names to toolchain format... " >&6; } +if test ${lt_cv_to_tool_file_cmd+y} +then : + printf %s "(cached) " >&6 +else $as_nop + #assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac + +fi + +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 +printf "%s\n" "$lt_cv_to_tool_file_cmd" >&6; } + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 +printf %s "checking for $LD option to reload object files... " >&6; } +if test ${lt_cv_ld_reload_flag+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_ld_reload_flag='-r' +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 +printf "%s\n" "$lt_cv_ld_reload_flag" >&6; } +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + if test yes != "$GCC"; then + reload_cmds=false + fi + ;; + darwin*) + if test yes = "$GCC"; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_OBJDUMP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +printf "%s\n" "$OBJDUMP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_OBJDUMP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +printf "%s\n" "$ac_ct_OBJDUMP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + +test -z "$OBJDUMP" && OBJDUMP=objdump + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 +printf %s "checking how to recognize dependent libraries... " >&6; } +if test ${lt_cv_deplibs_check_method+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# 'unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# that responds to the $file_magic_cmd with a given extended regex. +# If you have 'file' or equivalent on your system and you're not sure +# whether 'pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[4-9]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + # Keep this pattern in sync with the one in func_win32_libid. + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc*) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +haiku*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[3-9]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd* | bitrig*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +os2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 +printf "%s\n" "$lt_cv_deplibs_check_method" >&6; } + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` + fi + ;; + esac +fi + +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + + + + + + + + + + + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_DLLTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +printf "%s\n" "$DLLTOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_DLLTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DLLTOOL="dlltool" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +printf "%s\n" "$ac_ct_DLLTOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" +fi + +test -z "$DLLTOOL" && DLLTOOL=dlltool + + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 +printf %s "checking how to associate runtime and link libraries... " >&6; } +if test ${lt_cv_sharedlib_from_linklib_cmd+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd=$ECHO + ;; +esac + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 +printf "%s\n" "$lt_cv_sharedlib_from_linklib_cmd" >&6; } +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + + + + + + + + +if test -n "$ac_tool_prefix"; then + for ac_prog in ar + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_AR+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +printf "%s\n" "$AR" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$AR" && break + done +fi +if test -z "$AR"; then + ac_ct_AR=$AR + for ac_prog in ar +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_AR+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +printf "%s\n" "$ac_ct_AR" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$ac_ct_AR" && break +done + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +fi + +: ${AR=ar} +: ${AR_FLAGS=cr} + + + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 +printf %s "checking for archiver @FILE support... " >&6; } +if test ${lt_cv_ar_at_file+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_ar_at_file=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test 0 -eq "$ac_status"; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test 0 -ne "$ac_status"; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 +printf "%s\n" "$lt_cv_ar_at_file" >&6; } + +if test no = "$lt_cv_ar_at_file"; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +printf "%s\n" "$STRIP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +printf "%s\n" "$ac_ct_STRIP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +test -z "$STRIP" && STRIP=: + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_RANLIB+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +printf "%s\n" "$RANLIB" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_RANLIB+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +printf "%s\n" "$ac_ct_RANLIB" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +test -z "$RANLIB" && RANLIB=: + + + + + + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + bitrig* | openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" +fi + +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 +printf %s "checking command to parse $NM output from $compiler object... " >&6; } +if test ${lt_cv_sys_global_symbol_pipe+y} +then : + printf %s "(cached) " >&6 +else $as_nop + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[ABCDGISTW]' + ;; +hpux*) + if test ia64 = "$host_cpu"; then + symcode='[ABCDEGRST]' + fi + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris*) + symcode='[BDRT]' + ;; +sco3.2v5*) + symcode='[DT]' + ;; +sysv4.2uw2*) + symcode='[DT]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[ABDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. + lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" + lt_c_name_lib_hook="\ + -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ + -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" +else + # Disable hooks by default. + lt_cv_sys_global_symbol_to_import= + lt_cdecl_hook= + lt_c_name_hook= + lt_c_name_lib_hook= +fi + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +$lt_cdecl_hook\ +" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +$lt_c_name_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + +# Transform an extracted symbol line into symbol name with lib prefix and +# symbol address. +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +$lt_c_name_lib_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK '"\ +" {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ +" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ +" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ +" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ +" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + # Now try to grab the symbols. + nlist=conftest.nm + $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5 + if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +LT_DLSYM_CONST struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS + LIBS=conftstm.$ac_objext + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest$ac_exeext; then + pipe_works=yes + fi + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test yes = "$pipe_works"; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +printf "%s\n" "failed" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +printf "%s\n" "ok" >&6; } +fi + +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then + nm_file_list_spec='@' +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 +printf %s "checking for sysroot... " >&6; } + +# Check whether --with-sysroot was given. +if test ${with_sysroot+y} +then : + withval=$with_sysroot; +else $as_nop + with_sysroot=no +fi + + +lt_sysroot= +case $with_sysroot in #( + yes) + if test yes = "$GCC"; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 +printf "%s\n" "$with_sysroot" >&6; } + as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 + ;; +esac + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 +printf "%s\n" "${lt_sysroot:-no}" >&6; } + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 +printf %s "checking for a working dd... " >&6; } +if test ${ac_cv_path_lt_DD+y} +then : + printf %s "(cached) " >&6 +else $as_nop + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +: ${lt_DD:=$DD} +if test -z "$lt_DD"; then + ac_path_lt_DD_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in dd + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_lt_DD="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_lt_DD" || continue +if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: +fi + $ac_path_lt_DD_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_lt_DD"; then + : + fi +else + ac_cv_path_lt_DD=$lt_DD +fi + +rm -f conftest.i conftest2.i conftest.out +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 +printf "%s\n" "$ac_cv_path_lt_DD" >&6; } + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 +printf %s "checking how to truncate binary pipes... " >&6; } +if test ${lt_cv_truncate_bin+y} +then : + printf %s "(cached) " >&6 +else $as_nop + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +lt_cv_truncate_bin= +if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out +test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 +printf "%s\n" "$lt_cv_truncate_bin" >&6; } + + + + + + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + +# Check whether --enable-libtool-lock was given. +if test ${enable_libtool_lock+y} +then : + enableval=$enable_libtool_lock; +fi + +test no = "$enable_libtool_lock" || enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out what ABI is being produced by ac_compile, and set mode + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE=32 + ;; + *ELF-64*) + HPUX_IA64_MODE=64 + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + if test yes = "$lt_cv_prog_gnu_ld"; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +mips64*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + emul=elf + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; + *64-bit*) + emul="${emul}64" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; + *LSB*) + emul="${emul}ltsmip" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; + esac + LD="${LD-ld} -m $emul" + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. Note that the listed cases only cover the + # situations where additional linker options are needed (such as when + # doing 32-bit compilation for a host where ld defaults to 64-bit, or + # vice versa); the common cases where no linker options are needed do + # not appear in the list. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac + ;; + powerpc64le-*linux*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + powerpcle-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -belf" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 +printf %s "checking whether the C compiler needs -belf... " >&6; } +if test ${lt_cv_cc_needs_belf+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + lt_cv_cc_needs_belf=yes +else $as_nop + lt_cv_cc_needs_belf=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 +printf "%s\n" "$lt_cv_cc_needs_belf" >&6; } + if test yes != "$lt_cv_cc_needs_belf"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS=$SAVE_CFLAGS + fi + ;; +*-*solaris*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) + case $host in + i?86-*-solaris*|x86_64-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD=${LD-ld}_sol2 + fi + ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks=$enable_libtool_lock + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. +set dummy ${ac_tool_prefix}mt; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_MANIFEST_TOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$MANIFEST_TOOL"; then + ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL +if test -n "$MANIFEST_TOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 +printf "%s\n" "$MANIFEST_TOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_MANIFEST_TOOL"; then + ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL + # Extract the first word of "mt", so it can be a program name with args. +set dummy mt; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_MANIFEST_TOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_MANIFEST_TOOL"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL +if test -n "$ac_ct_MANIFEST_TOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 +printf "%s\n" "$ac_ct_MANIFEST_TOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_MANIFEST_TOOL" = x; then + MANIFEST_TOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL + fi +else + MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" +fi + +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 +printf %s "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } +if test ${lt_cv_path_mainfest_tool+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&5 + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest* +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 +printf "%s\n" "$lt_cv_path_mainfest_tool" >&6; } +if test yes != "$lt_cv_path_mainfest_tool"; then + MANIFEST_TOOL=: +fi + + + + + + + case $host_os in + rhapsody* | darwin*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. +set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_DSYMUTIL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$DSYMUTIL"; then + ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DSYMUTIL=$ac_cv_prog_DSYMUTIL +if test -n "$DSYMUTIL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 +printf "%s\n" "$DSYMUTIL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DSYMUTIL"; then + ac_ct_DSYMUTIL=$DSYMUTIL + # Extract the first word of "dsymutil", so it can be a program name with args. +set dummy dsymutil; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_DSYMUTIL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_DSYMUTIL"; then + ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL +if test -n "$ac_ct_DSYMUTIL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 +printf "%s\n" "$ac_ct_DSYMUTIL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_DSYMUTIL" = x; then + DSYMUTIL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DSYMUTIL=$ac_ct_DSYMUTIL + fi +else + DSYMUTIL="$ac_cv_prog_DSYMUTIL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. +set dummy ${ac_tool_prefix}nmedit; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_NMEDIT+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$NMEDIT"; then + ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +NMEDIT=$ac_cv_prog_NMEDIT +if test -n "$NMEDIT"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 +printf "%s\n" "$NMEDIT" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_NMEDIT"; then + ac_ct_NMEDIT=$NMEDIT + # Extract the first word of "nmedit", so it can be a program name with args. +set dummy nmedit; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_NMEDIT+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_NMEDIT"; then + ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_NMEDIT="nmedit" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT +if test -n "$ac_ct_NMEDIT"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 +printf "%s\n" "$ac_ct_NMEDIT" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_NMEDIT" = x; then + NMEDIT=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + NMEDIT=$ac_ct_NMEDIT + fi +else + NMEDIT="$ac_cv_prog_NMEDIT" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. +set dummy ${ac_tool_prefix}lipo; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_LIPO+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$LIPO"; then + ac_cv_prog_LIPO="$LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_LIPO="${ac_tool_prefix}lipo" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +LIPO=$ac_cv_prog_LIPO +if test -n "$LIPO"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 +printf "%s\n" "$LIPO" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_LIPO"; then + ac_ct_LIPO=$LIPO + # Extract the first word of "lipo", so it can be a program name with args. +set dummy lipo; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_LIPO+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_LIPO"; then + ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_LIPO="lipo" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO +if test -n "$ac_ct_LIPO"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 +printf "%s\n" "$ac_ct_LIPO" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_LIPO" = x; then + LIPO=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + LIPO=$ac_ct_LIPO + fi +else + LIPO="$ac_cv_prog_LIPO" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_OTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$OTOOL"; then + ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_OTOOL="${ac_tool_prefix}otool" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL=$ac_cv_prog_OTOOL +if test -n "$OTOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 +printf "%s\n" "$OTOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL"; then + ac_ct_OTOOL=$OTOOL + # Extract the first word of "otool", so it can be a program name with args. +set dummy otool; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_OTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_OTOOL"; then + ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OTOOL="otool" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL +if test -n "$ac_ct_OTOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 +printf "%s\n" "$ac_ct_OTOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_OTOOL" = x; then + OTOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL=$ac_ct_OTOOL + fi +else + OTOOL="$ac_cv_prog_OTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool64; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_OTOOL64+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$OTOOL64"; then + ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL64=$ac_cv_prog_OTOOL64 +if test -n "$OTOOL64"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 +printf "%s\n" "$OTOOL64" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL64"; then + ac_ct_OTOOL64=$OTOOL64 + # Extract the first word of "otool64", so it can be a program name with args. +set dummy otool64; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_OTOOL64+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_OTOOL64"; then + ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OTOOL64="otool64" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 +if test -n "$ac_ct_OTOOL64"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 +printf "%s\n" "$ac_ct_OTOOL64" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_OTOOL64" = x; then + OTOOL64=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL64=$ac_ct_OTOOL64 + fi +else + OTOOL64="$ac_cv_prog_OTOOL64" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 +printf %s "checking for -single_module linker flag... " >&6; } +if test ${lt_cv_apple_cc_single_mod+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_apple_cc_single_mod=no + if test -z "$LT_MULTI_MODULE"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&5 + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test 0 = "$_lt_result"; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&5 + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 +printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 +printf %s "checking for -exported_symbols_list linker flag... " >&6; } +if test ${lt_cv_ld_exported_symbols_list+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + lt_cv_ld_exported_symbols_list=yes +else $as_nop + lt_cv_ld_exported_symbols_list=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 +printf "%s\n" "$lt_cv_ld_exported_symbols_list" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 +printf %s "checking for -force_load linker flag... " >&6; } +if test ${lt_cv_ld_force_load+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_ld_force_load=no + cat > conftest.c << _LT_EOF +int forced_loaded() { return 2;} +_LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 + echo "$AR cr libconftest.a conftest.o" >&5 + $AR cr libconftest.a conftest.o 2>&5 + echo "$RANLIB libconftest.a" >&5 + $RANLIB libconftest.a 2>&5 + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err + _lt_result=$? + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&5 + elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then + lt_cv_ld_force_load=yes + else + cat conftest.err >&5 + fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 +printf "%s\n" "$lt_cv_ld_force_load" >&6; } + case $host_os in + rhapsody* | darwin1.[012]) + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[912]*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + 10.[012][,.]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + 10.*|11.*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test yes = "$lt_cv_apple_cc_single_mod"; then + _lt_dar_single_mod='$single_module' + fi + if test yes = "$lt_cv_ld_exported_symbols_list"; then + _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' + fi + if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + +ac_header= ac_cache= +for ac_item in $ac_header_c_list +do + if test $ac_cache; then + ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" + if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then + printf "%s\n" "#define $ac_item 1" >> confdefs.h + fi + ac_header= ac_cache= + elif test $ac_header; then + ac_cache=$ac_item + else + ac_header=$ac_item + fi +done + + + + + + + + +if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes +then : + +printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default +" +if test "x$ac_cv_header_dlfcn_h" = xyes +then : + printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h + +fi + + + + + +# Set options + + + + enable_dlopen=no + + + enable_win32_dll=no + + + # Check whether --enable-shared was given. +if test ${enable_shared+y} +then : + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else $as_nop + enable_shared=yes +fi + + + + + + + + + + # Check whether --enable-static was given. +if test ${enable_static+y} +then : + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else $as_nop + enable_static=yes +fi + + + + + + + + + + +# Check whether --with-pic was given. +if test ${with_pic+y} +then : + withval=$with_pic; lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $withval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else $as_nop + pic_mode=default +fi + + + + + + + + + # Check whether --enable-fast-install was given. +if test ${enable_fast_install+y} +then : + enableval=$enable_fast_install; p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else $as_nop + enable_fast_install=yes +fi + + + + + + + + + shared_archive_member_spec= +case $host,$enable_shared in +power*-*-aix[5-9]*,yes) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 +printf %s "checking which variant of shared library versioning to provide... " >&6; } + +# Check whether --with-aix-soname was given. +if test ${with_aix_soname+y} +then : + withval=$with_aix_soname; case $withval in + aix|svr4|both) + ;; + *) + as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname +else $as_nop + if test ${lt_cv_with_aix_soname+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_with_aix_soname=aix +fi + + with_aix_soname=$lt_cv_with_aix_soname +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 +printf "%s\n" "$with_aix_soname" >&6; } + if test aix != "$with_aix_soname"; then + # For the AIX way of multilib, we name the shared archive member + # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', + # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. + # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, + # the AIX toolchain works better with OBJECT_MODE set (default 32). + if test 64 = "${OBJECT_MODE-32}"; then + shared_archive_member_spec=shr_64 + else + shared_archive_member_spec=shr + fi + fi + ;; +*) + with_aix_soname=aix + ;; +esac + + + + + + + + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS=$ltmain + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +test -z "$LN_S" && LN_S="ln -s" + + + + + + + + + + + + + + +if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 +printf %s "checking for objdir... " >&6; } +if test ${lt_cv_objdir+y} +then : + printf %s "(cached) " >&6 +else $as_nop + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 +printf "%s\n" "$lt_cv_objdir" >&6; } +objdir=$lt_cv_objdir + + + + + +printf "%s\n" "#define LT_OBJDIR \"$lt_cv_objdir/\"" >>confdefs.h + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld=$lt_cv_prog_gnu_ld + +old_CC=$CC +old_CFLAGS=$CFLAGS + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +func_cc_basename $compiler +cc_basename=$func_cc_basename_result + + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 +printf %s "checking for ${ac_tool_prefix}file... " >&6; } +if test ${lt_cv_path_MAGIC_CMD+y} +then : + printf %s "(cached) " >&6 +else $as_nop + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/${ac_tool_prefix}file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac +fi + +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +printf "%s\n" "$MAGIC_CMD" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + + + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for file" >&5 +printf %s "checking for file... " >&6; } +if test ${lt_cv_path_MAGIC_CMD+y} +then : + printf %s "(cached) " >&6 +else $as_nop + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac +fi + +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +printf "%s\n" "$MAGIC_CMD" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +# Use C for the default configuration in the libtool script + +lt_save_CC=$CC +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* + +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* + + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + +lt_prog_compiler_no_builtin_flag= + +if test yes = "$GCC"; then + case $cc_basename in + nvcc*) + lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; + *) + lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; + esac + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +printf %s "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } +if test ${lt_cv_prog_compiler_rtti_exceptions+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +printf "%s\n" "$lt_cv_prog_compiler_rtti_exceptions" >&6; } + +if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + + + + + + + lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + + + if test yes = "$GCC"; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + lt_prog_compiler_pic='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + lt_prog_compiler_pic='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + lt_prog_compiler_static= + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + lt_prog_compiler_wl='-Xlinker ' + if test -n "$lt_prog_compiler_pic"; then + lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='$wl-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + # old Intel for x86_64, which still supported -KPIC. + ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + # flang / f18. f95 an alias for gfortran or flang on Debian + flang* | f18* | f95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='--shared' + lt_prog_compiler_static='--static' + ;; + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-qpic' + lt_prog_compiler_static='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' + ;; + *Sun\ F* | *Sun*Fortran*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Wl,' + ;; + *Intel*\ [CF]*Compiler*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + *Portland\ Group*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + rdos*) + lt_prog_compiler_static='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +case $host_os in + # For platforms that do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +printf %s "checking for $compiler option to produce PIC... " >&6; } +if test ${lt_cv_prog_compiler_pic+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_pic=$lt_prog_compiler_pic +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic" >&6; } +lt_prog_compiler_pic=$lt_cv_prog_compiler_pic + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if test ${lt_cv_prog_compiler_pic_works+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works=yes + fi + fi + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic_works" >&6; } + +if test yes = "$lt_cv_prog_compiler_pic_works"; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi + + + + + + + + + + + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if test ${lt_cv_prog_compiler_static_works+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_static_works=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works=yes + fi + else + lt_cv_prog_compiler_static_works=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 +printf "%s\n" "$lt_cv_prog_compiler_static_works" >&6; } + +if test yes = "$lt_cv_prog_compiler_static_works"; then + : +else + lt_prog_compiler_static= +fi + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test ${lt_cv_prog_compiler_c_o+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test ${lt_cv_prog_compiler_c_o+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } + + + + +hard_links=nottested +if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then + # do not overwrite the value of need_locks provided by the user + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +printf %s "checking if we can lock with hard links... " >&6; } + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +printf "%s\n" "$hard_links" >&6; } + if test no = "$hard_links"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + runpath_var= + allow_undefined_flag= + always_export_symbols=no + archive_cmds= + archive_expsym_cmds= + compiler_needs_object=no + enable_shared_with_static_runtimes=no + export_dynamic_flag_spec= + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + hardcode_automatic=no + hardcode_direct=no + hardcode_direct_absolute=no + hardcode_libdir_flag_spec= + hardcode_libdir_separator= + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + inherit_rpath=no + link_all_deplibs=unknown + module_cmds= + module_expsym_cmds= + old_archive_from_new_cmds= + old_archive_from_expsyms_cmds= + thread_safe_flag_spec= + whole_archive_flag_spec= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ' (' and ')$', so one must not match beginning or + # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', + # as well as any symbol that contains 'd'. + exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test yes != "$GCC"; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd* | bitrig*) + with_gnu_ld=no + ;; + linux* | k*bsd*-gnu | gnu*) + link_all_deplibs=no + ;; + esac + + ld_shlibs=yes + + # On some targets, GNU ld is compatible enough with the native linker + # that we're better off using the native interface for both. + lt_use_gnu_ld_interface=no + if test yes = "$with_gnu_ld"; then + case $host_os in + aix*) + # The AIX port of GNU ld has always aspired to compatibility + # with the native linker. However, as the warning in the GNU ld + # block says, versions before 2.19.5* couldn't really create working + # shared libraries, regardless of the interface used. + case `$LD -v 2>&1` in + *\ \(GNU\ Binutils\)\ 2.19.5*) ;; + *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; + *\ \(GNU\ Binutils\)\ [3-9]*) ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + fi + + if test yes = "$lt_use_gnu_ld_interface"; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='$wl' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + export_dynamic_flag_spec='$wl--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + whole_archive_flag_spec= + fi + supports_anon_versioning=no + case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test ia64 != "$host_cpu"; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.19, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to install binutils +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. +*** You will then need to restart the configuration process. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + export_dynamic_flag_spec='$wl--export-all-symbols' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' + exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs=no + fi + ;; + + haiku*) + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + link_all_deplibs=yes + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes + ;; + + interix[3-9]*) + hardcode_direct=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + tmp_diet=no + if test linux-dietlibc = "$host_os"; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test no = "$tmp_diet" + then + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group f77 and f90 compilers + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + whole_archive_flag_spec= + tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 + tmp_sharedflag='-Wl,-shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + nvcc*) # Cuda Compiler Driver 2.2 + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + compiler_needs_object=yes + ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + compiler_needs_object=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + tcc*) + export_dynamic_flag_spec='-rdynamic' + ;; + xlf* | bgf* | bgxlf* | mpixlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + ld_shlibs=no + fi + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test no = "$ld_shlibs"; then + runpath_var= + hardcode_libdir_flag_spec= + export_dynamic_flag_spec= + whole_archive_flag_spec= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix[4-9]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then + aix_use_runtimelinking=yes + break + fi + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_direct_absolute=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + file_list_spec='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # traditional, no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + hardcode_direct=no + hardcode_direct_absolute=no + ;; + esac + + if test yes = "$GCC"; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag="$shared_flag "'$wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + export_dynamic_flag_spec='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if test ${lt_cv_aix_libpath_+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=/usr/lib:/lib + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if test ${lt_cv_aix_libpath_+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=/usr/lib:/lib + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' $wl-bernotok' + allow_undefined_flag=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + fi + archive_cmds_need_lc=yes + archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in + cl*) + # Native MSVC + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + always_export_symbols=yes + file_list_spec='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, )='true' + enable_shared_with_static_runtimes=yes + exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + old_postinstall_cmds='chmod 644 $oldlib' + postlink_cmds='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + enable_shared_with_static_runtimes=yes + ;; + esac + ;; + + darwin* | rhapsody*) + + + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + if test yes = "$lt_cv_ld_force_load"; then + whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + + else + whole_archive_flag_spec='' + fi + link_all_deplibs=yes + allow_undefined_flag=$_lt_dar_allow_undefined + case $cc_basename in + ifort*|nagfor*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test yes = "$_lt_dar_can_shared"; then + output_verbose_link_cmd=func_echo_all + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + + else + ld_shlibs=no + fi + + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2.*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test yes = "$GCC"; then + archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='$wl-E' + ;; + + hpux10*) + if test yes,no = "$GCC,$with_gnu_ld"; then + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='$wl-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + + hpux11*) + if test yes,no = "$GCC,$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + + # Older versions of the 11.00 compiler do not understand -b yet + # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 +printf %s "checking if $CC understands -b... " >&6; } +if test ${lt_cv_prog_compiler__b+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler__b=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -b" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler__b=yes + fi + else + lt_cv_prog_compiler__b=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 +printf "%s\n" "$lt_cv_prog_compiler__b" >&6; } + +if test yes = "$lt_cv_prog_compiler__b"; then + archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' +else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' +fi + + ;; + esac + fi + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + *) + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='$wl-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test yes = "$GCC"; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + # This should be the same for all languages, so no per-tag cache variable. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 +printf %s "checking whether the $host_os linker accepts -exported_symbol... " >&6; } +if test ${lt_cv_irix_exported_symbol+y} +then : + printf %s "(cached) " >&6 +else $as_nop + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo (void) { return 0; } +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + lt_cv_irix_exported_symbol=yes +else $as_nop + lt_cv_irix_exported_symbol=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 +printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } + if test yes = "$lt_cv_irix_exported_symbol"; then + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' + fi + link_all_deplibs=no + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + inherit_rpath=yes + link_all_deplibs=yes + ;; + + linux*) + case $cc_basename in + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + ld_shlibs=yes + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + *nto* | *qnx*) + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + hardcode_shlibpath_var=no + hardcode_direct_absolute=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' + else + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + fi + else + ld_shlibs=no + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes + ;; + + osf3*) + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + archive_cmds_need_lc='no' + hardcode_libdir_separator=: + ;; + + solaris*) + no_undefined_flag=' -z defs' + if test yes = "$GCC"; then + wlarc='$wl' + archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='$wl' + archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. GCC discards it without '$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test yes = "$GCC"; then + whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + else + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' + fi + ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test sequent = "$host_vendor"; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag='$wl-z,text' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag='$wl-z,text' + allow_undefined_flag='$wl-z,nodefs' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='$wl-R,$libdir' + hardcode_libdir_separator=':' + link_all_deplibs=yes + export_dynamic_flag_spec='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + + if test sni = "$host_vendor"; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + export_dynamic_flag_spec='$wl-Blargedynsym' + ;; + esac + fi + fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 +printf "%s\n" "$ld_shlibs" >&6; } +test no = "$ld_shlibs" && can_build_shared=no + +with_gnu_ld=$with_gnu_ld + + + + + + + + + + + + + + + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test yes,yes = "$GCC,$enable_shared"; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +printf %s "checking whether -lc should be explicitly linked in... " >&6; } +if test ${lt_cv_archive_cmds_need_lc+y} +then : + printf %s "(cached) " >&6 +else $as_nop + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 + (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + then + lt_cv_archive_cmds_need_lc=no + else + lt_cv_archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 +printf "%s\n" "$lt_cv_archive_cmds_need_lc" >&6; } + archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc + ;; + esac + fi + ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +printf %s "checking dynamic linker characteristics... " >&6; } + +if test yes = "$GCC"; then + case $host_os in + darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; + *) lt_awk_arg='/^libraries:/' ;; + esac + case $host_os in + mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; + *) lt_sed_strip_eq='s|=/|/|g' ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` + case $lt_search_path_spec in + *\;*) + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary... + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + # ...but if some path component already ends with the multilib dir we assume + # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). + case "$lt_multi_os_dir; $lt_search_path_spec " in + "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) + lt_multi_os_dir= + ;; + esac + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" + elif test -n "$lt_multi_os_dir"; then + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' +BEGIN {RS = " "; FS = "/|\n";} { + lt_foo = ""; + lt_count = 0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo = "/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[lt_foo]++; } + if (lt_freq[lt_foo] == 1) { print lt_foo; } +}'` + # AWK program above erroneously prepends '/' to C:/dos/paths + # for these hosts. + case $host_os in + mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + $SED 's|/\([A-Za-z]:\)|\1|g'` ;; + esac + sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=.so +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + + + +case $host_os in +aix3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='$libname$release$shared_ext$major' + ;; + +aix[4-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test ia64 = "$host_cpu"; then + # AIX 5 supports IA64 + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a(lib.so.V)' + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='$libname$shared_ext' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + + case $GCC,$cc_basename in + yes,*) + # gcc + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec=$LIB + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' + ;; + + *) + # Assume MSVC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; + esac + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[23].*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2.*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + dynamic_linker="$host_os runtime_loader" + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=no + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 + fi + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 + ;; + +interix[3-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test yes = "$lt_cv_prog_gnu_ld"; then + version_type=linux # correct to gnu/linux during the next big refactor + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + hardcode_libdir_flag_spec='-L$libdir' + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + + # Some binutils ld are patched to set DT_RUNPATH + if test ${lt_cv_shlibpath_overrides_runpath+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null +then : + lt_cv_shlibpath_overrides_runpath=yes +fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + +fi + + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd* | bitrig*) + version_type=sunos + sys_lib_dlsearch_path_spec=/usr/lib + need_lib_prefix=no + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +os2*) + libname_spec='$name' + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test yes = "$with_gnu_ld"; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec; then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=sco + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test yes = "$with_gnu_ld"; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +printf "%s\n" "$dynamic_linker" >&6; } +test no = "$dynamic_linker" && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test yes = "$GCC"; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec +fi + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec +fi + +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +printf %s "checking how to hardcode library paths into programs... " >&6; } +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || + test -n "$runpath_var" || + test yes = "$hardcode_automatic"; then + + # We can hardcode non-existent directories. + if test no != "$hardcode_direct" && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && + test no != "$hardcode_minus_L"; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 +printf "%s\n" "$hardcode_action" >&6; } + +if test relink = "$hardcode_action" || + test yes = "$inherit_rpath"; then + # Fast installation is not supported + enable_fast_install=no +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + + + + + + if test yes != "$enable_dlopen"; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen=load_add_on + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen=LoadLibrary + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +printf %s "checking for dlopen in -ldl... " >&6; } +if test ${ac_cv_lib_dl_dlopen+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main (void) +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_dl_dlopen=yes +else $as_nop + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes +then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl +else $as_nop + + lt_cv_dlopen=dyld + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + tpf*) + # Don't try to run any link tests for TPF. We know it's impossible + # because TPF is a cross-compiler, and we know how we open DSOs. + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + lt_cv_dlopen_self=no + ;; + + *) + ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" +if test "x$ac_cv_func_shl_load" = xyes +then : + lt_cv_dlopen=shl_load +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 +printf %s "checking for shl_load in -ldld... " >&6; } +if test ${ac_cv_lib_dld_shl_load+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char shl_load (); +int +main (void) +{ +return shl_load (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_dld_shl_load=yes +else $as_nop + ac_cv_lib_dld_shl_load=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 +printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = xyes +then : + lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld +else $as_nop + ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" +if test "x$ac_cv_func_dlopen" = xyes +then : + lt_cv_dlopen=dlopen +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +printf %s "checking for dlopen in -ldl... " >&6; } +if test ${ac_cv_lib_dl_dlopen+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main (void) +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_dl_dlopen=yes +else $as_nop + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes +then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 +printf %s "checking for dlopen in -lsvld... " >&6; } +if test ${ac_cv_lib_svld_dlopen+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main (void) +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_svld_dlopen=yes +else $as_nop + ac_cv_lib_svld_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 +printf "%s\n" "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = xyes +then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 +printf %s "checking for dld_link in -ldld... " >&6; } +if test ${ac_cv_lib_dld_dld_link+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char dld_link (); +int +main (void) +{ +return dld_link (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_dld_dld_link=yes +else $as_nop + ac_cv_lib_dld_dld_link=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 +printf "%s\n" "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = xyes +then : + lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test no = "$lt_cv_dlopen"; then + enable_dlopen=no + else + enable_dlopen=yes + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS=$CPPFLAGS + test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS=$LDFLAGS + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS=$LIBS + LIBS="$lt_cv_dlopen_libs $LIBS" + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 +printf %s "checking whether a program can dlopen itself... " >&6; } +if test ${lt_cv_dlopen_self+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test yes = "$cross_compiling"; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 +printf "%s\n" "$lt_cv_dlopen_self" >&6; } + + if test yes = "$lt_cv_dlopen_self"; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 +printf %s "checking whether a statically linked program can dlopen itself... " >&6; } +if test ${lt_cv_dlopen_self_static+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test yes = "$cross_compiling"; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 +printf "%s\n" "$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + + + + + + + + + + + + + + + + +striplib= +old_striplib= +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 +printf %s "checking whether stripping libraries is possible... " >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP"; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + fi + ;; + *) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + ;; + esac +fi + + + + + + + + + + + + + # Report what library types will actually be built + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 +printf %s "checking if libtool supports shared libraries... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 +printf "%s\n" "$can_build_shared" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 +printf %s "checking whether to build shared libraries... " >&6; } + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[4-9]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 +printf "%s\n" "$enable_shared" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 +printf %s "checking whether to build static libraries... " >&6; } + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 +printf "%s\n" "$enable_static" >&6; } + + + + +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC=$lt_save_CC + + + + + + + + + + + + + + + + ac_config_commands="$ac_config_commands libtool" + + + + +# Only expand once: + + + + + + + + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +printf "%s\n" "$CXX" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +printf "%s\n" "$ac_ct_CXX" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C++" >&5 +printf %s "checking whether the compiler supports GNU C++... " >&6; } +if test ${ac_cv_cxx_compiler_gnu+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO" +then : + ac_compiler_gnu=yes +else $as_nop + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +printf "%s\n" "$ac_cv_cxx_compiler_gnu" >&6; } +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+y} +ac_save_CXXFLAGS=$CXXFLAGS +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +printf %s "checking whether $CXX accepts -g... " >&6; } +if test ${ac_cv_prog_cxx_g+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO" +then : + ac_cv_prog_cxx_g=yes +else $as_nop + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO" +then : + +else $as_nop + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO" +then : + ac_cv_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +printf "%s\n" "$ac_cv_prog_cxx_g" >&6; } +if test $ac_test_CXXFLAGS; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_prog_cxx_stdcxx=no +if test x$ac_prog_cxx_stdcxx = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5 +printf %s "checking for $CXX option to enable C++11 features... " >&6; } +if test ${ac_cv_prog_cxx_11+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cxx_11=no +ac_save_CXX=$CXX +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_cxx_conftest_cxx11_program +_ACEOF +for ac_arg in '' -std=gnu++11 -std=gnu++0x -std=c++11 -std=c++0x -qlanglvl=extended0x -AA +do + CXX="$ac_save_CXX $ac_arg" + if ac_fn_cxx_try_compile "$LINENO" +then : + ac_cv_prog_cxx_cxx11=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cxx_cxx11" != "xno" && break +done +rm -f conftest.$ac_ext +CXX=$ac_save_CXX +fi + +if test "x$ac_cv_prog_cxx_cxx11" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cxx_cxx11" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx11" >&5 +printf "%s\n" "$ac_cv_prog_cxx_cxx11" >&6; } + CXX="$CXX $ac_cv_prog_cxx_cxx11" +fi + ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11 + ac_prog_cxx_stdcxx=cxx11 +fi +fi +if test x$ac_prog_cxx_stdcxx = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5 +printf %s "checking for $CXX option to enable C++98 features... " >&6; } +if test ${ac_cv_prog_cxx_98+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cxx_98=no +ac_save_CXX=$CXX +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_cxx_conftest_cxx98_program +_ACEOF +for ac_arg in '' -std=gnu++98 -std=c++98 -qlanglvl=extended -AA +do + CXX="$ac_save_CXX $ac_arg" + if ac_fn_cxx_try_compile "$LINENO" +then : + ac_cv_prog_cxx_cxx98=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cxx_cxx98" != "xno" && break +done +rm -f conftest.$ac_ext +CXX=$ac_save_CXX +fi + +if test "x$ac_cv_prog_cxx_cxx98" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cxx_cxx98" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx98" >&5 +printf "%s\n" "$ac_cv_prog_cxx_cxx98" >&6; } + CXX="$CXX $ac_cv_prog_cxx_cxx98" +fi + ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98 + ac_prog_cxx_stdcxx=cxx98 +fi +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CXX" am_compiler_list= + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +printf %s "checking dependency style of $depcc... " >&6; } +if test ${am_cv_CXX_dependencies_compiler_type+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 +printf "%s\n" "$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + + + + +func_stripname_cnf () +{ + case $2 in + .*) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%\\\\$2\$%%"`;; + *) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%$2\$%%"`;; + esac +} # func_stripname_cnf + + if test -n "$CXX" && ( test no != "$CXX" && + ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || + (test g++ != "$CXX"))); then + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 +printf %s "checking how to run the C++ preprocessor... " >&6; } +if test -z "$CXXCPP"; then + if test ${ac_cv_prog_CXXCPP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + # Double quotes because $CXX needs to be expanded + for CXXCPP in "$CXX -E" cpp /lib/cpp + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO" +then : + +else $as_nop + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO" +then : + # Broken: success on invalid input. +continue +else $as_nop + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok +then : + break +fi + + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 +printf "%s\n" "$CXXCPP" >&6; } +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO" +then : + +else $as_nop + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO" +then : + # Broken: success on invalid input. +continue +else $as_nop + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok +then : + +else $as_nop + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +else + _lt_caught_CXX_error=yes +fi + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +archive_cmds_need_lc_CXX=no +allow_undefined_flag_CXX= +always_export_symbols_CXX=no +archive_expsym_cmds_CXX= +compiler_needs_object_CXX=no +export_dynamic_flag_spec_CXX= +hardcode_direct_CXX=no +hardcode_direct_absolute_CXX=no +hardcode_libdir_flag_spec_CXX= +hardcode_libdir_separator_CXX= +hardcode_minus_L_CXX=no +hardcode_shlibpath_var_CXX=unsupported +hardcode_automatic_CXX=no +inherit_rpath_CXX=no +module_cmds_CXX= +module_expsym_cmds_CXX= +link_all_deplibs_CXX=unknown +old_archive_cmds_CXX=$old_archive_cmds +reload_flag_CXX=$reload_flag +reload_cmds_CXX=$reload_cmds +no_undefined_flag_CXX= +whole_archive_flag_spec_CXX= +enable_shared_with_static_runtimes_CXX=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +objext_CXX=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_caught_CXX_error"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + + # save warnings/boilerplate of simple test code + ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* + + ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* + + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_CFLAGS=$CFLAGS + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + CFLAGS=$CXXFLAGS + compiler=$CC + compiler_CXX=$CC + func_cc_basename $compiler +cc_basename=$func_cc_basename_result + + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test yes = "$GXX"; then + lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' + else + lt_prog_compiler_no_builtin_flag_CXX= + fi + + if test yes = "$GXX"; then + # Set up default GNU C++ configuration + + + +# Check whether --with-gnu-ld was given. +if test ${with_gnu_ld+y} +then : + withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes +else $as_nop + with_gnu_ld=no +fi + +ac_prog=ld +if test yes = "$GCC"; then + # Check if gcc -print-prog-name=ld gives a path. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +printf %s "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return, which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD=$ac_prog + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test yes = "$with_gnu_ld"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +printf %s "checking for GNU ld... " >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +printf %s "checking for non-GNU ld... " >&6; } +fi +if test ${lt_cv_path_LD+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -z "$LD"; then + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD=$ac_dir/$ac_prog + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +printf "%s\n" "$LD" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +printf %s "checking if the linker ($LD) is GNU ld... " >&6; } +if test ${lt_cv_prog_gnu_ld+y} +then : + printf %s "(cached) " >&6 +else $as_nop + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + + + + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test yes = "$with_gnu_ld"; then + archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + + hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' + export_dynamic_flag_spec_CXX='$wl--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='$wl' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + whole_archive_flag_spec_CXX= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + ld_shlibs_CXX=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aix[4-9]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_CXX='' + hardcode_direct_CXX=yes + hardcode_direct_absolute_CXX=yes + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + file_list_spec_CXX='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + hardcode_direct_CXX=no + hardcode_direct_absolute_CXX=no + ;; + esac + + if test yes = "$GXX"; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct_CXX=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_CXX=yes + hardcode_libdir_flag_spec_CXX='-L$libdir' + hardcode_libdir_separator_CXX= + fi + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag=$shared_flag' $wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + export_dynamic_flag_spec_CXX='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + always_export_symbols_CXX=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + # The "-G" linker flag allows undefined symbols. + no_undefined_flag_CXX='-bernotok' + # Determine the default libpath from the value encoded in an empty + # executable. + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if test ${lt_cv_aix_libpath__CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO" +then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath__CXX"; then + lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath__CXX"; then + lt_cv_aix_libpath__CXX=/usr/lib:/lib + fi + +fi + + aix_libpath=$lt_cv_aix_libpath__CXX +fi + + hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath" + + archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + hardcode_libdir_flag_spec_CXX='$wl-R $libdir:/usr/lib:/lib' + allow_undefined_flag_CXX="-z nodefs" + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if test ${lt_cv_aix_libpath__CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO" +then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath__CXX"; then + lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath__CXX"; then + lt_cv_aix_libpath__CXX=/usr/lib:/lib + fi + +fi + + aix_libpath=$lt_cv_aix_libpath__CXX +fi + + hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_CXX=' $wl-bernotok' + allow_undefined_flag_CXX=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_CXX='$convenience' + fi + archive_cmds_need_lc_CXX=yes + archive_expsym_cmds_CXX='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared + # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. + archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_CXX=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + ld_shlibs_CXX=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + cygwin* | mingw* | pw32* | cegcc*) + case $GXX,$cc_basename in + ,cl* | no,cl*) + # Native MSVC + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec_CXX=' ' + allow_undefined_flag_CXX=unsupported + always_export_symbols_CXX=yes + file_list_spec_CXX='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + archive_expsym_cmds_CXX='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true' + enable_shared_with_static_runtimes_CXX=yes + # Don't use ranlib + old_postinstall_cmds_CXX='chmod 644 $oldlib' + postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + func_to_tool_file "$lt_outputfile"~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # g++ + # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_CXX='-L$libdir' + export_dynamic_flag_spec_CXX='$wl--export-all-symbols' + allow_undefined_flag_CXX=unsupported + always_export_symbols_CXX=no + enable_shared_with_static_runtimes_CXX=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + archive_expsym_cmds_CXX='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs_CXX=no + fi + ;; + esac + ;; + darwin* | rhapsody*) + + + archive_cmds_need_lc_CXX=no + hardcode_direct_CXX=no + hardcode_automatic_CXX=yes + hardcode_shlibpath_var_CXX=unsupported + if test yes = "$lt_cv_ld_force_load"; then + whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + + else + whole_archive_flag_spec_CXX='' + fi + link_all_deplibs_CXX=yes + allow_undefined_flag_CXX=$_lt_dar_allow_undefined + case $cc_basename in + ifort*|nagfor*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test yes = "$_lt_dar_can_shared"; then + output_verbose_link_cmd=func_echo_all + archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + module_expsym_cmds_CXX="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + if test yes != "$lt_cv_apple_cc_single_mod"; then + archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" + archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" + fi + + else + ld_shlibs_CXX=no + fi + + ;; + + os2*) + hardcode_libdir_flag_spec_CXX='-L$libdir' + hardcode_minus_L_CXX=yes + allow_undefined_flag_CXX=unsupported + shrext_cmds=.dll + archive_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds_CXX='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes_CXX=yes + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + freebsd2.*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + ld_shlibs_CXX=no + ;; + + freebsd-elf*) + archive_cmds_need_lc_CXX=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + ld_shlibs_CXX=yes + ;; + + haiku*) + archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + link_all_deplibs_CXX=yes + ;; + + hpux9*) + hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir' + hardcode_libdir_separator_CXX=: + export_dynamic_flag_spec_CXX='$wl-E' + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC*) + archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes = "$GXX"; then + archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir' + hardcode_libdir_separator_CXX=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + export_dynamic_flag_spec_CXX='$wl-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + ;; + *) + hardcode_direct_CXX=yes + hardcode_direct_absolute_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + archive_cmds_CXX='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + + interix[3-9]*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' + export_dynamic_flag_spec_CXX='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds_CXX='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' + fi + fi + link_all_deplibs_CXX=yes + ;; + esac + hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' + hardcode_libdir_separator_CXX=: + inherit_rpath_CXX=yes + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + + hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' + export_dynamic_flag_spec_CXX='$wl--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + archive_cmds_need_lc_CXX=no + hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' + export_dynamic_flag_spec_CXX='$wl--export-dynamic' + whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [1-5].* | *pgcpp\ [1-5].*) + prelink_cmds_CXX='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' + old_archive_cmds_CXX='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ + $RANLIB $oldlib' + archive_cmds_CXX='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 6 and above use weak symbols + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + + hardcode_libdir_flag_spec_CXX='$wl--rpath $wl$libdir' + export_dynamic_flag_spec_CXX='$wl--export-dynamic' + whole_archive_flag_spec_CXX='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + ;; + cxx*) + # Compaq C++ + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' + ;; + xl* | mpixl* | bgxl*) + # IBM XL 8.0 on PPC, with GNU ld + hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' + export_dynamic_flag_spec_CXX='$wl--export-dynamic' + archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + no_undefined_flag_CXX=' -zdefs' + archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_expsym_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' + hardcode_libdir_flag_spec_CXX='-R$libdir' + whole_archive_flag_spec_CXX='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + compiler_needs_object_CXX=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + ld_shlibs_CXX=yes + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + hardcode_direct_absolute_CXX=yes + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' + export_dynamic_flag_spec_CXX='$wl-E' + whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + fi + output_verbose_link_cmd=func_echo_all + else + ld_shlibs_CXX=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx*) + case $host in + osf3*) + allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*' + archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' + ;; + *) + allow_undefined_flag_CXX=' -expect_unresolved \*' + archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ + $RM $lib.exp' + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + ;; + esac + + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes,no = "$GXX,$with_gnu_ld"; then + allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*' + case $host in + osf3*) + archive_cmds_CXX='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + ;; + *) + archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + ;; + esac + + hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + archive_cmds_need_lc_CXX=yes + no_undefined_flag_CXX=' -zdefs' + archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_shlibpath_var_CXX=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' + ;; + esac + link_all_deplibs_CXX=yes + + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test yes,no = "$GXX,$with_gnu_ld"; then + no_undefined_flag_CXX=' $wl-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' + else + # g++ 2.7 appears to require '-G' NOT '-shared' on this + # platform. + archive_cmds_CXX='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' + fi + + hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir' + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + whole_archive_flag_spec_CXX='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag_CXX='$wl-z,text' + archive_cmds_need_lc_CXX=no + hardcode_shlibpath_var_CXX=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag_CXX='$wl-z,text' + allow_undefined_flag_CXX='$wl-z,nodefs' + archive_cmds_need_lc_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_libdir_flag_spec_CXX='$wl-R,$libdir' + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + export_dynamic_flag_spec_CXX='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~ + '"$old_archive_cmds_CXX" + reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~ + '"$reload_cmds_CXX" + ;; + *) + archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 +printf "%s\n" "$ld_shlibs_CXX" >&6; } + test no = "$ld_shlibs_CXX" && can_build_shared=no + + GCC_CXX=$GXX + LD_CXX=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + # Dependencies to place before and after the object being linked: +predep_objects_CXX= +postdep_objects_CXX= +predeps_CXX= +postdeps_CXX= +compiler_lib_search_path_CXX= + +cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF + + +_lt_libdeps_save_CFLAGS=$CFLAGS +case "$CC $CFLAGS " in #( +*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; +*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; +*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; +esac + +if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case $prev$p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test x-L = "$p" || + test x-R = "$p"; then + prev=$p + continue + fi + + # Expand the sysroot to ease extracting the directories later. + if test -z "$prev"; then + case $p in + -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; + -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; + -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; + esac + fi + case $p in + =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; + esac + if test no = "$pre_test_object_deps_done"; then + case $prev in + -L | -R) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$compiler_lib_search_path_CXX"; then + compiler_lib_search_path_CXX=$prev$p + else + compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} $prev$p" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$postdeps_CXX"; then + postdeps_CXX=$prev$p + else + postdeps_CXX="${postdeps_CXX} $prev$p" + fi + fi + prev= + ;; + + *.lto.$objext) ;; # Ignore GCC LTO objects + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test no = "$pre_test_object_deps_done"; then + if test -z "$predep_objects_CXX"; then + predep_objects_CXX=$p + else + predep_objects_CXX="$predep_objects_CXX $p" + fi + else + if test -z "$postdep_objects_CXX"; then + postdep_objects_CXX=$p + else + postdep_objects_CXX="$postdep_objects_CXX $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling CXX test program" +fi + +$RM -f confest.$objext +CFLAGS=$_lt_libdeps_save_CFLAGS + +# PORTME: override above test on systems where it is broken +case $host_os in +interix[3-9]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + predep_objects_CXX= + postdep_objects_CXX= + postdeps_CXX= + ;; +esac + + +case " $postdeps_CXX " in +*" -lc "*) archive_cmds_need_lc_CXX=no ;; +esac + compiler_lib_search_dirs_CXX= +if test -n "${compiler_lib_search_path_CXX}"; then + compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | $SED -e 's! -L! !g' -e 's!^ !!'` +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + lt_prog_compiler_wl_CXX= +lt_prog_compiler_pic_CXX= +lt_prog_compiler_static_CXX= + + + # C++ specific cases for pic, static, wl, etc. + if test yes = "$GXX"; then + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + fi + lt_prog_compiler_pic_CXX='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + lt_prog_compiler_pic_CXX='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic_CXX='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static_CXX='$wl-static' + ;; + esac + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_CXX='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + lt_prog_compiler_pic_CXX= + ;; + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + lt_prog_compiler_static_CXX= + ;; + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_CXX=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic_CXX='-fPIC -shared' + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + else + case $host_os in + aix[4-9]*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + else + lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_CXX='-DDLL_EXPORT' + ;; + dgux*) + case $cc_basename in + ec++*) + lt_prog_compiler_pic_CXX='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='$wl-a ${wl}archive' + if test ia64 != "$host_cpu"; then + lt_prog_compiler_pic_CXX='+Z' + fi + ;; + aCC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='$wl-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_CXX='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + KCC*) + # KAI C++ Compiler + lt_prog_compiler_wl_CXX='--backend -Wl,' + lt_prog_compiler_pic_CXX='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64, which still supported -KPIC. + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-fPIC' + lt_prog_compiler_static_CXX='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-fpic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + xlc* | xlC* | bgxl[cC]* | mpixl[cC]*) + # IBM XL 8.0, 9.0 on PPC and BlueGene + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-qpic' + lt_prog_compiler_static_CXX='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + lt_prog_compiler_wl_CXX='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + lt_prog_compiler_pic_CXX='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd* | netbsdelf*-gnu) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic_CXX='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + lt_prog_compiler_wl_CXX='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + lt_prog_compiler_pic_CXX='-pic' + ;; + cxx*) + # Digital/Compaq C++ + lt_prog_compiler_wl_CXX='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + lt_prog_compiler_wl_CXX='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + lt_prog_compiler_pic_CXX='-pic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + lcc*) + # Lucid + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + lt_prog_compiler_pic_CXX='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + lt_prog_compiler_can_build_shared_CXX=no + ;; + esac + fi + +case $host_os in + # For platforms that do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_CXX= + ;; + *) + lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" + ;; +esac + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +printf %s "checking for $compiler option to produce PIC... " >&6; } +if test ${lt_cv_prog_compiler_pic_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic_CXX" >&6; } +lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_CXX"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 +printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } +if test ${lt_cv_prog_compiler_pic_works_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_pic_works_CXX=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works_CXX=yes + fi + fi + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic_works_CXX" >&6; } + +if test yes = "$lt_cv_prog_compiler_pic_works_CXX"; then + case $lt_prog_compiler_pic_CXX in + "" | " "*) ;; + *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; + esac +else + lt_prog_compiler_pic_CXX= + lt_prog_compiler_can_build_shared_CXX=no +fi + +fi + + + + + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if test ${lt_cv_prog_compiler_static_works_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_static_works_CXX=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works_CXX=yes + fi + else + lt_cv_prog_compiler_static_works_CXX=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 +printf "%s\n" "$lt_cv_prog_compiler_static_works_CXX" >&6; } + +if test yes = "$lt_cv_prog_compiler_static_works_CXX"; then + : +else + lt_prog_compiler_static_CXX= +fi + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test ${lt_cv_prog_compiler_c_o_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_c_o_CXX=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o_CXX=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +printf "%s\n" "$lt_cv_prog_compiler_c_o_CXX" >&6; } + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test ${lt_cv_prog_compiler_c_o_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_c_o_CXX=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o_CXX=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +printf "%s\n" "$lt_cv_prog_compiler_c_o_CXX" >&6; } + + + + +hard_links=nottested +if test no = "$lt_cv_prog_compiler_c_o_CXX" && test no != "$need_locks"; then + # do not overwrite the value of need_locks provided by the user + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +printf %s "checking if we can lock with hard links... " >&6; } + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +printf "%s\n" "$hard_links" >&6; } + if test no = "$hard_links"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + case $host_os in + aix[4-9]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + export_symbols_cmds_CXX=$ltdll_cmds + ;; + cygwin* | mingw* | cegcc*) + case $cc_basename in + cl*) + exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; + *) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' + exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' + ;; + esac + ;; + linux* | k*bsd*-gnu | gnu*) + link_all_deplibs_CXX=no + ;; + *) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 +printf "%s\n" "$ld_shlibs_CXX" >&6; } +test no = "$ld_shlibs_CXX" && can_build_shared=no + +with_gnu_ld_CXX=$with_gnu_ld + + + + + + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_CXX" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_CXX=yes + + if test yes,yes = "$GCC,$enable_shared"; then + case $archive_cmds_CXX in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +printf %s "checking whether -lc should be explicitly linked in... " >&6; } +if test ${lt_cv_archive_cmds_need_lc_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_CXX + pic_flag=$lt_prog_compiler_pic_CXX + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_CXX + allow_undefined_flag_CXX= + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 + (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + then + lt_cv_archive_cmds_need_lc_CXX=no + else + lt_cv_archive_cmds_need_lc_CXX=yes + fi + allow_undefined_flag_CXX=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 +printf "%s\n" "$lt_cv_archive_cmds_need_lc_CXX" >&6; } + archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX + ;; + esac + fi + ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +printf %s "checking dynamic linker characteristics... " >&6; } + +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=.so +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + + + +case $host_os in +aix3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='$libname$release$shared_ext$major' + ;; + +aix[4-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test ia64 = "$host_cpu"; then + # AIX 5 supports IA64 + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a(lib.so.V)' + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='$libname$shared_ext' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + + case $GCC,$cc_basename in + yes,*) + # gcc + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec=$LIB + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' + ;; + + *) + # Assume MSVC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; + esac + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[23].*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2.*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + dynamic_linker="$host_os runtime_loader" + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=no + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 + fi + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 + ;; + +interix[3-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test yes = "$lt_cv_prog_gnu_ld"; then + version_type=linux # correct to gnu/linux during the next big refactor + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + hardcode_libdir_flag_spec_CXX='-L$libdir' + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + + # Some binutils ld are patched to set DT_RUNPATH + if test ${lt_cv_shlibpath_overrides_runpath+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO" +then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null +then : + lt_cv_shlibpath_overrides_runpath=yes +fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + +fi + + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd* | bitrig*) + version_type=sunos + sys_lib_dlsearch_path_spec=/usr/lib + need_lib_prefix=no + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +os2*) + libname_spec='$name' + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test yes = "$with_gnu_ld"; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec; then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=sco + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test yes = "$with_gnu_ld"; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +printf "%s\n" "$dynamic_linker" >&6; } +test no = "$dynamic_linker" && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test yes = "$GCC"; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec +fi + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec +fi + +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +printf %s "checking how to hardcode library paths into programs... " >&6; } +hardcode_action_CXX= +if test -n "$hardcode_libdir_flag_spec_CXX" || + test -n "$runpath_var_CXX" || + test yes = "$hardcode_automatic_CXX"; then + + # We can hardcode non-existent directories. + if test no != "$hardcode_direct_CXX" && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" && + test no != "$hardcode_minus_L_CXX"; then + # Linking always hardcodes the temporary library directory. + hardcode_action_CXX=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_CXX=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_CXX=unsupported +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 +printf "%s\n" "$hardcode_action_CXX" >&6; } + +if test relink = "$hardcode_action_CXX" || + test yes = "$inherit_rpath_CXX"; then + # Fast installation is not supported + enable_fast_install=no +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + + + + + + + fi # test -n "$compiler" + + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test yes != "$_lt_caught_CXX_error" + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +case $host in + *mingw*) + LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static" + ;; +esac + +BUILD_EXEEXT= +case $build in + *mingw*) + BUILD_EXEEXT=".exe" + ;; +esac + +ac_config_files="$ac_config_files Makefile pc/libunivalue.pc pc/libunivalue-uninstalled.pc" + + + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +printf "%s\n" "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 +printf %s "checking that generated files are newer than configure... " >&6; } + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: done" >&5 +printf "%s\n" "done" >&6; } + if test -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= +fi + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + as_fn_error $? "conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +as_nop=: +if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 +then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else $as_nop + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + + +# Reset variables that may have inherited troublesome values from +# the environment. + +# IFS needs to be set, to space, tab, and newline, in precisely that order. +# (If _AS_PATH_WALK were called with IFS unset, it would have the +# side effect of setting IFS to empty, thus disabling word splitting.) +# Quoting is to prevent editors from complaining about space-tab. +as_nl=' +' +export as_nl +IFS=" "" $as_nl" + +PS1='$ ' +PS2='> ' +PS4='+ ' + +# Ensure predictable behavior from utilities with locale-dependent output. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# We cannot yet rely on "unset" to work, but we need these variables +# to be unset--not just set to an empty or harmless value--now, to +# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct +# also avoids known problems related to "unset" and subshell syntax +# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). +for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH +do eval test \${$as_var+y} \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done + +# Ensure that fds 0, 1, and 2 are open. +if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi +if (exec 3>&2) ; then :; else exec 2>/dev/null; fi + +# The user is always right. +if ${PATH_SEPARATOR+false} :; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + test -r "$as_dir$0" && as_myself=$as_dir$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + printf "%s\n" "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null +then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else $as_nop + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null +then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else $as_nop + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + +# Determine whether it's possible to make 'echo' print without a newline. +# These variables are no longer used directly by Autoconf, but are AC_SUBSTed +# for compatibility with existing Makefiles. +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +# For backward compatibility with old third-party macros, we provide +# the shell variables $as_echo and $as_echo_n. New code should use +# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. +as_echo='printf %s\n' +as_echo_n='printf %s' + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by univalue $as_me 1.0.3, which was +generated by GNU Autoconf 2.71. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." + +_ACEOF +ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` +ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config='$ac_cs_config_escaped' +ac_cs_version="\\ +univalue config.status 1.0.3 +configured by $0, generated by GNU Autoconf 2.71, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2021 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + printf "%s\n" "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + printf "%s\n" "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + printf "%s\n" "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + printf "%s\n" "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" + + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' +macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' +enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' +enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' +pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' +enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' +shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' +SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' +ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' +PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' +host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' +host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' +host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' +build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' +build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' +build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' +SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' +Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' +GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' +EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' +FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' +LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' +NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' +LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' +max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' +ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' +exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' +lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' +lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' +lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' +lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' +lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' +reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' +reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' +OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' +deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' +file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' +file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' +want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' +DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' +sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' +AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' +AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' +archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' +STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' +RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' +old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' +old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' +lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' +CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' +CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' +compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' +GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' +lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' +nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' +lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' +lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' +objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' +MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' +need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' +MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' +DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' +NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' +LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' +OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' +OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' +libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' +shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' +extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' +export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' +whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' +compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' +old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' +archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' +module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' +module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' +with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' +allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' +no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' +hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' +hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' +hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' +hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' +hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' +inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' +link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' +always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' +export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' +exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' +include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' +prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' +postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' +file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' +variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' +need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' +need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' +version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' +runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' +libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' +library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' +soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' +install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' +postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' +postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' +finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' +hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' +sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' +configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' +configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' +hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' +enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' +old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' +striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' +compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`' +predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`' +postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`' +predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`' +postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`' +compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`' +LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`' +reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`' +reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`' +old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' +compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`' +GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`' +archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`' +export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' +whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' +compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`' +old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`' +archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' +archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' +module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`' +module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' +with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`' +allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' +no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`' +hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`' +hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`' +hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`' +hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`' +hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`' +inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`' +link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`' +always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`' +export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`' +exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`' +include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`' +prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`' +postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`' +file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`' +hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`' +compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`' +predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`' +postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`' +predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`' +postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`' +compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`' + +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in SHELL \ +ECHO \ +PATH_SEPARATOR \ +SED \ +GREP \ +EGREP \ +FGREP \ +LD \ +NM \ +LN_S \ +lt_SP2NL \ +lt_NL2SP \ +reload_flag \ +OBJDUMP \ +deplibs_check_method \ +file_magic_cmd \ +file_magic_glob \ +want_nocaseglob \ +DLLTOOL \ +sharedlib_from_linklib_cmd \ +AR \ +AR_FLAGS \ +archiver_list_spec \ +STRIP \ +RANLIB \ +CC \ +CFLAGS \ +compiler \ +lt_cv_sys_global_symbol_pipe \ +lt_cv_sys_global_symbol_to_cdecl \ +lt_cv_sys_global_symbol_to_import \ +lt_cv_sys_global_symbol_to_c_name_address \ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ +lt_cv_nm_interface \ +nm_file_list_spec \ +lt_cv_truncate_bin \ +lt_prog_compiler_no_builtin_flag \ +lt_prog_compiler_pic \ +lt_prog_compiler_wl \ +lt_prog_compiler_static \ +lt_cv_prog_compiler_c_o \ +need_locks \ +MANIFEST_TOOL \ +DSYMUTIL \ +NMEDIT \ +LIPO \ +OTOOL \ +OTOOL64 \ +shrext_cmds \ +export_dynamic_flag_spec \ +whole_archive_flag_spec \ +compiler_needs_object \ +with_gnu_ld \ +allow_undefined_flag \ +no_undefined_flag \ +hardcode_libdir_flag_spec \ +hardcode_libdir_separator \ +exclude_expsyms \ +include_expsyms \ +file_list_spec \ +variables_saved_for_relink \ +libname_spec \ +library_names_spec \ +soname_spec \ +install_override_mode \ +finish_eval \ +old_striplib \ +striplib \ +compiler_lib_search_dirs \ +predep_objects \ +postdep_objects \ +predeps \ +postdeps \ +compiler_lib_search_path \ +LD_CXX \ +reload_flag_CXX \ +compiler_CXX \ +lt_prog_compiler_no_builtin_flag_CXX \ +lt_prog_compiler_pic_CXX \ +lt_prog_compiler_wl_CXX \ +lt_prog_compiler_static_CXX \ +lt_cv_prog_compiler_c_o_CXX \ +export_dynamic_flag_spec_CXX \ +whole_archive_flag_spec_CXX \ +compiler_needs_object_CXX \ +with_gnu_ld_CXX \ +allow_undefined_flag_CXX \ +no_undefined_flag_CXX \ +hardcode_libdir_flag_spec_CXX \ +hardcode_libdir_separator_CXX \ +exclude_expsyms_CXX \ +include_expsyms_CXX \ +file_list_spec_CXX \ +compiler_lib_search_dirs_CXX \ +predep_objects_CXX \ +postdep_objects_CXX \ +predeps_CXX \ +postdeps_CXX \ +compiler_lib_search_path_CXX; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in reload_cmds \ +old_postinstall_cmds \ +old_postuninstall_cmds \ +old_archive_cmds \ +extract_expsyms_cmds \ +old_archive_from_new_cmds \ +old_archive_from_expsyms_cmds \ +archive_cmds \ +archive_expsym_cmds \ +module_cmds \ +module_expsym_cmds \ +export_symbols_cmds \ +prelink_cmds \ +postlink_cmds \ +postinstall_cmds \ +postuninstall_cmds \ +finish_cmds \ +sys_lib_search_path_spec \ +configure_time_dlsearch_path \ +configure_time_lt_sys_library_path \ +reload_cmds_CXX \ +old_archive_cmds_CXX \ +old_archive_from_new_cmds_CXX \ +old_archive_from_expsyms_cmds_CXX \ +archive_cmds_CXX \ +archive_expsym_cmds_CXX \ +module_cmds_CXX \ +module_expsym_cmds_CXX \ +export_symbols_cmds_CXX \ +prelink_cmds_CXX \ +postlink_cmds_CXX; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +ac_aux_dir='$ac_aux_dir' + +# See if we are running on zsh, and set the options that allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + + + PACKAGE='$PACKAGE' + VERSION='$VERSION' + RM='$RM' + ofile='$ofile' + + + + + + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "univalue-config.h") CONFIG_HEADERS="$CONFIG_HEADERS univalue-config.h" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "pc/libunivalue.pc") CONFIG_FILES="$CONFIG_FILES pc/libunivalue.pc" ;; + "pc/libunivalue-uninstalled.pc") CONFIG_FILES="$CONFIG_FILES pc/libunivalue-uninstalled.pc" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files + test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers + test ${CONFIG_COMMANDS+y} || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +printf "%s\n" "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`printf "%s\n" "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + printf "%s\n" "/* $configure_input */" >&1 \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + printf "%s\n" "/* $configure_input */" >&1 \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +printf "%s\n" "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Older Autoconf quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + case $CONFIG_FILES in #( + *\'*) : + eval set x "$CONFIG_FILES" ;; #( + *) : + set x $CONFIG_FILES ;; #( + *) : + ;; +esac + shift + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf + do + # Strip MF so we end up with the name of the file. + am_mf=`printf "%s\n" "$am_mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`$as_dirname -- "$am_mf" || +$as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$am_mf" : 'X\(//\)[^/]' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$am_mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + am_filepart=`$as_basename -- "$am_mf" || +$as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X/"$am_mf" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { echo "$as_me:$LINENO: cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles" >&5 + (cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } || am_rc=$? + done + if test $am_rc -ne 0; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE=\"gmake\" (or whatever is + necessary). You can also try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking). +See \`config.log' for more details" "$LINENO" 5; } + fi + { am_dirpart=; unset am_dirpart;} + { am_filepart=; unset am_filepart;} + { am_mf=; unset am_mf;} + { am_rc=; unset am_rc;} + rm -f conftest-deps.mk +} + ;; + "libtool":C) + + # See if we are running on zsh, and set the options that allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST + fi + + cfgfile=${ofile}T + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL +# Generated automatically by $as_me ($PACKAGE) $VERSION +# NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool 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 2 of of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. +# +# GNU Libtool 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 . + + +# The names of the tagged configurations supported by this script. +available_tags='CXX ' + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} + +# ### BEGIN LIBTOOL CONFIG + +# Which release of libtool.m4 was used? +macro_version=$macro_version +macro_revision=$macro_revision + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# What type of objects to build. +pic_mode=$pic_mode + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# Shared archive member basename,for filename based shared library versioning on AIX. +shared_archive_member_spec=$shared_archive_member_spec + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# An echo program that protects backslashes. +ECHO=$lt_ECHO + +# The PATH separator for the build system. +PATH_SEPARATOR=$lt_PATH_SEPARATOR + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="\$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP=$lt_GREP + +# An ERE matcher. +EGREP=$lt_EGREP + +# A literal string matcher. +FGREP=$lt_FGREP + +# A BSD- or MS-compatible name lister. +NM=$lt_NM + +# Whether we need soft or hard links. +LN_S=$lt_LN_S + +# What is the maximum length of a command? +max_cmd_len=$max_cmd_len + +# Object file suffix (normally "o"). +objext=$ac_objext + +# Executable file suffix (normally ""). +exeext=$exeext + +# whether the shell understands "unset". +lt_unset=$lt_unset + +# turn spaces into newlines. +SP2NL=$lt_lt_SP2NL + +# turn newlines into spaces. +NL2SP=$lt_lt_NL2SP + +# convert \$build file names to \$host format. +to_host_file_cmd=$lt_cv_to_host_file_cmd + +# convert \$build files to toolchain format. +to_tool_file_cmd=$lt_cv_to_tool_file_cmd + +# An object symbol dumper. +OBJDUMP=$lt_OBJDUMP + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method = "file_magic". +file_magic_cmd=$lt_file_magic_cmd + +# How to find potential files when deplibs_check_method = "file_magic". +file_magic_glob=$lt_file_magic_glob + +# Find potential files using nocaseglob when deplibs_check_method = "file_magic". +want_nocaseglob=$lt_want_nocaseglob + +# DLL creation program. +DLLTOOL=$lt_DLLTOOL + +# Command to associate shared and link libraries. +sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd + +# The archiver. +AR=$lt_AR + +# Flags to create an archive. +AR_FLAGS=$lt_AR_FLAGS + +# How to feed a file listing to the archiver. +archiver_list_spec=$lt_archiver_list_spec + +# A symbol stripping program. +STRIP=$lt_STRIP + +# Commands used to install an old-style archive. +RANLIB=$lt_RANLIB +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Whether to use a lock for old archive extraction. +lock_old_archive_extraction=$lock_old_archive_extraction + +# A C compiler. +LTCC=$lt_CC + +# LTCC compiler flags. +LTCFLAGS=$lt_CFLAGS + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm into a list of symbols to manually relocate. +global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix + +# The name lister interface. +nm_interface=$lt_lt_cv_nm_interface + +# Specify filename containing input files for \$NM. +nm_file_list_spec=$lt_nm_file_list_spec + +# The root where to search for dependent libraries,and where our libraries should be installed. +lt_sysroot=$lt_sysroot + +# Command to truncate a binary pipe. +lt_truncate_bin=$lt_lt_cv_truncate_bin + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=$MAGIC_CMD + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Manifest tool. +MANIFEST_TOOL=$lt_MANIFEST_TOOL + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL=$lt_DSYMUTIL + +# Tool to change global to local symbols on Mac OS X. +NMEDIT=$lt_NMEDIT + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO=$lt_LIPO + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL=$lt_OTOOL + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64=$lt_OTOOL64 + +# Old archive suffix (normally "a"). +libext=$libext + +# Shared library suffix (normally ".so"). +shrext_cmds=$lt_shrext_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink=$lt_variables_saved_for_relink + +# Do we need the "lib" prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Library versioning type. +version_type=$version_type + +# Shared library runtime path variable. +runpath_var=$runpath_var + +# Shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Permission mode override for installation of shared libraries. +install_override_mode=$lt_install_override_mode + +# Command to use after installation of a shared archive. +postinstall_cmds=$lt_postinstall_cmds + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval=$lt_finish_eval + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Compile-time system search path for libraries. +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Detected run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path + +# Explicit LT_SYS_LIBRARY_PATH set during ./configure time. +configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + + +# The linker used to build libraries. +LD=$lt_LD + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds + +# A language specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU compiler? +with_gcc=$GCC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \$shlibpath_var if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds + +# Commands necessary for finishing linking programs. +postlink_cmds=$lt_postlink_cmds + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# The directories searched by this compiler when creating a shared library. +compiler_lib_search_dirs=$lt_compiler_lib_search_dirs + +# Dependencies to place before and after the objects being linked to +# create a shared library. +predep_objects=$lt_predep_objects +postdep_objects=$lt_postdep_objects +predeps=$lt_predeps +postdeps=$lt_postdeps + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path + +# ### END LIBTOOL CONFIG + +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + + +# ### END FUNCTIONS SHARED WITH CONFIGURE + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + + +ltmain=$ac_aux_dir/ltmain.sh + + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + + + cat <<_LT_EOF >> "$ofile" + +# ### BEGIN LIBTOOL TAG CONFIG: CXX + +# The linker used to build libraries. +LD=$lt_LD_CXX + +# How to create reloadable object files. +reload_flag=$lt_reload_flag_CXX +reload_cmds=$lt_reload_cmds_CXX + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds_CXX + +# A language specific compiler. +CC=$lt_compiler_CXX + +# Is the compiler the GNU compiler? +with_gcc=$GCC_CXX + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_CXX + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_CXX + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_CXX + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_CXX + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object_CXX + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds_CXX +archive_expsym_cmds=$lt_archive_expsym_cmds_CXX + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds_CXX +module_expsym_cmds=$lt_module_expsym_cmds_CXX + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld_CXX + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_CXX + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_CXX + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct_CXX + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \$shlibpath_var if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute_CXX + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L_CXX + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic_CXX + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath_CXX + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_CXX + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols_CXX + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_CXX + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_CXX + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_CXX + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds_CXX + +# Commands necessary for finishing linking programs. +postlink_cmds=$lt_postlink_cmds_CXX + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec_CXX + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_CXX + +# The directories searched by this compiler when creating a shared library. +compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX + +# Dependencies to place before and after the objects being linked to +# create a shared library. +predep_objects=$lt_predep_objects_CXX +postdep_objects=$lt_postdep_objects_CXX +predeps=$lt_predeps_CXX +postdeps=$lt_postdeps_CXX + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_CXX + +# ### END LIBTOOL TAG CONFIG: CXX +_LT_EOF + + ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + + + diff --git a/src/util.cpp b/src/util.cpp index ef633dba8..336f2f0c4 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -369,7 +369,7 @@ void ParseParameters(int argc, const char* const argv[]) } // New 0.6 features: - for (const PAIRTYPE(string,string)& entry : mapArgs) + for (const std::pair& entry : mapArgs) { // interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set InterpretNegativeSetting(entry.first, mapArgs); diff --git a/src/utilstrencodings.h b/src/utilstrencodings.h index ce2ca034e..3b005177b 100644 --- a/src/utilstrencodings.h +++ b/src/utilstrencodings.h @@ -19,9 +19,6 @@ #define UEND(a) ((unsigned char*)&((&(a))[1])) #define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0])) -/** This is needed because the foreach macro can't get over the comma in pair */ -#define PAIRTYPE(t1, t2) std::pair - /** Used by SanitizeString() */ enum SafeChars { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b57376a19..c62e86dc8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -103,7 +103,7 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) entry.push_back(Pair("walletconflicts", conflicts)); entry.push_back(Pair("time", wtx.GetTxTime())); entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived)); - for (const PAIRTYPE(string,string)& item : wtx.mapValue) + for (const std::pair& item : wtx.mapValue) entry.push_back(Pair(item.first, item.second)); entry.push_back(Pair("vJoinSplit", TxJoinSplitToJSON(wtx))); @@ -1578,7 +1578,7 @@ UniValue listaccounts(const UniValue& params, bool fHelp) includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY; map mapAccountBalances; - for (const PAIRTYPE(CTxDestination, CAddressBookData)& entry : pwalletMain->mapAddressBook) { + for (const std::pair& entry : pwalletMain->mapAddressBook) { if (IsMine(*pwalletMain, entry.first) & includeWatchonly) // This address belongs to me mapAccountBalances[entry.second.name] = 0; } @@ -1613,7 +1613,7 @@ UniValue listaccounts(const UniValue& params, bool fHelp) mapAccountBalances[entry.strAccount] += entry.nCreditDebit; UniValue ret(UniValue::VOBJ); - for (const PAIRTYPE(string, CAmount)& accountBalance : mapAccountBalances) { + for (const std::pair& accountBalance : mapAccountBalances) { ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); } return ret; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 31b184c15..1390a2c44 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1387,7 +1387,7 @@ void CWallet::MarkDirty() { { LOCK(cs_wallet); - for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) + for (std::pair& item : mapWallet) item.second.MarkDirty(); } } @@ -2685,7 +2685,7 @@ void CWallet::ReacceptWalletTransactions() std::map mapSorted; // Sort pending wallet transactions based on their initial wallet insertion order - for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) + for (std::pair& item : mapWallet) { const uint256& wtxid = item.first; CWalletTx& wtx = item.second; @@ -2699,7 +2699,7 @@ void CWallet::ReacceptWalletTransactions() } // Try to add wallet transactions to memory pool - for (PAIRTYPE(const int64_t, CWalletTx*)& item : mapSorted) + for (std::pair& item : mapSorted) { CWalletTx& wtx = *(item.second); @@ -2928,7 +2928,7 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime) LOCK(cs_wallet); // Sort them in chronological order multimap mapSorted; - for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) + for (std::pair& item : mapWallet) { CWalletTx& wtx = item.second; // Don't rebroadcast if newer than nTime: @@ -2936,7 +2936,7 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime) continue; mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx)); } - for (PAIRTYPE(const unsigned int, CWalletTx*)& item : mapSorted) + for (std::pair& item : mapSorted) { CWalletTx& wtx = *item.second; if (wtx.RelayWalletTransaction()) @@ -3523,7 +3523,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt } return false; } - for (PAIRTYPE(const CWalletTx*, unsigned int) pcoin : setCoins) + for (std::pair pcoin : setCoins) { CAmount nCredit = pcoin.first->vout[pcoin.second].nValue; //The coin age after the next block (depth+1) is used instead of the current, @@ -3616,7 +3616,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt // // Note how the sequence number is set to max()-1 so that the // nLockTime set above actually works. - for (const PAIRTYPE(const CWalletTx*,unsigned int)& coin : setCoins) + for (const std::pair& coin : setCoins) txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(), std::numeric_limits::max()-1)); @@ -3642,7 +3642,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt // Sign int nIn = 0; CTransaction txNewConst(txNew); - for (const PAIRTYPE(const CWalletTx*,unsigned int)& coin : setCoins) + for (const std::pair& coin : setCoins) { bool signSuccess; const CScript& scriptPubKey = coin.first->vout[coin.second].scriptPubKey; @@ -3881,7 +3881,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address) { // Delete destdata tuples associated with address std::string strAddress = EncodeDestination(address); - for (const PAIRTYPE(string, string) &item : mapAddressBook[address].destdata) + for (const std::pair &item : mapAddressBook[address].destdata) { CWalletDB(strWalletFile).EraseDestData(strAddress, item.first); } @@ -4051,7 +4051,7 @@ std::map CWallet::GetAddressBalances() { LOCK(cs_wallet); - for (PAIRTYPE(uint256, CWalletTx) walletEntry : mapWallet) + for (std::pair walletEntry : mapWallet) { CWalletTx *pcoin = &walletEntry.second; @@ -4091,7 +4091,7 @@ set< set > CWallet::GetAddressGroupings() set< set > groupings; set grouping; - for (PAIRTYPE(uint256, CWalletTx) walletEntry : mapWallet) + for (std::pair walletEntry : mapWallet) { CWalletTx *pcoin = &walletEntry.second; @@ -4182,7 +4182,7 @@ std::set CWallet::GetAccountAddresses(const std::string& strAcco { LOCK(cs_wallet); set result; - for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : mapAddressBook) + for (const std::pair& item : mapAddressBook) { const CTxDestination& address = item.first; const string& strName = item.second.name; From e339f2c07c08927d4cffc651947370e6db3d1577 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Fri, 12 Jul 2024 23:36:19 +0000 Subject: [PATCH 009/162] fix: fetch-params.sh --- zcutil/fetch-params.sh | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/zcutil/fetch-params.sh b/zcutil/fetch-params.sh index 243723dc7..5a7520a5e 100755 --- a/zcutil/fetch-params.sh +++ b/zcutil/fetch-params.sh @@ -13,8 +13,7 @@ SPROUT_VKEY_NAME='sprout-verifying.key' SAPLING_SPEND_NAME='sapling-spend.params' SAPLING_OUTPUT_NAME='sapling-output.params' SAPLING_SPROUT_GROTH16_NAME='sprout-groth16.params' -SPROUT_URL="https://d.btcz.rocks" -SPROUT_IPFS="/ipfs/QmZKKx7Xup7LiAtFRhYsE1M7waXcv9ir9eCECyXAFGxhEo" +SPROUT_URL="https://verus.io/zcparams" SHA256CMD="$(command -v sha256sum || echo shasum)" SHA256ARGS="$(command -v sha256sum >/dev/null || echo '-a 256')" @@ -99,21 +98,6 @@ EOF } } -function fetch_ipfs { - if [ -z "$IPFSCMD" ] || ! [ -z "$ZC_DISABLE_IPFS" ]; then - return 1 - fi - - local filename="$1" - local dlname="$2" - - cat < Date: Fri, 12 Jul 2024 23:37:47 +0000 Subject: [PATCH 010/162] fix: Community Fee Period nHeight > GetCommunityFeeStartHeight() && nHeight <= GetLastCommunityFeeBlockHeight() --- src/chainparams.cpp | 2 +- src/consensus/params.cpp | 26 -------------------------- src/consensus/params.h | 2 -- src/gtest/test_foundersreward.cpp | 1 - src/main.cpp | 2 +- src/metrics.cpp | 2 +- src/miner.cpp | 4 ++-- src/rpc/mining.cpp | 5 ++--- 8 files changed, 7 insertions(+), 37 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 6dfd29373..47a17a07b 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -848,7 +848,7 @@ bool SelectParamsFromCommandLine() return true; } -// Block height must be >0 and <=last founders reward block height // Block height must be >0 and <=last founders reward block height +// Block height must be >0 and <=last founders reward block height // Index variable i ranges from 0 - (vCommunityFeeAddress.size()-1) std::string CChainParams::GetCommunityFeeAddressAtHeight(int nHeight) const { int preBlossomMaxHeight = GetLastCommunityFeeBlockHeight(); diff --git a/src/consensus/params.cpp b/src/consensus/params.cpp index 2974930b3..647dd175c 100644 --- a/src/consensus/params.cpp +++ b/src/consensus/params.cpp @@ -33,32 +33,6 @@ namespace Consensus { } } - int Params::GetLastCommunityFeeBlockHeight(int nHeight) const { - // zip208 - // CommunityFeeLastBlockHeight := max({ height ⦂ N | Halving(height) < 1 }) - // Halving(h) is defined as floor(f(h)) where f is a strictly increasing rational - // function, so it's sufficient to solve for f(height) = 1 in the rationals and - // then take ceiling(height - 1). - // H := blossom activation height; SS := SubsidySlowStartShift(); R := BLOSSOM_POW_TARGET_SPACING_RATIO - // preBlossom: - // 1 = (height - SS) / preInterval - // height = preInterval + SS - // postBlossom: - // 1 = (H - SS) / preInterval + (height - H) / postInterval - // height = H + postInterval - (H - SS) * (postInterval / preInterval) - // height = H + postInterval - (H - SS) * R - // Note: This depends on R being an integer - bool blossomActive = NetworkUpgradeActive(nHeight, Consensus::UPGRADE_BLOSSOM); - if (blossomActive) { - int blossomActivationHeight = vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight; - // The following calculation depends on BLOSSOM_POW_TARGET_SPACING_RATIO being an integer. - return blossomActivationHeight + nPostBlossomSubsidyHalvingInterval - - (blossomActivationHeight - SubsidySlowStartShift()) * BLOSSOM_POW_TARGET_SPACING_RATIO - 1; - } else { - return nPreBlossomSubsidyHalvingInterval + SubsidySlowStartShift() - 1; - } - } - int64_t Params::PoWTargetSpacing(int nHeight) const { // zip208 // PoWTargetSpacing(height) := diff --git a/src/consensus/params.h b/src/consensus/params.h index b34d3b72b..622c4835a 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -107,8 +107,6 @@ struct Params { int Halving(int nHeight) const; - int GetLastCommunityFeeBlockHeight(int nHeight) const; - /** Used to check majorities for block version upgrade */ int nMajorityEnforceBlockUpgrade; int nMajorityRejectBlockOutdated; diff --git a/src/gtest/test_foundersreward.cpp b/src/gtest/test_foundersreward.cpp index a497cff52..e97055093 100644 --- a/src/gtest/test_foundersreward.cpp +++ b/src/gtest/test_foundersreward.cpp @@ -86,7 +86,6 @@ TEST(founders_reward_test, create_testnet_2of3multisig) { static int GetLastCommunityFeeHeight(const Consensus::Params& params) { int blossomActivationHeight = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight; bool blossom = blossomActivationHeight != Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; - //return params.GetLastCommunityFeeBlockHeight(blossom ? blossomActivationHeight : 0); return Params().GetLastCommunityFeeBlockHeight(); } diff --git a/src/main.cpp b/src/main.cpp index c60143492..bdd4b0761 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4009,7 +4009,7 @@ bool ContextualCheckBlock( // Coinbase transaction must include an output sending 5% of the block // reward to a community fee script. - if (nHeight >= Params().GetCommunityFeeStartHeight()) { + if ((nHeight > Params().GetCommunityFeeStartHeight()) && (nHeight <= Params().GetLastCommunityFeeBlockHeight())) { bool found = false; for (const CTxOut& output : block.vtx[0].vout) { if (output.scriptPubKey == chainparams.GetCommunityFeeScriptAtHeight(nHeight)) { diff --git a/src/metrics.cpp b/src/metrics.cpp index 05a6472fb..fdd08ec7e 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -331,7 +331,7 @@ int printMetrics(size_t cols, bool mining) chainActive.Contains(mapBlockIndex[hash])) { int height = mapBlockIndex[hash]->nHeight; CAmount subsidy = GetBlockSubsidy(height, consensusParams); - if (height >= Params().GetCommunityFeeStartHeight()) { + if ((height > Params().GetCommunityFeeStartHeight()) && (height <= Params().GetLastCommunityFeeBlockHeight())) { subsidy -= (subsidy * 0.05); } if (std::max(0, COINBASE_MATURITY - (tipHeight - height)) > 0) { diff --git a/src/miner.cpp b/src/miner.cpp index 763eecdbf..5f6cf4b6a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -405,12 +405,12 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s // Set to 0 so expiry height does not apply to coinbase txs txNew.nExpiryHeight = 0; - if (nHeight >= chainparams.GetCommunityFeeStartHeight()) { + if ((nHeight > chainparams.GetCommunityFeeStartHeight()) && (nHeight <= chainparams.GetLastCommunityFeeBlockHeight())) { // Community Fee is 5% of the block subsidy auto vCommunityFee = txNew.vout[0].nValue * 0.05; // Take some reward away from us txNew.vout[0].nValue -= vCommunityFee; - // And give it to the community + // And give it to the community txNew.vout.push_back(CTxOut(vCommunityFee, chainparams.GetCommunityFeeScriptAtHeight(nHeight))); } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index c6b9a99ae..8debe91f3 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -902,13 +902,12 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp) LOCK(cs_main); int nHeight = (params.size()==1) ? params[0].get_int() : chainActive.Height(); - int nextBlockHeight = nHeight + 1; if (nHeight < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - CAmount nReward = GetBlockSubsidy(nextBlockHeight, Params().GetConsensus()); + CAmount nReward = GetBlockSubsidy(nHeight, Params().GetConsensus()); CAmount nCommunityFee = 0; - if (nextBlockHeight >= Params().GetCommunityFeeStartHeight()) { + if ((nHeight > Params().GetCommunityFeeStartHeight()) && (nHeight <= Params().GetLastCommunityFeeBlockHeight())) { nCommunityFee = nReward * 0.05; nReward -= nCommunityFee; } From 2a58853f281c524d3edc10e90578ea54a04f2376 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Sat, 13 Jul 2024 11:58:57 +0000 Subject: [PATCH 011/162] Remove libsnark --- build-aux/m4/ax_compiler_vendor.m4 | 117 -- build-aux/m4/ax_gcc_archflag.m4 | 267 --- build-aux/m4/ax_gcc_x86_cpuid.m4 | 89 - build-aux/m4/ax_openmp.m4 | 123 -- configure.ac | 37 +- contrib/debian/copyright | 8 - depends/packages/libgmp.mk | 18 - depends/packages/packages.mk | 2 +- qa/bitcoinz/full_test_suite.py | 2 - qa/pull-tester/rpc-tests.sh | 1 - qa/rpc-tests/bip65-cltv-p2p.py | 7 +- qa/rpc-tests/bipdersig-p2p.py | 7 +- qa/rpc-tests/finalsaplingroot.py | 3 - qa/rpc-tests/fundrawtransaction.py | 4 +- qa/rpc-tests/mempool_nu_activation.py | 98 +- qa/rpc-tests/mempool_tx_expiry.py | 24 +- qa/rpc-tests/mempool_tx_input_limit.py | 139 -- qa/rpc-tests/mergetoaddress_helper.py | 17 +- qa/rpc-tests/mergetoaddress_mixednotes.py | 2 - qa/rpc-tests/mergetoaddress_sapling.py | 7 +- qa/rpc-tests/mergetoaddress_sprout.py | 4 +- qa/rpc-tests/p2p_node_bloom.py | 14 +- qa/rpc-tests/p2p_txexpiringsoon.py | 11 +- qa/rpc-tests/p2p_txexpiry_dos.py | 13 +- qa/rpc-tests/rawtransactions.py | 2 +- qa/rpc-tests/regtest_signrawtransaction.py | 10 +- qa/rpc-tests/rewind_index.py | 12 +- qa/rpc-tests/signrawtransaction_offline.py | 8 +- qa/rpc-tests/sprout_sapling_migration.py | 7 +- qa/rpc-tests/test_framework/blocktools.py | 4 +- qa/rpc-tests/test_framework/mininode.py | 201 +- qa/rpc-tests/test_framework/util.py | 8 + qa/rpc-tests/turnstile.py | 7 +- qa/rpc-tests/wallet.py | 45 +- qa/rpc-tests/wallet_addresses.py | 40 +- qa/rpc-tests/wallet_listnotes.py | 28 +- qa/rpc-tests/wallet_listreceived.py | 8 +- qa/rpc-tests/wallet_overwintertx.py | 87 +- qa/rpc-tests/wallet_persistence.py | 12 +- qa/rpc-tests/wallet_sapling.py | 48 - qa/rpc-tests/wallet_shieldcoinbase.py | 32 +- src/Makefile.am | 34 +- src/Makefile.gtest.include | 4 +- src/Makefile.test.include | 4 +- src/consensus/params.h | 12 + src/gtest/main.cpp | 10 +- src/gtest/test_checktransaction.cpp | 1 - src/gtest/test_circuit.cpp | 183 -- src/gtest/test_joinsplit.cpp | 61 +- src/gtest/test_merkletree.cpp | 64 +- src/gtest/test_proofs.cpp | 702 ------- src/gtest/test_transaction.cpp | 3 - src/init.cpp | 32 +- src/main.cpp | 59 +- src/primitives/transaction.cpp | 19 +- src/primitives/transaction.h | 2 - src/snark/.gitignore | 51 - src/snark/AUTHORS | 19 - src/snark/LICENSE | 24 - src/snark/Makefile | 285 --- src/snark/README.md | 628 ------ src/snark/doxygen.conf | 1807 ----------------- .../algebra/curves/alt_bn128/alt_bn128_g1.cpp | 524 ----- .../algebra/curves/alt_bn128/alt_bn128_g1.hpp | 95 - .../algebra/curves/alt_bn128/alt_bn128_g2.cpp | 505 ----- .../algebra/curves/alt_bn128/alt_bn128_g2.hpp | 96 - .../curves/alt_bn128/alt_bn128_init.cpp | 273 --- .../curves/alt_bn128/alt_bn128_init.hpp | 57 - .../curves/alt_bn128/alt_bn128_pairing.cpp | 547 ----- .../curves/alt_bn128/alt_bn128_pairing.hpp | 92 - .../algebra/curves/alt_bn128/alt_bn128_pp.cpp | 58 - .../algebra/curves/alt_bn128/alt_bn128_pp.hpp | 50 - .../libsnark/algebra/curves/curve_utils.hpp | 22 - .../libsnark/algebra/curves/curve_utils.tcc | 37 - .../libsnark/algebra/curves/public_params.hpp | 103 - .../algebra/curves/tests/test_bilinearity.cpp | 121 -- .../algebra/curves/tests/test_groups.cpp | 153 -- .../domains/basic_radix2_domain.hpp | 45 - .../domains/basic_radix2_domain.tcc | 112 - .../domains/basic_radix2_domain_aux.hpp | 48 - .../domains/basic_radix2_domain_aux.tcc | 242 --- .../evaluation_domain/evaluation_domain.hpp | 125 -- .../evaluation_domain/evaluation_domain.tcc | 117 -- .../algebra/exponentiation/exponentiation.hpp | 31 - .../algebra/exponentiation/exponentiation.tcc | 53 - src/snark/libsnark/algebra/fields/bigint.hpp | 70 - src/snark/libsnark/algebra/fields/bigint.tcc | 279 --- .../libsnark/algebra/fields/field_utils.hpp | 51 - .../libsnark/algebra/fields/field_utils.tcc | 183 -- src/snark/libsnark/algebra/fields/fp.hpp | 182 -- src/snark/libsnark/algebra/fields/fp.tcc | 790 ------- .../algebra/fields/fp12_2over3over2.hpp | 116 -- .../algebra/fields/fp12_2over3over2.tcc | 412 ---- src/snark/libsnark/algebra/fields/fp2.hpp | 120 -- src/snark/libsnark/algebra/fields/fp2.tcc | 261 --- .../libsnark/algebra/fields/fp6_3over2.hpp | 104 - .../libsnark/algebra/fields/fp6_3over2.tcc | 216 -- src/snark/libsnark/algebra/fields/fp_aux.tcc | 389 ---- .../algebra/fields/tests/test_bigint.cpp | 96 - .../algebra/fields/tests/test_fields.cpp | 191 -- .../knowledge_commitment.hpp | 84 - .../knowledge_commitment.tcc | 111 - .../scalar_multiplication/kc_multiexp.hpp | 55 - .../scalar_multiplication/kc_multiexp.tcc | 274 --- .../scalar_multiplication/multiexp.hpp | 110 - .../scalar_multiplication/multiexp.tcc | 590 ------ .../algebra/scalar_multiplication/wnaf.hpp | 39 - .../algebra/scalar_multiplication/wnaf.tcc | 123 -- src/snark/libsnark/common/assert_except.hpp | 12 - .../data_structures/accumulation_vector.hpp | 74 - .../data_structures/accumulation_vector.tcc | 84 - .../common/data_structures/merkle_tree.hpp | 71 - .../common/data_structures/merkle_tree.tcc | 246 --- .../common/data_structures/sparse_vector.hpp | 79 - .../common/data_structures/sparse_vector.tcc | 316 --- .../libsnark/common/default_types/ec_pp.hpp | 53 - .../default_types/r1cs_ppzksnark_pp.hpp | 22 - src/snark/libsnark/common/profiling.cpp | 382 ---- src/snark/libsnark/common/profiling.hpp | 51 - src/snark/libsnark/common/serialization.hpp | 104 - src/snark/libsnark/common/serialization.tcc | 180 -- src/snark/libsnark/common/template_utils.hpp | 26 - src/snark/libsnark/common/utils.cpp | 102 - src/snark/libsnark/common/utils.hpp | 57 - src/snark/libsnark/common/utils.tcc | 23 - .../gadgetlib1/constraint_profiling.cpp | 48 - .../gadgetlib1/constraint_profiling.hpp | 42 - .../gadgetlib1/examples/simple_example.hpp | 23 - .../gadgetlib1/examples/simple_example.tcc | 54 - src/snark/libsnark/gadgetlib1/gadget.hpp | 27 - src/snark/libsnark/gadgetlib1/gadget.tcc | 23 - .../gadgetlib1/gadgets/basic_gadgets.hpp | 351 ---- .../gadgetlib1/gadgets/basic_gadgets.tcc | 705 ------- .../gadgetlib1/gadgets/gadget_from_r1cs.hpp | 45 - .../gadgetlib1/gadgets/gadget_from_r1cs.tcc | 123 -- .../gadgets/hashes/digest_selector_gadget.hpp | 42 - .../gadgets/hashes/digest_selector_gadget.tcc | 62 - .../gadgetlib1/gadgets/hashes/hash_io.hpp | 63 - .../gadgetlib1/gadgets/hashes/hash_io.tcc | 105 - .../gadgets/hashes/sha256/sha256_aux.hpp | 160 -- .../gadgets/hashes/sha256/sha256_aux.tcc | 297 --- .../hashes/sha256/sha256_components.hpp | 108 - .../hashes/sha256/sha256_components.tcc | 250 --- .../gadgets/hashes/sha256/sha256_gadget.hpp | 98 - .../gadgets/hashes/sha256/sha256_gadget.tcc | 230 --- .../tests/generate_sha256_gadget_tests.py | 55 - .../hashes/sha256/tests/pypy_sha256.py | 263 --- .../sha256/tests/test_sha256_gadget.cpp | 48 - .../merkle_authentication_path_variable.hpp | 38 - .../merkle_authentication_path_variable.tcc | 76 - .../merkle_tree_check_read_gadget.hpp | 73 - .../merkle_tree_check_read_gadget.tcc | 196 -- .../merkle_tree_check_update_gadget.hpp | 90 - .../merkle_tree_check_update_gadget.tcc | 265 --- .../tests/test_merkle_tree_gadgets.cpp | 40 - src/snark/libsnark/gadgetlib1/pb_variable.hpp | 144 -- src/snark/libsnark/gadgetlib1/pb_variable.tcc | 330 --- src/snark/libsnark/gadgetlib1/protoboard.hpp | 75 - src/snark/libsnark/gadgetlib1/protoboard.tcc | 189 -- src/snark/libsnark/gtests.cpp | 12 - .../reductions/r1cs_to_qap/r1cs_to_qap.hpp | 70 - .../reductions/r1cs_to_qap/r1cs_to_qap.tcc | 338 --- .../relations/arithmetic_programs/qap/qap.hpp | 193 -- .../relations/arithmetic_programs/qap/qap.tcc | 324 --- .../qap/tests/test_qap.cpp | 104 - .../r1cs/examples/r1cs_examples.hpp | 73 - .../r1cs/examples/r1cs_examples.tcc | 164 -- .../r1cs/r1cs.hpp | 153 -- .../r1cs/r1cs.tcc | 310 --- src/snark/libsnark/relations/variable.hpp | 213 -- src/snark/libsnark/relations/variable.tcc | 512 ----- .../examples/run_r1cs_ppzksnark.hpp | 35 - .../examples/run_r1cs_ppzksnark.tcc | 114 -- .../profiling/profile_r1cs_ppzksnark.cpp | 71 - .../r1cs_ppzksnark/r1cs_ppzksnark.hpp | 486 ----- .../r1cs_ppzksnark/r1cs_ppzksnark.tcc | 886 -------- .../r1cs_ppzksnark/r1cs_ppzksnark_params.hpp | 34 - .../tests/test_r1cs_ppzksnark.cpp | 44 - src/test/rpc_wallet_tests.cpp | 29 +- src/test/sighash_tests.cpp | 7 +- src/test/test_bitcoin.cpp | 4 +- src/test/transaction_tests.cpp | 13 +- src/transaction_builder.cpp | 2 +- src/utiltest.cpp | 25 +- src/utiltest.h | 6 +- .../asyncrpcoperation_mergetoaddress.cpp | 2 +- src/wallet/asyncrpcoperation_sendmany.cpp | 2 +- .../asyncrpcoperation_shieldcoinbase.cpp | 2 +- src/wallet/gtest/test_wallet.cpp | 41 +- src/wallet/rpcwallet.cpp | 51 +- src/zcash/JoinSplit.cpp | 267 +-- src/zcash/JoinSplit.hpp | 22 +- src/zcash/Proof.cpp | 233 --- src/zcash/Proof.hpp | 35 - src/zcash/circuit/commitment.tcc | 100 - src/zcash/circuit/gadget.tcc | 349 ---- src/zcash/circuit/merkle.tcc | 60 - src/zcash/circuit/note.tcc | 244 --- src/zcash/circuit/prfs.tcc | 109 - src/zcash/circuit/utils.tcc | 75 - src/zcbenchmarks.cpp | 21 +- src/zcbenchmarks.h | 1 - zcutil/fetch-params.sh | 6 - 203 files changed, 590 insertions(+), 25801 deletions(-) delete mode 100644 build-aux/m4/ax_compiler_vendor.m4 delete mode 100644 build-aux/m4/ax_gcc_archflag.m4 delete mode 100644 build-aux/m4/ax_gcc_x86_cpuid.m4 delete mode 100644 build-aux/m4/ax_openmp.m4 delete mode 100644 depends/packages/libgmp.mk delete mode 100755 qa/rpc-tests/mempool_tx_input_limit.py delete mode 100644 src/gtest/test_circuit.cpp delete mode 100644 src/gtest/test_proofs.cpp delete mode 100644 src/snark/.gitignore delete mode 100644 src/snark/AUTHORS delete mode 100644 src/snark/LICENSE delete mode 100644 src/snark/Makefile delete mode 100644 src/snark/README.md delete mode 100644 src/snark/doxygen.conf delete mode 100644 src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g1.cpp delete mode 100644 src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g1.hpp delete mode 100644 src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g2.cpp delete mode 100644 src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g2.hpp delete mode 100644 src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_init.cpp delete mode 100644 src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_init.hpp delete mode 100644 src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pairing.cpp delete mode 100644 src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pairing.hpp delete mode 100644 src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pp.cpp delete mode 100644 src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pp.hpp delete mode 100644 src/snark/libsnark/algebra/curves/curve_utils.hpp delete mode 100644 src/snark/libsnark/algebra/curves/curve_utils.tcc delete mode 100644 src/snark/libsnark/algebra/curves/public_params.hpp delete mode 100644 src/snark/libsnark/algebra/curves/tests/test_bilinearity.cpp delete mode 100644 src/snark/libsnark/algebra/curves/tests/test_groups.cpp delete mode 100644 src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain.hpp delete mode 100644 src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain.tcc delete mode 100644 src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain_aux.hpp delete mode 100644 src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain_aux.tcc delete mode 100644 src/snark/libsnark/algebra/evaluation_domain/evaluation_domain.hpp delete mode 100644 src/snark/libsnark/algebra/evaluation_domain/evaluation_domain.tcc delete mode 100644 src/snark/libsnark/algebra/exponentiation/exponentiation.hpp delete mode 100644 src/snark/libsnark/algebra/exponentiation/exponentiation.tcc delete mode 100644 src/snark/libsnark/algebra/fields/bigint.hpp delete mode 100644 src/snark/libsnark/algebra/fields/bigint.tcc delete mode 100644 src/snark/libsnark/algebra/fields/field_utils.hpp delete mode 100644 src/snark/libsnark/algebra/fields/field_utils.tcc delete mode 100644 src/snark/libsnark/algebra/fields/fp.hpp delete mode 100644 src/snark/libsnark/algebra/fields/fp.tcc delete mode 100644 src/snark/libsnark/algebra/fields/fp12_2over3over2.hpp delete mode 100644 src/snark/libsnark/algebra/fields/fp12_2over3over2.tcc delete mode 100644 src/snark/libsnark/algebra/fields/fp2.hpp delete mode 100644 src/snark/libsnark/algebra/fields/fp2.tcc delete mode 100644 src/snark/libsnark/algebra/fields/fp6_3over2.hpp delete mode 100644 src/snark/libsnark/algebra/fields/fp6_3over2.tcc delete mode 100644 src/snark/libsnark/algebra/fields/fp_aux.tcc delete mode 100644 src/snark/libsnark/algebra/fields/tests/test_bigint.cpp delete mode 100644 src/snark/libsnark/algebra/fields/tests/test_fields.cpp delete mode 100644 src/snark/libsnark/algebra/knowledge_commitment/knowledge_commitment.hpp delete mode 100644 src/snark/libsnark/algebra/knowledge_commitment/knowledge_commitment.tcc delete mode 100644 src/snark/libsnark/algebra/scalar_multiplication/kc_multiexp.hpp delete mode 100644 src/snark/libsnark/algebra/scalar_multiplication/kc_multiexp.tcc delete mode 100644 src/snark/libsnark/algebra/scalar_multiplication/multiexp.hpp delete mode 100644 src/snark/libsnark/algebra/scalar_multiplication/multiexp.tcc delete mode 100644 src/snark/libsnark/algebra/scalar_multiplication/wnaf.hpp delete mode 100644 src/snark/libsnark/algebra/scalar_multiplication/wnaf.tcc delete mode 100644 src/snark/libsnark/common/assert_except.hpp delete mode 100644 src/snark/libsnark/common/data_structures/accumulation_vector.hpp delete mode 100644 src/snark/libsnark/common/data_structures/accumulation_vector.tcc delete mode 100644 src/snark/libsnark/common/data_structures/merkle_tree.hpp delete mode 100644 src/snark/libsnark/common/data_structures/merkle_tree.tcc delete mode 100644 src/snark/libsnark/common/data_structures/sparse_vector.hpp delete mode 100644 src/snark/libsnark/common/data_structures/sparse_vector.tcc delete mode 100644 src/snark/libsnark/common/default_types/ec_pp.hpp delete mode 100644 src/snark/libsnark/common/default_types/r1cs_ppzksnark_pp.hpp delete mode 100644 src/snark/libsnark/common/profiling.cpp delete mode 100644 src/snark/libsnark/common/profiling.hpp delete mode 100644 src/snark/libsnark/common/serialization.hpp delete mode 100644 src/snark/libsnark/common/serialization.tcc delete mode 100644 src/snark/libsnark/common/template_utils.hpp delete mode 100644 src/snark/libsnark/common/utils.cpp delete mode 100644 src/snark/libsnark/common/utils.hpp delete mode 100644 src/snark/libsnark/common/utils.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/constraint_profiling.cpp delete mode 100644 src/snark/libsnark/gadgetlib1/constraint_profiling.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/examples/simple_example.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/examples/simple_example.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadget.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadget.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/basic_gadgets.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/basic_gadgets.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/gadget_from_r1cs.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/gadget_from_r1cs.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/digest_selector_gadget.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/digest_selector_gadget.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/hash_io.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/hash_io.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_aux.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_aux.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_components.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_components.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_gadget.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_gadget.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/generate_sha256_gadget_tests.py delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/pypy_sha256.py delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/test_sha256_gadget.cpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_authentication_path_variable.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_authentication_path_variable.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_read_gadget.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_read_gadget.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_update_gadget.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_update_gadget.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/tests/test_merkle_tree_gadgets.cpp delete mode 100644 src/snark/libsnark/gadgetlib1/pb_variable.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/pb_variable.tcc delete mode 100644 src/snark/libsnark/gadgetlib1/protoboard.hpp delete mode 100644 src/snark/libsnark/gadgetlib1/protoboard.tcc delete mode 100644 src/snark/libsnark/gtests.cpp delete mode 100644 src/snark/libsnark/reductions/r1cs_to_qap/r1cs_to_qap.hpp delete mode 100644 src/snark/libsnark/reductions/r1cs_to_qap/r1cs_to_qap.tcc delete mode 100644 src/snark/libsnark/relations/arithmetic_programs/qap/qap.hpp delete mode 100644 src/snark/libsnark/relations/arithmetic_programs/qap/qap.tcc delete mode 100644 src/snark/libsnark/relations/arithmetic_programs/qap/tests/test_qap.cpp delete mode 100644 src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.hpp delete mode 100644 src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.tcc delete mode 100644 src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.hpp delete mode 100644 src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.tcc delete mode 100644 src/snark/libsnark/relations/variable.hpp delete mode 100644 src/snark/libsnark/relations/variable.tcc delete mode 100644 src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.hpp delete mode 100644 src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.tcc delete mode 100644 src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/profiling/profile_r1cs_ppzksnark.cpp delete mode 100644 src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.hpp delete mode 100644 src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc delete mode 100644 src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark_params.hpp delete mode 100644 src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/tests/test_r1cs_ppzksnark.cpp delete mode 100644 src/zcash/circuit/commitment.tcc delete mode 100644 src/zcash/circuit/gadget.tcc delete mode 100644 src/zcash/circuit/merkle.tcc delete mode 100644 src/zcash/circuit/note.tcc delete mode 100644 src/zcash/circuit/prfs.tcc delete mode 100644 src/zcash/circuit/utils.tcc diff --git a/build-aux/m4/ax_compiler_vendor.m4 b/build-aux/m4/ax_compiler_vendor.m4 deleted file mode 100644 index f06e86540..000000000 --- a/build-aux/m4/ax_compiler_vendor.m4 +++ /dev/null @@ -1,117 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_COMPILER_VENDOR -# -# DESCRIPTION -# -# Determine the vendor of the C, C++ or Fortran compiler. The vendor is -# returned in the cache variable $ax_cv_c_compiler_vendor for C, -# $ax_cv_cxx_compiler_vendor for C++ or $ax_cv_fc_compiler_vendor for -# (modern) Fortran. The value is one of "intel", "ibm", "pathscale", -# "clang" (LLVM), "cray", "fujitsu", "sdcc", "sx", "portland" (PGI), "gnu" -# (GCC), "sun" (Oracle Developer Studio), "hp", "dec", "borland", -# "comeau", "kai", "lcc", "sgi", "microsoft", "metrowerks", "watcom", -# "tcc" (Tiny CC) or "unknown" (if the compiler cannot be determined). -# -# To check for a Fortran compiler, you must first call AC_FC_PP_SRCEXT -# with an appropriate preprocessor-enabled extension. For example: -# -# AC_LANG_PUSH([Fortran]) -# AC_PROG_FC -# AC_FC_PP_SRCEXT([F]) -# AX_COMPILER_VENDOR -# AC_LANG_POP([Fortran]) -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# Copyright (c) 2018-19 John Zaitseff -# -# 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 30 - -AC_DEFUN([AX_COMPILER_VENDOR], [dnl - AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, [dnl - dnl If you modify this list of vendors, please add similar support - dnl to ax_compiler_version.m4 if at all possible. - dnl - dnl Note: Do NOT check for GCC first since some other compilers - dnl define __GNUC__ to remain compatible with it. Compilers that - dnl are very slow to start (such as Intel) are listed first. - - vendors=" - intel: __ICC,__ECC,__INTEL_COMPILER - ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__,__ibmxl__ - pathscale: __PATHCC__,__PATHSCALE__ - clang: __clang__ - cray: _CRAYC - fujitsu: __FUJITSU - sdcc: SDCC,__SDCC - sx: _SX - portland: __PGI - gnu: __GNUC__ - sun: __SUNPRO_C,__SUNPRO_CC,__SUNPRO_F90,__SUNPRO_F95 - hp: __HP_cc,__HP_aCC - dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER - borland: __BORLANDC__,__CODEGEARC__,__TURBOC__ - comeau: __COMO__ - kai: __KCC - lcc: __LCC__ - sgi: __sgi,sgi - microsoft: _MSC_VER - metrowerks: __MWERKS__ - watcom: __WATCOMC__ - tcc: __TINYC__ - unknown: UNKNOWN - " - for ventest in $vendors; do - case $ventest in - *:) - vendor=$ventest - continue - ;; - *) - vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" - ;; - esac - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ -#if !($vencpp) - thisisanerror; -#endif - ]])], [break]) - done - - ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` - ]) -])dnl diff --git a/build-aux/m4/ax_gcc_archflag.m4 b/build-aux/m4/ax_gcc_archflag.m4 deleted file mode 100644 index c52b9b296..000000000 --- a/build-aux/m4/ax_gcc_archflag.m4 +++ /dev/null @@ -1,267 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_gcc_archflag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_GCC_ARCHFLAG([PORTABLE?], [ACTION-SUCCESS], [ACTION-FAILURE]) -# -# DESCRIPTION -# -# This macro tries to guess the "native" arch corresponding to the target -# architecture for use with gcc's -march=arch or -mtune=arch flags. If -# found, the cache variable $ax_cv_gcc_archflag is set to this flag and -# ACTION-SUCCESS is executed; otherwise $ax_cv_gcc_archflag is set to -# "unknown" and ACTION-FAILURE is executed. The default ACTION-SUCCESS is -# to add $ax_cv_gcc_archflag to the end of $CFLAGS. -# -# PORTABLE? should be either [yes] (default) or [no]. In the former case, -# the flag is set to -mtune (or equivalent) so that the architecture is -# only used for tuning, but the instruction set used is still portable. In -# the latter case, the flag is set to -march (or equivalent) so that -# architecture-specific instructions are enabled. -# -# The user can specify --with-gcc-arch= in order to override the -# macro's choice of architecture, or --without-gcc-arch to disable this. -# -# When cross-compiling, or if $CC is not gcc, then ACTION-FAILURE is -# called unless the user specified --with-gcc-arch manually. -# -# Requires macros: AX_CHECK_COMPILE_FLAG, AX_GCC_X86_CPUID -# -# (The main emphasis here is on recent CPUs, on the principle that doing -# high-performance computing on old hardware is uncommon.) -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# Copyright (c) 2014 Tsukasa Oi -# Copyright (c) 2017-2018 Alexey Kopytov -# -# 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 22 - -AC_DEFUN([AX_GCC_ARCHFLAG], -[AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([AC_CANONICAL_HOST]) -AC_REQUIRE([AC_PROG_SED]) -AC_REQUIRE([AX_COMPILER_VENDOR]) - -AC_ARG_WITH(gcc-arch, [AS_HELP_STRING([--with-gcc-arch=], [use architecture for gcc -march/-mtune, instead of guessing])], - ax_gcc_arch=$withval, ax_gcc_arch=yes) - -AC_MSG_CHECKING([for gcc architecture flag]) -AC_MSG_RESULT([]) -AC_CACHE_VAL(ax_cv_gcc_archflag, -[ -ax_cv_gcc_archflag="unknown" - -if test "$GCC" = yes; then - -if test "x$ax_gcc_arch" = xyes; then -ax_gcc_arch="" -if test "$cross_compiling" = no; then -case $host_cpu in - i[[3456]]86*|x86_64*|amd64*) # use cpuid codes - AX_GCC_X86_CPUID(0) - AX_GCC_X86_CPUID(1) - case $ax_cv_gcc_x86_cpuid_0 in - *:756e6547:6c65746e:49656e69) # Intel - case $ax_cv_gcc_x86_cpuid_1 in - *5[[4578]]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;; - *5[[123]]?:*:*:*) ax_gcc_arch=pentium ;; - *0?61?:*:*:*|?61?:*:*:*|61?:*:*:*) ax_gcc_arch=pentiumpro ;; - *0?6[[356]]?:*:*:*|?6[[356]]?:*:*:*|6[[356]]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; - *0?6[[78ab]]?:*:*:*|?6[[78ab]]?:*:*:*|6[[78ab]]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; - *0?6[[9d]]?:*:*:*|?6[[9d]]?:*:*:*|6[[9d]]?:*:*:*|*1?65?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;; - *0?6e?:*:*:*|?6e?:*:*:*|6e?:*:*:*) ax_gcc_arch="yonah pentium-m pentium3 pentiumpro" ;; - *0?6f?:*:*:*|?6f?:*:*:*|6f?:*:*:*|*1?66?:*:*:*) ax_gcc_arch="core2 pentium-m pentium3 pentiumpro" ;; - *1?6[[7d]]?:*:*:*) ax_gcc_arch="penryn core2 pentium-m pentium3 pentiumpro" ;; - *1?6[[aef]]?:*:*:*|*2?6e?:*:*:*) ax_gcc_arch="nehalem corei7 core2 pentium-m pentium3 pentiumpro" ;; - *2?6[[5cf]]?:*:*:*) ax_gcc_arch="westmere corei7 core2 pentium-m pentium3 pentiumpro" ;; - *2?6[[ad]]?:*:*:*) ax_gcc_arch="sandybridge corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; - *3?6[[ae]]?:*:*:*) ax_gcc_arch="ivybridge core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; - *3?6[[cf]]?:*:*:*|*4?6[[56]]?:*:*:*) ax_gcc_arch="haswell core-avx2 core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; - *3?6d?:*:*:*|*4?6[[7f]]?:*:*:*|*5?66?:*:*:*) ax_gcc_arch="broadwell core-avx2 core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; - *1?6c?:*:*:*|*2?6[[67]]?:*:*:*|*3?6[[56]]?:*:*:*) ax_gcc_arch="bonnell atom core2 pentium-m pentium3 pentiumpro" ;; - *3?67?:*:*:*|*[[45]]?6[[ad]]?:*:*:*) ax_gcc_arch="silvermont atom core2 pentium-m pentium3 pentiumpro" ;; - *000?f[[012]]?:*:*:*|?f[[012]]?:*:*:*|f[[012]]?:*:*:*) ax_gcc_arch="pentium4 pentiumpro" ;; - *000?f[[346]]?:*:*:*|?f[[346]]?:*:*:*|f[[346]]?:*:*:*) ax_gcc_arch="nocona prescott pentium4 pentiumpro" ;; - # fallback - *5??:*:*:*) ax_gcc_arch=pentium ;; - *??6??:*:*:*) ax_gcc_arch="core2 pentiumpro" ;; - *6??:*:*:*) ax_gcc_arch=pentiumpro ;; - *00??f??:*:*:*|??f??:*:*:*|?f??:*:*:*|f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro" ;; - esac ;; - *:68747541:444d4163:69746e65) # AMD - case $ax_cv_gcc_x86_cpuid_1 in - *5[[67]]?:*:*:*) ax_gcc_arch=k6 ;; - *5[[8]]?:*:*:*) ax_gcc_arch="k6-2 k6" ;; - *5[[9d]]?:*:*:*) ax_gcc_arch="k6-3 k6" ;; - *6[[12]]?:*:*:*) ax_gcc_arch="athlon k7" ;; - *6[[34]]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;; - *6[[678a]]?:*:*:*) ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;; - *000?f[[4578bcef]]?:*:*:*|?f[[4578bcef]]?:*:*:*|f[[4578bcef]]?:*:*:*|*001?f[[4578bcf]]?:*:*:*|1?f[[4578bcf]]?:*:*:*) ax_gcc_arch="athlon64 k8" ;; - *002?f[[13457bcf]]?:*:*:*|2?f[[13457bcf]]?:*:*:*|*004?f[[138bcf]]?:*:*:*|4?f[[138bcf]]?:*:*:*|*005?f[[df]]?:*:*:*|5?f[[df]]?:*:*:*|*006?f[[8bcf]]?:*:*:*|6?f[[8bcf]]?:*:*:*|*007?f[[cf]]?:*:*:*|7?f[[cf]]?:*:*:*|*00c?f1?:*:*:*|c?f1?:*:*:*|*020?f3?:*:*:*|20?f3?:*:*:*) ax_gcc_arch="athlon64-sse3 k8-sse3 athlon64 k8" ;; - *010?f[[245689a]]?:*:*:*|10?f[[245689a]]?:*:*:*|*030?f1?:*:*:*|30?f1?:*:*:*) ax_gcc_arch="barcelona amdfam10 k8" ;; - *050?f[[12]]?:*:*:*|50?f[[12]]?:*:*:*) ax_gcc_arch="btver1 amdfam10 k8" ;; - *060?f1?:*:*:*|60?f1?:*:*:*) ax_gcc_arch="bdver1 amdfam10 k8" ;; - *060?f2?:*:*:*|60?f2?:*:*:*|*061?f[[03]]?:*:*:*|61?f[[03]]?:*:*:*) ax_gcc_arch="bdver2 bdver1 amdfam10 k8" ;; - *063?f0?:*:*:*|63?f0?:*:*:*) ax_gcc_arch="bdver3 bdver2 bdver1 amdfam10 k8" ;; - *07[[03]]?f0?:*:*:*|7[[03]]?f0?:*:*:*) ax_gcc_arch="btver2 btver1 amdfam10 k8" ;; - # fallback - *0[[13]]??f??:*:*:*|[[13]]??f??:*:*:*) ax_gcc_arch="barcelona amdfam10 k8" ;; - *020?f??:*:*:*|20?f??:*:*:*) ax_gcc_arch="athlon64-sse3 k8-sse3 athlon64 k8" ;; - *05??f??:*:*:*|5??f??:*:*:*) ax_gcc_arch="btver1 amdfam10 k8" ;; - *060?f??:*:*:*|60?f??:*:*:*) ax_gcc_arch="bdver1 amdfam10 k8" ;; - *061?f??:*:*:*|61?f??:*:*:*) ax_gcc_arch="bdver2 bdver1 amdfam10 k8" ;; - *06??f??:*:*:*|6??f??:*:*:*) ax_gcc_arch="bdver3 bdver2 bdver1 amdfam10 k8" ;; - *070?f??:*:*:*|70?f??:*:*:*) ax_gcc_arch="btver2 btver1 amdfam10 k8" ;; - *???f??:*:*:*) ax_gcc_arch="amdfam10 k8" ;; - esac ;; - *:746e6543:736c7561:48727561) # IDT / VIA (Centaur) - case $ax_cv_gcc_x86_cpuid_1 in - *54?:*:*:*) ax_gcc_arch=winchip-c6 ;; - *5[[89]]?:*:*:*) ax_gcc_arch=winchip2 ;; - *66?:*:*:*) ax_gcc_arch=winchip2 ;; - *6[[78]]?:*:*:*) ax_gcc_arch=c3 ;; - *6[[9adf]]?:*:*:*) ax_gcc_arch="c3-2 c3" ;; - esac ;; - esac - if test x"$ax_gcc_arch" = x; then # fallback - case $host_cpu in - i586*) ax_gcc_arch=pentium ;; - i686*) ax_gcc_arch=pentiumpro ;; - esac - fi - ;; - - sparc*) - AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag], [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/]) - cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null` - cputype=`echo "$cputype" | tr -d ' -' | $SED 's/SPARCIIi/SPARCII/' |tr $as_cr_LETTERS $as_cr_letters` - case $cputype in - *ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;; - *ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;; - *ultrasparc*) ax_gcc_arch="ultrasparc v9" ;; - *supersparc*|*tms390z5[[05]]*) ax_gcc_arch="supersparc v8" ;; - *hypersparc*|*rt62[[056]]*) ax_gcc_arch="hypersparc v8" ;; - *cypress*) ax_gcc_arch=cypress ;; - esac ;; - - alphaev5) ax_gcc_arch=ev5 ;; - alphaev56) ax_gcc_arch=ev56 ;; - alphapca56) ax_gcc_arch="pca56 ev56" ;; - alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;; - alphaev6) ax_gcc_arch=ev6 ;; - alphaev67) ax_gcc_arch=ev67 ;; - alphaev68) ax_gcc_arch="ev68 ev67" ;; - alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;; - alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;; - alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;; - - powerpc*) - cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | $SED 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null` - cputype=`echo $cputype | $SED -e 's/ppc//g;s/ *//g'` - case $cputype in - *750*) ax_gcc_arch="750 G3" ;; - *740[[0-9]]*) ax_gcc_arch="$cputype 7400 G4" ;; - *74[[4-5]][[0-9]]*) ax_gcc_arch="$cputype 7450 G4" ;; - *74[[0-9]][[0-9]]*) ax_gcc_arch="$cputype G4" ;; - *970*) ax_gcc_arch="970 G5 power4";; - *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";; - *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";; - 603ev|8240) ax_gcc_arch="$cputype 603e 603";; - *POWER7*) ax_gcc_arch="power7";; - *POWER8*) ax_gcc_arch="power8";; - *POWER9*) ax_gcc_arch="power9";; - *POWER10*) ax_gcc_arch="power10";; - *) ax_gcc_arch=$cputype ;; - esac - ax_gcc_arch="$ax_gcc_arch powerpc" - ;; - aarch64) - cpuimpl=`grep 'CPU implementer' /proc/cpuinfo 2> /dev/null | cut -d: -f2 | tr -d " " | head -n 1` - cpuarch=`grep 'CPU architecture' /proc/cpuinfo 2> /dev/null | cut -d: -f2 | tr -d " " | head -n 1` - cpuvar=`grep 'CPU variant' /proc/cpuinfo 2> /dev/null | cut -d: -f2 | tr -d " " | head -n 1` - case $cpuimpl in - 0x42) case $cpuarch in - 8) case $cpuvar in - 0x0) ax_gcc_arch="thunderx2t99 vulcan armv8.1-a armv8-a+lse armv8-a native" ;; - esac - ;; - esac - ;; - 0x43) case $cpuarch in - 8) case $cpuvar in - 0x0) ax_gcc_arch="thunderx armv8-a native" ;; - 0x1) ax_gcc_arch="thunderx+lse armv8.1-a armv8-a+lse armv8-a native" ;; - esac - ;; - esac - ;; - esac - ;; -esac -fi # not cross-compiling -fi # guess arch - -if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then -if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code - flag_prefixes="-mtune=" - if test "x$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" = xclang; then flag_prefixes="-march="; fi - # -mcpu=$arch and m$arch generate nonportable code on every arch except - # x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr. - case $host_cpu in i*86|x86_64*|amd64*) flag_prefixes="$flag_prefixes -mcpu= -m";; esac -else - flag_prefixes="-march= -mcpu= -m" -fi -for flag_prefix in $flag_prefixes; do - for arch in $ax_gcc_arch; do - flag="$flag_prefix$arch" - AX_CHECK_COMPILE_FLAG($flag, [if test "x$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" = xclang; then - if test "x[]m4_default([$1],yes)" = xyes; then - if test "x$flag" = "x-march=$arch"; then flag=-mtune=$arch; fi - fi - fi; ax_cv_gcc_archflag=$flag; break]) - done - test "x$ax_cv_gcc_archflag" = xunknown || break -done -fi - -fi # $GCC=yes -]) -AC_MSG_CHECKING([for gcc architecture flag]) -AC_MSG_RESULT($ax_cv_gcc_archflag) -if test "x$ax_cv_gcc_archflag" = xunknown; then - m4_default([$3],:) -else - m4_default([$2], [CFLAGS="$CFLAGS $ax_cv_gcc_archflag"]) -fi -]) diff --git a/build-aux/m4/ax_gcc_x86_cpuid.m4 b/build-aux/m4/ax_gcc_x86_cpuid.m4 deleted file mode 100644 index df954658e..000000000 --- a/build-aux/m4/ax_gcc_x86_cpuid.m4 +++ /dev/null @@ -1,89 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_GCC_X86_CPUID(OP) -# AX_GCC_X86_CPUID_COUNT(OP, COUNT) -# -# DESCRIPTION -# -# On Pentium and later x86 processors, with gcc or a compiler that has a -# compatible syntax for inline assembly instructions, run a small program -# that executes the cpuid instruction with input OP. This can be used to -# detect the CPU type. AX_GCC_X86_CPUID_COUNT takes an additional COUNT -# parameter that gets passed into register ECX before calling cpuid. -# -# On output, the values of the eax, ebx, ecx, and edx registers are stored -# as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable -# ax_cv_gcc_x86_cpuid_OP. -# -# If the cpuid instruction fails (because you are running a -# cross-compiler, or because you are not using gcc, or because you are on -# a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP -# is set to the string "unknown". -# -# This macro mainly exists to be used in AX_GCC_ARCHFLAG. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# Copyright (c) 2015 Michael Petch -# -# 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 10 - -AC_DEFUN([AX_GCC_X86_CPUID], -[AX_GCC_X86_CPUID_COUNT($1, 0) -]) - -AC_DEFUN([AX_GCC_X86_CPUID_COUNT], -[AC_REQUIRE([AC_PROG_CC]) -AC_LANG_PUSH([C]) -AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1, - [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include ], [ - int op = $1, level = $2, eax, ebx, ecx, edx; - FILE *f; - __asm__ __volatile__ ("xchg %%ebx, %1\n" - "cpuid\n" - "xchg %%ebx, %1\n" - : "=a" (eax), "=r" (ebx), "=c" (ecx), "=d" (edx) - : "a" (op), "2" (level)); - - f = fopen("conftest_cpuid", "w"); if (!f) return 1; - fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); - fclose(f); - return 0; -])], - [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid], - [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid], - [ax_cv_gcc_x86_cpuid_$1=unknown])]) -AC_LANG_POP([C]) -]) diff --git a/build-aux/m4/ax_openmp.m4 b/build-aux/m4/ax_openmp.m4 deleted file mode 100644 index 866e1d664..000000000 --- a/build-aux/m4/ax_openmp.m4 +++ /dev/null @@ -1,123 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_openmp.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_OPENMP([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -# -# DESCRIPTION -# -# This macro tries to find out how to compile programs that use OpenMP a -# standard API and set of compiler directives for parallel programming -# (see http://www-unix.mcs/) -# -# On success, it sets the OPENMP_CFLAGS/OPENMP_CXXFLAGS/OPENMP_F77FLAGS -# output variable to the flag (e.g. -omp) used both to compile *and* link -# OpenMP programs in the current language. -# -# NOTE: You are assumed to not only compile your program with these flags, -# but also link it with them as well. -# -# If you want to compile everything with OpenMP, you should set: -# -# CFLAGS="$CFLAGS $OPENMP_CFLAGS" -# #OR# CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS" -# #OR# FFLAGS="$FFLAGS $OPENMP_FFLAGS" -# -# (depending on the selected language). -# -# The user can override the default choice by setting the corresponding -# environment variable (e.g. OPENMP_CFLAGS). -# -# ACTION-IF-FOUND is a list of shell commands to run if an OpenMP flag 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_OPENMP. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2015 John W. Peterson -# Copyright (c) 2016 Nick R. Papior -# -# 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 13 - -AC_DEFUN([AX_OPENMP], [ -AC_PREREQ([2.69]) dnl for _AC_LANG_PREFIX - -AC_CACHE_CHECK([for OpenMP flag of _AC_LANG compiler], ax_cv_[]_AC_LANG_ABBREV[]_openmp, [save[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS -ax_cv_[]_AC_LANG_ABBREV[]_openmp=unknown -# Flags to try: -fopenmp (gcc), -mp (SGI & PGI), -# -qopenmp (icc>=15), -openmp (icc), -# -xopenmp (Sun), -omp (Tru64), -# -qsmp=omp (AIX), -# none -ax_openmp_flags="-fopenmp -openmp -qopenmp -mp -xopenmp -omp -qsmp=omp none" -if test "x$OPENMP_[]_AC_LANG_PREFIX[]FLAGS" != x; then - ax_openmp_flags="$OPENMP_[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flags" -fi -for ax_openmp_flag in $ax_openmp_flags; do - case $ax_openmp_flag in - none) []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[] ;; - *) []_AC_LANG_PREFIX[]FLAGS="$save[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flag" ;; - esac - AC_LINK_IFELSE([AC_LANG_SOURCE([[ -@%:@include - -static void -parallel_fill(int * data, int n) -{ - int i; -@%:@pragma omp parallel for - for (i = 0; i < n; ++i) - data[i] = i; -} - -int -main() -{ - int arr[100000]; - omp_set_num_threads(2); - parallel_fill(arr, 100000); - return 0; -} -]])],[ax_cv_[]_AC_LANG_ABBREV[]_openmp=$ax_openmp_flag; break],[]) -done -[]_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[]FLAGS -]) -if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" = "xunknown"; then - m4_default([$2],:) -else - if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" != "xnone"; then - OPENMP_[]_AC_LANG_PREFIX[]FLAGS=$ax_cv_[]_AC_LANG_ABBREV[]_openmp - fi - m4_default([$1], [AC_DEFINE(HAVE_OPENMP,1,[Define if OpenMP is enabled])]) -fi -])dnl AX_OPENMP diff --git a/configure.ac b/configure.ac index f8946ea89..00e7fb9ae 100644 --- a/configure.ac +++ b/configure.ac @@ -733,14 +733,6 @@ else fi fi -# These packages don't provide pkgconfig config files across all -# platforms, so we use older autoconf detection mechanisms: -AC_CHECK_HEADER([gmp.h],,AC_MSG_ERROR(libgmp headers missing)) -AC_CHECK_LIB([gmp],[__gmpn_sub_n],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing)]) - -AC_CHECK_HEADER([gmpxx.h],,AC_MSG_ERROR(libgmpxx headers missing)) -AC_CHECK_LIB([gmpxx],[main],GMPXX_LIBS=-lgmpxx, [AC_MSG_ERROR(libgmpxx missing)]) - RUST_LIBS="-lrustzcash" case $host in *mingw*) @@ -750,33 +742,12 @@ case $host in ;; esac -dnl Check for OpenMP support -AX_OPENMP( - [AC_DEFINE(HAVE_OPENMP, 1, [Define if OpenMP is enabled]) - AM_CONDITIONAL([HAVE_OPENMP], [true]) - CPPFLAGS="$CPPFLAGS -DMULTICORE" - CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"], - [AC_MSG_WARN([OpenMP not supported, disabling multithreading]) - AC_DEFINE(HAVE_OPENMP, 0, [Define if OpenMP is enabled]) - AM_CONDITIONAL([HAVE_OPENMP], [false])]) - -# Gitian uses a config.site that sets depends_prefix, and then sets --prefix=/ -# build.sh just uses --prefix -if test x$depends_prefix != x; then - LIBSNARK_DEPINST="$depends_prefix" -else - LIBSNARK_DEPINST="$prefix" -fi - -# Set optimization flags for libsnark -AX_GCC_ARCHFLAG([no], [LIBSNARK_OPTFLAGS="-O2 $ax_cv_gcc_archflag"], [LIBSNARK_OPTFLAGS="-O2"]) - # Additional BitcoinZ flags AX_CHECK_COMPILE_FLAG([-fwrapv],[CXXFLAGS="$CXXFLAGS -fwrapv"]) AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing],[CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"]) AX_CHECK_COMPILE_FLAG([-Wno-builtin-declaration-mismatch],[CXXFLAGS="$CXXFLAGS -Wno-builtin-declaration-mismatch"],,[[$CXXFLAG_WERROR]]) -LIBZCASH_LIBS="-lgmp -lgmpxx $BOOST_SYSTEM_LIB -lcrypto -lsodium $RUST_LIBS" +LIBZCASH_LIBS="$BOOST_SYSTEM_LIB -lcrypto -lsodium $RUST_LIBS" AC_MSG_CHECKING([whether to build bitcoind]) AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes]) @@ -906,10 +877,6 @@ AC_SUBST(SSL_LIBS) AC_SUBST(EVENT_LIBS) AC_SUBST(EVENT_PTHREADS_LIBS) AC_SUBST(ZMQ_LIBS) -AC_SUBST(GMP_LIBS) -AC_SUBST(GMPXX_LIBS) -AC_SUBST(LIBSNARK_DEPINST) -AC_SUBST(LIBSNARK_OPTFLAGS) AC_SUBST(LIBZCASH_LIBS) AC_SUBST(PROTON_LIBS) AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile src/test/buildenv.py]) @@ -940,7 +907,7 @@ unset PKG_CONFIG_LIBDIR PKG_CONFIG_LIBDIR="$PKGCONFIG_LIBDIR_TEMP" ac_configure_args="${ac_configure_args} --disable-shared --with-pic --with-bignum=no --enable-module-recovery" -AC_CONFIG_SUBDIRS([src/secp256k1 src/snark src/univalue]) +AC_CONFIG_SUBDIRS([src/secp256k1 src/univalue]) AC_OUTPUT diff --git a/contrib/debian/copyright b/contrib/debian/copyright index c918e8889..27e65b74d 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -17,14 +17,6 @@ Files: depends/sources/libsodium-*.tar.gz Copyright: 2013-2016 Frank Denis License: ISC -Files: depends/sources/libsnark-*.tar.gz -Copyright: 2012-2016 SCIPR Lab and contributors; 2016 The Zcash developers -License: Expat - -Files: depends/sources/gmp-*.tar.bz2 -Copyright: 1991, 1996, 1999, 2000, 2007 Free Software Foundation, Inc. -License: LGPL - Files: depends/sources/boost_*.tar.gz Copyright: 2008 Beman Dawes License: Boost-Software-License-1.0 diff --git a/depends/packages/libgmp.mk b/depends/packages/libgmp.mk deleted file mode 100644 index ad5289ede..000000000 --- a/depends/packages/libgmp.mk +++ /dev/null @@ -1,18 +0,0 @@ -package=libgmp -$(package)_version=6.1.2 -$(package)_download_path=https://gmplib.org/download/gmp/ -$(package)_file_name=gmp-$($(package)_version).tar.bz2 -$(package)_sha256_hash=5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d73d8fb2 -$(package)_config_opts=--enable-cxx --disable-shared --with-pic - -define $(package)_config_cmds - $($(package)_autoconf) --host=$(host) --build=$(build) -endef - -define $(package)_build_cmds - $(MAKE) CPPFLAGS='-fPIC' -endef - -define $(package)_stage_cmds - $(MAKE) DESTDIR=$($(package)_staging_dir) install ; echo '=== staging find for $(package):' ; find $($(package)_staging_dir) -endef diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 91f7b9934..6f9b1883d 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -34,7 +34,7 @@ rust_crates := \ crate_winapi_x86_64_pc_windows_gnu rust_packages := rust $(rust_crates) librustzcash proton_packages := proton -zcash_packages := libgmp libsodium utfcpp +zcash_packages := libsodium utfcpp packages := boost openssl libevent zeromq $(zcash_packages) googletest native_packages := native_ccache diff --git a/qa/bitcoinz/full_test_suite.py b/qa/bitcoinz/full_test_suite.py index e7ab9e135..7a1e7739b 100644 --- a/qa/bitcoinz/full_test_suite.py +++ b/qa/bitcoinz/full_test_suite.py @@ -138,7 +138,6 @@ def util_test(): 'no-dot-so', 'util-test', 'secp256k1', - 'libsnark', 'univalue', 'rpc', ] @@ -150,7 +149,6 @@ def util_test(): 'no-dot-so': ensure_no_dot_so_in_depends, 'util-test': util_test, 'secp256k1': ['make', '-C', repofile('src/secp256k1'), 'check'], - 'libsnark': ['make', '-C', repofile('src'), 'libsnark-tests'], 'univalue': ['make', '-C', repofile('src/univalue'), 'check'], 'rpc': [repofile('qa/pull-tester/rpc-tests.sh')], } diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 4ab7fc3b9..676a9ee52 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -43,7 +43,6 @@ testScripts=( 'rest.py' 'mempool_spendcoinbase.py' 'mempool_coinbase_spends.py' - 'mempool_tx_input_limit.py' 'httpbasics.py' 'zapwallettxes.py' # 'proxy_test.py' diff --git a/qa/rpc-tests/bip65-cltv-p2p.py b/qa/rpc-tests/bip65-cltv-p2p.py index 254c075c3..c3adfbff4 100755 --- a/qa/rpc-tests/bip65-cltv-p2p.py +++ b/qa/rpc-tests/bip65-cltv-p2p.py @@ -66,7 +66,9 @@ def invalidate_transaction(self, tx): def get_tests(self): self.coinbase_blocks = self.nodes[0].generate(1) self.nodes[0].generate(100) - self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0) + hashTip = self.nodes[0].getbestblockhash() + hashFinalSaplingRoot = int("0x" + self.nodes[0].getblock(hashTip)['finalsaplingroot'] + "L", 0) + self.tip = int ("0x" + hashTip + "L", 0) self.nodeaddress = self.nodes[0].getnewaddress() '''Check that the rules are enforced.''' @@ -83,7 +85,8 @@ def get_tests(self): self.block_bits = int("0x" + gbt["bits"], 0) block = create_block(self.tip, create_coinbase(101), - self.block_time, self.block_bits) + self.block_time, self.block_bits, + hashFinalSaplingRoot) block.nVersion = 4 block.vtx.append(spendtx) block.hashMerkleRoot = block.calc_merkle_root() diff --git a/qa/rpc-tests/bipdersig-p2p.py b/qa/rpc-tests/bipdersig-p2p.py index 7eca0404d..7c1cfebfa 100755 --- a/qa/rpc-tests/bipdersig-p2p.py +++ b/qa/rpc-tests/bipdersig-p2p.py @@ -73,7 +73,9 @@ def invalidate_transaction(self, tx): def get_tests(self): self.coinbase_blocks = self.nodes[0].generate(1) self.nodes[0].generate(100) - self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0) + hashTip = self.nodes[0].getbestblockhash() + hashFinalSaplingRoot = int("0x" + self.nodes[0].getblock(hashTip)['finalsaplingroot'] + "L", 0) + self.tip = int ("0x" + hashTip + "L", 0) self.nodeaddress = self.nodes[0].getnewaddress() '''Check that the rules are enforced.''' @@ -90,7 +92,8 @@ def get_tests(self): self.block_bits = int("0x" + gbt["bits"], 0) block = create_block(self.tip, create_coinbase(101), - self.block_time, self.block_bits) + self.block_time, self.block_bits, + hashFinalSaplingRoot) block.nVersion = 4 block.vtx.append(spendtx) block.hashMerkleRoot = block.calc_merkle_root() diff --git a/qa/rpc-tests/finalsaplingroot.py b/qa/rpc-tests/finalsaplingroot.py index 3d37edd4e..ddfc5729f 100755 --- a/qa/rpc-tests/finalsaplingroot.py +++ b/qa/rpc-tests/finalsaplingroot.py @@ -31,8 +31,6 @@ def setup_chain(self): def setup_network(self, split=False): self.nodes = start_nodes(4, self.options.tmpdir, extra_args=[[ - '-nuparams=5ba81b19:100', # Overwinter - '-nuparams=76b809bb:200', # Sapling '-txindex' # Avoid JSONRPC error: No information available about transaction ]] * 4 ) connect_nodes_bi(self.nodes,0,1) @@ -43,7 +41,6 @@ def setup_network(self, split=False): self.sync_all() def run_test(self): - # Activate Overwinter and Sapling self.nodes[0].generate(200) self.sync_all() diff --git a/qa/rpc-tests/fundrawtransaction.py b/qa/rpc-tests/fundrawtransaction.py index 311ef743a..84ef11f14 100755 --- a/qa/rpc-tests/fundrawtransaction.py +++ b/qa/rpc-tests/fundrawtransaction.py @@ -190,8 +190,8 @@ def run_test(self): outputs = { self.nodes[0].getnewaddress() : 1.0 } rawtx = self.nodes[2].createrawtransaction(inputs, outputs) - # 4-byte version + 1-byte vin count + 36-byte prevout then script_len - rawtx = rawtx[:82] + "0100" + rawtx[84:] + # 4-byte version + 4-byte versionGroupId + 1-byte vin count + 36-byte prevout then script_len + rawtx = rawtx[:90] + "0100" + rawtx[92:] dec_tx = self.nodes[2].decoderawtransaction(rawtx) assert_equal(utx['txid'], dec_tx['vin'][0]['txid']) diff --git a/qa/rpc-tests/mempool_nu_activation.py b/qa/rpc-tests/mempool_nu_activation.py index 20d435f95..ae5df651d 100755 --- a/qa/rpc-tests/mempool_nu_activation.py +++ b/qa/rpc-tests/mempool_nu_activation.py @@ -24,9 +24,7 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework): def setup_network(self): args = ["-checkmempool", "-debug=mempool", "-blockmaxsize=4000", - "-nuparams=5ba81b19:200", # Overwinter - "-nuparams=76b809bb:210", # Sapling - "-nuparams=2bb40e60:220", # Blossom + "-nuparams=2bb40e60:200", # Blossom ] self.nodes = [] self.nodes.append(start_node(0, self.options.tmpdir, args)) @@ -45,23 +43,24 @@ def run_test(self): # Mine 97 blocks. After this, nodes[1] blocks # 1 to 97 are spend-able. - self.nodes[0].generate(97) + self.nodes[0].generate(94) self.sync_all() # Shield some ZEC node1_taddr = get_coinbase_address(self.nodes[1]) - node0_zaddr = self.nodes[0].z_getnewaddress('sprout') + node0_zaddr = self.nodes[0].z_getnewaddress('sapling') recipients = [{'address': node0_zaddr, 'amount': Decimal('10')}] myopid = self.nodes[1].z_sendmany(node1_taddr, recipients, 1, Decimal('0')) print wait_and_assert_operationid_status(self.nodes[1], myopid) self.sync_all() + self.nodes[0].generate(1) + self.sync_all() # Mempool checks for activation of upgrade Y at height H on base X def nu_activation_checks(): - # Mine block H - 2. After this, the mempool expects - # block H - 1, which is the last X block. - self.nodes[0].generate(1) - self.sync_all() + # Start at block H - 5. After this, the mempool expects block H - 4, which is + # the last height at which we can create transactions for X blocks (due to the + # expiring-soon restrictions). # Mempool should be empty. assert_equal(set(self.nodes[0].getrawmempool()), set()) @@ -69,40 +68,64 @@ def nu_activation_checks(): # Check node 0 shielded balance assert_equal(self.nodes[0].z_getbalance(node0_zaddr), Decimal('10')) - # Fill the mempool with twice as many transactions as can fit into blocks + # Fill the mempool with more transactions than can fit into 4 blocks node0_taddr = self.nodes[0].getnewaddress() x_txids = [] - info = self.nodes[0].getblockchaininfo() - chaintip_branchid = info["consensus"]["chaintip"] - while self.nodes[1].getmempoolinfo()['bytes'] < 2 * 4000: - try: - x_txids.append(self.nodes[1].sendtoaddress(node0_taddr, Decimal('0.001'))) - - except JSONRPCException: - # This fails due to expiring soon threshold, which applies from Overwinter onwards. - upgrade_name = info["upgrades"][chaintip_branchid]["name"] - assert_true(upgrade_name in ("Overwinter", "Sapling"), upgrade_name) - break + while self.nodes[1].getmempoolinfo()['bytes'] < 8 * 4000: + x_txids.append(self.nodes[1].sendtoaddress(node0_taddr, Decimal('0.001'))) self.sync_all() # Spends should be in the mempool x_mempool = set(self.nodes[0].getrawmempool()) assert_equal(x_mempool, set(x_txids)) + assert_equal(set(self.nodes[1].getrawmempool()), set(x_txids)) + + blocks = [] + + # Mine block H - 4. After this, the mempool expects + # block H - 3, which is an X block. + self.nodes[0].generate(1) + self.sync_all() + blocks.append(self.nodes[0].getblock(self.nodes[0].getbestblockhash())['tx']) + + # mempool should not be empty. + assert_true(len(set(self.nodes[0].getrawmempool())) > 0) + assert_true(len(set(self.nodes[1].getrawmempool())) > 0) + + # Mine block H - 3. After this, the mempool expects + # block H - 2, which is an X block. + self.nodes[0].generate(1) + self.sync_all() + blocks.append(self.nodes[0].getblock(self.nodes[0].getbestblockhash())['tx']) + + # mempool should not be empty. + assert_true(len(set(self.nodes[0].getrawmempool())) > 0) + assert_true(len(set(self.nodes[1].getrawmempool())) > 0) + + # Mine block H - 2. After this, the mempool expects + # block H - 1, which is an X block. + self.nodes[0].generate(1) + self.sync_all() + blocks.append(self.nodes[0].getblock(self.nodes[0].getbestblockhash())['tx']) + + # mempool should not be empty. + assert_true(len(set(self.nodes[0].getrawmempool())) > 0) + assert_true(len(set(self.nodes[1].getrawmempool())) > 0) # Mine block H - 1. After this, the mempool expects # block H, which is the first Y block. self.nodes[0].generate(1) self.sync_all() + blocks.append(self.nodes[0].getblock(self.nodes[0].getbestblockhash())['tx']) # mempool should be empty. assert_equal(set(self.nodes[0].getrawmempool()), set()) + assert_equal(set(self.nodes[1].getrawmempool()), set()) - # When transitioning from Sprout to Overwinter, where expiring soon threshold does not apply: - # Block H - 1 should contain a subset of the original mempool + # Blocks [H - 4..H - 1] should contain a subset of the original mempool # (with all other transactions having been dropped) - block_txids = self.nodes[0].getblock(self.nodes[0].getbestblockhash())['tx'] - if chaintip_branchid is "00000000": - assert(len(block_txids) < len(x_txids)) + assert(sum([len(block_txids) for block_txids in blocks]) < len(x_txids)) + for block_txids in blocks: for txid in block_txids[1:]: # Exclude coinbase assert(txid in x_txids) @@ -120,6 +143,7 @@ def nu_activation_checks(): # Spends should be in the mempool assert_equal(set(self.nodes[0].getrawmempool()), set(y_txids)) + assert_equal(set(self.nodes[1].getrawmempool()), set(y_txids)) # Node 0 note should be unspendable assert_equal(self.nodes[0].z_getbalance(node0_zaddr), Decimal('0')) @@ -138,6 +162,9 @@ def nu_activation_checks(): #assert_equal(set(self.nodes[0].getrawmempool()), set(block_txids[1:])) assert_equal(set(self.nodes[0].getrawmempool()), set()) + # Node 1's mempool is unaffected because it still considers block H - 1 valid. + assert_equal(set(self.nodes[1].getrawmempool()), set(y_txids)) + # Node 0 note should be spendable again assert_equal(self.nodes[0].z_getbalance(node0_zaddr), Decimal('10')) @@ -149,25 +176,10 @@ def nu_activation_checks(): self.nodes[1].generate(6) self.sync_all() - print('Testing Sprout -> Overwinter activation boundary') - # Current height = 197 - nu_activation_checks() - # Current height = 205 - - self.nodes[0].generate(2) - self.sync_all() - - print('Testing Overwinter -> Sapling activation boundary') - # Current height = 207 - nu_activation_checks() - # Current height = 215 - self.nodes[0].generate(2) - self.sync_all() - print('Testing Sapling -> Blossom activation boundary') - # Current height = 217 + # Current height = 195 nu_activation_checks() - # Current height = 225 + # Current height = 205 if __name__ == '__main__': MempoolUpgradeActivationTest().main() diff --git a/qa/rpc-tests/mempool_tx_expiry.py b/qa/rpc-tests/mempool_tx_expiry.py index 7d66fd0e9..12eabb2ac 100755 --- a/qa/rpc-tests/mempool_tx_expiry.py +++ b/qa/rpc-tests/mempool_tx_expiry.py @@ -4,7 +4,7 @@ # file COPYING or https://www.opensource.org/licenses/mit-license.php . # -# Test proper expiry for transactions >= version 3 +# Test proper expiry for transactions >= version 4 # import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x." @@ -17,7 +17,6 @@ from decimal import Decimal -SAPLING_ACTIVATION_HEIGHT = 300 TX_EXPIRING_SOON_THRESHOLD = 3 TX_EXPIRY_DELTA = 10 @@ -26,8 +25,6 @@ class MempoolTxExpiryTest(BitcoinTestFramework): def setup_nodes(self): return start_nodes(4, self.options.tmpdir, [[ - "-nuparams=5ba81b19:205", # Overwinter - "-nuparams=76b809bb:%d" % SAPLING_ACTIVATION_HEIGHT, # Sapling "-txexpirydelta=%d" % TX_EXPIRY_DELTA, "-debug=mempool" ]] * 4) @@ -40,22 +37,13 @@ def run_test(self): bob = self.nodes[2].getnewaddress() z_bob = self.nodes[2].z_getnewaddress('sapling') - # When Overwinter not yet activated, no expiryheight in tx - tx = self.nodes[0].sendtoaddress(bob, 0.01) - rawtx = self.nodes[0].getrawtransaction(tx, 1) - assert_equal(rawtx["overwintered"], False) - assert("expiryheight" not in rawtx) - - self.nodes[0].generate(6) - self.sync_all() - print "Splitting network..." self.split_network() - # When Overwinter is activated, test dependent txs + # Test dependent txs firstTx = self.nodes[0].sendtoaddress(alice, 0.1) firstTxInfo = self.nodes[0].getrawtransaction(firstTx, 1) - assert_equal(firstTxInfo["version"], 3) + assert_equal(firstTxInfo["version"], 4) assert_equal(firstTxInfo["overwintered"], True) assert("expiryheight" in firstTxInfo) print "First tx expiry height:", firstTxInfo['expiryheight'] @@ -88,12 +76,6 @@ def run_test(self): assert_equal(set(self.nodes[0].getrawmempool()), set()) assert_equal(set(self.nodes[2].getrawmempool()), set()) - # Activate Sapling - n = SAPLING_ACTIVATION_HEIGHT - self.nodes[0].getblockcount() - assert(n > 0) - self.nodes[0].generate(n) - self.sync_all() - ## Shield one of Alice's coinbase funds to her zaddr res = self.nodes[0].z_shieldcoinbase("*", z_alice, 0.0001, 1) wait_and_assert_operationid_status(self.nodes[0], res['opid']) diff --git a/qa/rpc-tests/mempool_tx_input_limit.py b/qa/rpc-tests/mempool_tx_input_limit.py deleted file mode 100755 index 0e9ea786a..000000000 --- a/qa/rpc-tests/mempool_tx_input_limit.py +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2017 The Zcash developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or https://www.opensource.org/licenses/mit-license.php . - -import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x." - -from test_framework.test_framework import BitcoinTestFramework -from test_framework.authproxy import JSONRPCException -from test_framework.util import assert_equal, initialize_chain_clean, \ - start_node, connect_nodes, wait_and_assert_operationid_status, \ - get_coinbase_address - -from decimal import Decimal - -# Test -mempooltxinputlimit -class MempoolTxInputLimitTest(BitcoinTestFramework): - - alert_filename = None # Set by setup_network - - def setup_network(self): - args = ["-checkmempool", "-debug=mempool", "-mempooltxinputlimit=2", "-nuparams=5ba81b19:110"] - self.nodes = [] - self.nodes.append(start_node(0, self.options.tmpdir, args)) - self.nodes.append(start_node(1, self.options.tmpdir, args)) - connect_nodes(self.nodes[1], 0) - self.is_network_split = False - self.sync_all - - def setup_chain(self): - print "Initializing test directory "+self.options.tmpdir - initialize_chain_clean(self.options.tmpdir, 2) - - def call_z_sendmany(self, from_addr, to_addr, amount): - recipients = [] - recipients.append({"address": to_addr, "amount": amount}) - myopid = self.nodes[0].z_sendmany(from_addr, recipients) - return wait_and_assert_operationid_status(self.nodes[0], myopid) - - def run_test(self): - self.nodes[0].generate(100) - self.sync_all() - # Mine three blocks. After this, nodes[0] blocks - # 1, 2, and 3 are spend-able. - self.nodes[1].generate(3) - self.sync_all() - - # Check 1: z_sendmany is limited by -mempooltxinputlimit - - # Add zaddr to node 0 - node0_zaddr = self.nodes[0].z_getnewaddress('sprout') - - # Send three inputs from node 0 taddr to zaddr to get out of coinbase - node0_taddr = get_coinbase_address(self.nodes[0]) - recipients = [] - recipients.append({"address":node0_zaddr, "amount":Decimal('37500.0')-Decimal('0.0001')}) # utxo amount less fee - myopid = self.nodes[0].z_sendmany(node0_taddr, recipients) - - # Spend should fail due to -mempooltxinputlimit - wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "Too many transparent inputs 3 > limit 2", 120) - - # Mempool should be empty. - assert_equal(set(self.nodes[0].getrawmempool()), set()) - - # Reduce amount to only use two inputs - spend_zaddr_amount = Decimal('25000.0') - Decimal('0.0001') - spend_zaddr_id = self.call_z_sendmany(node0_taddr, node0_zaddr, spend_zaddr_amount) # utxo amount less fee - self.sync_all() - - # Spend should be in the mempool - assert_equal(set(self.nodes[0].getrawmempool()), set([ spend_zaddr_id ])) - - self.nodes[0].generate(1) - self.sync_all() - - # mempool should be empty. - assert_equal(set(self.nodes[0].getrawmempool()), set()) - - # Check 2: sendfrom is limited by -mempooltxinputlimit - recipients = [] - spend_taddr_amount = spend_zaddr_amount - Decimal('0.0001') - spend_taddr_output = Decimal('8') - - # Create three outputs - recipients.append({"address":self.nodes[1].getnewaddress(), "amount": spend_taddr_output}) - recipients.append({"address":self.nodes[1].getnewaddress(), "amount": spend_taddr_output}) - recipients.append({"address":self.nodes[1].getnewaddress(), "amount": spend_taddr_amount - spend_taddr_output - spend_taddr_output}) - - myopid = self.nodes[0].z_sendmany(node0_zaddr, recipients) - wait_and_assert_operationid_status(self.nodes[0], myopid) - self.sync_all() - self.nodes[1].generate(1) - self.sync_all() - - # Should use three UTXOs and fail - try: - self.nodes[1].sendfrom("", node0_taddr, spend_taddr_amount - Decimal('1')) - assert(False) - except JSONRPCException,e: - msg = e.error['message'] - assert_equal("Too many transparent inputs 3 > limit 2", msg) - - # mempool should be empty. - assert_equal(set(self.nodes[1].getrawmempool()), set()) - - # Should use two UTXOs and succeed - spend_taddr_id2 = self.nodes[1].sendfrom("", node0_taddr, spend_taddr_output + spend_taddr_output - Decimal('1')) - - # Spend should be in the mempool - assert_equal(set(self.nodes[1].getrawmempool()), set([ spend_taddr_id2 ])) - - # Mine three blocks - self.nodes[1].generate(3) - self.sync_all() - # The next block to be mined, 109, is the last Sprout block - bci = self.nodes[0].getblockchaininfo() - assert_equal(bci['consensus']['chaintip'], '00000000') - assert_equal(bci['consensus']['nextblock'], '00000000') - - # z_sendmany should be limited by -mempooltxinputlimit - recipients = [] - recipients.append({"address":node0_zaddr, "amount":Decimal('30.0')-Decimal('0.0001')}) # utxo amount less fee - myopid = self.nodes[0].z_sendmany(node0_taddr, recipients) - wait_and_assert_operationid_status(self.nodes[0], myopid, 'failed', 'Too many transparent inputs 3 > limit 2') - - # Mine one block - self.nodes[1].generate(1) - self.sync_all() - # The next block to be mined, 110, is the first Overwinter block - bci = self.nodes[0].getblockchaininfo() - assert_equal(bci['consensus']['chaintip'], '00000000') - assert_equal(bci['consensus']['nextblock'], '5ba81b19') - - # z_sendmany should no longer be limited by -mempooltxinputlimit - myopid = self.nodes[0].z_sendmany(node0_taddr, recipients) - wait_and_assert_operationid_status(self.nodes[0], myopid) - -if __name__ == '__main__': - MempoolTxInputLimitTest().main() diff --git a/qa/rpc-tests/mergetoaddress_helper.py b/qa/rpc-tests/mergetoaddress_helper.py index 346b3c7fd..7d0538d5c 100755 --- a/qa/rpc-tests/mergetoaddress_helper.py +++ b/qa/rpc-tests/mergetoaddress_helper.py @@ -27,7 +27,7 @@ def assert_mergetoaddress_exception(expected_error_msg, merge_to_address_lambda) class MergeToAddressHelper: - def __init__(self, addr_type, any_zaddr, utxos_to_generate, utxos_in_tx1, utxos_in_tx2, test_mempooltxinputlimit): + def __init__(self, addr_type, any_zaddr, utxos_to_generate, utxos_in_tx1, utxos_in_tx2): self.addr_type = addr_type self.any_zaddr = [any_zaddr] self.any_zaddr_or_utxo = [any_zaddr, "ANY_TADDR"] @@ -35,7 +35,6 @@ def __init__(self, addr_type, any_zaddr, utxos_to_generate, utxos_in_tx1, utxos_ self.utxos_to_generate = utxos_to_generate self.utxos_in_tx1 = utxos_in_tx1 self.utxos_in_tx2 = utxos_in_tx2 - self.test_mempooltxinputlimit = test_mempooltxinputlimit def setup_chain(self, test): print("Initializing test directory "+test.options.tmpdir) @@ -283,16 +282,10 @@ def run_test(self, test): test.nodes[1].generate(1) test.sync_all() - # Verify maximum number of UTXOs which node 2 can shield is limited by option -mempooltxinputlimit - # This option is used when the limit parameter is set to 0. - - # -mempooltxinputlimit is not used after overwinter activation - if self.test_mempooltxinputlimit: - expected_to_merge = 7 - expected_remaining = 13 - else: - expected_to_merge = 20 - expected_remaining = 0 + # Verify maximum number of UTXOs which node 2 can shield is not limited + # when the limit parameter is set to 0. + expected_to_merge = 20 + expected_remaining = 0 result = test.nodes[2].z_mergetoaddress([n2taddr], myzaddr, Decimal('0.0001'), 0) assert_equal(result["mergingUTXOs"], expected_to_merge) diff --git a/qa/rpc-tests/mergetoaddress_mixednotes.py b/qa/rpc-tests/mergetoaddress_mixednotes.py index 1aa59db97..c0b511d65 100755 --- a/qa/rpc-tests/mergetoaddress_mixednotes.py +++ b/qa/rpc-tests/mergetoaddress_mixednotes.py @@ -16,8 +16,6 @@ class MergeToAddressMixedNotes(BitcoinTestFramework): def setup_nodes(self): return start_nodes(4, self.options.tmpdir, [[ - '-nuparams=5ba81b19:100', # Overwinter - '-nuparams=76b809bb:100', # Sapling '-experimentalfeatures', '-zmergetoaddress' ]] * 4) diff --git a/qa/rpc-tests/mergetoaddress_sapling.py b/qa/rpc-tests/mergetoaddress_sapling.py index 72ca6929a..9c3c96e13 100755 --- a/qa/rpc-tests/mergetoaddress_sapling.py +++ b/qa/rpc-tests/mergetoaddress_sapling.py @@ -12,16 +12,13 @@ class MergeToAddressSapling (BitcoinTestFramework): # 13505 would be the maximum number of utxos based on the transaction size limits for Sapling # but testing this causes the test to take an indeterminately long time to run. - helper = MergeToAddressHelper('sapling', 'ANY_SAPLING', 800, 800, 0, False) + helper = MergeToAddressHelper('sapling', 'ANY_SAPLING', 800, 800, 0) def setup_chain(self): self.helper.setup_chain(self) def setup_network(self, split=False): - self.helper.setup_network(self, [ - '-nuparams=5ba81b19:100', # Overwinter - '-nuparams=76b809bb:100', # Sapling - ]) + self.helper.setup_network(self) def run_test(self): self.helper.run_test(self) diff --git a/qa/rpc-tests/mergetoaddress_sprout.py b/qa/rpc-tests/mergetoaddress_sprout.py index 8d3e2cbec..669606c1e 100755 --- a/qa/rpc-tests/mergetoaddress_sprout.py +++ b/qa/rpc-tests/mergetoaddress_sprout.py @@ -10,7 +10,9 @@ class MergeToAddressSprout (BitcoinTestFramework): - helper = MergeToAddressHelper('sprout', 'ANY_SPROUT', 800, 662, 138, True) + # 13505 would be the maximum number of utxos based on the transaction size limits for Sapling + # but testing this causes the test to take an indeterminately long time to run. + helper = MergeToAddressHelper('sprout', 'ANY_SPROUT', 800, 800, 0) def setup_chain(self): self.helper.setup_chain(self) diff --git a/qa/rpc-tests/p2p_node_bloom.py b/qa/rpc-tests/p2p_node_bloom.py index dd8709c04..7c5a07b23 100755 --- a/qa/rpc-tests/p2p_node_bloom.py +++ b/qa/rpc-tests/p2p_node_bloom.py @@ -6,7 +6,7 @@ import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x." from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \ - msg_filteradd, msg_filterclear, mininode_lock, SPROUT_PROTO_VERSION + msg_filteradd, msg_filterclear, mininode_lock, SAPLING_PROTO_VERSION from test_framework.test_framework import BitcoinTestFramework from test_framework.util import initialize_chain_clean, start_nodes, \ p2p_port, assert_equal @@ -74,10 +74,10 @@ def run_test(self): # Verify mininodes are connected to zcashd nodes peerinfo = self.nodes[0].getpeerinfo() versions = [x["version"] for x in peerinfo] - assert_equal(1, versions.count(SPROUT_PROTO_VERSION)) + assert_equal(1, versions.count(SAPLING_PROTO_VERSION)) peerinfo = self.nodes[1].getpeerinfo() versions = [x["version"] for x in peerinfo] - assert_equal(1, versions.count(SPROUT_PROTO_VERSION)) + assert_equal(1, versions.count(SAPLING_PROTO_VERSION)) # Mininodes send filterclear message to zcashd node. nobf_node.send_message(msg_filterclear()) @@ -88,10 +88,10 @@ def run_test(self): # Verify mininodes are still connected to zcashd nodes peerinfo = self.nodes[0].getpeerinfo() versions = [x["version"] for x in peerinfo] - assert_equal(1, versions.count(SPROUT_PROTO_VERSION)) + assert_equal(1, versions.count(SAPLING_PROTO_VERSION)) peerinfo = self.nodes[1].getpeerinfo() versions = [x["version"] for x in peerinfo] - assert_equal(1, versions.count(SPROUT_PROTO_VERSION)) + assert_equal(1, versions.count(SAPLING_PROTO_VERSION)) # Mininodes send filteradd message to zcashd node. nobf_node.send_message(msg_filteradd()) @@ -102,10 +102,10 @@ def run_test(self): # Verify NoBF mininode has been dropped, and BF mininode is still connected. peerinfo = self.nodes[0].getpeerinfo() versions = [x["version"] for x in peerinfo] - assert_equal(0, versions.count(SPROUT_PROTO_VERSION)) + assert_equal(0, versions.count(SAPLING_PROTO_VERSION)) peerinfo = self.nodes[1].getpeerinfo() versions = [x["version"] for x in peerinfo] - assert_equal(1, versions.count(SPROUT_PROTO_VERSION)) + assert_equal(1, versions.count(SAPLING_PROTO_VERSION)) [ c.disconnect_node() for c in connections ] diff --git a/qa/rpc-tests/p2p_txexpiringsoon.py b/qa/rpc-tests/p2p_txexpiringsoon.py index bd631a5ad..01fd90768 100755 --- a/qa/rpc-tests/p2p_txexpiringsoon.py +++ b/qa/rpc-tests/p2p_txexpiringsoon.py @@ -7,7 +7,7 @@ from test_framework.authproxy import JSONRPCException from test_framework.mininode import NodeConn, NetworkThread, CInv, \ - msg_mempool, msg_getdata, msg_tx, mininode_lock, OVERWINTER_PROTO_VERSION + msg_mempool, msg_getdata, msg_tx, mininode_lock, SAPLING_PROTO_VERSION from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, connect_nodes_bi, fail, \ initialize_chain_clean, p2p_port, start_nodes, sync_blocks, sync_mempools @@ -23,8 +23,7 @@ def setup_chain(self): initialize_chain_clean(self.options.tmpdir, 3) def setup_network(self): - self.nodes = start_nodes(3, self.options.tmpdir, - extra_args=[['-nuparams=5ba81b19:10']] * 3) + self.nodes = start_nodes(3, self.options.tmpdir) connect_nodes_bi(self.nodes, 0, 1) # We don't connect node 2 @@ -85,7 +84,7 @@ def run_test(self): testnode0 = TestNode() connections = [] connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], - testnode0, "regtest", OVERWINTER_PROTO_VERSION)) + testnode0, "regtest", SAPLING_PROTO_VERSION)) testnode0.add_connection(connections[0]) # Start up network handling in another thread @@ -95,7 +94,7 @@ def run_test(self): # Verify mininodes are connected to zcashd nodes peerinfo = self.nodes[0].getpeerinfo() versions = [x["version"] for x in peerinfo] - assert_equal(1, versions.count(OVERWINTER_PROTO_VERSION)) + assert_equal(1, versions.count(SAPLING_PROTO_VERSION)) assert_equal(0, peerinfo[0]["banscore"]) # Mine some blocks so we can spend @@ -150,7 +149,7 @@ def run_test(self): # Set up test node for node 2 testnode2 = TestNode() connections.append(NodeConn('127.0.0.1', p2p_port(2), self.nodes[2], - testnode2, "regtest", OVERWINTER_PROTO_VERSION)) + testnode2, "regtest", SAPLING_PROTO_VERSION)) testnode2.add_connection(connections[-1]) # Verify block count diff --git a/qa/rpc-tests/p2p_txexpiry_dos.py b/qa/rpc-tests/p2p_txexpiry_dos.py index e51bf2cb6..633f00284 100755 --- a/qa/rpc-tests/p2p_txexpiry_dos.py +++ b/qa/rpc-tests/p2p_txexpiry_dos.py @@ -6,7 +6,7 @@ import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x." from test_framework.mininode import NodeConn, NetworkThread, \ - msg_tx, OVERWINTER_PROTO_VERSION + msg_tx, SAPLING_PROTO_VERSION from test_framework.test_framework import BitcoinTestFramework from test_framework.util import initialize_chain_clean, start_nodes, \ p2p_port, assert_equal @@ -22,15 +22,14 @@ def setup_chain(self): initialize_chain_clean(self.options.tmpdir, 1) def setup_network(self): - self.nodes = start_nodes(1, self.options.tmpdir, - extra_args=[['-nuparams=5ba81b19:10']]) + self.nodes = start_nodes(1, self.options.tmpdir) def run_test(self): test_node = TestNode() connections = [] connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], - test_node, "regtest", OVERWINTER_PROTO_VERSION)) + test_node, "regtest", SAPLING_PROTO_VERSION)) test_node.add_connection(connections[0]) # Start up network handling in another thread @@ -41,7 +40,7 @@ def run_test(self): # Verify mininodes are connected to zcashd nodes peerinfo = self.nodes[0].getpeerinfo() versions = [x["version"] for x in peerinfo] - assert_equal(1, versions.count(OVERWINTER_PROTO_VERSION)) + assert_equal(1, versions.count(SAPLING_PROTO_VERSION)) assert_equal(0, peerinfo[0]["banscore"]) coinbase_blocks = self.nodes[0].generate(1) @@ -62,7 +61,7 @@ def run_test(self): # and still has a banscore of 0. peerinfo = self.nodes[0].getpeerinfo() versions = [x["version"] for x in peerinfo] - assert_equal(1, versions.count(OVERWINTER_PROTO_VERSION)) + assert_equal(1, versions.count(SAPLING_PROTO_VERSION)) assert_equal(0, peerinfo[0]["banscore"]) # Mine a block and resend the transaction @@ -75,7 +74,7 @@ def run_test(self): # but has a banscore of 10. peerinfo = self.nodes[0].getpeerinfo() versions = [x["version"] for x in peerinfo] - assert_equal(1, versions.count(OVERWINTER_PROTO_VERSION)) + assert_equal(1, versions.count(SAPLING_PROTO_VERSION)) assert_equal(10, peerinfo[0]["banscore"]) [c.disconnect_node() for c in connections] diff --git a/qa/rpc-tests/rawtransactions.py b/qa/rpc-tests/rawtransactions.py index 6deaafad1..0dd779183 100755 --- a/qa/rpc-tests/rawtransactions.py +++ b/qa/rpc-tests/rawtransactions.py @@ -132,7 +132,7 @@ def run_test(self): break; bal = self.nodes[0].getbalance() - inputs = [{ "txid" : txId, "vout" : vout['n'], "scriptPubKey" : vout['scriptPubKey']['hex']}] + inputs = [{ "txid" : txId, "vout" : vout['n'], "scriptPubKey" : vout['scriptPubKey']['hex'], "amount" : vout['value']}] outputs = { self.nodes[0].getnewaddress() : 2.199 } rawTx = self.nodes[2].createrawtransaction(inputs, outputs) rawTxPartialSigned = self.nodes[1].signrawtransaction(rawTx, inputs) diff --git a/qa/rpc-tests/regtest_signrawtransaction.py b/qa/rpc-tests/regtest_signrawtransaction.py index 4b2b524bc..acdba0397 100755 --- a/qa/rpc-tests/regtest_signrawtransaction.py +++ b/qa/rpc-tests/regtest_signrawtransaction.py @@ -6,16 +6,10 @@ import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x." from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import start_nodes, wait_and_assert_operationid_status +from test_framework.util import wait_and_assert_operationid_status class RegtestSignrawtransactionTest (BitcoinTestFramework): - def setup_nodes(self): - return start_nodes(4, self.options.tmpdir, [[ - "-nuparams=5ba81b19:200", # Overwinter - "-nuparams=76b809bb:206", # Sapling - ]] * 4) - def run_test(self): self.nodes[0].generate(1) self.sync_all() @@ -26,7 +20,7 @@ def run_test(self): self.nodes[0].generate(1) self.sync_all() - # Create and sign Overwinter transaction. + # Create and sign Sapling transaction. # If the incorrect consensus branch id is selected, there will be a signing error. opid = self.nodes[1].z_sendmany(taddr, [{'address': zaddr1, 'amount': 1}]) diff --git a/qa/rpc-tests/rewind_index.py b/qa/rpc-tests/rewind_index.py index 9a30f393c..14ad3f86a 100755 --- a/qa/rpc-tests/rewind_index.py +++ b/qa/rpc-tests/rewind_index.py @@ -11,6 +11,8 @@ import time +FAKE_SPROUT = ['-nuparams=5ba81b19:210', '-nuparams=76b809bb:220'] +FAKE_OVERWINTER = ['-nuparams=5ba81b19:10', '-nuparams=76b809bb:220'] class RewindBlockIndexTest (BitcoinTestFramework): @@ -22,7 +24,11 @@ def setup_network(self, split=False): # Node 0 - Overwinter, then Sprout, then Overwinter again # Node 1 - Sprout # Node 2 - Overwinter - self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[['-nuparams=5ba81b19:10'], [], ['-nuparams=5ba81b19:10']]) + self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[ + FAKE_OVERWINTER, + FAKE_SPROUT, + FAKE_OVERWINTER, + ]) connect_nodes_bi(self.nodes,0,1) connect_nodes_bi(self.nodes,1,2) connect_nodes_bi(self.nodes,0,2) @@ -52,7 +58,7 @@ def run_test (self): print("Switching node 0 from Overwinter to Sprout") self.nodes[0].stop() bitcoind_processes[0].wait() - self.nodes[0] = start_node(0,self.options.tmpdir) + self.nodes[0] = start_node(0, self.options.tmpdir, extra_args=FAKE_SPROUT) connect_nodes_bi(self.nodes,0,1) connect_nodes_bi(self.nodes,1,2) connect_nodes_bi(self.nodes,0,2) @@ -69,7 +75,7 @@ def run_test (self): print("Switching node 0 from Sprout to Overwinter") self.nodes[0].stop() bitcoind_processes[0].wait() - self.nodes[0] = start_node(0,self.options.tmpdir, extra_args=['-nuparams=5ba81b19:10']) + self.nodes[0] = start_node(0, self.options.tmpdir, extra_args=FAKE_OVERWINTER) connect_nodes_bi(self.nodes,0,1) connect_nodes_bi(self.nodes,1,2) connect_nodes_bi(self.nodes,0,2) diff --git a/qa/rpc-tests/signrawtransaction_offline.py b/qa/rpc-tests/signrawtransaction_offline.py index a4478c3c4..f2e498815 100755 --- a/qa/rpc-tests/signrawtransaction_offline.py +++ b/qa/rpc-tests/signrawtransaction_offline.py @@ -13,7 +13,7 @@ def setup_chain(self): initialize_chain_clean(self.options.tmpdir, 2) def setup_network(self): - self.nodes = [ start_node(0, self.options.tmpdir, ["-nuparams=5ba81b19:10"]) ] + self.nodes = [ start_node(0, self.options.tmpdir, ["-nuparams=2bb40e60:10"]) ] self.is_network_split = False self.sync_all() @@ -22,7 +22,7 @@ def run_test(self): print "Mining blocks..." self.nodes[0].generate(101) - offline_node = start_node(1, self.options.tmpdir, ["-maxconnections=0", "-nuparams=5ba81b19:10"]) + offline_node = start_node(1, self.options.tmpdir, ["-maxconnections=0", "-nuparams=2bb40e60:10"]) self.nodes.append(offline_node) assert_equal(0, len(offline_node.getpeerinfo())) # make sure node 1 has no peers @@ -49,11 +49,11 @@ def run_test(self): pass # Passing in the consensus branch id resolves the issue for offline regtest nodes. - signed_tx = offline_node.signrawtransaction(create_hex, sign_inputs, privkeys, "ALL", "5ba81b19") + signed_tx = offline_node.signrawtransaction(create_hex, sign_inputs, privkeys, "ALL", "2bb40e60") # If we return the transaction hash, then we have have not thrown an error (success) online_tx_hash = self.nodes[0].sendrawtransaction(signed_tx['hex']) assert_true(len(online_tx_hash) > 0) if __name__ == '__main__': - SignOfflineTest().main() \ No newline at end of file + SignOfflineTest().main() diff --git a/qa/rpc-tests/sprout_sapling_migration.py b/qa/rpc-tests/sprout_sapling_migration.py index 29d045e9f..4940258d7 100755 --- a/qa/rpc-tests/sprout_sapling_migration.py +++ b/qa/rpc-tests/sprout_sapling_migration.py @@ -52,10 +52,7 @@ def check_migration_status(node, destination_address, migration_state): class SproutSaplingMigration(BitcoinTestFramework): def setup_nodes(self): - # Activate overwinter/sapling on all nodes extra_args = [[ - '-nuparams=5ba81b19:100', # Overwinter - '-nuparams=76b809bb:100', # Sapling ]] * 4 # Add migration parameters to nodes[0] extra_args[0] = extra_args[0] + [ @@ -63,8 +60,8 @@ def setup_nodes(self): '-migrationdestaddress=' + SAPLING_ADDR, '-debug=zrpcunsafe' ] - assert_equal(5, len(extra_args[0])) - assert_equal(2, len(extra_args[1])) + assert_equal(3, len(extra_args[0])) + assert_equal(0, len(extra_args[1])) return start_nodes(4, self.options.tmpdir, extra_args) def setup_chain(self): diff --git a/qa/rpc-tests/test_framework/blocktools.py b/qa/rpc-tests/test_framework/blocktools.py index e1b4321de..0a4baa161 100644 --- a/qa/rpc-tests/test_framework/blocktools.py +++ b/qa/rpc-tests/test_framework/blocktools.py @@ -8,7 +8,7 @@ from script import CScript, OP_0, OP_EQUAL, OP_HASH160 # Create a block (with regtest difficulty) -def create_block(hashprev, coinbase, nTime=None, nBits=None): +def create_block(hashprev, coinbase, nTime=None, nBits=None, hashFinalSaplingRoot=None): block = CBlock() if nTime is None: import time @@ -16,6 +16,8 @@ def create_block(hashprev, coinbase, nTime=None, nBits=None): else: block.nTime = nTime block.hashPrevBlock = hashprev + if hashFinalSaplingRoot is not None: + block.hashFinalSaplingRoot = hashFinalSaplingRoot if nBits is None: block.nBits = 0x200f0f0f # Will break after a difficulty adjustment... else: diff --git a/qa/rpc-tests/test_framework/mininode.py b/qa/rpc-tests/test_framework/mininode.py index 5e3c25d3d..b338435b8 100755 --- a/qa/rpc-tests/test_framework/mininode.py +++ b/qa/rpc-tests/test_framework/mininode.py @@ -355,8 +355,72 @@ def serialize(self): return r def __repr__(self): - return "CBlockLocator(nVersion=%i vHave=%s)" \ - % (self.nVersion, repr(self.vHave)) + return "CBlockLocator(nVersion=%i vHave=%r)" \ + % (self.nVersion, self.vHave) + + +class SpendDescription(object): + def __init__(self): + self.cv = None + self.anchor = None + self.nullifier = None + self.rk = None + self.zkproof = None + self.spendAuthSig = None + + def deserialize(self, f): + self.cv = deser_uint256(f) + self.anchor = deser_uint256(f) + self.nullifier = deser_uint256(f) + self.rk = deser_uint256(f) + self.zkproof = f.read(192) + self.spendAuthSig = f.read(64) + + def serialize(self): + r = "" + r += ser_uint256(self.cv) + r += ser_uint256(self.anchor) + r += ser_uint256(self.nullifier) + r += ser_uint256(self.rk) + r += self.zkproof + r += self.spendAuthSig + return r + + def __repr__(self): + return "SpendDescription(cv=%064x, anchor=%064x, nullifier=%064x, rk=%064x, zkproof=%064x, spendAuthSig=%064x)" \ + % (self.cv, self.anchor, self.nullifier, self.rk, self.zkproof, self.spendauthsig) + + +class OutputDescription(object): + def __init__(self): + self.cv = None + self.cmu = None + self.ephemeralKey = None + self.encCiphertext = None + self.outCiphertext = None + self.zkproof = None + + def deserialize(self, f): + self.cv = deser_uint256(f) + self.cmu = deser_uint256(f) + self.ephemeralKey = deser_uint256(f) + self.encCiphertext = f.read(580) + self.outCiphertext = f.read(80) + self.zkproof = f.read(192) + + def serialize(self): + r = "" + r += ser_uint256(self.cv) + r += ser_uint256(self.cmu) + r += ser_uint256(self.ephemeralKey) + r += self.encCiphertext + r += self.outCiphertext + r += self.zkproof + return r + + def __repr__(self): + return "OutputDescription(cv=%064x, cmu=%064x, ephemeralKey=%064x, encCiphertext=%064x, outCiphertext=%064x, zkproof=%064x)" \ + % (self.cv, self.cmu, self.ephemeralKey, self.encCiphertext, self.outCiphertext, self.zkproof) G1_PREFIX_MASK = 0x02 @@ -412,11 +476,11 @@ def ser_g2(self, p): return r def __repr__(self): - return "ZCProof(g_A=%s g_A_prime=%s g_B=%s g_B_prime=%s g_C=%s g_C_prime=%s g_K=%s g_H=%s)" \ - % (repr(self.g_A), repr(self.g_A_prime), - repr(self.g_B), repr(self.g_B_prime), - repr(self.g_C), repr(self.g_C_prime), - repr(self.g_K), repr(self.g_H)) + return "ZCProof(g_A=%r g_A_prime=%r g_B=%r g_B_prime=%r g_C=%r g_C_prime=%r g_K=%r g_H=%r)" \ + % (self.g_A, self.g_A_prime, + self.g_B, self.g_B_prime, + self.g_C, self.g_C_prime, + self.g_K, self.g_H) ZC_NUM_JS_INPUTS = 2 @@ -502,9 +566,9 @@ def serialize(self): return r def __repr__(self): - return "JSDescription(vpub_old=%i.%08i vpub_new=%i.%08i anchor=%064x onetimePubKey=%064x randomSeed=%064x proof=%s)" \ + return "JSDescription(vpub_old=%i.%08i vpub_new=%i.%08i anchor=%064x onetimePubKey=%064x randomSeed=%064x proof=%r)" \ % (self.vpub_old, self.vpub_new, self.anchor, - self.onetimePubKey, self.randomSeed, repr(self.proof)) + self.onetimePubKey, self.randomSeed, self.proof) class COutPoint(object): @@ -549,8 +613,8 @@ def serialize(self): return r def __repr__(self): - return "CTxIn(prevout=%s scriptSig=%s nSequence=%i)" \ - % (repr(self.prevout), binascii.hexlify(self.scriptSig), + return "CTxIn(prevout=%r scriptSig=%s nSequence=%i)" \ + % (self.prevout, binascii.hexlify(self.scriptSig), self.nSequence) @@ -578,16 +642,20 @@ def __repr__(self): class CTransaction(object): def __init__(self, tx=None): if tx is None: - self.fOverwintered = False - self.nVersion = 1 - self.nVersionGroupId = 0 + self.fOverwintered = True + self.nVersion = 4 + self.nVersionGroupId = SAPLING_VERSION_GROUP_ID self.vin = [] self.vout = [] self.nLockTime = 0 self.nExpiryHeight = 0 + self.valueBalance = 0 + self.shieldedSpends = [] + self.shieldedOutputs = [] self.vJoinSplit = [] self.joinSplitPubKey = None self.joinSplitSig = None + self.bindingSig = None self.sha256 = None self.hash = None else: @@ -598,9 +666,13 @@ def __init__(self, tx=None): self.vout = copy.deepcopy(tx.vout) self.nLockTime = tx.nLockTime self.nExpiryHeight = tx.nExpiryHeight + self.valueBalance = tx.valueBalance + self.shieldedSpends = copy.deepcopy(tx.shieldedSpends) + self.shieldedOutputs = copy.deepcopy(tx.shieldedOutputs) self.vJoinSplit = copy.deepcopy(tx.vJoinSplit) self.joinSplitPubKey = tx.joinSplitPubKey self.joinSplitSig = tx.joinSplitSig + self.bindingSig = tx.bindingSig self.sha256 = None self.hash = None @@ -614,19 +686,30 @@ def deserialize(self, f): isOverwinterV3 = (self.fOverwintered and self.nVersionGroupId == OVERWINTER_VERSION_GROUP_ID and self.nVersion == 3) + isSaplingV4 = (self.fOverwintered and + self.nVersionGroupId == SAPLING_VERSION_GROUP_ID and + self.nVersion == 4) self.vin = deser_vector(f, CTxIn) self.vout = deser_vector(f, CTxOut) self.nLockTime = struct.unpack("= 2: self.vJoinSplit = deser_vector(f, JSDescription) if len(self.vJoinSplit) > 0: self.joinSplitPubKey = deser_uint256(f) self.joinSplitSig = f.read(64) + if isSaplingV4 and not (len(self.shieldedSpends) == 0 and len(self.shieldedOutputs) == 0): + self.bindingSig = f.read(64) + self.sha256 = None self.hash = None @@ -635,6 +718,9 @@ def serialize(self): isOverwinterV3 = (self.fOverwintered and self.nVersionGroupId == OVERWINTER_VERSION_GROUP_ID and self.nVersion == 3) + isSaplingV4 = (self.fOverwintered and + self.nVersionGroupId == SAPLING_VERSION_GROUP_ID and + self.nVersion == 4) r = "" r += struct.pack("= 2: r += ser_vector(self.vJoinSplit) if len(self.vJoinSplit) > 0: r += ser_uint256(self.joinSplitPubKey) r += self.joinSplitSig + if isSaplingV4 and not (len(self.shieldedSpends) == 0 and len(self.shieldedOutputs) == 0): + r += self.bindingSig return r def rehash(self): @@ -670,14 +762,18 @@ def is_valid(self): def __repr__(self): r = ("CTransaction(fOverwintered=%r nVersion=%i nVersionGroupId=0x%08x " - "vin=%s vout=%s nLockTime=%i nExpiryHeight=%i" + "vin=%r vout=%r nLockTime=%i nExpiryHeight=%i " + "valueBalance=%i shieldedSpends=%r shieldedOutputs=%r" % (self.fOverwintered, self.nVersion, self.nVersionGroupId, - repr(self.vin), repr(self.vout), self.nLockTime, self.nExpiryHeight)) + self.vin, self.vout, self.nLockTime, self.nExpiryHeight, + self.valueBalance, self.shieldedSpends, self.shieldedOutputs)) if self.nVersion >= 2: - r += " vJoinSplit=%s" % repr(self.vJoinSplit) + r += " vJoinSplit=%r" % (self.vJoinSplit,) if len(self.vJoinSplit) > 0: r += " joinSplitPubKey=%064x joinSplitSig=%064x" \ (self.joinSplitPubKey, self.joinSplitSig) + if len(self.shieldedSpends) > 0 or len(self.shieldedOutputs) > 0: + r += " bindingSig=%064x" % (self.bindingSig,) r += ")" return r @@ -690,7 +786,7 @@ def __init__(self, header=None): self.nVersion = header.nVersion self.hashPrevBlock = header.hashPrevBlock self.hashMerkleRoot = header.hashMerkleRoot - self.hashReserved = header.hashReserved + self.hashFinalSaplingRoot = header.hashFinalSaplingRoot self.nTime = header.nTime self.nBits = header.nBits self.nNonce = header.nNonce @@ -703,7 +799,7 @@ def set_null(self): self.nVersion = 4 self.hashPrevBlock = 0 self.hashMerkleRoot = 0 - self.hashReserved = 0 + self.hashFinalSaplingRoot = 0 self.nTime = 0 self.nBits = 0 self.nNonce = 0 @@ -715,7 +811,7 @@ def deserialize(self, f): self.nVersion = struct.unpack(" 0: args.append("-connect=127.0.0.1:"+str(p2p_port(0))) bitcoind_processes[i] = subprocess.Popen(args) @@ -200,6 +204,10 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= if binary is None: binary = os.getenv("BITCOIND", "bitcoind") args = [ binary, "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ] + args.extend([ + '-nuparams=5ba81b19:1', # Overwinter + '-nuparams=76b809bb:1', # Sapling + ]) if extra_args is not None: args.extend(extra_args) bitcoind_processes[i] = subprocess.Popen(args) devnull = open("/dev/null", "w+") diff --git a/qa/rpc-tests/turnstile.py b/qa/rpc-tests/turnstile.py index 129a91ee5..31451d116 100755 --- a/qa/rpc-tests/turnstile.py +++ b/qa/rpc-tests/turnstile.py @@ -40,8 +40,6 @@ ) from decimal import Decimal -NUPARAMS_ARGS = ['-nuparams=5ba81b19:100', # Overwinter - '-nuparams=76b809bb:101'] # Sapling TURNSTILE_ARGS = ['-experimentalfeatures', '-developersetpoolsizezero'] @@ -52,8 +50,7 @@ def setup_chain(self): initialize_chain_clean(self.options.tmpdir, 3) def setup_network(self, split=False): - self.nodes = start_nodes(3, self.options.tmpdir, - extra_args=[NUPARAMS_ARGS] * 3) + self.nodes = start_nodes(3, self.options.tmpdir) connect_nodes_bi(self.nodes,0,1) connect_nodes_bi(self.nodes,1,2) self.is_network_split=False @@ -70,7 +67,7 @@ def assert_pool_balance(self, node, name, balance): # Helper method to start a single node with extra args and sync to the network def start_and_sync_node(self, index, args=[]): - self.nodes[index] = start_node(index, self.options.tmpdir, extra_args=NUPARAMS_ARGS + args) + self.nodes[index] = start_node(index, self.options.tmpdir, extra_args=args) connect_nodes_bi(self.nodes,0,1) connect_nodes_bi(self.nodes,1,2) connect_nodes_bi(self.nodes,0,2) diff --git a/qa/rpc-tests/wallet.py b/qa/rpc-tests/wallet.py index fcf8ee131..a7709e0a0 100755 --- a/qa/rpc-tests/wallet.py +++ b/qa/rpc-tests/wallet.py @@ -93,7 +93,7 @@ def run_test (self): # Catch an attempt to send a transaction with an absurdly high fee. # Send 1.0 from an utxo of value 10.0 but don't specify a change output, so then - # the change of 9.0 becomes the fee, which is greater than estimated fee of 0.0019. + # the change of 9.0 becomes the fee, which is greater than estimated fee of 0.0021. inputs = [] outputs = {} for utxo in node2utxos: @@ -109,7 +109,7 @@ def run_test (self): except JSONRPCException,e: errorString = e.error['message'] assert("absurdly high fees" in errorString) - assert("900000000 > 190000" in errorString) + assert("900000000 > 210000" in errorString) # create both transactions txns_to_send = [] @@ -287,12 +287,16 @@ def run_test (self): myzaddr = self.nodes[0].z_getnewaddress('sprout') recipients = [] - num_t_recipients = 3000 + num_t_recipients = 1000 + num_z_recipients = 2100 amount_per_recipient = Decimal('0.00000001') errorString = '' for i in xrange(0,num_t_recipients): newtaddr = self.nodes[2].getnewaddress() recipients.append({"address":newtaddr, "amount":amount_per_recipient}) + for i in xrange(0,num_z_recipients): + newzaddr = self.nodes[2].z_getnewaddress('sprout') + recipients.append({"address":newzaddr, "amount":amount_per_recipient}) # Issue #2759 Workaround START # HTTP connection to node 0 may fall into a state, during the few minutes it takes to process @@ -303,47 +307,12 @@ def run_test (self): self.nodes[0].getinfo() # Issue #2759 Workaround END - try: - self.nodes[0].z_sendmany(myzaddr, recipients) - except JSONRPCException,e: - errorString = e.error['message'] - assert("Too many outputs, size of raw transaction" in errorString) - - recipients = [] - num_t_recipients = 2000 - num_z_recipients = 50 - amount_per_recipient = Decimal('0.00000001') - errorString = '' - for i in xrange(0,num_t_recipients): - newtaddr = self.nodes[2].getnewaddress() - recipients.append({"address":newtaddr, "amount":amount_per_recipient}) - for i in xrange(0,num_z_recipients): - newzaddr = self.nodes[2].z_getnewaddress('sprout') - recipients.append({"address":newzaddr, "amount":amount_per_recipient}) - - # Issue #2759 Workaround START - self.nodes[0].getinfo() - # Issue #2759 Workaround END - try: self.nodes[0].z_sendmany(myzaddr, recipients) except JSONRPCException,e: errorString = e.error['message'] assert("size of raw transaction would be larger than limit" in errorString) - recipients = [] - num_z_recipients = 100 - amount_per_recipient = Decimal('0.00000001') - errorString = '' - for i in xrange(0,num_z_recipients): - newzaddr = self.nodes[2].z_getnewaddress('sprout') - recipients.append({"address":newzaddr, "amount":amount_per_recipient}) - try: - self.nodes[0].z_sendmany(myzaddr, recipients) - except JSONRPCException,e: - errorString = e.error['message'] - assert("Invalid parameter, too many zaddr outputs" in errorString) - # add zaddr to node 2 myzaddr = self.nodes[2].z_getnewaddress('sprout') diff --git a/qa/rpc-tests/wallet_addresses.py b/qa/rpc-tests/wallet_addresses.py index c9a6ab7c3..897c7cc5a 100755 --- a/qa/rpc-tests/wallet_addresses.py +++ b/qa/rpc-tests/wallet_addresses.py @@ -6,17 +6,11 @@ import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x." from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, start_nodes +from test_framework.util import assert_equal # Test wallet address behaviour across network upgradesa\ class WalletAddressesTest(BitcoinTestFramework): - def setup_nodes(self): - return start_nodes(4, self.options.tmpdir, [[ - '-nuparams=5ba81b19:202', # Overwinter - '-nuparams=76b809bb:204', # Sapling - ]] * 4) - def run_test(self): def addr_checks(default_type): # Check default type, as well as explicit types @@ -38,41 +32,17 @@ def addr_checks(default_type): # Sanity-check the test harness assert_equal(self.nodes[0].getblockcount(), 200) - # Current height = 200 -> Sprout - # Default address type is Sapling - print "Testing height 200 (Sprout)" - addr_checks('sapling') - - self.nodes[0].generate(1) - self.sync_all() - - # Current height = 201 -> Sprout - # Default address type is Sapling - print "Testing height 201 (Sprout)" - addr_checks('sapling') - - self.nodes[0].generate(1) - self.sync_all() - - # Current height = 202 -> Overwinter - # Default address type is Sapling - print "Testing height 202 (Overwinter)" - addr_checks('sapling') - - self.nodes[0].generate(1) - self.sync_all() - - # Current height = 203 -> Overwinter + # Current height = 200 -> Sapling # Default address type is Sapling - print "Testing height 203 (Overwinter)" + print "Testing height 200 (Sapling)" addr_checks('sapling') self.nodes[0].generate(1) self.sync_all() - # Current height = 204 -> Sapling + # Current height = 201 -> Sapling # Default address type is Sapling - print "Testing height 204 (Sapling)" + print "Testing height 201 (Sapling)" addr_checks('sapling') if __name__ == '__main__': diff --git a/qa/rpc-tests/wallet_listnotes.py b/qa/rpc-tests/wallet_listnotes.py index 9f9b09937..169d4be56 100755 --- a/qa/rpc-tests/wallet_listnotes.py +++ b/qa/rpc-tests/wallet_listnotes.py @@ -9,7 +9,6 @@ from test_framework.util import ( assert_equal, get_coinbase_address, - start_nodes, wait_and_assert_operationid_status, ) @@ -18,29 +17,21 @@ # Test wallet z_listunspent behaviour across network upgrades class WalletListNotes(BitcoinTestFramework): - def setup_nodes(self): - return start_nodes(4, self.options.tmpdir, [[ - '-nuparams=5ba81b19:202', # Overwinter - '-nuparams=76b809bb:214', # Sapling - ]] * 4) - def run_test(self): - # Current height = 200 -> Sprout + # Current height = 200 assert_equal(200, self.nodes[0].getblockcount()) sproutzaddr = self.nodes[0].z_getnewaddress('sprout') - - # test that we can create a sapling zaddr before sapling activates saplingzaddr = self.nodes[0].z_getnewaddress('sapling') # we've got lots of coinbase (taddr) but no shielded funds yet assert_equal(0, Decimal(self.nodes[0].z_gettotalbalance()['private'])) - - # Set current height to 201 -> Sprout + + # Set current height to 201 self.nodes[0].generate(1) self.sync_all() assert_equal(201, self.nodes[0].getblockcount()) - # Shield coinbase funds (must be a multiple of 10, no change allowed pre-sapling) + # Shield coinbase funds (must be a multiple of 10, no change allowed) receive_amount_10 = Decimal('10.0') - Decimal('0.0001') recipients = [{"address":sproutzaddr, "amount":receive_amount_10}] myopid = self.nodes[0].z_sendmany(get_coinbase_address(self.nodes[0]), recipients) @@ -70,8 +61,8 @@ def run_test(self): # Generate a block to confirm shield coinbase tx self.nodes[0].generate(1) self.sync_all() - - # Current height = 202 -> Overwinter. Default address type remains Sprout + + # Current height = 202 assert_equal(202, self.nodes[0].getblockcount()) # Send 1.0 (actually 0.9999) from sproutzaddr to a new zaddr @@ -108,12 +99,7 @@ def run_test(self): unspent_tx_filter = self.nodes[0].z_listunspent(0, 9999, False, [sproutzaddr]) assert_equal(1, len(unspent_tx_filter)) assert_equal(unspent_tx[1], unspent_tx_filter[0]) - - # Set current height to 204 -> Sapling - self.nodes[0].generate(12) - self.sync_all() - assert_equal(214, self.nodes[0].getblockcount()) - + # No funds in saplingzaddr yet assert_equal(0, len(self.nodes[0].z_listunspent(0, 9999, False, [saplingzaddr]))) diff --git a/qa/rpc-tests/wallet_listreceived.py b/qa/rpc-tests/wallet_listreceived.py index 0ab104c64..a3da3d8ef 100755 --- a/qa/rpc-tests/wallet_listreceived.py +++ b/qa/rpc-tests/wallet_listreceived.py @@ -7,7 +7,7 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_true, assert_false -from test_framework.util import start_nodes, wait_and_assert_operationid_status +from test_framework.util import wait_and_assert_operationid_status from decimal import Decimal my_memo_str = 'c0ffee' # stay awake @@ -20,12 +20,6 @@ class ListReceivedTest (BitcoinTestFramework): - def setup_nodes(self): - return start_nodes(4, self.options.tmpdir, [[ - "-nuparams=5ba81b19:201", # Overwinter - "-nuparams=76b809bb:214", # Sapling - ]] * 4) - def generate_and_sync(self, new_height): current_height = self.nodes[0].getblockcount() assert(new_height > current_height) diff --git a/qa/rpc-tests/wallet_overwintertx.py b/qa/rpc-tests/wallet_overwintertx.py index 8915789bb..92b14d78f 100755 --- a/qa/rpc-tests/wallet_overwintertx.py +++ b/qa/rpc-tests/wallet_overwintertx.py @@ -6,9 +6,15 @@ import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x." from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, initialize_chain_clean, \ - start_nodes, connect_nodes_bi, wait_and_assert_operationid_status, \ - assert_greater_than, get_coinbase_address +from test_framework.util import ( + assert_equal, + assert_greater_than, + connect_nodes_bi, + get_coinbase_address, + initialize_chain_clean, + start_nodes, + wait_and_assert_operationid_status, +) from test_framework.authproxy import JSONRPCException from decimal import Decimal @@ -20,7 +26,11 @@ def setup_chain(self): initialize_chain_clean(self.options.tmpdir, 4) def setup_network(self, split=False): - self.nodes = start_nodes(4, self.options.tmpdir, extra_args=[["-nuparams=5ba81b19:200", "-debug=zrpcunsafe", "-txindex"]] * 4 ) + self.nodes = start_nodes(4, self.options.tmpdir, extra_args=[[ + "-nuparams=2bb40e60:200", + "-debug=zrpcunsafe", + "-txindex", + ]] * 4 ) connect_nodes_bi(self.nodes,0,1) connect_nodes_bi(self.nodes,1,2) connect_nodes_bi(self.nodes,0,2) @@ -31,9 +41,9 @@ def setup_network(self, split=False): def run_test (self): self.nodes[0].generate(100) self.sync_all() - self.nodes[1].generate(98) + self.nodes[1].generate(95) self.sync_all() - # Node 0 has reward from blocks 1 to 98 which are spendable. + # Node 0 has reward from blocks 1 to 95 which are spendable. taddr0 = get_coinbase_address(self.nodes[0]) taddr1 = self.nodes[1].getnewaddress() @@ -43,19 +53,12 @@ def run_test (self): zaddr3 = self.nodes[3].z_getnewaddress('sprout') # - # Currently at block 198. The next block to be mined 199 is a Sprout block + # Currently at block 195. The next block to be mined 196 is a Sapling block # bci = self.nodes[0].getblockchaininfo() - assert_equal(bci['consensus']['chaintip'], '00000000') - assert_equal(bci['consensus']['nextblock'], '00000000') - assert_equal(bci['upgrades']['5ba81b19']['status'], 'pending') - - # Cannot use the expiryheight parameter of createrawtransaction if Overwinter is not active in the next block - try: - self.nodes[0].createrawtransaction([], {}, 0, 99) - except JSONRPCException,e: - errorString = e.error['message'] - assert_equal("Invalid parameter, expiryheight can only be used if Overwinter is active when the transaction is mined" in errorString, True) + assert_equal(bci['consensus']['chaintip'], '76b809bb') + assert_equal(bci['consensus']['nextblock'], '76b809bb') + assert_equal(bci['upgrades']['2bb40e60']['status'], 'pending') # Node 0 sends transparent funds to Node 2 tsendamount = Decimal('1.0') @@ -75,8 +78,10 @@ def run_test (self): myopid = self.nodes[0].z_sendmany(taddr0, recipients) txid_shielded = wait_and_assert_operationid_status(self.nodes[0], myopid) + # Skip over the three blocks prior to activation; no transactions can be mined + # in them due to the nearly-expiring restrictions. self.sync_all() - self.nodes[0].generate(1) + self.nodes[0].generate(4) self.sync_all() # Verify balance @@ -84,26 +89,26 @@ def run_test (self): assert_equal(self.nodes[2].getbalance(), Decimal('0.4999')) assert_equal(self.nodes[2].z_getbalance(zaddr2), zsendamount) - # Verify transaction versions are 1 or 2 (intended for Sprout) + # Verify transaction version is 4 (intended for Sapling+) result = self.nodes[0].getrawtransaction(txid_transparent, 1) - assert_equal(result["version"], 1) - assert_equal(result["overwintered"], False) + assert_equal(result["version"], 4) + assert_equal(result["overwintered"], True) result = self.nodes[0].getrawtransaction(txid_zsendmany, 1) - assert_equal(result["version"], 1) - assert_equal(result["overwintered"], False) + assert_equal(result["version"], 4) + assert_equal(result["overwintered"], True) result = self.nodes[0].getrawtransaction(txid_shielded, 1) - assert_equal(result["version"], 2) - assert_equal(result["overwintered"], False) + assert_equal(result["version"], 4) + assert_equal(result["overwintered"], True) # - # Currently at block 199. The next block to be mined 200 is an Overwinter block + # Currently at block 199. The next block to be mined 200 is a Blossom block # bci = self.nodes[0].getblockchaininfo() - assert_equal(bci['consensus']['chaintip'], '00000000') - assert_equal(bci['consensus']['nextblock'], '5ba81b19') - assert_equal(bci['upgrades']['5ba81b19']['status'], 'pending') + assert_equal(bci['consensus']['chaintip'], '76b809bb') + assert_equal(bci['consensus']['nextblock'], '2bb40e60') + assert_equal(bci['upgrades']['2bb40e60']['status'], 'pending') - # Test using expiryheight parameter of createrawtransaction when Overwinter is active in the next block + # Test using expiryheight parameter of createrawtransaction when Blossom is active in the next block errorString = "" try: self.nodes[0].createrawtransaction([], {}, 0, 499999999) @@ -144,7 +149,7 @@ def run_test (self): myopid = self.nodes[0].z_sendmany(taddr0, recipients) txid_shielded = wait_and_assert_operationid_status(self.nodes[0], myopid) - # Mine the first Overwinter block + # Mine the first Blossom block self.sync_all() self.nodes[0].generate(1) self.sync_all() @@ -153,28 +158,28 @@ def run_test (self): # size_on_disk should be > 0 assert_greater_than(bci['size_on_disk'], 0) - assert_equal(bci['consensus']['chaintip'], '5ba81b19') - assert_equal(bci['consensus']['nextblock'], '5ba81b19') - assert_equal(bci['upgrades']['5ba81b19']['status'], 'active') + assert_equal(bci['consensus']['chaintip'], '2bb40e60') + assert_equal(bci['consensus']['nextblock'], '2bb40e60') + assert_equal(bci['upgrades']['2bb40e60']['status'], 'active') # Verify balance assert_equal(self.nodes[1].z_getbalance(taddr1), Decimal('1.0')) assert_equal(self.nodes[3].getbalance(), Decimal('0.4999')) assert_equal(self.nodes[3].z_getbalance(zaddr3), zsendamount) - # Verify transaction version is 3 (intended for Overwinter) + # Verify transaction version is 4 (intended for Sapling+) result = self.nodes[0].getrawtransaction(txid_transparent, 1) - assert_equal(result["version"], 3) + assert_equal(result["version"], 4) assert_equal(result["overwintered"], True) - assert_equal(result["versiongroupid"], "03c48270") + assert_equal(result["versiongroupid"], "892f2085") result = self.nodes[0].getrawtransaction(txid_zsendmany, 1) - assert_equal(result["version"], 3) + assert_equal(result["version"], 4) assert_equal(result["overwintered"], True) - assert_equal(result["versiongroupid"], "03c48270") + assert_equal(result["versiongroupid"], "892f2085") result = self.nodes[0].getrawtransaction(txid_shielded, 1) - assert_equal(result["version"], 3) + assert_equal(result["version"], 4) assert_equal(result["overwintered"], True) - assert_equal(result["versiongroupid"], "03c48270") + assert_equal(result["versiongroupid"], "892f2085") if __name__ == '__main__': WalletOverwinterTxTest().main() diff --git a/qa/rpc-tests/wallet_persistence.py b/qa/rpc-tests/wallet_persistence.py index 2d6bc5b46..77a1e938d 100755 --- a/qa/rpc-tests/wallet_persistence.py +++ b/qa/rpc-tests/wallet_persistence.py @@ -22,11 +22,7 @@ def setup_chain(self): initialize_chain_clean(self.options.tmpdir, 4) def setup_network(self, split=False): - self.nodes = start_nodes(4, self.options.tmpdir, - extra_args=[[ - '-nuparams=5ba81b19:100', # Overwinter - '-nuparams=76b809bb:201', # Sapling - ]] * 3) + self.nodes = start_nodes(3, self.options.tmpdir) connect_nodes_bi(self.nodes,0,1) connect_nodes_bi(self.nodes,1,2) self.is_network_split=False @@ -38,7 +34,7 @@ def run_test(self): assert_equal(self.nodes[0].getblockcount(), 200) self.sync_all() - # Verify Sapling address is persisted in wallet (even when Sapling is not yet active) + # Verify Sapling address is persisted in wallet sapling_addr = self.nodes[0].z_getnewaddress('sapling') # Make sure the node has the addresss @@ -54,10 +50,6 @@ def run_test(self): addresses = self.nodes[0].z_listaddresses() assert_true(sapling_addr in addresses, "Should contain address after restart") - # Activate Sapling - self.nodes[0].generate(1) - self.sync_all() - # Node 0 shields funds to Sapling address taddr0 = get_coinbase_address(self.nodes[0]) recipients = [] diff --git a/qa/rpc-tests/wallet_sapling.py b/qa/rpc-tests/wallet_sapling.py index 3ac4d02d8..fe12ab16f 100755 --- a/qa/rpc-tests/wallet_sapling.py +++ b/qa/rpc-tests/wallet_sapling.py @@ -21,8 +21,6 @@ class WalletSaplingTest(BitcoinTestFramework): def setup_nodes(self): return start_nodes(4, self.options.tmpdir, [[ - '-nuparams=5ba81b19:201', # Overwinter - '-nuparams=76b809bb:203', # Sapling '-experimentalfeatures', '-zmergetoaddress', ]] * 4) @@ -30,52 +28,6 @@ def run_test(self): # Sanity-check the test harness assert_equal(self.nodes[0].getblockcount(), 200) - # Activate Overwinter - self.nodes[2].generate(1) - self.sync_all() - - # Verify RPCs disallow Sapling value transfer if Sapling is not active - tmp_taddr = get_coinbase_address(self.nodes[3]) - tmp_zaddr = self.nodes[3].z_getnewaddress('sapling') - try: - recipients = [] - recipients.append({"address": tmp_zaddr, "amount": Decimal('10')}) - self.nodes[3].z_sendmany(tmp_taddr, recipients, 1, 0) - raise AssertionError("Should have thrown an exception") - except JSONRPCException as e: - assert_equal("Invalid parameter, Sapling has not activated", e.error['message']) - try: - recipients = [] - recipients.append({"address": tmp_taddr, "amount": Decimal('10')}) - self.nodes[3].z_sendmany(tmp_zaddr, recipients, 1, 0) - raise AssertionError("Should have thrown an exception") - except JSONRPCException as e: - assert_equal("Invalid parameter, Sapling has not activated", e.error['message']) - try: - self.nodes[3].z_shieldcoinbase(tmp_taddr, tmp_zaddr) - raise AssertionError("Should have thrown an exception") - except JSONRPCException as e: - assert_equal("Invalid parameter, Sapling has not activated", e.error['message']) - - # Verify z_mergetoaddress RPC does not support Sapling yet - try: - self.nodes[3].z_mergetoaddress([tmp_taddr], tmp_zaddr) - raise AssertionError("Should have thrown an exception") - except JSONRPCException as e: - assert_equal("Invalid parameter, Sapling has not activated", e.error['message']) - try: - self.nodes[3].z_mergetoaddress([tmp_zaddr], tmp_taddr) - raise AssertionError("Should have thrown an exception") - except JSONRPCException as e: - # When sending from a zaddr we check for sapling activation only if - # we find notes belonging to that address. Since sapling is not active - # none can be generated and none will be found. - assert_equal("Could not find any funds to merge.", e.error['message']) - - # Activate Sapling - self.nodes[2].generate(2) - self.sync_all() - taddr1 = self.nodes[1].getnewaddress() saplingAddr0 = self.nodes[0].z_getnewaddress('sapling') saplingAddr1 = self.nodes[1].z_getnewaddress('sapling') diff --git a/qa/rpc-tests/wallet_shieldcoinbase.py b/qa/rpc-tests/wallet_shieldcoinbase.py index 69e02f8a2..d4b69a2d0 100755 --- a/qa/rpc-tests/wallet_shieldcoinbase.py +++ b/qa/rpc-tests/wallet_shieldcoinbase.py @@ -24,18 +24,10 @@ def setup_chain(self): def setup_network(self, split=False): args = ['-regtestprotectcoinbase', '-debug=zrpcunsafe'] - args2 = ['-regtestprotectcoinbase', '-debug=zrpcunsafe', "-mempooltxinputlimit=7"] - if self.addr_type != 'sprout': - nu = [ - '-nuparams=5ba81b19:0', # Overwinter - '-nuparams=76b809bb:1', # Sapling - ] - args.extend(nu) - args2 = args self.nodes = [] self.nodes.append(start_node(0, self.options.tmpdir, args)) self.nodes.append(start_node(1, self.options.tmpdir, args)) - self.nodes.append(start_node(2, self.options.tmpdir, args2)) + self.nodes.append(start_node(2, self.options.tmpdir, args)) connect_nodes_bi(self.nodes,0,1) connect_nodes_bi(self.nodes,1,2) connect_nodes_bi(self.nodes,0,2) @@ -165,14 +157,8 @@ def verify_locking(first, second, limit): wait_and_assert_operationid_status(self.nodes[0], opid1) wait_and_assert_operationid_status(self.nodes[0], opid2) - if self.addr_type == 'sprout': - # Shielding the 800 utxos will occur over two transactions, since max tx size is 100,000 bytes. - # We don't verify shieldingValue as utxos are not selected in any specific order, so value can change on each test run. - # We set an unrealistically high limit parameter of 99999, to verify that max tx size will constrain the number of utxos. - verify_locking('662', '138', 99999) - else: - # Shield the 800 utxos over two transactions - verify_locking('500', '300', 500) + # Shield the 800 utxos over two transactions + verify_locking('500', '300', 500) # sync_all() invokes sync_mempool() but node 2's mempool limit will cause tx1 and tx2 to be rejected. # So instead, we sync on blocks and mempool for node 0 and node 1, and after a new block is generated @@ -182,18 +168,6 @@ def verify_locking(first, second, limit): self.nodes[1].generate(1) self.sync_all() - if self.addr_type == 'sprout': - # Verify maximum number of utxos which node 2 can shield is limited by option -mempooltxinputlimit - # This option is used when the limit parameter is set to 0. - mytaddr = get_coinbase_address(self.nodes[2], 20) - result = self.nodes[2].z_shieldcoinbase(mytaddr, myzaddr, Decimal('0.0001'), 0) - assert_equal(result["shieldingUTXOs"], Decimal('7')) - assert_equal(result["remainingUTXOs"], Decimal('13')) - wait_and_assert_operationid_status(self.nodes[2], result['opid']) - self.sync_all() - self.nodes[1].generate(1) - self.sync_all() - # Verify maximum number of utxos which node 0 can shield is set by default limit parameter of 50 self.nodes[0].generate(200) self.sync_all() diff --git a/src/Makefile.am b/src/Makefile.am index 1d0c7ccc2..32a31b677 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,8 +31,6 @@ BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS) BITCOIN_INCLUDES += -I$(srcdir)/secp256k1/include -BITCOIN_INCLUDES += -I$(srcdir)/snark -BITCOIN_INCLUDES += -I$(srcdir)/snark/libsnark BITCOIN_INCLUDES += -I$(srcdir)/univalue/include LIBBITCOIN_SERVER=libbitcoin_server.a @@ -41,7 +39,6 @@ LIBBITCOIN_CLI=libbitcoin_cli.a LIBBITCOIN_UTIL=libbitcoin_util.a LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a LIBSECP256K1=secp256k1/libsecp256k1.la -LIBSNARK=snark/libsnark.a LIBUNIVALUE=univalue/libunivalue.la LIBZCASH=libzcash.a @@ -61,21 +58,6 @@ endif $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*) $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) -LIBSNARK_CXXFLAGS = $(AM_CXXFLAGS) $(PIC_FLAGS) -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1 -fstack-protector-all -LIBSNARK_CONFIG_FLAGS = CURVE=ALT_BN128 NO_PROCPS=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT NO_COPY_DEPINST=1 NO_COMPILE_LIBGTEST=1 -if HAVE_OPENMP -LIBSNARK_CONFIG_FLAGS += MULTICORE=1 -endif -if TARGET_DARWIN -LIBSNARK_CONFIG_FLAGS += PLATFORM=darwin -endif - -$(LIBSNARK): $(wildcard snark/src/*) - $(AM_V_at) CC="$(CC)" CXX="$(CXX)" AR="$(AR)" CXXFLAGS="$(LIBSNARK_CXXFLAGS)" $(MAKE) $(AM_MAKEFLAGS) -C snark/ DEPINST="$(LIBSNARK_DEPINST)" $(LIBSNARK_CONFIG_FLAGS) OPTFLAGS="$(LIBSNARK_OPTFLAGS)" - -libsnark-tests: $(wildcard snark/src/*) - $(AM_V_at) CC="$(CC)" CXX="$(CXX)" AR="$(AR)" CXXFLAGS="$(LIBSNARK_CXXFLAGS)" $(MAKE) $(AM_MAKEFLAGS) -C snark/ check DEPINST="$(LIBSNARK_DEPINST)" $(LIBSNARK_CONFIG_FLAGS) OPTFLAGS="$(LIBSNARK_OPTFLAGS)" - $(LIBUNIVALUE): $(wildcard univalue/lib/*) $(wildcard univalue/include/*) $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) @@ -120,7 +102,7 @@ LIBZCASH_H = \ zcash/util.h \ zcash/Zcash.h -.PHONY: FORCE collate-libsnark check-symbols check-security +.PHONY: FORCE check-symbols check-security # bitcoin core # BITCOIN_CORE_H = \ addressindex.h \ @@ -463,7 +445,6 @@ bitcoinzd_LDADD = \ $(LIBBITCOIN_PROTON) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH) \ - $(LIBSNARK) \ $(LIBLEVELDB) \ $(LIBMEMENV) \ $(LIBSECP256K1) @@ -499,7 +480,6 @@ bitcoinz_cli_LDADD = \ $(CRYPTO_LIBS) \ $(EVENT_LIBS) \ $(LIBZCASH) \ - $(LIBSNARK) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) # @@ -521,7 +501,6 @@ bitcoinz_tx_LDADD = \ $(LIBBITCOIN_UTIL) \ $(LIBSECP256K1) \ $(LIBZCASH) \ - $(LIBSNARK) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) @@ -540,13 +519,7 @@ libzcash_a_SOURCES = \ zcash/Proof.cpp \ zcash/Note.cpp \ zcash/prf.cpp \ - zcash/util.cpp \ - zcash/circuit/commitment.tcc \ - zcash/circuit/gadget.tcc \ - zcash/circuit/merkle.tcc \ - zcash/circuit/note.tcc \ - zcash/circuit/prfs.tcc \ - zcash/circuit/utils.tcc + zcash/util.cpp libzcash_a_CPPFLAGS = $(AM_CPPFLAGS) $(PIC_FLAGS) -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DBOOST_SPIRIT_THREADSAFE -fvisibility=hidden -DSTATIC $(BITCOIN_INCLUDES) libzcash_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) @@ -589,12 +562,11 @@ CLEANFILES = leveldb/libleveldb.a leveldb/libmemenv.a *.gcda *.gcno */*.gcno wal DISTCLEANFILES = obj/build.h -EXTRA_DIST = leveldb snark +EXTRA_DIST = leveldb clean-local: -$(MAKE) -C leveldb clean -$(MAKE) -C secp256k1 clean - -$(MAKE) -C snark clean -$(MAKE) -C univalue clean rm -f leveldb/*/*.gcno leveldb/helpers/memenv/*.gcno -rm -f config.h diff --git a/src/Makefile.gtest.include b/src/Makefile.gtest.include index c25cb4136..b583ff5ea 100644 --- a/src/Makefile.gtest.include +++ b/src/Makefile.gtest.include @@ -45,10 +45,8 @@ zcash_gtest_SOURCES += \ gtest/test_transaction_builder.cpp \ gtest/test_upgrades.cpp \ gtest/test_validation.cpp \ - gtest/test_circuit.cpp \ gtest/test_txid.cpp \ gtest/test_libzcash_utils.cpp \ - gtest/test_proofs.cpp \ gtest/test_pedersen_hash.cpp \ gtest/test_checkblock.cpp \ gtest/test_zip32.cpp @@ -70,7 +68,7 @@ if ENABLE_WALLET zcash_gtest_LDADD += $(LIBBITCOIN_WALLET) endif -zcash_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBSNARK) $(LIBZCASH_LIBS) +zcash_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) if ENABLE_PROTON zcash_gtest_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 1eb6b262e..e4f3540d8 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -38,8 +38,6 @@ JSON_TEST_FILES = \ test/data/merkle_witness_serialization_sapling.json \ test/data/merkle_path_sapling.json \ test/data/merkle_commitments_sapling.json \ - test/data/g1_compressed.json \ - test/data/g2_compressed.json \ test/data/sapling_key_components.json RAW_TEST_FILES = test/data/alertTests.raw @@ -120,7 +118,7 @@ test_test_bitcoin_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_C $(LIBLEVELDB) $(LIBMEMENV) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -test_test_bitcoin_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(LIBZCASH) $(LIBSNARK) $(LIBZCASH_LIBS) +test_test_bitcoin_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static if ENABLE_ZMQ diff --git a/src/consensus/params.h b/src/consensus/params.h index 622c4835a..32371051e 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -59,6 +59,18 @@ struct NetworkUpgrade { * should remain disabled on mainnet. */ static constexpr int NO_ACTIVATION_HEIGHT = -1; + + /** + * The hash of the block at height nActivationHeight, if known. This is set manually + * after a network upgrade activates. + * + * We use this in IsInitialBlockDownload to detect whether we are potentially being + * fed a fake alternate chain. We use NU activation blocks for this purpose instead of + * the checkpoint blocks, because network upgrades (should) have significantly more + * scrutiny than regular releases. nMinimumChainWork MUST be set to at least the chain + * work of this block, otherwise this detection will have false positives. + */ + boost::optional hashActivationBlock; }; /** ZIP208 block target interval in seconds. */ diff --git a/src/gtest/main.cpp b/src/gtest/main.cpp index 5f32b5fef..6c8fd0c2b 100644 --- a/src/gtest/main.cpp +++ b/src/gtest/main.cpp @@ -5,9 +5,6 @@ #include "zcash/JoinSplit.hpp" #include "util.h" -#include -#include - #include "librustzcash.h" struct ECCryptoClosure @@ -23,12 +20,7 @@ int main(int argc, char **argv) { assert(init_and_check_sodium() != -1); ECC_Start(); - libsnark::default_r1cs_ppzksnark_pp::init_public_params(); - libsnark::inhibit_profiling_info = true; - libsnark::inhibit_profiling_counters = true; - boost::filesystem::path pk_path = ZC_GetParamsDir() / "sprout-proving.key"; - boost::filesystem::path vk_path = ZC_GetParamsDir() / "sprout-verifying.key"; - params = ZCJoinSplit::Prepared(vk_path.string(), pk_path.string()); + params = ZCJoinSplit::Prepared(); boost::filesystem::path sapling_spend = ZC_GetParamsDir() / "sapling-spend.params"; boost::filesystem::path sapling_output = ZC_GetParamsDir() / "sapling-output.params"; diff --git a/src/gtest/test_checktransaction.cpp b/src/gtest/test_checktransaction.cpp index a30b1268c..69e8748a6 100644 --- a/src/gtest/test_checktransaction.cpp +++ b/src/gtest/test_checktransaction.cpp @@ -748,7 +748,6 @@ TEST(checktransaction_tests, SaplingSproutInputSumsTooLarge) { std::array outputMap; auto jsdesc = JSDescription::Randomized( - true, *params, joinSplitPubKey, rt, inputs, outputs, inputMap, outputMap, diff --git a/src/gtest/test_circuit.cpp b/src/gtest/test_circuit.cpp deleted file mode 100644 index ab2a8ecb6..000000000 --- a/src/gtest/test_circuit.cpp +++ /dev/null @@ -1,183 +0,0 @@ -#include -#include "uint256.h" - -#include "zcash/util.h" - -#include -#include -#include - -#include -#include -#include -#include - -#include "zcash/IncrementalMerkleTree.hpp" - -using namespace libsnark; -using namespace libzcash; - -#include "zcash/circuit/utils.tcc" -#include "zcash/circuit/merkle.tcc" - -template -void test_value_equals(uint64_t i) { - protoboard pb; - pb_variable_array num; - num.allocate(pb, 64, ""); - num.fill_with_bits(pb, uint64_to_bool_vector(i)); - pb.add_r1cs_constraint(r1cs_constraint( - packed_addition(num), - FieldT::one(), - FieldT::one() * i - ), ""); - ASSERT_TRUE(pb.is_satisfied()); -} - -TEST(circuit, values) -{ - typedef Fr FieldT; - test_value_equals(0); - test_value_equals(1); - test_value_equals(3); - test_value_equals(5391); - test_value_equals(883128374); - test_value_equals(173419028459); - test_value_equals(2205843009213693953); -} - -TEST(circuit, endianness) -{ - std::vector before = { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63 - }; - auto result = swap_endianness_u64(before); - - std::vector after = { - 56, 57, 58, 59, 60, 61, 62, 63, - 48, 49, 50, 51, 52, 53, 54, 55, - 40, 41, 42, 43, 44, 45, 46, 47, - 32, 33, 34, 35, 36, 37, 38, 39, - 24, 25, 26, 27, 28, 29, 30, 31, - 16, 17, 18, 19, 20, 21, 22, 23, - 8, 9, 10, 11, 12, 13, 14, 15, - 0, 1, 2, 3, 4, 5, 6, 7 - }; - - EXPECT_EQ(after, result); - - std::vector bad = {0, 1, 2, 3}; - - ASSERT_THROW(swap_endianness_u64(bad), std::length_error); -} - -template -bool test_merkle_gadget( - bool enforce_a, - bool enforce_b, - bool write_root_first -) -{ - protoboard pb; - digest_variable root(pb, 256, "root"); - pb.set_input_sizes(256); - - digest_variable commitment1(pb, 256, "commitment1"); - digest_variable commitment2(pb, 256, "commitment2"); - - pb_variable commitment1_read; - commitment1_read.allocate(pb); - pb_variable commitment2_read; - commitment2_read.allocate(pb); - - merkle_tree_gadget mgadget1(pb, commitment1, root, commitment1_read); - merkle_tree_gadget mgadget2(pb, commitment2, root, commitment2_read); - - commitment1.generate_r1cs_constraints(); - commitment2.generate_r1cs_constraints(); - root.generate_r1cs_constraints(); - mgadget1.generate_r1cs_constraints(); - mgadget2.generate_r1cs_constraints(); - - SproutMerkleTree tree; - uint256 commitment1_data = uint256S("54d626e08c1c802b305dad30b7e54a82f102390cc92c7d4db112048935236e9c"); - uint256 commitment2_data = uint256S("59d2cde5e65c1414c32ba54f0fe4bdb3d67618125286e6a191317917c812c6d7"); - tree.append(commitment1_data); - auto wit1 = tree.witness(); - tree.append(commitment2_data); - wit1.append(commitment2_data); - auto wit2 = tree.witness(); - auto expected_root = tree.root(); - tree.append(uint256S("3e243c8798678570bb8d42616c23a536af44be15c4eef073490c2a44ae5f32c3")); - auto unexpected_root = tree.root(); - tree.append(uint256S("26d9b20c7f1c3d2528bbcd43cd63344b0afd3b6a0a8ebd37ec51cba34907bec7")); - auto badwit1 = tree.witness(); - tree.append(uint256S("02c2467c9cd15e0d150f74cd636505ed675b0b71b66a719f6f52fdb49a5937bb")); - auto badwit2 = tree.witness(); - - // Perform the test - - pb.val(commitment1_read) = enforce_a ? FieldT::one() : FieldT::zero(); - pb.val(commitment2_read) = enforce_b ? FieldT::one() : FieldT::zero(); - - commitment1.bits.fill_with_bits(pb, uint256_to_bool_vector(commitment1_data)); - commitment2.bits.fill_with_bits(pb, uint256_to_bool_vector(commitment2_data)); - - if (write_root_first) { - root.bits.fill_with_bits(pb, uint256_to_bool_vector(expected_root)); - } - - mgadget1.generate_r1cs_witness(wit1.path()); - mgadget2.generate_r1cs_witness(wit2.path()); - - // Overwrite with our expected root - root.bits.fill_with_bits(pb, uint256_to_bool_vector(expected_root)); - - return pb.is_satisfied(); -} - -TEST(circuit, merkle_tree_gadget_weirdness) -{ - /* - The merkle tree gadget takes a leaf in the merkle tree (the Note commitment), - a merkle tree authentication path, and a root (anchor). It also takes a parameter - called read_success, which is used to determine if the commitment actually needs to - appear in the tree. - - If two input notes use the same root (which our protocol does) then if `read_success` - is disabled on the first note but enabled on the second note (i.e., the first note - has value of zero and second note has nonzero value) then there is an edge case in - the witnessing behavior. The first witness will accidentally constrain the root to - equal null (the default value of the anchor) and the second witness will actually - copy the bits, violating the constraint system. - - Notice that this edge case is not in the constraint system but in the witnessing - behavior. - */ - - typedef Fr FieldT; - - // Test the normal case - ASSERT_TRUE(test_merkle_gadget(true, true, false)); - ASSERT_TRUE(test_merkle_gadget(true, true, true)); - - // Test the case where the first commitment is enforced but the second isn't - // Works because the first read is performed before the second one - ASSERT_TRUE(test_merkle_gadget(true, false, false)); - ASSERT_TRUE(test_merkle_gadget(true, false, true)); - - // Test the case where the first commitment isn't enforced but the second is - // Doesn't work because the first multipacker witnesses the existing root (which - // is null) - ASSERT_TRUE(!test_merkle_gadget(false, true, false)); - - // Test the last again, except this time write the root first. - ASSERT_TRUE(test_merkle_gadget(false, true, true)); -} diff --git a/src/gtest/test_joinsplit.cpp b/src/gtest/test_joinsplit.cpp index 50abea3f0..546ae6aa6 100644 --- a/src/gtest/test_joinsplit.cpp +++ b/src/gtest/test_joinsplit.cpp @@ -22,10 +22,9 @@ using namespace libzcash; extern ZCJoinSplit* params; -typedef std::array SproutProofs; -// Make both the PHGR and Groth proof for a Sprout statement, -// and store the results in JSDescription objects. -SproutProofs makeSproutProofs( +// Make the Groth proof for a Sprout statement, +// and store the result in a JSDescription object. +JSDescription makeSproutProof( ZCJoinSplit& js, const std::array& inputs, const std::array& outputs, @@ -34,25 +33,17 @@ SproutProofs makeSproutProofs( uint64_t vpub_new, const uint256& rt ){ - //Making the PHGR proof - JSDescription phgr(false, js, joinSplitPubKey, rt, inputs, outputs, vpub_old, vpub_new); - //Making the Groth proof - JSDescription groth(true, js, joinSplitPubKey, rt, inputs, outputs, vpub_old, vpub_new); - - return {phgr, groth}; - + return JSDescription(js, joinSplitPubKey, rt, inputs, outputs, vpub_old, vpub_new); } -bool verifySproutProofs( +bool verifySproutProof( ZCJoinSplit& js, - const SproutProofs& jsdescs, + const JSDescription& jsdesc, const uint256& joinSplitPubKey ) { auto verifier = libzcash::ProofVerifier::Strict(); - bool phgrPassed = jsdescs[0].Verify(js, verifier, joinSplitPubKey); - bool grothPassed = jsdescs[1].Verify(js, verifier, joinSplitPubKey); - return phgrPassed && grothPassed; + return jsdesc.Verify(js, verifier, joinSplitPubKey); } @@ -73,7 +64,7 @@ void test_full_api(ZCJoinSplit* js) uint64_t vpub_new = 0; uint256 joinSplitPubKey = random_uint256(); uint256 rt = tree.root(); - SproutProofs jsdescs; + JSDescription jsdesc; { std::array inputs = { @@ -89,7 +80,7 @@ void test_full_api(ZCJoinSplit* js) std::array output_notes; // Perform the proofs - jsdescs = makeSproutProofs( + jsdesc = makeSproutProof( *js, inputs, outputs, @@ -101,13 +92,11 @@ void test_full_api(ZCJoinSplit* js) } // Verify both PHGR and Groth Proof: - ASSERT_TRUE(verifySproutProofs(*js, jsdescs, joinSplitPubKey)); + ASSERT_TRUE(verifySproutProof(*js, jsdesc, joinSplitPubKey)); - // Run tests using both phgr and groth as basis for field values - for (auto jsdesc : jsdescs) { SproutMerkleTree tree; - SproutProofs jsdescs2; + JSDescription jsdesc2; // Recipient should decrypt // Now the recipient should spend the money again auto h_sig = js->h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey); @@ -153,7 +142,7 @@ void test_full_api(ZCJoinSplit* js) // Perform the proofs - jsdescs2 = makeSproutProofs( + jsdesc2 = makeSproutProof( *js, inputs, outputs, @@ -166,8 +155,8 @@ void test_full_api(ZCJoinSplit* js) } - // Verify both PHGR and Groth Proof: - ASSERT_TRUE(verifySproutProofs(*js, jsdescs2, joinSplitPubKey2)); + // Verify Groth Proof: + ASSERT_TRUE(verifySproutProof(*js, jsdesc2, joinSplitPubKey2)); } } @@ -191,28 +180,8 @@ void invokeAPI( std::array output_notes; - // PHGR - SproutProof proof = js->prove( - false, - inputs, - outputs, - output_notes, - ciphertexts, - ephemeralKey, - joinSplitPubKey, - randomSeed, - macs, - nullifiers, - commitments, - vpub_old, - vpub_new, - rt, - false - ); - // Groth - proof = js->prove( - true, + SproutProof proof = js->prove( inputs, outputs, output_notes, diff --git a/src/gtest/test_merkletree.cpp b/src/gtest/test_merkletree.cpp index 3d58e32d0..a7b7c5287 100644 --- a/src/gtest/test_merkletree.cpp +++ b/src/gtest/test_merkletree.cpp @@ -26,17 +26,11 @@ #include "zcash/IncrementalMerkleTree.hpp" #include "zcash/util.h" -#include -#include -#include -#include - #include #include "json_test_vectors.h" using namespace std; -using namespace libsnark; template<> void expect_deser_same(const SproutTestingWitness& expected) @@ -58,8 +52,7 @@ void test_tree( UniValue root_tests, UniValue ser_tests, UniValue witness_ser_tests, - UniValue path_tests, - bool libsnark_test + UniValue path_tests ) { size_t witness_ser_i = 0; @@ -115,55 +108,6 @@ void test_tree( } else { auto path = wit.path(); expect_test_vector(path_tests[path_i++], path); - - if (libsnark_test) { - typedef Fr FieldT; - - protoboard pb; - pb_variable_array positions; - digest_variable commitment(pb, 256, "commitment"); - digest_variable root(pb, 256, "root"); - positions.allocate(pb, INCREMENTAL_MERKLE_TREE_DEPTH_TESTING, "pos"); - merkle_authentication_path_variable> authvars(pb, INCREMENTAL_MERKLE_TREE_DEPTH_TESTING, "auth"); - merkle_tree_check_read_gadget> auth( - pb, INCREMENTAL_MERKLE_TREE_DEPTH_TESTING, positions, commitment, root, authvars, ONE, "path" - ); - commitment.generate_r1cs_constraints(); - root.generate_r1cs_constraints(); - authvars.generate_r1cs_constraints(); - auth.generate_r1cs_constraints(); - - std::vector commitment_bv; - { - uint256 witnessed_commitment = wit.element(); - std::vector commitment_v(witnessed_commitment.begin(), witnessed_commitment.end()); - commitment_bv = convertBytesVectorToVector(commitment_v); - } - - size_t path_index = convertVectorToInt(path.index); - - commitment.bits.fill_with_bits(pb, bit_vector(commitment_bv)); - positions.fill_with_bits_of_uint64(pb, path_index); - - authvars.generate_r1cs_witness(path_index, path.authentication_path); - auth.generate_r1cs_witness(); - - std::vector root_bv; - { - uint256 witroot = wit.root(); - std::vector root_v(witroot.begin(), witroot.end()); - root_bv = convertBytesVectorToVector(root_v); - } - - root.bits.fill_with_bits(pb, bit_vector(root_bv)); - - ASSERT_TRUE(pb.is_satisfied()); - - root_bv[0] = !root_bv[0]; - root.bits.fill_with_bits(pb, bit_vector(root_bv)); - - ASSERT_TRUE(!pb.is_satisfied()); - } } // Check witness serialization @@ -200,8 +144,7 @@ TEST(merkletree, vectors) { root_tests, ser_tests, witness_ser_tests, - path_tests, - true + path_tests ); } @@ -217,8 +160,7 @@ TEST(merkletree, SaplingVectors) { root_tests, ser_tests, witness_ser_tests, - path_tests, - false + path_tests ); } diff --git a/src/gtest/test_proofs.cpp b/src/gtest/test_proofs.cpp deleted file mode 100644 index 5b5c19395..000000000 --- a/src/gtest/test_proofs.cpp +++ /dev/null @@ -1,702 +0,0 @@ -#include -#include "zcash/Proof.hpp" - -#include - -#include -#include -#include - -using namespace libzcash; - -typedef libsnark::default_r1cs_ppzksnark_pp curve_pp; -typedef libsnark::default_r1cs_ppzksnark_pp::G1_type curve_G1; -typedef libsnark::default_r1cs_ppzksnark_pp::G2_type curve_G2; -typedef libsnark::default_r1cs_ppzksnark_pp::GT_type curve_GT; -typedef libsnark::default_r1cs_ppzksnark_pp::Fp_type curve_Fr; -typedef libsnark::default_r1cs_ppzksnark_pp::Fq_type curve_Fq; -typedef libsnark::default_r1cs_ppzksnark_pp::Fqe_type curve_Fq2; - -#include "streams.h" -#include "version.h" -#include "utilstrencodings.h" - -TEST(proofs, g1_pairing_at_infinity) -{ - for (size_t i = 0; i < 100; i++) { - auto r1 = curve_G1::random_element(); - auto r2 = curve_G2::random_element(); - ASSERT_TRUE( - curve_pp::reduced_pairing(curve_G1::zero(), r2) == - curve_GT::one() - ); - ASSERT_TRUE( - curve_pp::final_exponentiation( - curve_pp::double_miller_loop( - curve_pp::precompute_G1(curve_G1::zero()), - curve_pp::precompute_G2(r2), - curve_pp::precompute_G1(curve_G1::zero()), - curve_pp::precompute_G2(r2) - ) - ) == - curve_GT::one() - ); - ASSERT_TRUE( - curve_pp::final_exponentiation( - curve_pp::double_miller_loop( - curve_pp::precompute_G1(r1), - curve_pp::precompute_G2(r2), - curve_pp::precompute_G1(curve_G1::zero()), - curve_pp::precompute_G2(r2) - ) - ) == - curve_pp::reduced_pairing(r1, r2) - ); - ASSERT_TRUE( - curve_pp::final_exponentiation( - curve_pp::double_miller_loop( - curve_pp::precompute_G1(curve_G1::zero()), - curve_pp::precompute_G2(r2), - curve_pp::precompute_G1(r1), - curve_pp::precompute_G2(r2) - ) - ) == - curve_pp::reduced_pairing(r1, r2) - ); - } -} - -TEST(proofs, g2_subgroup_check) -{ - // all G2 elements are order r - ASSERT_TRUE(libsnark::alt_bn128_modulus_r * curve_G2::random_element() == curve_G2::zero()); - - // but that doesn't mean all elements that satisfy the curve equation are in G2... - curve_G2 p = curve_G2::one(); - - while (1) { - // This will construct an order r(2q-r) point with high probability - p.X = curve_Fq2::random_element(); - try { - p.Y = ((p.X.squared() * p.X) + libsnark::alt_bn128_twist_coeff_b).sqrt(); - break; - } catch(...) {} - } - - ASSERT_TRUE(p.is_well_formed()); // it's on the curve - ASSERT_TRUE(libsnark::alt_bn128_modulus_r * p != curve_G2::zero()); // but not the order r subgroup.. - - { - // libsnark unfortunately doesn't check, and the pairing will complete - auto e = curve_Fr("149"); - auto a = curve_pp::reduced_pairing(curve_G1::one(), p); - auto b = curve_pp::reduced_pairing(e * curve_G1::one(), p); - - // though it will not preserve bilinearity - ASSERT_TRUE((a^e) != b); - } - - { - // so, our decompression API should not allow you to decompress G2 elements of that form! - CompressedG2 badp(p); - try { - auto newp = badp.to_libsnark_g2(); - FAIL() << "Expected std::runtime_error"; - } catch (std::runtime_error const & err) { - EXPECT_EQ(err.what(), std::string("point is not in G2")); - } catch(...) { - FAIL() << "Expected std::runtime_error"; - } - } - - // educational purposes: showing that E'(Fp2) is of order r(2q-r), - // by multiplying our random point in E' by (2q-r) = (q + q - r) to - // get an element in G2 - { - auto p1 = libsnark::alt_bn128_modulus_q * p; - p1 = p1 + p1; - p1 = p1 - (libsnark::alt_bn128_modulus_r * p); - - ASSERT_TRUE(p1.is_well_formed()); - ASSERT_TRUE(libsnark::alt_bn128_modulus_r * p1 == curve_G2::zero()); - - CompressedG2 goodp(p1); - auto newp = goodp.to_libsnark_g2(); - - ASSERT_TRUE(newp == p1); - } -} - -TEST(proofs, sqrt_zero) -{ - ASSERT_TRUE(curve_Fq::zero() == curve_Fq::zero().sqrt()); - ASSERT_TRUE(curve_Fq2::zero() == curve_Fq2::zero().sqrt()); -} - -TEST(proofs, sqrt_fq) -{ - // Poor man's PRNG - curve_Fq acc = curve_Fq("348957923485290374852379485") ^ 1000; - - size_t quadratic_residues = 0; - size_t quadratic_nonresidues = 0; - - for (size_t i = 1; i < 1000; i++) { - try { - acc += curve_Fq("45634563456") ^ i; - - curve_Fq x = acc.sqrt(); - ASSERT_TRUE((x*x) == acc); - quadratic_residues += 1; - } catch (std::runtime_error &e) { - quadratic_nonresidues += 1; - } - } - - // Half of all nonzero elements in Fp are quadratic residues - ASSERT_TRUE(quadratic_residues == 511); - ASSERT_TRUE(quadratic_nonresidues == 488); - - for (size_t i = 0; i < 1000; i++) { - curve_Fq x = curve_Fq::random_element(); - curve_Fq x2 = x * x; - - ASSERT_TRUE((x2.sqrt() == x) || (x2.sqrt() == -x)); - } - - // Test vectors - ASSERT_TRUE( - curve_Fq("5204065062716160319596273903996315000119019512886596366359652578430118331601") - == - curve_Fq("348579348568").sqrt() - ); - ASSERT_THROW(curve_Fq("348579348569").sqrt(), std::runtime_error); -} - -TEST(proofs, sqrt_fq2) -{ - curve_Fq2 acc = curve_Fq2( - curve_Fq("3456293840592348059238409578239048769348760238476029347885092384059238459834") ^ 1000, - curve_Fq("2394578084760439457823945729347502374590283479582739485723945729384759823745") ^ 1000 - ); - - size_t quadratic_residues = 0; - size_t quadratic_nonresidues = 0; - - for (size_t i = 1; i < 1000; i++) { - try { - acc = acc + curve_Fq2( - curve_Fq("5204065062716160319596273903996315000119019512886596366359652578430118331601") ^ i, - curve_Fq("348957923485290374852379485348957923485290374852379485348957923485290374852") ^ i - ); - - curve_Fq2 x = acc.sqrt(); - ASSERT_TRUE((x*x) == acc); - quadratic_residues += 1; - } catch (std::runtime_error &e) { - quadratic_nonresidues += 1; - } - } - - // Half of all nonzero elements in Fp^k are quadratic residues as long - // as p != 2 - ASSERT_TRUE(quadratic_residues == 505); - ASSERT_TRUE(quadratic_nonresidues == 494); - - for (size_t i = 0; i < 1000; i++) { - curve_Fq2 x = curve_Fq2::random_element(); - curve_Fq2 x2 = x * x; - - ASSERT_TRUE((x2.sqrt() == x) || (x2.sqrt() == -x)); - } - - // Test vectors - ASSERT_THROW(curve_Fq2( - curve_Fq("2"), - curve_Fq("1") - ).sqrt(), std::runtime_error); - - ASSERT_THROW(curve_Fq2( - curve_Fq("3345897230485723946872934576923485762803457692345760237495682347502347589473"), - curve_Fq("1234912378405347958234756902345768290345762348957605678245967234857634857676") - ).sqrt(), std::runtime_error); - - curve_Fq2 x = curve_Fq2( - curve_Fq("12844195307879678418043983815760255909500142247603239203345049921980497041944"), - curve_Fq("7476417578426924565731404322659619974551724117137577781074613937423560117731") - ); - - curve_Fq2 nx = -x; - - curve_Fq2 x2 = curve_Fq2( - curve_Fq("3345897230485723946872934576923485762803457692345760237495682347502347589474"), - curve_Fq("1234912378405347958234756902345768290345762348957605678245967234857634857676") - ); - - ASSERT_TRUE(x == x2.sqrt()); - ASSERT_TRUE(nx == -x2.sqrt()); - ASSERT_TRUE(x*x == x2); - ASSERT_TRUE(nx*nx == x2); -} - -TEST(proofs, size_is_expected) -{ - PHGRProof p; - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << p; - - ASSERT_EQ(ss.size(), 296); -} - -TEST(proofs, fq_serializes_properly) -{ - for (size_t i = 0; i < 1000; i++) { - curve_Fq e = curve_Fq::random_element(); - - Fq e2(e); - - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << e2; - - Fq e3; - ss >> e3; - - curve_Fq e4 = e3.to_libsnark_fq(); - - ASSERT_TRUE(e == e4); - } -} - -TEST(proofs, fq2_serializes_properly) -{ - for (size_t i = 0; i < 1000; i++) { - curve_Fq2 e = curve_Fq2::random_element(); - - Fq2 e2(e); - - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << e2; - - Fq2 e3; - ss >> e3; - - curve_Fq2 e4 = e3.to_libsnark_fq2(); - - ASSERT_TRUE(e == e4); - } -} - -template -T deserialize_tv(std::string s) -{ - T e; - CDataStream ss(ParseHex(s), SER_NETWORK, PROTOCOL_VERSION); - ss >> e; - - return e; -} - -curve_Fq deserialize_fq(std::string s) -{ - return deserialize_tv(s).to_libsnark_fq(); -} - -curve_Fq2 deserialize_fq2(std::string s) -{ - return deserialize_tv(s).to_libsnark_fq2(); -} - -TEST(proofs, fq_valid) -{ - curve_Fq e = deserialize_fq("30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd46"); - - ASSERT_TRUE(e == curve_Fq("21888242871839275222246405745257275088696311157297823662689037894645226208582")); - ASSERT_TRUE(e != curve_Fq("21888242871839275222246405745257275088696311157297823662689037894645226208581")); - - curve_Fq e2 = deserialize_fq("30644e72e131a029b75045b68181585d97816a916871ca8d3c208c16d87cfd46"); - - ASSERT_TRUE(e2 == curve_Fq("21888242871839275222221885816603420866962577604863418715751138068690288573766")); -} - -TEST(proofs, fq_invalid) -{ - // Should not be able to deserialize the modulus - ASSERT_THROW( - deserialize_fq("30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47"), - std::logic_error - ); - - // Should not be able to deserialize the modulus plus one - ASSERT_THROW( - deserialize_fq("30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd48"), - std::logic_error - ); - - // Should not be able to deserialize a ridiculously out of bound int - ASSERT_THROW( - deserialize_fq("ff644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd46"), - std::logic_error - ); -} - -TEST(proofs, fq2_valid) -{ - // (q - 1) * q + q - curve_Fq2 e = deserialize_fq2("0925c4b8763cbf9c599a6f7c0348d21cb00b85511637560626edfa5c34c6b38d04689e957a1242c84a50189c6d96cadca602072d09eac1013b5458a2275d69b0"); - ASSERT_TRUE(e.c0 == curve_Fq("21888242871839275222246405745257275088696311157297823662689037894645226208582")); - ASSERT_TRUE(e.c1 == curve_Fq("21888242871839275222246405745257275088696311157297823662689037894645226208582")); - - curve_Fq2 e2 = deserialize_fq2("000000000000000000000000000000000000000000000000010245be1c91e3186bbbe1c430a93fcfc5aada4ab10c3492f70eea97a91c7b29554db55acffa34d2"); - ASSERT_TRUE(e2.c0 == curve_Fq("238769481237490823")); - ASSERT_TRUE(e2.c1 == curve_Fq("384579238459723485")); - - curve_Fq2 e3 = deserialize_fq2("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); - ASSERT_TRUE(e3.c0 == curve_Fq("0")); - ASSERT_TRUE(e3.c1 == curve_Fq("0")); - - curve_Fq2 e4 = deserialize_fq2("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"); - ASSERT_TRUE(e4.c0 == curve_Fq("1")); - ASSERT_TRUE(e4.c1 == curve_Fq("0")); -} - -TEST(proofs, fq2_invalid) -{ - // (q - 1) * q + q is invalid - ASSERT_THROW( - deserialize_fq2("0925c4b8763cbf9c599a6f7c0348d21cb00b85511637560626edfa5c34c6b38d04689e957a1242c84a50189c6d96cadca602072d09eac1013b5458a2275d69b1"), - std::logic_error - ); - - // q * q + (q - 1) is invalid - ASSERT_THROW( - deserialize_fq2("0925c4b8763cbf9c599a6f7c0348d21cb00b85511637560626edfa5c34c6b38d34cced085b43e2f202a05e52ef18233a3d8371be725c8b8e7774e4b8ffda66f7"), - std::logic_error - ); - - // Ridiculously out of bounds - ASSERT_THROW( - deserialize_fq2("0fffc4b8763cbf9c599a6f7c0348d21cb00b85511637560626edfa5c34c6b38d04689e957a1242c84a50189c6d96cadca602072d09eac1013b5458a2275d69b0"), - std::logic_error - ); - ASSERT_THROW( - deserialize_fq2("ffffffff763cbf9c599a6f7c0348d21cb00b85511637560626edfa5c34c6b38d04689e957a1242c84a50189c6d96cadca602072d09eac1013b5458a2275d69b0"), - std::logic_error - ); -} - -TEST(proofs, g1_serializes_properly) -{ - // Cannot serialize zero - { - ASSERT_THROW({CompressedG1 g = CompressedG1(curve_G1::zero());}, std::domain_error); - } - - for (size_t i = 0; i < 1000; i++) { - curve_G1 e = curve_G1::random_element(); - - CompressedG1 e2(e); - - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << e2; - - CompressedG1 e3; - ss >> e3; - - ASSERT_TRUE(e2 == e3); - - curve_G1 e4 = e3.to_libsnark_g1(); - - ASSERT_TRUE(e == e4); - } -} - -TEST(proofs, g2_serializes_properly) -{ - // Cannot serialize zero - { - ASSERT_THROW({CompressedG2 g = CompressedG2(curve_G2::zero());}, std::domain_error); - } - - for (size_t i = 0; i < 1000; i++) { - curve_G2 e = curve_G2::random_element(); - - CompressedG2 e2(e); - - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << e2; - - CompressedG2 e3; - ss >> e3; - - ASSERT_TRUE(e2 == e3); - - curve_G2 e4 = e3.to_libsnark_g2(); - - ASSERT_TRUE(e == e4); - } -} - -TEST(proofs, zksnark_serializes_properly) -{ - auto example = libsnark::generate_r1cs_example_with_field_input(250, 4); - example.constraint_system.swap_AB_if_beneficial(); - auto kp = libsnark::r1cs_ppzksnark_generator(example.constraint_system); - auto vkprecomp = libsnark::r1cs_ppzksnark_verifier_process_vk(kp.vk); - - for (size_t i = 0; i < 20; i++) { - auto badproof = PHGRProof::random_invalid(); - auto proof = badproof.to_libsnark_proof>(); - - auto verifierEnabled = ProofVerifier::Strict(); - auto verifierDisabled = ProofVerifier::Disabled(); - // This verifier should catch the bad proof - ASSERT_FALSE(verifierEnabled.check( - kp.vk, - vkprecomp, - example.primary_input, - proof - )); - // This verifier won't! - ASSERT_TRUE(verifierDisabled.check( - kp.vk, - vkprecomp, - example.primary_input, - proof - )); - } - - for (size_t i = 0; i < 20; i++) { - auto proof = libsnark::r1cs_ppzksnark_prover( - kp.pk, - example.primary_input, - example.auxiliary_input, - example.constraint_system - ); - - { - auto verifierEnabled = ProofVerifier::Strict(); - auto verifierDisabled = ProofVerifier::Disabled(); - ASSERT_TRUE(verifierEnabled.check( - kp.vk, - vkprecomp, - example.primary_input, - proof - )); - ASSERT_TRUE(verifierDisabled.check( - kp.vk, - vkprecomp, - example.primary_input, - proof - )); - } - - ASSERT_TRUE(libsnark::r1cs_ppzksnark_verifier_strong_IC( - kp.vk, - example.primary_input, - proof - )); - - PHGRProof compressed_proof_0(proof); - - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << compressed_proof_0; - - PHGRProof compressed_proof_1; - ss >> compressed_proof_1; - - ASSERT_TRUE(compressed_proof_0 == compressed_proof_1); - - auto newproof = compressed_proof_1.to_libsnark_proof>(); - - ASSERT_TRUE(proof == newproof); - ASSERT_TRUE(libsnark::r1cs_ppzksnark_verifier_strong_IC( - kp.vk, - example.primary_input, - newproof - )); - } -} - -TEST(proofs, g1_deserialization) -{ - CompressedG1 g; - curve_G1 expected; - - // Valid G1 element. - { - CDataStream ss(ParseHex("0230644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd46"), SER_NETWORK, PROTOCOL_VERSION); - ss >> g; - - expected.X = curve_Fq("21888242871839275222246405745257275088696311157297823662689037894645226208582"); - expected.Y = curve_Fq("3969792565221544645472939191694882283483352126195956956354061729942568608776"); - expected.Z = curve_Fq::one(); - - ASSERT_TRUE(g.to_libsnark_g1() == expected); - } - - // Its negation. - { - CDataStream ss(ParseHex("0330644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd46"), SER_NETWORK, PROTOCOL_VERSION); - ss >> g; - - expected.X = curve_Fq("21888242871839275222246405745257275088696311157297823662689037894645226208582"); - expected.Y = curve_Fq("3969792565221544645472939191694882283483352126195956956354061729942568608776"); - expected.Z = curve_Fq::one(); - - ASSERT_TRUE(g.to_libsnark_g1() == -expected); - } - - // Invalid leading bytes - { - CDataStream ss(ParseHex("ff30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd46"), SER_NETWORK, PROTOCOL_VERSION); - - ASSERT_THROW(ss >> g, std::ios_base::failure); - } - - // Invalid point - { - CDataStream ss(ParseHex("0208c6d2adffacbc8438f09f321874ea66e2fcc29f8dcfec2caefa21ec8c96a77c"), SER_NETWORK, PROTOCOL_VERSION); - ss >> g; - - ASSERT_THROW(g.to_libsnark_g1(), std::runtime_error); - } - - // Point with out of bounds Fq - { - CDataStream ss(ParseHex("02ffc6d2adffacbc8438f09f321874ea66e2fcc29f8dcfec2caefa21ec8c96a77c"), SER_NETWORK, PROTOCOL_VERSION); - ss >> g; - - ASSERT_THROW(g.to_libsnark_g1(), std::logic_error); - } - - // Randomly produce valid G1 representations and fail/succeed to - // turn them into G1 points based on whether they are valid. - for (size_t i = 0; i < 5000; i++) { - curve_Fq e = curve_Fq::random_element(); - CDataStream ss(ParseHex("02"), SER_NETWORK, PROTOCOL_VERSION); - ss << Fq(e); - CompressedG1 g; - ss >> g; - - try { - curve_G1 g_real = g.to_libsnark_g1(); - } catch(...) { - - } - } -} - -TEST(proofs, g2_deserialization) -{ - CompressedG2 g; - curve_G2 expected = curve_G2::random_element(); - - // Valid G2 point - { - CDataStream ss(ParseHex("0a023aed31b5a9e486366ea9988b05dba469c6206e58361d9c065bbea7d928204a761efc6e4fa08ed227650134b52c7f7dd0463963e8a4bf21f4899fe5da7f984a"), SER_NETWORK, PROTOCOL_VERSION); - ss >> g; - - expected.X = curve_Fq2( - curve_Fq("5923585509243758863255447226263146374209884951848029582715967108651637186684"), - curve_Fq("5336385337059958111259504403491065820971993066694750945459110579338490853570") - ); - expected.Y = curve_Fq2( - curve_Fq("10374495865873200088116930399159835104695426846400310764827677226300185211748"), - curve_Fq("5256529835065685814318509161957442385362539991735248614869838648137856366932") - ); - expected.Z = curve_Fq2::one(); - - ASSERT_TRUE(g.to_libsnark_g2() == expected); - } - - // Its negation - { - CDataStream ss(ParseHex("0b023aed31b5a9e486366ea9988b05dba469c6206e58361d9c065bbea7d928204a761efc6e4fa08ed227650134b52c7f7dd0463963e8a4bf21f4899fe5da7f984a"), SER_NETWORK, PROTOCOL_VERSION); - ss >> g; - - expected.X = curve_Fq2( - curve_Fq("5923585509243758863255447226263146374209884951848029582715967108651637186684"), - curve_Fq("5336385337059958111259504403491065820971993066694750945459110579338490853570") - ); - expected.Y = curve_Fq2( - curve_Fq("10374495865873200088116930399159835104695426846400310764827677226300185211748"), - curve_Fq("5256529835065685814318509161957442385362539991735248614869838648137856366932") - ); - expected.Z = curve_Fq2::one(); - - ASSERT_TRUE(g.to_libsnark_g2() == -expected); - } - - // Invalid leading bytes - { - CDataStream ss(ParseHex("ff023aed31b5a9e486366ea9988b05dba469c6206e58361d9c065bbea7d928204a761efc6e4fa08ed227650134b52c7f7dd0463963e8a4bf21f4899fe5da7f984a"), SER_NETWORK, PROTOCOL_VERSION); - - ASSERT_THROW(ss >> g, std::ios_base::failure); - } - - - // Invalid point - { - CDataStream ss(ParseHex("0b023aed31b5a9e486366ea9988b05dba469c6206e58361d9c065bbea7d928204a761efc6e4fa08ed227650134b52c7f7dd0463963e8a4bf21f4899fe5da7f984b"), SER_NETWORK, PROTOCOL_VERSION); - ss >> g; - - ASSERT_THROW(g.to_libsnark_g2(), std::runtime_error); - } - - // Point with out of bounds Fq2 - { - CDataStream ss(ParseHex("0a0f3aed31b5a9e486366ea9988b05dba469c6206e58361d9c065bbea7d928204a761efc6e4fa08ed227650134b52c7f7dd0463963e8a4bf21f4899fe5da7f984a"), SER_NETWORK, PROTOCOL_VERSION); - ss >> g; - - ASSERT_THROW(g.to_libsnark_g2(), std::logic_error); - } - - // Randomly produce valid G2 representations and fail/succeed to - // turn them into G2 points based on whether they are valid. - for (size_t i = 0; i < 5000; i++) { - curve_Fq2 e = curve_Fq2::random_element(); - CDataStream ss(ParseHex("0a"), SER_NETWORK, PROTOCOL_VERSION); - ss << Fq2(e); - CompressedG2 g; - ss >> g; - - try { - curve_G2 g_real = g.to_libsnark_g2(); - } catch(...) { - - } - } -} - -#include "json_test_vectors.h" -#include "test/data/g1_compressed.json.h" - -TEST(proofs, g1_test_vectors) -{ - UniValue v = read_json(std::string(json_tests::g1_compressed, json_tests::g1_compressed + sizeof(json_tests::g1_compressed))); - - curve_G1 e = curve_Fr("34958239045823") * curve_G1::one(); - for (size_t i = 0; i < 10000; i++) { - e = (curve_Fr("34958239045823") ^ i) * e; - auto expected = CompressedG1(e); - - expect_test_vector(v[i], expected); - ASSERT_TRUE(expected.to_libsnark_g1() == e); - } -} - -#include "test/data/g2_compressed.json.h" - -TEST(proofs, g2_test_vectors) -{ - UniValue v = read_json(std::string(json_tests::g2_compressed, json_tests::g2_compressed + sizeof(json_tests::g2_compressed))); - - curve_G2 e = curve_Fr("34958239045823") * curve_G2::one(); - for (size_t i = 0; i < 10000; i++) { - e = (curve_Fr("34958239045823") ^ i) * e; - auto expected = CompressedG2(e); - - expect_test_vector(v[i], expected); - ASSERT_TRUE(expected.to_libsnark_g2() == e); - } -} diff --git a/src/gtest/test_transaction.cpp b/src/gtest/test_transaction.cpp index 1350768ff..4ba48c3d2 100644 --- a/src/gtest/test_transaction.cpp +++ b/src/gtest/test_transaction.cpp @@ -45,7 +45,6 @@ TEST(Transaction, JSDescriptionRandomized) { { auto jsdesc = JSDescription::Randomized( - false, *params, joinSplitPubKey, rt, inputs, outputs, inputMap, outputMap, @@ -62,7 +61,6 @@ TEST(Transaction, JSDescriptionRandomized) { { auto jsdesc = JSDescription::Randomized( - false, *params, joinSplitPubKey, rt, inputs, outputs, inputMap, outputMap, @@ -76,7 +74,6 @@ TEST(Transaction, JSDescriptionRandomized) { { auto jsdesc = JSDescription::Randomized( - false, *params, joinSplitPubKey, rt, inputs, outputs, inputMap, outputMap, diff --git a/src/init.cpp b/src/init.cpp index 9092a8fa4..bd72c1418 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -60,8 +60,6 @@ #include #include -#include - #if ENABLE_ZMQ #include "zmq/zmqnotificationinterface.h" #endif @@ -528,7 +526,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-rpcservertimeout=", strprintf("Timeout during HTTP requests (default: %d)", DEFAULT_HTTP_SERVER_TIMEOUT)); } - // Disabled until we can lock notes and also tune performance of libsnark which by default uses multiple threads + // Disabled until we can lock notes and also tune performance of the prover which by default uses multiple threads //strUsage += HelpMessageOpt("-rpcasyncthreads=", strprintf(_("Set the number of threads to service Async RPC calls (default: %d)"), 1)); if (mode == HMM_BITCOIND) { @@ -706,15 +704,11 @@ static void ZC_LoadParams( struct timeval tv_start, tv_end; float elapsed; - boost::filesystem::path pk_path = ZC_GetParamsDir() / "sprout-proving.key"; - boost::filesystem::path vk_path = ZC_GetParamsDir() / "sprout-verifying.key"; boost::filesystem::path sapling_spend = ZC_GetParamsDir() / "sapling-spend.params"; boost::filesystem::path sapling_output = ZC_GetParamsDir() / "sapling-output.params"; boost::filesystem::path sprout_groth16 = ZC_GetParamsDir() / "sprout-groth16.params"; if (!( - boost::filesystem::exists(pk_path) && - boost::filesystem::exists(vk_path) && boost::filesystem::exists(sapling_spend) && boost::filesystem::exists(sapling_output) && boost::filesystem::exists(sprout_groth16) @@ -729,14 +723,7 @@ static void ZC_LoadParams( return; } - LogPrintf("Loading verifying key from %s\n", vk_path.string().c_str()); - gettimeofday(&tv_start, 0); - - pzcashParams = ZCJoinSplit::Prepared(vk_path.string(), pk_path.string()); - - gettimeofday(&tv_end, 0); - elapsed = float(tv_end.tv_sec-tv_start.tv_sec) + (tv_end.tv_usec-tv_start.tv_usec)/float(1000000); - LogPrintf("Loaded verifying key in %fs seconds.\n", elapsed); + pzcashParams = ZCJoinSplit::Prepared(); static_assert( sizeof(boost::filesystem::path::value_type) == sizeof(codeunit), @@ -863,8 +850,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError(_("Payment disclosure requires -experimentalfeatures.")); } else if (mapArgs.count("-zmergetoaddress")) { return InitError(_("RPC method z_mergetoaddress requires -experimentalfeatures.")); - } else if (mapArgs.count("-savesproutr1cs")) { - return InitError(_("Saving the Sprout R1CS requires -experimentalfeatures.")); } else if (mapArgs.count("-insightexplorer")) { return InitError(_("Insight explorer requires -experimentalfeatures.")); } @@ -1245,22 +1230,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) threadGroup.create_thread(&ThreadShowMetricsScreen); } - // These must be disabled for now, they are buggy and we probably don't - // want any of libsnark's profiling in production anyway. - libsnark::inhibit_profiling_info = true; - libsnark::inhibit_profiling_counters = true; - // Initialize BitcoinZ circuit parameters ZC_LoadParams(chainparams); - if (GetBoolArg("-savesproutr1cs", false)) { - boost::filesystem::path r1cs_path = ZC_GetParamsDir() / "r1cs"; - - LogPrintf("Saving Sprout R1CS to %s\n", r1cs_path.string()); - - pzcashParams->saveR1CS(r1cs_path.string()); - } - /* Start the RPC server already. It will be started in "warmup" mode * and not really process calls already (but it will signify connections * that the server is there and will be ready later). Warmup mode will diff --git a/src/main.cpp b/src/main.cpp index bdd4b0761..b02078c8e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,6 +114,24 @@ const string strMessageMagic = "BitcoinZ Signed Message:\n"; // Internal stuff namespace { + /** Abort with a message */ + bool AbortNode(const std::string& strMessage, const std::string& userMessage="") + { + SetMiscWarning(strMessage); + LogPrintf("*** %s\n", strMessage); + uiInterface.ThreadSafeMessageBox( + userMessage.empty() ? _("Error: A fatal internal error occurred, see debug.log for details") : userMessage, + "", CClientUIInterface::MSG_ERROR); + StartShutdown(); + return false; + } + + bool AbortNode(CValidationState& state, const std::string& strMessage, const std::string& userMessage="") + { + AbortNode(strMessage, userMessage); + return state.Error(strMessage); + } + struct CBlockIndexWorkComparator { bool operator()(CBlockIndex *pa, CBlockIndex *pb) const { @@ -1849,6 +1867,29 @@ bool IsInitialBlockDownload(const CChainParams& chainParams) return true; if (chainActive.Tip()->nChainWork < UintToArith256(chainParams.GetConsensus().nMinimumChainWork)) return true; + // Don't bother checking Sprout, it is always active. + for (int idx = Consensus::BASE_SPROUT + 1; idx < Consensus::MAX_NETWORK_UPGRADES; idx++) { + // If we expect a particular activation block hash, and either the upgrade is not + // active or it doesn't match the block at that height on the current chain, then + // we are not on the correct chain. As we have already checked that the current + // chain satisfies the minimum chain work, this is likely an adversarial situation + // where the node is being fed a fake alternate chain; shut down for safety. + auto upgrade = chainParams.GetConsensus().vUpgrades[idx]; + if (upgrade.hashActivationBlock && ( + !chainParams.GetConsensus().NetworkUpgradeActive(chainActive.Height(), Consensus::UpgradeIndex(idx)) + || chainActive[upgrade.nActivationHeight]->GetBlockHash() != upgrade.hashActivationBlock.get() + )) { + AbortNode( + strprintf( + "%s: Activation block hash mismatch for the %s network upgrade (expected %s, found %s). Likely adversarial condition; shutting down for safety.", + __func__, + NetworkUpgradeInfo[idx].strName, + upgrade.hashActivationBlock.get().GetHex(), + chainActive[upgrade.nActivationHeight]->GetBlockHash().GetHex()), + _("We are on a chain with sufficient work, but the network upgrade checkpoints do not match. Your node may be under attack! Shutting down for safety.")); + return true; + } + } if (chainActive.Tip()->GetBlockTime() < (GetTime() - nMaxTipAge)) return true; LogPrintf("Leaving InitialBlockDownload (latching to false)\n"); @@ -2236,24 +2277,6 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uin return true; } -/** Abort with a message */ -bool AbortNode(const std::string& strMessage, const std::string& userMessage="") -{ - SetMiscWarning(strMessage); - LogPrintf("*** %s\n", strMessage); - uiInterface.ThreadSafeMessageBox( - userMessage.empty() ? _("Error: A fatal internal error occurred, see debug.log for details") : userMessage, - "", CClientUIInterface::MSG_ERROR); - StartShutdown(); - return false; -} - -bool AbortNode(CValidationState& state, const std::string& strMessage, const std::string& userMessage="") -{ - AbortNode(strMessage, userMessage); - return state.Error(strMessage); -} - } // anon namespace diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 8a4b20327..a0ce86270 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -12,7 +12,6 @@ #include "librustzcash.h" JSDescription::JSDescription( - bool makeGrothProof, ZCJoinSplit& params, const uint256& joinSplitPubKey, const uint256& anchor, @@ -27,7 +26,6 @@ JSDescription::JSDescription( std::array notes; proof = params.prove( - makeGrothProof, inputs, outputs, notes, @@ -47,7 +45,6 @@ JSDescription::JSDescription( } JSDescription JSDescription::Randomized( - bool makeGrothProof, ZCJoinSplit& params, const uint256& joinSplitPubKey, const uint256& anchor, @@ -72,7 +69,6 @@ JSDescription JSDescription::Randomized( MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, gen); return JSDescription( - makeGrothProof, params, joinSplitPubKey, anchor, inputs, outputs, vpub_old, vpub_new, computeProof, esk // payment disclosure @@ -96,18 +92,9 @@ class SproutProofVerifier : public boost::static_visitor bool operator()(const libzcash::PHGRProof& proof) const { - return params.verify( - proof, - verifier, - joinSplitPubKey, - jsdesc.randomSeed, - jsdesc.macs, - jsdesc.nullifiers, - jsdesc.commitments, - jsdesc.vpub_old, - jsdesc.vpub_new, - jsdesc.anchor - ); + // We checkpoint after Sapling activation, so we can skip verification + // for all Sprout proofs. + return true; } bool operator()(const libzcash::GrothProof& proof) const diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 599903cad..d82cd6fed 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -227,7 +227,6 @@ class JSDescription JSDescription(): vpub_old(0), vpub_new(0) { } JSDescription( - bool makeGrothProof, ZCJoinSplit& params, const uint256& joinSplitPubKey, const uint256& rt, @@ -240,7 +239,6 @@ class JSDescription ); static JSDescription Randomized( - bool makeGrothProof, ZCJoinSplit& params, const uint256& joinSplitPubKey, const uint256& rt, diff --git a/src/snark/.gitignore b/src/snark/.gitignore deleted file mode 100644 index ea2a20f44..000000000 --- a/src/snark/.gitignore +++ /dev/null @@ -1,51 +0,0 @@ -*.o -*.a -*.so -*.d -libsnark/gtests -depinst/ -depsrc/ -README.html -doxygen/ -libsnark/gtests -libsnark/gadgetlib2/examples/tutorial -libsnark/gadgetlib2/tests/gadgetlib2_test - -libsnark/algebra/curves/tests/test_bilinearity -libsnark/algebra/curves/tests/test_groups -libsnark/algebra/fields/tests/test_fields -libsnark/common/routing_algorithms/profiling/profile_routing_algorithms -libsnark/common/routing_algorithms/tests/test_routing_algorithms -libsnark/gadgetlib1/gadgets/cpu_checkers/fooram/examples/test_fooram -libsnark/gadgetlib1/gadgets/hashes/knapsack/tests/test_knapsack_gadget -libsnark/gadgetlib1/gadgets/hashes/sha256/tests/test_sha256_gadget -libsnark/gadgetlib1/gadgets/merkle_tree/tests/test_merkle_tree_gadgets -libsnark/gadgetlib1/gadgets/routing/profiling/profile_routing_gadgets -libsnark/gadgetlib1/gadgets/set_commitment/tests/test_set_commitment_gadget -libsnark/gadgetlib1/gadgets/verifiers/tests/test_r1cs_ppzksnark_verifier_gadget -libsnark/reductions/ram_to_r1cs/examples/demo_arithmetization -libsnark/relations/arithmetic_programs/qap/tests/test_qap -libsnark/relations/arithmetic_programs/ssp/tests/test_ssp -libsnark/zk_proof_systems/pcd/r1cs_pcd/r1cs_mp_ppzkpcd/profiling/profile_r1cs_mp_ppzkpcd -libsnark/zk_proof_systems/pcd/r1cs_pcd/r1cs_mp_ppzkpcd/tests/test_r1cs_mp_ppzkpcd -libsnark/zk_proof_systems/pcd/r1cs_pcd/r1cs_sp_ppzkpcd/profiling/profile_r1cs_sp_ppzkpcd -libsnark/zk_proof_systems/pcd/r1cs_pcd/r1cs_sp_ppzkpcd/tests/test_r1cs_sp_ppzkpcd -libsnark/zk_proof_systems/ppzkadsnark/r1cs_ppzkadsnark/examples/demo_r1cs_ppzkadsnark -libsnark/zk_proof_systems/ppzksnark/bacs_ppzksnark/profiling/profile_bacs_ppzksnark -libsnark/zk_proof_systems/ppzksnark/bacs_ppzksnark/tests/test_bacs_ppzksnark -libsnark/zk_proof_systems/ppzksnark/r1cs_gg_ppzksnark/profiling/profile_r1cs_gg_ppzksnark -libsnark/zk_proof_systems/ppzksnark/r1cs_gg_ppzksnark/tests/test_r1cs_gg_ppzksnark -libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/profiling/profile_r1cs_ppzksnark -libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/tests/test_r1cs_ppzksnark -libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/examples/demo_ram_ppzksnark -libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/examples/demo_ram_ppzksnark_generator -libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/examples/demo_ram_ppzksnark_prover -libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/examples/demo_ram_ppzksnark_verifier -libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/profiling/profile_ram_ppzksnark -libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/tests/test_ram_ppzksnark -libsnark/zk_proof_systems/ppzksnark/tbcs_ppzksnark/profiling/profile_tbcs_ppzksnark -libsnark/zk_proof_systems/ppzksnark/tbcs_ppzksnark/tests/test_tbcs_ppzksnark -libsnark/zk_proof_systems/ppzksnark/uscs_ppzksnark/profiling/profile_uscs_ppzksnark -libsnark/zk_proof_systems/ppzksnark/uscs_ppzksnark/tests/test_uscs_ppzksnark -libsnark/zk_proof_systems/zksnark/ram_zksnark/profiling/profile_ram_zksnark -libsnark/zk_proof_systems/zksnark/ram_zksnark/tests/test_ram_zksnark diff --git a/src/snark/AUTHORS b/src/snark/AUTHORS deleted file mode 100644 index 1b2d7a247..000000000 --- a/src/snark/AUTHORS +++ /dev/null @@ -1,19 +0,0 @@ -SCIPR Lab: - Eli Ben-Sasson - Alessandro Chiesa - Daniel Genkin - Shaul Kfir - Eran Tromer - Madars Virza - -External contributors: - Michael Backes - Manuel Barbosa - Dario Fiore - Jens Groth - Joshua A. Kroll - Shigeo MITSUNARI - Raphael Reischuk - Tadanori TERUYA - Sean Bowe - Daira Hopwood diff --git a/src/snark/LICENSE b/src/snark/LICENSE deleted file mode 100644 index 81cea11e1..000000000 --- a/src/snark/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -The libsnark library is developed by SCIPR Lab (http://scipr-lab.org) -and contributors. - -Copyright (c) 2012-2014 SCIPR Lab and contributors (see AUTHORS file). - -All files, with the exceptions below, are released under the MIT License: - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. diff --git a/src/snark/Makefile b/src/snark/Makefile deleted file mode 100644 index aff19c603..000000000 --- a/src/snark/Makefile +++ /dev/null @@ -1,285 +0,0 @@ -#******************************************************************************** -# Makefile for the libsnark library. -#******************************************************************************** -#* @author This file is part of libsnark, developed by SCIPR Lab -#* and contributors (see AUTHORS). -#* @copyright MIT license (see LICENSE file) -#*******************************************************************************/ - -# To override these, use "make OPTFLAGS=..." etc. -CURVE = BN128 -OPTFLAGS = -O2 -march=native -mtune=native -FEATUREFLAGS = -DUSE_ASM -DMONTGOMERY_OUTPUT - -# Initialize this using "CXXFLAGS=... make". The makefile appends to that. -CXXFLAGS += -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wno-comment -Wfatal-errors $(OPTFLAGS) $(FEATUREFLAGS) -DCURVE_$(CURVE) - -DEPSRC = depsrc -DEPINST = depinst - -CXXFLAGS += -I$(DEPINST)/include -Ilibsnark -LDFLAGS += -L$(DEPINST)/lib -Wl,-rpath,$(DEPINST)/lib -LDLIBS += -lgmpxx -lgmp -lboost_program_options -lsodium -# List of .a files to include within libsnark.a and libsnark.so: -AR_LIBS = -# List of library files to install: -INSTALL_LIBS = $(LIB_FILE) -# Sentinel file to check existence of this directory (since directories don't work as a Make dependency): -DEPINST_EXISTS = $(DEPINST)/.exists - -ifneq ($(NO_GTEST),1) - # Compile GTest from sourcecode if we can (e.g., Ubuntu). Otherwise use precompiled one (e.g., Fedora). - # See https://github.com/google/googletest/blob/master/googletest/docs/FAQ.md#why-is-it-not-recommended-to-install-a-pre-compiled-copy-of-google-test-for-example-into-usrlocal - ifneq ($(NO_COMPILE_LIBGTEST),1) - GTESTDIR=/usr/src/gtest - COMPILE_LIBGTEST = $(shell test -d $(GTESTDIR) && echo -n 1) - endif - GTEST_LDLIBS += -lgtest -lpthread -endif - -ifneq ($(NO_SUPERCOP),1) - SUPERCOP_LDLIBS += -lsupercop - INSTALL_LIBS += depinst/lib/libsupercop.a - # Would have been nicer to roll supercop into libsnark.a ("AR_LIBS += $(DEPINST)/lib/libsupercop.a"), but it doesn't support position-independent code (libsnark issue #20). -endif - -LIB_SRCS = \ - libsnark/algebra/curves/alt_bn128/alt_bn128_g1.cpp \ - libsnark/algebra/curves/alt_bn128/alt_bn128_g2.cpp \ - libsnark/algebra/curves/alt_bn128/alt_bn128_init.cpp \ - libsnark/algebra/curves/alt_bn128/alt_bn128_pairing.cpp \ - libsnark/algebra/curves/alt_bn128/alt_bn128_pp.cpp \ - libsnark/common/profiling.cpp \ - libsnark/common/utils.cpp \ - libsnark/gadgetlib1/constraint_profiling.cpp \ - -ifeq ($(CURVE),BN128) - LIB_SRCS += \ - libsnark/algebra/curves/bn128/bn128_g1.cpp \ - libsnark/algebra/curves/bn128/bn128_g2.cpp \ - libsnark/algebra/curves/bn128/bn128_gt.cpp \ - libsnark/algebra/curves/bn128/bn128_init.cpp \ - libsnark/algebra/curves/bn128/bn128_pairing.cpp \ - libsnark/algebra/curves/bn128/bn128_pp.cpp - - CXXFLAGS += -DBN_SUPPORT_SNARK - AR_LIBS += $(DEPINST)/lib/libzm.a -endif - -# FIXME: most of these are broken due to removed code. -DISABLED_EXECUTABLES = \ - libsnark/common/routing_algorithms/profiling/profile_routing_algorithms \ - libsnark/common/routing_algorithms/tests/test_routing_algorithms \ - libsnark/gadgetlib1/gadgets/cpu_checkers/fooram/examples/test_fooram \ - libsnark/gadgetlib1/gadgets/hashes/knapsack/tests/test_knapsack_gadget \ - libsnark/gadgetlib1/gadgets/routing/profiling/profile_routing_gadgets \ - libsnark/gadgetlib1/gadgets/set_commitment/tests/test_set_commitment_gadget \ - libsnark/gadgetlib1/gadgets/verifiers/tests/test_r1cs_ppzksnark_verifier_gadget \ - libsnark/reductions/ram_to_r1cs/examples/demo_arithmetization \ - libsnark/relations/arithmetic_programs/ssp/tests/test_ssp \ - libsnark/zk_proof_systems/pcd/r1cs_pcd/r1cs_mp_ppzkpcd/profiling/profile_r1cs_mp_ppzkpcd \ - libsnark/zk_proof_systems/pcd/r1cs_pcd/r1cs_mp_ppzkpcd/tests/test_r1cs_mp_ppzkpcd \ - libsnark/zk_proof_systems/pcd/r1cs_pcd/r1cs_sp_ppzkpcd/profiling/profile_r1cs_sp_ppzkpcd \ - libsnark/zk_proof_systems/pcd/r1cs_pcd/r1cs_sp_ppzkpcd/tests/test_r1cs_sp_ppzkpcd \ - libsnark/zk_proof_systems/ppzksnark/bacs_ppzksnark/profiling/profile_bacs_ppzksnark \ - libsnark/zk_proof_systems/ppzksnark/bacs_ppzksnark/tests/test_bacs_ppzksnark \ - libsnark/zk_proof_systems/ppzksnark/r1cs_gg_ppzksnark/profiling/profile_r1cs_gg_ppzksnark \ - libsnark/zk_proof_systems/ppzksnark/r1cs_gg_ppzksnark/tests/test_r1cs_gg_ppzksnark \ - libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/profiling/profile_r1cs_ppzksnark \ - libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/examples/demo_ram_ppzksnark \ - libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/examples/demo_ram_ppzksnark_generator \ - libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/examples/demo_ram_ppzksnark_prover \ - libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/examples/demo_ram_ppzksnark_verifier \ - libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/profiling/profile_ram_ppzksnark \ - libsnark/zk_proof_systems/ppzksnark/ram_ppzksnark/tests/test_ram_ppzksnark \ - libsnark/zk_proof_systems/ppzksnark/tbcs_ppzksnark/profiling/profile_tbcs_ppzksnark \ - libsnark/zk_proof_systems/ppzksnark/tbcs_ppzksnark/tests/test_tbcs_ppzksnark \ - libsnark/zk_proof_systems/ppzksnark/uscs_ppzksnark/profiling/profile_uscs_ppzksnark \ - libsnark/zk_proof_systems/ppzksnark/uscs_ppzksnark/tests/test_uscs_ppzksnark \ - libsnark/zk_proof_systems/zksnark/ram_zksnark/profiling/profile_ram_zksnark \ - libsnark/zk_proof_systems/zksnark/ram_zksnark/tests/test_ram_zksnark - -EXECUTABLES = - -EXECUTABLES_WITH_GTEST = - -EXECUTABLES_WITH_SUPERCOP = \ - libsnark/zk_proof_systems/ppzkadsnark/r1cs_ppzkadsnark/examples/demo_r1cs_ppzkadsnark - -GTEST_TESTS = libsnark/gtests - -GTEST_SRCS = \ - libsnark/algebra/curves/tests/test_bilinearity.cpp \ - libsnark/algebra/curves/tests/test_groups.cpp \ - libsnark/algebra/fields/tests/test_bigint.cpp \ - libsnark/algebra/fields/tests/test_fields.cpp \ - libsnark/gadgetlib1/gadgets/hashes/sha256/tests/test_sha256_gadget.cpp \ - libsnark/gadgetlib1/gadgets/merkle_tree/tests/test_merkle_tree_gadgets.cpp \ - libsnark/relations/arithmetic_programs/qap/tests/test_qap.cpp \ - libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/tests/test_r1cs_ppzksnark.cpp \ - libsnark/gtests.cpp - -DOCS = README.html - -LIBSNARK_A = libsnark.a - -# For documentation of the following options, see README.md . - -ifeq ($(NO_PROCPS),1) - CXXFLAGS += -DNO_PROCPS -else - LDLIBS += -lprocps -endif - -ifeq ($(LOWMEM),1) - CXXFLAGS += -DLOWMEM -endif - -ifeq ($(PROFILE_OP_COUNTS),1) - STATIC = 1 - CXXFLAGS += -DPROFILE_OP_COUNTS -endif - -ifeq ($(STATIC),1) -ifneq ($(PLATFORM),darwin) - CXXFLAGS += -static -endif - CXXFLAGS += -DSTATIC -else - CXXFLAGS += -fPIC -endif - -ifeq ($(MULTICORE),1) - CXXFLAGS += -DMULTICORE -fopenmp -endif - -ifeq ($(CPPDEBUG),1) - CXXFLAGS += -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC - DEBUG = 1 -endif - -ifeq ($(DEBUG),1) - CXXFLAGS += -DDEBUG -ggdb3 -endif - -ifeq ($(PERFORMANCE),1) - OPTFLAGS = -O3 -march=native -mtune=native - CXXFLAGS += -DNDEBUG - # Enable link-time optimization: - CXXFLAGS += -flto -fuse-linker-plugin - LDFLAGS += -flto -endif - -LIB_OBJS =$(patsubst %.cpp,%.o,$(LIB_SRCS)) -EXEC_OBJS =$(patsubst %,%.o,$(EXECUTABLES) $(EXECUTABLES_WITH_GTEST) $(EXECUTABLES_WITH_SUPERCOP)) -GTEST_OBJS =$(patsubst %.cpp,%.o,$(GTEST_SRCS)) - -all: \ - $(if $(NO_GTEST),,$(EXECUTABLES_WITH_GTEST) $(GTEST_TESTS)) \ - $(if $(NO_SUPERCOP),,$(EXECUTABLES_WITH_SUPERCOP)) \ - $(EXECUTABLES) \ - $(if $(NO_DOCS),,doc) - -doc: $(DOCS) - -$(DEPINST_EXISTS): - # Create placeholder directories for installed dependencies. Some make settings (including the default) require actually running ./prepare-depends.sh to populate this directory. - mkdir -p $(DEPINST)/lib $(DEPINST)/include - touch $@ - -# In order to detect changes to #include dependencies. -MMD below generates a .d file for each .o file. Include the .d file. --include $(patsubst %.o,%.d, $(LIB_OBJS) $(GTEST_OBJS) $(EXEC_OBJS) ) - -$(LIB_OBJS) $(if $(NO_GTEST),,$(GTEST_OBJS)) $(EXEC_OBJS): %.o: %.cpp - $(CXX) -o $@ $< -c -MMD $(CXXFLAGS) - -LIBGTEST_A = $(DEPINST)/lib/libgtest.a - -$(LIBGTEST_A): $(GTESTDIR)/libsnark/gtest-all.cc $(DEPINST_EXISTS) - $(CXX) -o $(DEPINST)/lib/gtest-all.o -I $(GTESTDIR) -c -isystem $(GTESTDIR)/include $< $(CXXFLAGS) - $(AR) -rv $(LIBGTEST_A) $(DEPINST)/lib/gtest-all.o - -# libsnark.a will contains all of our relevant object files, and we also mash in the .a files of relevant dependencies built by ./prepare-depends.sh -$(LIBSNARK_A): $(LIB_OBJS) $(AR_LIBS) - $(AR) q $(LIBSNARK_A) $(LIB_OBJS) - if [ -n "$(AR_LIBS)" ]; then mkdir -p tmp-ar; cd tmp-ar; for AR_LIB in $(AR_LIBS); do $(AR) x $$AR_LIB; done; $(AR) qc $(LIBSNARK_A) tmp-ar/*; cd ..; rm -r tmp-ar; fi; - $(AR) s $(LIBSNARK_A) - -libsnark.so: $(LIBSNARK_A) $(DEPINST_EXISTS) - $(CXX) -o $@ --shared -Wl,--whole-archive $(LIBSNARK_A) $(CXXFLAGS) $(LDFLAGS) -Wl,--no-whole-archive $(LDLIBS) - -libsnark/gadgetlib2/tests/gadgetlib2_test: \ - libsnark/gadgetlib2/tests/adapters_UTEST.cpp \ - libsnark/gadgetlib2/tests/constraint_UTEST.cpp \ - libsnark/gadgetlib2/tests/gadget_UTEST.cpp \ - libsnark/gadgetlib2/tests/integration_UTEST.cpp \ - libsnark/gadgetlib2/tests/protoboard_UTEST.cpp \ - libsnark/gadgetlib2/tests/variable_UTEST.cpp - -$(EXECUTABLES): %: %.o $(LIBSNARK_A) $(DEPINST_EXISTS) - $(CXX) -o $@ $@.o $(LIBSNARK_A) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) - -$(EXECUTABLES_WITH_GTEST): %: %.o $(LIBSNARK_A) $(if $(COMPILE_LIBGTEST),$(LIBGTEST_A)) $(DEPINST_EXISTS) - $(CXX) -o $@ $@.o $(LIBSNARK_A) $(CXXFLAGS) $(LDFLAGS) $(GTEST_LDLIBS) $(LDLIBS) - -$(EXECUTABLES_WITH_SUPERCOP): %: %.o $(LIBSNARK_A) $(DEPINST_EXISTS) - $(CXX) -o $@ $@.o $(LIBSNARK_A) $(CXXFLAGS) $(LDFLAGS) $(SUPERCOP_LDLIBS) $(LDLIBS) - -$(GTEST_TESTS): %: $(GTEST_OBJS) $(LIBSNARK_A) $(if $(COMPILE_LIBGTEST),$(LIBGTEST_A)) $(DEPINST_EXISTS) - $(CXX) -o $@ $(GTEST_OBJS) $(LIBSNARK_A) $(CXXFLAGS) $(LDFLAGS) $(GTEST_LDLIBS) $(LDLIBS) - - -ifeq ($(STATIC),1) -LIB_FILE = $(LIBSNARK_A) -else -LIB_FILE = libsnark.so -endif - -lib: $(LIB_FILE) - -$(DOCS): %.html: %.md - markdown_py -f $@ $^ -x toc -x extra --noisy -# TODO: Would be nice to enable "-x smartypants" but Ubuntu 12.04 doesn't support that. -# TODO: switch to redcarpet, to produce same output as GitHub's processing of README.md. But what about TOC? - -ifeq ($(PREFIX),) -install: - $(error Please provide PREFIX. E.g. make install PREFIX=/usr) -else -HEADERS_SRC=$(shell find libsnark -name '*.hpp' -o -name '*.tcc') -HEADERS_DEST=$(patsubst libsnark/%,$(PREFIX)/include/libsnark/%,$(HEADERS_SRC)) - -$(HEADERS_DEST): $(PREFIX)/include/libsnark/%: libsnark/% - mkdir -p $(shell dirname $@) - cp $< $@ - -install: $(INSTALL_LIBS) $(HEADERS_DEST) $(DEPINST_EXISTS) - mkdir -p $(PREFIX)/lib - cp -v $(INSTALL_LIBS) $(PREFIX)/lib/ -ifneq ($(NO_COPY_DEPINST),1) - cp -rv $(DEPINST)/include $(PREFIX) -endif -endif - -check: $(GTEST_TESTS) - $(GTEST_TESTS) - -doxy: - doxygen doxygen.conf - -# Clean generated files, except locally-compiled dependencies -clean: - $(RM) \ - $(LIB_OBJS) $(GTEST_OBJS) $(EXEC_OBJS) \ - $(EXECUTABLES) $(EXECUTABLES_WITH_GTEST) $(EXECUTABLES_WITH_SUPERCOP) $(GTEST_TESTS) \ - $(DOCS) \ - ${patsubst %.o,%.d,${LIB_OBJS} ${GTEST_OBJS} ${EXEC_OBJS}} \ - libsnark.so $(LIBSNARK_A) \ - $(RM) -fr doxygen/ \ - $(RM) $(LIBGTEST_A) $(DEPINST)/lib/gtest-all.o - -# Clean all, including locally-compiled dependencies -clean-all: clean - $(RM) -fr $(DEPSRC) $(DEPINST) - -.PHONY: all clean clean-all doc doxy lib install diff --git a/src/snark/README.md b/src/snark/README.md deleted file mode 100644 index 89183b43a..000000000 --- a/src/snark/README.md +++ /dev/null @@ -1,628 +0,0 @@ -libsnark: a C++ library for zkSNARK proofs -================================================================================ - --------------------------------------------------------------------------------- -Authors --------------------------------------------------------------------------------- - -The libsnark library is developed by the [SCIPR Lab] project and contributors -and is released under the MIT License (see the [LICENSE] file). - -Copyright (c) 2012-2014 SCIPR Lab and contributors (see [AUTHORS] file). - --------------------------------------------------------------------------------- -[TOC] - - - --------------------------------------------------------------------------------- -Overview --------------------------------------------------------------------------------- - -This library implements __zkSNARK__ schemes, which are a cryptographic method -for proving/verifying, in zero knowledge, the integrity of computations. - -A computation can be expressed as an NP statement, in forms such as the following: - -- "The C program _foo_, when executed, returns exit code 0 if given the input _bar_ and some additional input _qux_." -- "The Boolean circuit _foo_ is satisfiable by some input _qux_." -- "The arithmetic circuit _foo_ accepts the partial assignment _bar_, when extended into some full assignment _qux_." -- "The set of constraints _foo_ is satisfiable by the partial assignment _bar_, when extended into some full assignment _qux_." - -A prover who knows the witness for the NP statement (i.e., a satisfying input/assignment) can produce a short proof attesting to the truth of the NP statement. This proof can be verified by anyone, and offers the following properties. - -- __Zero knowledge:__ - the verifier learns nothing from the proof beside the truth of the statement (i.e., the value _qux_, in the above examples, remains secret). -- __Succinctness:__ - the proof is short and easy to verify. -- __Non-interactivity:__ - the proof is a string (i.e. it does not require back-and-forth interaction between the prover and the verifier). -- __Soundness:__ - the proof is computationally sound (i.e., it is infeasible to fake a proof of a false NP statement). Such a proof system is also called an _argument_. -- __Proof of knowledge:__ - the proof attests not just that the NP statement is true, but also that the - prover knows why (e.g., knows a valid _qux_). - -These properties are summarized by the _zkSNARK_ acronym, which stands for _Zero-Knowledge Succinct Non-interactive ARgument of Knowledge_ (though zkSNARKs are also knows as -_succinct non-interactive computationally-sound zero-knowledge proofs of knowledge_). -For formal definitions and theoretical discussions about these, see -\[BCCT12], \[BCIOP13], and the references therein. - -The libsnark library currently provides a C++ implementation of: - -1. General-purpose proof systems: - 1. A preprocessing zkSNARK for the NP-complete language "R1CS" - (_Rank-1 Constraint Systems_), which is a language that is similar to arithmetic - circuit satisfiability. - 2. A preprocessing SNARK for a language of arithmetic circuits, "BACS" - (_Bilinear Arithmetic Circuit Satisfiability_). This simplifies the writing - of NP statements when the additional flexibility of R1CS is not needed. - Internally, it reduces to R1CS. - 3. A preprocessing SNARK for the language "USCS" - (_Unitary-Square Constraint Systems_). This abstracts and implements the core - contribution of \[DFGK14] - 4. A preprocessing SNARK for a language of Boolean circuits, "TBCS" - (_Two-input Boolean Circuit Satisfiability_). Internally, it reduces to USCS. - This is much more efficient than going through R1CS. - 5. ADSNARK, a preprocessing SNARKs for proving statements on authenticated - data, as described in \[BBFR15]. - 6. Proof-Carrying Data (PCD). This uses recursive composition of SNARKs, as - explained in \[BCCT13] and optimized in \[BCTV14b]. -2. Gadget libraries (gadgetlib1 and gadgetlib2) for constructing R1CS - instances out of modular "gadget" classes. -3. Examples of applications that use the above proof systems to prove - statements about: - 1. Several toy examples. - 2. Execution of TinyRAM machine code, as explained in \[BCTV14a] and - \[BCGTV13]. (Such machine code can be obtained, e.g., by compiling from C.) - This is easily adapted to any other Random Access Machine that satisfies a - simple load-store interface. - 3. A scalable for TinyRAM using Proof-Carrying Data, as explained in \[BCTV14b] - 4. Zero-knowledge cluster MapReduce, as explained in \[CTV15]. - -The zkSNARK construction implemented by libsnark follows, extends, and -optimizes the approach described in \[BCTV14], itself an extension of -\[BCGTV13], following the approach of \[BCIOP13] and \[GGPR13]. An alternative -implementation of the basic approach is the _Pinocchio_ system of \[PGHR13]. -See these references for discussions of efficiency aspects that arise in -practical use of such constructions, as well as security and trust -considerations. - -This scheme is a _preprocessing zkSNARK_ (_ppzkSNARK_): before proofs can be -created and verified, one needs to first decide on a size/circuit/system -representing the NP statements to be proved, and run a _generator_ algorithm to -create corresponding public parameters (a long proving key and a short -verification key). - -Using the library involves the following high-level steps: - -1. Express the statements to be proved as an R1CS (or any of the other - languages above, such as arithmetic circuits, Boolean circuits, or TinyRAM). - This is done by writing C++ code that constructs an R1CS, and linking this code - together with libsnark -2. Use libsnark's generator algorithm to create the public parameters for this - statement (once and for all). -3. Use libsnark's prover algorithm to create proofs of true statements about - the satisfiability of the R1CS. -4. Use libsnark's verifier algorithm to check proofs for alleged statements. - - --------------------------------------------------------------------------------- -The NP-complete language R1CS --------------------------------------------------------------------------------- - -The ppzkSNARK supports proving/verifying membership in a specific NP-complete -language: R1CS (*rank-1 constraint systems*). An instance of the language is -specified by a set of equations over a prime field F, and each equation looks like: - < A, (1,X) > * < B , (1,X) > = < C, (1,X) > -where A,B,C are vectors over F, and X is a vector of variables. - -In particular, arithmetic (as well as boolean) circuits are easily reducible to -this language by converting each gate into a rank-1 constraint. See \[BCGTV13] -Appendix E (and "System of Rank 1 Quadratic Equations") for more details about this. - - --------------------------------------------------------------------------------- -Elliptic curve choices --------------------------------------------------------------------------------- - -The ppzkSNARK can be instantiated with different parameter choices, depending on -which elliptic curve is used. The libsnark library currently provides three -options: - -* "edwards": - an instantiation based on an Edwards curve, providing 80 bits of security. - -* "bn128": - an instantiation based on a Barreto-Naehrig curve, providing 128 - bits of security. The underlying curve implementation is - \[ate-pairing], which has incorporated our patch that changes the - BN curve to one suitable for SNARK applications. - - * This implementation uses dynamically-generated machine code for the curve - arithmetic. Some modern systems disallow execution of code on the heap, and - will thus block this implementation. - - For example, on Fedora 20 at its default settings, you will get the error - `zmInit ERR:can't protect` when running this code. To solve this, - run `sudo setsebool -P allow_execheap 1` to allow execution, - or use `make CURVE=ALT_BN128` instead. - -* "alt_bn128": - an alternative to "bn128", somewhat slower but avoids dynamic code generation. - -Note that bn128 requires an x86-64 CPU while the other curve choices -should be architecture-independent; see [portability](#portability). - - --------------------------------------------------------------------------------- -Gadget libraries --------------------------------------------------------------------------------- - -The libsnark library currently provides two libraries for conveniently constructing -R1CS instances out of reusable "gadgets". Both libraries provide a way to construct -gadgets on other gadgets as well as additional explicit equations. In this way, -complex R1CS instances can be built bottom up. - -### gadgetlib1 - -This is a low-level library which expose all features of the preprocessing -zkSNARK for R1CS. Its design is based on templates (as does the ppzkSNARK code) -to efficiently support working on multiple elliptic curves simultaneously. This -library is used for most of the constraint-building in libsnark, both internal -(reductions and Proof-Carrying Data) and examples applications. - -### gadgetlib2 - -This is an alternative library for constructing systems of polynomial equations -and, in particular, also R1CS instances. It is better documented and easier to -use than gadgetlib1, and its interface does not use templates. However, fewer -useful gadgets are provided. - - --------------------------------------------------------------------------------- -Security --------------------------------------------------------------------------------- - -The theoretical security of the underlying mathematical constructions, and the -requisite assumptions, are analyzed in detailed in the aforementioned research -papers. - -** -This code is a research-quality proof of concept, and has not -yet undergone extensive review or testing. It is thus not suitable, -as is, for use in critical or production systems. -** - -Known issues include the following: - -* The ppzkSNARK's generator and prover exhibit data-dependent running times - and memory usage. These form timing and cache-contention side channels, - which may be an issue in some applications. - -* Randomness is retrieved from /dev/urandom, but this should be - changed to a carefully considered (depending on system and threat - model) external, high-quality randomness source when creating - long-term proving/verification keys. - - --------------------------------------------------------------------------------- -Build instructions --------------------------------------------------------------------------------- - -The libsnark library relies on the following: - -- C++ build environment -- GMP for certain bit-integer arithmetic -- libprocps for reporting memory usage -- GTest for some of the unit tests - -So far we have tested these only on Linux, though we have been able to make the library work, -with some features disabled (such as memory profiling or GTest tests), on Windows via Cygwin -and on Mac OS X. (If you succeed in achieving more complete ports of the library, please -let us know!) See also the notes on [portability](#portability) below. - -For example, on a fresh install of Ubuntu 14.04, install the following packages: - - $ sudo apt-get install build-essential git libgmp3-dev libprocps3-dev libgtest-dev python-markdown libboost-all-dev libssl-dev - -Or, on Fedora 20: - - $ sudo yum install gcc-c++ make git gmp-devel procps-ng-devel gtest-devel python-markdown - -Run the following, to fetch dependencies from their GitHub repos and compile them. -(Not required if you set `CURVE` to other than the default `BN128` and also set `NO_SUPERCOP=1`.) - - $ ./prepare-depends.sh - -Then, to compile the library, tests, profiling harness and documentation, run: - - $ make - -To create just the HTML documentation, run - - $ make doc - -and then view the resulting `README.html` (which contains the very text you are reading now). - -To create Doxygen documentation summarizing all files, classes and functions, -with some (currently sparse) comments, install the `doxygen` and `graphviz` packages, then run - - $ make doxy - -(this may take a few minutes). Then view the resulting [`doxygen/index.html`](doxygen/index.html). - -### Using libsnark as a library - -To develop an application that uses libsnark, you could add it within the libsnark directory tree and adjust the Makefile, but it is far better to build libsnark as a (shared or static) library. You can then write your code in a separate directory tree, and link it against libsnark. - - -To build just the shared object library `libsnark.so`, run: - - $ make lib - -To build just the static library `libsnark.a`, run: - - $ make lib STATIC=1 - -Note that static compilation requires static versions of all libraries it depends on. -It may help to minimize these dependencies by appending -`CURVE=ALT_BN128 NO_PROCPS=1 NO_GTEST=1 NO_SUPERCOP=1`. On Fedora 21, the requisite -library RPM dependencies are then: -`boost-static glibc-static gmp-static libstdc++-static openssl-static zlib-static - boost-devel glibc-devel gmp-devel gmp-devel libstdc++-devel openssl-devel openssl-devel`. - -To build *and install* the libsnark library: - - $ make install PREFIX=/install/path - -This will install `libsnark.so` into `/install/path/lib`; so your application should be linked using `-L/install/path/lib -lsnark`. It also installs the requisite headers into `/install/path/include`; so your application should be compiled using `-I/install/path/include`. - -In addition, unless you use `NO_SUPERCOP=1`, `libsupercop.a` will be installed and should be linked in using `-lsupercop`. - - -### Building on Windows using Cygwin -Install Cygwin using the graphical installer, including the `g++`, `libgmp` -and `git` packages. Then disable the dependencies not easily supported under CygWin, -using: - - $ make NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 - - -### Building on Mac OS X - -On Mac OS X, install GMP from MacPorts (`port install gmp`). Then disable the -dependencies not easily supported under CygWin, using: - - $ make NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 - -MacPorts does not write its libraries into standard system folders, so you -might need to explicitly provide the paths to the header files and libraries by -appending `CXXFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib` to the line -above. Similarly, to pass the paths to ate-pairing you would run -`INC_DIR=-I/opt/local/include LIB_DIR=-L/opt/local/lib ./prepare-depends.sh` -instead of `./prepare-depends.sh` above. - --------------------------------------------------------------------------------- -Tutorials --------------------------------------------------------------------------------- - -libsnark includes a tutorial, and some usage examples, for the high-level API. - -* `src/gadgetlib1/examples1` contains a simple example for constructing a - constraint system using gadgetlib1. - -* `src/gadgetlib2/examples` contains a tutorial for using gadgetlib2 to express - NP statements as constraint systems. It introduces basic terminology, design - overview, and recommended programming style. It also shows how to invoke - ppzkSNARKs on such constraint systems. The main file, `tutorial.cpp`, builds - into a standalone executable. - -* `src/zk_proof_systems/ppzksnark/r1cs_ppzksnark/profiling/profile_r1cs_ppzksnark.cpp` - constructs a simple constraint system and runs the ppzksnark. See below for how to - run it. - - --------------------------------------------------------------------------------- -Executing profiling example --------------------------------------------------------------------------------- - -The command - - $ src/zk_proof_systems/ppzksnark/r1cs_ppzksnark/profiling/profile_r1cs_ppzksnark 1000 10 Fr - -exercises the ppzkSNARK (first generator, then prover, then verifier) on an -R1CS instance with 1000 equations and an input consisting of 10 field elements. - -(If you get the error `zmInit ERR:can't protect`, see the discussion -[above](#elliptic-curve-choices).) - -The command - - $ src/zk_proof_systems/ppzksnark/r1cs_ppzksnark/profiling/profile_r1cs_ppzksnark 1000 10 bytes - -does the same but now the input consists of 10 bytes. - - --------------------------------------------------------------------------------- -Build options --------------------------------------------------------------------------------- - -The following flags change the behavior of the compiled code. - -* `make FEATUREFLAGS='-Dname1 -Dname2 ...'` - - Override the active conditional #define names (you can see the default at the top of the Makefile). - The next bullets list the most important conditionally-#defined features. - For example, `make FEATUREFLAGS='-DBINARY_OUTPUT'` enables binary output and disables the default - assembly optimizations and Montgomery-representation output. - -* define `BINARY_OUTPUT` - - In serialization, output raw binary data (instead of decimal, when not set). - -* `make CURVE=choice` / define `CURVE_choice` (where `choice` is one of: - ALT_BN128, BN128, EDWARDS, MNT4, MNT6) - - Set the default curve to one of the above (see [elliptic curve choices](#elliptic-curve-choices)). - -* `make DEBUG=1` / define `DEBUG` - - Print additional information for debugging purposes. - -* `make LOWMEM=1` / define `LOWMEM` - - Limit the size of multi-exponentiation tables, for low-memory platforms. - -* `make NO_DOCS=1` - - Do not generate HTML documentation, e.g. on platforms where Markdown is not easily available. - -* `make NO_PROCPS=1` - - Do not link against libprocps. This disables memory profiling. - -* `make NO_GTEST=1` - - Do not link against GTest. The tutorial and test suite of gadgetlib2 tutorial won't be compiled. - -* `make NO_SUPERCOP=1` - - Do not link against SUPERCOP for optimized crypto. The ADSNARK executables will not be built. - -* `make MULTICORE=1` - - Enable parallelized execution of the ppzkSNARK generator and prover, using OpenMP. - This will utilize all cores on the CPU for heavyweight parallelizable operations such as - FFT and multiexponentiation. The default is single-core. - - To override the maximum number of cores used, set the environment variable `OMP_NUM_THREADS` - at runtime (not compile time), e.g., `OMP_NUM_THREADS=8 test_r1cs_sp_ppzkpc`. It defaults - to the autodetected number of cores, but on some devices, dynamic core management confused - OpenMP's autodetection, so setting `OMP_NUM_THREADS` is necessary for full utilization. - -* define `NO_PT_COMPRESSION` - - Do not use point compression. - This gives much faster serialization times, at the expense of ~2x larger - sizes for serialized keys and proofs. - -* define `MONTGOMERY_OUTPUT` (on by default) - - Serialize Fp elements as their Montgomery representations. If this - option is disabled then Fp elements are serialized as their - equivalence classes, which is slower but produces human-readable - output. - -* `make PROFILE_OP_COUNTS=1` / define `PROFILE_OP_COUNTS` - - Collect counts for field and curve operations inside static variables - of the corresponding algebraic objects. This option works for all - curves except bn128. - -* define `USE_ASM` (on by default) - - Use unrolled assembly routines for F[p] arithmetic and faster heap in - multi-exponentiation. (When not set, use GMP's `mpn_*` routines instead.) - -* define `USE_MIXED_ADDITION` - - Convert each element of the proving key and verification key to - affine coordinates. This allows using mixed addition formulas in - multiexponentiation and results in slightly faster prover and - verifier runtime at expense of increased proving time. - -* `make PERFORMANCE=1` - - Enables compiler optimizations such as link-time optimization, and disables debugging aids. - (On some distributions this causes a `plugin needed to handle lto object` link error and `undefined reference`s, which can be remedied by `AR=gcc-ar make ...`.) - -Not all combinations are tested together or supported by every part of the codebase. - - --------------------------------------------------------------------------------- -Portability --------------------------------------------------------------------------------- - -libsnark is written in fairly standard C++11. - -However, having been developed on Linux on x86-64 CPUs, libsnark has some limitations -with respect to portability. Specifically: - -1. libsnark's algebraic data structures assume little-endian byte order. - -2. Profiling routines use `clock_gettime` and `readproc` calls, which are Linux-specific. - -3. Random-number generation is done by reading from `/dev/urandom`, which is - specific to Unix-like systems. - -4. libsnark binary serialization routines (see `BINARY_OUTPUT` above) assume - a fixed machine word size (i.e. sizeof(mp_limb_t) for GMP's limb data type). - Objects serialized in binary on a 64-bit system cannot be de-serialized on - a 32-bit system, and vice versa. - (The decimal serialization routines have no such limitation.) - -5. libsnark requires a C++ compiler with good C++11 support. It has been - tested with g++ 4.7, g++ 4.8, and clang 3.4. - -6. On x86-64, we by default use highly optimized assembly implementations for some - operations (see `USE_ASM` above). On other architectures we fall back to a - portable C++ implementation, which is slower. - -Tested configurations include: - -* Debian jessie with g++ 4.7 on x86-64 -* Debian jessie with clang 3.4 on x86-64 -* Fedora 20/21 with g++ 4.8.2/4.9.2 on x86-64 and i686 -* Ubuntu 14.04 LTS with g++ 4.8 on x86-64 -* Ubuntu 14.04 LTS with g++ 4.8 on x86-32, for EDWARDS and ALT_BN128 curve choices -* Debian wheezy with g++ 4.7 on ARM little endian (Debian armel port) inside QEMU, for EDWARDS and ALT_BN128 curve choices -* Windows 7 with g++ 4.8.3 under Cygwin 1.7.30 on x86-64 with NO_PROCPS=1, NO_GTEST=1 and NO_DOCS=1, for EDWARDS and ALT_BN128 curve choices -* Mac OS X 10.9.4 (Mavericks) with Apple LLVM version 5.1 (based on LLVM 3.4svn) on x86-64 with NO_PROCPS=1, NO_GTEST=1 and NO_DOCS=1 - - --------------------------------------------------------------------------------- -Directory structure --------------------------------------------------------------------------------- - -The directory structure of the libsnark library is as follows: - -* src/ --- main C++ source code, containing the following modules: - * algebra/ --- fields and elliptic curve groups - * common/ --- miscellaneous utilities - * gadgetlib1/ --- gadgetlib1, a library to construct R1CS instances - * gadgets/ --- basic gadgets for gadgetlib1 - * gadgetlib2/ --- gadgetlib2, a library to construct R1CS instances - * qap/ --- quadratic arithmetic program - * domains/ --- support for fast interpolation/evaluation, by providing - FFTs and Lagrange-coefficient computations for various domains - * relations/ --- interfaces for expressing statement (relations between instances and witnesses) as various NP-complete languages - * constraint_satisfaction_problems/ --- R1CS and USCS languages - * circuit_satisfaction_problems/ --- Boolean and arithmetic circuit satisfiability languages - * ram_computations/ --- RAM computation languages - * zk_proof_systems --- interfaces and implementations of the proof systems - * reductions --- reductions between languages (used internally, but contains many examples of building constraints) - - Some of these module directories have the following subdirectories: - - * ... - * examples/ --- example code and tutorials for this module - * tests/ --- unit tests for this module - - In particular, the top-level API examples are at `src/r1cs_ppzksnark/examples/` and `src/gadgetlib2/examples/`. - -* depsrc/ --- created by `prepare_depends.sh` for retrieved sourcecode and local builds of external code - (currently: \[ate-pairing], and its dependency xbyak). - -* depinst/ --- created by `prepare_depends.sh` and `Makefile` - for local installation of locally-compiled dependencies. - -* doxygen/ --- created by `make doxy` and contains a Doxygen summary of all files, classes etc. in libsnark. - - --------------------------------------------------------------------------------- -Further considerations --------------------------------------------------------------------------------- - -### Multiexponentiation window size - -The ppzkSNARK's generator has to solve a fixed-base multi-exponentiation -problem. We use a window-based method in which the optimal window size depends -on the size of the multiexponentiation instance *and* the platform. - -On our benchmarking platform (a 3.40 GHz Intel Core i7-4770 CPU), we have -computed for each curve optimal windows, provided as -"fixed_base_exp_window_table" initialization sequences, for each curve; see -`X_init.cpp` for X=edwards,bn128,alt_bn128. - -Performance on other platforms may not be optimal (but probably not be far off). -Future releases of the libsnark library will include a tool that generates -optimal window sizes. - - --------------------------------------------------------------------------------- -References --------------------------------------------------------------------------------- - -\[BBFR15] [ - _ADSNARK: nearly practical and privacy-preserving proofs on authenticated data_ -](https://eprint.iacr.org/2014/617), - Michael Backes, Manuel Barbosa, Dario Fiore, Raphael M. Reischuk, - IEEE Symposium on Security and Privacy (Oakland) 2015 - -\[BCCT12] [ - _From extractable collision resistance to succinct non-Interactive arguments of knowledge, and back again_ -](http://eprint.iacr.org/2011/443), - Nir Bitansky, Ran Canetti, Alessandro Chiesa, Eran Tromer, - Innovations in Computer Science (ITCS) 2012 - -\[BCCT13] [ - _Recursive composition and bootstrapping for SNARKs and proof-carrying data_ -](http://eprint.iacr.org/2012/095) - Nir Bitansky, Ran Canetti, Alessandro Chiesa, Eran Tromer, - Symposium on Theory of Computing (STOC) 13 - -\[BCGTV13] [ - _SNARKs for C: Verifying Program Executions Succinctly and in Zero Knowledge_ -](http://eprint.iacr.org/2013/507), - Eli Ben-Sasson, Alessandro Chiesa, Daniel Genkin, Eran Tromer, Madars Virza, - CRYPTO 2013 - -\[BCIOP13] [ - _Succinct Non-Interactive Arguments via Linear Interactive Proofs_ -](http://eprint.iacr.org/2012/718), - Nir Bitansky, Alessandro Chiesa, Yuval Ishai, Rafail Ostrovsky, Omer Paneth, - Theory of Cryptography Conference 2013 - -\[BCTV14a] [ - _Succinct Non-Interactive Zero Knowledge for a von Neumann Architecture_ -](http://eprint.iacr.org/2013/879), - Eli Ben-Sasson, Alessandro Chiesa, Eran Tromer, Madars Virza, - USENIX Security 2014 - -\[BCTV14b] [ - _Scalable succinct non-interactive arguments via cycles of elliptic curves_ -](https://eprint.iacr.org/2014/595), - Eli Ben-Sasson, Alessandro Chiesa, Eran Tromer, Madars Virza, - CRYPTO 2014 - -\[CTV15] [ - _Cluster computing in zero knowledge_ -](https://eprint.iacr.org/2015/377), - Alessandro Chiesa, Eran Tromer, Madars Virza, - Eurocrypt 2015 - -\[DFGK14] [ - Square span programs with applications to succinct NIZK arguments -](https://eprint.iacr.org/2014/718), - George Danezis, Cedric Fournet, Jens Groth, Markulf Kohlweiss, - ASIACCS 2014 - -\[GGPR13] [ - _Quadratic span programs and succinct NIZKs without PCPs_ -](http://eprint.iacr.org/2012/215), - Rosario Gennaro, Craig Gentry, Bryan Parno, Mariana Raykova, - EUROCRYPT 2013 - -\[ate-pairing] [ - _High-Speed Software Implementation of the Optimal Ate Pairing over Barreto-Naehrig Curves_ -](https://github.com/herumi/ate-pairing), - MITSUNARI Shigeo, TERUYA Tadanori - -\[PGHR13] [ - _Pinocchio: Nearly Practical Verifiable Computation_ -](http://eprint.iacr.org/2013/279), - Bryan Parno, Craig Gentry, Jon Howell, Mariana Raykova, - IEEE Symposium on Security and Privacy (Oakland) 2013 - -[SCIPR Lab]: http://www.scipr-lab.org/ (Succinct Computational Integrity and Privacy Research Lab) - -[LICENSE]: LICENSE (LICENSE file in top directory of libsnark distribution) - -[AUTHORS]: AUTHORS (AUTHORS file in top directory of libsnark distribution) diff --git a/src/snark/doxygen.conf b/src/snark/doxygen.conf deleted file mode 100644 index 5fbe61681..000000000 --- a/src/snark/doxygen.conf +++ /dev/null @@ -1,1807 +0,0 @@ -# Doxyfile 1.8.2 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. - -PROJECT_NAME = libsnark - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. Note that you specify absolute paths here, but also -# relative paths, which will be relative from the directory where doxygen is -# started. - -STRIP_FROM_PATH = src - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = YES - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, -# and language is one of the parsers supported by doxygen: IDL, Java, -# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, -# C++. For instance to make doxygen treat .inc files as Fortran files (default -# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note -# that for custom extensions you also need to set FILE_PATTERNS otherwise the -# files are not read by doxygen. - -EXTENSION_MAPPING = tcc=C++ - -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. -# Disable only in case of backward compatibilities issues. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented classes, -# or namespaces to their corresponding documentation. Such a link can be -# prevented in individual cases by by putting a % sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES (the -# default) will make doxygen replace the get and set methods by a property in -# the documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -SYMBOL_CACHE_SIZE = 0 - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = src README.md - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = *.md *.c *.h *.cpp *.hpp *.tcc *.inc *.cc - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = Debug \ - Release - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = "perl -pe 's/^(libsnark: .*)$/$1 {#mainpage}/ if $.==1; s!//+ *(TODO|FIXME|XXX)!/// \\todo!'" - # The 1st replacement marks README.md as the main page. - # The 2nd replacement identifies additional TODO notations. - # These should be done with FILTER_PATTERNS instead, but it looks like shell escaping is different there. - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = YES - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C, C++ and Fortran comments will always remain visible. - -STRIP_CODE_COMMENTS = NO - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = doxygen - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If left blank doxygen will -# generate a default style sheet. Note that it is recommended to use -# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this -# tag will in the future become obsolete. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional -# user-defined cascading style sheet that is included after the standard -# style sheets created by doxygen. Using this option one can overrule -# certain style aspects. This is preferred over using HTML_STYLESHEET -# since it does not replace the standard style sheet and is therefor more -# robust against future updates. Doxygen will copy the style sheet file to -# the output directory. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = NO - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of -# entries shown in the various tree structured indices initially; the user -# can expand and collapse entries dynamically later on. Doxygen will expand -# the tree to such a level that at most the specified number of entries are -# visible (unless a fully collapsed tree already exceeds this amount). -# So setting the number of entries 1 will produce a full collapsed tree by -# default. 0 is a special value representing an infinite number of entries -# and will result in a full expanded tree by default. - -HTML_INDEX_NUM_ENTRIES = 0 - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely -# identify the documentation publisher. This should be a reverse domain-name -# style string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. - -GENERATE_TREEVIEW = YES - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = YES - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. However, it is strongly recommended to install a local -# copy of MathJax from http://www.mathjax.org before deployment. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. - -MATHJAX_EXTENSIONS = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4 - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = amsfonts - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a -# standard footer. Notice: only use this tag if you know what you are doing! - -LATEX_FOOTER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# pointed to by INCLUDE_PATH will be searched when a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that -# overrules the definition found in the source code. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. For each -# tag file the location of the external documentation should be added. The -# format of a tag file without this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths -# or URLs. Note that each tag file must have a unique name (where the name does -# NOT include the path). If a tag file is not located in the directory in which -# doxygen is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = NO - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the -# directory containing the font. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to -# set the path where dot can find it. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If the UML_LOOK tag is enabled, the fields and methods are shown inside -# the class node. If there are many fields or methods and many nodes the -# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS -# threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be -# exceeded by 50% before the limit is enforced. - -UML_LIMIT_NUM_FIELDS = 10 - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = YES - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = YES - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible in IE 9+ (other browsers do not have this requirement). - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible. Older versions of IE do not have SVG support. - -INTERACTIVE_SVG = NO - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g1.cpp b/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g1.cpp deleted file mode 100644 index 2c6206056..000000000 --- a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g1.cpp +++ /dev/null @@ -1,524 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#include "algebra/curves/alt_bn128/alt_bn128_g1.hpp" - -namespace libsnark { - -#ifdef PROFILE_OP_COUNTS -int64_t alt_bn128_G1::add_cnt = 0; -int64_t alt_bn128_G1::dbl_cnt = 0; -#endif - -std::vector alt_bn128_G1::wnaf_window_table; -std::vector alt_bn128_G1::fixed_base_exp_window_table; -alt_bn128_G1 alt_bn128_G1::G1_zero; -alt_bn128_G1 alt_bn128_G1::G1_one; - -alt_bn128_G1::alt_bn128_G1() -{ - this->X = G1_zero.X; - this->Y = G1_zero.Y; - this->Z = G1_zero.Z; -} - -void alt_bn128_G1::print() const -{ - if (this->is_zero()) - { - printf("O\n"); - } - else - { - alt_bn128_G1 copy(*this); - copy.to_affine_coordinates(); - gmp_printf("(%Nd , %Nd)\n", - copy.X.as_bigint().data, alt_bn128_Fq::num_limbs, - copy.Y.as_bigint().data, alt_bn128_Fq::num_limbs); - } -} - -void alt_bn128_G1::print_coordinates() const -{ - if (this->is_zero()) - { - printf("O\n"); - } - else - { - gmp_printf("(%Nd : %Nd : %Nd)\n", - this->X.as_bigint().data, alt_bn128_Fq::num_limbs, - this->Y.as_bigint().data, alt_bn128_Fq::num_limbs, - this->Z.as_bigint().data, alt_bn128_Fq::num_limbs); - } -} - -void alt_bn128_G1::to_affine_coordinates() -{ - if (this->is_zero()) - { - this->X = alt_bn128_Fq::zero(); - this->Y = alt_bn128_Fq::one(); - this->Z = alt_bn128_Fq::zero(); - } - else - { - alt_bn128_Fq Z_inv = Z.inverse(); - alt_bn128_Fq Z2_inv = Z_inv.squared(); - alt_bn128_Fq Z3_inv = Z2_inv * Z_inv; - this->X = this->X * Z2_inv; - this->Y = this->Y * Z3_inv; - this->Z = alt_bn128_Fq::one(); - } -} - -void alt_bn128_G1::to_special() -{ - this->to_affine_coordinates(); -} - -bool alt_bn128_G1::is_special() const -{ - return (this->is_zero() || this->Z == alt_bn128_Fq::one()); -} - -bool alt_bn128_G1::is_zero() const -{ - return (this->Z.is_zero()); -} - -bool alt_bn128_G1::operator==(const alt_bn128_G1 &other) const -{ - if (this->is_zero()) - { - return other.is_zero(); - } - - if (other.is_zero()) - { - return false; - } - - /* now neither is O */ - - // using Jacobian coordinates so: - // (X1:Y1:Z1) = (X2:Y2:Z2) - // iff - // X1/Z1^2 == X2/Z2^2 and Y1/Z1^3 == Y2/Z2^3 - // iff - // X1 * Z2^2 == X2 * Z1^2 and Y1 * Z2^3 == Y2 * Z1^3 - - alt_bn128_Fq Z1_squared = (this->Z).squared(); - alt_bn128_Fq Z2_squared = (other.Z).squared(); - - if ((this->X * Z2_squared) != (other.X * Z1_squared)) - { - return false; - } - - alt_bn128_Fq Z1_cubed = (this->Z) * Z1_squared; - alt_bn128_Fq Z2_cubed = (other.Z) * Z2_squared; - - if ((this->Y * Z2_cubed) != (other.Y * Z1_cubed)) - { - return false; - } - - return true; -} - -bool alt_bn128_G1::operator!=(const alt_bn128_G1& other) const -{ - return !(operator==(other)); -} - -alt_bn128_G1 alt_bn128_G1::operator+(const alt_bn128_G1 &other) const -{ - // handle special cases having to do with O - if (this->is_zero()) - { - return other; - } - - if (other.is_zero()) - { - return *this; - } - - // no need to handle points of order 2,4 - // (they cannot exist in a prime-order subgroup) - - // check for doubling case - - // using Jacobian coordinates so: - // (X1:Y1:Z1) = (X2:Y2:Z2) - // iff - // X1/Z1^2 == X2/Z2^2 and Y1/Z1^3 == Y2/Z2^3 - // iff - // X1 * Z2^2 == X2 * Z1^2 and Y1 * Z2^3 == Y2 * Z1^3 - - alt_bn128_Fq Z1Z1 = (this->Z).squared(); - alt_bn128_Fq Z2Z2 = (other.Z).squared(); - - alt_bn128_Fq U1 = this->X * Z2Z2; - alt_bn128_Fq U2 = other.X * Z1Z1; - - alt_bn128_Fq Z1_cubed = (this->Z) * Z1Z1; - alt_bn128_Fq Z2_cubed = (other.Z) * Z2Z2; - - alt_bn128_Fq S1 = (this->Y) * Z2_cubed; // S1 = Y1 * Z2 * Z2Z2 - alt_bn128_Fq S2 = (other.Y) * Z1_cubed; // S2 = Y2 * Z1 * Z1Z1 - - if (U1 == U2 && S1 == S2) - { - // dbl case; nothing of above can be reused - return this->dbl(); - } - - // rest of add case - alt_bn128_Fq H = U2 - U1; // H = U2-U1 - alt_bn128_Fq S2_minus_S1 = S2-S1; - alt_bn128_Fq I = (H+H).squared(); // I = (2 * H)^2 - alt_bn128_Fq J = H * I; // J = H * I - alt_bn128_Fq r = S2_minus_S1 + S2_minus_S1; // r = 2 * (S2-S1) - alt_bn128_Fq V = U1 * I; // V = U1 * I - alt_bn128_Fq X3 = r.squared() - J - (V+V); // X3 = r^2 - J - 2 * V - alt_bn128_Fq S1_J = S1 * J; - alt_bn128_Fq Y3 = r * (V-X3) - (S1_J+S1_J); // Y3 = r * (V-X3)-2 S1 J - alt_bn128_Fq Z3 = ((this->Z+other.Z).squared()-Z1Z1-Z2Z2) * H; // Z3 = ((Z1+Z2)^2-Z1Z1-Z2Z2) * H - - return alt_bn128_G1(X3, Y3, Z3); -} - -alt_bn128_G1 alt_bn128_G1::operator-() const -{ - return alt_bn128_G1(this->X, -(this->Y), this->Z); -} - - -alt_bn128_G1 alt_bn128_G1::operator-(const alt_bn128_G1 &other) const -{ - return (*this) + (-other); -} - -alt_bn128_G1 alt_bn128_G1::add(const alt_bn128_G1 &other) const -{ - // handle special cases having to do with O - if (this->is_zero()) - { - return other; - } - - if (other.is_zero()) - { - return *this; - } - - // no need to handle points of order 2,4 - // (they cannot exist in a prime-order subgroup) - - // handle double case - if (this->operator==(other)) - { - return this->dbl(); - } - -#ifdef PROFILE_OP_COUNTS - this->add_cnt++; -#endif - // NOTE: does not handle O and pts of order 2,4 - // http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-add-2007-bl - - alt_bn128_Fq Z1Z1 = (this->Z).squared(); // Z1Z1 = Z1^2 - alt_bn128_Fq Z2Z2 = (other.Z).squared(); // Z2Z2 = Z2^2 - alt_bn128_Fq U1 = (this->X) * Z2Z2; // U1 = X1 * Z2Z2 - alt_bn128_Fq U2 = (other.X) * Z1Z1; // U2 = X2 * Z1Z1 - alt_bn128_Fq S1 = (this->Y) * (other.Z) * Z2Z2; // S1 = Y1 * Z2 * Z2Z2 - alt_bn128_Fq S2 = (other.Y) * (this->Z) * Z1Z1; // S2 = Y2 * Z1 * Z1Z1 - alt_bn128_Fq H = U2 - U1; // H = U2-U1 - alt_bn128_Fq S2_minus_S1 = S2-S1; - alt_bn128_Fq I = (H+H).squared(); // I = (2 * H)^2 - alt_bn128_Fq J = H * I; // J = H * I - alt_bn128_Fq r = S2_minus_S1 + S2_minus_S1; // r = 2 * (S2-S1) - alt_bn128_Fq V = U1 * I; // V = U1 * I - alt_bn128_Fq X3 = r.squared() - J - (V+V); // X3 = r^2 - J - 2 * V - alt_bn128_Fq S1_J = S1 * J; - alt_bn128_Fq Y3 = r * (V-X3) - (S1_J+S1_J); // Y3 = r * (V-X3)-2 S1 J - alt_bn128_Fq Z3 = ((this->Z+other.Z).squared()-Z1Z1-Z2Z2) * H; // Z3 = ((Z1+Z2)^2-Z1Z1-Z2Z2) * H - - return alt_bn128_G1(X3, Y3, Z3); -} - -alt_bn128_G1 alt_bn128_G1::mixed_add(const alt_bn128_G1 &other) const -{ -#ifdef DEBUG - assert(other.is_special()); -#endif - - // handle special cases having to do with O - if (this->is_zero()) - { - return other; - } - - if (other.is_zero()) - { - return *this; - } - - // no need to handle points of order 2,4 - // (they cannot exist in a prime-order subgroup) - - // check for doubling case - - // using Jacobian coordinates so: - // (X1:Y1:Z1) = (X2:Y2:Z2) - // iff - // X1/Z1^2 == X2/Z2^2 and Y1/Z1^3 == Y2/Z2^3 - // iff - // X1 * Z2^2 == X2 * Z1^2 and Y1 * Z2^3 == Y2 * Z1^3 - - // we know that Z2 = 1 - - const alt_bn128_Fq Z1Z1 = (this->Z).squared(); - - const alt_bn128_Fq &U1 = this->X; - const alt_bn128_Fq U2 = other.X * Z1Z1; - - const alt_bn128_Fq Z1_cubed = (this->Z) * Z1Z1; - - const alt_bn128_Fq &S1 = (this->Y); // S1 = Y1 * Z2 * Z2Z2 - const alt_bn128_Fq S2 = (other.Y) * Z1_cubed; // S2 = Y2 * Z1 * Z1Z1 - - if (U1 == U2 && S1 == S2) - { - // dbl case; nothing of above can be reused - return this->dbl(); - } - -#ifdef PROFILE_OP_COUNTS - this->add_cnt++; -#endif - - // NOTE: does not handle O and pts of order 2,4 - // http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-madd-2007-bl - alt_bn128_Fq H = U2-(this->X); // H = U2-X1 - alt_bn128_Fq HH = H.squared() ; // HH = H&2 - alt_bn128_Fq I = HH+HH; // I = 4*HH - I = I + I; - alt_bn128_Fq J = H*I; // J = H*I - alt_bn128_Fq r = S2-(this->Y); // r = 2*(S2-Y1) - r = r + r; - alt_bn128_Fq V = (this->X) * I ; // V = X1*I - alt_bn128_Fq X3 = r.squared()-J-V-V; // X3 = r^2-J-2*V - alt_bn128_Fq Y3 = (this->Y)*J; // Y3 = r*(V-X3)-2*Y1*J - Y3 = r*(V-X3) - Y3 - Y3; - alt_bn128_Fq Z3 = ((this->Z)+H).squared() - Z1Z1 - HH; // Z3 = (Z1+H)^2-Z1Z1-HH - - return alt_bn128_G1(X3, Y3, Z3); -} - -alt_bn128_G1 alt_bn128_G1::dbl() const -{ -#ifdef PROFILE_OP_COUNTS - this->dbl_cnt++; -#endif - // handle point at infinity - if (this->is_zero()) - { - return (*this); - } - - // no need to handle points of order 2,4 - // (they cannot exist in a prime-order subgroup) - - // NOTE: does not handle O and pts of order 2,4 - // http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#doubling-dbl-2009-l - - alt_bn128_Fq A = (this->X).squared(); // A = X1^2 - alt_bn128_Fq B = (this->Y).squared(); // B = Y1^2 - alt_bn128_Fq C = B.squared(); // C = B^2 - alt_bn128_Fq D = (this->X + B).squared() - A - C; - D = D+D; // D = 2 * ((X1 + B)^2 - A - C) - alt_bn128_Fq E = A + A + A; // E = 3 * A - alt_bn128_Fq F = E.squared(); // F = E^2 - alt_bn128_Fq X3 = F - (D+D); // X3 = F - 2 D - alt_bn128_Fq eightC = C+C; - eightC = eightC + eightC; - eightC = eightC + eightC; - alt_bn128_Fq Y3 = E * (D - X3) - eightC; // Y3 = E * (D - X3) - 8 * C - alt_bn128_Fq Y1Z1 = (this->Y)*(this->Z); - alt_bn128_Fq Z3 = Y1Z1 + Y1Z1; // Z3 = 2 * Y1 * Z1 - - return alt_bn128_G1(X3, Y3, Z3); -} - -bool alt_bn128_G1::is_well_formed() const -{ - if (this->is_zero()) - { - return true; - } - else - { - /* - y^2 = x^3 + b - - We are using Jacobian coordinates, so equation we need to check is actually - - (y/z^3)^2 = (x/z^2)^3 + b - y^2 / z^6 = x^3 / z^6 + b - y^2 = x^3 + b z^6 - */ - alt_bn128_Fq X2 = this->X.squared(); - alt_bn128_Fq Y2 = this->Y.squared(); - alt_bn128_Fq Z2 = this->Z.squared(); - - alt_bn128_Fq X3 = this->X * X2; - alt_bn128_Fq Z3 = this->Z * Z2; - alt_bn128_Fq Z6 = Z3.squared(); - - return (Y2 == X3 + alt_bn128_coeff_b * Z6); - } -} - -alt_bn128_G1 alt_bn128_G1::zero() -{ - return G1_zero; -} - -alt_bn128_G1 alt_bn128_G1::one() -{ - return G1_one; -} - -alt_bn128_G1 alt_bn128_G1::random_element() -{ - return (scalar_field::random_element().as_bigint()) * G1_one; -} - -std::ostream& operator<<(std::ostream &out, const alt_bn128_G1 &g) -{ - alt_bn128_G1 copy(g); - copy.to_affine_coordinates(); - - out << (copy.is_zero() ? 1 : 0) << OUTPUT_SEPARATOR; -#ifdef NO_PT_COMPRESSION - out << copy.X << OUTPUT_SEPARATOR << copy.Y; -#else - /* storing LSB of Y */ - out << copy.X << OUTPUT_SEPARATOR << (copy.Y.as_bigint().data[0] & 1); -#endif - - return out; -} - -std::istream& operator>>(std::istream &in, alt_bn128_G1 &g) -{ - char is_zero; - alt_bn128_Fq tX, tY; - -#ifdef NO_PT_COMPRESSION - in >> is_zero >> tX >> tY; - is_zero -= '0'; -#else - in.read((char*)&is_zero, 1); // this reads is_zero; - is_zero -= '0'; - consume_OUTPUT_SEPARATOR(in); - - unsigned char Y_lsb; - in >> tX; - consume_OUTPUT_SEPARATOR(in); - in.read((char*)&Y_lsb, 1); - Y_lsb -= '0'; - - // y = +/- sqrt(x^3 + b) - if (!is_zero) - { - alt_bn128_Fq tX2 = tX.squared(); - alt_bn128_Fq tY2 = tX2*tX + alt_bn128_coeff_b; - tY = tY2.sqrt(); - - if ((tY.as_bigint().data[0] & 1) != Y_lsb) - { - tY = -tY; - } - } -#endif - // using Jacobian coordinates - if (!is_zero) - { - g.X = tX; - g.Y = tY; - g.Z = alt_bn128_Fq::one(); - } - else - { - g = alt_bn128_G1::zero(); - } - - return in; -} - -std::ostream& operator<<(std::ostream& out, const std::vector &v) -{ - out << v.size() << "\n"; - for (const alt_bn128_G1& t : v) - { - out << t << OUTPUT_NEWLINE; - } - - return out; -} - -std::istream& operator>>(std::istream& in, std::vector &v) -{ - v.clear(); - - size_t s; - in >> s; - consume_newline(in); - - v.reserve(s); - - for (size_t i = 0; i < s; ++i) - { - alt_bn128_G1 g; - in >> g; - consume_OUTPUT_NEWLINE(in); - v.emplace_back(g); - } - - return in; -} - -template<> -void batch_to_special_all_non_zeros(std::vector &vec) -{ - std::vector Z_vec; - Z_vec.reserve(vec.size()); - - for (auto &el: vec) - { - Z_vec.emplace_back(el.Z); - } - batch_invert(Z_vec); - - const alt_bn128_Fq one = alt_bn128_Fq::one(); - - for (size_t i = 0; i < vec.size(); ++i) - { - alt_bn128_Fq Z2 = Z_vec[i].squared(); - alt_bn128_Fq Z3 = Z_vec[i] * Z2; - - vec[i].X = vec[i].X * Z2; - vec[i].Y = vec[i].Y * Z3; - vec[i].Z = one; - } -} - -} // libsnark diff --git a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g1.hpp b/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g1.hpp deleted file mode 100644 index 7053fe688..000000000 --- a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g1.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef ALT_BN128_G1_HPP_ -#define ALT_BN128_G1_HPP_ -#include -#include "algebra/curves/alt_bn128/alt_bn128_init.hpp" -#include "algebra/curves/curve_utils.hpp" - -namespace libsnark { - -class alt_bn128_G1; -std::ostream& operator<<(std::ostream &, const alt_bn128_G1&); -std::istream& operator>>(std::istream &, alt_bn128_G1&); - -class alt_bn128_G1 { -public: -#ifdef PROFILE_OP_COUNTS - static int64_t add_cnt; - static int64_t dbl_cnt; -#endif - static std::vector wnaf_window_table; - static std::vector fixed_base_exp_window_table; - static alt_bn128_G1 G1_zero; - static alt_bn128_G1 G1_one; - - typedef alt_bn128_Fq base_field; - typedef alt_bn128_Fr scalar_field; - - alt_bn128_Fq X, Y, Z; - - // using Jacobian coordinates - alt_bn128_G1(); - alt_bn128_G1(const alt_bn128_Fq& X, const alt_bn128_Fq& Y, const alt_bn128_Fq& Z) : X(X), Y(Y), Z(Z) {}; - - void print() const; - void print_coordinates() const; - - void to_affine_coordinates(); - void to_special(); - bool is_special() const; - - bool is_zero() const; - - bool operator==(const alt_bn128_G1 &other) const; - bool operator!=(const alt_bn128_G1 &other) const; - - alt_bn128_G1 operator+(const alt_bn128_G1 &other) const; - alt_bn128_G1 operator-() const; - alt_bn128_G1 operator-(const alt_bn128_G1 &other) const; - - alt_bn128_G1 add(const alt_bn128_G1 &other) const; - alt_bn128_G1 mixed_add(const alt_bn128_G1 &other) const; - alt_bn128_G1 dbl() const; - - bool is_well_formed() const; - - static alt_bn128_G1 zero(); - static alt_bn128_G1 one(); - static alt_bn128_G1 random_element(); - - static size_t size_in_bits() { return base_field::size_in_bits() + 1; } - static bigint base_field_char() { return base_field::field_char(); } - static bigint order() { return scalar_field::field_char(); } - - friend std::ostream& operator<<(std::ostream &out, const alt_bn128_G1 &g); - friend std::istream& operator>>(std::istream &in, alt_bn128_G1 &g); -}; - -template -alt_bn128_G1 operator*(const bigint &lhs, const alt_bn128_G1 &rhs) -{ - return scalar_mul(rhs, lhs); -} - -template& modulus_p> -alt_bn128_G1 operator*(const Fp_model &lhs, const alt_bn128_G1 &rhs) -{ - return scalar_mul(rhs, lhs.as_bigint()); -} - -std::ostream& operator<<(std::ostream& out, const std::vector &v); -std::istream& operator>>(std::istream& in, std::vector &v); - -template -void batch_to_special_all_non_zeros(std::vector &vec); -template<> -void batch_to_special_all_non_zeros(std::vector &vec); - -} // libsnark -#endif // ALT_BN128_G1_HPP_ diff --git a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g2.cpp b/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g2.cpp deleted file mode 100644 index 4b592e804..000000000 --- a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g2.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#include "algebra/curves/alt_bn128/alt_bn128_g2.hpp" - -namespace libsnark { - -#ifdef PROFILE_OP_COUNTS -int64_t alt_bn128_G2::add_cnt = 0; -int64_t alt_bn128_G2::dbl_cnt = 0; -#endif - -std::vector alt_bn128_G2::wnaf_window_table; -std::vector alt_bn128_G2::fixed_base_exp_window_table; -alt_bn128_G2 alt_bn128_G2::G2_zero; -alt_bn128_G2 alt_bn128_G2::G2_one; - -alt_bn128_G2::alt_bn128_G2() -{ - this->X = G2_zero.X; - this->Y = G2_zero.Y; - this->Z = G2_zero.Z; -} - -alt_bn128_Fq2 alt_bn128_G2::mul_by_b(const alt_bn128_Fq2 &elt) -{ - return alt_bn128_Fq2(alt_bn128_twist_mul_by_b_c0 * elt.c0, alt_bn128_twist_mul_by_b_c1 * elt.c1); -} - -void alt_bn128_G2::print() const -{ - if (this->is_zero()) - { - printf("O\n"); - } - else - { - alt_bn128_G2 copy(*this); - copy.to_affine_coordinates(); - gmp_printf("(%Nd*z + %Nd , %Nd*z + %Nd)\n", - copy.X.c1.as_bigint().data, alt_bn128_Fq::num_limbs, - copy.X.c0.as_bigint().data, alt_bn128_Fq::num_limbs, - copy.Y.c1.as_bigint().data, alt_bn128_Fq::num_limbs, - copy.Y.c0.as_bigint().data, alt_bn128_Fq::num_limbs); - } -} - -void alt_bn128_G2::print_coordinates() const -{ - if (this->is_zero()) - { - printf("O\n"); - } - else - { - gmp_printf("(%Nd*z + %Nd : %Nd*z + %Nd : %Nd*z + %Nd)\n", - this->X.c1.as_bigint().data, alt_bn128_Fq::num_limbs, - this->X.c0.as_bigint().data, alt_bn128_Fq::num_limbs, - this->Y.c1.as_bigint().data, alt_bn128_Fq::num_limbs, - this->Y.c0.as_bigint().data, alt_bn128_Fq::num_limbs, - this->Z.c1.as_bigint().data, alt_bn128_Fq::num_limbs, - this->Z.c0.as_bigint().data, alt_bn128_Fq::num_limbs); - } -} - -void alt_bn128_G2::to_affine_coordinates() -{ - if (this->is_zero()) - { - this->X = alt_bn128_Fq2::zero(); - this->Y = alt_bn128_Fq2::one(); - this->Z = alt_bn128_Fq2::zero(); - } - else - { - alt_bn128_Fq2 Z_inv = Z.inverse(); - alt_bn128_Fq2 Z2_inv = Z_inv.squared(); - alt_bn128_Fq2 Z3_inv = Z2_inv * Z_inv; - this->X = this->X * Z2_inv; - this->Y = this->Y * Z3_inv; - this->Z = alt_bn128_Fq2::one(); - } -} - -void alt_bn128_G2::to_special() -{ - this->to_affine_coordinates(); -} - -bool alt_bn128_G2::is_special() const -{ - return (this->is_zero() || this->Z == alt_bn128_Fq2::one()); -} - -bool alt_bn128_G2::is_zero() const -{ - return (this->Z.is_zero()); -} - -bool alt_bn128_G2::operator==(const alt_bn128_G2 &other) const -{ - if (this->is_zero()) - { - return other.is_zero(); - } - - if (other.is_zero()) - { - return false; - } - - /* now neither is O */ - - // using Jacobian coordinates so: - // (X1:Y1:Z1) = (X2:Y2:Z2) - // iff - // X1/Z1^2 == X2/Z2^2 and Y1/Z1^3 == Y2/Z2^3 - // iff - // X1 * Z2^2 == X2 * Z1^2 and Y1 * Z2^3 == Y2 * Z1^3 - - alt_bn128_Fq2 Z1_squared = (this->Z).squared(); - alt_bn128_Fq2 Z2_squared = (other.Z).squared(); - - if ((this->X * Z2_squared) != (other.X * Z1_squared)) - { - return false; - } - - alt_bn128_Fq2 Z1_cubed = (this->Z) * Z1_squared; - alt_bn128_Fq2 Z2_cubed = (other.Z) * Z2_squared; - - if ((this->Y * Z2_cubed) != (other.Y * Z1_cubed)) - { - return false; - } - - return true; -} - -bool alt_bn128_G2::operator!=(const alt_bn128_G2& other) const -{ - return !(operator==(other)); -} - -alt_bn128_G2 alt_bn128_G2::operator+(const alt_bn128_G2 &other) const -{ - // handle special cases having to do with O - if (this->is_zero()) - { - return other; - } - - if (other.is_zero()) - { - return *this; - } - - // no need to handle points of order 2,4 - // (they cannot exist in a prime-order subgroup) - - // check for doubling case - - // using Jacobian coordinates so: - // (X1:Y1:Z1) = (X2:Y2:Z2) - // iff - // X1/Z1^2 == X2/Z2^2 and Y1/Z1^3 == Y2/Z2^3 - // iff - // X1 * Z2^2 == X2 * Z1^2 and Y1 * Z2^3 == Y2 * Z1^3 - - alt_bn128_Fq2 Z1Z1 = (this->Z).squared(); - alt_bn128_Fq2 Z2Z2 = (other.Z).squared(); - - alt_bn128_Fq2 U1 = this->X * Z2Z2; - alt_bn128_Fq2 U2 = other.X * Z1Z1; - - alt_bn128_Fq2 Z1_cubed = (this->Z) * Z1Z1; - alt_bn128_Fq2 Z2_cubed = (other.Z) * Z2Z2; - - alt_bn128_Fq2 S1 = (this->Y) * Z2_cubed; // S1 = Y1 * Z2 * Z2Z2 - alt_bn128_Fq2 S2 = (other.Y) * Z1_cubed; // S2 = Y2 * Z1 * Z1Z1 - - if (U1 == U2 && S1 == S2) - { - // dbl case; nothing of above can be reused - return this->dbl(); - } - - // rest of add case - alt_bn128_Fq2 H = U2 - U1; // H = U2-U1 - alt_bn128_Fq2 S2_minus_S1 = S2-S1; - alt_bn128_Fq2 I = (H+H).squared(); // I = (2 * H)^2 - alt_bn128_Fq2 J = H * I; // J = H * I - alt_bn128_Fq2 r = S2_minus_S1 + S2_minus_S1; // r = 2 * (S2-S1) - alt_bn128_Fq2 V = U1 * I; // V = U1 * I - alt_bn128_Fq2 X3 = r.squared() - J - (V+V); // X3 = r^2 - J - 2 * V - alt_bn128_Fq2 S1_J = S1 * J; - alt_bn128_Fq2 Y3 = r * (V-X3) - (S1_J+S1_J); // Y3 = r * (V-X3)-2 S1 J - alt_bn128_Fq2 Z3 = ((this->Z+other.Z).squared()-Z1Z1-Z2Z2) * H; // Z3 = ((Z1+Z2)^2-Z1Z1-Z2Z2) * H - - return alt_bn128_G2(X3, Y3, Z3); -} - -alt_bn128_G2 alt_bn128_G2::operator-() const -{ - return alt_bn128_G2(this->X, -(this->Y), this->Z); -} - - -alt_bn128_G2 alt_bn128_G2::operator-(const alt_bn128_G2 &other) const -{ - return (*this) + (-other); -} - -alt_bn128_G2 alt_bn128_G2::add(const alt_bn128_G2 &other) const -{ - // handle special cases having to do with O - if (this->is_zero()) - { - return other; - } - - if (other.is_zero()) - { - return *this; - } - - // no need to handle points of order 2,4 - // (they cannot exist in a prime-order subgroup) - - // handle double case - if (this->operator==(other)) - { - return this->dbl(); - } - -#ifdef PROFILE_OP_COUNTS - this->add_cnt++; -#endif - // NOTE: does not handle O and pts of order 2,4 - // http://www.hyperelliptic.org/EFD/g1p/auto-shortw-projective.html#addition-add-1998-cmo-2 - - alt_bn128_Fq2 Z1Z1 = (this->Z).squared(); // Z1Z1 = Z1^2 - alt_bn128_Fq2 Z2Z2 = (other.Z).squared(); // Z2Z2 = Z2^2 - alt_bn128_Fq2 U1 = (this->X) * Z2Z2; // U1 = X1 * Z2Z2 - alt_bn128_Fq2 U2 = (other.X) * Z1Z1; // U2 = X2 * Z1Z1 - alt_bn128_Fq2 S1 = (this->Y) * (other.Z) * Z2Z2; // S1 = Y1 * Z2 * Z2Z2 - alt_bn128_Fq2 S2 = (other.Y) * (this->Z) * Z1Z1; // S2 = Y2 * Z1 * Z1Z1 - alt_bn128_Fq2 H = U2 - U1; // H = U2-U1 - alt_bn128_Fq2 S2_minus_S1 = S2-S1; - alt_bn128_Fq2 I = (H+H).squared(); // I = (2 * H)^2 - alt_bn128_Fq2 J = H * I; // J = H * I - alt_bn128_Fq2 r = S2_minus_S1 + S2_minus_S1; // r = 2 * (S2-S1) - alt_bn128_Fq2 V = U1 * I; // V = U1 * I - alt_bn128_Fq2 X3 = r.squared() - J - (V+V); // X3 = r^2 - J - 2 * V - alt_bn128_Fq2 S1_J = S1 * J; - alt_bn128_Fq2 Y3 = r * (V-X3) - (S1_J+S1_J); // Y3 = r * (V-X3)-2 S1 J - alt_bn128_Fq2 Z3 = ((this->Z+other.Z).squared()-Z1Z1-Z2Z2) * H; // Z3 = ((Z1+Z2)^2-Z1Z1-Z2Z2) * H - - return alt_bn128_G2(X3, Y3, Z3); -} - -alt_bn128_G2 alt_bn128_G2::mixed_add(const alt_bn128_G2 &other) const -{ -#ifdef DEBUG - assert(other.is_special()); -#endif - - // handle special cases having to do with O - if (this->is_zero()) - { - return other; - } - - if (other.is_zero()) - { - return *this; - } - - // no need to handle points of order 2,4 - // (they cannot exist in a prime-order subgroup) - - // check for doubling case - - // using Jacobian coordinates so: - // (X1:Y1:Z1) = (X2:Y2:Z2) - // iff - // X1/Z1^2 == X2/Z2^2 and Y1/Z1^3 == Y2/Z2^3 - // iff - // X1 * Z2^2 == X2 * Z1^2 and Y1 * Z2^3 == Y2 * Z1^3 - - // we know that Z2 = 1 - - const alt_bn128_Fq2 Z1Z1 = (this->Z).squared(); - - const alt_bn128_Fq2 &U1 = this->X; - const alt_bn128_Fq2 U2 = other.X * Z1Z1; - - const alt_bn128_Fq2 Z1_cubed = (this->Z) * Z1Z1; - - const alt_bn128_Fq2 &S1 = (this->Y); // S1 = Y1 * Z2 * Z2Z2 - const alt_bn128_Fq2 S2 = (other.Y) * Z1_cubed; // S2 = Y2 * Z1 * Z1Z1 - - if (U1 == U2 && S1 == S2) - { - // dbl case; nothing of above can be reused - return this->dbl(); - } - -#ifdef PROFILE_OP_COUNTS - this->add_cnt++; -#endif - - // NOTE: does not handle O and pts of order 2,4 - // http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-madd-2007-bl - alt_bn128_Fq2 H = U2-(this->X); // H = U2-X1 - alt_bn128_Fq2 HH = H.squared() ; // HH = H&2 - alt_bn128_Fq2 I = HH+HH; // I = 4*HH - I = I + I; - alt_bn128_Fq2 J = H*I; // J = H*I - alt_bn128_Fq2 r = S2-(this->Y); // r = 2*(S2-Y1) - r = r + r; - alt_bn128_Fq2 V = (this->X) * I ; // V = X1*I - alt_bn128_Fq2 X3 = r.squared()-J-V-V; // X3 = r^2-J-2*V - alt_bn128_Fq2 Y3 = (this->Y)*J; // Y3 = r*(V-X3)-2*Y1*J - Y3 = r*(V-X3) - Y3 - Y3; - alt_bn128_Fq2 Z3 = ((this->Z)+H).squared() - Z1Z1 - HH; // Z3 = (Z1+H)^2-Z1Z1-HH - - return alt_bn128_G2(X3, Y3, Z3); -} - -alt_bn128_G2 alt_bn128_G2::dbl() const -{ -#ifdef PROFILE_OP_COUNTS - this->dbl_cnt++; -#endif - // handle point at infinity - if (this->is_zero()) - { - return (*this); - } - - // NOTE: does not handle O and pts of order 2,4 - // http://www.hyperelliptic.org/EFD/g1p/auto-shortw-projective.html#doubling-dbl-2007-bl - - alt_bn128_Fq2 A = (this->X).squared(); // A = X1^2 - alt_bn128_Fq2 B = (this->Y).squared(); // B = Y1^2 - alt_bn128_Fq2 C = B.squared(); // C = B^2 - alt_bn128_Fq2 D = (this->X + B).squared() - A - C; - D = D+D; // D = 2 * ((X1 + B)^2 - A - C) - alt_bn128_Fq2 E = A + A + A; // E = 3 * A - alt_bn128_Fq2 F = E.squared(); // F = E^2 - alt_bn128_Fq2 X3 = F - (D+D); // X3 = F - 2 D - alt_bn128_Fq2 eightC = C+C; - eightC = eightC + eightC; - eightC = eightC + eightC; - alt_bn128_Fq2 Y3 = E * (D - X3) - eightC; // Y3 = E * (D - X3) - 8 * C - alt_bn128_Fq2 Y1Z1 = (this->Y)*(this->Z); - alt_bn128_Fq2 Z3 = Y1Z1 + Y1Z1; // Z3 = 2 * Y1 * Z1 - - return alt_bn128_G2(X3, Y3, Z3); -} - -alt_bn128_G2 alt_bn128_G2::mul_by_q() const -{ - return alt_bn128_G2(alt_bn128_twist_mul_by_q_X * (this->X).Frobenius_map(1), - alt_bn128_twist_mul_by_q_Y * (this->Y).Frobenius_map(1), - (this->Z).Frobenius_map(1)); -} - -bool alt_bn128_G2::is_well_formed() const -{ - if (this->is_zero()) - { - return true; - } - else - { - /* - y^2 = x^3 + b - - We are using Jacobian coordinates, so equation we need to check is actually - - (y/z^3)^2 = (x/z^2)^3 + b - y^2 / z^6 = x^3 / z^6 + b - y^2 = x^3 + b z^6 - */ - alt_bn128_Fq2 X2 = this->X.squared(); - alt_bn128_Fq2 Y2 = this->Y.squared(); - alt_bn128_Fq2 Z2 = this->Z.squared(); - - alt_bn128_Fq2 X3 = this->X * X2; - alt_bn128_Fq2 Z3 = this->Z * Z2; - alt_bn128_Fq2 Z6 = Z3.squared(); - - return (Y2 == X3 + alt_bn128_twist_coeff_b * Z6); - } -} - -alt_bn128_G2 alt_bn128_G2::zero() -{ - return G2_zero; -} - -alt_bn128_G2 alt_bn128_G2::one() -{ - return G2_one; -} - -alt_bn128_G2 alt_bn128_G2::random_element() -{ - return (alt_bn128_Fr::random_element().as_bigint()) * G2_one; -} - -std::ostream& operator<<(std::ostream &out, const alt_bn128_G2 &g) -{ - alt_bn128_G2 copy(g); - copy.to_affine_coordinates(); - out << (copy.is_zero() ? 1 : 0) << OUTPUT_SEPARATOR; -#ifdef NO_PT_COMPRESSION - out << copy.X << OUTPUT_SEPARATOR << copy.Y; -#else - /* storing LSB of Y */ - out << copy.X << OUTPUT_SEPARATOR << (copy.Y.c0.as_bigint().data[0] & 1); -#endif - - return out; -} - -std::istream& operator>>(std::istream &in, alt_bn128_G2 &g) -{ - char is_zero; - alt_bn128_Fq2 tX, tY; - -#ifdef NO_PT_COMPRESSION - in >> is_zero >> tX >> tY; - is_zero -= '0'; -#else - in.read((char*)&is_zero, 1); // this reads is_zero; - is_zero -= '0'; - consume_OUTPUT_SEPARATOR(in); - - unsigned char Y_lsb; - in >> tX; - consume_OUTPUT_SEPARATOR(in); - in.read((char*)&Y_lsb, 1); - Y_lsb -= '0'; - - // y = +/- sqrt(x^3 + b) - if (!is_zero) - { - alt_bn128_Fq2 tX2 = tX.squared(); - alt_bn128_Fq2 tY2 = tX2 * tX + alt_bn128_twist_coeff_b; - tY = tY2.sqrt(); - - if ((tY.c0.as_bigint().data[0] & 1) != Y_lsb) - { - tY = -tY; - } - } -#endif - // using projective coordinates - if (!is_zero) - { - g.X = tX; - g.Y = tY; - g.Z = alt_bn128_Fq2::one(); - } - else - { - g = alt_bn128_G2::zero(); - } - - return in; -} - -template<> -void batch_to_special_all_non_zeros(std::vector &vec) -{ - std::vector Z_vec; - Z_vec.reserve(vec.size()); - - for (auto &el: vec) - { - Z_vec.emplace_back(el.Z); - } - batch_invert(Z_vec); - - const alt_bn128_Fq2 one = alt_bn128_Fq2::one(); - - for (size_t i = 0; i < vec.size(); ++i) - { - alt_bn128_Fq2 Z2 = Z_vec[i].squared(); - alt_bn128_Fq2 Z3 = Z_vec[i] * Z2; - - vec[i].X = vec[i].X * Z2; - vec[i].Y = vec[i].Y * Z3; - vec[i].Z = one; - } -} - -} // libsnark diff --git a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g2.hpp b/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g2.hpp deleted file mode 100644 index d6fa6a10d..000000000 --- a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_g2.hpp +++ /dev/null @@ -1,96 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef ALT_BN128_G2_HPP_ -#define ALT_BN128_G2_HPP_ -#include -#include "algebra/curves/alt_bn128/alt_bn128_init.hpp" -#include "algebra/curves/curve_utils.hpp" - -namespace libsnark { - -class alt_bn128_G2; -std::ostream& operator<<(std::ostream &, const alt_bn128_G2&); -std::istream& operator>>(std::istream &, alt_bn128_G2&); - -class alt_bn128_G2 { -public: -#ifdef PROFILE_OP_COUNTS - static int64_t add_cnt; - static int64_t dbl_cnt; -#endif - static std::vector wnaf_window_table; - static std::vector fixed_base_exp_window_table; - static alt_bn128_G2 G2_zero; - static alt_bn128_G2 G2_one; - - typedef alt_bn128_Fq base_field; - typedef alt_bn128_Fq2 twist_field; - typedef alt_bn128_Fr scalar_field; - - alt_bn128_Fq2 X, Y, Z; - - // using Jacobian coordinates - alt_bn128_G2(); - alt_bn128_G2(const alt_bn128_Fq2& X, const alt_bn128_Fq2& Y, const alt_bn128_Fq2& Z) : X(X), Y(Y), Z(Z) {}; - - static alt_bn128_Fq2 mul_by_b(const alt_bn128_Fq2 &elt); - - void print() const; - void print_coordinates() const; - - void to_affine_coordinates(); - void to_special(); - bool is_special() const; - - bool is_zero() const; - - bool operator==(const alt_bn128_G2 &other) const; - bool operator!=(const alt_bn128_G2 &other) const; - - alt_bn128_G2 operator+(const alt_bn128_G2 &other) const; - alt_bn128_G2 operator-() const; - alt_bn128_G2 operator-(const alt_bn128_G2 &other) const; - - alt_bn128_G2 add(const alt_bn128_G2 &other) const; - alt_bn128_G2 mixed_add(const alt_bn128_G2 &other) const; - alt_bn128_G2 dbl() const; - alt_bn128_G2 mul_by_q() const; - - bool is_well_formed() const; - - static alt_bn128_G2 zero(); - static alt_bn128_G2 one(); - static alt_bn128_G2 random_element(); - - static size_t size_in_bits() { return twist_field::size_in_bits() + 1; } - static bigint base_field_char() { return base_field::field_char(); } - static bigint order() { return scalar_field::field_char(); } - - friend std::ostream& operator<<(std::ostream &out, const alt_bn128_G2 &g); - friend std::istream& operator>>(std::istream &in, alt_bn128_G2 &g); -}; - -template -alt_bn128_G2 operator*(const bigint &lhs, const alt_bn128_G2 &rhs) -{ - return scalar_mul(rhs, lhs); -} - -template& modulus_p> -alt_bn128_G2 operator*(const Fp_model &lhs, const alt_bn128_G2 &rhs) -{ - return scalar_mul(rhs, lhs.as_bigint()); -} - -template -void batch_to_special_all_non_zeros(std::vector &vec); -template<> -void batch_to_special_all_non_zeros(std::vector &vec); - -} // libsnark -#endif // ALT_BN128_G2_HPP_ diff --git a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_init.cpp b/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_init.cpp deleted file mode 100644 index 7c23773d6..000000000 --- a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_init.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#include "algebra/curves/alt_bn128/alt_bn128_init.hpp" -#include "algebra/curves/alt_bn128/alt_bn128_g1.hpp" -#include "algebra/curves/alt_bn128/alt_bn128_g2.hpp" - -namespace libsnark { - -bigint alt_bn128_modulus_r; -bigint alt_bn128_modulus_q; - -alt_bn128_Fq alt_bn128_coeff_b; -alt_bn128_Fq2 alt_bn128_twist; -alt_bn128_Fq2 alt_bn128_twist_coeff_b; -alt_bn128_Fq alt_bn128_twist_mul_by_b_c0; -alt_bn128_Fq alt_bn128_twist_mul_by_b_c1; -alt_bn128_Fq2 alt_bn128_twist_mul_by_q_X; -alt_bn128_Fq2 alt_bn128_twist_mul_by_q_Y; - -bigint alt_bn128_ate_loop_count; -bool alt_bn128_ate_is_loop_count_neg; -bigint<12*alt_bn128_q_limbs> alt_bn128_final_exponent; -bigint alt_bn128_final_exponent_z; -bool alt_bn128_final_exponent_is_z_neg; - -void init_alt_bn128_params() -{ - typedef bigint bigint_r; - typedef bigint bigint_q; - - assert(sizeof(mp_limb_t) == 8 || sizeof(mp_limb_t) == 4); // Montgomery assumes this - - /* parameters for scalar field Fr */ - - alt_bn128_modulus_r = bigint_r("21888242871839275222246405745257275088548364400416034343698204186575808495617"); - assert(alt_bn128_Fr::modulus_is_valid()); - if (sizeof(mp_limb_t) == 8) - { - alt_bn128_Fr::Rsquared = bigint_r("944936681149208446651664254269745548490766851729442924617792859073125903783"); - alt_bn128_Fr::Rcubed = bigint_r("5866548545943845227489894872040244720403868105578784105281690076696998248512"); - alt_bn128_Fr::inv = 0xc2e1f593efffffff; - } - if (sizeof(mp_limb_t) == 4) - { - alt_bn128_Fr::Rsquared = bigint_r("944936681149208446651664254269745548490766851729442924617792859073125903783"); - alt_bn128_Fr::Rcubed = bigint_r("5866548545943845227489894872040244720403868105578784105281690076696998248512"); - alt_bn128_Fr::inv = 0xefffffff; - } - alt_bn128_Fr::num_bits = 254; - alt_bn128_Fr::euler = bigint_r("10944121435919637611123202872628637544274182200208017171849102093287904247808"); - alt_bn128_Fr::s = 28; - alt_bn128_Fr::t = bigint_r("81540058820840996586704275553141814055101440848469862132140264610111"); - alt_bn128_Fr::t_minus_1_over_2 = bigint_r("40770029410420498293352137776570907027550720424234931066070132305055"); - alt_bn128_Fr::multiplicative_generator = alt_bn128_Fr("5"); - alt_bn128_Fr::root_of_unity = alt_bn128_Fr("19103219067921713944291392827692070036145651957329286315305642004821462161904"); - alt_bn128_Fr::nqr = alt_bn128_Fr("5"); - alt_bn128_Fr::nqr_to_t = alt_bn128_Fr("19103219067921713944291392827692070036145651957329286315305642004821462161904"); - - /* parameters for base field Fq */ - - alt_bn128_modulus_q = bigint_q("21888242871839275222246405745257275088696311157297823662689037894645226208583"); - assert(alt_bn128_Fq::modulus_is_valid()); - if (sizeof(mp_limb_t) == 8) - { - alt_bn128_Fq::Rsquared = bigint_q("3096616502983703923843567936837374451735540968419076528771170197431451843209"); - alt_bn128_Fq::Rcubed = bigint_q("14921786541159648185948152738563080959093619838510245177710943249661917737183"); - alt_bn128_Fq::inv = 0x87d20782e4866389; - } - if (sizeof(mp_limb_t) == 4) - { - alt_bn128_Fq::Rsquared = bigint_q("3096616502983703923843567936837374451735540968419076528771170197431451843209"); - alt_bn128_Fq::Rcubed = bigint_q("14921786541159648185948152738563080959093619838510245177710943249661917737183"); - alt_bn128_Fq::inv = 0xe4866389; - } - alt_bn128_Fq::num_bits = 254; - alt_bn128_Fq::euler = bigint_q("10944121435919637611123202872628637544348155578648911831344518947322613104291"); - alt_bn128_Fq::s = 1; - alt_bn128_Fq::t = bigint_q("10944121435919637611123202872628637544348155578648911831344518947322613104291"); - alt_bn128_Fq::t_minus_1_over_2 = bigint_q("5472060717959818805561601436314318772174077789324455915672259473661306552145"); - alt_bn128_Fq::multiplicative_generator = alt_bn128_Fq("3"); - alt_bn128_Fq::root_of_unity = alt_bn128_Fq("21888242871839275222246405745257275088696311157297823662689037894645226208582"); - alt_bn128_Fq::nqr = alt_bn128_Fq("3"); - alt_bn128_Fq::nqr_to_t = alt_bn128_Fq("21888242871839275222246405745257275088696311157297823662689037894645226208582"); - - /* parameters for twist field Fq2 */ - alt_bn128_Fq2::euler = bigint<2*alt_bn128_q_limbs>("239547588008311421220994022608339370399626158265550411218223901127035046843189118723920525909718935985594116157406550130918127817069793474323196511433944"); - alt_bn128_Fq2::s = 4; - alt_bn128_Fq2::t = bigint<2*alt_bn128_q_limbs>("29943448501038927652624252826042421299953269783193801402277987640879380855398639840490065738714866998199264519675818766364765977133724184290399563929243"); - alt_bn128_Fq2::t_minus_1_over_2 = bigint<2*alt_bn128_q_limbs>("14971724250519463826312126413021210649976634891596900701138993820439690427699319920245032869357433499099632259837909383182382988566862092145199781964621"); - alt_bn128_Fq2::non_residue = alt_bn128_Fq("21888242871839275222246405745257275088696311157297823662689037894645226208582"); - alt_bn128_Fq2::nqr = alt_bn128_Fq2(alt_bn128_Fq("2"),alt_bn128_Fq("1")); - alt_bn128_Fq2::nqr_to_t = alt_bn128_Fq2(alt_bn128_Fq("5033503716262624267312492558379982687175200734934877598599011485707452665730"),alt_bn128_Fq("314498342015008975724433667930697407966947188435857772134235984660852259084")); - alt_bn128_Fq2::Frobenius_coeffs_c1[0] = alt_bn128_Fq("1"); - alt_bn128_Fq2::Frobenius_coeffs_c1[1] = alt_bn128_Fq("21888242871839275222246405745257275088696311157297823662689037894645226208582"); - - /* parameters for Fq6 */ - alt_bn128_Fq6::non_residue = alt_bn128_Fq2(alt_bn128_Fq("9"),alt_bn128_Fq("1")); - alt_bn128_Fq6::Frobenius_coeffs_c1[0] = alt_bn128_Fq2(alt_bn128_Fq("1"),alt_bn128_Fq("0")); - alt_bn128_Fq6::Frobenius_coeffs_c1[1] = alt_bn128_Fq2(alt_bn128_Fq("21575463638280843010398324269430826099269044274347216827212613867836435027261"),alt_bn128_Fq("10307601595873709700152284273816112264069230130616436755625194854815875713954")); - alt_bn128_Fq6::Frobenius_coeffs_c1[2] = alt_bn128_Fq2(alt_bn128_Fq("21888242871839275220042445260109153167277707414472061641714758635765020556616"),alt_bn128_Fq("0")); - alt_bn128_Fq6::Frobenius_coeffs_c1[3] = alt_bn128_Fq2(alt_bn128_Fq("3772000881919853776433695186713858239009073593817195771773381919316419345261"),alt_bn128_Fq("2236595495967245188281701248203181795121068902605861227855261137820944008926")); - alt_bn128_Fq6::Frobenius_coeffs_c1[4] = alt_bn128_Fq2(alt_bn128_Fq("2203960485148121921418603742825762020974279258880205651966"),alt_bn128_Fq("0")); - alt_bn128_Fq6::Frobenius_coeffs_c1[5] = alt_bn128_Fq2(alt_bn128_Fq("18429021223477853657660792034369865839114504446431234726392080002137598044644"),alt_bn128_Fq("9344045779998320333812420223237981029506012124075525679208581902008406485703")); - alt_bn128_Fq6::Frobenius_coeffs_c2[0] = alt_bn128_Fq2(alt_bn128_Fq("1"),alt_bn128_Fq("0")); - alt_bn128_Fq6::Frobenius_coeffs_c2[1] = alt_bn128_Fq2(alt_bn128_Fq("2581911344467009335267311115468803099551665605076196740867805258568234346338"),alt_bn128_Fq("19937756971775647987995932169929341994314640652964949448313374472400716661030")); - alt_bn128_Fq6::Frobenius_coeffs_c2[2] = alt_bn128_Fq2(alt_bn128_Fq("2203960485148121921418603742825762020974279258880205651966"),alt_bn128_Fq("0")); - alt_bn128_Fq6::Frobenius_coeffs_c2[3] = alt_bn128_Fq2(alt_bn128_Fq("5324479202449903542726783395506214481928257762400643279780343368557297135718"),alt_bn128_Fq("16208900380737693084919495127334387981393726419856888799917914180988844123039")); - alt_bn128_Fq6::Frobenius_coeffs_c2[4] = alt_bn128_Fq2(alt_bn128_Fq("21888242871839275220042445260109153167277707414472061641714758635765020556616"),alt_bn128_Fq("0")); - alt_bn128_Fq6::Frobenius_coeffs_c2[5] = alt_bn128_Fq2(alt_bn128_Fq("13981852324922362344252311234282257507216387789820983642040889267519694726527"),alt_bn128_Fq("7629828391165209371577384193250820201684255241773809077146787135900891633097")); - - /* parameters for Fq12 */ - - alt_bn128_Fq12::non_residue = alt_bn128_Fq2(alt_bn128_Fq("9"),alt_bn128_Fq("1")); - alt_bn128_Fq12::Frobenius_coeffs_c1[0] = alt_bn128_Fq2(alt_bn128_Fq("1"),alt_bn128_Fq("0")); - alt_bn128_Fq12::Frobenius_coeffs_c1[1] = alt_bn128_Fq2(alt_bn128_Fq("8376118865763821496583973867626364092589906065868298776909617916018768340080"),alt_bn128_Fq("16469823323077808223889137241176536799009286646108169935659301613961712198316")); - alt_bn128_Fq12::Frobenius_coeffs_c1[2] = alt_bn128_Fq2(alt_bn128_Fq("21888242871839275220042445260109153167277707414472061641714758635765020556617"),alt_bn128_Fq("0")); - alt_bn128_Fq12::Frobenius_coeffs_c1[3] = alt_bn128_Fq2(alt_bn128_Fq("11697423496358154304825782922584725312912383441159505038794027105778954184319"),alt_bn128_Fq("303847389135065887422783454877609941456349188919719272345083954437860409601")); - alt_bn128_Fq12::Frobenius_coeffs_c1[4] = alt_bn128_Fq2(alt_bn128_Fq("21888242871839275220042445260109153167277707414472061641714758635765020556616"),alt_bn128_Fq("0")); - alt_bn128_Fq12::Frobenius_coeffs_c1[5] = alt_bn128_Fq2(alt_bn128_Fq("3321304630594332808241809054958361220322477375291206261884409189760185844239"),alt_bn128_Fq("5722266937896532885780051958958348231143373700109372999374820235121374419868")); - alt_bn128_Fq12::Frobenius_coeffs_c1[6] = alt_bn128_Fq2(alt_bn128_Fq("21888242871839275222246405745257275088696311157297823662689037894645226208582"),alt_bn128_Fq("0")); - alt_bn128_Fq12::Frobenius_coeffs_c1[7] = alt_bn128_Fq2(alt_bn128_Fq("13512124006075453725662431877630910996106405091429524885779419978626457868503"),alt_bn128_Fq("5418419548761466998357268504080738289687024511189653727029736280683514010267")); - alt_bn128_Fq12::Frobenius_coeffs_c1[8] = alt_bn128_Fq2(alt_bn128_Fq("2203960485148121921418603742825762020974279258880205651966"),alt_bn128_Fq("0")); - alt_bn128_Fq12::Frobenius_coeffs_c1[9] = alt_bn128_Fq2(alt_bn128_Fq("10190819375481120917420622822672549775783927716138318623895010788866272024264"),alt_bn128_Fq("21584395482704209334823622290379665147239961968378104390343953940207365798982")); - alt_bn128_Fq12::Frobenius_coeffs_c1[10] = alt_bn128_Fq2(alt_bn128_Fq("2203960485148121921418603742825762020974279258880205651967"),alt_bn128_Fq("0")); - alt_bn128_Fq12::Frobenius_coeffs_c1[11] = alt_bn128_Fq2(alt_bn128_Fq("18566938241244942414004596690298913868373833782006617400804628704885040364344"),alt_bn128_Fq("16165975933942742336466353786298926857552937457188450663314217659523851788715")); - - /* choice of short Weierstrass curve and its twist */ - - alt_bn128_coeff_b = alt_bn128_Fq("3"); - alt_bn128_twist = alt_bn128_Fq2(alt_bn128_Fq("9"), alt_bn128_Fq("1")); - alt_bn128_twist_coeff_b = alt_bn128_coeff_b * alt_bn128_twist.inverse(); - alt_bn128_twist_mul_by_b_c0 = alt_bn128_coeff_b * alt_bn128_Fq2::non_residue; - alt_bn128_twist_mul_by_b_c1 = alt_bn128_coeff_b * alt_bn128_Fq2::non_residue; - alt_bn128_twist_mul_by_q_X = alt_bn128_Fq2(alt_bn128_Fq("21575463638280843010398324269430826099269044274347216827212613867836435027261"), - alt_bn128_Fq("10307601595873709700152284273816112264069230130616436755625194854815875713954")); - alt_bn128_twist_mul_by_q_Y = alt_bn128_Fq2(alt_bn128_Fq("2821565182194536844548159561693502659359617185244120367078079554186484126554"), - alt_bn128_Fq("3505843767911556378687030309984248845540243509899259641013678093033130930403")); - - /* choice of group G1 */ - alt_bn128_G1::G1_zero = alt_bn128_G1(alt_bn128_Fq::zero(), - alt_bn128_Fq::one(), - alt_bn128_Fq::zero()); - alt_bn128_G1::G1_one = alt_bn128_G1(alt_bn128_Fq("1"), - alt_bn128_Fq("2"), - alt_bn128_Fq::one()); - alt_bn128_G1::wnaf_window_table.push_back(11); - alt_bn128_G1::wnaf_window_table.push_back(24); - alt_bn128_G1::wnaf_window_table.push_back(60); - alt_bn128_G1::wnaf_window_table.push_back(127); - - alt_bn128_G1::fixed_base_exp_window_table.resize(0); - // window 1 is unbeaten in [-inf, 4.99] - alt_bn128_G1::fixed_base_exp_window_table.push_back(1); - // window 2 is unbeaten in [4.99, 10.99] - alt_bn128_G1::fixed_base_exp_window_table.push_back(5); - // window 3 is unbeaten in [10.99, 32.29] - alt_bn128_G1::fixed_base_exp_window_table.push_back(11); - // window 4 is unbeaten in [32.29, 55.23] - alt_bn128_G1::fixed_base_exp_window_table.push_back(32); - // window 5 is unbeaten in [55.23, 162.03] - alt_bn128_G1::fixed_base_exp_window_table.push_back(55); - // window 6 is unbeaten in [162.03, 360.15] - alt_bn128_G1::fixed_base_exp_window_table.push_back(162); - // window 7 is unbeaten in [360.15, 815.44] - alt_bn128_G1::fixed_base_exp_window_table.push_back(360); - // window 8 is unbeaten in [815.44, 2373.07] - alt_bn128_G1::fixed_base_exp_window_table.push_back(815); - // window 9 is unbeaten in [2373.07, 6977.75] - alt_bn128_G1::fixed_base_exp_window_table.push_back(2373); - // window 10 is unbeaten in [6977.75, 7122.23] - alt_bn128_G1::fixed_base_exp_window_table.push_back(6978); - // window 11 is unbeaten in [7122.23, 57818.46] - alt_bn128_G1::fixed_base_exp_window_table.push_back(7122); - // window 12 is never the best - alt_bn128_G1::fixed_base_exp_window_table.push_back(0); - // window 13 is unbeaten in [57818.46, 169679.14] - alt_bn128_G1::fixed_base_exp_window_table.push_back(57818); - // window 14 is never the best - alt_bn128_G1::fixed_base_exp_window_table.push_back(0); - // window 15 is unbeaten in [169679.14, 439758.91] - alt_bn128_G1::fixed_base_exp_window_table.push_back(169679); - // window 16 is unbeaten in [439758.91, 936073.41] - alt_bn128_G1::fixed_base_exp_window_table.push_back(439759); - // window 17 is unbeaten in [936073.41, 4666554.74] - alt_bn128_G1::fixed_base_exp_window_table.push_back(936073); - // window 18 is never the best - alt_bn128_G1::fixed_base_exp_window_table.push_back(0); - // window 19 is unbeaten in [4666554.74, 7580404.42] - alt_bn128_G1::fixed_base_exp_window_table.push_back(4666555); - // window 20 is unbeaten in [7580404.42, 34552892.20] - alt_bn128_G1::fixed_base_exp_window_table.push_back(7580404); - // window 21 is never the best - alt_bn128_G1::fixed_base_exp_window_table.push_back(0); - // window 22 is unbeaten in [34552892.20, inf] - alt_bn128_G1::fixed_base_exp_window_table.push_back(34552892); - - /* choice of group G2 */ - - alt_bn128_G2::G2_zero = alt_bn128_G2(alt_bn128_Fq2::zero(), - alt_bn128_Fq2::one(), - alt_bn128_Fq2::zero()); - - alt_bn128_G2::G2_one = alt_bn128_G2(alt_bn128_Fq2(alt_bn128_Fq("10857046999023057135944570762232829481370756359578518086990519993285655852781"), - alt_bn128_Fq("11559732032986387107991004021392285783925812861821192530917403151452391805634")), - alt_bn128_Fq2(alt_bn128_Fq("8495653923123431417604973247489272438418190587263600148770280649306958101930"), - alt_bn128_Fq("4082367875863433681332203403145435568316851327593401208105741076214120093531")), - alt_bn128_Fq2::one()); - alt_bn128_G2::wnaf_window_table.push_back(5); - alt_bn128_G2::wnaf_window_table.push_back(15); - alt_bn128_G2::wnaf_window_table.push_back(39); - alt_bn128_G2::wnaf_window_table.push_back(109); - - alt_bn128_G2::fixed_base_exp_window_table.resize(0); - // window 1 is unbeaten in [-inf, 5.10] - alt_bn128_G2::fixed_base_exp_window_table.push_back(1); - // window 2 is unbeaten in [5.10, 10.43] - alt_bn128_G2::fixed_base_exp_window_table.push_back(5); - // window 3 is unbeaten in [10.43, 25.28] - alt_bn128_G2::fixed_base_exp_window_table.push_back(10); - // window 4 is unbeaten in [25.28, 59.00] - alt_bn128_G2::fixed_base_exp_window_table.push_back(25); - // window 5 is unbeaten in [59.00, 154.03] - alt_bn128_G2::fixed_base_exp_window_table.push_back(59); - // window 6 is unbeaten in [154.03, 334.25] - alt_bn128_G2::fixed_base_exp_window_table.push_back(154); - // window 7 is unbeaten in [334.25, 742.58] - alt_bn128_G2::fixed_base_exp_window_table.push_back(334); - // window 8 is unbeaten in [742.58, 2034.40] - alt_bn128_G2::fixed_base_exp_window_table.push_back(743); - // window 9 is unbeaten in [2034.40, 4987.56] - alt_bn128_G2::fixed_base_exp_window_table.push_back(2034); - // window 10 is unbeaten in [4987.56, 8888.27] - alt_bn128_G2::fixed_base_exp_window_table.push_back(4988); - // window 11 is unbeaten in [8888.27, 26271.13] - alt_bn128_G2::fixed_base_exp_window_table.push_back(8888); - // window 12 is unbeaten in [26271.13, 39768.20] - alt_bn128_G2::fixed_base_exp_window_table.push_back(26271); - // window 13 is unbeaten in [39768.20, 106275.75] - alt_bn128_G2::fixed_base_exp_window_table.push_back(39768); - // window 14 is unbeaten in [106275.75, 141703.40] - alt_bn128_G2::fixed_base_exp_window_table.push_back(106276); - // window 15 is unbeaten in [141703.40, 462422.97] - alt_bn128_G2::fixed_base_exp_window_table.push_back(141703); - // window 16 is unbeaten in [462422.97, 926871.84] - alt_bn128_G2::fixed_base_exp_window_table.push_back(462423); - // window 17 is unbeaten in [926871.84, 4873049.17] - alt_bn128_G2::fixed_base_exp_window_table.push_back(926872); - // window 18 is never the best - alt_bn128_G2::fixed_base_exp_window_table.push_back(0); - // window 19 is unbeaten in [4873049.17, 5706707.88] - alt_bn128_G2::fixed_base_exp_window_table.push_back(4873049); - // window 20 is unbeaten in [5706707.88, 31673814.95] - alt_bn128_G2::fixed_base_exp_window_table.push_back(5706708); - // window 21 is never the best - alt_bn128_G2::fixed_base_exp_window_table.push_back(0); - // window 22 is unbeaten in [31673814.95, inf] - alt_bn128_G2::fixed_base_exp_window_table.push_back(31673815); - - /* pairing parameters */ - - alt_bn128_ate_loop_count = bigint_q("29793968203157093288"); - alt_bn128_ate_is_loop_count_neg = false; - alt_bn128_final_exponent = bigint<12*alt_bn128_q_limbs>("552484233613224096312617126783173147097382103762957654188882734314196910839907541213974502761540629817009608548654680343627701153829446747810907373256841551006201639677726139946029199968412598804882391702273019083653272047566316584365559776493027495458238373902875937659943504873220554161550525926302303331747463515644711876653177129578303191095900909191624817826566688241804408081892785725967931714097716709526092261278071952560171111444072049229123565057483750161460024353346284167282452756217662335528813519139808291170539072125381230815729071544861602750936964829313608137325426383735122175229541155376346436093930287402089517426973178917569713384748081827255472576937471496195752727188261435633271238710131736096299798168852925540549342330775279877006784354801422249722573783561685179618816480037695005515426162362431072245638324744480"); - alt_bn128_final_exponent_z = bigint_q("4965661367192848881"); - alt_bn128_final_exponent_is_z_neg = false; - -} -} // libsnark diff --git a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_init.hpp b/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_init.hpp deleted file mode 100644 index c3bea7673..000000000 --- a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_init.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef ALT_BN128_INIT_HPP_ -#define ALT_BN128_INIT_HPP_ -#include "algebra/curves/public_params.hpp" -#include "algebra/fields/fp.hpp" -#include "algebra/fields/fp2.hpp" -#include "algebra/fields/fp6_3over2.hpp" -#include "algebra/fields/fp12_2over3over2.hpp" - -namespace libsnark { - -const mp_size_t alt_bn128_r_bitcount = 254; -const mp_size_t alt_bn128_q_bitcount = 254; - -const mp_size_t alt_bn128_r_limbs = (alt_bn128_r_bitcount+GMP_NUMB_BITS-1)/GMP_NUMB_BITS; -const mp_size_t alt_bn128_q_limbs = (alt_bn128_q_bitcount+GMP_NUMB_BITS-1)/GMP_NUMB_BITS; - -extern bigint alt_bn128_modulus_r; -extern bigint alt_bn128_modulus_q; - -typedef Fp_model alt_bn128_Fr; -typedef Fp_model alt_bn128_Fq; -typedef Fp2_model alt_bn128_Fq2; -typedef Fp6_3over2_model alt_bn128_Fq6; -typedef Fp12_2over3over2_model alt_bn128_Fq12; -typedef alt_bn128_Fq12 alt_bn128_GT; - -// parameters for Barreto--Naehrig curve E/Fq : y^2 = x^3 + b -extern alt_bn128_Fq alt_bn128_coeff_b; -// parameters for twisted Barreto--Naehrig curve E'/Fq2 : y^2 = x^3 + b/xi -extern alt_bn128_Fq2 alt_bn128_twist; -extern alt_bn128_Fq2 alt_bn128_twist_coeff_b; -extern alt_bn128_Fq alt_bn128_twist_mul_by_b_c0; -extern alt_bn128_Fq alt_bn128_twist_mul_by_b_c1; -extern alt_bn128_Fq2 alt_bn128_twist_mul_by_q_X; -extern alt_bn128_Fq2 alt_bn128_twist_mul_by_q_Y; - -// parameters for pairing -extern bigint alt_bn128_ate_loop_count; -extern bool alt_bn128_ate_is_loop_count_neg; -extern bigint<12*alt_bn128_q_limbs> alt_bn128_final_exponent; -extern bigint alt_bn128_final_exponent_z; -extern bool alt_bn128_final_exponent_is_z_neg; - -void init_alt_bn128_params(); - -class alt_bn128_G1; -class alt_bn128_G2; - -} // libsnark -#endif // ALT_BN128_INIT_HPP_ diff --git a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pairing.cpp b/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pairing.cpp deleted file mode 100644 index 07b6a8c71..000000000 --- a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pairing.cpp +++ /dev/null @@ -1,547 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#include "algebra/curves/alt_bn128/alt_bn128_pairing.hpp" -#include "algebra/curves/alt_bn128/alt_bn128_init.hpp" -#include "algebra/curves/alt_bn128/alt_bn128_g1.hpp" -#include "algebra/curves/alt_bn128/alt_bn128_g2.hpp" -#include -#include "common/profiling.hpp" -#include "common/assert_except.hpp" - -namespace libsnark { - -bool alt_bn128_ate_G1_precomp::operator==(const alt_bn128_ate_G1_precomp &other) const -{ - return (this->PX == other.PX && - this->PY == other.PY); -} - -std::ostream& operator<<(std::ostream &out, const alt_bn128_ate_G1_precomp &prec_P) -{ - out << prec_P.PX << OUTPUT_SEPARATOR << prec_P.PY; - - return out; -} - -std::istream& operator>>(std::istream &in, alt_bn128_ate_G1_precomp &prec_P) -{ - in >> prec_P.PX; - consume_OUTPUT_SEPARATOR(in); - in >> prec_P.PY; - - return in; -} - -bool alt_bn128_ate_ell_coeffs::operator==(const alt_bn128_ate_ell_coeffs &other) const -{ - return (this->ell_0 == other.ell_0 && - this->ell_VW == other.ell_VW && - this->ell_VV == other.ell_VV); -} - -std::ostream& operator<<(std::ostream &out, const alt_bn128_ate_ell_coeffs &c) -{ - out << c.ell_0 << OUTPUT_SEPARATOR << c.ell_VW << OUTPUT_SEPARATOR << c.ell_VV; - return out; -} - -std::istream& operator>>(std::istream &in, alt_bn128_ate_ell_coeffs &c) -{ - in >> c.ell_0; - consume_OUTPUT_SEPARATOR(in); - in >> c.ell_VW; - consume_OUTPUT_SEPARATOR(in); - in >> c.ell_VV; - - return in; -} - -bool alt_bn128_ate_G2_precomp::operator==(const alt_bn128_ate_G2_precomp &other) const -{ - return (this->QX == other.QX && - this->QY == other.QY && - this->coeffs == other.coeffs); -} - -std::ostream& operator<<(std::ostream& out, const alt_bn128_ate_G2_precomp &prec_Q) -{ - out << prec_Q.QX << OUTPUT_SEPARATOR << prec_Q.QY << "\n"; - out << prec_Q.coeffs.size() << "\n"; - for (const alt_bn128_ate_ell_coeffs &c : prec_Q.coeffs) - { - out << c << OUTPUT_NEWLINE; - } - return out; -} - -std::istream& operator>>(std::istream& in, alt_bn128_ate_G2_precomp &prec_Q) -{ - in >> prec_Q.QX; - consume_OUTPUT_SEPARATOR(in); - in >> prec_Q.QY; - consume_newline(in); - - prec_Q.coeffs.clear(); - size_t s; - in >> s; - - consume_newline(in); - - prec_Q.coeffs.reserve(s); - - for (size_t i = 0; i < s; ++i) - { - alt_bn128_ate_ell_coeffs c; - in >> c; - consume_OUTPUT_NEWLINE(in); - prec_Q.coeffs.emplace_back(c); - } - - return in; -} - -/* final exponentiations */ - -alt_bn128_Fq12 alt_bn128_final_exponentiation_first_chunk(const alt_bn128_Fq12 &elt) -{ - enter_block("Call to alt_bn128_final_exponentiation_first_chunk"); - - /* - Computes result = elt^((q^6-1)*(q^2+1)). - Follows, e.g., Beuchat et al page 9, by computing result as follows: - elt^((q^6-1)*(q^2+1)) = (conj(elt) * elt^(-1))^(q^2+1) - More precisely: - A = conj(elt) - B = elt.inverse() - C = A * B - D = C.Frobenius_map(2) - result = D * C - */ - - const alt_bn128_Fq12 A = alt_bn128_Fq12(elt.c0,-elt.c1); - const alt_bn128_Fq12 B = elt.inverse(); - const alt_bn128_Fq12 C = A * B; - const alt_bn128_Fq12 D = C.Frobenius_map(2); - const alt_bn128_Fq12 result = D * C; - - leave_block("Call to alt_bn128_final_exponentiation_first_chunk"); - - return result; -} - -alt_bn128_Fq12 alt_bn128_exp_by_neg_z(const alt_bn128_Fq12 &elt) -{ - enter_block("Call to alt_bn128_exp_by_neg_z"); - - alt_bn128_Fq12 result = elt.cyclotomic_exp(alt_bn128_final_exponent_z); - if (!alt_bn128_final_exponent_is_z_neg) - { - result = result.unitary_inverse(); - } - - leave_block("Call to alt_bn128_exp_by_neg_z"); - - return result; -} - -alt_bn128_Fq12 alt_bn128_final_exponentiation_last_chunk(const alt_bn128_Fq12 &elt) -{ - enter_block("Call to alt_bn128_final_exponentiation_last_chunk"); - - /* - Follows Laura Fuentes-Castaneda et al. "Faster hashing to G2" - by computing: - - result = elt^(q^3 * (12*z^3 + 6z^2 + 4z - 1) + - q^2 * (12*z^3 + 6z^2 + 6z) + - q * (12*z^3 + 6z^2 + 4z) + - 1 * (12*z^3 + 12z^2 + 6z + 1)) - which equals - - result = elt^( 2z * ( 6z^2 + 3z + 1 ) * (q^4 - q^2 + 1)/r ). - - Using the following addition chain: - - A = exp_by_neg_z(elt) // = elt^(-z) - B = A^2 // = elt^(-2*z) - C = B^2 // = elt^(-4*z) - D = C * B // = elt^(-6*z) - E = exp_by_neg_z(D) // = elt^(6*z^2) - F = E^2 // = elt^(12*z^2) - G = epx_by_neg_z(F) // = elt^(-12*z^3) - H = conj(D) // = elt^(6*z) - I = conj(G) // = elt^(12*z^3) - J = I * E // = elt^(12*z^3 + 6*z^2) - K = J * H // = elt^(12*z^3 + 6*z^2 + 6*z) - L = K * B // = elt^(12*z^3 + 6*z^2 + 4*z) - M = K * E // = elt^(12*z^3 + 12*z^2 + 6*z) - N = M * elt // = elt^(12*z^3 + 12*z^2 + 6*z + 1) - O = L.Frobenius_map(1) // = elt^(q*(12*z^3 + 6*z^2 + 4*z)) - P = O * N // = elt^(q*(12*z^3 + 6*z^2 + 4*z) * (12*z^3 + 12*z^2 + 6*z + 1)) - Q = K.Frobenius_map(2) // = elt^(q^2 * (12*z^3 + 6*z^2 + 6*z)) - R = Q * P // = elt^(q^2 * (12*z^3 + 6*z^2 + 6*z) + q*(12*z^3 + 6*z^2 + 4*z) * (12*z^3 + 12*z^2 + 6*z + 1)) - S = conj(elt) // = elt^(-1) - T = S * L // = elt^(12*z^3 + 6*z^2 + 4*z - 1) - U = T.Frobenius_map(3) // = elt^(q^3(12*z^3 + 6*z^2 + 4*z - 1)) - V = U * R // = elt^(q^3(12*z^3 + 6*z^2 + 4*z - 1) + q^2 * (12*z^3 + 6*z^2 + 6*z) + q*(12*z^3 + 6*z^2 + 4*z) * (12*z^3 + 12*z^2 + 6*z + 1)) - result = V - - */ - - const alt_bn128_Fq12 A = alt_bn128_exp_by_neg_z(elt); - const alt_bn128_Fq12 B = A.cyclotomic_squared(); - const alt_bn128_Fq12 C = B.cyclotomic_squared(); - const alt_bn128_Fq12 D = C * B; - const alt_bn128_Fq12 E = alt_bn128_exp_by_neg_z(D); - const alt_bn128_Fq12 F = E.cyclotomic_squared(); - const alt_bn128_Fq12 G = alt_bn128_exp_by_neg_z(F); - const alt_bn128_Fq12 H = D.unitary_inverse(); - const alt_bn128_Fq12 I = G.unitary_inverse(); - const alt_bn128_Fq12 J = I * E; - const alt_bn128_Fq12 K = J * H; - const alt_bn128_Fq12 L = K * B; - const alt_bn128_Fq12 M = K * E; - const alt_bn128_Fq12 N = M * elt; - const alt_bn128_Fq12 O = L.Frobenius_map(1); - const alt_bn128_Fq12 P = O * N; - const alt_bn128_Fq12 Q = K.Frobenius_map(2); - const alt_bn128_Fq12 R = Q * P; - const alt_bn128_Fq12 S = elt.unitary_inverse(); - const alt_bn128_Fq12 T = S * L; - const alt_bn128_Fq12 U = T.Frobenius_map(3); - const alt_bn128_Fq12 V = U * R; - - const alt_bn128_Fq12 result = V; - - leave_block("Call to alt_bn128_final_exponentiation_last_chunk"); - - return result; -} - -alt_bn128_GT alt_bn128_final_exponentiation(const alt_bn128_Fq12 &elt) -{ - enter_block("Call to alt_bn128_final_exponentiation"); - /* OLD naive version: - alt_bn128_GT result = elt^alt_bn128_final_exponent; - */ - alt_bn128_Fq12 A = alt_bn128_final_exponentiation_first_chunk(elt); - alt_bn128_GT result = alt_bn128_final_exponentiation_last_chunk(A); - - leave_block("Call to alt_bn128_final_exponentiation"); - return result; -} - -/* ate pairing */ - -void doubling_step_for_flipped_miller_loop(const alt_bn128_Fq two_inv, - alt_bn128_G2 ¤t, - alt_bn128_ate_ell_coeffs &c) -{ - const alt_bn128_Fq2 X = current.X, Y = current.Y, Z = current.Z; - - const alt_bn128_Fq2 A = two_inv * (X * Y); // A = X1 * Y1 / 2 - const alt_bn128_Fq2 B = Y.squared(); // B = Y1^2 - const alt_bn128_Fq2 C = Z.squared(); // C = Z1^2 - const alt_bn128_Fq2 D = C+C+C; // D = 3 * C - const alt_bn128_Fq2 E = alt_bn128_twist_coeff_b * D; // E = twist_b * D - const alt_bn128_Fq2 F = E+E+E; // F = 3 * E - const alt_bn128_Fq2 G = two_inv * (B+F); // G = (B+F)/2 - const alt_bn128_Fq2 H = (Y+Z).squared() - (B+C); // H = (Y1+Z1)^2-(B+C) - const alt_bn128_Fq2 I = E-B; // I = E-B - const alt_bn128_Fq2 J = X.squared(); // J = X1^2 - const alt_bn128_Fq2 E_squared = E.squared(); // E_squared = E^2 - - current.X = A * (B-F); // X3 = A * (B-F) - current.Y = G.squared() - (E_squared+E_squared+E_squared); // Y3 = G^2 - 3*E^2 - current.Z = B * H; // Z3 = B * H - c.ell_0 = alt_bn128_twist * I; // ell_0 = xi * I - c.ell_VW = -H; // ell_VW = - H (later: * yP) - c.ell_VV = J+J+J; // ell_VV = 3*J (later: * xP) -} - -void mixed_addition_step_for_flipped_miller_loop(const alt_bn128_G2 base, - alt_bn128_G2 ¤t, - alt_bn128_ate_ell_coeffs &c) -{ - const alt_bn128_Fq2 X1 = current.X, Y1 = current.Y, Z1 = current.Z; - const alt_bn128_Fq2 &x2 = base.X, &y2 = base.Y; - - const alt_bn128_Fq2 D = X1 - x2 * Z1; // D = X1 - X2*Z1 - const alt_bn128_Fq2 E = Y1 - y2 * Z1; // E = Y1 - Y2*Z1 - const alt_bn128_Fq2 F = D.squared(); // F = D^2 - const alt_bn128_Fq2 G = E.squared(); // G = E^2 - const alt_bn128_Fq2 H = D*F; // H = D*F - const alt_bn128_Fq2 I = X1 * F; // I = X1 * F - const alt_bn128_Fq2 J = H + Z1*G - (I+I); // J = H + Z1*G - (I+I) - - current.X = D * J; // X3 = D*J - current.Y = E * (I-J)-(H * Y1); // Y3 = E*(I-J)-(H*Y1) - current.Z = Z1 * H; // Z3 = Z1*H - c.ell_0 = alt_bn128_twist * (E * x2 - D * y2); // ell_0 = xi * (E * X2 - D * Y2) - c.ell_VV = - E; // ell_VV = - E (later: * xP) - c.ell_VW = D; // ell_VW = D (later: * yP ) -} - -alt_bn128_ate_G1_precomp alt_bn128_ate_precompute_G1(const alt_bn128_G1& P) -{ - enter_block("Call to alt_bn128_ate_precompute_G1"); - - alt_bn128_G1 Pcopy = P; - Pcopy.to_affine_coordinates(); - - alt_bn128_ate_G1_precomp result; - result.PX = Pcopy.X; - result.PY = Pcopy.Y; - - leave_block("Call to alt_bn128_ate_precompute_G1"); - return result; -} - -alt_bn128_ate_G2_precomp alt_bn128_ate_precompute_G2(const alt_bn128_G2& Q) -{ - enter_block("Call to alt_bn128_ate_precompute_G2"); - - alt_bn128_G2 Qcopy(Q); - Qcopy.to_affine_coordinates(); - - alt_bn128_Fq two_inv = (alt_bn128_Fq("2").inverse()); // could add to global params if needed - - alt_bn128_ate_G2_precomp result; - result.QX = Qcopy.X; - result.QY = Qcopy.Y; - - alt_bn128_G2 R; - R.X = Qcopy.X; - R.Y = Qcopy.Y; - R.Z = alt_bn128_Fq2::one(); - - const bigint &loop_count = alt_bn128_ate_loop_count; - bool found_one = false; - alt_bn128_ate_ell_coeffs c; - - for (int64_t i = loop_count.max_bits(); i >= 0; --i) - { - const bool bit = loop_count.test_bit(i); - if (!found_one) - { - /* this skips the MSB itself */ - found_one |= bit; - continue; - } - - doubling_step_for_flipped_miller_loop(two_inv, R, c); - result.coeffs.push_back(c); - - if (bit) - { - mixed_addition_step_for_flipped_miller_loop(Qcopy, R, c); - result.coeffs.push_back(c); - } - } - - alt_bn128_G2 Q1 = Qcopy.mul_by_q(); - assert_except(Q1.Z == alt_bn128_Fq2::one()); - alt_bn128_G2 Q2 = Q1.mul_by_q(); - assert_except(Q2.Z == alt_bn128_Fq2::one()); - - if (alt_bn128_ate_is_loop_count_neg) - { - R.Y = - R.Y; - } - Q2.Y = - Q2.Y; - - mixed_addition_step_for_flipped_miller_loop(Q1, R, c); - result.coeffs.push_back(c); - - mixed_addition_step_for_flipped_miller_loop(Q2, R, c); - result.coeffs.push_back(c); - - leave_block("Call to alt_bn128_ate_precompute_G2"); - return result; -} - -alt_bn128_Fq12 alt_bn128_ate_miller_loop(const alt_bn128_ate_G1_precomp &prec_P, - const alt_bn128_ate_G2_precomp &prec_Q) -{ - enter_block("Call to alt_bn128_ate_miller_loop"); - - alt_bn128_Fq12 f = alt_bn128_Fq12::one(); - - bool found_one = false; - size_t idx = 0; - - const bigint &loop_count = alt_bn128_ate_loop_count; - alt_bn128_ate_ell_coeffs c; - - for (int64_t i = loop_count.max_bits(); i >= 0; --i) - { - const bool bit = loop_count.test_bit(i); - if (!found_one) - { - /* this skips the MSB itself */ - found_one |= bit; - continue; - } - - /* code below gets executed for all bits (EXCEPT the MSB itself) of - alt_bn128_param_p (skipping leading zeros) in MSB to LSB - order */ - - c = prec_Q.coeffs[idx++]; - f = f.squared(); - f = f.mul_by_024(c.ell_0, prec_P.PY * c.ell_VW, prec_P.PX * c.ell_VV); - - if (bit) - { - c = prec_Q.coeffs[idx++]; - f = f.mul_by_024(c.ell_0, prec_P.PY * c.ell_VW, prec_P.PX * c.ell_VV); - } - - } - - if (alt_bn128_ate_is_loop_count_neg) - { - f = f.inverse(); - } - - c = prec_Q.coeffs[idx++]; - f = f.mul_by_024(c.ell_0,prec_P.PY * c.ell_VW,prec_P.PX * c.ell_VV); - - c = prec_Q.coeffs[idx++]; - f = f.mul_by_024(c.ell_0,prec_P.PY * c.ell_VW,prec_P.PX * c.ell_VV); - - leave_block("Call to alt_bn128_ate_miller_loop"); - return f; -} - -alt_bn128_Fq12 alt_bn128_ate_double_miller_loop(const alt_bn128_ate_G1_precomp &prec_P1, - const alt_bn128_ate_G2_precomp &prec_Q1, - const alt_bn128_ate_G1_precomp &prec_P2, - const alt_bn128_ate_G2_precomp &prec_Q2) -{ - enter_block("Call to alt_bn128_ate_double_miller_loop"); - - alt_bn128_Fq12 f = alt_bn128_Fq12::one(); - - bool found_one = false; - size_t idx = 0; - - const bigint &loop_count = alt_bn128_ate_loop_count; - for (int64_t i = loop_count.max_bits(); i >= 0; --i) - { - const bool bit = loop_count.test_bit(i); - if (!found_one) - { - /* this skips the MSB itself */ - found_one |= bit; - continue; - } - - /* code below gets executed for all bits (EXCEPT the MSB itself) of - alt_bn128_param_p (skipping leading zeros) in MSB to LSB - order */ - - alt_bn128_ate_ell_coeffs c1 = prec_Q1.coeffs[idx]; - alt_bn128_ate_ell_coeffs c2 = prec_Q2.coeffs[idx]; - ++idx; - - f = f.squared(); - - f = f.mul_by_024(c1.ell_0, prec_P1.PY * c1.ell_VW, prec_P1.PX * c1.ell_VV); - f = f.mul_by_024(c2.ell_0, prec_P2.PY * c2.ell_VW, prec_P2.PX * c2.ell_VV); - - if (bit) - { - alt_bn128_ate_ell_coeffs c1 = prec_Q1.coeffs[idx]; - alt_bn128_ate_ell_coeffs c2 = prec_Q2.coeffs[idx]; - ++idx; - - f = f.mul_by_024(c1.ell_0, prec_P1.PY * c1.ell_VW, prec_P1.PX * c1.ell_VV); - f = f.mul_by_024(c2.ell_0, prec_P2.PY * c2.ell_VW, prec_P2.PX * c2.ell_VV); - } - } - - if (alt_bn128_ate_is_loop_count_neg) - { - f = f.inverse(); - } - - alt_bn128_ate_ell_coeffs c1 = prec_Q1.coeffs[idx]; - alt_bn128_ate_ell_coeffs c2 = prec_Q2.coeffs[idx]; - ++idx; - f = f.mul_by_024(c1.ell_0, prec_P1.PY * c1.ell_VW, prec_P1.PX * c1.ell_VV); - f = f.mul_by_024(c2.ell_0, prec_P2.PY * c2.ell_VW, prec_P2.PX * c2.ell_VV); - - c1 = prec_Q1.coeffs[idx]; - c2 = prec_Q2.coeffs[idx]; - ++idx; - f = f.mul_by_024(c1.ell_0, prec_P1.PY * c1.ell_VW, prec_P1.PX * c1.ell_VV); - f = f.mul_by_024(c2.ell_0, prec_P2.PY * c2.ell_VW, prec_P2.PX * c2.ell_VV); - - leave_block("Call to alt_bn128_ate_double_miller_loop"); - - return f; -} - -alt_bn128_Fq12 alt_bn128_ate_pairing(const alt_bn128_G1& P, const alt_bn128_G2 &Q) -{ - enter_block("Call to alt_bn128_ate_pairing"); - alt_bn128_ate_G1_precomp prec_P = alt_bn128_ate_precompute_G1(P); - alt_bn128_ate_G2_precomp prec_Q = alt_bn128_ate_precompute_G2(Q); - alt_bn128_Fq12 result = alt_bn128_ate_miller_loop(prec_P, prec_Q); - leave_block("Call to alt_bn128_ate_pairing"); - return result; -} - -alt_bn128_GT alt_bn128_ate_reduced_pairing(const alt_bn128_G1 &P, const alt_bn128_G2 &Q) -{ - enter_block("Call to alt_bn128_ate_reduced_pairing"); - const alt_bn128_Fq12 f = alt_bn128_ate_pairing(P, Q); - const alt_bn128_GT result = alt_bn128_final_exponentiation(f); - leave_block("Call to alt_bn128_ate_reduced_pairing"); - return result; -} - -/* choice of pairing */ - -alt_bn128_G1_precomp alt_bn128_precompute_G1(const alt_bn128_G1& P) -{ - return alt_bn128_ate_precompute_G1(P); -} - -alt_bn128_G2_precomp alt_bn128_precompute_G2(const alt_bn128_G2& Q) -{ - return alt_bn128_ate_precompute_G2(Q); -} - -alt_bn128_Fq12 alt_bn128_miller_loop(const alt_bn128_G1_precomp &prec_P, - const alt_bn128_G2_precomp &prec_Q) -{ - return alt_bn128_ate_miller_loop(prec_P, prec_Q); -} - -alt_bn128_Fq12 alt_bn128_double_miller_loop(const alt_bn128_G1_precomp &prec_P1, - const alt_bn128_G2_precomp &prec_Q1, - const alt_bn128_G1_precomp &prec_P2, - const alt_bn128_G2_precomp &prec_Q2) -{ - return alt_bn128_ate_double_miller_loop(prec_P1, prec_Q1, prec_P2, prec_Q2); -} - -alt_bn128_Fq12 alt_bn128_pairing(const alt_bn128_G1& P, - const alt_bn128_G2 &Q) -{ - return alt_bn128_ate_pairing(P, Q); -} - -alt_bn128_GT alt_bn128_reduced_pairing(const alt_bn128_G1 &P, - const alt_bn128_G2 &Q) -{ - return alt_bn128_ate_reduced_pairing(P, Q); -} -} // libsnark diff --git a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pairing.hpp b/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pairing.hpp deleted file mode 100644 index 15d325485..000000000 --- a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pairing.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef ALT_BN128_PAIRING_HPP_ -#define ALT_BN128_PAIRING_HPP_ -#include -#include "algebra/curves/alt_bn128/alt_bn128_init.hpp" - -namespace libsnark { - -/* final exponentiation */ - -alt_bn128_GT alt_bn128_final_exponentiation(const alt_bn128_Fq12 &elt); - -/* ate pairing */ - -struct alt_bn128_ate_G1_precomp { - alt_bn128_Fq PX; - alt_bn128_Fq PY; - - bool operator==(const alt_bn128_ate_G1_precomp &other) const; - friend std::ostream& operator<<(std::ostream &out, const alt_bn128_ate_G1_precomp &prec_P); - friend std::istream& operator>>(std::istream &in, alt_bn128_ate_G1_precomp &prec_P); -}; - -struct alt_bn128_ate_ell_coeffs { - alt_bn128_Fq2 ell_0; - alt_bn128_Fq2 ell_VW; - alt_bn128_Fq2 ell_VV; - - bool operator==(const alt_bn128_ate_ell_coeffs &other) const; - friend std::ostream& operator<<(std::ostream &out, const alt_bn128_ate_ell_coeffs &dc); - friend std::istream& operator>>(std::istream &in, alt_bn128_ate_ell_coeffs &dc); -}; - -struct alt_bn128_ate_G2_precomp { - alt_bn128_Fq2 QX; - alt_bn128_Fq2 QY; - std::vector coeffs; - - bool operator==(const alt_bn128_ate_G2_precomp &other) const; - friend std::ostream& operator<<(std::ostream &out, const alt_bn128_ate_G2_precomp &prec_Q); - friend std::istream& operator>>(std::istream &in, alt_bn128_ate_G2_precomp &prec_Q); -}; - -alt_bn128_ate_G1_precomp alt_bn128_ate_precompute_G1(const alt_bn128_G1& P); -alt_bn128_ate_G2_precomp alt_bn128_ate_precompute_G2(const alt_bn128_G2& Q); - -alt_bn128_Fq12 alt_bn128_ate_miller_loop(const alt_bn128_ate_G1_precomp &prec_P, - const alt_bn128_ate_G2_precomp &prec_Q); -alt_bn128_Fq12 alt_bn128_ate_double_miller_loop(const alt_bn128_ate_G1_precomp &prec_P1, - const alt_bn128_ate_G2_precomp &prec_Q1, - const alt_bn128_ate_G1_precomp &prec_P2, - const alt_bn128_ate_G2_precomp &prec_Q2); - -alt_bn128_Fq12 alt_bn128_ate_pairing(const alt_bn128_G1& P, - const alt_bn128_G2 &Q); -alt_bn128_GT alt_bn128_ate_reduced_pairing(const alt_bn128_G1 &P, - const alt_bn128_G2 &Q); - -/* choice of pairing */ - -typedef alt_bn128_ate_G1_precomp alt_bn128_G1_precomp; -typedef alt_bn128_ate_G2_precomp alt_bn128_G2_precomp; - -alt_bn128_G1_precomp alt_bn128_precompute_G1(const alt_bn128_G1& P); - -alt_bn128_G2_precomp alt_bn128_precompute_G2(const alt_bn128_G2& Q); - -alt_bn128_Fq12 alt_bn128_miller_loop(const alt_bn128_G1_precomp &prec_P, - const alt_bn128_G2_precomp &prec_Q); - -alt_bn128_Fq12 alt_bn128_double_miller_loop(const alt_bn128_G1_precomp &prec_P1, - const alt_bn128_G2_precomp &prec_Q1, - const alt_bn128_G1_precomp &prec_P2, - const alt_bn128_G2_precomp &prec_Q2); - -alt_bn128_Fq12 alt_bn128_pairing(const alt_bn128_G1& P, - const alt_bn128_G2 &Q); - -alt_bn128_GT alt_bn128_reduced_pairing(const alt_bn128_G1 &P, - const alt_bn128_G2 &Q); - -alt_bn128_GT alt_bn128_affine_reduced_pairing(const alt_bn128_G1 &P, - const alt_bn128_G2 &Q); - -} // libsnark -#endif // ALT_BN128_PAIRING_HPP_ diff --git a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pp.cpp b/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pp.cpp deleted file mode 100644 index 25ea924d8..000000000 --- a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pp.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#include "algebra/curves/alt_bn128/alt_bn128_pp.hpp" - -namespace libsnark { - -void alt_bn128_pp::init_public_params() -{ - init_alt_bn128_params(); -} - -alt_bn128_GT alt_bn128_pp::final_exponentiation(const alt_bn128_Fq12 &elt) -{ - return alt_bn128_final_exponentiation(elt); -} - -alt_bn128_G1_precomp alt_bn128_pp::precompute_G1(const alt_bn128_G1 &P) -{ - return alt_bn128_precompute_G1(P); -} - -alt_bn128_G2_precomp alt_bn128_pp::precompute_G2(const alt_bn128_G2 &Q) -{ - return alt_bn128_precompute_G2(Q); -} - -alt_bn128_Fq12 alt_bn128_pp::miller_loop(const alt_bn128_G1_precomp &prec_P, - const alt_bn128_G2_precomp &prec_Q) -{ - return alt_bn128_miller_loop(prec_P, prec_Q); -} - -alt_bn128_Fq12 alt_bn128_pp::double_miller_loop(const alt_bn128_G1_precomp &prec_P1, - const alt_bn128_G2_precomp &prec_Q1, - const alt_bn128_G1_precomp &prec_P2, - const alt_bn128_G2_precomp &prec_Q2) -{ - return alt_bn128_double_miller_loop(prec_P1, prec_Q1, prec_P2, prec_Q2); -} - -alt_bn128_Fq12 alt_bn128_pp::pairing(const alt_bn128_G1 &P, - const alt_bn128_G2 &Q) -{ - return alt_bn128_pairing(P, Q); -} - -alt_bn128_Fq12 alt_bn128_pp::reduced_pairing(const alt_bn128_G1 &P, - const alt_bn128_G2 &Q) -{ - return alt_bn128_reduced_pairing(P, Q); -} - -} // libsnark diff --git a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pp.hpp b/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pp.hpp deleted file mode 100644 index ec8059dcb..000000000 --- a/src/snark/libsnark/algebra/curves/alt_bn128/alt_bn128_pp.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/** @file -***************************************************************************** -* @author This file is part of libsnark, developed by SCIPR Lab -* and contributors (see AUTHORS). -* @copyright MIT license (see LICENSE file) -*****************************************************************************/ - -#ifndef ALT_BN128_PP_HPP_ -#define ALT_BN128_PP_HPP_ -#include "algebra/curves/public_params.hpp" -#include "algebra/curves/alt_bn128/alt_bn128_init.hpp" -#include "algebra/curves/alt_bn128/alt_bn128_g1.hpp" -#include "algebra/curves/alt_bn128/alt_bn128_g2.hpp" -#include "algebra/curves/alt_bn128/alt_bn128_pairing.hpp" - -namespace libsnark { - -class alt_bn128_pp { -public: - typedef alt_bn128_Fr Fp_type; - typedef alt_bn128_G1 G1_type; - typedef alt_bn128_G2 G2_type; - typedef alt_bn128_G1_precomp G1_precomp_type; - typedef alt_bn128_G2_precomp G2_precomp_type; - typedef alt_bn128_Fq Fq_type; - typedef alt_bn128_Fq2 Fqe_type; - typedef alt_bn128_Fq12 Fqk_type; - typedef alt_bn128_GT GT_type; - - static const bool has_affine_pairing = false; - - static void init_public_params(); - static alt_bn128_GT final_exponentiation(const alt_bn128_Fq12 &elt); - static alt_bn128_G1_precomp precompute_G1(const alt_bn128_G1 &P); - static alt_bn128_G2_precomp precompute_G2(const alt_bn128_G2 &Q); - static alt_bn128_Fq12 miller_loop(const alt_bn128_G1_precomp &prec_P, - const alt_bn128_G2_precomp &prec_Q); - static alt_bn128_Fq12 double_miller_loop(const alt_bn128_G1_precomp &prec_P1, - const alt_bn128_G2_precomp &prec_Q1, - const alt_bn128_G1_precomp &prec_P2, - const alt_bn128_G2_precomp &prec_Q2); - static alt_bn128_Fq12 pairing(const alt_bn128_G1 &P, - const alt_bn128_G2 &Q); - static alt_bn128_Fq12 reduced_pairing(const alt_bn128_G1 &P, - const alt_bn128_G2 &Q); -}; - -} // libsnark - -#endif // ALT_BN128_PP_HPP_ diff --git a/src/snark/libsnark/algebra/curves/curve_utils.hpp b/src/snark/libsnark/algebra/curves/curve_utils.hpp deleted file mode 100644 index 33a8e1e17..000000000 --- a/src/snark/libsnark/algebra/curves/curve_utils.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef CURVE_UTILS_HPP_ -#define CURVE_UTILS_HPP_ -#include - -#include "algebra/fields/bigint.hpp" - -namespace libsnark { - -template -GroupT scalar_mul(const GroupT &base, const bigint &scalar); - -} // libsnark -#include "algebra/curves/curve_utils.tcc" - -#endif // CURVE_UTILS_HPP_ diff --git a/src/snark/libsnark/algebra/curves/curve_utils.tcc b/src/snark/libsnark/algebra/curves/curve_utils.tcc deleted file mode 100644 index 38140cd48..000000000 --- a/src/snark/libsnark/algebra/curves/curve_utils.tcc +++ /dev/null @@ -1,37 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef CURVE_UTILS_TCC_ -#define CURVE_UTILS_TCC_ - -namespace libsnark { - -template -GroupT scalar_mul(const GroupT &base, const bigint &scalar) -{ - GroupT result = GroupT::zero(); - - bool found_one = false; - for (int64_t i = scalar.max_bits() - 1; i >= 0; --i) - { - if (found_one) - { - result = result.dbl(); - } - - if (scalar.test_bit(i)) - { - found_one = true; - result = result + base; - } - } - - return result; -} - -} // libsnark -#endif // CURVE_UTILS_TCC_ diff --git a/src/snark/libsnark/algebra/curves/public_params.hpp b/src/snark/libsnark/algebra/curves/public_params.hpp deleted file mode 100644 index 07e047560..000000000 --- a/src/snark/libsnark/algebra/curves/public_params.hpp +++ /dev/null @@ -1,103 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef PUBLIC_PARAMS_HPP_ -#define PUBLIC_PARAMS_HPP_ -#include - -namespace libsnark { - -/* - for every curve the user should define corresponding - public_params with the following typedefs: - - Fp_type - G1_type - G2_type - G1_precomp_type - G2_precomp_type - affine_ate_G1_precomp_type - affine_ate_G2_precomp_type - Fq_type - Fqe_type - Fqk_type - GT_type - - one should also define the following static methods: - - void init_public_params(); - - GT final_exponentiation(const Fqk &elt); - - G1_precomp precompute_G1(const G1 &P); - G2_precomp precompute_G2(const G2 &Q); - - Fqk miller_loop(const G1_precomp &prec_P, - const G2_precomp &prec_Q); - - affine_ate_G1_precomp affine_ate_precompute_G1(const G1 &P); - affine_ate_G2_precomp affine_ate_precompute_G2(const G2 &Q); - - - Fqk affine_ate_miller_loop(const affine_ate_G1_precomp &prec_P, - const affine_ate_G2_precomp &prec_Q); - Fqk affine_ate_e_over_e_miller_loop(const affine_ate_G1_precomp &prec_P1, - const affine_ate_G2_precomp &prec_Q1, - const affine_ate_G1_precomp &prec_P2, - const affine_ate_G2_precomp &prec_Q2); - Fqk affine_ate_e_times_e_over_e_miller_loop(const affine_ate_G1_precomp &prec_P1, - const affine_ate_G2_precomp &prec_Q1, - const affine_ate_G1_precomp &prec_P2, - const affine_ate_G2_precomp &prec_Q2, - const affine_ate_G1_precomp &prec_P3, - const affine_ate_G2_precomp &prec_Q3); - Fqk double_miller_loop(const G1_precomp &prec_P1, - const G2_precomp &prec_Q1, - const G1_precomp &prec_P2, - const G2_precomp &prec_Q2); - - Fqk pairing(const G1 &P, - const G2 &Q); - GT reduced_pairing(const G1 &P, - const G2 &Q); - GT affine_reduced_pairing(const G1 &P, - const G2 &Q); -*/ - -template -using Fr = typename EC_ppT::Fp_type; -template -using G1 = typename EC_ppT::G1_type; -template -using G2 = typename EC_ppT::G2_type; -template -using G1_precomp = typename EC_ppT::G1_precomp_type; -template -using G2_precomp = typename EC_ppT::G2_precomp_type; -template -using affine_ate_G1_precomp = typename EC_ppT::affine_ate_G1_precomp_type; -template -using affine_ate_G2_precomp = typename EC_ppT::affine_ate_G2_precomp_type; -template -using Fq = typename EC_ppT::Fq_type; -template -using Fqe = typename EC_ppT::Fqe_type; -template -using Fqk = typename EC_ppT::Fqk_type; -template -using GT = typename EC_ppT::GT_type; - -template -using Fr_vector = std::vector >; -template -using G1_vector = std::vector >; -template -using G2_vector = std::vector >; - -} // libsnark - -#endif // PUBLIC_PARAMS_HPP_ diff --git a/src/snark/libsnark/algebra/curves/tests/test_bilinearity.cpp b/src/snark/libsnark/algebra/curves/tests/test_bilinearity.cpp deleted file mode 100644 index fe6593bae..000000000 --- a/src/snark/libsnark/algebra/curves/tests/test_bilinearity.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ -#include "common/profiling.hpp" -#ifdef CURVE_BN128 -#include "algebra/curves/bn128/bn128_pp.hpp" -#endif -#include "algebra/curves/alt_bn128/alt_bn128_pp.hpp" - -#include - -using namespace libsnark; - -template -void pairing_test() -{ - GT GT_one = GT::one(); - - printf("Running bilinearity tests:\n"); - G1 P = (Fr::random_element()) * G1::one(); - //G1 P = Fr("2") * G1::one(); - G2 Q = (Fr::random_element()) * G2::one(); - //G2 Q = Fr("3") * G2::one(); - - printf("P:\n"); - P.print(); - P.print_coordinates(); - printf("Q:\n"); - Q.print(); - Q.print_coordinates(); - printf("\n\n"); - - Fr s = Fr::random_element(); - //Fr s = Fr("2"); - G1 sP = s * P; - G2 sQ = s * Q; - - printf("Pairing bilinearity tests (three must match):\n"); - GT ans1 = ppT::reduced_pairing(sP, Q); - GT ans2 = ppT::reduced_pairing(P, sQ); - GT ans3 = ppT::reduced_pairing(P, Q)^s; - ans1.print(); - ans2.print(); - ans3.print(); - EXPECT_EQ(ans1, ans2); - EXPECT_EQ(ans2, ans3); - - EXPECT_NE(ans1, GT_one); - EXPECT_EQ((ans1^Fr::field_char()), GT_one); - printf("\n\n"); -} - -template -void double_miller_loop_test() -{ - const G1 P1 = (Fr::random_element()) * G1::one(); - const G1 P2 = (Fr::random_element()) * G1::one(); - const G2 Q1 = (Fr::random_element()) * G2::one(); - const G2 Q2 = (Fr::random_element()) * G2::one(); - - const G1_precomp prec_P1 = ppT::precompute_G1(P1); - const G1_precomp prec_P2 = ppT::precompute_G1(P2); - const G2_precomp prec_Q1 = ppT::precompute_G2(Q1); - const G2_precomp prec_Q2 = ppT::precompute_G2(Q2); - - const Fqk ans_1 = ppT::miller_loop(prec_P1, prec_Q1); - const Fqk ans_2 = ppT::miller_loop(prec_P2, prec_Q2); - const Fqk ans_12 = ppT::double_miller_loop(prec_P1, prec_Q1, prec_P2, prec_Q2); - EXPECT_EQ(ans_1 * ans_2, ans_12); -} - -template -void affine_pairing_test() -{ - GT GT_one = GT::one(); - - printf("Running bilinearity tests:\n"); - G1 P = (Fr::random_element()) * G1::one(); - G2 Q = (Fr::random_element()) * G2::one(); - - printf("P:\n"); - P.print(); - printf("Q:\n"); - Q.print(); - printf("\n\n"); - - Fr s = Fr::random_element(); - G1 sP = s * P; - G2 sQ = s * Q; - - printf("Pairing bilinearity tests (three must match):\n"); - GT ans1 = ppT::affine_reduced_pairing(sP, Q); - GT ans2 = ppT::affine_reduced_pairing(P, sQ); - GT ans3 = ppT::affine_reduced_pairing(P, Q)^s; - ans1.print(); - ans2.print(); - ans3.print(); - EXPECT_EQ(ans1, ans2); - EXPECT_EQ(ans2, ans3); - - EXPECT_NE(ans1, GT_one); - EXPECT_EQ((ans1^Fr::field_char()), GT_one); - printf("\n\n"); -} - -TEST(algebra, bilinearity) -{ - start_profiling(); - alt_bn128_pp::init_public_params(); - pairing_test(); - double_miller_loop_test(); - -#ifdef CURVE_BN128 // BN128 has fancy dependencies so it may be disabled - bn128_pp::init_public_params(); - pairing_test(); - double_miller_loop_test(); -#endif -} diff --git a/src/snark/libsnark/algebra/curves/tests/test_groups.cpp b/src/snark/libsnark/algebra/curves/tests/test_groups.cpp deleted file mode 100644 index 7bb7c31cc..000000000 --- a/src/snark/libsnark/algebra/curves/tests/test_groups.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ -#include "common/profiling.hpp" -#ifdef CURVE_BN128 -#include "algebra/curves/bn128/bn128_pp.hpp" -#endif -#include "algebra/curves/alt_bn128/alt_bn128_pp.hpp" -#include - -#include - -using namespace libsnark; - -template -void test_mixed_add() -{ - GroupT base, el, result; - - base = GroupT::zero(); - el = GroupT::zero(); - el.to_special(); - result = base.mixed_add(el); - EXPECT_EQ(result, base + el); - - base = GroupT::zero(); - el = GroupT::random_element(); - el.to_special(); - result = base.mixed_add(el); - EXPECT_EQ(result, base + el); - - base = GroupT::random_element(); - el = GroupT::zero(); - el.to_special(); - result = base.mixed_add(el); - EXPECT_EQ(result, base + el); - - base = GroupT::random_element(); - el = GroupT::random_element(); - el.to_special(); - result = base.mixed_add(el); - EXPECT_EQ(result, base + el); - - base = GroupT::random_element(); - el = base; - el.to_special(); - result = base.mixed_add(el); - EXPECT_EQ(result, base.dbl()); -} - -template -void test_group() -{ - bigint<1> rand1 = bigint<1>("76749407"); - bigint<1> rand2 = bigint<1>("44410867"); - bigint<1> randsum = bigint<1>("121160274"); - - GroupT zero = GroupT::zero(); - EXPECT_EQ(zero, zero); - GroupT one = GroupT::one(); - EXPECT_EQ(one, one); - GroupT two = bigint<1>(2l) * GroupT::one(); - EXPECT_EQ(two, two); - GroupT five = bigint<1>(5l) * GroupT::one(); - - GroupT three = bigint<1>(3l) * GroupT::one(); - GroupT four = bigint<1>(4l) * GroupT::one(); - - EXPECT_EQ(two+five, three+four); - - GroupT a = GroupT::random_element(); - GroupT b = GroupT::random_element(); - - EXPECT_NE(one, zero); - EXPECT_NE(a, zero); - EXPECT_NE(a, one); - - EXPECT_NE(b, zero); - EXPECT_NE(b, one); - - EXPECT_EQ(a.dbl(), a + a); - EXPECT_EQ(b.dbl(), b + b); - EXPECT_EQ(one.add(two), three); - EXPECT_EQ(two.add(one), three); - EXPECT_EQ(a + b, b + a); - EXPECT_EQ(a - a, zero); - EXPECT_EQ(a - b, a + (-b)); - EXPECT_EQ(a - b, (-b) + a); - - // handle special cases - EXPECT_EQ(zero + (-a), -a); - EXPECT_EQ(zero - a, -a); - EXPECT_EQ(a - zero, a); - EXPECT_EQ(a + zero, a); - EXPECT_EQ(zero + a, a); - - EXPECT_EQ((a + b).dbl(), (a + b) + (b + a)); - EXPECT_EQ(bigint<1>("2") * (a + b), (a + b) + (b + a)); - - EXPECT_EQ((rand1 * a) + (rand2 * a), (randsum * a)); - - EXPECT_EQ(GroupT::order() * a, zero); - EXPECT_EQ(GroupT::order() * one, zero); - EXPECT_NE((GroupT::order() * a) - a, zero); - EXPECT_NE((GroupT::order() * one) - one, zero); - - test_mixed_add(); -} - -template -void test_mul_by_q() -{ - GroupT a = GroupT::random_element(); - EXPECT_EQ((GroupT::base_field_char()*a), a.mul_by_q()); -} - -template -void test_output() -{ - GroupT g = GroupT::zero(); - - for (size_t i = 0; i < 1000; ++i) - { - std::stringstream ss; - ss << g; - GroupT gg; - ss >> gg; - EXPECT_EQ(g, gg); - /* use a random point in next iteration */ - g = GroupT::random_element(); - } -} - -TEST(algebra, groups) -{ - alt_bn128_pp::init_public_params(); - test_group >(); - test_output >(); - test_group >(); - test_output >(); - test_mul_by_q >(); - -#ifdef CURVE_BN128 // BN128 has fancy dependencies so it may be disabled - bn128_pp::init_public_params(); - test_group >(); - test_output >(); - test_group >(); - test_output >(); -#endif -} diff --git a/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain.hpp b/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain.hpp deleted file mode 100644 index 3e127a063..000000000 --- a/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for the "basic radix-2" evaluation domain. - - Roughly, the domain has size m = 2^k and consists of the m-th roots of unity. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef BASIC_RADIX2_DOMAIN_HPP_ -#define BASIC_RADIX2_DOMAIN_HPP_ - -#include "algebra/evaluation_domain/evaluation_domain.hpp" - -namespace libsnark { - -template -class basic_radix2_domain : public evaluation_domain { -public: - - FieldT omega; - - basic_radix2_domain(const size_t m); - - void FFT(std::vector &a); - void iFFT(std::vector &a); - void cosetFFT(std::vector &a, const FieldT &g); - void icosetFFT(std::vector &a, const FieldT &g); - std::vector lagrange_coeffs(const FieldT &t); - FieldT get_element(const size_t idx); - FieldT compute_Z(const FieldT &t); - void add_poly_Z(const FieldT &coeff, std::vector &H); - void divide_by_Z_on_coset(std::vector &P); - -}; - -} // libsnark - -#include "algebra/evaluation_domain/domains/basic_radix2_domain.tcc" - -#endif // BASIC_RADIX2_DOMAIN_HPP_ diff --git a/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain.tcc b/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain.tcc deleted file mode 100644 index d315e8319..000000000 --- a/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain.tcc +++ /dev/null @@ -1,112 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for the "basic radix-2" evaluation domain. - - See basic_radix2_domain.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef BASIC_RADIX2_DOMAIN_TCC_ -#define BASIC_RADIX2_DOMAIN_TCC_ - -#include "algebra/evaluation_domain/domains/basic_radix2_domain_aux.hpp" - -namespace libsnark { - -template -basic_radix2_domain::basic_radix2_domain(const size_t m) : evaluation_domain(m) -{ - assert(m > 1); - const size_t logm = log2(m); - assert(logm <= (FieldT::s)); - - omega = get_root_of_unity(m); -} - -template -void basic_radix2_domain::FFT(std::vector &a) -{ - enter_block("Execute FFT"); - assert(a.size() == this->m); - _basic_radix2_FFT(a, omega); - leave_block("Execute FFT"); -} - -template -void basic_radix2_domain::iFFT(std::vector &a) -{ - enter_block("Execute inverse FFT"); - assert(a.size() == this->m); - _basic_radix2_FFT(a, omega.inverse()); - - const FieldT sconst = FieldT(a.size()).inverse(); - for (size_t i = 0; i < a.size(); ++i) - { - a[i] *= sconst; - } - leave_block("Execute inverse FFT"); -} - -template -void basic_radix2_domain::cosetFFT(std::vector &a, const FieldT &g) -{ - enter_block("Execute coset FFT"); - _multiply_by_coset(a, g); - FFT(a); - leave_block("Execute coset FFT"); -} - -template -void basic_radix2_domain::icosetFFT(std::vector &a, const FieldT &g) -{ - enter_block("Execute inverse coset IFFT"); - iFFT(a); - _multiply_by_coset(a, g.inverse()); - leave_block("Execute inverse coset IFFT"); -} - -template -std::vector basic_radix2_domain::lagrange_coeffs(const FieldT &t) -{ - return _basic_radix2_lagrange_coeffs(this->m, t); -} - -template -FieldT basic_radix2_domain::get_element(const size_t idx) -{ - return omega^idx; -} - -template -FieldT basic_radix2_domain::compute_Z(const FieldT &t) -{ - return (t^this->m) - FieldT::one(); -} - -template -void basic_radix2_domain::add_poly_Z(const FieldT &coeff, std::vector &H) -{ - assert(H.size() == this->m+1); - H[this->m] += coeff; - H[0] -= coeff; -} - -template -void basic_radix2_domain::divide_by_Z_on_coset(std::vector &P) -{ - const FieldT coset = FieldT::multiplicative_generator; - const FieldT Z_inverse_at_coset = this->compute_Z(coset).inverse(); - for (size_t i = 0; i < this->m; ++i) - { - P[i] *= Z_inverse_at_coset; - } -} - -} // libsnark - -#endif // BASIC_RADIX2_DOMAIN_TCC_ diff --git a/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain_aux.hpp b/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain_aux.hpp deleted file mode 100644 index c42ab2f6f..000000000 --- a/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain_aux.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for auxiliary functions for the "basic radix-2" evaluation domain. - - These functions compute the radix-2 FFT (in single- or multi-thread mode) and, - also compute Lagrange coefficients. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef BASIC_RADIX2_DOMAIN_AUX_HPP_ -#define BASIC_RADIX2_DOMAIN_AUX_HPP_ - -namespace libsnark { - -/** - * Compute the radix-2 FFT of the vector a over the set S={omega^{0},...,omega^{m-1}}. - */ -template -void _basic_radix2_FFT(std::vector &a, const FieldT &omega); - -/** - * A multi-thread version of _basic_radix2_FFT. - */ -template -void _parallel_basic_radix2_FFT(std::vector &a, const FieldT &omega); - -/** - * Translate the vector a to a coset defined by g. - */ -template -void _multiply_by_coset(std::vector &a, const FieldT &g); - -/** - * Compute the m Lagrange coefficients, relative to the set S={omega^{0},...,omega^{m-1}}, at the field element t. - */ -template -std::vector _basic_radix2_lagrange_coeffs(const size_t m, const FieldT &t); - -} // libsnark - -#include "algebra/evaluation_domain/domains/basic_radix2_domain_aux.tcc" - -#endif // BASIC_RADIX2_DOMAIN_AUX_HPP_ diff --git a/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain_aux.tcc b/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain_aux.tcc deleted file mode 100644 index 79f2ffec7..000000000 --- a/src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain_aux.tcc +++ /dev/null @@ -1,242 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for auxiliary functions for the "basic radix-2" evaluation domain. - - See basic_radix2_domain_aux.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef BASIC_RADIX2_DOMAIN_AUX_TCC_ -#define BASIC_RADIX2_DOMAIN_AUX_TCC_ - -#include -#ifdef MULTICORE -#include -#endif -#include "algebra/fields/field_utils.hpp" -#include "common/profiling.hpp" -#include "common/utils.hpp" - -namespace libsnark { - -#ifdef MULTICORE -#define _basic_radix2_FFT _basic_parallel_radix2_FFT -#else -#define _basic_radix2_FFT _basic_serial_radix2_FFT -#endif - -/* - Below we make use of pseudocode from [CLRS 2n Ed, pp. 864]. - Also, note that it's the caller's responsibility to multiply by 1/N. - */ -template -void _basic_serial_radix2_FFT(std::vector &a, const FieldT &omega) -{ - const size_t n = a.size(), logn = log2(n); - assert(n == (1u << logn)); - - /* swapping in place (from Storer's book) */ - for (size_t k = 0; k < n; ++k) - { - const size_t rk = bitreverse(k, logn); - if (k < rk) - std::swap(a[k], a[rk]); - } - - size_t m = 1; // invariant: m = 2^{s-1} - for (size_t s = 1; s <= logn; ++s) - { - // w_m is 2^s-th root of unity now - const FieldT w_m = omega^(n/(2*m)); - - asm volatile ("/* pre-inner */"); - for (size_t k = 0; k < n; k += 2*m) - { - FieldT w = FieldT::one(); - for (size_t j = 0; j < m; ++j) - { - const FieldT t = w * a[k+j+m]; - a[k+j+m] = a[k+j] - t; - a[k+j] += t; - w *= w_m; - } - } - asm volatile ("/* post-inner */"); - m *= 2; - } -} - -template -void _basic_parallel_radix2_FFT_inner(std::vector &a, const FieldT &omega, const size_t log_cpus) -{ - const size_t num_cpus = UINT64_C(1)< > tmp(num_cpus); - for (size_t j = 0; j < num_cpus; ++j) - { - tmp[j].resize(UINT64_C(1)<<(log_m-log_cpus), FieldT::zero()); - } - -#ifdef MULTICORE - #pragma omp parallel for -#endif - for (size_t j = 0; j < num_cpus; ++j) - { - const FieldT omega_j = omega^j; - const FieldT omega_step = omega^(j<<(log_m - log_cpus)); - - FieldT elt = FieldT::one(); - for (size_t i = 0; i < UINT64_C(1)<<(log_m - log_cpus); ++i) - { - for (size_t s = 0; s < num_cpus; ++s) - { - // invariant: elt is omega^(j*idx) - const size_t idx = (i + (s<<(log_m - log_cpus))) % (1u << log_m); - tmp[j][i] += a[idx] * elt; - elt *= omega_step; - } - elt *= omega_j; - } - } - leave_block("Shuffle inputs"); - - enter_block("Execute sub-FFTs"); - const FieldT omega_num_cpus = omega^num_cpus; - -#ifdef MULTICORE - #pragma omp parallel for -#endif - for (size_t j = 0; j < num_cpus; ++j) - { - _basic_serial_radix2_FFT(tmp[j], omega_num_cpus); - } - leave_block("Execute sub-FFTs"); - - enter_block("Re-shuffle outputs"); - -#ifdef MULTICORE - #pragma omp parallel for -#endif - for (size_t i = 0; i < num_cpus; ++i) - { - for (size_t j = 0; j < UINT64_C(1)<<(log_m - log_cpus); ++j) - { - // now: i = idx >> (log_m - log_cpus) and j = idx % (1u << (log_m - log_cpus)), for idx = ((i<<(log_m-log_cpus))+j) % (1u << log_m) - a[(j< -void _basic_parallel_radix2_FFT(std::vector &a, const FieldT &omega) -{ -#ifdef MULTICORE - const size_t num_cpus = omp_get_max_threads(); -#else - const size_t num_cpus = 1; -#endif - const size_t log_cpus = ((num_cpus & (num_cpus - 1)) == 0 ? log2(num_cpus) : log2(num_cpus) - 1); - -#ifdef DEBUG - print_indent(); printf("* Invoking parallel FFT on 2^%zu CPUs (omp_get_max_threads = %zu)\n", log_cpus, num_cpus); -#endif - - if (log_cpus == 0) - { - _basic_serial_radix2_FFT(a, omega); - } - else - { - _basic_parallel_radix2_FFT_inner(a, omega, log_cpus); - } -} - -template -void _multiply_by_coset(std::vector &a, const FieldT &g) -{ - //enter_block("Multiply by coset"); - FieldT u = g; - for (size_t i = 1; i < a.size(); ++i) - { - a[i] *= u; - u *= g; - } - //leave_block("Multiply by coset"); -} - -template -std::vector _basic_radix2_lagrange_coeffs(const size_t m, const FieldT &t) -{ - if (m == 1) - { - return std::vector(1, FieldT::one()); - } - - assert(m == (1u << log2(m))); - - const FieldT omega = get_root_of_unity(m); - - std::vector u(m, FieldT::zero()); - - /* - If t equals one of the roots of unity in S={omega^{0},...,omega^{m-1}} - then output 1 at the right place, and 0 elsewhere - */ - - if ((t^m) == (FieldT::one())) - { - FieldT omega_i = FieldT::one(); - for (size_t i = 0; i < m; ++i) - { - if (omega_i == t) // i.e., t equals omega^i - { - u[i] = FieldT::one(); - return u; - } - - omega_i *= omega; - } - } - - /* - Otherwise, if t does not equal any of the roots of unity in S, - then compute each L_{i,S}(t) as Z_{S}(t) * v_i / (t-\omega^i) - where: - - Z_{S}(t) = \prod_{j} (t-\omega^j) = (t^m-1), and - - v_{i} = 1 / \prod_{j \neq i} (\omega^i-\omega^j). - Below we use the fact that v_{0} = 1/m and v_{i+1} = \omega * v_{i}. - */ - - const FieldT Z = (t^m)-FieldT::one(); - FieldT l = Z * FieldT(m).inverse(); - FieldT r = FieldT::one(); - for (size_t i = 0; i < m; ++i) - { - u[i] = l * (t - r).inverse(); - l *= omega; - r *= omega; - } - - return u; -} - -} // libsnark - -#endif // BASIC_RADIX2_DOMAIN_AUX_TCC_ diff --git a/src/snark/libsnark/algebra/evaluation_domain/evaluation_domain.hpp b/src/snark/libsnark/algebra/evaluation_domain/evaluation_domain.hpp deleted file mode 100644 index d8d91ea68..000000000 --- a/src/snark/libsnark/algebra/evaluation_domain/evaluation_domain.hpp +++ /dev/null @@ -1,125 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for evaluation domains. - - Roughly, given a desired size m for the domain, the constructor selects - a choice of domain S with size ~m that has been selected so to optimize - - computations of Lagrange polynomials, and - - FFT/iFFT computations. - An evaluation domain also provides other functions, e.g., accessing - individual elements in S or evaluating its vanishing polynomial. - - The descriptions below make use of the definition of a *Lagrange polynomial*, - which we recall. Given a field F, a subset S=(a_i)_i of F, and an index idx - in {0,...,|S-1|}, the idx-th Lagrange polynomial (wrt to subset S) is defined to be - \f[ L_{idx,S}(z) := prod_{k \neq idx} (z - a_k) / prod_{k \neq idx} (a_{idx} - a_k) \f] - Note that, by construction: - \f[ \forall j \neq idx: L_{idx,S}(a_{idx}) = 1 \text{ and } L_{idx,S}(a_j) = 0 \f] - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef EVALUATION_DOMAIN_HPP_ -#define EVALUATION_DOMAIN_HPP_ - -#include - -namespace libsnark { - -/** - * An evaluation domain. - */ -template -class evaluation_domain { -public: - - const size_t m; - - /** - * Construct an evaluation domain S of size m, if possible. - * - * (See the function get_evaluation_domain below.) - */ - evaluation_domain(const size_t m) : m(m) {}; - - /** - * Get the idx-th element in S. - */ - virtual FieldT get_element(const size_t idx) = 0; - - /** - * Compute the FFT, over the domain S, of the vector a. - */ - virtual void FFT(std::vector &a) = 0; - - /** - * Compute the inverse FFT, over the domain S, of the vector a. - */ - virtual void iFFT(std::vector &a) = 0; - - /** - * Compute the FFT, over the domain g*S, of the vector a. - */ - virtual void cosetFFT(std::vector &a, const FieldT &g) = 0; - - /** - * Compute the inverse FFT, over the domain g*S, of the vector a. - */ - virtual void icosetFFT(std::vector &a, const FieldT &g) = 0; - - /** - * Evaluate all Lagrange polynomials. - * - * The inputs are: - * - an integer m - * - an element t - * The output is a vector (b_{0},...,b_{m-1}) - * where b_{i} is the evaluation of L_{i,S}(z) at z = t. - */ - virtual std::vector lagrange_coeffs(const FieldT &t) = 0; - - /** - * Evaluate the vanishing polynomial of S at the field element t. - */ - virtual FieldT compute_Z(const FieldT &t) = 0; - - /** - * Add the coefficients of the vanishing polynomial of S to the coefficients of the polynomial H. - */ - virtual void add_poly_Z(const FieldT &coeff, std::vector &H) = 0; - - /** - * Multiply by the evaluation, on a coset of S, of the inverse of the vanishing polynomial of S. - */ - virtual void divide_by_Z_on_coset(std::vector &P) = 0; -}; - -/** - * Return an evaluation domain object in which the domain S has size |S| >= min_size. - * The function chooses from different supported domains, depending on min_size. - */ -template -std::shared_ptr > get_evaluation_domain(const size_t min_size); - -/** - * Naive evaluation of a *single* Lagrange polynomial, used for testing purposes. - * - * The inputs are: - * - an integer m - * - a domain S = (a_{0},...,a_{m-1}) of size m - * - a field element t - * - an index idx in {0,...,m-1} - * The output is the polynomial L_{idx,S}(z) evaluated at z = t. - */ -template -FieldT lagrange_eval(const size_t m, const std::vector &domain, const FieldT &t, const size_t idx); - -} // libsnark - -#include "algebra/evaluation_domain/evaluation_domain.tcc" - -#endif // EVALUATION_DOMAIN_HPP_ diff --git a/src/snark/libsnark/algebra/evaluation_domain/evaluation_domain.tcc b/src/snark/libsnark/algebra/evaluation_domain/evaluation_domain.tcc deleted file mode 100644 index ec58ad87c..000000000 --- a/src/snark/libsnark/algebra/evaluation_domain/evaluation_domain.tcc +++ /dev/null @@ -1,117 +0,0 @@ -/** @file - ***************************************************************************** - - Imeplementation of interfaces for evaluation domains. - - See evaluation_domain.hpp . - - We currently implement, and select among, three types of domains: - - "basic radix-2": the domain has size m = 2^k and consists of the m-th roots of unity - - "extended radix-2": the domain has size m = 2^{k+1} and consists of "the m-th roots of unity" union "a coset" - - "step radix-2": the domain has size m = 2^k + 2^r and consists of "the 2^k-th roots of unity" union "a coset of 2^r-th roots of unity" - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef EVALUATION_DOMAIN_TCC_ -#define EVALUATION_DOMAIN_TCC_ - -#include -#include "algebra/fields/field_utils.hpp" -#include "algebra/evaluation_domain/domains/basic_radix2_domain.hpp" - -namespace libsnark { - -template -std::shared_ptr > get_evaluation_domain(const size_t min_size) -{ - assert(min_size > 1); - const size_t log_min_size = log2(min_size); - assert(log_min_size <= (FieldT::s+1)); - - std::shared_ptr > result; - if (min_size == (1u << log_min_size)) - { - if (log_min_size == FieldT::s+1) - { - if (!inhibit_profiling_info) - { - print_indent(); printf("* Selected domain: extended_radix2\n"); - } - assert(0); - } - else - { - if (!inhibit_profiling_info) - { - print_indent(); printf("* Selected domain: basic_radix2\n"); - } - result.reset(new basic_radix2_domain(min_size)); - } - } - else - { - const size_t big = UINT64_C(1)<<(log2(min_size)-1); - const size_t small = min_size - big; - const size_t rounded_small = (UINT64_C(1)<(big + rounded_small)); - } - else - { - if (!inhibit_profiling_info) - { - print_indent(); printf("* Selected domain: extended_radix2\n"); - } - assert(0); - } - } - else - { - if (!inhibit_profiling_info) - { - print_indent(); printf("* Selected domain: step_radix2\n"); - } - assert(0); - } - } - - return result; -} - -template -FieldT lagrange_eval(const size_t m, const std::vector &domain, const FieldT &t, const size_t idx) -{ - assert(m == domain.size()); - assert(idx < m); - - FieldT num = FieldT::one(); - FieldT denom = FieldT::one(); - - for (size_t k = 0; k < m; ++k) - { - if (k == idx) - { - continue; - } - - num *= t - domain[k]; - denom *= domain[idx] - domain[k]; - } - - return num * denom.inverse(); -} - -} // libsnark - -#endif // EVALUATION_DOMAIN_TCC_ diff --git a/src/snark/libsnark/algebra/exponentiation/exponentiation.hpp b/src/snark/libsnark/algebra/exponentiation/exponentiation.hpp deleted file mode 100644 index 836ebf002..000000000 --- a/src/snark/libsnark/algebra/exponentiation/exponentiation.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for (square-and-multiply) exponentiation. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef EXPONENTIATION_HPP_ -#define EXPONENTIATION_HPP_ - -#include - -#include "algebra/fields/bigint.hpp" - -namespace libsnark { - -template -FieldT power(const FieldT &base, const bigint &exponent); - -template -FieldT power(const FieldT &base, const uint64_t exponent); - -} // libsnark - -#include "algebra/exponentiation/exponentiation.tcc" - -#endif // EXPONENTIATION_HPP_ diff --git a/src/snark/libsnark/algebra/exponentiation/exponentiation.tcc b/src/snark/libsnark/algebra/exponentiation/exponentiation.tcc deleted file mode 100644 index 7ac3bf5d3..000000000 --- a/src/snark/libsnark/algebra/exponentiation/exponentiation.tcc +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for (square-and-multiply) exponentiation. - - See exponentiation.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef EXPONENTIATION_TCC_ -#define EXPONENTIATION_TCC_ - -#include "common/utils.hpp" - -namespace libsnark { - -template -FieldT power(const FieldT &base, const bigint &exponent) -{ - FieldT result = FieldT::one(); - - bool found_one = false; - - for (int64_t i = exponent.max_bits() - 1; i >= 0; --i) - { - if (found_one) - { - result = result * result; - } - - if (exponent.test_bit(i)) - { - found_one = true; - result = result * base; - } - } - - return result; -} - -template -FieldT power(const FieldT &base, const uint64_t exponent) -{ - return power(base, bigint<1>(exponent)); -} - -} // libsnark - -#endif // EXPONENTIATION_TCC_ diff --git a/src/snark/libsnark/algebra/fields/bigint.hpp b/src/snark/libsnark/algebra/fields/bigint.hpp deleted file mode 100644 index d17e9a7bb..000000000 --- a/src/snark/libsnark/algebra/fields/bigint.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/** @file - ***************************************************************************** - Declaration of bigint wrapper class around GMP's MPZ long integers. - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef BIGINT_HPP_ -#define BIGINT_HPP_ -#include -#include -#include -#include "common/serialization.hpp" - -namespace libsnark { - -template class bigint; -template std::ostream& operator<<(std::ostream &, const bigint&); -template std::istream& operator>>(std::istream &, bigint&); - -/** - * Wrapper class around GMP's MPZ long integers. It supports arithmetic operations, - * serialization and randomization. Serialization is fragile, see common/serialization.hpp. - */ - -template -class bigint { -public: - static const mp_size_t N = n; - - mp_limb_t data[n] = {0}; - - bigint() = default; - bigint(const uint64_t x); /// Initalize from a small integer - bigint(const char* s); /// Initialize from a string containing an integer in decimal notation - bigint(const mpz_t r); /// Initialize from MPZ element - - void print() const; - void print_hex() const; - bool operator==(const bigint& other) const; - bool operator!=(const bigint& other) const; - void clear(); - bool is_zero() const; - size_t max_bits() const { return n * GMP_NUMB_BITS; } - size_t num_bits() const; - - uint64_t as_uint64() const; /* return the last limb of the integer */ - void to_mpz(mpz_t r) const; - bool test_bit(const std::size_t bitno) const; - - template inline void operator+=(const bigint& other); - template inline bigint operator*(const bigint& other) const; - template static inline void div_qr(bigint& quotient, bigint& remainder, - const bigint& dividend, const bigint& divisor); - template inline bigint shorten(const bigint& q, const char *msg) const; - - inline void limit(const bigint& q, const char *msg) const; - bool operator>(const bigint& other) const; - - bigint& randomize(); - - friend std::ostream& operator<< (std::ostream &out, const bigint &b); - friend std::istream& operator>> (std::istream &in, bigint &b); -}; - -} // libsnark -#include "algebra/fields/bigint.tcc" -#endif diff --git a/src/snark/libsnark/algebra/fields/bigint.tcc b/src/snark/libsnark/algebra/fields/bigint.tcc deleted file mode 100644 index 7a59233d4..000000000 --- a/src/snark/libsnark/algebra/fields/bigint.tcc +++ /dev/null @@ -1,279 +0,0 @@ -/** @file - ***************************************************************************** - Implementation of bigint wrapper class around GMP's MPZ long integers. - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef BIGINT_TCC_ -#define BIGINT_TCC_ -#include -#include -#include -#include "sodium.h" - -namespace libsnark { - -template -bigint::bigint(const uint64_t x) /// Initialize from a small integer -{ - static_assert(UINT64_MAX <= GMP_NUMB_MAX, "uint64_t does not fit in a GMP limb"); - this->data[0] = x; -} - -template -bigint::bigint(const char* s) /// Initialize from a string containing an integer in decimal notation -{ - size_t l = strlen(s); - unsigned char* s_copy = new unsigned char[l]; - - for (size_t i = 0; i < l; ++i) - { - assert(s[i] >= '0' && s[i] <= '9'); - s_copy[i] = s[i] - '0'; - } - - mp_size_t limbs_written = mpn_set_str(this->data, s_copy, l, 10); - assert(limbs_written <= n); - - delete[] s_copy; -} - -template -bigint::bigint(const mpz_t r) /// Initialize from MPZ element -{ - mpz_t k; - mpz_init_set(k, r); - - for (size_t i = 0; i < n; ++i) - { - data[i] = mpz_get_ui(k); - mpz_fdiv_q_2exp(k, k, GMP_NUMB_BITS); - } - - assert(mpz_sgn(k) == 0); - mpz_clear(k); -} - -template -void bigint::print() const -{ - gmp_printf("%Nd\n", this->data, n); -} - -template -void bigint::print_hex() const -{ - gmp_printf("%Nx\n", this->data, n); -} - -template -bool bigint::operator==(const bigint& other) const -{ - return (mpn_cmp(this->data, other.data, n) == 0); -} - -template -bool bigint::operator!=(const bigint& other) const -{ - return !(operator==(other)); -} - -template -void bigint::clear() -{ - mpn_zero(this->data, n); -} - -template -bool bigint::is_zero() const -{ - for (mp_size_t i = 0; i < n; ++i) - { - if (this->data[i]) - { - return false; - } - } - - return true; -} - -template -size_t bigint::num_bits() const -{ -/* - for (int64_t i = max_bits(); i >= 0; --i) - { - if (this->test_bit(i)) - { - return i+1; - } - } - - return 0; -*/ - for (int64_t i = n-1; i >= 0; --i) - { - mp_limb_t x = this->data[i]; - if (x == 0) - { - continue; - } - else - { - static_assert(GMP_NUMB_MAX <= ULLONG_MAX, "coercing limb to unsigned long long might truncate"); - return ((i+1) * GMP_NUMB_BITS) - __builtin_clzll(x); - } - } - return 0; -} - -template -uint64_t bigint::as_uint64() const -{ - return this->data[0]; -} - -template -void bigint::to_mpz(mpz_t r) const -{ - mpz_set_ui(r, 0); - - for (int i = n-1; i >= 0; --i) - { - mpz_mul_2exp(r, r, GMP_NUMB_BITS); - mpz_add_ui(r, r, this->data[i]); - } -} - -template -bool bigint::test_bit(const std::size_t bitno) const -{ - if (bitno >= n * GMP_NUMB_BITS) - { - return false; - } - else - { - const std::size_t part = bitno/GMP_NUMB_BITS; - const std::size_t bit = bitno - (GMP_NUMB_BITS*part); - const mp_limb_t one = 1; - return (this->data[part] & (one< template -inline void bigint::operator+=(const bigint& other) -{ - static_assert(n >= m, "first arg must not be smaller than second arg for bigint in-place add"); - mpn_add(data, data, n, other.data, m); -} - -template template -inline bigint bigint::operator*(const bigint& other) const -{ - static_assert(n >= m, "first arg must not be smaller than second arg for bigint mul"); - bigint res; - mpn_mul(res.data, data, n, other.data, m); - return res; -} - -template template -inline void bigint::div_qr(bigint& quotient, bigint& remainder, - const bigint& dividend, const bigint& divisor) -{ - static_assert(n >= d, "dividend must not be smaller than divisor for bigint::div_qr"); - assert(divisor.data[d-1] != 0); - mpn_tdiv_qr(quotient.data, remainder.data, 0, dividend.data, n, divisor.data, d); -} - -// Return a copy shortened to m limbs provided it is less than limit, throwing std::domain_error if not in range. -template template -inline bigint bigint::shorten(const bigint& q, const char *msg) const -{ - static_assert(m <= n, "number of limbs must not increase for bigint::shorten"); - for (mp_size_t i = m; i < n; i++) { // high-order limbs - if (data[i] != 0) { - throw std::domain_error(msg); - } - } - bigint res; - mpn_copyi(res.data, data, m); - res.limit(q, msg); - return res; -} - -template -inline void bigint::limit(const bigint& q, const char *msg) const -{ - if (!(q > *this)) { - throw std::domain_error(msg); - } -} - -template -inline bool bigint::operator>(const bigint& other) const -{ - return mpn_cmp(this->data, other.data, n) > 0; -} - -template -bigint& bigint::randomize() -{ - assert(GMP_NUMB_BITS == sizeof(mp_limb_t) * 8); - - randombytes_buf(this->data, sizeof(mp_limb_t) * n); - - return (*this); -} - - -template -std::ostream& operator<<(std::ostream &out, const bigint &b) -{ -#ifdef BINARY_OUTPUT - out.write((char*)b.data, sizeof(b.data[0]) * n); -#else - mpz_t t; - mpz_init(t); - b.to_mpz(t); - - out << t; - - mpz_clear(t); -#endif - return out; -} - -template -std::istream& operator>>(std::istream &in, bigint &b) -{ -#ifdef BINARY_OUTPUT - in.read((char*)b.data, sizeof(b.data[0]) * n); -#else - std::string s; - in >> s; - - size_t l = s.size(); - unsigned char* s_copy = new unsigned char[l]; - - for (size_t i = 0; i < l; ++i) - { - assert(s[i] >= '0' && s[i] <= '9'); - s_copy[i] = s[i] - '0'; - } - - mp_size_t limbs_written = mpn_set_str(b.data, s_copy, l, 10); - assert(limbs_written <= n); - - delete[] s_copy; -#endif - return in; -} - -} // libsnark -#endif // BIGINT_TCC_ diff --git a/src/snark/libsnark/algebra/fields/field_utils.hpp b/src/snark/libsnark/algebra/fields/field_utils.hpp deleted file mode 100644 index a07ecfe28..000000000 --- a/src/snark/libsnark/algebra/fields/field_utils.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef FIELD_UTILS_HPP_ -#define FIELD_UTILS_HPP_ -#include - -#include "common/utils.hpp" -#include "algebra/fields/bigint.hpp" - -namespace libsnark { - -// returns root of unity of order n (for n a power of 2), if one exists -template -FieldT get_root_of_unity(const size_t n); - -template -std::vector pack_int_vector_into_field_element_vector(const std::vector &v, const size_t w); - -template -std::vector pack_bit_vector_into_field_element_vector(const bit_vector &v, const size_t chunk_bits); - -template -std::vector pack_bit_vector_into_field_element_vector(const bit_vector &v); - -template -std::vector convert_bit_vector_to_field_element_vector(const bit_vector &v); - -template -bit_vector convert_field_element_vector_to_bit_vector(const std::vector &v); - -template -bit_vector convert_field_element_to_bit_vector(const FieldT &el); - -template -bit_vector convert_field_element_to_bit_vector(const FieldT &el, const size_t bitcount); - -template -FieldT convert_bit_vector_to_field_element(const bit_vector &v); - -template -void batch_invert(std::vector &vec); - -} // libsnark -#include "algebra/fields/field_utils.tcc" - -#endif // FIELD_UTILS_HPP_ diff --git a/src/snark/libsnark/algebra/fields/field_utils.tcc b/src/snark/libsnark/algebra/fields/field_utils.tcc deleted file mode 100644 index 66b532345..000000000 --- a/src/snark/libsnark/algebra/fields/field_utils.tcc +++ /dev/null @@ -1,183 +0,0 @@ -/** @file - ***************************************************************************** - Implementation of misc. math and serialization utility functions - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef FIELD_UTILS_TCC_ -#define FIELD_UTILS_TCC_ - -#include "common/utils.hpp" - -namespace libsnark { - -template -FieldT coset_shift() -{ - return FieldT::multiplicative_generator.squared(); -} - -template -FieldT get_root_of_unity(const size_t n) -{ - const size_t logn = log2(n); - assert(n == (1u << logn)); - assert(logn <= FieldT::s); - - FieldT omega = FieldT::root_of_unity; - for (size_t i = FieldT::s; i > logn; --i) - { - omega *= omega; - } - - return omega; -} - -template -std::vector pack_int_vector_into_field_element_vector(const std::vector &v, const size_t w) -{ - const size_t chunk_bits = FieldT::capacity(); - const size_t repacked_size = div_ceil(v.size() * w, chunk_bits); - std::vector result(repacked_size); - - for (size_t i = 0; i < repacked_size; ++i) - { - bigint b; - for (size_t j = 0; j < chunk_bits; ++j) - { - const size_t word_index = (i * chunk_bits + j) / w; - const size_t pos_in_word = (i * chunk_bits + j) % w; - const size_t word_or_0 = (word_index < v.size() ? v[word_index] : 0); - const size_t bit = (word_or_0 >> pos_in_word) & 1; - - b.data[j / GMP_NUMB_BITS] |= bit << (j % GMP_NUMB_BITS); - } - result[i] = FieldT(b); - } - - return result; -} - -template -std::vector pack_bit_vector_into_field_element_vector(const bit_vector &v, const size_t chunk_bits) -{ - assert(chunk_bits <= FieldT::capacity()); - - const size_t repacked_size = div_ceil(v.size(), chunk_bits); - std::vector result(repacked_size); - - for (size_t i = 0; i < repacked_size; ++i) - { - bigint b; - for (size_t j = 0; j < chunk_bits; ++j) - { - b.data[j / GMP_NUMB_BITS] |= ((i * chunk_bits + j) < v.size() && v[i * chunk_bits + j] ? 1ll : 0ll) << (j % GMP_NUMB_BITS); - } - result[i] = FieldT(b); - } - - return result; -} - -template -std::vector pack_bit_vector_into_field_element_vector(const bit_vector &v) -{ - return pack_bit_vector_into_field_element_vector(v, FieldT::capacity()); -} - -template -std::vector convert_bit_vector_to_field_element_vector(const bit_vector &v) -{ - std::vector result; - result.reserve(v.size()); - - for (const bool b : v) - { - result.emplace_back(b ? FieldT::one() : FieldT::zero()); - } - - return result; -} - -template -bit_vector convert_field_element_vector_to_bit_vector(const std::vector &v) -{ - bit_vector result; - - for (const FieldT &el : v) - { - const bit_vector el_bits = convert_field_element_to_bit_vector(el); - result.insert(result.end(), el_bits.begin(), el_bits.end()); - } - - return result; -} - -template -bit_vector convert_field_element_to_bit_vector(const FieldT &el) -{ - bit_vector result; - - bigint b = el.as_bigint(); - for (size_t i = 0; i < FieldT::size_in_bits(); ++i) - { - result.push_back(b.test_bit(i)); - } - - return result; -} - -template -bit_vector convert_field_element_to_bit_vector(const FieldT &el, const size_t bitcount) -{ - bit_vector result = convert_field_element_to_bit_vector(el); - result.resize(bitcount); - - return result; -} - -template -FieldT convert_bit_vector_to_field_element(const bit_vector &v) -{ - assert(v.size() <= FieldT::size_in_bits()); - - FieldT res = FieldT::zero(); - FieldT c = FieldT::one(); - for (bool b : v) - { - res += b ? c : FieldT::zero(); - c += c; - } - return res; -} - -template -void batch_invert(std::vector &vec) -{ - std::vector prod; - prod.reserve(vec.size()); - - FieldT acc = FieldT::one(); - - for (auto el : vec) - { - assert(!el.is_zero()); - prod.emplace_back(acc); - acc = acc * el; - } - - FieldT acc_inverse = acc.inverse(); - - for (int64_t i = vec.size()-1; i >= 0; --i) - { - const FieldT old_el = vec[i]; - vec[i] = acc_inverse * prod[i]; - acc_inverse = acc_inverse * old_el; - } -} - -} // libsnark -#endif // FIELD_UTILS_TCC_ diff --git a/src/snark/libsnark/algebra/fields/fp.hpp b/src/snark/libsnark/algebra/fields/fp.hpp deleted file mode 100644 index af9eb0b9a..000000000 --- a/src/snark/libsnark/algebra/fields/fp.hpp +++ /dev/null @@ -1,182 +0,0 @@ -/** @file - ***************************************************************************** - Declaration of arithmetic in the finite field F[p], for prime p of fixed length. - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef FP_HPP_ -#define FP_HPP_ - -#include "algebra/fields/bigint.hpp" -#include "algebra/exponentiation/exponentiation.hpp" - -namespace libsnark { - -template& modulus> -class Fp_model; - -template& modulus> -std::ostream& operator<<(std::ostream &, const Fp_model&); - -template& modulus> -std::istream& operator>>(std::istream &, Fp_model &); - -/** - * Arithmetic in the finite field F[p], for prime p of fixed length. - * - * This class implements Fp-arithmetic, for a large prime p, using a fixed number - * of words. It is optimized for tight memory consumption, so the modulus p is - * passed as a template parameter, to avoid per-element overheads. - * - * The implementation is mostly a wrapper around GMP's MPN (constant-size integers). - * But for the integer sizes of interest for libsnark (3 to 5 limbs of 64 bits each), - * we implement performance-critical routines, like addition and multiplication, - * using hand-optimized assembly code. -*/ -template& modulus> -class Fp_model { -public: - bigint mont_repr; -public: - static const mp_size_t num_limbs = n; - static const constexpr bigint& mod = modulus; -#ifdef PROFILE_OP_COUNTS - static int64_t add_cnt; - static int64_t sub_cnt; - static int64_t mul_cnt; - static int64_t sqr_cnt; - static int64_t inv_cnt; -#endif - static size_t num_bits; - static bigint euler; // (modulus-1)/2 - static size_t s; // modulus = 2^s * t + 1 - static bigint t; // with t odd - static bigint t_minus_1_over_2; // (t-1)/2 - static Fp_model nqr; // a quadratic nonresidue - static Fp_model nqr_to_t; // nqr^t - static Fp_model multiplicative_generator; // generator of Fp^* - static Fp_model root_of_unity; // generator^((modulus-1)/2^s) - static mp_limb_t inv; // modulus^(-1) mod W, where W = 2^(word size) - static bigint Rsquared; // R^2, where R = W^k, where k = ?? - static bigint Rcubed; // R^3 - - static bool modulus_is_valid() { return modulus.data[n-1] != 0; } // mpn inverse assumes that highest limb is non-zero - - Fp_model() {}; - Fp_model(const bigint &b); - Fp_model(const int64_t x, const bool is_unsigned=false); - - void set_uint64(const uint64_t x); - - void mul_reduce(const bigint &other); - - void clear(); - - /* Return the standard (not Montgomery) representation of the - Field element's requivalence class. I.e. Fp(2).as_bigint() - would return bigint(2) */ - bigint as_bigint() const; - /* Return the last limb of the standard representation of the - field element. E.g. on 64-bit architectures Fp(123).as_uint64() - and Fp(2^64+123).as_uint64() would both return 123. */ - uint64_t as_uint64() const; - - bool operator==(const Fp_model& other) const; - bool operator!=(const Fp_model& other) const; - bool is_zero() const; - - void print() const; - - Fp_model& operator+=(const Fp_model& other); - Fp_model& operator-=(const Fp_model& other); - Fp_model& operator*=(const Fp_model& other); - Fp_model& operator^=(const uint64_t pow); - - template - Fp_model& operator^=(const bigint &pow); - - Fp_model operator+(const Fp_model& other) const; - Fp_model operator-(const Fp_model& other) const; - Fp_model operator*(const Fp_model& other) const; - Fp_model operator-() const; - Fp_model squared() const; - Fp_model& invert(); - Fp_model inverse() const; - Fp_model sqrt() const; // HAS TO BE A SQUARE (else does not terminate) - - Fp_model operator^(const uint64_t pow) const; - template - Fp_model operator^(const bigint &pow) const; - - static size_t size_in_bits() { return num_bits; } - static size_t capacity() { return num_bits - 1; } - static bigint field_char() { return modulus; } - - static Fp_model zero(); - static Fp_model one(); - static Fp_model random_element(); - - friend std::ostream& operator<< (std::ostream &out, const Fp_model &p); - friend std::istream& operator>> (std::istream &in, Fp_model &p); -}; - -#ifdef PROFILE_OP_COUNTS -template& modulus> -int64_t Fp_model::add_cnt = 0; - -template& modulus> -int64_t Fp_model::sub_cnt = 0; - -template& modulus> -int64_t Fp_model::mul_cnt = 0; - -template& modulus> -int64_t Fp_model::sqr_cnt = 0; - -template& modulus> -int64_t Fp_model::inv_cnt = 0; -#endif - -template& modulus> -size_t Fp_model::num_bits; - -template& modulus> -bigint Fp_model::euler; - -template& modulus> -size_t Fp_model::s; - -template& modulus> -bigint Fp_model::t; - -template& modulus> -bigint Fp_model::t_minus_1_over_2; - -template& modulus> -Fp_model Fp_model::nqr; - -template& modulus> -Fp_model Fp_model::nqr_to_t; - -template& modulus> -Fp_model Fp_model::multiplicative_generator; - -template& modulus> -Fp_model Fp_model::root_of_unity; - -template& modulus> -mp_limb_t Fp_model::inv; - -template& modulus> -bigint Fp_model::Rsquared; - -template& modulus> -bigint Fp_model::Rcubed; - -} // libsnark -#include "algebra/fields/fp.tcc" - -#endif // FP_HPP_ diff --git a/src/snark/libsnark/algebra/fields/fp.tcc b/src/snark/libsnark/algebra/fields/fp.tcc deleted file mode 100644 index 02baf6274..000000000 --- a/src/snark/libsnark/algebra/fields/fp.tcc +++ /dev/null @@ -1,790 +0,0 @@ -/** @file - ***************************************************************************** - Implementation of arithmetic in the finite field F[p], for prime p of fixed length. - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef FP_TCC_ -#define FP_TCC_ -#include -#include -#include - -#include "algebra/fields/fp_aux.tcc" -#include "algebra/fields/field_utils.hpp" -#include "common/assert_except.hpp" - -namespace libsnark { - -template& modulus> -void Fp_model::mul_reduce(const bigint &other) -{ - /* stupid pre-processor tricks; beware */ -#if defined(__x86_64__) && defined(USE_ASM) - if (n == 3) - { // Use asm-optimized Comba multiplication and reduction - mp_limb_t res[2*n]; - mp_limb_t c0, c1, c2; - COMBA_3_BY_3_MUL(c0, c1, c2, res, this->mont_repr.data, other.data); - - mp_limb_t k; - mp_limb_t tmp1, tmp2, tmp3; - REDUCE_6_LIMB_PRODUCT(k, tmp1, tmp2, tmp3, inv, res, modulus.data); - - /* subtract t > mod */ - __asm__ - ("/* check for overflow */ \n\t" - MONT_CMP(16) - MONT_CMP(8) - MONT_CMP(0) - - "/* subtract mod if overflow */ \n\t" - "subtract%=: \n\t" - MONT_FIRSTSUB - MONT_NEXTSUB(8) - MONT_NEXTSUB(16) - "done%=: \n\t" - : - : [tmp] "r" (res+n), [M] "r" (modulus.data) - : "cc", "memory", "%rax"); - mpn_copyi(this->mont_repr.data, res+n, n); - } - else if (n == 4) - { // use asm-optimized "CIOS method" - - mp_limb_t tmp[n+1]; - mp_limb_t T0=0, T1=1, cy=2, u=3; // TODO: fix this - - __asm__ (MONT_PRECOMPUTE - MONT_FIRSTITER(1) - MONT_FIRSTITER(2) - MONT_FIRSTITER(3) - MONT_FINALIZE(3) - MONT_ITERFIRST(1) - MONT_ITERITER(1, 1) - MONT_ITERITER(1, 2) - MONT_ITERITER(1, 3) - MONT_FINALIZE(3) - MONT_ITERFIRST(2) - MONT_ITERITER(2, 1) - MONT_ITERITER(2, 2) - MONT_ITERITER(2, 3) - MONT_FINALIZE(3) - MONT_ITERFIRST(3) - MONT_ITERITER(3, 1) - MONT_ITERITER(3, 2) - MONT_ITERITER(3, 3) - MONT_FINALIZE(3) - "/* check for overflow */ \n\t" - MONT_CMP(24) - MONT_CMP(16) - MONT_CMP(8) - MONT_CMP(0) - - "/* subtract mod if overflow */ \n\t" - "subtract%=: \n\t" - MONT_FIRSTSUB - MONT_NEXTSUB(8) - MONT_NEXTSUB(16) - MONT_NEXTSUB(24) - "done%=: \n\t" - : - : [tmp] "r" (tmp), [A] "r" (this->mont_repr.data), [B] "r" (other.data), [inv] "r" (inv), [M] "r" (modulus.data), - [T0] "r" (T0), [T1] "r" (T1), [cy] "r" (cy), [u] "r" (u) - : "cc", "memory", "%rax", "%rdx" - ); - mpn_copyi(this->mont_repr.data, tmp, n); - } - else if (n == 5) - { // use asm-optimized "CIOS method" - - mp_limb_t tmp[n+1]; - mp_limb_t T0=0, T1=1, cy=2, u=3; // TODO: fix this - - __asm__ (MONT_PRECOMPUTE - MONT_FIRSTITER(1) - MONT_FIRSTITER(2) - MONT_FIRSTITER(3) - MONT_FIRSTITER(4) - MONT_FINALIZE(4) - MONT_ITERFIRST(1) - MONT_ITERITER(1, 1) - MONT_ITERITER(1, 2) - MONT_ITERITER(1, 3) - MONT_ITERITER(1, 4) - MONT_FINALIZE(4) - MONT_ITERFIRST(2) - MONT_ITERITER(2, 1) - MONT_ITERITER(2, 2) - MONT_ITERITER(2, 3) - MONT_ITERITER(2, 4) - MONT_FINALIZE(4) - MONT_ITERFIRST(3) - MONT_ITERITER(3, 1) - MONT_ITERITER(3, 2) - MONT_ITERITER(3, 3) - MONT_ITERITER(3, 4) - MONT_FINALIZE(4) - MONT_ITERFIRST(4) - MONT_ITERITER(4, 1) - MONT_ITERITER(4, 2) - MONT_ITERITER(4, 3) - MONT_ITERITER(4, 4) - MONT_FINALIZE(4) - "/* check for overflow */ \n\t" - MONT_CMP(32) - MONT_CMP(24) - MONT_CMP(16) - MONT_CMP(8) - MONT_CMP(0) - - "/* subtract mod if overflow */ \n\t" - "subtract%=: \n\t" - MONT_FIRSTSUB - MONT_NEXTSUB(8) - MONT_NEXTSUB(16) - MONT_NEXTSUB(24) - MONT_NEXTSUB(32) - "done%=: \n\t" - : - : [tmp] "r" (tmp), [A] "r" (this->mont_repr.data), [B] "r" (other.data), [inv] "r" (inv), [M] "r" (modulus.data), - [T0] "r" (T0), [T1] "r" (T1), [cy] "r" (cy), [u] "r" (u) - : "cc", "memory", "%rax", "%rdx" - ); - mpn_copyi(this->mont_repr.data, tmp, n); - } - else -#endif - { - mp_limb_t res[2*n]; - mpn_mul_n(res, this->mont_repr.data, other.data, n); - - /* - The Montgomery reduction here is based on Algorithm 14.32 in - Handbook of Applied Cryptography - . - */ - for (size_t i = 0; i < n; ++i) - { - mp_limb_t k = inv * res[i]; - /* calculate res = res + k * mod * b^i */ - mp_limb_t carryout = mpn_addmul_1(res+i, modulus.data, n, k); - carryout = mpn_add_1(res+n+i, res+n+i, n-i, carryout); - assert(carryout == 0); - } - - if (mpn_cmp(res+n, modulus.data, n) >= 0) - { - const mp_limb_t borrow = mpn_sub(res+n, res+n, n, modulus.data, n); - assert(borrow == 0); - } - - mpn_copyi(this->mont_repr.data, res+n, n); - } -} - -template& modulus> -Fp_model::Fp_model(const bigint &b) -{ - mpn_copyi(this->mont_repr.data, Rsquared.data, n); - mul_reduce(b); -} - -template& modulus> -Fp_model::Fp_model(const int64_t x, const bool is_unsigned) -{ - if (is_unsigned || x >= 0) - { - this->mont_repr.data[0] = x; - } - else - { - const mp_limb_t borrow = mpn_sub_1(this->mont_repr.data, modulus.data, n, -x); - assert(borrow == 0); - } - - mul_reduce(Rsquared); -} - -template& modulus> -void Fp_model::set_uint64(const uint64_t x) -{ - this->mont_repr.clear(); - this->mont_repr.data[0] = x; - mul_reduce(Rsquared); -} - -template& modulus> -void Fp_model::clear() -{ - this->mont_repr.clear(); -} - -template& modulus> -bigint Fp_model::as_bigint() const -{ - bigint one; - one.clear(); - one.data[0] = 1; - - Fp_model res(*this); - res.mul_reduce(one); - - return (res.mont_repr); -} - -template& modulus> -uint64_t Fp_model::as_uint64() const -{ - return this->as_bigint().as_uint64(); -} - -template& modulus> -bool Fp_model::operator==(const Fp_model& other) const -{ - return (this->mont_repr == other.mont_repr); -} - -template& modulus> -bool Fp_model::operator!=(const Fp_model& other) const -{ - return (this->mont_repr != other.mont_repr); -} - -template& modulus> -bool Fp_model::is_zero() const -{ - return (this->mont_repr.is_zero()); // zero maps to zero -} - -template& modulus> -void Fp_model::print() const -{ - Fp_model tmp; - tmp.mont_repr.data[0] = 1; - tmp.mul_reduce(this->mont_repr); - - tmp.mont_repr.print(); -} - -template& modulus> -Fp_model Fp_model::zero() -{ - Fp_model res; - res.mont_repr.clear(); - return res; -} - -template& modulus> -Fp_model Fp_model::one() -{ - Fp_model res; - res.mont_repr.data[0] = 1; - res.mul_reduce(Rsquared); - return res; -} - -template& modulus> -Fp_model& Fp_model::operator+=(const Fp_model& other) -{ -#ifdef PROFILE_OP_COUNTS - this->add_cnt++; -#endif -#if defined(__x86_64__) && defined(USE_ASM) - if (n == 3) - { - __asm__ - ("/* perform bignum addition */ \n\t" - ADD_FIRSTADD - ADD_NEXTADD(8) - ADD_NEXTADD(16) - "/* if overflow: subtract */ \n\t" - "/* (tricky point: if A and B are in the range we do not need to do anything special for the possible carry flag) */ \n\t" - "jc subtract%= \n\t" - - "/* check for overflow */ \n\t" - ADD_CMP(16) - ADD_CMP(8) - ADD_CMP(0) - - "/* subtract mod if overflow */ \n\t" - "subtract%=: \n\t" - ADD_FIRSTSUB - ADD_NEXTSUB(8) - ADD_NEXTSUB(16) - "done%=: \n\t" - : - : [A] "r" (this->mont_repr.data), [B] "r" (other.mont_repr.data), [mod] "r" (modulus.data) - : "cc", "memory", "%rax"); - } - else if (n == 4) - { - __asm__ - ("/* perform bignum addition */ \n\t" - ADD_FIRSTADD - ADD_NEXTADD(8) - ADD_NEXTADD(16) - ADD_NEXTADD(24) - "/* if overflow: subtract */ \n\t" - "/* (tricky point: if A and B are in the range we do not need to do anything special for the possible carry flag) */ \n\t" - "jc subtract%= \n\t" - - "/* check for overflow */ \n\t" - ADD_CMP(24) - ADD_CMP(16) - ADD_CMP(8) - ADD_CMP(0) - - "/* subtract mod if overflow */ \n\t" - "subtract%=: \n\t" - ADD_FIRSTSUB - ADD_NEXTSUB(8) - ADD_NEXTSUB(16) - ADD_NEXTSUB(24) - "done%=: \n\t" - : - : [A] "r" (this->mont_repr.data), [B] "r" (other.mont_repr.data), [mod] "r" (modulus.data) - : "cc", "memory", "%rax"); - } - else if (n == 5) - { - __asm__ - ("/* perform bignum addition */ \n\t" - ADD_FIRSTADD - ADD_NEXTADD(8) - ADD_NEXTADD(16) - ADD_NEXTADD(24) - ADD_NEXTADD(32) - "/* if overflow: subtract */ \n\t" - "/* (tricky point: if A and B are in the range we do not need to do anything special for the possible carry flag) */ \n\t" - "jc subtract%= \n\t" - - "/* check for overflow */ \n\t" - ADD_CMP(32) - ADD_CMP(24) - ADD_CMP(16) - ADD_CMP(8) - ADD_CMP(0) - - "/* subtract mod if overflow */ \n\t" - "subtract%=: \n\t" - ADD_FIRSTSUB - ADD_NEXTSUB(8) - ADD_NEXTSUB(16) - ADD_NEXTSUB(24) - ADD_NEXTSUB(32) - "done%=: \n\t" - : - : [A] "r" (this->mont_repr.data), [B] "r" (other.mont_repr.data), [mod] "r" (modulus.data) - : "cc", "memory", "%rax"); - } - else -#endif - { - mp_limb_t scratch[n+1]; - const mp_limb_t carry = mpn_add_n(scratch, this->mont_repr.data, other.mont_repr.data, n); - scratch[n] = carry; - - if (carry || mpn_cmp(scratch, modulus.data, n) >= 0) - { - const mp_limb_t borrow = mpn_sub(scratch, scratch, n+1, modulus.data, n); - assert(borrow == 0); - } - - mpn_copyi(this->mont_repr.data, scratch, n); - } - - return *this; -} - -template& modulus> -Fp_model& Fp_model::operator-=(const Fp_model& other) -{ -#ifdef PROFILE_OP_COUNTS - this->sub_cnt++; -#endif -#if defined(__x86_64__) && defined(USE_ASM) - if (n == 3) - { - __asm__ - (SUB_FIRSTSUB - SUB_NEXTSUB(8) - SUB_NEXTSUB(16) - - "jnc done%=\n\t" - - SUB_FIRSTADD - SUB_NEXTADD(8) - SUB_NEXTADD(16) - - "done%=:\n\t" - : - : [A] "r" (this->mont_repr.data), [B] "r" (other.mont_repr.data), [mod] "r" (modulus.data) - : "cc", "memory", "%rax"); - } - else if (n == 4) - { - __asm__ - (SUB_FIRSTSUB - SUB_NEXTSUB(8) - SUB_NEXTSUB(16) - SUB_NEXTSUB(24) - - "jnc done%=\n\t" - - SUB_FIRSTADD - SUB_NEXTADD(8) - SUB_NEXTADD(16) - SUB_NEXTADD(24) - - "done%=:\n\t" - : - : [A] "r" (this->mont_repr.data), [B] "r" (other.mont_repr.data), [mod] "r" (modulus.data) - : "cc", "memory", "%rax"); - } - else if (n == 5) - { - __asm__ - (SUB_FIRSTSUB - SUB_NEXTSUB(8) - SUB_NEXTSUB(16) - SUB_NEXTSUB(24) - SUB_NEXTSUB(32) - - "jnc done%=\n\t" - - SUB_FIRSTADD - SUB_NEXTADD(8) - SUB_NEXTADD(16) - SUB_NEXTADD(24) - SUB_NEXTADD(32) - - "done%=:\n\t" - : - : [A] "r" (this->mont_repr.data), [B] "r" (other.mont_repr.data), [mod] "r" (modulus.data) - : "cc", "memory", "%rax"); - } - else -#endif - { - mp_limb_t scratch[n+1]; - if (mpn_cmp(this->mont_repr.data, other.mont_repr.data, n) < 0) - { - const mp_limb_t carry = mpn_add_n(scratch, this->mont_repr.data, modulus.data, n); - scratch[n] = carry; - } - else - { - mpn_copyi(scratch, this->mont_repr.data, n); - scratch[n] = 0; - } - - const mp_limb_t borrow = mpn_sub(scratch, scratch, n+1, other.mont_repr.data, n); - assert(borrow == 0); - - mpn_copyi(this->mont_repr.data, scratch, n); - } - return *this; -} - -template& modulus> -Fp_model& Fp_model::operator*=(const Fp_model& other) -{ -#ifdef PROFILE_OP_COUNTS - this->mul_cnt++; -#endif - - mul_reduce(other.mont_repr); - return *this; -} - -template& modulus> -Fp_model& Fp_model::operator^=(const uint64_t pow) -{ - (*this) = power >(*this, pow); - return (*this); -} - -template& modulus> -template -Fp_model& Fp_model::operator^=(const bigint &pow) -{ - (*this) = power, m>(*this, pow); - return (*this); -} - -template& modulus> -Fp_model Fp_model::operator+(const Fp_model& other) const -{ - Fp_model r(*this); - return (r += other); -} - -template& modulus> -Fp_model Fp_model::operator-(const Fp_model& other) const -{ - Fp_model r(*this); - return (r -= other); -} - -template& modulus> -Fp_model Fp_model::operator*(const Fp_model& other) const -{ - Fp_model r(*this); - return (r *= other); -} - -template& modulus> -Fp_model Fp_model::operator^(const uint64_t pow) const -{ - Fp_model r(*this); - return (r ^= pow); -} - -template& modulus> -template -Fp_model Fp_model::operator^(const bigint &pow) const -{ - Fp_model r(*this); - return (r ^= pow); -} - -template& modulus> -Fp_model Fp_model::operator-() const -{ -#ifdef PROFILE_OP_COUNTS - this->sub_cnt++; -#endif - - if (this->is_zero()) - { - return (*this); - } - else - { - Fp_model r; - mpn_sub_n(r.mont_repr.data, modulus.data, this->mont_repr.data, n); - return r; - } -} - -template& modulus> -Fp_model Fp_model::squared() const -{ -#ifdef PROFILE_OP_COUNTS - this->sqr_cnt++; - this->mul_cnt--; // zero out the upcoming mul -#endif - /* stupid pre-processor tricks; beware */ -#if defined(__x86_64__) && defined(USE_ASM) - if (n == 3) - { // use asm-optimized Comba squaring - mp_limb_t res[2*n]; - mp_limb_t c0, c1, c2; - COMBA_3_BY_3_SQR(c0, c1, c2, res, this->mont_repr.data); - - mp_limb_t k; - mp_limb_t tmp1, tmp2, tmp3; - REDUCE_6_LIMB_PRODUCT(k, tmp1, tmp2, tmp3, inv, res, modulus.data); - - /* subtract t > mod */ - __asm__ volatile - ("/* check for overflow */ \n\t" - MONT_CMP(16) - MONT_CMP(8) - MONT_CMP(0) - - "/* subtract mod if overflow */ \n\t" - "subtract%=: \n\t" - MONT_FIRSTSUB - MONT_NEXTSUB(8) - MONT_NEXTSUB(16) - "done%=: \n\t" - : - : [tmp] "r" (res+n), [M] "r" (modulus.data) - : "cc", "memory", "%rax"); - - Fp_model r; - mpn_copyi(r.mont_repr.data, res+n, n); - return r; - } - else -#endif - { - Fp_model r(*this); - return (r *= r); - } -} - -template& modulus> -Fp_model& Fp_model::invert() -{ -#ifdef PROFILE_OP_COUNTS - this->inv_cnt++; -#endif - - assert(!this->is_zero()); - - bigint g; /* gp should have room for vn = n limbs */ - - mp_limb_t s[n+1]; /* sp should have room for vn+1 limbs */ - mp_size_t sn; - - bigint v = modulus; // both source operands are destroyed by mpn_gcdext - - /* computes gcd(u, v) = g = u*s + v*t, so s*u will be 1 (mod v) */ - const mp_size_t gn = mpn_gcdext(g.data, s, &sn, this->mont_repr.data, n, v.data, n); - assert(gn == 1 && g.data[0] == 1); /* inverse exists */ - - mp_limb_t q; /* division result fits into q, as sn <= n+1 */ - /* sn < 0 indicates negative sn; will fix up later */ - - if (std::abs(sn) >= n) - { - /* if sn could require modulus reduction, do it here */ - mpn_tdiv_qr(&q, this->mont_repr.data, 0, s, std::abs(sn), modulus.data, n); - } - else - { - /* otherwise just copy it over */ - mpn_zero(this->mont_repr.data, n); - mpn_copyi(this->mont_repr.data, s, std::abs(sn)); - } - - /* fix up the negative sn */ - if (sn < 0) - { - const mp_limb_t borrow = mpn_sub_n(this->mont_repr.data, modulus.data, this->mont_repr.data, n); - assert(borrow == 0); - } - - mul_reduce(Rcubed); - return *this; -} - -template& modulus> -Fp_model Fp_model::inverse() const -{ - Fp_model r(*this); - return (r.invert()); -} - -template& modulus> -Fp_model Fp_model::random_element() /// returns random element of Fp_model -{ - /* note that as Montgomery representation is a bijection then - selecting a random element of {xR} is the same as selecting a - random element of {x} */ - Fp_model r; - do - { - r.mont_repr.randomize(); - - /* clear all bits higher than MSB of modulus */ - size_t bitno = GMP_NUMB_BITS * n - 1; - while (modulus.test_bit(bitno) == false) - { - const std::size_t part = bitno/GMP_NUMB_BITS; - const std::size_t bit = bitno - (GMP_NUMB_BITS*part); - - r.mont_repr.data[part] &= ~(UINT64_C(1)<= modulus -- repeat (rejection sampling) */ - while (mpn_cmp(r.mont_repr.data, modulus.data, n) >= 0); - - return r; -} - -template& modulus> -Fp_model Fp_model::sqrt() const -{ - if (is_zero()) { - return *this; - } - - Fp_model one = Fp_model::one(); - - size_t v = Fp_model::s; - Fp_model z = Fp_model::nqr_to_t; - Fp_model w = (*this)^Fp_model::t_minus_1_over_2; - Fp_model x = (*this) * w; - Fp_model b = x * w; // b = (*this)^t - - - // check if square with euler's criterion - Fp_model check = b; - for (size_t i = 0; i < v-1; ++i) - { - check = check.squared(); - } - if (check != one) - { - assert_except(0); - } - - - // compute square root with Tonelli--Shanks - // (does not terminate if not a square!) - - while (b != one) - { - size_t m = 0; - Fp_model b2m = b; - while (b2m != one) - { - /* invariant: b2m = b^(2^m) after entering this loop */ - b2m = b2m.squared(); - m += 1; - } - - int j = v-m-1; - w = z; - while (j > 0) - { - w = w.squared(); - --j; - } // w = z^2^(v-m-1) - - z = w.squared(); - b = b * z; - x = x * w; - v = m; - } - - return x; -} - -template& modulus> -std::ostream& operator<<(std::ostream &out, const Fp_model &p) -{ -#ifndef MONTGOMERY_OUTPUT - Fp_model tmp; - tmp.mont_repr.data[0] = 1; - tmp.mul_reduce(p.mont_repr); - out << tmp.mont_repr; -#else - out << p.mont_repr; -#endif - return out; -} - -template& modulus> -std::istream& operator>>(std::istream &in, Fp_model &p) -{ -#ifndef MONTGOMERY_OUTPUT - in >> p.mont_repr; - p.mul_reduce(Fp_model::Rsquared); -#else - in >> p.mont_repr; -#endif - return in; -} - -} // libsnark -#endif // FP_TCC_ diff --git a/src/snark/libsnark/algebra/fields/fp12_2over3over2.hpp b/src/snark/libsnark/algebra/fields/fp12_2over3over2.hpp deleted file mode 100644 index 62ac8aa29..000000000 --- a/src/snark/libsnark/algebra/fields/fp12_2over3over2.hpp +++ /dev/null @@ -1,116 +0,0 @@ -/** @file - ***************************************************************************** - Declaration of arithmetic in the finite field F[((p^2)^3)^2]. - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef FP12_2OVER3OVER2_HPP_ -#define FP12_2OVER3OVER2_HPP_ -#include "algebra/fields/fp.hpp" -#include "algebra/fields/fp2.hpp" -#include "algebra/fields/fp6_3over2.hpp" -#include - -namespace libsnark { - -template& modulus> -class Fp12_2over3over2_model; - -template& modulus> -std::ostream& operator<<(std::ostream &, const Fp12_2over3over2_model &); - -template& modulus> -std::istream& operator>>(std::istream &, Fp12_2over3over2_model &); - -/** - * Arithmetic in the finite field F[((p^2)^3)^2]. - * - * Let p := modulus. This interface provides arithmetic for the extension field - * Fp12 = Fp6[W]/(W^2-V) where Fp6 = Fp2[V]/(V^3-non_residue) and non_residue is in Fp2 - * - * ASSUMPTION: p = 1 (mod 6) - */ -template& modulus> -class Fp12_2over3over2_model { -public: - typedef Fp_model my_Fp; - typedef Fp2_model my_Fp2; - typedef Fp6_3over2_model my_Fp6; - - static Fp2_model non_residue; - static Fp2_model Frobenius_coeffs_c1[12]; // non_residue^((modulus^i-1)/6) for i=0,...,11 - - my_Fp6 c0, c1; - Fp12_2over3over2_model() {}; - Fp12_2over3over2_model(const my_Fp6& c0, const my_Fp6& c1) : c0(c0), c1(c1) {}; - - void clear() { c0.clear(); c1.clear(); } - void print() const { printf("c0/c1:\n"); c0.print(); c1.print(); } - - static Fp12_2over3over2_model zero(); - static Fp12_2over3over2_model one(); - static Fp12_2over3over2_model random_element(); - - bool is_zero() const { return c0.is_zero() && c1.is_zero(); } - bool operator==(const Fp12_2over3over2_model &other) const; - bool operator!=(const Fp12_2over3over2_model &other) const; - - Fp12_2over3over2_model operator+(const Fp12_2over3over2_model &other) const; - Fp12_2over3over2_model operator-(const Fp12_2over3over2_model &other) const; - Fp12_2over3over2_model operator*(const Fp12_2over3over2_model &other) const; - Fp12_2over3over2_model operator-() const; - Fp12_2over3over2_model squared() const; // default is squared_complex - Fp12_2over3over2_model squared_karatsuba() const; - Fp12_2over3over2_model squared_complex() const; - Fp12_2over3over2_model inverse() const; - Fp12_2over3over2_model Frobenius_map(uint64_t power) const; - Fp12_2over3over2_model unitary_inverse() const; - Fp12_2over3over2_model cyclotomic_squared() const; - - Fp12_2over3over2_model mul_by_024(const my_Fp2 &ell_0, const my_Fp2 &ell_VW, const my_Fp2 &ell_VV) const; - - static my_Fp6 mul_by_non_residue(const my_Fp6 &elt); - - template - Fp12_2over3over2_model cyclotomic_exp(const bigint &exponent) const; - - static bigint base_field_char() { return modulus; } - static size_t extension_degree() { return 12; } - - friend std::ostream& operator<< (std::ostream &out, const Fp12_2over3over2_model &el); - friend std::istream& operator>> (std::istream &in, Fp12_2over3over2_model &el); -}; - -template& modulus> -std::ostream& operator<<(std::ostream& out, const std::vector > &v); - -template& modulus> -std::istream& operator>>(std::istream& in, std::vector > &v); - -template& modulus> -Fp12_2over3over2_model operator*(const Fp_model &lhs, const Fp12_2over3over2_model &rhs); - -template& modulus> -Fp12_2over3over2_model operator*(const Fp2_model &lhs, const Fp12_2over3over2_model &rhs); - -template& modulus> -Fp12_2over3over2_model operator*(const Fp6_3over2_model &lhs, const Fp12_2over3over2_model &rhs); - -template& modulus, mp_size_t m> -Fp12_2over3over2_model operator^(const Fp12_2over3over2_model &self, const bigint &exponent); - -template& modulus, mp_size_t m, const bigint& exp_modulus> -Fp12_2over3over2_model operator^(const Fp12_2over3over2_model &self, const Fp_model &exponent); - -template& modulus> -Fp2_model Fp12_2over3over2_model::non_residue; - -template& modulus> -Fp2_model Fp12_2over3over2_model::Frobenius_coeffs_c1[12]; - -} // libsnark -#include "algebra/fields/fp12_2over3over2.tcc" -#endif // FP12_2OVER3OVER2_HPP_ diff --git a/src/snark/libsnark/algebra/fields/fp12_2over3over2.tcc b/src/snark/libsnark/algebra/fields/fp12_2over3over2.tcc deleted file mode 100644 index 5ce95fbad..000000000 --- a/src/snark/libsnark/algebra/fields/fp12_2over3over2.tcc +++ /dev/null @@ -1,412 +0,0 @@ -/** @file - ***************************************************************************** - Implementation of arithmetic in the finite field F[((p^2)^3)^2]. - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef FP12_2OVER3OVER2_TCC_ -#define FP12_2OVER3OVER2_TCC_ - -namespace libsnark { - -template& modulus> -Fp6_3over2_model Fp12_2over3over2_model::mul_by_non_residue(const Fp6_3over2_model &elt) -{ - return Fp6_3over2_model(non_residue * elt.c2, elt.c0, elt.c1); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::zero() -{ - return Fp12_2over3over2_model(my_Fp6::zero(), my_Fp6::zero()); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::one() -{ - return Fp12_2over3over2_model(my_Fp6::one(), my_Fp6::zero()); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::random_element() -{ - Fp12_2over3over2_model r; - r.c0 = my_Fp6::random_element(); - r.c1 = my_Fp6::random_element(); - - return r; -} - -template& modulus> -bool Fp12_2over3over2_model::operator==(const Fp12_2over3over2_model &other) const -{ - return (this->c0 == other.c0 && this->c1 == other.c1); -} - -template& modulus> -bool Fp12_2over3over2_model::operator!=(const Fp12_2over3over2_model &other) const -{ - return !(operator==(other)); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::operator+(const Fp12_2over3over2_model &other) const -{ - return Fp12_2over3over2_model(this->c0 + other.c0, - this->c1 + other.c1); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::operator-(const Fp12_2over3over2_model &other) const -{ - return Fp12_2over3over2_model(this->c0 - other.c0, - this->c1 - other.c1); -} - -template& modulus> -Fp12_2over3over2_model operator*(const Fp_model &lhs, const Fp12_2over3over2_model &rhs) -{ - return Fp12_2over3over2_model(lhs*rhs.c0, - lhs*rhs.c1); -} - -template& modulus> -Fp12_2over3over2_model operator*(const Fp2_model &lhs, const Fp12_2over3over2_model &rhs) -{ - return Fp12_2over3over2_model(lhs*rhs.c0, - lhs*rhs.c1); -} - -template& modulus> -Fp12_2over3over2_model operator*(const Fp6_3over2_model &lhs, const Fp12_2over3over2_model &rhs) -{ - return Fp12_2over3over2_model(lhs*rhs.c0, - lhs*rhs.c1); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::operator*(const Fp12_2over3over2_model &other) const -{ - /* Devegili OhEig Scott Dahab --- Multiplication and Squaring on Pairing-Friendly Fields.pdf; Section 3 (Karatsuba) */ - - const my_Fp6 &A = other.c0, &B = other.c1, - &a = this->c0, &b = this->c1; - const my_Fp6 aA = a * A; - const my_Fp6 bB = b * B; - - return Fp12_2over3over2_model(aA + Fp12_2over3over2_model::mul_by_non_residue(bB), - (a + b)*(A+B) - aA - bB); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::operator-() const -{ - return Fp12_2over3over2_model(-this->c0, - -this->c1); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::squared() const -{ - return squared_complex(); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::squared_karatsuba() const -{ - /* Devegili OhEig Scott Dahab --- Multiplication and Squaring on Pairing-Friendly Fields.pdf; Section 3 (Karatsuba squaring) */ - - const my_Fp6 &a = this->c0, &b = this->c1; - const my_Fp6 asq = a.squared(); - const my_Fp6 bsq = b.squared(); - - return Fp12_2over3over2_model(asq + Fp12_2over3over2_model::mul_by_non_residue(bsq), - (a + b).squared() - asq - bsq); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::squared_complex() const -{ - /* Devegili OhEig Scott Dahab --- Multiplication and Squaring on Pairing-Friendly Fields.pdf; Section 3 (Complex squaring) */ - - const my_Fp6 &a = this->c0, &b = this->c1; - const my_Fp6 ab = a * b; - - return Fp12_2over3over2_model((a + b) * (a + Fp12_2over3over2_model::mul_by_non_residue(b)) - ab - Fp12_2over3over2_model::mul_by_non_residue(ab), - ab + ab); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::inverse() const -{ - /* From "High-Speed Software Implementation of the Optimal Ate Pairing over Barreto-Naehrig Curves"; Algorithm 8 */ - - const my_Fp6 &a = this->c0, &b = this->c1; - const my_Fp6 t0 = a.squared(); - const my_Fp6 t1 = b.squared(); - const my_Fp6 t2 = t0 - Fp12_2over3over2_model::mul_by_non_residue(t1); - const my_Fp6 t3 = t2.inverse(); - const my_Fp6 c0 = a * t3; - const my_Fp6 c1 = - (b * t3); - - return Fp12_2over3over2_model(c0, c1); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::Frobenius_map(uint64_t power) const -{ - return Fp12_2over3over2_model(c0.Frobenius_map(power), - Frobenius_coeffs_c1[power % 12] * c1.Frobenius_map(power)); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::unitary_inverse() const -{ - return Fp12_2over3over2_model(this->c0, - -this->c1); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::cyclotomic_squared() const -{ - /* OLD: naive implementation - return (*this).squared(); - */ - my_Fp2 z0 = this->c0.c0; - my_Fp2 z4 = this->c0.c1; - my_Fp2 z3 = this->c0.c2; - my_Fp2 z2 = this->c1.c0; - my_Fp2 z1 = this->c1.c1; - my_Fp2 z5 = this->c1.c2; - - my_Fp2 t0, t1, t2, t3, t4, t5, tmp; - - // t0 + t1*y = (z0 + z1*y)^2 = a^2 - tmp = z0 * z1; - t0 = (z0 + z1) * (z0 + my_Fp6::non_residue * z1) - tmp - my_Fp6::non_residue * tmp; - t1 = tmp + tmp; - // t2 + t3*y = (z2 + z3*y)^2 = b^2 - tmp = z2 * z3; - t2 = (z2 + z3) * (z2 + my_Fp6::non_residue * z3) - tmp - my_Fp6::non_residue * tmp; - t3 = tmp + tmp; - // t4 + t5*y = (z4 + z5*y)^2 = c^2 - tmp = z4 * z5; - t4 = (z4 + z5) * (z4 + my_Fp6::non_residue * z5) - tmp - my_Fp6::non_residue * tmp; - t5 = tmp + tmp; - - // for A - - // z0 = 3 * t0 - 2 * z0 - z0 = t0 - z0; - z0 = z0 + z0; - z0 = z0 + t0; - // z1 = 3 * t1 + 2 * z1 - z1 = t1 + z1; - z1 = z1 + z1; - z1 = z1 + t1; - - // for B - - // z2 = 3 * (xi * t5) + 2 * z2 - tmp = my_Fp6::non_residue * t5; - z2 = tmp + z2; - z2 = z2 + z2; - z2 = z2 + tmp; - - // z3 = 3 * t4 - 2 * z3 - z3 = t4 - z3; - z3 = z3 + z3; - z3 = z3 + t4; - - // for C - - // z4 = 3 * t2 - 2 * z4 - z4 = t2 - z4; - z4 = z4 + z4; - z4 = z4 + t2; - - // z5 = 3 * t3 + 2 * z5 - z5 = t3 + z5; - z5 = z5 + z5; - z5 = z5 + t3; - - return Fp12_2over3over2_model(my_Fp6(z0,z4,z3),my_Fp6(z2,z1,z5)); -} - -template& modulus> -Fp12_2over3over2_model Fp12_2over3over2_model::mul_by_024(const Fp2_model &ell_0, - const Fp2_model &ell_VW, - const Fp2_model &ell_VV) const -{ - /* OLD: naive implementation - Fp12_2over3over2_model a(my_Fp6(ell_0, my_Fp2::zero(), ell_VV), - my_Fp6(my_Fp2::zero(), ell_VW, my_Fp2::zero())); - - return (*this) * a; - */ - my_Fp2 z0 = this->c0.c0; - my_Fp2 z1 = this->c0.c1; - my_Fp2 z2 = this->c0.c2; - my_Fp2 z3 = this->c1.c0; - my_Fp2 z4 = this->c1.c1; - my_Fp2 z5 = this->c1.c2; - - my_Fp2 x0 = ell_0; - my_Fp2 x2 = ell_VV; - my_Fp2 x4 = ell_VW; - - my_Fp2 t0, t1, t2, s0, T3, T4, D0, D2, D4, S1; - - D0 = z0 * x0; - D2 = z2 * x2; - D4 = z4 * x4; - t2 = z0 + z4; - t1 = z0 + z2; - s0 = z1 + z3 + z5; - - // For z.a_.a_ = z0. - S1 = z1 * x2; - T3 = S1 + D4; - T4 = my_Fp6::non_residue * T3 + D0; - z0 = T4; - - // For z.a_.b_ = z1 - T3 = z5 * x4; - S1 = S1 + T3; - T3 = T3 + D2; - T4 = my_Fp6::non_residue * T3; - T3 = z1 * x0; - S1 = S1 + T3; - T4 = T4 + T3; - z1 = T4; - - // For z.a_.c_ = z2 - t0 = x0 + x2; - T3 = t1 * t0 - D0 - D2; - T4 = z3 * x4; - S1 = S1 + T4; - T3 = T3 + T4; - - // For z.b_.a_ = z3 (z3 needs z2) - t0 = z2 + z4; - z2 = T3; - t1 = x2 + x4; - T3 = t0 * t1 - D2 - D4; - T4 = my_Fp6::non_residue * T3; - T3 = z3 * x0; - S1 = S1 + T3; - T4 = T4 + T3; - z3 = T4; - - // For z.b_.b_ = z4 - T3 = z5 * x2; - S1 = S1 + T3; - T4 = my_Fp6::non_residue * T3; - t0 = x0 + x4; - T3 = t2 * t0 - D0 - D4; - T4 = T4 + T3; - z4 = T4; - - // For z.b_.c_ = z5. - t0 = x0 + x2 + x4; - T3 = s0 * t0 - S1; - z5 = T3; - - return Fp12_2over3over2_model(my_Fp6(z0,z1,z2),my_Fp6(z3,z4,z5)); - -} - -template& modulus, mp_size_t m> -Fp12_2over3over2_model operator^(const Fp12_2over3over2_model &self, const bigint &exponent) -{ - return power >(self, exponent); -} - -template& modulus, mp_size_t m, const bigint& exp_modulus> -Fp12_2over3over2_model operator^(const Fp12_2over3over2_model &self, const Fp_model &exponent) -{ - return self^(exponent.as_bigint()); -} - - -template& modulus> -template -Fp12_2over3over2_model Fp12_2over3over2_model::cyclotomic_exp(const bigint &exponent) const -{ - Fp12_2over3over2_model res = Fp12_2over3over2_model::one(); - - bool found_one = false; - for (int64_t i = m-1; i >= 0; --i) - { - for (int64_t j = GMP_NUMB_BITS - 1; j >= 0; --j) - { - if (found_one) - { - res = res.cyclotomic_squared(); - } - - if (exponent.data[i] & (((mp_limb_t) 1)<& modulus> -std::ostream& operator<<(std::ostream &out, const Fp12_2over3over2_model &el) -{ - out << el.c0 << OUTPUT_SEPARATOR << el.c1; - return out; -} - -template& modulus> -std::istream& operator>>(std::istream &in, Fp12_2over3over2_model &el) -{ - in >> el.c0 >> el.c1; - return in; -} - -template& modulus> -std::ostream& operator<<(std::ostream& out, const std::vector > &v) -{ - out << v.size() << "\n"; - for (const Fp12_2over3over2_model& t : v) - { - out << t << OUTPUT_NEWLINE; - } - - return out; -} - -template& modulus> -std::istream& operator>>(std::istream& in, std::vector > &v) -{ - v.clear(); - - size_t s; - in >> s; - - char b; - in.read(&b, 1); - - v.reserve(s); - - for (size_t i = 0; i < s; ++i) - { - Fp12_2over3over2_model el; - in >> el; - v.emplace_back(el); - } - - return in; -} - -} // libsnark -#endif // FP12_2OVER3OVER2_TCC_ diff --git a/src/snark/libsnark/algebra/fields/fp2.hpp b/src/snark/libsnark/algebra/fields/fp2.hpp deleted file mode 100644 index 276c923e9..000000000 --- a/src/snark/libsnark/algebra/fields/fp2.hpp +++ /dev/null @@ -1,120 +0,0 @@ -/** @file - ***************************************************************************** - Implementation of arithmetic in the finite field F[p^2]. - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef FP2_HPP_ -#define FP2_HPP_ -#include "algebra/fields/fp.hpp" -#include - -namespace libsnark { - -template& modulus> -class Fp2_model; - -template& modulus> -std::ostream& operator<<(std::ostream &, const Fp2_model &); - -template& modulus> -std::istream& operator>>(std::istream &, Fp2_model &); - -/** - * Arithmetic in the field F[p^3]. - * - * Let p := modulus. This interface provides arithmetic for the extension field - * Fp2 = Fp[U]/(U^2-non_residue), where non_residue is in Fp. - * - * ASSUMPTION: p = 1 (mod 6) - */ -template& modulus> -class Fp2_model { -public: - typedef Fp_model my_Fp; - - static bigint<2*n> euler; // (modulus^2-1)/2 - static size_t s; // modulus^2 = 2^s * t + 1 - static bigint<2*n> t; // with t odd - static bigint<2*n> t_minus_1_over_2; // (t-1)/2 - static my_Fp non_residue; // X^4-non_residue irreducible over Fp; used for constructing Fp2 = Fp[X] / (X^2 - non_residue) - static Fp2_model nqr; // a quadratic nonresidue in Fp2 - static Fp2_model nqr_to_t; // nqr^t - static my_Fp Frobenius_coeffs_c1[2]; // non_residue^((modulus^i-1)/2) for i=0,1 - - my_Fp c0, c1; - Fp2_model() {}; - Fp2_model(const my_Fp& c0, const my_Fp& c1) : c0(c0), c1(c1) {}; - - void clear() { c0.clear(); c1.clear(); } - void print() const { printf("c0/c1:\n"); c0.print(); c1.print(); } - - static Fp2_model zero(); - static Fp2_model one(); - static Fp2_model random_element(); - - bool is_zero() const { return c0.is_zero() && c1.is_zero(); } - bool operator==(const Fp2_model &other) const; - bool operator!=(const Fp2_model &other) const; - - Fp2_model operator+(const Fp2_model &other) const; - Fp2_model operator-(const Fp2_model &other) const; - Fp2_model operator*(const Fp2_model &other) const; - Fp2_model operator-() const; - Fp2_model squared() const; // default is squared_complex - Fp2_model inverse() const; - Fp2_model Frobenius_map(uint64_t power) const; - Fp2_model sqrt() const; // HAS TO BE A SQUARE (else does not terminate) - Fp2_model squared_karatsuba() const; - Fp2_model squared_complex() const; - - template - Fp2_model operator^(const bigint &other) const; - - static size_t size_in_bits() { return 2*my_Fp::size_in_bits(); } - static bigint base_field_char() { return modulus; } - - friend std::ostream& operator<< (std::ostream &out, const Fp2_model &el); - friend std::istream& operator>> (std::istream &in, Fp2_model &el); -}; - -template& modulus> -std::ostream& operator<<(std::ostream& out, const std::vector > &v); - -template& modulus> -std::istream& operator>>(std::istream& in, std::vector > &v); - -template& modulus> -Fp2_model operator*(const Fp_model &lhs, const Fp2_model &rhs); - -template& modulus> -bigint<2*n> Fp2_model::euler; - -template& modulus> -size_t Fp2_model::s; - -template& modulus> -bigint<2*n> Fp2_model::t; - -template& modulus> -bigint<2*n> Fp2_model::t_minus_1_over_2; - -template& modulus> -Fp_model Fp2_model::non_residue; - -template& modulus> -Fp2_model Fp2_model::nqr; - -template& modulus> -Fp2_model Fp2_model::nqr_to_t; - -template& modulus> -Fp_model Fp2_model::Frobenius_coeffs_c1[2]; - -} // libsnark -#include "algebra/fields/fp2.tcc" - -#endif // FP2_HPP_ diff --git a/src/snark/libsnark/algebra/fields/fp2.tcc b/src/snark/libsnark/algebra/fields/fp2.tcc deleted file mode 100644 index fb3eacda9..000000000 --- a/src/snark/libsnark/algebra/fields/fp2.tcc +++ /dev/null @@ -1,261 +0,0 @@ -/** @file - ***************************************************************************** - Implementation of arithmetic in the finite field F[p^2]. - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef FP2_TCC_ -#define FP2_TCC_ - -#include "algebra/fields/field_utils.hpp" - -namespace libsnark { - -template& modulus> -Fp2_model Fp2_model::zero() -{ - return Fp2_model(my_Fp::zero(), my_Fp::zero()); -} - -template& modulus> -Fp2_model Fp2_model::one() -{ - return Fp2_model(my_Fp::one(), my_Fp::zero()); -} - -template& modulus> -Fp2_model Fp2_model::random_element() -{ - Fp2_model r; - r.c0 = my_Fp::random_element(); - r.c1 = my_Fp::random_element(); - - return r; -} - -template& modulus> -bool Fp2_model::operator==(const Fp2_model &other) const -{ - return (this->c0 == other.c0 && this->c1 == other.c1); -} - -template& modulus> -bool Fp2_model::operator!=(const Fp2_model &other) const -{ - return !(operator==(other)); -} - -template& modulus> -Fp2_model Fp2_model::operator+(const Fp2_model &other) const -{ - return Fp2_model(this->c0 + other.c0, - this->c1 + other.c1); -} - -template& modulus> -Fp2_model Fp2_model::operator-(const Fp2_model &other) const -{ - return Fp2_model(this->c0 - other.c0, - this->c1 - other.c1); -} - -template& modulus> -Fp2_model operator*(const Fp_model &lhs, const Fp2_model &rhs) -{ - return Fp2_model(lhs*rhs.c0, - lhs*rhs.c1); -} - -template& modulus> -Fp2_model Fp2_model::operator*(const Fp2_model &other) const -{ - /* Devegili OhEig Scott Dahab --- Multiplication and Squaring on Pairing-Friendly Fields.pdf; Section 3 (Karatsuba) */ - const my_Fp - &A = other.c0, &B = other.c1, - &a = this->c0, &b = this->c1; - const my_Fp aA = a * A; - const my_Fp bB = b * B; - - return Fp2_model(aA + non_residue * bB, - (a + b)*(A+B) - aA - bB); -} - -template& modulus> -Fp2_model Fp2_model::operator-() const -{ - return Fp2_model(-this->c0, - -this->c1); -} - -template& modulus> -Fp2_model Fp2_model::squared() const -{ - return squared_complex(); -} - -template& modulus> -Fp2_model Fp2_model::squared_karatsuba() const -{ - /* Devegili OhEig Scott Dahab --- Multiplication and Squaring on Pairing-Friendly Fields.pdf; Section 3 (Karatsuba squaring) */ - const my_Fp &a = this->c0, &b = this->c1; - const my_Fp asq = a.squared(); - const my_Fp bsq = b.squared(); - - return Fp2_model(asq + non_residue * bsq, - (a + b).squared() - asq - bsq); -} - -template& modulus> -Fp2_model Fp2_model::squared_complex() const -{ - /* Devegili OhEig Scott Dahab --- Multiplication and Squaring on Pairing-Friendly Fields.pdf; Section 3 (Complex squaring) */ - const my_Fp &a = this->c0, &b = this->c1; - const my_Fp ab = a * b; - - return Fp2_model((a + b) * (a + non_residue * b) - ab - non_residue * ab, - ab + ab); -} - -template& modulus> -Fp2_model Fp2_model::inverse() const -{ - const my_Fp &a = this->c0, &b = this->c1; - - /* From "High-Speed Software Implementation of the Optimal Ate Pairing over Barreto-Naehrig Curves"; Algorithm 8 */ - const my_Fp t0 = a.squared(); - const my_Fp t1 = b.squared(); - const my_Fp t2 = t0 - non_residue * t1; - const my_Fp t3 = t2.inverse(); - const my_Fp c0 = a * t3; - const my_Fp c1 = - (b * t3); - - return Fp2_model(c0, c1); -} - -template& modulus> -Fp2_model Fp2_model::Frobenius_map(uint64_t power) const -{ - return Fp2_model(c0, - Frobenius_coeffs_c1[power % 2] * c1); -} - -template& modulus> -Fp2_model Fp2_model::sqrt() const -{ - if (is_zero()) { - return *this; - } - - Fp2_model one = Fp2_model::one(); - - size_t v = Fp2_model::s; - Fp2_model z = Fp2_model::nqr_to_t; - Fp2_model w = (*this)^Fp2_model::t_minus_1_over_2; - Fp2_model x = (*this) * w; - Fp2_model b = x * w; // b = (*this)^t - - - // check if square with euler's criterion - Fp2_model check = b; - for (size_t i = 0; i < v-1; ++i) - { - check = check.squared(); - } - if (check != one) - { - assert_except(0); - } - - - // compute square root with Tonelli--Shanks - // (does not terminate if not a square!) - - while (b != one) - { - size_t m = 0; - Fp2_model b2m = b; - while (b2m != one) - { - /* invariant: b2m = b^(2^m) after entering this loop */ - b2m = b2m.squared(); - m += 1; - } - - int j = v-m-1; - w = z; - while (j > 0) - { - w = w.squared(); - --j; - } // w = z^2^(v-m-1) - - z = w.squared(); - b = b * z; - x = x * w; - v = m; - } - - return x; -} - -template& modulus> -template -Fp2_model Fp2_model::operator^(const bigint &pow) const -{ - return power, m>(*this, pow); -} - -template& modulus> -std::ostream& operator<<(std::ostream &out, const Fp2_model &el) -{ - out << el.c0 << OUTPUT_SEPARATOR << el.c1; - return out; -} - -template& modulus> -std::istream& operator>>(std::istream &in, Fp2_model &el) -{ - in >> el.c0 >> el.c1; - return in; -} - -template& modulus> -std::ostream& operator<<(std::ostream& out, const std::vector > &v) -{ - out << v.size() << "\n"; - for (const Fp2_model& t : v) - { - out << t << OUTPUT_NEWLINE; - } - - return out; -} - -template& modulus> -std::istream& operator>>(std::istream& in, std::vector > &v) -{ - v.clear(); - - size_t s; - in >> s; - - char b; - in.read(&b, 1); - - v.reserve(s); - - for (size_t i = 0; i < s; ++i) - { - Fp2_model el; - in >> el; - v.emplace_back(el); - } - - return in; -} - -} // libsnark -#endif // FP2_TCC_ diff --git a/src/snark/libsnark/algebra/fields/fp6_3over2.hpp b/src/snark/libsnark/algebra/fields/fp6_3over2.hpp deleted file mode 100644 index 912c58a74..000000000 --- a/src/snark/libsnark/algebra/fields/fp6_3over2.hpp +++ /dev/null @@ -1,104 +0,0 @@ -/** @file - ***************************************************************************** - Declaration of arithmetic in the finite field F[(p^2)^3] - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef FP6_3OVER2_HPP_ -#define FP6_3OVER2_HPP_ -#include "algebra/fields/fp.hpp" -#include "algebra/fields/fp2.hpp" -#include - -namespace libsnark { - -template& modulus> -class Fp6_3over2_model; - -template& modulus> -std::ostream& operator<<(std::ostream &, const Fp6_3over2_model &); - -template& modulus> -std::istream& operator>>(std::istream &, Fp6_3over2_model &); - -/** - * Arithmetic in the finite field F[(p^2)^3]. - * - * Let p := modulus. This interface provides arithmetic for the extension field - * Fp6 = Fp2[V]/(V^3-non_residue) where non_residue is in Fp. - * - * ASSUMPTION: p = 1 (mod 6) - */ -template& modulus> -class Fp6_3over2_model { -public: - typedef Fp_model my_Fp; - typedef Fp2_model my_Fp2; - - static my_Fp2 non_residue; - static my_Fp2 Frobenius_coeffs_c1[6]; // non_residue^((modulus^i-1)/3) for i=0,1,2,3,4,5 - static my_Fp2 Frobenius_coeffs_c2[6]; // non_residue^((2*modulus^i-2)/3) for i=0,1,2,3,4,5 - - my_Fp2 c0, c1, c2; - Fp6_3over2_model() {}; - Fp6_3over2_model(const my_Fp2& c0, const my_Fp2& c1, const my_Fp2& c2) : c0(c0), c1(c1), c2(c2) {}; - - void clear() { c0.clear(); c1.clear(); c2.clear(); } - void print() const { printf("c0/c1/c2:\n"); c0.print(); c1.print(); c2.print(); } - - static Fp6_3over2_model zero(); - static Fp6_3over2_model one(); - static Fp6_3over2_model random_element(); - - bool is_zero() const { return c0.is_zero() && c1.is_zero() && c2.is_zero(); } - bool operator==(const Fp6_3over2_model &other) const; - bool operator!=(const Fp6_3over2_model &other) const; - - Fp6_3over2_model operator+(const Fp6_3over2_model &other) const; - Fp6_3over2_model operator-(const Fp6_3over2_model &other) const; - Fp6_3over2_model operator*(const Fp6_3over2_model &other) const; - Fp6_3over2_model operator-() const; - Fp6_3over2_model squared() const; - Fp6_3over2_model inverse() const; - Fp6_3over2_model Frobenius_map(uint64_t power) const; - - static my_Fp2 mul_by_non_residue(const my_Fp2 &elt); - - template - Fp6_3over2_model operator^(const bigint &other) const; - - static bigint base_field_char() { return modulus; } - static size_t extension_degree() { return 6; } - - friend std::ostream& operator<< (std::ostream &out, const Fp6_3over2_model &el); - friend std::istream& operator>> (std::istream &in, Fp6_3over2_model &el); -}; - -template& modulus> -std::ostream& operator<<(std::ostream& out, const std::vector > &v); - -template& modulus> -std::istream& operator>>(std::istream& in, std::vector > &v); - -template& modulus> -Fp6_3over2_model operator*(const Fp_model &lhs, const Fp6_3over2_model &rhs); - -template& modulus> -Fp6_3over2_model operator*(const Fp2_model &lhs, const Fp6_3over2_model &rhs); - -template& modulus> -Fp2_model Fp6_3over2_model::non_residue; - -template& modulus> -Fp2_model Fp6_3over2_model::Frobenius_coeffs_c1[6]; - -template& modulus> -Fp2_model Fp6_3over2_model::Frobenius_coeffs_c2[6]; - -} // libsnark -#include "algebra/fields/fp6_3over2.tcc" - -#endif // FP6_3OVER2_HPP_ diff --git a/src/snark/libsnark/algebra/fields/fp6_3over2.tcc b/src/snark/libsnark/algebra/fields/fp6_3over2.tcc deleted file mode 100644 index 86b864ef0..000000000 --- a/src/snark/libsnark/algebra/fields/fp6_3over2.tcc +++ /dev/null @@ -1,216 +0,0 @@ -/** @file - ***************************************************************************** - Implementation of arithmetic in the finite field F[(p^2)^3]. - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef FP6_3OVER2_TCC_ -#define FP6_3OVER2_TCC_ -#include "algebra/fields/field_utils.hpp" - -namespace libsnark { - -template& modulus> -Fp2_model Fp6_3over2_model::mul_by_non_residue(const Fp2_model &elt) -{ - return Fp2_model(non_residue * elt); -} - -template& modulus> -Fp6_3over2_model Fp6_3over2_model::zero() -{ - return Fp6_3over2_model(my_Fp2::zero(), my_Fp2::zero(), my_Fp2::zero()); -} - -template& modulus> -Fp6_3over2_model Fp6_3over2_model::one() -{ - return Fp6_3over2_model(my_Fp2::one(), my_Fp2::zero(), my_Fp2::zero()); -} - -template& modulus> -Fp6_3over2_model Fp6_3over2_model::random_element() -{ - Fp6_3over2_model r; - r.c0 = my_Fp2::random_element(); - r.c1 = my_Fp2::random_element(); - r.c2 = my_Fp2::random_element(); - - return r; -} - -template& modulus> -bool Fp6_3over2_model::operator==(const Fp6_3over2_model &other) const -{ - return (this->c0 == other.c0 && this->c1 == other.c1 && this->c2 == other.c2); -} - -template& modulus> -bool Fp6_3over2_model::operator!=(const Fp6_3over2_model &other) const -{ - return !(operator==(other)); -} - -template& modulus> -Fp6_3over2_model Fp6_3over2_model::operator+(const Fp6_3over2_model &other) const -{ - return Fp6_3over2_model(this->c0 + other.c0, - this->c1 + other.c1, - this->c2 + other.c2); -} - -template& modulus> -Fp6_3over2_model Fp6_3over2_model::operator-(const Fp6_3over2_model &other) const -{ - return Fp6_3over2_model(this->c0 - other.c0, - this->c1 - other.c1, - this->c2 - other.c2); -} - -template& modulus> -Fp6_3over2_model operator*(const Fp_model &lhs, const Fp6_3over2_model &rhs) -{ - return Fp6_3over2_model(lhs*rhs.c0, - lhs*rhs.c1, - lhs*rhs.c2); -} - -template& modulus> -Fp6_3over2_model operator*(const Fp2_model &lhs, const Fp6_3over2_model &rhs) -{ - return Fp6_3over2_model(lhs*rhs.c0, - lhs*rhs.c1, - lhs*rhs.c2); -} - -template& modulus> -Fp6_3over2_model Fp6_3over2_model::operator*(const Fp6_3over2_model &other) const -{ - /* Devegili OhEig Scott Dahab --- Multiplication and Squaring on Pairing-Friendly Fields.pdf; Section 4 (Karatsuba) */ - - const my_Fp2 &A = other.c0, &B = other.c1, &C = other.c2, - &a = this->c0, &b = this->c1, &c = this->c2; - const my_Fp2 aA = a*A; - const my_Fp2 bB = b*B; - const my_Fp2 cC = c*C; - - return Fp6_3over2_model(aA + Fp6_3over2_model::mul_by_non_residue((b+c)*(B+C)-bB-cC), - (a+b)*(A+B)-aA-bB+Fp6_3over2_model::mul_by_non_residue(cC), - (a+c)*(A+C)-aA+bB-cC); -} - -template& modulus> -Fp6_3over2_model Fp6_3over2_model::operator-() const -{ - return Fp6_3over2_model(-this->c0, - -this->c1, - -this->c2); -} - -template& modulus> -Fp6_3over2_model Fp6_3over2_model::squared() const -{ - /* Devegili OhEig Scott Dahab --- Multiplication and Squaring on Pairing-Friendly Fields.pdf; Section 4 (CH-SQR2) */ - - const my_Fp2 &a = this->c0, &b = this->c1, &c = this->c2; - const my_Fp2 s0 = a.squared(); - const my_Fp2 ab = a*b; - const my_Fp2 s1 = ab + ab; - const my_Fp2 s2 = (a - b + c).squared(); - const my_Fp2 bc = b*c; - const my_Fp2 s3 = bc + bc; - const my_Fp2 s4 = c.squared(); - - return Fp6_3over2_model(s0 + Fp6_3over2_model::mul_by_non_residue(s3), - s1 + Fp6_3over2_model::mul_by_non_residue(s4), - s1 + s2 + s3 - s0 - s4); -} - -template& modulus> -Fp6_3over2_model Fp6_3over2_model::inverse() const -{ - /* From "High-Speed Software Implementation of the Optimal Ate Pairing over Barreto-Naehrig Curves"; Algorithm 17 */ - - const my_Fp2 &a = this->c0, &b = this->c1, &c = this->c2; - const my_Fp2 t0 = a.squared(); - const my_Fp2 t1 = b.squared(); - const my_Fp2 t2 = c.squared(); - const my_Fp2 t3 = a*b; - const my_Fp2 t4 = a*c; - const my_Fp2 t5 = b*c; - const my_Fp2 c0 = t0 - Fp6_3over2_model::mul_by_non_residue(t5); - const my_Fp2 c1 = Fp6_3over2_model::mul_by_non_residue(t2) - t3; - const my_Fp2 c2 = t1 - t4; // typo in paper referenced above. should be "-" as per Scott, but is "*" - const my_Fp2 t6 = (a * c0 + Fp6_3over2_model::mul_by_non_residue((c * c1 + b * c2))).inverse(); - return Fp6_3over2_model(t6 * c0, t6 * c1, t6 * c2); -} - -template& modulus> -Fp6_3over2_model Fp6_3over2_model::Frobenius_map(uint64_t power) const -{ - return Fp6_3over2_model(c0.Frobenius_map(power), - Frobenius_coeffs_c1[power % 6] * c1.Frobenius_map(power), - Frobenius_coeffs_c2[power % 6] * c2.Frobenius_map(power)); -} - -template& modulus> -template -Fp6_3over2_model Fp6_3over2_model::operator^(const bigint &pow) const -{ - return power, m>(*this, pow); -} - -template& modulus> -std::ostream& operator<<(std::ostream &out, const Fp6_3over2_model &el) -{ - out << el.c0 << OUTPUT_SEPARATOR << el.c1 << OUTPUT_SEPARATOR << el.c2; - return out; -} - -template& modulus> -std::istream& operator>>(std::istream &in, Fp6_3over2_model &el) -{ - in >> el.c0 >> el.c1 >> el.c2; - return in; -} - -template& modulus> -std::ostream& operator<<(std::ostream& out, const std::vector > &v) -{ - out << v.size() << "\n"; - for (const Fp6_3over2_model& t : v) - { - out << t << OUTPUT_NEWLINE; - } - - return out; -} - -template& modulus> -std::istream& operator>>(std::istream& in, std::vector > &v) -{ - v.clear(); - - size_t s; - in >> s; - - char b; - in.read(&b, 1); - - v.reserve(s); - - for (size_t i = 0; i < s; ++i) - { - Fp6_3over2_model el; - in >> el; - v.emplace_back(el); - } - - return in; -} - -} // libsnark -#endif // FP6_3_OVER_2_TCC_ diff --git a/src/snark/libsnark/algebra/fields/fp_aux.tcc b/src/snark/libsnark/algebra/fields/fp_aux.tcc deleted file mode 100644 index 7f8a3eadf..000000000 --- a/src/snark/libsnark/algebra/fields/fp_aux.tcc +++ /dev/null @@ -1,389 +0,0 @@ -/** @file - ***************************************************************************** - Assembly code snippets for F[p] finite field arithmetic, used by fp.tcc . - Specific to x86-64, and used only if USE_ASM is defined. - On other architectures or without USE_ASM, fp.tcc uses a portable - C++ implementation instead. - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef FP_AUX_TCC_ -#define FP_AUX_TCC_ - -namespace libsnark { - -#define STR_HELPER(x) #x -#define STR(x) STR_HELPER(x) - -/* addq is faster than adcq, even if preceded by clc */ -#define ADD_FIRSTADD \ - "movq (%[B]), %%rax \n\t" \ - "addq %%rax, (%[A]) \n\t" - -#define ADD_NEXTADD(ofs) \ - "movq " STR(ofs) "(%[B]), %%rax \n\t" \ - "adcq %%rax, " STR(ofs) "(%[A]) \n\t" - -#define ADD_CMP(ofs) \ - "movq " STR(ofs) "(%[mod]), %%rax \n\t" \ - "cmpq %%rax, " STR(ofs) "(%[A]) \n\t" \ - "jb done%= \n\t" \ - "ja subtract%= \n\t" - -#define ADD_FIRSTSUB \ - "movq (%[mod]), %%rax \n\t" \ - "subq %%rax, (%[A]) \n\t" - -#define ADD_FIRSTSUB \ - "movq (%[mod]), %%rax \n\t" \ - "subq %%rax, (%[A]) \n\t" - -#define ADD_NEXTSUB(ofs) \ - "movq " STR(ofs) "(%[mod]), %%rax \n\t" \ - "sbbq %%rax, " STR(ofs) "(%[A]) \n\t" - -#define SUB_FIRSTSUB \ - "movq (%[B]), %%rax\n\t" \ - "subq %%rax, (%[A])\n\t" - -#define SUB_NEXTSUB(ofs) \ - "movq " STR(ofs) "(%[B]), %%rax\n\t" \ - "sbbq %%rax, " STR(ofs) "(%[A])\n\t" - -#define SUB_FIRSTADD \ - "movq (%[mod]), %%rax\n\t" \ - "addq %%rax, (%[A])\n\t" - -#define SUB_NEXTADD(ofs) \ - "movq " STR(ofs) "(%[mod]), %%rax\n\t" \ - "adcq %%rax, " STR(ofs) "(%[A])\n\t" - -#define MONT_CMP(ofs) \ - "movq " STR(ofs) "(%[M]), %%rax \n\t" \ - "cmpq %%rax, " STR(ofs) "(%[tmp]) \n\t" \ - "jb done%= \n\t" \ - "ja subtract%= \n\t" - -#define MONT_FIRSTSUB \ - "movq (%[M]), %%rax \n\t" \ - "subq %%rax, (%[tmp]) \n\t" - -#define MONT_NEXTSUB(ofs) \ - "movq " STR(ofs) "(%[M]), %%rax \n\t" \ - "sbbq %%rax, " STR(ofs) "(%[tmp]) \n\t" - -/* - The x86-64 Montgomery multiplication here is similar - to Algorithm 2 (CIOS method) in http://eprint.iacr.org/2012/140.pdf - and the PowerPC pseudocode of gmp-ecm library (c) Paul Zimmermann and Alexander Kruppa - (see comments on top of powerpc64/mulredc.m4). -*/ - -#define MONT_PRECOMPUTE \ - "xorq %[cy], %[cy] \n\t" \ - "movq 0(%[A]), %%rax \n\t" \ - "mulq 0(%[B]) \n\t" \ - "movq %%rax, %[T0] \n\t" \ - "movq %%rdx, %[T1] # T1:T0 <- A[0] * B[0] \n\t" \ - "mulq %[inv] \n\t" \ - "movq %%rax, %[u] # u <- T0 * inv \n\t" \ - "mulq 0(%[M]) \n\t" \ - "addq %[T0], %%rax \n\t" \ - "adcq %%rdx, %[T1] \n\t" \ - "adcq $0, %[cy] # cy:T1 <- (M[0]*u + T1 * b + T0) / b\n\t" - -#define MONT_FIRSTITER(j) \ - "xorq %[T0], %[T0] \n\t" \ - "movq 0(%[A]), %%rax \n\t" \ - "mulq " STR((j*8)) "(%[B]) \n\t" \ - "addq %[T1], %%rax \n\t" \ - "movq %%rax, " STR(((j-1)*8)) "(%[tmp]) \n\t" \ - "adcq $0, %%rdx \n\t" \ - "movq %%rdx, %[T1] # now T1:tmp[j-1] <-- X[0] * Y[j] + T1\n\t" \ - "movq " STR((j*8)) "(%[M]), %%rax \n\t" \ - "mulq %[u] \n\t" \ - "addq %%rax, " STR(((j-1)*8)) "(%[tmp]) \n\t" \ - "adcq %[cy], %%rdx \n\t" \ - "adcq $0, %[T0] \n\t" \ - "xorq %[cy], %[cy] \n\t" \ - "addq %%rdx, %[T1] \n\t" \ - "adcq %[T0], %[cy] # cy:T1:tmp[j-1] <---- (X[0] * Y[j] + T1) + (M[j] * u + cy * b) \n\t" - -#define MONT_ITERFIRST(i) \ - "xorq %[cy], %[cy] \n\t" \ - "movq " STR((i*8)) "(%[A]), %%rax \n\t" \ - "mulq 0(%[B]) \n\t" \ - "addq 0(%[tmp]), %%rax \n\t" \ - "adcq 8(%[tmp]), %%rdx \n\t" \ - "adcq $0, %[cy] \n\t" \ - "movq %%rax, %[T0] \n\t" \ - "movq %%rdx, %[T1] # cy:T1:T0 <- A[i] * B[0] + tmp[1] * b + tmp[0]\n\t" \ - "mulq %[inv] \n\t" \ - "movq %%rax, %[u] # u <- T0 * inv\n\t" \ - "mulq 0(%[M]) \n\t" \ - "addq %[T0], %%rax \n\t" \ - "adcq %%rdx, %[T1] \n\t" \ - "adcq $0, %[cy] # cy:T1 <- (M[0]*u + cy * b * b + T1 * b + T0) / b\n\t" - -#define MONT_ITERITER(i, j) \ - "xorq %[T0], %[T0] \n\t" \ - "movq " STR((i*8)) "(%[A]), %%rax \n\t" \ - "mulq " STR((j*8)) "(%[B]) \n\t" \ - "addq %[T1], %%rax \n\t" \ - "movq %%rax, " STR(((j-1)*8)) "(%[tmp]) \n\t" \ - "adcq $0, %%rdx \n\t" \ - "movq %%rdx, %[T1] # now T1:tmp[j-1] <-- X[i] * Y[j] + T1 \n\t" \ - "movq " STR((j*8)) "(%[M]), %%rax \n\t" \ - "mulq %[u] \n\t" \ - "addq %%rax, " STR(((j-1)*8)) "(%[tmp]) \n\t" \ - "adcq %[cy], %%rdx \n\t" \ - "adcq $0, %[T0] \n\t" \ - "xorq %[cy], %[cy] \n\t" \ - "addq %%rdx, %[T1] \n\t" \ - "adcq %[T0], %[cy] # cy:T1:tmp[j-1] <-- (X[i] * Y[j] + T1) + M[j] * u + cy * b \n\t" \ - "addq " STR(((j+1)*8)) "(%[tmp]), %[T1] \n\t" \ - "adcq $0, %[cy] # cy:T1:tmp[j-1] <-- (X[i] * Y[j] + T1) + M[j] * u + (tmp[j+1] + cy) * b \n\t" - -#define MONT_FINALIZE(j) \ - "movq %[T1], " STR((j*8)) "(%[tmp]) \n\t" \ - "movq %[cy], " STR(((j+1)*8)) "(%[tmp]) \n\t" - -/* - Comba multiplication and squaring routines are based on the - public-domain tomsfastmath library by Tom St Denis - - - - Compared to the above, we save 5-20% of cycles by using careful register - renaming to implement Comba forward operation. - */ - -#define COMBA_3_BY_3_MUL(c0_, c1_, c2_, res_, A_, B_) \ - asm volatile ( \ - "movq 0(%[A]), %%rax \n\t" \ - "mulq 0(%[B]) \n\t" \ - "movq %%rax, 0(%[res]) \n\t" \ - "movq %%rdx, %[c0] \n\t" \ - \ - "xorq %[c1], %[c1] \n\t" \ - "movq 0(%[A]), %%rax \n\t" \ - "mulq 8(%[B]) \n\t" \ - "addq %%rax, %[c0] \n\t" \ - "adcq %%rdx, %[c1] \n\t" \ - \ - "xorq %[c2], %[c2] \n\t" \ - "movq 8(%[A]), %%rax \n\t" \ - "mulq 0(%[B]) \n\t" \ - "addq %%rax, %[c0] \n\t" \ - "movq %[c0], 8(%[res]) \n\t" \ - "adcq %%rdx, %[c1] \n\t" \ - "adcq $0, %[c2] \n\t" \ - \ - "// register renaming (c1, c2, c0)\n\t" \ - "xorq %[c0], %[c0] \n\t" \ - "movq 0(%[A]), %%rax \n\t" \ - "mulq 16(%[B]) \n\t" \ - "addq %%rax, %[c1] \n\t" \ - "adcq %%rdx, %[c2] \n\t" \ - "adcq $0, %[c0] \n\t" \ - \ - "movq 8(%[A]), %%rax \n\t" \ - "mulq 8(%[B]) \n\t" \ - "addq %%rax, %[c1] \n\t" \ - "adcq %%rdx, %[c2] \n\t" \ - "adcq $0, %[c0] \n\t" \ - \ - "movq 16(%[A]), %%rax \n\t" \ - "mulq 0(%[B]) \n\t" \ - "addq %%rax, %[c1] \n\t" \ - "movq %[c1], 16(%[res]) \n\t" \ - "adcq %%rdx, %[c2] \n\t" \ - "adcq $0, %[c0] \n\t" \ - \ - "// register renaming (c2, c0, c1)\n\t" \ - "xorq %[c1], %[c1] \n\t" \ - "movq 8(%[A]), %%rax \n\t" \ - "mulq 16(%[B]) \n\t" \ - "addq %%rax, %[c2] \n\t" \ - "adcq %%rdx, %[c0] \n\t" \ - "adcq $0, %[c1] \n\t" \ - \ - "movq 16(%[A]), %%rax \n\t" \ - "mulq 8(%[B]) \n\t" \ - "addq %%rax, %[c2] \n\t" \ - "movq %[c2], 24(%[res]) \n\t" \ - "adcq %%rdx, %[c0] \n\t" \ - "adcq $0, %[c1] \n\t" \ - \ - "// register renaming (c0, c1, c2)\n\t" \ - "xorq %[c2], %[c2] \n\t" \ - "movq 16(%[A]), %%rax \n\t" \ - "mulq 16(%[B]) \n\t" \ - "addq %%rax, %[c0] \n\t" \ - "movq %[c0], 32(%[res]) \n\t" \ - "adcq %%rdx, %[c1] \n\t" \ - "movq %[c1], 40(%[res]) \n\t" \ - : [c0] "=&r" (c0_), [c1] "=&r" (c1_), [c2] "=&r" (c2_) \ - : [res] "r" (res_), [A] "r" (A_), [B] "r" (B_) \ - : "%rax", "%rdx", "cc", "memory") - -#define COMBA_3_BY_3_SQR(c0_, c1_, c2_, res_, A_) \ - asm volatile ( \ - "xorq %[c1], %[c1] \n\t" \ - "xorq %[c2], %[c2] \n\t" \ - "movq 0(%[A]), %%rax \n\t" \ - "mulq %%rax \n\t" \ - "movq %%rax, 0(%[res]) \n\t" \ - "movq %%rdx, %[c0] \n\t" \ - \ - "movq 0(%[A]), %%rax \n\t" \ - "mulq 8(%[A]) \n\t" \ - "addq %%rax, %[c0] \n\t" \ - "adcq %%rdx, %[c1] \n\t" \ - "addq %%rax, %[c0] \n\t" \ - "movq %[c0], 8(%[res]) \n\t" \ - "adcq %%rdx, %[c1] \n\t" \ - "adcq $0, %[c2] \n\t" \ - \ - "// register renaming (c1, c2, c0)\n\t" \ - "movq 0(%[A]), %%rax \n\t" \ - "xorq %[c0], %[c0] \n\t" \ - "mulq 16(%[A]) \n\t" \ - "addq %%rax, %[c1] \n\t" \ - "adcq %%rdx, %[c2] \n\t" \ - "adcq $0, %[c0] \n\t" \ - "addq %%rax, %[c1] \n\t" \ - "adcq %%rdx, %[c2] \n\t" \ - "adcq $0, %[c0] \n\t" \ - \ - "movq 8(%[A]), %%rax \n\t" \ - "mulq %%rax \n\t" \ - "addq %%rax, %[c1] \n\t" \ - "movq %[c1], 16(%[res]) \n\t" \ - "adcq %%rdx, %[c2] \n\t" \ - "adcq $0, %[c0] \n\t" \ - \ - "// register renaming (c2, c0, c1)\n\t" \ - "movq 8(%[A]), %%rax \n\t" \ - "xorq %[c1], %[c1] \n\t" \ - "mulq 16(%[A]) \n\t" \ - "addq %%rax, %[c2] \n\t" \ - "adcq %%rdx, %[c0] \n\t" \ - "adcq $0, %[c1] \n\t" \ - "addq %%rax, %[c2] \n\t" \ - "movq %[c2], 24(%[res]) \n\t" \ - "adcq %%rdx, %[c0] \n\t" \ - "adcq $0, %[c1] \n\t" \ - \ - "// register renaming (c0, c1, c2)\n\t" \ - "movq 16(%[A]), %%rax \n\t" \ - "mulq %%rax \n\t" \ - "addq %%rax, %[c0] \n\t" \ - "movq %[c0], 32(%[res]) \n\t" \ - "adcq %%rdx, %[c1] \n\t" \ - "movq %[c1], 40(%[res]) \n\t" \ - \ - : [c0] "=&r" (c0_), [c1] "=&r" (c1_), [c2] "=&r" (c2_) \ - : [res] "r" (res_), [A] "r" (A_) \ - : "%rax", "%rdx", "cc", "memory") - -/* - The Montgomery reduction here is based on Algorithm 14.32 in - Handbook of Applied Cryptography - . - */ -#define REDUCE_6_LIMB_PRODUCT(k_, tmp1_, tmp2_, tmp3_, inv_, res_, mod_) \ - __asm__ volatile \ - ("///////////////////////////////////\n\t" \ - "movq 0(%[res]), %%rax \n\t" \ - "mulq %[modprime] \n\t" \ - "movq %%rax, %[k] \n\t" \ - \ - "movq (%[mod]), %%rax \n\t" \ - "mulq %[k] \n\t" \ - "movq %%rax, %[tmp1] \n\t" \ - "movq %%rdx, %[tmp2] \n\t" \ - \ - "xorq %[tmp3], %[tmp3] \n\t" \ - "movq 8(%[mod]), %%rax \n\t" \ - "mulq %[k] \n\t" \ - "addq %[tmp1], 0(%[res]) \n\t" \ - "adcq %%rax, %[tmp2] \n\t" \ - "adcq %%rdx, %[tmp3] \n\t" \ - \ - "xorq %[tmp1], %[tmp1] \n\t" \ - "movq 16(%[mod]), %%rax \n\t" \ - "mulq %[k] \n\t" \ - "addq %[tmp2], 8(%[res]) \n\t" \ - "adcq %%rax, %[tmp3] \n\t" \ - "adcq %%rdx, %[tmp1] \n\t" \ - \ - "addq %[tmp3], 16(%[res]) \n\t" \ - "adcq %[tmp1], 24(%[res]) \n\t" \ - "adcq $0, 32(%[res]) \n\t" \ - "adcq $0, 40(%[res]) \n\t" \ - \ - "///////////////////////////////////\n\t" \ - "movq 8(%[res]), %%rax \n\t" \ - "mulq %[modprime] \n\t" \ - "movq %%rax, %[k] \n\t" \ - \ - "movq (%[mod]), %%rax \n\t" \ - "mulq %[k] \n\t" \ - "movq %%rax, %[tmp1] \n\t" \ - "movq %%rdx, %[tmp2] \n\t" \ - \ - "xorq %[tmp3], %[tmp3] \n\t" \ - "movq 8(%[mod]), %%rax \n\t" \ - "mulq %[k] \n\t" \ - "addq %[tmp1], 8(%[res]) \n\t" \ - "adcq %%rax, %[tmp2] \n\t" \ - "adcq %%rdx, %[tmp3] \n\t" \ - \ - "xorq %[tmp1], %[tmp1] \n\t" \ - "movq 16(%[mod]), %%rax \n\t" \ - "mulq %[k] \n\t" \ - "addq %[tmp2], 16(%[res]) \n\t" \ - "adcq %%rax, %[tmp3] \n\t" \ - "adcq %%rdx, %[tmp1] \n\t" \ - \ - "addq %[tmp3], 24(%[res]) \n\t" \ - "adcq %[tmp1], 32(%[res]) \n\t" \ - "adcq $0, 40(%[res]) \n\t" \ - \ - "///////////////////////////////////\n\t" \ - "movq 16(%[res]), %%rax \n\t" \ - "mulq %[modprime] \n\t" \ - "movq %%rax, %[k] \n\t" \ - \ - "movq (%[mod]), %%rax \n\t" \ - "mulq %[k] \n\t" \ - "movq %%rax, %[tmp1] \n\t" \ - "movq %%rdx, %[tmp2] \n\t" \ - \ - "xorq %[tmp3], %[tmp3] \n\t" \ - "movq 8(%[mod]), %%rax \n\t" \ - "mulq %[k] \n\t" \ - "addq %[tmp1], 16(%[res]) \n\t" \ - "adcq %%rax, %[tmp2] \n\t" \ - "adcq %%rdx, %[tmp3] \n\t" \ - \ - "xorq %[tmp1], %[tmp1] \n\t" \ - "movq 16(%[mod]), %%rax \n\t" \ - "mulq %[k] \n\t" \ - "addq %[tmp2], 24(%[res]) \n\t" \ - "adcq %%rax, %[tmp3] \n\t" \ - "adcq %%rdx, %[tmp1] \n\t" \ - \ - "addq %[tmp3], 32(%[res]) \n\t" \ - "adcq %[tmp1], 40(%[res]) \n\t" \ - : [k] "=&r" (k_), [tmp1] "=&r" (tmp1_), [tmp2] "=&r" (tmp2_), [tmp3] "=&r" (tmp3_) \ - : [modprime] "r" (inv_), [res] "r" (res_), [mod] "r" (mod_) \ - : "%rax", "%rdx", "cc", "memory") - -} // libsnark -#endif // FP_AUX_TCC_ diff --git a/src/snark/libsnark/algebra/fields/tests/test_bigint.cpp b/src/snark/libsnark/algebra/fields/tests/test_bigint.cpp deleted file mode 100644 index 24832ed51..000000000 --- a/src/snark/libsnark/algebra/fields/tests/test_bigint.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#include "algebra/fields/bigint.hpp" - -#include - -using namespace libsnark; - -TEST(algebra, bigint) -{ - static_assert(GMP_NUMB_BITS == 64, "GMP limb not 64-bit"); - - const char *b1_decimal = "76749407"; - const char *b2_decimal = "435020359732196472065729437602"; - const char *b3_decimal = "33387554642372758038536799358397002014"; - const char *b2_binary = "0000000000000000000000000000010101111101101000000110100001011010" - "1101101010001001000001101000101000100110011001110001111110100010"; - - bigint<1> b0 = bigint<1>(UINT64_C(0)); - bigint<1> b1 = bigint<1>(b1_decimal); - bigint<2> b2 = bigint<2>(b2_decimal); - - EXPECT_EQ(b0.as_uint64(), UINT64_C(0)); - EXPECT_TRUE(b0.is_zero()); - EXPECT_EQ(b1.as_uint64(), UINT64_C(76749407)); - EXPECT_FALSE(b1.is_zero()); - EXPECT_EQ(b2.as_uint64(), UINT64_C(15747124762497195938)); - EXPECT_FALSE(b2.is_zero()); - EXPECT_NE(b0, b1); - EXPECT_FALSE(b0 == b1); - - EXPECT_EQ(b2.max_bits(), 128u); - EXPECT_EQ(b2.num_bits(), 99u); - for (size_t i = 0; i < 128; i++) { - EXPECT_EQ(b2.test_bit(i), (b2_binary[127-i] == '1')); - } - - bigint<3> b3 = b2 * b1; - - EXPECT_EQ(b3, bigint<3>(b3_decimal)); - EXPECT_FALSE(b3.is_zero()); - - bigint<3> b3a { b3 }; - EXPECT_EQ(b3a, bigint<3>(b3_decimal)); - EXPECT_EQ(b3a, b3); - EXPECT_FALSE(b3a.is_zero()); - - mpz_t m3; - mpz_init(m3); - b3.to_mpz(m3); - bigint<3> b3b { m3 }; - EXPECT_EQ(b3b, b3); - - bigint<2> quotient; - bigint<2> remainder; - bigint<3>::div_qr(quotient, remainder, b3, b2); - EXPECT_LT(quotient.num_bits(), static_cast(GMP_NUMB_BITS)); - EXPECT_EQ(quotient.as_uint64(), b1.as_uint64()); - bigint<1> b1inc = bigint<1>("76749408"); - bigint<1> b1a = quotient.shorten(b1inc, "test"); - EXPECT_EQ(b1a, b1); - EXPECT_TRUE(remainder.is_zero()); - remainder.limit(b2, "test"); - - EXPECT_THROW((void)(quotient.shorten(b1, "test")), std::domain_error); - EXPECT_THROW(remainder.limit(remainder, "test"), std::domain_error); - - bigint<1> br = bigint<1>("42"); - b3 += br; - EXPECT_NE(b3, b3a); - EXPECT_GT(b3, b3a); - EXPECT_FALSE(b3a > b3); - - bigint<3>::div_qr(quotient, remainder, b3, b2); - EXPECT_LT(quotient.num_bits(), static_cast(GMP_NUMB_BITS)); - EXPECT_EQ(quotient.as_uint64(), b1.as_uint64()); - EXPECT_LT(remainder.num_bits(), static_cast(GMP_NUMB_BITS)); - EXPECT_EQ(remainder.as_uint64(), 42u); - - b3a.clear(); - EXPECT_TRUE(b3a.is_zero()); - EXPECT_EQ(b3a.num_bits(), 0u); - EXPECT_FALSE(b3.is_zero()); - - bigint<4> bx = bigint<4>().randomize(); - bigint<4> by = bigint<4>().randomize(); - EXPECT_FALSE(bx == by); - - // TODO: test serialization -} - diff --git a/src/snark/libsnark/algebra/fields/tests/test_fields.cpp b/src/snark/libsnark/algebra/fields/tests/test_fields.cpp deleted file mode 100644 index 2101fad9d..000000000 --- a/src/snark/libsnark/algebra/fields/tests/test_fields.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ -#include "common/profiling.hpp" -#ifdef CURVE_BN128 -#include "algebra/curves/bn128/bn128_pp.hpp" -#endif -#include "algebra/curves/alt_bn128/alt_bn128_pp.hpp" -#include "algebra/fields/fp6_3over2.hpp" -#include "algebra/fields/fp12_2over3over2.hpp" - -#include - -using namespace libsnark; - -template -void test_field() -{ - bigint<1> rand1 = bigint<1>("76749407"); - bigint<1> rand2 = bigint<1>("44410867"); - bigint<1> randsum = bigint<1>("121160274"); - - FieldT zero = FieldT::zero(); - FieldT one = FieldT::one(); - FieldT a = FieldT::random_element(); - FieldT a_ser; - a_ser = reserialize(a); - EXPECT_EQ(a_ser, a); - - FieldT b = FieldT::random_element(); - FieldT c = FieldT::random_element(); - FieldT d = FieldT::random_element(); - - EXPECT_NE(a, zero); - EXPECT_NE(a, one); - - EXPECT_EQ(a * a, a.squared()); - EXPECT_EQ((a + b).squared(), a.squared() + a*b + b*a + b.squared()); - EXPECT_EQ((a + b)*(c + d), a*c + a*d + b*c + b*d); - EXPECT_EQ(a - b, a + (-b)); - EXPECT_EQ(a - b, (-b) + a); - - EXPECT_EQ((a ^ rand1) * (a ^ rand2), (a^randsum)); - - EXPECT_EQ(a * a.inverse(), one); - EXPECT_EQ((a + b) * c.inverse(), a * c.inverse() + (b.inverse() * c).inverse()); - -} - -template -void test_sqrt() -{ - for (size_t i = 0; i < 100; ++i) - { - FieldT a = FieldT::random_element(); - FieldT asq = a.squared(); - EXPECT_TRUE(asq.sqrt() == a || asq.sqrt() == -a); - } -} - -template -void test_two_squarings() -{ - FieldT a = FieldT::random_element(); - EXPECT_EQ(a.squared(), a * a); - EXPECT_EQ(a.squared(), a.squared_complex()); - EXPECT_EQ(a.squared(), a.squared_karatsuba()); -} - -template -void test_Frobenius() -{ - FieldT a = FieldT::random_element(); - EXPECT_EQ(a.Frobenius_map(0), a); - FieldT a_q = a ^ FieldT::base_field_char(); - for (size_t power = 1; power < 10; ++power) - { - const FieldT a_qi = a.Frobenius_map(power); - EXPECT_EQ(a_qi, a_q); - - a_q = a_q ^ FieldT::base_field_char(); - } -} - -template -void test_unitary_inverse() -{ - EXPECT_EQ(FieldT::extension_degree() % 2, 0u); - FieldT a = FieldT::random_element(); - FieldT aqcubed_minus1 = a.Frobenius_map(FieldT::extension_degree()/2) * a.inverse(); - EXPECT_EQ(aqcubed_minus1.inverse(), aqcubed_minus1.unitary_inverse()); -} - -template -void test_all_fields() -{ - test_field >(); - test_field >(); - test_field >(); - test_field >(); - - test_sqrt >(); - test_sqrt >(); - test_sqrt >(); - - test_Frobenius >(); - test_Frobenius >(); - - test_unitary_inverse >(); -} - -template -void test_Fp4_tom_cook() -{ - typedef typename Fp4T::my_Fp FieldT; - for (size_t i = 0; i < 100; ++i) - { - const Fp4T a = Fp4T::random_element(); - const Fp4T b = Fp4T::random_element(); - const Fp4T correct_res = a * b; - - Fp4T res; - - const FieldT - &a0 = a.c0.c0, - &a1 = a.c1.c0, - &a2 = a.c0.c1, - &a3 = a.c1.c1; - - const FieldT - &b0 = b.c0.c0, - &b1 = b.c1.c0, - &b2 = b.c0.c1, - &b3 = b.c1.c1; - - FieldT - &c0 = res.c0.c0, - &c1 = res.c1.c0, - &c2 = res.c0.c1, - &c3 = res.c1.c1; - - const FieldT v0 = a0 * b0; - const FieldT v1 = (a0 + a1 + a2 + a3) * (b0 + b1 + b2 + b3); - const FieldT v2 = (a0 - a1 + a2 - a3) * (b0 - b1 + b2 - b3); - const FieldT v3 = (a0 + FieldT(2)*a1 + FieldT(4)*a2 + FieldT(8)*a3) * (b0 + FieldT(2)*b1 + FieldT(4)*b2 + FieldT(8)*b3); - const FieldT v4 = (a0 - FieldT(2)*a1 + FieldT(4)*a2 - FieldT(8)*a3) * (b0 - FieldT(2)*b1 + FieldT(4)*b2 - FieldT(8)*b3); - const FieldT v5 = (a0 + FieldT(3)*a1 + FieldT(9)*a2 + FieldT(27)*a3) * (b0 + FieldT(3)*b1 + FieldT(9)*b2 + FieldT(27)*b3); - const FieldT v6 = a3 * b3; - - const FieldT beta = Fp4T::non_residue; - - c0 = v0 + beta*(FieldT(4).inverse()*v0 - FieldT(6).inverse()*(v1 + v2) + FieldT(24).inverse() * (v3 + v4) - FieldT(5) * v6); - c1 = - FieldT(3).inverse()*v0 + v1 - FieldT(2).inverse()*v2 - FieldT(4).inverse()*v3 + FieldT(20).inverse() * v4 + FieldT(30).inverse() * v5 - FieldT(12) * v6 + beta * ( - FieldT(12).inverse() * (v0 - v1) + FieldT(24).inverse()*(v2 - v3) - FieldT(120).inverse() * (v4 - v5) - FieldT(3) * v6); - c2 = - (FieldT(5)*(FieldT(4).inverse()))* v0 + (FieldT(2)*(FieldT(3).inverse()))*(v1 + v2) - FieldT(24).inverse()*(v3 + v4) + FieldT(4)*v6 + beta*v6; - c3 = FieldT(12).inverse() * (FieldT(5)*v0 - FieldT(7)*v1) - FieldT(24).inverse()*(v2 - FieldT(7)*v3 + v4 + v5) + FieldT(15)*v6; - - EXPECT_EQ(res, correct_res); - - // {v0, v3, v4, v5} - const FieldT u = (FieldT::one() - beta).inverse(); - EXPECT_EQ(v0, u * c0 + beta * u * c2 - beta * u * FieldT(2).inverse() * v1 - beta * u * FieldT(2).inverse() * v2 + beta * v6); - EXPECT_EQ(v3, - FieldT(15) * u * c0 - FieldT(30) * u * c1 - FieldT(3) * (FieldT(4) + beta) * u * c2 - FieldT(6) * (FieldT(4) + beta) * u * c3 + (FieldT(24) - FieldT(3) * beta * FieldT(2).inverse()) * u * v1 + (-FieldT(8) + beta * FieldT(2).inverse()) * u * v2 - - FieldT(3) * (-FieldT(16) + beta) * v6); - EXPECT_EQ(v4, - FieldT(15) * u * c0 + FieldT(30) * u * c1 - FieldT(3) * (FieldT(4) + beta) * u * c2 + FieldT(6) * (FieldT(4) + beta) * u * c3 + (FieldT(24) - FieldT(3) * beta * FieldT(2).inverse()) * u * v2 + (-FieldT(8) + beta * FieldT(2).inverse()) * u * v1 - - FieldT(3) * (-FieldT(16) + beta) * v6); - EXPECT_EQ(v5, - FieldT(80) * u * c0 - FieldT(240) * u * c1 - FieldT(8) * (FieldT(9) + beta) * u * c2 - FieldT(24) * (FieldT(9) + beta) * u * c3 - FieldT(2) * (-FieldT(81) + beta) * u * v1 + (-FieldT(81) + beta) * u * v2 - - FieldT(8) * (-FieldT(81) + beta) * v6); - - // c0 + beta c2 - (beta v1)/2 - (beta v2)/ 2 - (-1 + beta) beta v6, - // -15 c0 - 30 c1 - 3 (4 + beta) c2 - 6 (4 + beta) c3 + (24 - (3 beta)/2) v1 + (-8 + beta/2) v2 + 3 (-16 + beta) (-1 + beta) v6, - // -15 c0 + 30 c1 - 3 (4 + beta) c2 + 6 (4 + beta) c3 + (-8 + beta/2) v1 + (24 - (3 beta)/2) v2 + 3 (-16 + beta) (-1 + beta) v6, - // -80 c0 - 240 c1 - 8 (9 + beta) c2 - 24 (9 + beta) c3 - 2 (-81 + beta) v1 + (-81 + beta) v2 + 8 (-81 + beta) (-1 + beta) v6 - } -} - -TEST(algebra, fields) -{ - alt_bn128_pp::init_public_params(); - test_field(); - test_Frobenius(); - test_all_fields(); - -#ifdef CURVE_BN128 // BN128 has fancy dependencies so it may be disabled - bn128_pp::init_public_params(); - test_field >(); - test_field >(); -#endif -} diff --git a/src/snark/libsnark/algebra/knowledge_commitment/knowledge_commitment.hpp b/src/snark/libsnark/algebra/knowledge_commitment/knowledge_commitment.hpp deleted file mode 100644 index 902423134..000000000 --- a/src/snark/libsnark/algebra/knowledge_commitment/knowledge_commitment.hpp +++ /dev/null @@ -1,84 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for: - - a knowledge commitment, and - - a knowledge commitment vector. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef KNOWLEDGE_COMMITMENT_HPP_ -#define KNOWLEDGE_COMMITMENT_HPP_ - -#include "algebra/fields/fp.hpp" -#include "common/data_structures/sparse_vector.hpp" - -namespace libsnark { - -/********************** Knowledge commitment *********************************/ - -/** - * A knowledge commitment is a pair (g,h) where g is in T1 and h in T2, - * and T1 and T2 are groups (written additively). - * - * Such pairs form a group by defining: - * - "zero" = (0,0) - * - "one" = (1,1) - * - a * (g,h) + b * (g',h') := ( a * g + b * g', a * h + b * h'). - */ -template -struct knowledge_commitment { - - T1 g; - T2 h; - - knowledge_commitment() = default; - knowledge_commitment(const knowledge_commitment &other) = default; - knowledge_commitment(knowledge_commitment &&other) = default; - knowledge_commitment(const T1 &g, const T2 &h); - - knowledge_commitment& operator=(const knowledge_commitment &other) = default; - knowledge_commitment& operator=(knowledge_commitment &&other) = default; - knowledge_commitment operator+(const knowledge_commitment &other) const; - - bool is_zero() const; - bool operator==(const knowledge_commitment &other) const; - bool operator!=(const knowledge_commitment &other) const; - - static knowledge_commitment zero(); - static knowledge_commitment one(); - - void print() const; - - static size_t size_in_bits(); -}; - -template -knowledge_commitment operator*(const bigint &lhs, const knowledge_commitment &rhs); - -template &modulus_p> -knowledge_commitment operator*(const Fp_model &lhs, const knowledge_commitment &rhs); - -template -std::ostream& operator<<(std::ostream& out, const knowledge_commitment &kc); - -template -std::istream& operator>>(std::istream& in, knowledge_commitment &kc); - -/******************** Knowledge commitment vector ****************************/ - -/** - * A knowledge commitment vector is a sparse vector of knowledge commitments. - */ -template -using knowledge_commitment_vector = sparse_vector >; - -} // libsnark - -#include "algebra/knowledge_commitment/knowledge_commitment.tcc" - -#endif // KNOWLEDGE_COMMITMENT_HPP_ diff --git a/src/snark/libsnark/algebra/knowledge_commitment/knowledge_commitment.tcc b/src/snark/libsnark/algebra/knowledge_commitment/knowledge_commitment.tcc deleted file mode 100644 index 15b2926c8..000000000 --- a/src/snark/libsnark/algebra/knowledge_commitment/knowledge_commitment.tcc +++ /dev/null @@ -1,111 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for: - - a knowledge commitment, and - - a knowledge commitment vector. - - See knowledge_commitment.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef KNOWLEDGE_COMMITMENT_TCC_ -#define KNOWLEDGE_COMMITMENT_TCC_ - -namespace libsnark { - -template -knowledge_commitment::knowledge_commitment(const T1 &g, const T2 &h) : - g(g), h(h) -{ -} - -template -knowledge_commitment knowledge_commitment::zero() -{ - return knowledge_commitment(T1::zero(), T2::zero()); -} - -template -knowledge_commitment knowledge_commitment::one() -{ - return knowledge_commitment(T1::one(), T2::one()); -} - -template -knowledge_commitment knowledge_commitment::operator+(const knowledge_commitment &other) const -{ - return knowledge_commitment(this->g + other.g, - this->h + other.h); -} - -template -bool knowledge_commitment::is_zero() const -{ - return (g.is_zero() && h.is_zero()); -} - -template -bool knowledge_commitment::operator==(const knowledge_commitment &other) const -{ - return (this->g == other.g && - this->h == other.h); -} - -template -bool knowledge_commitment::operator!=(const knowledge_commitment &other) const -{ - return !((*this) == other); -} - -template -knowledge_commitment operator*(const bigint &lhs, const knowledge_commitment &rhs) -{ - return knowledge_commitment(lhs * rhs.g, - lhs * rhs.h); -} - -template &modulus_p> -knowledge_commitment operator*(const Fp_model &lhs, const knowledge_commitment &rhs) -{ - return (lhs.as_bigint()) * rhs; -} - -template -void knowledge_commitment::print() const -{ - printf("knowledge_commitment.g:\n"); - g.print(); - printf("knowledge_commitment.h:\n"); - h.print(); -} - -template -size_t knowledge_commitment::size_in_bits() -{ - return T1::size_in_bits() + T2::size_in_bits(); -} - -template -std::ostream& operator<<(std::ostream& out, const knowledge_commitment &kc) -{ - out << kc.g << OUTPUT_SEPARATOR << kc.h; - return out; -} - -template -std::istream& operator>>(std::istream& in, knowledge_commitment &kc) -{ - in >> kc.g; - consume_OUTPUT_SEPARATOR(in); - in >> kc.h; - return in; -} - -} // libsnark - -#endif // KNOWLEDGE_COMMITMENT_TCC_ diff --git a/src/snark/libsnark/algebra/scalar_multiplication/kc_multiexp.hpp b/src/snark/libsnark/algebra/scalar_multiplication/kc_multiexp.hpp deleted file mode 100644 index 27e48f821..000000000 --- a/src/snark/libsnark/algebra/scalar_multiplication/kc_multiexp.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef KC_MULTIEXP_HPP_ -#define KC_MULTIEXP_HPP_ - -/* - Split out from multiexp to prevent cyclical - dependencies. I.e. previously multiexp depended on - knowledge_commitment, which depended on sparse_vector, which - depended on multiexp (to do accumulate). - - Will probably go away in more general exp refactoring. -*/ - -#include "algebra/knowledge_commitment/knowledge_commitment.hpp" - -namespace libsnark { - -template -knowledge_commitment opt_window_wnaf_exp(const knowledge_commitment &base, - const bigint &scalar, const size_t scalar_bits); - -template -knowledge_commitment kc_multi_exp_with_mixed_addition(const knowledge_commitment_vector &vec, - const size_t min_idx, - const size_t max_idx, - typename std::vector::const_iterator scalar_start, - typename std::vector::const_iterator scalar_end, - const size_t chunks, - const bool use_multiexp=false); - -template -void kc_batch_to_special(std::vector > &vec); - -template -knowledge_commitment_vector kc_batch_exp(const size_t scalar_size, - const size_t T1_window, - const size_t T2_window, - const window_table &T1_table, - const window_table &T2_table, - const FieldT &T1_coeff, - const FieldT &T2_coeff, - const std::vector &v, - const size_t suggested_num_chunks); - -} // libsnark - -#include "algebra/scalar_multiplication/kc_multiexp.tcc" - -#endif // KC_MULTIEXP_HPP_ diff --git a/src/snark/libsnark/algebra/scalar_multiplication/kc_multiexp.tcc b/src/snark/libsnark/algebra/scalar_multiplication/kc_multiexp.tcc deleted file mode 100644 index e9c08d4bc..000000000 --- a/src/snark/libsnark/algebra/scalar_multiplication/kc_multiexp.tcc +++ /dev/null @@ -1,274 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef KC_MULTIEXP_TCC_ -#define KC_MULTIEXP_TCC_ - -namespace libsnark { - -template -knowledge_commitment opt_window_wnaf_exp(const knowledge_commitment &base, - const bigint &scalar, const size_t scalar_bits) -{ - return knowledge_commitment(opt_window_wnaf_exp(base.g, scalar, scalar_bits), - opt_window_wnaf_exp(base.h, scalar, scalar_bits)); -} - -template -knowledge_commitment kc_multi_exp_with_mixed_addition(const knowledge_commitment_vector &vec, - const size_t min_idx, - const size_t max_idx, - typename std::vector::const_iterator scalar_start, - typename std::vector::const_iterator scalar_end, - const size_t chunks, - const bool use_multiexp) -{ - enter_block("Process scalar vector"); - auto index_it = std::lower_bound(vec.indices.begin(), vec.indices.end(), min_idx); - const size_t offset = index_it - vec.indices.begin(); - - auto value_it = vec.values.begin() + offset; - - const FieldT zero = FieldT::zero(); - const FieldT one = FieldT::one(); - - std::vector p; - std::vector > g; - - knowledge_commitment acc = knowledge_commitment::zero(); - - size_t num_skip = 0; - size_t num_add = 0; - size_t num_other = 0; - - const size_t scalar_length = std::distance(scalar_start, scalar_end); - - while (index_it != vec.indices.end() && *index_it < max_idx) - { - const size_t scalar_position = (*index_it) - min_idx; - assert(scalar_position < scalar_length); - - const FieldT scalar = *(scalar_start + scalar_position); - - if (scalar == zero) - { - // do nothing - ++num_skip; - } - else if (scalar == one) - { -#ifdef USE_MIXED_ADDITION - acc.g = acc.g.mixed_add(value_it->g); - acc.h = acc.h.mixed_add(value_it->h); -#else - acc.g = acc.g + value_it->g; - acc.h = acc.h + value_it->h; -#endif - ++num_add; - } - else - { - p.emplace_back(scalar); - g.emplace_back(*value_it); - ++num_other; - } - - ++index_it; - ++value_it; - } - - //print_indent(); printf("* Elements of w skipped: %zu (%0.2f%%)\n", num_skip, 100.*num_skip/(num_skip+num_add+num_other)); - //print_indent(); printf("* Elements of w processed with special addition: %zu (%0.2f%%)\n", num_add, 100.*num_add/(num_skip+num_add+num_other)); - //print_indent(); printf("* Elements of w remaining: %zu (%0.2f%%)\n", num_other, 100.*num_other/(num_skip+num_add+num_other)); - leave_block("Process scalar vector"); - - return acc + multi_exp, FieldT>(g.begin(), g.end(), p.begin(), p.end(), chunks, use_multiexp); -} - -template -void kc_batch_to_special(std::vector > &vec) -{ - enter_block("Batch-convert knowledge-commitments to special form"); - - std::vector g_vec; - g_vec.reserve(vec.size()); - - for (size_t i = 0; i < vec.size(); ++i) - { - if (!vec[i].g.is_zero()) - { - g_vec.emplace_back(vec[i].g); - } - } - - batch_to_special_all_non_zeros(g_vec); - auto g_it = g_vec.begin(); - T1 T1_zero_special = T1::zero(); - T1_zero_special.to_special(); - - for (size_t i = 0; i < vec.size(); ++i) - { - if (!vec[i].g.is_zero()) - { - vec[i].g = *g_it; - ++g_it; - } - else - { - vec[i].g = T1_zero_special; - } - } - - g_vec.clear(); - - std::vector h_vec; - h_vec.reserve(vec.size()); - - for (size_t i = 0; i < vec.size(); ++i) - { - if (!vec[i].h.is_zero()) - { - h_vec.emplace_back(vec[i].h); - } - } - - batch_to_special_all_non_zeros(h_vec); - auto h_it = h_vec.begin(); - T2 T2_zero_special = T2::zero(); - T2_zero_special.to_special(); - - for (size_t i = 0; i < vec.size(); ++i) - { - if (!vec[i].h.is_zero()) - { - vec[i].h = *h_it; - ++h_it; - } - else - { - vec[i].h = T2_zero_special; - } - } - - g_vec.clear(); - - leave_block("Batch-convert knowledge-commitments to special form"); -} - -template -knowledge_commitment_vector kc_batch_exp_internal(const size_t scalar_size, - const size_t T1_window, - const size_t T2_window, - const window_table &T1_table, - const window_table &T2_table, - const FieldT &T1_coeff, - const FieldT &T2_coeff, - const std::vector &v, - const size_t start_pos, - const size_t end_pos, - const size_t expected_size) -{ - knowledge_commitment_vector res; - - res.values.reserve(expected_size); - res.indices.reserve(expected_size); - - for (size_t pos = start_pos; pos != end_pos; ++pos) - { - if (!v[pos].is_zero()) - { - res.values.emplace_back(knowledge_commitment(windowed_exp(scalar_size, T1_window, T1_table, T1_coeff * v[pos]), - windowed_exp(scalar_size, T2_window, T2_table, T2_coeff * v[pos]))); - res.indices.emplace_back(pos); - } - } - - return res; -} - -template -knowledge_commitment_vector kc_batch_exp(const size_t scalar_size, - const size_t T1_window, - const size_t T2_window, - const window_table &T1_table, - const window_table &T2_table, - const FieldT &T1_coeff, - const FieldT &T2_coeff, - const std::vector &v, - const size_t suggested_num_chunks) -{ - knowledge_commitment_vector res; - res.domain_size_ = v.size(); - - size_t nonzero = 0; - for (size_t i = 0; i < v.size(); ++i) - { - nonzero += (v[i].is_zero() ? 0 : 1); - } - - const size_t num_chunks = std::max((size_t)1, std::min(nonzero, suggested_num_chunks)); - - if (!inhibit_profiling_info) - { - print_indent(); printf("Non-zero coordinate count: %zu/%zu (%0.2f%%)\n", nonzero, v.size(), 100.*nonzero/v.size()); - } - - std::vector > tmp(num_chunks); - std::vector chunk_pos(num_chunks+1); - - const size_t chunk_size = nonzero / num_chunks; - const size_t last_chunk = nonzero - chunk_size * (num_chunks - 1); - - chunk_pos[0] = 0; - - size_t cnt = 0; - size_t chunkno = 1; - - for (size_t i = 0; i < v.size(); ++i) - { - cnt += (v[i].is_zero() ? 0 : 1); - if (cnt == chunk_size && chunkno < num_chunks) - { - chunk_pos[chunkno] = i; - cnt = 0; - ++chunkno; - } - } - - chunk_pos[num_chunks] = v.size(); - -#ifdef MULTICORE -#pragma omp parallel for -#endif - for (size_t i = 0; i < num_chunks; ++i) - { - tmp[i] = kc_batch_exp_internal(scalar_size, T1_window, T2_window, T1_table, T2_table, T1_coeff, T2_coeff, v, - chunk_pos[i], chunk_pos[i+1], i == num_chunks - 1 ? last_chunk : chunk_size); -#ifdef USE_MIXED_ADDITION - kc_batch_to_special(tmp[i].values); -#endif - } - - if (num_chunks == 1) - { - tmp[0].domain_size_ = v.size(); - return tmp[0]; - } - else - { - for (size_t i = 0; i < num_chunks; ++i) - { - res.values.insert(res.values.end(), tmp[i].values.begin(), tmp[i].values.end()); - res.indices.insert(res.indices.end(), tmp[i].indices.begin(), tmp[i].indices.end()); - } - return res; - } -} - -} // libsnark - -#endif // KC_MULTIEXP_TCC_ diff --git a/src/snark/libsnark/algebra/scalar_multiplication/multiexp.hpp b/src/snark/libsnark/algebra/scalar_multiplication/multiexp.hpp deleted file mode 100644 index eaf72d61f..000000000 --- a/src/snark/libsnark/algebra/scalar_multiplication/multiexp.hpp +++ /dev/null @@ -1,110 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for multi-exponentiation routines. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef MULTIEXP_HPP_ -#define MULTIEXP_HPP_ - -namespace libsnark { - -/** - * Naive multi-exponentiation individually multiplies each base by the - * corresponding scalar and adds up the results. - */ -template -T naive_exp(typename std::vector::const_iterator vec_start, - typename std::vector::const_iterator vec_end, - typename std::vector::const_iterator scalar_start, - typename std::vector::const_iterator scalar_end); - -template -T naive_plain_exp(typename std::vector::const_iterator vec_start, - typename std::vector::const_iterator vec_end, - typename std::vector::const_iterator scalar_start, - typename std::vector::const_iterator scalar_end); - -/** - * Naive multi-exponentiation uses a variant of the Bos-Coster algorithm [1], - * and implementation suggestions from [2]. - * - * [1] = Bos and Coster, "Addition chain heuristics", CRYPTO '89 - * [2] = Bernstein, Duif, Lange, Schwabe, and Yang, "High-speed high-security signatures", CHES '11 - */ -template -T multi_exp(typename std::vector::const_iterator vec_start, - typename std::vector::const_iterator vec_end, - typename std::vector::const_iterator scalar_start, - typename std::vector::const_iterator scalar_end, - const size_t chunks, - const bool use_multiexp=false); - - -/** - * A variant of multi_exp that takes advantage of the method mixed_add (instead of the operator '+'). - */ -template -T multi_exp_with_mixed_addition(typename std::vector::const_iterator vec_start, - typename std::vector::const_iterator vec_end, - typename std::vector::const_iterator scalar_start, - typename std::vector::const_iterator scalar_end, - const size_t chunks, - const bool use_multiexp); - -/** - * A window table stores window sizes for different instance sizes for fixed-base multi-scalar multiplications. - */ -template -using window_table = std::vector >; - -/** - * Compute window size for the given number of scalars. - */ -template -size_t get_exp_window_size(const size_t num_scalars); - -/** - * Compute table of window sizes. - */ -template -window_table get_window_table(const size_t scalar_size, - const size_t window, - const T &g); - -template -T windowed_exp(const size_t scalar_size, - const size_t window, - const window_table &powers_of_g, - const FieldT &pow); - -template -std::vector batch_exp(const size_t scalar_size, - const size_t window, - const window_table &table, - const std::vector &v); - -template -std::vector batch_exp_with_coeff(const size_t scalar_size, - const size_t window, - const window_table &table, - const FieldT &coeff, - const std::vector &v); - -// defined in every curve -template -void batch_to_special_all_non_zeros(std::vector &vec); - -template -void batch_to_special(std::vector &vec); - -} // libsnark - -#include "algebra/scalar_multiplication/multiexp.tcc" - -#endif // MULTIEXP_HPP_ diff --git a/src/snark/libsnark/algebra/scalar_multiplication/multiexp.tcc b/src/snark/libsnark/algebra/scalar_multiplication/multiexp.tcc deleted file mode 100644 index e1783a881..000000000 --- a/src/snark/libsnark/algebra/scalar_multiplication/multiexp.tcc +++ /dev/null @@ -1,590 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for multi-exponentiation routines. - - See multiexp.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef MULTIEXP_TCC_ -#define MULTIEXP_TCC_ - -#include "algebra/fields/fp_aux.tcc" - -#include -#include -#include - -#include "common/profiling.hpp" -#include "common/utils.hpp" -#include "algebra/scalar_multiplication/wnaf.hpp" - -namespace libsnark { - -template -class ordered_exponent { -// to use std::push_heap and friends later -public: - size_t idx; - bigint r; - - ordered_exponent(const size_t idx, const bigint &r) : idx(idx), r(r) {}; - - bool operator<(const ordered_exponent &other) const - { -#if defined(__x86_64__) && defined(USE_ASM) - if (n == 3) - { - int64_t res; - __asm__ - ("// check for overflow \n\t" - "mov $0, %[res] \n\t" - ADD_CMP(16) - ADD_CMP(8) - ADD_CMP(0) - "jmp done%= \n\t" - "subtract%=: \n\t" - "mov $1, %[res] \n\t" - "done%=: \n\t" - : [res] "=&r" (res) - : [A] "r" (other.r.data), [mod] "r" (this->r.data) - : "cc", "%rax"); - return res; - } - else if (n == 4) - { - int64_t res; - __asm__ - ("// check for overflow \n\t" - "mov $0, %[res] \n\t" - ADD_CMP(24) - ADD_CMP(16) - ADD_CMP(8) - ADD_CMP(0) - "jmp done%= \n\t" - "subtract%=: \n\t" - "mov $1, %[res] \n\t" - "done%=: \n\t" - : [res] "=&r" (res) - : [A] "r" (other.r.data), [mod] "r" (this->r.data) - : "cc", "%rax"); - return res; - } - else if (n == 5) - { - int64_t res; - __asm__ - ("// check for overflow \n\t" - "mov $0, %[res] \n\t" - ADD_CMP(32) - ADD_CMP(24) - ADD_CMP(16) - ADD_CMP(8) - ADD_CMP(0) - "jmp done%= \n\t" - "subtract%=: \n\t" - "mov $1, %[res] \n\t" - "done%=: \n\t" - : [res] "=&r" (res) - : [A] "r" (other.r.data), [mod] "r" (this->r.data) - : "cc", "%rax"); - return res; - } - else -#endif - { - return (mpn_cmp(this->r.data, other.r.data, n) < 0); - } - } -}; - -template -T naive_exp(typename std::vector::const_iterator vec_start, - typename std::vector::const_iterator vec_end, - typename std::vector::const_iterator scalar_start, - typename std::vector::const_iterator scalar_end) -{ - T result(T::zero()); - - typename std::vector::const_iterator vec_it; - typename std::vector::const_iterator scalar_it; - - for (vec_it = vec_start, scalar_it = scalar_start; vec_it != vec_end; ++vec_it, ++scalar_it) - { - bigint scalar_bigint = scalar_it->as_bigint(); - result = result + opt_window_wnaf_exp(*vec_it, scalar_bigint, scalar_bigint.num_bits()); - } - assert(scalar_it == scalar_end); - - return result; -} - -template -T naive_plain_exp(typename std::vector::const_iterator vec_start, - typename std::vector::const_iterator vec_end, - typename std::vector::const_iterator scalar_start, - typename std::vector::const_iterator scalar_end) -{ - T result(T::zero()); - - typename std::vector::const_iterator vec_it; - typename std::vector::const_iterator scalar_it; - - for (vec_it = vec_start, scalar_it = scalar_start; vec_it != vec_end; ++vec_it, ++scalar_it) - { - result = result + (*scalar_it) * (*vec_it); - } - assert(scalar_it == scalar_end); - - return result; -} - -/* - The multi-exponentiation algorithm below is a variant of the Bos-Coster algorithm - [Bos and Coster, "Addition chain heuristics", CRYPTO '89]. - The implementation uses suggestions from - [Bernstein, Duif, Lange, Schwabe, and Yang, "High-speed high-security signatures", CHES '11]. -*/ -template -T multi_exp_inner(typename std::vector::const_iterator vec_start, - typename std::vector::const_iterator vec_end, - typename std::vector::const_iterator scalar_start, - typename std::vector::const_iterator scalar_end) -{ - const mp_size_t n = std::remove_reference::type::num_limbs; - - if (vec_start == vec_end) - { - return T::zero(); - } - - if (vec_start + 1 == vec_end) - { - return (*scalar_start)*(*vec_start); - } - - std::vector > opt_q; - const size_t vec_len = scalar_end - scalar_start; - const size_t odd_vec_len = (vec_len % 2 == 1 ? vec_len : vec_len + 1); - opt_q.reserve(odd_vec_len); - std::vector g; - g.reserve(odd_vec_len); - - typename std::vector::const_iterator vec_it; - typename std::vector::const_iterator scalar_it; - size_t i; - for (i=0, vec_it = vec_start, scalar_it = scalar_start; vec_it != vec_end; ++vec_it, ++scalar_it, ++i) - { - g.emplace_back(*vec_it); - - opt_q.emplace_back(ordered_exponent(i, scalar_it->as_bigint())); - } - std::make_heap(opt_q.begin(),opt_q.end()); - assert(scalar_it == scalar_end); - - if (vec_len != odd_vec_len) - { - g.emplace_back(T::zero()); - opt_q.emplace_back(ordered_exponent(odd_vec_len - 1, bigint(UINT64_C(0)))); - } - assert(g.size() % 2 == 1); - assert(opt_q.size() == g.size()); - - T opt_result = T::zero(); - - while (true) - { - ordered_exponent &a = opt_q[0]; - ordered_exponent &b = (opt_q[1] < opt_q[2] ? opt_q[2] : opt_q[1]); - - const size_t abits = a.r.num_bits(); - - if (b.r.is_zero()) - { - // opt_result = opt_result + (a.r * g[a.idx]); - opt_result = opt_result + opt_window_wnaf_exp(g[a.idx], a.r, abits); - break; - } - - const size_t bbits = b.r.num_bits(); - const size_t limit = (abits-bbits >= 20 ? 20 : abits-bbits); - - if (bbits < UINT64_C(1)< (x-y) A + y (B+A) - mpn_sub_n(a.r.data, a.r.data, b.r.data, n); - g[b.idx] = g[b.idx] + g[a.idx]; - } - - // regardless of whether a was cleared or subtracted from we push it down, then take back up - - /* heapify A down */ - size_t a_pos = 0; - while (2*a_pos + 2< odd_vec_len) - { - // this is a max-heap so to maintain a heap property we swap with the largest of the two - if (opt_q[2*a_pos+1] < opt_q[2*a_pos+2]) - { - std::swap(opt_q[a_pos], opt_q[2*a_pos+2]); - a_pos = 2*a_pos+2; - } - else - { - std::swap(opt_q[a_pos], opt_q[2*a_pos+1]); - a_pos = 2*a_pos+1; - } - } - - /* now heapify A up appropriate amount of times */ - while (a_pos > 0 && opt_q[(a_pos-1)/2] < opt_q[a_pos]) - { - std::swap(opt_q[a_pos], opt_q[(a_pos-1)/2]); - a_pos = (a_pos-1) / 2; - } - } - - return opt_result; -} - -template -T multi_exp(typename std::vector::const_iterator vec_start, - typename std::vector::const_iterator vec_end, - typename std::vector::const_iterator scalar_start, - typename std::vector::const_iterator scalar_end, - const size_t chunks, - const bool use_multiexp) -{ - const size_t total = vec_end - vec_start; - if (total < chunks) - { - return naive_exp(vec_start, vec_end, scalar_start, scalar_end); - } - - const size_t one = total/chunks; - - std::vector partial(chunks, T::zero()); - - if (use_multiexp) - { -#ifdef MULTICORE -#pragma omp parallel for -#endif - for (size_t i = 0; i < chunks; ++i) - { - partial[i] = multi_exp_inner(vec_start + i*one, - (i == chunks-1 ? vec_end : vec_start + (i+1)*one), - scalar_start + i*one, - (i == chunks-1 ? scalar_end : scalar_start + (i+1)*one)); - } - } - else - { -#ifdef MULTICORE -#pragma omp parallel for -#endif - for (size_t i = 0; i < chunks; ++i) - { - partial[i] = naive_exp(vec_start + i*one, - (i == chunks-1 ? vec_end : vec_start + (i+1)*one), - scalar_start + i*one, - (i == chunks-1 ? scalar_end : scalar_start + (i+1)*one)); - } - } - - T final = T::zero(); - - for (size_t i = 0; i < chunks; ++i) - { - final = final + partial[i]; - } - - return final; -} - -template -T multi_exp_with_mixed_addition(typename std::vector::const_iterator vec_start, - typename std::vector::const_iterator vec_end, - typename std::vector::const_iterator scalar_start, - typename std::vector::const_iterator scalar_end, - const size_t chunks, - const bool use_multiexp) -{ - assert(std::distance(vec_start, vec_end) == std::distance(scalar_start, scalar_end)); - enter_block("Process scalar vector"); - auto value_it = vec_start; - auto scalar_it = scalar_start; - - const FieldT zero = FieldT::zero(); - const FieldT one = FieldT::one(); - std::vector p; - std::vector g; - - T acc = T::zero(); - - size_t num_skip = 0; - size_t num_add = 0; - size_t num_other = 0; - - for (; scalar_it != scalar_end; ++scalar_it, ++value_it) - { - if (*scalar_it == zero) - { - // do nothing - ++num_skip; - } - else if (*scalar_it == one) - { -#ifdef USE_MIXED_ADDITION - acc = acc.mixed_add(*value_it); -#else - acc = acc + (*value_it); -#endif - ++num_add; - } - else - { - p.emplace_back(*scalar_it); - g.emplace_back(*value_it); - ++num_other; - } - } - //print_indent(); printf("* Elements of w skipped: %zu (%0.2f%%)\n", num_skip, 100.*num_skip/(num_skip+num_add+num_other)); - //print_indent(); printf("* Elements of w processed with special addition: %zu (%0.2f%%)\n", num_add, 100.*num_add/(num_skip+num_add+num_other)); - //print_indent(); printf("* Elements of w remaining: %zu (%0.2f%%)\n", num_other, 100.*num_other/(num_skip+num_add+num_other)); - - leave_block("Process scalar vector"); - - return acc + multi_exp(g.begin(), g.end(), p.begin(), p.end(), chunks, use_multiexp); -} - -template -size_t get_exp_window_size(const size_t num_scalars) -{ - if (T::fixed_base_exp_window_table.empty()) - { -#ifdef LOWMEM - return 14; -#else - return 17; -#endif - } - size_t window = 1; - for (int64_t i = T::fixed_base_exp_window_table.size()-1; i >= 0; --i) - { -#ifdef DEBUG - if (!inhibit_profiling_info) - { - printf("%ld %zu %zu\n", i, num_scalars, T::fixed_base_exp_window_table[i]); - } -#endif - if (T::fixed_base_exp_window_table[i] != 0 && num_scalars >= T::fixed_base_exp_window_table[i]) - { - window = i+1; - break; - } - } - - if (!inhibit_profiling_info) - { - print_indent(); printf("Choosing window size %zu for %zu elements\n", window, num_scalars); - } - -#ifdef LOWMEM - window = std::min((size_t)14, window); -#endif - return window; -} - -template -window_table get_window_table(const size_t scalar_size, - const size_t window, - const T &g) -{ - const size_t in_window = UINT64_C(1)< powers_of_g(outerc, std::vector(in_window, T::zero())); - - T gouter = g; - - for (size_t outer = 0; outer < outerc; ++outer) - { - T ginner = T::zero(); - size_t cur_in_window = outer == outerc-1 ? last_in_window : in_window; - for (size_t inner = 0; inner < cur_in_window; ++inner) - { - powers_of_g[outer][inner] = ginner; - ginner = ginner + gouter; - } - - for (size_t i = 0; i < window; ++i) - { - gouter = gouter + gouter; - } - } - - return powers_of_g; -} - -template -T windowed_exp(const size_t scalar_size, - const size_t window, - const window_table &powers_of_g, - const FieldT &pow) -{ - const size_t outerc = (scalar_size+window-1)/window; - const bigint pow_val = pow.as_bigint(); - - /* exp */ - T res = powers_of_g[0][0]; - - for (size_t outer = 0; outer < outerc; ++outer) - { - size_t inner = 0; - for (size_t i = 0; i < window; ++i) - { - if (pow_val.test_bit(outer*window + i)) - { - inner |= 1u << i; - } - } - - res = res + powers_of_g[outer][inner]; - } - - return res; -} - -template -std::vector batch_exp(const size_t scalar_size, - const size_t window, - const window_table &table, - const std::vector &v) -{ - if (!inhibit_profiling_info) - { - print_indent(); - } - std::vector res(v.size(), table[0][0]); - -#ifdef MULTICORE -#pragma omp parallel for -#endif - for (size_t i = 0; i < v.size(); ++i) - { - res[i] = windowed_exp(scalar_size, window, table, v[i]); - - if (!inhibit_profiling_info && (i % 10000 == 0)) - { - printf("."); - fflush(stdout); - } - } - - if (!inhibit_profiling_info) - { - printf(" DONE!\n"); - } - - return res; -} - -template -std::vector batch_exp_with_coeff(const size_t scalar_size, - const size_t window, - const window_table &table, - const FieldT &coeff, - const std::vector &v) -{ - if (!inhibit_profiling_info) - { - print_indent(); - } - std::vector res(v.size(), table[0][0]); - -#ifdef MULTICORE -#pragma omp parallel for -#endif - for (size_t i = 0; i < v.size(); ++i) - { - res[i] = windowed_exp(scalar_size, window, table, coeff * v[i]); - - if (!inhibit_profiling_info && (i % 10000 == 0)) - { - printf("."); - fflush(stdout); - } - } - - if (!inhibit_profiling_info) - { - printf(" DONE!\n"); - } - - return res; -} - -template -void batch_to_special(std::vector &vec) -{ - enter_block("Batch-convert elements to special form"); - - std::vector non_zero_vec; - for (size_t i = 0; i < vec.size(); ++i) - { - if (!vec[i].is_zero()) - { - non_zero_vec.emplace_back(vec[i]); - } - } - - batch_to_special_all_non_zeros(non_zero_vec); - auto it = non_zero_vec.begin(); - T zero_special = T::zero(); - zero_special.to_special(); - - for (size_t i = 0; i < vec.size(); ++i) - { - if (!vec[i].is_zero()) - { - vec[i] = *it; - ++it; - } - else - { - vec[i] = zero_special; - } - } - leave_block("Batch-convert elements to special form"); -} - -} // libsnark - -#endif // MULTIEXP_TCC_ diff --git a/src/snark/libsnark/algebra/scalar_multiplication/wnaf.hpp b/src/snark/libsnark/algebra/scalar_multiplication/wnaf.hpp deleted file mode 100644 index d6c43267e..000000000 --- a/src/snark/libsnark/algebra/scalar_multiplication/wnaf.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for wNAF ("width-w Non-Adjacent Form") exponentiation routines. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef WNAF_HPP_ -#define WNAF_HPP_ - -namespace libsnark { - -/** - * Find the wNAF representation of the given scalar relative to the given window size. - */ -template -std::vector find_wnaf(const size_t window_size, const bigint &scalar); - -/** - * In additive notation, use wNAF exponentiation (with the given window size) to compute scalar * base. - */ -template -T fixed_window_wnaf_exp(const size_t window_size, const T &base, const bigint &scalar); - -/** - * In additive notation, use wNAF exponentiation (with the window size determined by T) to compute scalar * base. - */ -template -T opt_window_wnaf_exp(const T &base, const bigint &scalar, const size_t scalar_bits); - -} // libsnark - -#include "algebra/scalar_multiplication/wnaf.tcc" - -#endif // WNAF_HPP_ diff --git a/src/snark/libsnark/algebra/scalar_multiplication/wnaf.tcc b/src/snark/libsnark/algebra/scalar_multiplication/wnaf.tcc deleted file mode 100644 index 4f2e4072c..000000000 --- a/src/snark/libsnark/algebra/scalar_multiplication/wnaf.tcc +++ /dev/null @@ -1,123 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for wNAF ("weighted Non-Adjacent Form") exponentiation routines. - - See wnaf.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef WNAF_TCC_ -#define WNAF_TCC_ - -namespace libsnark { - -template -std::vector find_wnaf(const size_t window_size, const bigint &scalar) -{ - const size_t length = scalar.max_bits(); // upper bound - std::vector res(length+1); - bigint c = scalar; - int64_t j = 0; - while (!c.is_zero()) - { - int64_t u; - if ((c.data[0] & 1) == 1) - { - u = c.data[0] % (1u << (window_size+1)); - if (u > (1 << window_size)) - { - u = u - (1 << (window_size+1)); - } - - if (u > 0) - { - mpn_sub_1(c.data, c.data, n, u); - } - else - { - mpn_add_1(c.data, c.data, n, -u); - } - } - else - { - u = 0; - } - res[j] = u; - ++j; - - mpn_rshift(c.data, c.data, n, 1); // c = c/2 - } - - return res; -} - -template -T fixed_window_wnaf_exp(const size_t window_size, const T &base, const bigint &scalar) -{ - std::vector naf = find_wnaf(window_size, scalar); - std::vector table(UINT64_C(1)<<(window_size-1)); - T tmp = base; - T dbl = base.dbl(); - for (size_t i = 0; i < UINT64_C(1)<<(window_size-1); ++i) - { - table[i] = tmp; - tmp = tmp + dbl; - } - - T res = T::zero(); - bool found_nonzero = false; - for (int64_t i = naf.size()-1; i >= 0; --i) - { - if (found_nonzero) - { - res = res.dbl(); - } - - if (naf[i] != 0) - { - found_nonzero = true; - if (naf[i] > 0) - { - res = res + table[naf[i]/2]; - } - else - { - res = res - table[(-naf[i])/2]; - } - } - } - - return res; -} - -template -T opt_window_wnaf_exp(const T &base, const bigint &scalar, const size_t scalar_bits) -{ - size_t best = 0; - for (int64_t i = T::wnaf_window_table.size() - 1; i >= 0; --i) - { - if (scalar_bits >= T::wnaf_window_table[i]) - { - best = i+1; - break; - } - } - - if (best > 0) - { - return fixed_window_wnaf_exp(best, base, scalar); - } - else - { - return scalar * base; - } -} - -} // libsnark - -#endif // WNAF_TCC_ diff --git a/src/snark/libsnark/common/assert_except.hpp b/src/snark/libsnark/common/assert_except.hpp deleted file mode 100644 index 781923044..000000000 --- a/src/snark/libsnark/common/assert_except.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ASSERT_except_H -#define ASSERT_except_H - -#include - -inline void assert_except(bool condition) { - if (!condition) { - throw std::runtime_error("Assertion failed."); - } -} - -#endif diff --git a/src/snark/libsnark/common/data_structures/accumulation_vector.hpp b/src/snark/libsnark/common/data_structures/accumulation_vector.hpp deleted file mode 100644 index 37e0c9841..000000000 --- a/src/snark/libsnark/common/data_structures/accumulation_vector.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for an accumulation vector. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef ACCUMULATION_VECTOR_HPP_ -#define ACCUMULATION_VECTOR_HPP_ - -#include "common/data_structures/sparse_vector.hpp" - -namespace libsnark { - -template -class accumulation_vector; - -template -std::ostream& operator<<(std::ostream &out, const accumulation_vector &v); - -template -std::istream& operator>>(std::istream &in, accumulation_vector &v); - -/** - * An accumulation vector comprises an accumulation value and a sparse vector. - * The method "accumulate_chunk" allows one to accumlate portions of the sparse - * vector into the accumualation value. - */ -template -class accumulation_vector { -public: - T first; - sparse_vector rest; - - accumulation_vector() = default; - accumulation_vector(const accumulation_vector &other) = default; - accumulation_vector(accumulation_vector &&other) = default; - accumulation_vector(T &&first, sparse_vector &&rest) : first(std::move(first)), rest(std::move(rest)) {}; - accumulation_vector(T &&first, std::vector &&v) : first(std::move(first)), rest(std::move(v)) {} - accumulation_vector(std::vector &&v) : first(T::zero()), rest(std::move(v)) {}; - - accumulation_vector& operator=(const accumulation_vector &other) = default; - accumulation_vector& operator=(accumulation_vector &&other) = default; - - bool operator==(const accumulation_vector &other) const; - - bool is_fully_accumulated() const; - - size_t domain_size() const; - size_t size() const; - size_t size_in_bits() const; - - template - accumulation_vector accumulate_chunk(const typename std::vector::const_iterator &it_begin, - const typename std::vector::const_iterator &it_end, - const size_t offset) const; - -}; - -template -std::ostream& operator<<(std::ostream &out, const accumulation_vector &v); - -template -std::istream& operator>>(std::istream &in, accumulation_vector &v); - -} // libsnark - -#include "common/data_structures/accumulation_vector.tcc" - -#endif // ACCUMULATION_VECTOR_HPP_ diff --git a/src/snark/libsnark/common/data_structures/accumulation_vector.tcc b/src/snark/libsnark/common/data_structures/accumulation_vector.tcc deleted file mode 100644 index 9e524aba7..000000000 --- a/src/snark/libsnark/common/data_structures/accumulation_vector.tcc +++ /dev/null @@ -1,84 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for an accumulation vector. - - See accumulation_vector.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef ACCUMULATION_VECTOR_TCC_ -#define ACCUMULATION_VECTOR_TCC_ - -namespace libsnark { - -template -bool accumulation_vector::operator==(const accumulation_vector &other) const -{ - return (this->first == other.first && this->rest == other.rest); -} - -template -bool accumulation_vector::is_fully_accumulated() const -{ - return rest.empty(); -} - -template -size_t accumulation_vector::domain_size() const -{ - return rest.domain_size(); -} - -template -size_t accumulation_vector::size() const -{ - return rest.domain_size(); -} - -template -size_t accumulation_vector::size_in_bits() const -{ - const size_t first_size_in_bits = T::size_in_bits(); - const size_t rest_size_in_bits = rest.size_in_bits(); - return first_size_in_bits + rest_size_in_bits; -} - -template -template -accumulation_vector accumulation_vector::accumulate_chunk(const typename std::vector::const_iterator &it_begin, - const typename std::vector::const_iterator &it_end, - const size_t offset) const -{ - std::pair > acc_result = rest.template accumulate(it_begin, it_end, offset); - T new_first = first + acc_result.first; - return accumulation_vector(std::move(new_first), std::move(acc_result.second)); -} - -template -std::ostream& operator<<(std::ostream& out, const accumulation_vector &v) -{ - out << v.first << OUTPUT_NEWLINE; - out << v.rest << OUTPUT_NEWLINE; - - return out; -} - -template -std::istream& operator>>(std::istream& in, accumulation_vector &v) -{ - in >> v.first; - consume_OUTPUT_NEWLINE(in); - in >> v.rest; - consume_OUTPUT_NEWLINE(in); - - return in; -} - -} // libsnark - -#endif // ACCUMULATION_VECTOR_TCC_ diff --git a/src/snark/libsnark/common/data_structures/merkle_tree.hpp b/src/snark/libsnark/common/data_structures/merkle_tree.hpp deleted file mode 100644 index 6f0c851ba..000000000 --- a/src/snark/libsnark/common/data_structures/merkle_tree.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for a Merkle tree. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef MERKLE_TREE_HPP_ -#define MERKLE_TREE_HPP_ - -#include -#include -#include "common/utils.hpp" - -namespace libsnark { - -/** - * A Merkle tree is maintained as two maps: - * - a map from addresses to values, and - * - a map from addresses to hashes. - * - * The second map maintains the intermediate hashes of a Merkle tree - * built atop the values currently stored in the tree (the - * implementation admits a very efficient support for sparse - * trees). Besides offering methods to load and store values, the - * class offers methods to retrieve the root of the Merkle tree and to - * obtain the authentication paths for (the value at) a given address. - */ - -typedef bit_vector merkle_authentication_node; -typedef std::vector merkle_authentication_path; - -template -class merkle_tree { -private: - - typedef typename HashT::hash_value_type hash_value_type; - typedef typename HashT::merkle_authentication_path_type merkle_authentication_path_type; - -public: - - std::vector hash_defaults; - std::map values; - std::map hashes; - - size_t depth; - size_t value_size; - size_t digest_size; - - merkle_tree(const size_t depth, const size_t value_size); - merkle_tree(const size_t depth, const size_t value_size, const std::vector &contents_as_vector); - merkle_tree(const size_t depth, const size_t value_size, const std::map &contents); - - bit_vector get_value(const size_t address) const; - void set_value(const size_t address, const bit_vector &value); - - hash_value_type get_root() const; - merkle_authentication_path_type get_path(const size_t address) const; - - void dump() const; -}; - -} // libsnark - -#include "common/data_structures/merkle_tree.tcc" - -#endif // MERKLE_TREE_HPP_ diff --git a/src/snark/libsnark/common/data_structures/merkle_tree.tcc b/src/snark/libsnark/common/data_structures/merkle_tree.tcc deleted file mode 100644 index ce28b124f..000000000 --- a/src/snark/libsnark/common/data_structures/merkle_tree.tcc +++ /dev/null @@ -1,246 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for Merkle tree. - - See merkle_tree.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef MERKLE_TREE_TCC -#define MERKLE_TREE_TCC - -#include - -#include "common/profiling.hpp" -#include "common/utils.hpp" - -namespace libsnark { - -template -typename HashT::hash_value_type two_to_one_CRH(const typename HashT::hash_value_type &l, - const typename HashT::hash_value_type &r) -{ - typename HashT::hash_value_type new_input; - new_input.insert(new_input.end(), l.begin(), l.end()); - new_input.insert(new_input.end(), r.begin(), r.end()); - - const size_t digest_size = HashT::get_digest_len(); - assert(l.size() == digest_size); - assert(r.size() == digest_size); - - return HashT::get_hash(new_input); -} - -template -merkle_tree::merkle_tree(const size_t depth, const size_t value_size) : - depth(depth), value_size(value_size) -{ - assert(depth < sizeof(size_t) * 8); - - digest_size = HashT::get_digest_len(); - assert(value_size <= digest_size); - - hash_value_type last(digest_size); - hash_defaults.reserve(depth+1); - hash_defaults.emplace_back(last); - for (size_t i = 0; i < depth; ++i) - { - last = two_to_one_CRH(last, last); - hash_defaults.emplace_back(last); - } - - std::reverse(hash_defaults.begin(), hash_defaults.end()); -} - -template -merkle_tree::merkle_tree(const size_t depth, - const size_t value_size, - const std::vector &contents_as_vector) : - merkle_tree(depth, value_size) -{ - assert(log2(contents_as_vector.size()) <= depth); - for (size_t address = 0; address < contents_as_vector.size(); ++address) - { - const size_t idx = address + (UINT64_C(1)< 0; --layer) - { - for (size_t idx = idx_begin; idx < idx_end; idx += 2) - { - hash_value_type l = hashes[idx]; // this is sound, because idx_begin is always a left child - hash_value_type r = (idx + 1 < idx_end ? hashes[idx+1] : hash_defaults[layer]); - - hash_value_type h = two_to_one_CRH(l, r); - hashes[(idx-1)/2] = h; - } - - idx_begin = (idx_begin-1)/2; - idx_end = (idx_end-1)/2; - } -} - -template -merkle_tree::merkle_tree(const size_t depth, - const size_t value_size, - const std::map &contents) : - merkle_tree(depth, value_size) -{ - - if (!contents.empty()) - { - assert(contents.rbegin()->first < UINT64_C(1)<first; - const bit_vector value = it->second; - const size_t idx = address + (UINT64_C(1)< 0; --layer) - { - auto next_last_it = hashes.begin(); - - for (auto it = hashes.begin(); it != last_it; ++it) - { - const size_t idx = it->first; - const hash_value_type hash = it->second; - - if (idx % 2 == 0) - { - // this is the right child of its parent and by invariant we are missing the left child - hashes[(idx-1)/2] = two_to_one_CRH(hash_defaults[layer], hash); - } - else - { - if (std::next(it) == last_it || std::next(it)->first != idx + 1) - { - // this is the left child of its parent and is missing its right child - hashes[(idx-1)/2] = two_to_one_CRH(hash, hash_defaults[layer]); - } - else - { - // typical case: this is the left child of the parent and adjecent to it there is a right child - hashes[(idx-1)/2] = two_to_one_CRH(hash, std::next(it)->second); - ++it; - } - } - } - - last_it = next_last_it; - } - } -} - -template -bit_vector merkle_tree::get_value(const size_t address) const -{ - assert(log2(address) <= depth); - - auto it = values.find(address); - bit_vector padded_result = (it == values.end() ? bit_vector(digest_size) : it->second); - padded_result.resize(value_size); - - return padded_result; -} - -template -void merkle_tree::set_value(const size_t address, - const bit_vector &value) -{ - assert(log2(address) <= depth); - size_t idx = address + (UINT64_C(1)<=0; --layer) - { - idx = (idx-1)/2; - - auto it = hashes.find(2*idx+1); - hash_value_type l = (it == hashes.end() ? hash_defaults[layer+1] : it->second); - - it = hashes.find(2*idx+2); - hash_value_type r = (it == hashes.end() ? hash_defaults[layer+1] : it->second); - - hash_value_type h = two_to_one_CRH(l, r); - hashes[idx] = h; - } -} - -template -typename HashT::hash_value_type merkle_tree::get_root() const -{ - auto it = hashes.find(0); - return (it == hashes.end() ? hash_defaults[0] : it->second); -} - -template -typename HashT::merkle_authentication_path_type merkle_tree::get_path(const size_t address) const -{ - typename HashT::merkle_authentication_path_type result(depth); - assert(log2(address) <= depth); - size_t idx = address + (UINT64_C(1)< 0; --layer) - { - size_t sibling_idx = ((idx + 1) ^ 1) - 1; - auto it = hashes.find(sibling_idx); - if (layer == depth) - { - auto it2 = values.find(sibling_idx - ((UINT64_C(1)<second); - result[layer-1].resize(digest_size); - } - else - { - result[layer-1] = (it == hashes.end() ? hash_defaults[layer] : it->second); - } - - idx = (idx-1)/2; - } - - return result; -} - -template -void merkle_tree::dump() const -{ - for (size_t i = 0; i < UINT64_C(1)< ", i); - const bit_vector value = (it == values.end() ? bit_vector(value_size) : it->second); - for (bool b : value) - { - printf("%d", b ? 1 : 0); - } - printf("\n"); - } - printf("\n"); -} - -} // libsnark - -#endif // MERKLE_TREE_TCC diff --git a/src/snark/libsnark/common/data_structures/sparse_vector.hpp b/src/snark/libsnark/common/data_structures/sparse_vector.hpp deleted file mode 100644 index 6c5a10447..000000000 --- a/src/snark/libsnark/common/data_structures/sparse_vector.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for a sparse vector. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SPARSE_VECTOR_HPP_ -#define SPARSE_VECTOR_HPP_ - -#include - -namespace libsnark { - -template -struct sparse_vector; - -template -std::ostream& operator<<(std::ostream &out, const sparse_vector &v); - -template -std::istream& operator>>(std::istream &in, sparse_vector &v); - -/** - * A sparse vector is a list of indices along with corresponding values. - * The indices are selected from the set {0,1,...,domain_size-1}. - */ -template -struct sparse_vector { - - std::vector indices; - std::vector values; - size_t domain_size_ = 0; - - sparse_vector() = default; - sparse_vector(const sparse_vector &other) = default; - sparse_vector(sparse_vector &&other) = default; - sparse_vector(std::vector &&v); /* constructor from std::vector */ - - sparse_vector& operator=(const sparse_vector &other) = default; - sparse_vector& operator=(sparse_vector &&other) = default; - - T operator[](const size_t idx) const; - - bool operator==(const sparse_vector &other) const; - bool operator==(const std::vector &other) const; - - bool is_valid() const; - bool empty() const; - - size_t domain_size() const; // return domain_size_ - size_t size() const; // return the number of indices (representing the number of non-zero entries) - size_t size_in_bits() const; // return the number bits needed to store the sparse vector - - /* return a pair consisting of the accumulated value and the sparse vector of non-accumulated values */ - template - std::pair > accumulate(const typename std::vector::const_iterator &it_begin, - const typename std::vector::const_iterator &it_end, - const size_t offset) const; - - friend std::ostream& operator<< (std::ostream &out, const sparse_vector &v); - friend std::istream& operator>> (std::istream &in, sparse_vector &v); -}; - -template -std::ostream& operator<<(std::ostream& out, const sparse_vector &v); - -template -std::istream& operator>>(std::istream& in, sparse_vector &v); - -} // libsnark - -#include "common/data_structures/sparse_vector.tcc" - -#endif // SPARSE_VECTOR_HPP_ diff --git a/src/snark/libsnark/common/data_structures/sparse_vector.tcc b/src/snark/libsnark/common/data_structures/sparse_vector.tcc deleted file mode 100644 index cfc5d7559..000000000 --- a/src/snark/libsnark/common/data_structures/sparse_vector.tcc +++ /dev/null @@ -1,316 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for a sparse vector. - - See sparse_vector.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SPARSE_VECTOR_TCC_ -#define SPARSE_VECTOR_TCC_ - -#include "algebra/scalar_multiplication/multiexp.hpp" - -#include - -namespace libsnark { - -template -sparse_vector::sparse_vector(std::vector &&v) : - values(std::move(v)), domain_size_(values.size()) -{ - indices.resize(domain_size_); - std::iota(indices.begin(), indices.end(), 0); -} - -template -T sparse_vector::operator[](const size_t idx) const -{ - auto it = std::lower_bound(indices.begin(), indices.end(), idx); - return (it != indices.end() && *it == idx) ? values[it - indices.begin()] : T(); -} - -template -bool sparse_vector::operator==(const sparse_vector &other) const -{ - if (this->domain_size_ != other.domain_size_) - { - return false; - } - - size_t this_pos = 0, other_pos = 0; - while (this_pos < this->indices.size() && other_pos < other.indices.size()) - { - if (this->indices[this_pos] == other.indices[other_pos]) - { - if (this->values[this_pos] != other.values[other_pos]) - { - return false; - } - ++this_pos; - ++other_pos; - } - else if (this->indices[this_pos] < other.indices[other_pos]) - { - if (!this->values[this_pos].is_zero()) - { - return false; - } - ++this_pos; - } - else - { - if (!other.values[other_pos].is_zero()) - { - return false; - } - ++other_pos; - } - } - - /* at least one of the vectors has been exhausted, so other must be empty */ - while (this_pos < this->indices.size()) - { - if (!this->values[this_pos].is_zero()) - { - return false; - } - ++this_pos; - } - - while (other_pos < other.indices.size()) - { - if (!other.values[other_pos].is_zero()) - { - return false; - } - ++other_pos; - } - - return true; -} - -template -bool sparse_vector::operator==(const std::vector &other) const -{ - if (this->domain_size_ < other.size()) - { - return false; - } - - size_t j = 0; - for (size_t i = 0; i < other.size(); ++i) - { - if (this->indices[j] == i) - { - if (this->values[j] != other[j]) - { - return false; - } - ++j; - } - else - { - if (!other[j].is_zero()) - { - return false; - } - } - } - - return true; -} - -template -bool sparse_vector::is_valid() const -{ - if (values.size() == indices.size() && values.size() <= domain_size_) - { - return false; - } - - for (size_t i = 0; i + 1 < indices.size(); ++i) - { - if (indices[i] >= indices[i+1]) - { - return false; - } - } - - if (!indices.empty() && indices[indices.size()-1] >= domain_size_) - { - return false; - } - - return true; -} - -template -bool sparse_vector::empty() const -{ - return indices.empty(); -} - -template -size_t sparse_vector::domain_size() const -{ - return domain_size_; -} - -template -size_t sparse_vector::size() const -{ - return indices.size(); -} - -template -size_t sparse_vector::size_in_bits() const -{ - return indices.size() * (sizeof(size_t) * 8 + T::size_in_bits()); -} - -template -template -std::pair > sparse_vector::accumulate(const typename std::vector::const_iterator &it_begin, - const typename std::vector::const_iterator &it_end, - const size_t offset) const -{ - // TODO: does not really belong here. - const size_t chunks = 1; - const bool use_multiexp = true; - - T accumulated_value = T::zero(); - sparse_vector resulting_vector; - resulting_vector.domain_size_ = domain_size_; - - const size_t range_len = it_end - it_begin; - bool in_block = false; - size_t first_pos = -1, last_pos = -1; // g++ -flto emits unitialized warning, even though in_block guards for such cases. - - for (size_t i = 0; i < indices.size(); ++i) - { - const bool matching_pos = (offset <= indices[i] && indices[i] < offset + range_len); - // printf("i = %zu, pos[i] = %zu, offset = %zu, w_size = %zu\n", i, indices[i], offset, w_size); - bool copy_over; - - if (in_block) - { - if (matching_pos && last_pos == i-1) - { - // block can be extended, do it - last_pos = i; - copy_over = false; - } - else - { - // block has ended here - in_block = false; - copy_over = true; - -#ifdef DEBUG - print_indent(); printf("doing multiexp for w_%zu ... w_%zu\n", indices[first_pos], indices[last_pos]); -#endif - accumulated_value = accumulated_value + multi_exp(values.begin() + first_pos, - values.begin() + last_pos + 1, - it_begin + (indices[first_pos] - offset), - it_begin + (indices[last_pos] - offset) + 1, - chunks, use_multiexp); - } - } - else - { - if (matching_pos) - { - // block can be started - first_pos = i; - last_pos = i; - in_block = true; - copy_over = false; - } - else - { - copy_over = true; - } - } - - if (copy_over) - { - resulting_vector.indices.emplace_back(indices[i]); - resulting_vector.values.emplace_back(values[i]); - } - } - - if (in_block) - { -#ifdef DEBUG - print_indent(); printf("doing multiexp for w_%zu ... w_%zu\n", indices[first_pos], indices[last_pos]); -#endif - accumulated_value = accumulated_value + multi_exp(values.begin() + first_pos, - values.begin() + last_pos + 1, - it_begin + (indices[first_pos] - offset), - it_begin + (indices[last_pos] - offset) + 1, - chunks, use_multiexp); - } - - return std::make_pair(accumulated_value, resulting_vector); -} - -template -std::ostream& operator<<(std::ostream& out, const sparse_vector &v) -{ - out << v.domain_size_ << "\n"; - out << v.indices.size() << "\n"; - for (const size_t& i : v.indices) - { - out << i << "\n"; - } - - out << v.values.size() << "\n"; - for (const T& t : v.values) - { - out << t << OUTPUT_NEWLINE; - } - - return out; -} - -template -std::istream& operator>>(std::istream& in, sparse_vector &v) -{ - in >> v.domain_size_; - consume_newline(in); - - size_t s; - in >> s; - consume_newline(in); - v.indices.resize(s); - for (size_t i = 0; i < s; ++i) - { - in >> v.indices[i]; - consume_newline(in); - } - - v.values.clear(); - in >> s; - consume_newline(in); - v.values.reserve(s); - - for (size_t i = 0; i < s; ++i) - { - T t; - in >> t; - consume_OUTPUT_NEWLINE(in); - v.values.emplace_back(t); - } - - return in; -} - -} // libsnark - -#endif // SPARSE_VECTOR_TCC_ diff --git a/src/snark/libsnark/common/default_types/ec_pp.hpp b/src/snark/libsnark/common/default_types/ec_pp.hpp deleted file mode 100644 index b08c2da88..000000000 --- a/src/snark/libsnark/common/default_types/ec_pp.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - ***************************************************************************** - - This file defines default_ec_pp based on the CURVE=... make flag, which selects - which elliptic curve is used to implement group arithmetic and pairings. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef EC_PP_HPP_ -#define EC_PP_HPP_ - -/************************ Pick the elliptic curve ****************************/ - -#ifdef CURVE_ALT_BN128 -#include "algebra/curves/alt_bn128/alt_bn128_pp.hpp" -namespace libsnark { -typedef alt_bn128_pp default_ec_pp; -} // libsnark -#endif - -#ifdef CURVE_BN128 -#include "algebra/curves/bn128/bn128_pp.hpp" -namespace libsnark { -typedef bn128_pp default_ec_pp; -} // libsnark -#endif - -#ifdef CURVE_EDWARDS -#include "algebra/curves/edwards/edwards_pp.hpp" -namespace libsnark { -typedef edwards_pp default_ec_pp; -} // libsnark -#endif - -#ifdef CURVE_MNT4 -#include "algebra/curves/mnt/mnt4/mnt4_pp.hpp" -namespace libsnark { -typedef mnt4_pp default_ec_pp; -} // libsnark -#endif - -#ifdef CURVE_MNT6 -#include "algebra/curves/mnt/mnt6/mnt6_pp.hpp" -namespace libsnark { -typedef mnt6_pp default_ec_pp; -} // libsnark -#endif - -#endif // EC_PP_HPP_ diff --git a/src/snark/libsnark/common/default_types/r1cs_ppzksnark_pp.hpp b/src/snark/libsnark/common/default_types/r1cs_ppzksnark_pp.hpp deleted file mode 100644 index c819b4a85..000000000 --- a/src/snark/libsnark/common/default_types/r1cs_ppzksnark_pp.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/** @file - ***************************************************************************** - - This file defines default_r1cs_ppzksnark_pp based on the elliptic curve - choice selected in ec_pp.hpp. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef R1CS_PPZKSNARK_PP_HPP_ -#define R1CS_PPZKSNARK_PP_HPP_ - -#include "common/default_types/ec_pp.hpp" - -namespace libsnark { -typedef default_ec_pp default_r1cs_ppzksnark_pp; -} // libsnark - -#endif // R1CS_PPZKSNARK_PP_HPP_ diff --git a/src/snark/libsnark/common/profiling.cpp b/src/snark/libsnark/common/profiling.cpp deleted file mode 100644 index e6f1f4525..000000000 --- a/src/snark/libsnark/common/profiling.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of functions for profiling code blocks. - - See profiling.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#include "common/profiling.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include "common/default_types/ec_pp.hpp" -#include "common/utils.hpp" - -#ifndef NO_PROCPS -#include -#endif - -namespace libsnark { - -int64_t get_nsec_time() -{ - auto timepoint = std::chrono::high_resolution_clock::now(); - return std::chrono::duration_cast(timepoint.time_since_epoch()).count(); -} - -/* Return total CPU time consumed by all threads of the process, in nanoseconds. */ -int64_t get_nsec_cpu_time() -{ - ::timespec ts; - if ( ::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) ) - throw ::std::runtime_error("clock_gettime(CLOCK_PROCESS_CPUTIME_ID) failed"); - // If we expected this to work, don't silently ignore failures, because that would hide the problem and incur an unnecessarily system-call overhead. So if we ever observe this exception, we should probably add a suitable #ifdef . - //TODO: clock_gettime(CLOCK_PROCESS_CPUTIME_ID) is not supported by native Windows. What about Cygwin? Should we #ifdef on CLOCK_PROCESS_CPUTIME_ID or on __linux__? - return ts.tv_sec * 1000000000ll + ts.tv_nsec; -} - -static int64_t start_time; -static int64_t last_time; -static int64_t start_cpu_time; -static int64_t last_cpu_time; - -void start_profiling() -{ - printf("Reset time counters for profiling\n"); - - last_time = start_time = get_nsec_time(); - last_cpu_time = start_cpu_time = get_nsec_cpu_time(); -} - -std::map invocation_counts; -static std::map enter_times; -std::map last_times; -std::map cumulative_times; -//TODO: Instead of analogous maps for time and cpu_time, use a single struct-valued map -static std::map enter_cpu_times; -static std::map last_cpu_times; -static std::map, int64_t> op_counts; -static std::map, int64_t> cumulative_op_counts; // ((msg, data_point), value) - // TODO: Convert op_counts and cumulative_op_counts from pair to structs -static size_t indentation = 0; - -static std::vector block_names; - -static std::list > op_data_points = { -#ifdef PROFILE_OP_COUNTS - std::make_pair("Fradd", &Fr::add_cnt), - std::make_pair("Frsub", &Fr::sub_cnt), - std::make_pair("Frmul", &Fr::mul_cnt), - std::make_pair("Frinv", &Fr::inv_cnt), - std::make_pair("Fqadd", &Fq::add_cnt), - std::make_pair("Fqsub", &Fq::sub_cnt), - std::make_pair("Fqmul", &Fq::mul_cnt), - std::make_pair("Fqinv", &Fq::inv_cnt), - std::make_pair("G1add", &G1::add_cnt), - std::make_pair("G1dbl", &G1::dbl_cnt), - std::make_pair("G2add", &G2::add_cnt), - std::make_pair("G2dbl", &G2::dbl_cnt) -#endif -}; - -bool inhibit_profiling_info = true; -bool inhibit_profiling_counters = false; - -void clear_profiling_counters() -{ - invocation_counts.clear(); - last_times.clear(); - last_cpu_times.clear(); - cumulative_times.clear(); -} - -void print_cumulative_time_entry(const std::string &key, const int64_t factor) -{ - const double total_ms = (cumulative_times.at(key) * 1e-6); - const size_t cnt = invocation_counts.at(key); - const double avg_ms = total_ms / cnt; - printf(" %-45s: %12.5fms = %" PRId64 " * %0.5fms (%zu invocations, %0.5fms = %" PRId64 " * %0.5fms per invocation)\n", key.c_str(), total_ms, factor, total_ms/factor, cnt, avg_ms, factor, avg_ms/factor); -} - -void print_cumulative_times(const int64_t factor) -{ - printf("Dumping times:\n"); - for (auto& kv : cumulative_times) - { - print_cumulative_time_entry(kv.first, factor); - } -} - -void print_cumulative_op_counts(const bool only_fq) -{ -#ifdef PROFILE_OP_COUNTS - printf("Dumping operation counts:\n"); - for (auto& msg : invocation_counts) - { - printf(" %-45s: ", msg.first.c_str()); - bool first = true; - for (auto& data_point : op_data_points) - { - if (only_fq && data_point.first.compare(0, 2, "Fq") != 0) - { - continue; - } - - if (!first) - { - printf(", "); - } - printf("%-5s = %7.0f (%3zu)", - data_point.first.c_str(), - 1. * cumulative_op_counts[std::make_pair(msg.first, data_point.first)] / msg.second, - msg.second); - first = false; - } - printf("\n"); - } -#else - UNUSED(only_fq); -#endif -} - -void print_op_profiling(const std::string &msg) -{ -#ifdef PROFILE_OP_COUNTS - printf("\n"); - print_indent(); - - printf("(opcounts) = ("); - bool first = true; - for (std::pair p : op_data_points) - { - if (!first) - { - printf(", "); - } - - printf("%s=%lld", p.first.c_str(), *(p.second)-op_counts[std::make_pair(msg, p.first)]); - first = false; - } - printf(")"); -#else - UNUSED(msg); -#endif -} - -static void print_times_from_last_and_start(int64_t now, int64_t last, - int64_t cpu_now, int64_t cpu_last) -{ - int64_t time_from_start = now - start_time; - int64_t time_from_last = now - last; - - int64_t cpu_time_from_start = cpu_now - start_cpu_time; - int64_t cpu_time_from_last = cpu_now - cpu_last; - - if (time_from_last != 0) { - double parallelism_from_last = 1.0 * cpu_time_from_last / time_from_last; - printf("[%0.4fs x%0.2f]", time_from_last * 1e-9, parallelism_from_last); - } else { - printf("[ ]"); - } - if (time_from_start != 0) { - double parallelism_from_start = 1.0 * cpu_time_from_start / time_from_start; - printf("\t(%0.4fs x%0.2f from start)", time_from_start * 1e-9, parallelism_from_start); - } -} - -void print_time(const char* msg) -{ - if (inhibit_profiling_info) - { - return; - } - - int64_t now = get_nsec_time(); - int64_t cpu_now = get_nsec_cpu_time(); - - printf("%-35s\t", msg); - print_times_from_last_and_start(now, last_time, cpu_now, last_cpu_time); -#ifdef PROFILE_OP_COUNTS - print_op_profiling(msg); -#endif - printf("\n"); - - fflush(stdout); - last_time = now; - last_cpu_time = cpu_now; -} - -void print_header(const char *msg) -{ - printf("\n================================================================================\n"); - printf("%s\n", msg); - printf("================================================================================\n\n"); -} - -void print_indent() -{ - for (size_t i = 0; i < indentation; ++i) - { - printf(" "); - } -} - -void op_profiling_enter(const std::string &msg) -{ - for (std::pair p : op_data_points) - { - op_counts[std::make_pair(msg, p.first)] = *(p.second); - } -} - -void enter_block(const std::string &msg, const bool indent) -{ - if (inhibit_profiling_counters) - { - return; - } - - block_names.emplace_back(msg); - int64_t t = get_nsec_time(); - enter_times[msg] = t; - int64_t cpu_t = get_nsec_cpu_time(); - enter_cpu_times[msg] = cpu_t; - - if (inhibit_profiling_info) - { - return; - } - -#ifdef MULTICORE -#pragma omp critical -#endif - { - op_profiling_enter(msg); - - print_indent(); - printf("(enter) %-35s\t", msg.c_str()); - print_times_from_last_and_start(t, t, cpu_t, cpu_t); - printf("\n"); - fflush(stdout); - - if (indent) - { - ++indentation; - } - } -} - -void leave_block(const std::string &msg, const bool indent) -{ - if (inhibit_profiling_counters) - { - return; - } - -#ifndef MULTICORE - assert(*(--block_names.end()) == msg); -#endif - block_names.pop_back(); - - ++invocation_counts[msg]; - - int64_t t = get_nsec_time(); - last_times[msg] = (t - enter_times[msg]); - cumulative_times[msg] += (t - enter_times[msg]); - - int64_t cpu_t = get_nsec_cpu_time(); - last_cpu_times[msg] = (cpu_t - enter_cpu_times[msg]); - -#ifdef PROFILE_OP_COUNTS - for (std::pair p : op_data_points) - { - cumulative_op_counts[std::make_pair(msg, p.first)] += *(p.second)-op_counts[std::make_pair(msg, p.first)]; - } -#endif - - if (inhibit_profiling_info) - { - return; - } - -#ifdef MULTICORE -#pragma omp critical -#endif - { - if (indent) - { - --indentation; - } - - print_indent(); - printf("(leave) %-35s\t", msg.c_str()); - print_times_from_last_and_start(t, enter_times[msg], cpu_t, enter_cpu_times[msg]); - print_op_profiling(msg); - printf("\n"); - fflush(stdout); - } -} - -void print_mem(const std::string &s) -{ -#ifndef NO_PROCPS - struct proc_t usage; - look_up_our_self(&usage); - if (s.empty()) - { - printf("* Peak vsize (physical memory+swap) in mebibytes: %lu\n", usage.vsize >> 20); - } - else - { - printf("* Peak vsize (physical memory+swap) in mebibytes (%s): %lu\n", s.c_str(), usage.vsize >> 20); - } -#else - printf("* Memory profiling not supported in NO_PROCPS mode\n"); -#endif -} - -void print_compilation_info() -{ -#ifdef __GNUC__ - printf("g++ version: %s\n", __VERSION__); - //printf("Compiled on %s %s\n", __DATE__, __TIME__); -#endif -#ifdef STATIC - printf("STATIC: yes\n"); -#else - printf("STATIC: no\n"); -#endif -#ifdef MULTICORE - printf("MULTICORE: yes\n"); -#else - printf("MULTICORE: no\n"); -#endif -#ifdef DEBUG - printf("DEBUG: yes\n"); -#else - printf("DEBUG: no\n"); -#endif -#ifdef PROFILE_OP_COUNTS - printf("PROFILE_OP_COUNTS: yes\n"); -#else - printf("PROFILE_OP_COUNTS: no\n"); -#endif -#ifdef _GLIBCXX_DEBUG - printf("_GLIBCXX_DEBUG: yes\n"); -#else - printf("_GLIBCXX_DEBUG: no\n"); -#endif -} - -} // libsnark diff --git a/src/snark/libsnark/common/profiling.hpp b/src/snark/libsnark/common/profiling.hpp deleted file mode 100644 index 4a496107b..000000000 --- a/src/snark/libsnark/common/profiling.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of functions for profiling code blocks. - - Reports time, operation counts, memory usage, and others. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef PROFILING_HPP_ -#define PROFILING_HPP_ - -#include -#include -#include -#include - -namespace libsnark { - -void start_profiling(); -int64_t get_nsec_time(); -void print_time(const char* msg); -void print_header(const char* msg); - -void print_indent(); - -extern bool inhibit_profiling_info; -extern bool inhibit_profiling_counters; -extern std::map invocation_counts; -extern std::map last_times; -extern std::map cumulative_times; - -void clear_profiling_counters(); - -void print_cumulative_time_entry(const std::string &key, const int64_t factor=1); -void print_cumulative_times(const int64_t factor=1); -void print_cumulative_op_counts(const bool only_fq=false); - -void enter_block(const std::string &msg, const bool indent=true); -void leave_block(const std::string &msg, const bool indent=true); - -void print_mem(const std::string &s = ""); -void print_compilation_info(); - -} // libsnark - -#endif // PROFILING_HPP_ diff --git a/src/snark/libsnark/common/serialization.hpp b/src/snark/libsnark/common/serialization.hpp deleted file mode 100644 index 6757e1966..000000000 --- a/src/snark/libsnark/common/serialization.hpp +++ /dev/null @@ -1,104 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of serialization routines and constants. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SERIALIZATION_HPP_ -#define SERIALIZATION_HPP_ - -#include -#include -#include -#include -#include - -namespace libsnark { - -/* - * @todo - * The serialization is fragile. Should be rewritten using a standard, portable-format - * library like boost::serialize. - * - * However, for now the following conventions are used within the code. - * - * All algebraic objects support either binary or decimal output using - * the standard C++ stream operators (operator<<, operator>>). - * - * The binary mode is activated by defining a BINARY_OUTPUT - * preprocessor macro (e.g. g++ -DBINARY_OUTPUT ...). - * - * Binary output assumes that the stream is to be binary read at its - * current position so any white space should be consumed beforehand. - * - * Consecutive algebraic objects are separated by OUTPUT_NEWLINE and - * within themselves (e.g. X and Y coordinates for field elements) with - * OUTPUT_SEPARATOR (as defined below). - * - * Therefore to dump two integers, two Fp elements and another integer - * one would: - * - * out << 3 << "\n"; - * out << 4 << "\n"; - * out << FieldT(56) << OUTPUT_NEWLINE; - * out << FieldT(78) << OUTPUT_NEWLINE; - * out << 9 << "\n"; - * - * Then reading back it its reader's responsibility (!) to consume "\n" - * after 4, but Fp::operator<< will correctly consume OUTPUT_NEWLINE. - * - * The reader should also consume "\n" after 9, so that another field - * element can be properly chained. This is especially important for - * binary output. - * - * The binary serialization of algebraic objects is currently *not* - * portable between machines of different word sizes. - */ - -#ifdef BINARY_OUTPUT -#define OUTPUT_NEWLINE "" -#define OUTPUT_SEPARATOR "" -#else -#define OUTPUT_NEWLINE "\n" -#define OUTPUT_SEPARATOR " " -#endif - -inline void consume_newline(std::istream &in); -inline void consume_OUTPUT_NEWLINE(std::istream &in); -inline void consume_OUTPUT_SEPARATOR(std::istream &in); - -inline void output_bool(std::ostream &out, const bool b); - -inline void output_bool_vector(std::ostream &out, const std::vector &v); - -template -T reserialize(const T &obj); - -template -std::ostream& operator<<(std::ostream& out, const std::vector &v); - -template -std::istream& operator>>(std::ostream& out, std::vector &v); - -template -std::ostream& operator<<(std::ostream& out, const std::map &m); - -template -std::istream& operator>>(std::istream& in, std::map &m); - -template -std::ostream& operator<<(std::ostream& out, const std::set &s); - -template -std::istream& operator>>(std::istream& in, std::set &s); - -} // libsnark - -#include "common/serialization.tcc" - -#endif // SERIALIZATION_HPP_ diff --git a/src/snark/libsnark/common/serialization.tcc b/src/snark/libsnark/common/serialization.tcc deleted file mode 100644 index 398f97850..000000000 --- a/src/snark/libsnark/common/serialization.tcc +++ /dev/null @@ -1,180 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of serialization routines. - - See serialization.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SERIALIZATION_TCC_ -#define SERIALIZATION_TCC_ - -#include -#include -#include "common/utils.hpp" - -namespace libsnark { - -inline void consume_newline(std::istream &in) -{ - char c; - in.read(&c, 1); -} - -inline void consume_OUTPUT_NEWLINE(std::istream &in) -{ -#ifdef BINARY_OUTPUT - // nothing to consume - UNUSED(in); -#else - char c; - in.read(&c, 1); -#endif -} - -inline void consume_OUTPUT_SEPARATOR(std::istream &in) -{ -#ifdef BINARY_OUTPUT - // nothing to consume - UNUSED(in); -#else - char c; - in.read(&c, 1); -#endif -} - -inline void output_bool(std::ostream &out, const bool b) -{ - out << (b ? 1 : 0) << "\n"; -} - -inline void output_bool_vector(std::ostream &out, const std::vector &v) -{ - out << v.size() << "\n"; - for (const bool b : v) - { - output_bool(out, b); - } -} - -template -T reserialize(const T &obj) -{ - std::stringstream ss; - ss << obj; - T tmp; - ss >> tmp; - assert(obj == tmp); - return tmp; -} - -template -std::ostream& operator<<(std::ostream& out, const std::vector &v) -{ - static_assert(!std::is_same::value, "this does not work for std::vector"); - out << v.size() << "\n"; - for (const T& t : v) - { - out << t << OUTPUT_NEWLINE; - } - - return out; -} - -template -std::istream& operator>>(std::istream& in, std::vector &v) -{ - static_assert(!std::is_same::value, "this does not work for std::vector"); - size_t size; - in >> size; - consume_newline(in); - - v.resize(0); - for (size_t i = 0; i < size; ++i) - { - T elt; - in >> elt; - consume_OUTPUT_NEWLINE(in); - v.push_back(elt); - } - - return in; -} - -template -std::ostream& operator<<(std::ostream& out, const std::map &m) -{ - out << m.size() << "\n"; - - for (auto &it : m) - { - out << it.first << "\n"; - out << it.second << "\n"; - } - - return out; -} - -template -std::istream& operator>>(std::istream& in, std::map &m) -{ - m.clear(); - size_t size; - in >> size; - consume_newline(in); - - for (size_t i = 0; i < size; ++i) - { - T1 k; - T2 v; - in >> k; - consume_newline(in); - in >> v; - consume_newline(in); - m[k] = v; - } - - return in; -} - -template -std::ostream& operator<<(std::ostream& out, const std::set &s) -{ - out << s.size() << "\n"; - - for (auto &el : s) - { - out << el << "\n"; - } - - return out; -} - - -template -std::istream& operator>>(std::istream& in, std::set &s) -{ - s.clear(); - size_t size; - in >> size; - consume_newline(in); - - for (size_t i = 0; i < size; ++i) - { - T el; - in >> el; - consume_newline(in); - s.insert(el); - } - - return in; -} - -} - -#endif // SERIALIZATION_TCC_ diff --git a/src/snark/libsnark/common/template_utils.hpp b/src/snark/libsnark/common/template_utils.hpp deleted file mode 100644 index 8dbfd261d..000000000 --- a/src/snark/libsnark/common/template_utils.hpp +++ /dev/null @@ -1,26 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of functions for supporting the use of templates. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef TEMPLATE_UTILS_HPP_ -#define TEMPLATE_UTILS_HPP_ - -namespace libsnark { - -/* A commonly used SFINAE helper type */ -template -struct void_type -{ - typedef void type; -}; - -} // libsnark - -#endif // TEMPLATE_UTILS_HPP_ diff --git a/src/snark/libsnark/common/utils.cpp b/src/snark/libsnark/common/utils.cpp deleted file mode 100644 index 06af6eff8..000000000 --- a/src/snark/libsnark/common/utils.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/** @file - ***************************************************************************** - Implementation of misc math and serialization utility functions - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#include -#include -#include -#include -#include "common/utils.hpp" - -namespace libsnark { - -size_t log2(size_t n) -/* returns ceil(log2(n)), so UINT64_C(1)< 1) - { - n >>= 1; - r++; - } - - return r; -} - -size_t bitreverse(size_t n, const size_t l) -{ - size_t r = 0; - for (size_t k = 0; k < l; ++k) - { - r = (r << 1) | (n & 1); - n >>= 1; - } - return r; -} - -bit_vector int_list_to_bits(const std::initializer_list &l, const size_t wordsize) -{ - bit_vector res(wordsize*l.size()); - for (size_t i = 0; i < l.size(); ++i) - { - for (size_t j = 0; j < wordsize; ++j) - { - res[i*wordsize + j] = (*(l.begin()+i) & (UINT64_C(1)<<(wordsize-1-j))); - } - } - return res; -} - -int64_t div_ceil(int64_t x, int64_t y) -{ - return (x + (y-1)) / y; -} - -bool is_little_endian() -{ - uint64_t a = 0x12345678; - unsigned char *c = (unsigned char*)(&a); - return (*c = 0x78); -} - -std::string FORMAT(const std::string &prefix, const char* format, ...) -{ - const static size_t MAX_FMT = 256; - char buf[MAX_FMT]; - va_list args; - va_start(args, format); - vsnprintf(buf, MAX_FMT, format, args); - va_end(args); - - return prefix + std::string(buf); -} - -void serialize_bit_vector(std::ostream &out, const bit_vector &v) -{ - out << v.size() << "\n"; - for (size_t i = 0; i < v.size(); ++i) - { - out << v[i] << "\n"; - } -} - -void deserialize_bit_vector(std::istream &in, bit_vector &v) -{ - size_t size; - in >> size; - v.resize(size); - for (size_t i = 0; i < size; ++i) - { - bool b; - in >> b; - v[i] = b; - } -} -} // libsnark diff --git a/src/snark/libsnark/common/utils.hpp b/src/snark/libsnark/common/utils.hpp deleted file mode 100644 index 505f67410..000000000 --- a/src/snark/libsnark/common/utils.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/** @file - ***************************************************************************** - Declaration of misc math and serialization utility functions - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef UTILS_HPP_ -#define UTILS_HPP_ - -#include -#include -#include -#include -#include - -namespace libsnark { - -typedef std::vector bit_vector; - -/// returns ceil(log2(n)), so UINT64_C(1)< &l, const size_t wordsize); -int64_t div_ceil(int64_t x, int64_t y); - -bool is_little_endian(); - -std::string FORMAT(const std::string &prefix, const char* format, ...); - -/* A variadic template to suppress unused argument warnings */ -template -void UNUSED(Types&&...) {} - -#ifdef DEBUG -#define FMT FORMAT -#else -#define FMT(...) (UNUSED(__VA_ARGS__), "") -#endif - -void serialize_bit_vector(std::ostream &out, const bit_vector &v); -void deserialize_bit_vector(std::istream &in, bit_vector &v); - -template -size_t size_in_bits(const std::vector &v); - -#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0])) - -} // libsnark - -#include "common/utils.tcc" /* note that utils has a templatized part (utils.tcc) and non-templatized part (utils.cpp) */ -#endif // UTILS_HPP_ diff --git a/src/snark/libsnark/common/utils.tcc b/src/snark/libsnark/common/utils.tcc deleted file mode 100644 index f97178f8c..000000000 --- a/src/snark/libsnark/common/utils.tcc +++ /dev/null @@ -1,23 +0,0 @@ -/** @file - ***************************************************************************** - Implementation of templatized utility functions - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef UTILS_TCC_ -#define UTILS_TCC_ - -namespace libsnark { - -template -size_t size_in_bits(const std::vector &v) -{ - return v.size() * T::size_in_bits(); -} - -} // libsnark - -#endif // UTILS_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/constraint_profiling.cpp b/src/snark/libsnark/gadgetlib1/constraint_profiling.cpp deleted file mode 100644 index bc17e63bc..000000000 --- a/src/snark/libsnark/gadgetlib1/constraint_profiling.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for profiling constraints. - - See constraint_profiling.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#include "gadgetlib1/constraint_profiling.hpp" -#include "common/profiling.hpp" - -namespace libsnark { - -size_t constraint_profiling_indent = 0; -std::vector constraint_profiling_table; - -size_t PRINT_CONSTRAINT_PROFILING() -{ - size_t accounted = 0; - print_indent(); - printf("Constraint profiling:\n"); - for (constraint_profiling_entry &ent : constraint_profiling_table) - { - if (ent.indent == 0) - { - accounted += ent.count; - } - - print_indent(); - for (size_t i = 0; i < ent.indent; ++i) - { - printf(" "); - } - printf("* Number of constraints in [%s]: %zu\n", ent.annotation.c_str(), ent.count); - } - - constraint_profiling_table.clear(); - constraint_profiling_indent = 0; - - return accounted; -} - -} diff --git a/src/snark/libsnark/gadgetlib1/constraint_profiling.hpp b/src/snark/libsnark/gadgetlib1/constraint_profiling.hpp deleted file mode 100644 index df8a55de1..000000000 --- a/src/snark/libsnark/gadgetlib1/constraint_profiling.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for profiling constraints. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef CONSTRAINT_PROFILING_HPP_ -#define CONSTRAINT_PROFILING_HPP_ - -#include -#include -#include -#include - -namespace libsnark { - -extern size_t constraint_profiling_indent; - -struct constraint_profiling_entry { - size_t indent; - std::string annotation; - size_t count; -}; - -extern std::vector constraint_profiling_table; - -#define PROFILE_CONSTRAINTS(pb, annotation) \ - for (size_t _num_constraints_before = pb.num_constraints(), _iter = (++constraint_profiling_indent, 0), _cp_pos = constraint_profiling_table.size(); \ - _iter == 0; \ - constraint_profiling_table.insert(constraint_profiling_table.begin() + _cp_pos, constraint_profiling_entry{--constraint_profiling_indent, annotation, pb.num_constraints() - _num_constraints_before}), \ - _iter = 1) - -size_t PRINT_CONSTRAINT_PROFILING(); // returns # of top level constraints - -} // libsnark - -#endif // CONSTRAINT_PROFILING_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/examples/simple_example.hpp b/src/snark/libsnark/gadgetlib1/examples/simple_example.hpp deleted file mode 100644 index faa3a9605..000000000 --- a/src/snark/libsnark/gadgetlib1/examples/simple_example.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SIMPLE_EXAMPLE_HPP_ -#define SIMPLE_EXAMPLE_HPP_ - -#include "examples/r1cs_examples.hpp" - -namespace libsnark { - -template -r1cs_example gen_r1cs_example_from_protoboard(const size_t num_constraints, - const size_t num_inputs); - -} // libsnark - -#include "gadgetlib1/examples/simple_example.tcc" - -#endif // SIMPLE_EXAMPLE_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/examples/simple_example.tcc b/src/snark/libsnark/gadgetlib1/examples/simple_example.tcc deleted file mode 100644 index 9d500b5c7..000000000 --- a/src/snark/libsnark/gadgetlib1/examples/simple_example.tcc +++ /dev/null @@ -1,54 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SIMPLE_EXAMPLE_TCC_ -#define SIMPLE_EXAMPLE_TCC_ - -#include -#include "gadgetlib1/gadgets/basic_gadgets.hpp" - -namespace libsnark { - -/* NOTE: all examples here actually generate one constraint less to account for soundness constraint in QAP */ - -template -r1cs_example gen_r1cs_example_from_protoboard(const size_t num_constraints, - const size_t num_inputs) -{ - const size_t new_num_constraints = num_constraints - 1; - - /* construct dummy example: inner products of two vectors */ - protoboard pb; - pb_variable_array A; - pb_variable_array B; - pb_variable res; - - // the variables on the protoboard are (ONE (constant 1 term), res, A[0], ..., A[num_constraints-1], B[0], ..., B[num_constraints-1]) - res.allocate(pb, "res"); - A.allocate(pb, new_num_constraints, "A"); - B.allocate(pb, new_num_constraints, "B"); - - inner_product_gadget compute_inner_product(pb, A, B, res, "compute_inner_product"); - compute_inner_product.generate_r1cs_constraints(); - - /* fill in random example */ - for (size_t i = 0; i < new_num_constraints; ++i) - { - pb.val(A[i]) = FieldT::random_element(); - pb.val(B[i]) = FieldT::random_element(); - } - - compute_inner_product.generate_r1cs_witness(); - - pb.constraint_system.num_inputs = num_inputs; - const r1cs_variable_assignment va = pb.values; - const r1cs_variable_assignment input(va.begin(), va.begin() + num_inputs); - return r1cs_example(pb.constraint_system, input, va, num_inputs); -} - -} // libsnark -#endif // R1CS_EXAMPLES_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/gadget.hpp b/src/snark/libsnark/gadgetlib1/gadget.hpp deleted file mode 100644 index dbeaa9d4b..000000000 --- a/src/snark/libsnark/gadgetlib1/gadget.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef GADGET_HPP_ -#define GADGET_HPP_ - -#include "gadgetlib1/protoboard.hpp" - -namespace libsnark { - -template -class gadget { -protected: - protoboard &pb; - const std::string annotation_prefix; -public: - gadget(protoboard &pb, const std::string &annotation_prefix=""); -}; - -} // libsnark -#include "gadgetlib1/gadget.tcc" - -#endif // GADGET_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/gadget.tcc b/src/snark/libsnark/gadgetlib1/gadget.tcc deleted file mode 100644 index 120229bbe..000000000 --- a/src/snark/libsnark/gadgetlib1/gadget.tcc +++ /dev/null @@ -1,23 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef GADGET_TCC_ -#define GADGET_TCC_ - -namespace libsnark { - -template -gadget::gadget(protoboard &pb, const std::string &annotation_prefix) : - pb(pb), annotation_prefix(annotation_prefix) -{ -#ifdef DEBUG - assert(annotation_prefix != ""); -#endif -} - -} // libsnark -#endif // GADGET_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/basic_gadgets.hpp b/src/snark/libsnark/gadgetlib1/gadgets/basic_gadgets.hpp deleted file mode 100644 index 08e596bee..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/basic_gadgets.hpp +++ /dev/null @@ -1,351 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef BASIC_GADGETS_HPP_ -#define BASIC_GADGETS_HPP_ - -#include -#include - -#include "gadgetlib1/gadget.hpp" - -namespace libsnark { - -/* forces lc to take value 0 or 1 by adding constraint lc * (1-lc) = 0 */ -template -void generate_boolean_r1cs_constraint(protoboard &pb, const pb_linear_combination &lc, const std::string &annotation_prefix=""); - -template -void generate_r1cs_equals_const_constraint(protoboard &pb, const pb_linear_combination &lc, const FieldT& c, const std::string &annotation_prefix=""); - -template -class packing_gadget : public gadget { -private: - /* no internal variables */ -public: - const pb_linear_combination_array bits; - const pb_linear_combination packed; - - packing_gadget(protoboard &pb, - const pb_linear_combination_array &bits, - const pb_linear_combination &packed, - const std::string &annotation_prefix="") : - gadget(pb, annotation_prefix), bits(bits), packed(packed) {} - - void generate_r1cs_constraints(const bool enforce_bitness); - /* adds constraint result = \sum bits[i] * 2^i */ - - void generate_r1cs_witness_from_packed(); - void generate_r1cs_witness_from_bits(); -}; - -template -class multipacking_gadget : public gadget { -private: - std::vector > packers; -public: - const pb_linear_combination_array bits; - const pb_linear_combination_array packed_vars; - - const size_t chunk_size; - const size_t num_chunks; - // const size_t last_chunk_size; - - multipacking_gadget(protoboard &pb, - const pb_linear_combination_array &bits, - const pb_linear_combination_array &packed_vars, - const size_t chunk_size, - const std::string &annotation_prefix=""); - void generate_r1cs_constraints(const bool enforce_bitness); - void generate_r1cs_witness_from_packed(); - void generate_r1cs_witness_from_bits(); -}; - -template -class field_vector_copy_gadget : public gadget { -public: - const pb_variable_array source; - const pb_variable_array target; - const pb_linear_combination do_copy; - - field_vector_copy_gadget(protoboard &pb, - const pb_variable_array &source, - const pb_variable_array &target, - const pb_linear_combination &do_copy, - const std::string &annotation_prefix=""); - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -template -class bit_vector_copy_gadget : public gadget { -public: - const pb_variable_array source_bits; - const pb_variable_array target_bits; - const pb_linear_combination do_copy; - - pb_variable_array packed_source; - pb_variable_array packed_target; - - std::shared_ptr > pack_source; - std::shared_ptr > pack_target; - std::shared_ptr > copier; - - const size_t chunk_size; - const size_t num_chunks; - - bit_vector_copy_gadget(protoboard &pb, - const pb_variable_array &source_bits, - const pb_variable_array &target_bits, - const pb_linear_combination &do_copy, - const size_t chunk_size, - const std::string &annotation_prefix=""); - void generate_r1cs_constraints(const bool enforce_source_bitness, const bool enforce_target_bitness); - void generate_r1cs_witness(); -}; - -template -class dual_variable_gadget : public gadget { -private: - std::shared_ptr > consistency_check; -public: - pb_variable packed; - pb_variable_array bits; - - dual_variable_gadget(protoboard &pb, - const size_t width, - const std::string &annotation_prefix="") : - gadget(pb, annotation_prefix) - { - packed.allocate(pb, FMT(this->annotation_prefix, " packed")); - bits.allocate(pb, width, FMT(this->annotation_prefix, " bits")); - consistency_check.reset(new packing_gadget(pb, - bits, - packed, - FMT(this->annotation_prefix, " consistency_check"))); - } - - dual_variable_gadget(protoboard &pb, - const pb_variable_array &bits, - const std::string &annotation_prefix="") : - gadget(pb, annotation_prefix), bits(bits) - { - packed.allocate(pb, FMT(this->annotation_prefix, " packed")); - consistency_check.reset(new packing_gadget(pb, - bits, - packed, - FMT(this->annotation_prefix, " consistency_check"))); - } - - dual_variable_gadget(protoboard &pb, - const pb_variable &packed, - const size_t width, - const std::string &annotation_prefix="") : - gadget(pb, annotation_prefix), packed(packed) - { - bits.allocate(pb, width, FMT(this->annotation_prefix, " bits")); - consistency_check.reset(new packing_gadget(pb, - bits, - packed, - FMT(this->annotation_prefix, " consistency_check"))); - } - - void generate_r1cs_constraints(const bool enforce_bitness); - void generate_r1cs_witness_from_packed(); - void generate_r1cs_witness_from_bits(); -}; - -/* - the gadgets below are Fp specific: - I * X = R - (1-R) * X = 0 - - if X = 0 then R = 0 - if X != 0 then R = 1 and I = X^{-1} -*/ - -template -class disjunction_gadget : public gadget { -private: - pb_variable inv; -public: - const pb_variable_array inputs; - const pb_variable output; - - disjunction_gadget(protoboard& pb, - const pb_variable_array &inputs, - const pb_variable &output, - const std::string &annotation_prefix="") : - gadget(pb, annotation_prefix), inputs(inputs), output(output) - { - assert(inputs.size() >= 1); - inv.allocate(pb, FMT(this->annotation_prefix, " inv")); - } - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -template -void test_disjunction_gadget(const size_t n); - -template -class conjunction_gadget : public gadget { -private: - pb_variable inv; -public: - const pb_variable_array inputs; - const pb_variable output; - - conjunction_gadget(protoboard& pb, - const pb_variable_array &inputs, - const pb_variable &output, - const std::string &annotation_prefix="") : - gadget(pb, annotation_prefix), inputs(inputs), output(output) - { - assert(inputs.size() >= 1); - inv.allocate(pb, FMT(this->annotation_prefix, " inv")); - } - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -template -void test_conjunction_gadget(const size_t n); - -template -class comparison_gadget : public gadget { -private: - pb_variable_array alpha; - pb_variable alpha_packed; - std::shared_ptr > pack_alpha; - - std::shared_ptr > all_zeros_test; - pb_variable not_all_zeros; -public: - const size_t n; - const pb_linear_combination A; - const pb_linear_combination B; - const pb_variable less; - const pb_variable less_or_eq; - - comparison_gadget(protoboard& pb, - const size_t n, - const pb_linear_combination &A, - const pb_linear_combination &B, - const pb_variable &less, - const pb_variable &less_or_eq, - const std::string &annotation_prefix="") : - gadget(pb, annotation_prefix), n(n), A(A), B(B), less(less), less_or_eq(less_or_eq) - { - alpha.allocate(pb, n, FMT(this->annotation_prefix, " alpha")); - alpha.emplace_back(less_or_eq); // alpha[n] is less_or_eq - - alpha_packed.allocate(pb, FMT(this->annotation_prefix, " alpha_packed")); - not_all_zeros.allocate(pb, FMT(this->annotation_prefix, " not_all_zeros")); - - pack_alpha.reset(new packing_gadget(pb, alpha, alpha_packed, - FMT(this->annotation_prefix, " pack_alpha"))); - - all_zeros_test.reset(new disjunction_gadget(pb, - pb_variable_array(alpha.begin(), alpha.begin() + n), - not_all_zeros, - FMT(this->annotation_prefix, " all_zeros_test"))); - }; - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -template -void test_comparison_gadget(const size_t n); - -template -class inner_product_gadget : public gadget { -private: - /* S_i = \sum_{k=0}^{i+1} A[i] * B[i] */ - pb_variable_array S; -public: - const pb_linear_combination_array A; - const pb_linear_combination_array B; - const pb_variable result; - - inner_product_gadget(protoboard& pb, - const pb_linear_combination_array &A, - const pb_linear_combination_array &B, - const pb_variable &result, - const std::string &annotation_prefix="") : - gadget(pb, annotation_prefix), A(A), B(B), result(result) - { - assert(A.size() >= 1); - assert(A.size() == B.size()); - - S.allocate(pb, A.size()-1, FMT(this->annotation_prefix, " S")); - } - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -template -void test_inner_product_gadget(const size_t n); - -template -class loose_multiplexing_gadget : public gadget { -/* - this implements loose multiplexer: - index not in bounds -> success_flag = 0 - index in bounds && success_flag = 1 -> result is correct - however if index is in bounds we can also set success_flag to 0 (and then result will be forced to be 0) -*/ -public: - pb_variable_array alpha; -private: - std::shared_ptr > compute_result; -public: - const pb_linear_combination_array arr; - const pb_variable index; - const pb_variable result; - const pb_variable success_flag; - - loose_multiplexing_gadget(protoboard& pb, - const pb_linear_combination_array &arr, - const pb_variable &index, - const pb_variable &result, - const pb_variable &success_flag, - const std::string &annotation_prefix="") : - gadget(pb, annotation_prefix), arr(arr), index(index), result(result), success_flag(success_flag) - { - alpha.allocate(pb, arr.size(), FMT(this->annotation_prefix, " alpha")); - compute_result.reset(new inner_product_gadget(pb, alpha, arr, result, FMT(this->annotation_prefix, " compute_result"))); - }; - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -template -void test_loose_multiplexing_gadget(const size_t n); - -template -void create_linear_combination_constraints(protoboard &pb, - const std::vector &base, - const std::vector > &v, - const VarT &target, - const std::string &annotation_prefix); - -template -void create_linear_combination_witness(protoboard &pb, - const std::vector &base, - const std::vector > &v, - const VarT &target); - -} // libsnark -#include "gadgetlib1/gadgets/basic_gadgets.tcc" - -#endif // BASIC_GADGETS_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/basic_gadgets.tcc b/src/snark/libsnark/gadgetlib1/gadgets/basic_gadgets.tcc deleted file mode 100644 index 4e2d9fce3..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/basic_gadgets.tcc +++ /dev/null @@ -1,705 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef BASIC_GADGETS_TCC_ -#define BASIC_GADGETS_TCC_ - -#include "common/profiling.hpp" -#include "common/utils.hpp" - -namespace libsnark { - -template -void generate_boolean_r1cs_constraint(protoboard &pb, const pb_linear_combination &lc, const std::string &annotation_prefix) -/* forces lc to take value 0 or 1 by adding constraint lc * (1-lc) = 0 */ -{ - pb.add_r1cs_constraint(r1cs_constraint(lc, 1-lc, 0), - FMT(annotation_prefix, " boolean_r1cs_constraint")); -} - -template -void generate_r1cs_equals_const_constraint(protoboard &pb, const pb_linear_combination &lc, const FieldT& c, const std::string &annotation_prefix) -{ - pb.add_r1cs_constraint(r1cs_constraint(1, lc, c), - FMT(annotation_prefix, " constness_constraint")); -} - -template -void packing_gadget::generate_r1cs_constraints(const bool enforce_bitness) -/* adds constraint result = \sum bits[i] * 2^i */ -{ - this->pb.add_r1cs_constraint(r1cs_constraint(1, pb_packing_sum(bits), packed), FMT(this->annotation_prefix, " packing_constraint")); - - if (enforce_bitness) - { - for (size_t i = 0; i < bits.size(); ++i) - { - generate_boolean_r1cs_constraint(this->pb, bits[i], FMT(this->annotation_prefix, " bitness_%zu", i)); - } - } -} - -template -void packing_gadget::generate_r1cs_witness_from_packed() -{ - packed.evaluate(this->pb); - assert(this->pb.lc_val(packed).as_bigint().num_bits() <= bits.size()); - bits.fill_with_bits_of_field_element(this->pb, this->pb.lc_val(packed)); -} - -template -void packing_gadget::generate_r1cs_witness_from_bits() -{ - bits.evaluate(this->pb); - this->pb.lc_val(packed) = bits.get_field_element_from_bits(this->pb); -} - -template -multipacking_gadget::multipacking_gadget(protoboard &pb, - const pb_linear_combination_array &bits, - const pb_linear_combination_array &packed_vars, - const size_t chunk_size, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), bits(bits), packed_vars(packed_vars), - chunk_size(chunk_size), - num_chunks(div_ceil(bits.size(), chunk_size)) - // last_chunk_size(bits.size() - (num_chunks-1) * chunk_size) -{ - assert(packed_vars.size() == num_chunks); - for (size_t i = 0; i < num_chunks; ++i) - { - packers.emplace_back(packing_gadget(this->pb, pb_linear_combination_array(bits.begin() + i * chunk_size, - bits.begin() + std::min((i+1) * chunk_size, bits.size())), - packed_vars[i], FMT(this->annotation_prefix, " packers_%zu", i))); - } -} - -template -void multipacking_gadget::generate_r1cs_constraints(const bool enforce_bitness) -{ - for (size_t i = 0; i < num_chunks; ++i) - { - packers[i].generate_r1cs_constraints(enforce_bitness); - } -} - -template -void multipacking_gadget::generate_r1cs_witness_from_packed() -{ - for (size_t i = 0; i < num_chunks; ++i) - { - packers[i].generate_r1cs_witness_from_packed(); - } -} - -template -void multipacking_gadget::generate_r1cs_witness_from_bits() -{ - for (size_t i = 0; i < num_chunks; ++i) - { - packers[i].generate_r1cs_witness_from_bits(); - } -} - -template -size_t multipacking_num_chunks(const size_t num_bits) -{ - return div_ceil(num_bits, FieldT::capacity()); -} - -template -field_vector_copy_gadget::field_vector_copy_gadget(protoboard &pb, - const pb_variable_array &source, - const pb_variable_array &target, - const pb_linear_combination &do_copy, - const std::string &annotation_prefix) : -gadget(pb, annotation_prefix), source(source), target(target), do_copy(do_copy) -{ - assert(source.size() == target.size()); -} - -template -void field_vector_copy_gadget::generate_r1cs_constraints() -{ - for (size_t i = 0; i < source.size(); ++i) - { - this->pb.add_r1cs_constraint(r1cs_constraint(do_copy, source[i] - target[i], 0), - FMT(this->annotation_prefix, " copying_check_%zu", i)); - } -} - -template -void field_vector_copy_gadget::generate_r1cs_witness() -{ - do_copy.evaluate(this->pb); - assert(this->pb.lc_val(do_copy) == FieldT::one() || this->pb.lc_val(do_copy) == FieldT::zero()); - if (this->pb.lc_val(do_copy) != FieldT::zero()) - { - for (size_t i = 0; i < source.size(); ++i) - { - this->pb.val(target[i]) = this->pb.val(source[i]); - } - } -} - -template -bit_vector_copy_gadget::bit_vector_copy_gadget(protoboard &pb, - const pb_variable_array &source_bits, - const pb_variable_array &target_bits, - const pb_linear_combination &do_copy, - const size_t chunk_size, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), source_bits(source_bits), target_bits(target_bits), do_copy(do_copy), - chunk_size(chunk_size), num_chunks(div_ceil(source_bits.size(), chunk_size)) -{ - assert(source_bits.size() == target_bits.size()); - - packed_source.allocate(pb, num_chunks, FMT(annotation_prefix, " packed_source")); - pack_source.reset(new multipacking_gadget(pb, source_bits, packed_source, chunk_size, FMT(annotation_prefix, " pack_source"))); - - packed_target.allocate(pb, num_chunks, FMT(annotation_prefix, " packed_target")); - pack_target.reset(new multipacking_gadget(pb, target_bits, packed_target, chunk_size, FMT(annotation_prefix, " pack_target"))); - - copier.reset(new field_vector_copy_gadget(pb, packed_source, packed_target, do_copy, FMT(annotation_prefix, " copier"))); -} - -template -void bit_vector_copy_gadget::generate_r1cs_constraints(const bool enforce_source_bitness, const bool enforce_target_bitness) -{ - pack_source->generate_r1cs_constraints(enforce_source_bitness); - pack_target->generate_r1cs_constraints(enforce_target_bitness); - - copier->generate_r1cs_constraints(); -} - -template -void bit_vector_copy_gadget::generate_r1cs_witness() -{ - do_copy.evaluate(this->pb); - assert(this->pb.lc_val(do_copy) == FieldT::zero() || this->pb.lc_val(do_copy) == FieldT::one()); - if (this->pb.lc_val(do_copy) == FieldT::one()) - { - for (size_t i = 0; i < source_bits.size(); ++i) - { - this->pb.val(target_bits[i]) = this->pb.val(source_bits[i]); - } - } - - pack_source->generate_r1cs_witness_from_bits(); - pack_target->generate_r1cs_witness_from_bits(); -} - -template -void dual_variable_gadget::generate_r1cs_constraints(const bool enforce_bitness) -{ - consistency_check->generate_r1cs_constraints(enforce_bitness); -} - -template -void dual_variable_gadget::generate_r1cs_witness_from_packed() -{ - consistency_check->generate_r1cs_witness_from_packed(); -} - -template -void dual_variable_gadget::generate_r1cs_witness_from_bits() -{ - consistency_check->generate_r1cs_witness_from_bits(); -} - -template -void disjunction_gadget::generate_r1cs_constraints() -{ - /* inv * sum = output */ - linear_combination a1, b1, c1; - a1.add_term(inv); - for (size_t i = 0; i < inputs.size(); ++i) - { - b1.add_term(inputs[i]); - } - c1.add_term(output); - - this->pb.add_r1cs_constraint(r1cs_constraint(a1, b1, c1), FMT(this->annotation_prefix, " inv*sum=output")); - - /* (1-output) * sum = 0 */ - linear_combination a2, b2, c2; - a2.add_term(ONE); - a2.add_term(output, -1); - for (size_t i = 0; i < inputs.size(); ++i) - { - b2.add_term(inputs[i]); - } - c2.add_term(ONE, 0); - - this->pb.add_r1cs_constraint(r1cs_constraint(a2, b2, c2), FMT(this->annotation_prefix, " (1-output)*sum=0")); -} - -template -void disjunction_gadget::generate_r1cs_witness() -{ - FieldT sum = FieldT::zero(); - - for (size_t i = 0; i < inputs.size(); ++i) - { - sum += this->pb.val(inputs[i]); - } - - if (sum.is_zero()) - { - this->pb.val(inv) = FieldT::zero(); - this->pb.val(output) = FieldT::zero(); - } - else - { - this->pb.val(inv) = sum.inverse(); - this->pb.val(output) = FieldT::one(); - } -} - -template -void test_disjunction_gadget(const size_t n) -{ - printf("testing disjunction_gadget on all %zu bit strings\n", n); - - protoboard pb; - pb_variable_array inputs; - inputs.allocate(pb, n, "inputs"); - - pb_variable output; - output.allocate(pb, "output"); - - disjunction_gadget d(pb, inputs, output, "d"); - d.generate_r1cs_constraints(); - - for (size_t w = 0; w < UINT64_C(1)< -void conjunction_gadget::generate_r1cs_constraints() -{ - /* inv * (n-sum) = 1-output */ - linear_combination a1, b1, c1; - a1.add_term(inv); - b1.add_term(ONE, inputs.size()); - for (size_t i = 0; i < inputs.size(); ++i) - { - b1.add_term(inputs[i], -1); - } - c1.add_term(ONE); - c1.add_term(output, -1); - - this->pb.add_r1cs_constraint(r1cs_constraint(a1, b1, c1), FMT(this->annotation_prefix, " inv*(n-sum)=(1-output)")); - - /* output * (n-sum) = 0 */ - linear_combination a2, b2, c2; - a2.add_term(output); - b2.add_term(ONE, inputs.size()); - for (size_t i = 0; i < inputs.size(); ++i) - { - b2.add_term(inputs[i], -1); - } - c2.add_term(ONE, 0); - - this->pb.add_r1cs_constraint(r1cs_constraint(a2, b2, c2), FMT(this->annotation_prefix, " output*(n-sum)=0")); -} - -template -void conjunction_gadget::generate_r1cs_witness() -{ - FieldT sum = FieldT(inputs.size()); - - for (size_t i = 0; i < inputs.size(); ++i) - { - sum -= this->pb.val(inputs[i]); - } - - if (sum.is_zero()) - { - this->pb.val(inv) = FieldT::zero(); - this->pb.val(output) = FieldT::one(); - } - else - { - this->pb.val(inv) = sum.inverse(); - this->pb.val(output) = FieldT::zero(); - } -} - -template -void test_conjunction_gadget(const size_t n) -{ - printf("testing conjunction_gadget on all %zu bit strings\n", n); - - protoboard pb; - pb_variable_array inputs; - inputs.allocate(pb, n, "inputs"); - - pb_variable output; - output.allocate(pb, "output"); - - conjunction_gadget c(pb, inputs, output, "c"); - c.generate_r1cs_constraints(); - - for (size_t w = 0; w < UINT64_C(1)< -void comparison_gadget::generate_r1cs_constraints() -{ - /* - packed(alpha) = 2^n + B - A - - not_all_zeros = \bigvee_{i=0}^{n-1} alpha_i - - if B - A > 0, then 2^n + B - A > 2^n, - so alpha_n = 1 and not_all_zeros = 1 - if B - A = 0, then 2^n + B - A = 2^n, - so alpha_n = 1 and not_all_zeros = 0 - if B - A < 0, then 2^n + B - A \in {0, 1, \ldots, 2^n-1}, - so alpha_n = 0 - - therefore alpha_n = less_or_eq and alpha_n * not_all_zeros = less - */ - - /* not_all_zeros to be Boolean, alpha_i are Boolean by packing gadget */ - generate_boolean_r1cs_constraint(this->pb, not_all_zeros, - FMT(this->annotation_prefix, " not_all_zeros")); - - /* constraints for packed(alpha) = 2^n + B - A */ - pack_alpha->generate_r1cs_constraints(true); - this->pb.add_r1cs_constraint(r1cs_constraint(1, (FieldT(2)^n) + B - A, alpha_packed), FMT(this->annotation_prefix, " main_constraint")); - - /* compute result */ - all_zeros_test->generate_r1cs_constraints(); - this->pb.add_r1cs_constraint(r1cs_constraint(less_or_eq, not_all_zeros, less), - FMT(this->annotation_prefix, " less")); -} - -template -void comparison_gadget::generate_r1cs_witness() -{ - A.evaluate(this->pb); - B.evaluate(this->pb); - - /* unpack 2^n + B - A into alpha_packed */ - this->pb.val(alpha_packed) = (FieldT(2)^n) + this->pb.lc_val(B) - this->pb.lc_val(A); - pack_alpha->generate_r1cs_witness_from_packed(); - - /* compute result */ - all_zeros_test->generate_r1cs_witness(); - this->pb.val(less) = this->pb.val(less_or_eq) * this->pb.val(not_all_zeros); -} - -template -void test_comparison_gadget(const size_t n) -{ - printf("testing comparison_gadget on all %zu bit inputs\n", n); - - protoboard pb; - - pb_variable A, B, less, less_or_eq; - A.allocate(pb, "A"); - B.allocate(pb, "B"); - less.allocate(pb, "less"); - less_or_eq.allocate(pb, "less_or_eq"); - - comparison_gadget cmp(pb, n, A, B, less, less_or_eq, "cmp"); - cmp.generate_r1cs_constraints(); - - for (size_t a = 0; a < UINT64_C(1)< -void inner_product_gadget::generate_r1cs_constraints() -{ - /* - S_i = \sum_{k=0}^{i+1} A[i] * B[i] - S[0] = A[0] * B[0] - S[i+1] - S[i] = A[i] * B[i] - */ - for (size_t i = 0; i < A.size(); ++i) - { - this->pb.add_r1cs_constraint( - r1cs_constraint(A[i], B[i], - (i == A.size()-1 ? result : S[i]) + (i == 0 ? 0 * ONE : -S[i-1])), - FMT(this->annotation_prefix, " S_%zu", i)); - } -} - -template -void inner_product_gadget::generate_r1cs_witness() -{ - FieldT total = FieldT::zero(); - for (size_t i = 0; i < A.size(); ++i) - { - A[i].evaluate(this->pb); - B[i].evaluate(this->pb); - - total += this->pb.lc_val(A[i]) * this->pb.lc_val(B[i]); - this->pb.val(i == A.size()-1 ? result : S[i]) = total; - } -} - -template -void test_inner_product_gadget(const size_t n) -{ - printf("testing inner_product_gadget on all %zu bit strings\n", n); - - protoboard pb; - pb_variable_array A; - A.allocate(pb, n, "A"); - pb_variable_array B; - B.allocate(pb, n, "B"); - - pb_variable result; - result.allocate(pb, "result"); - - inner_product_gadget g(pb, A, B, result, "g"); - g.generate_r1cs_constraints(); - - for (size_t i = 0; i < UINT64_C(1)< -void loose_multiplexing_gadget::generate_r1cs_constraints() -{ - /* \alpha_i (index - i) = 0 */ - for (size_t i = 0; i < arr.size(); ++i) - { - this->pb.add_r1cs_constraint( - r1cs_constraint(alpha[i], index - i, 0), - FMT(this->annotation_prefix, " alpha_%zu", i)); - } - - /* 1 * (\sum \alpha_i) = success_flag */ - linear_combination a, b, c; - a.add_term(ONE); - for (size_t i = 0; i < arr.size(); ++i) - { - b.add_term(alpha[i]); - } - c.add_term(success_flag); - this->pb.add_r1cs_constraint(r1cs_constraint(a, b, c), FMT(this->annotation_prefix, " main_constraint")); - - /* now success_flag is constrained to either 0 (if index is out of - range) or \alpha_i. constrain it and \alpha_i to zero */ - generate_boolean_r1cs_constraint(this->pb, success_flag, FMT(this->annotation_prefix, " success_flag")); - - /* compute result */ - compute_result->generate_r1cs_constraints(); -} - -template -void loose_multiplexing_gadget::generate_r1cs_witness() -{ - /* assumes that idx can be fit in uint64_t; true for our purposes for now */ - const bigint valint = this->pb.val(index).as_bigint(); - uint64_t idx = valint.as_uint64(); - const bigint arrsize(arr.size()); - - if (idx >= arr.size() || mpn_cmp(valint.data, arrsize.data, FieldT::num_limbs) >= 0) - { - for (size_t i = 0; i < arr.size(); ++i) - { - this->pb.val(alpha[i]) = FieldT::zero(); - } - - this->pb.val(success_flag) = FieldT::zero(); - } - else - { - for (size_t i = 0; i < arr.size(); ++i) - { - this->pb.val(alpha[i]) = (i == idx ? FieldT::one() : FieldT::zero()); - } - - this->pb.val(success_flag) = FieldT::one(); - } - - compute_result->generate_r1cs_witness(); -} - -template -void test_loose_multiplexing_gadget(const size_t n) -{ - printf("testing loose_multiplexing_gadget on 2**%zu pb_variable array inputs\n", n); - protoboard pb; - - pb_variable_array arr; - arr.allocate(pb, UINT64_C(1)< index, result, success_flag; - index.allocate(pb, "index"); - result.allocate(pb, "result"); - success_flag.allocate(pb, "success_flag"); - - loose_multiplexing_gadget g(pb, arr, index, result, success_flag, "g"); - g.generate_r1cs_constraints(); - - for (size_t i = 0; i < UINT64_C(1)< -void create_linear_combination_constraints(protoboard &pb, - const std::vector &base, - const std::vector > &v, - const VarT &target, - const std::string &annotation_prefix) -{ - for (size_t i = 0; i < base.size(); ++i) - { - linear_combination a, b, c; - - a.add_term(ONE); - b.add_term(ONE, base[i]); - - for (auto &p : v) - { - b.add_term(p.first.all_vars[i], p.second); - } - - c.add_term(target.all_vars[i]); - - pb.add_r1cs_constraint(r1cs_constraint(a, b, c), FMT(annotation_prefix, " linear_combination_%zu", i)); - } -} - -template -void create_linear_combination_witness(protoboard &pb, - const std::vector &base, - const std::vector > &v, - const VarT &target) -{ - for (size_t i = 0; i < base.size(); ++i) - { - pb.val(target.all_vars[i]) = base[i]; - - for (auto &p : v) - { - pb.val(target.all_vars[i]) += p.second * pb.val(p.first.all_vars[i]); - } - } -} - -} // libsnark -#endif // BASIC_GADGETS_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/gadget_from_r1cs.hpp b/src/snark/libsnark/gadgetlib1/gadgets/gadget_from_r1cs.hpp deleted file mode 100644 index e4b8a2acf..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/gadget_from_r1cs.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for a gadget that can be created from an R1CS constraint system. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef GADGET_FROM_R1CS_HPP_ -#define GADGET_FROM_R1CS_HPP_ - -#include - -#include "gadgetlib1/gadget.hpp" - -namespace libsnark { - -template -class gadget_from_r1cs : public gadget { - -private: - const std::vector > vars; - const r1cs_constraint_system cs; - std::map cs_to_vars; - -public: - - gadget_from_r1cs(protoboard &pb, - const std::vector > &vars, - const r1cs_constraint_system &cs, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(const r1cs_primary_input &primary_input, - const r1cs_auxiliary_input &auxiliary_input); -}; - -} // libsnark - -#include "gadgetlib1/gadgets/gadget_from_r1cs.tcc" - -#endif // GADGET_FROM_R1CS_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/gadget_from_r1cs.tcc b/src/snark/libsnark/gadgetlib1/gadgets/gadget_from_r1cs.tcc deleted file mode 100644 index bc59b4587..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/gadget_from_r1cs.tcc +++ /dev/null @@ -1,123 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for a gadget that can be created from an R1CS constraint system. - - See gadget_from_r1cs.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef GADGET_FROM_R1CS_TCC_ -#define GADGET_FROM_R1CS_TCC_ - -namespace libsnark { - -template -gadget_from_r1cs::gadget_from_r1cs(protoboard &pb, - const std::vector > &vars, - const r1cs_constraint_system &cs, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - vars(vars), - cs(cs) -{ - cs_to_vars[0] = 0; /* constant term maps to constant term */ - - size_t cs_var_idx = 1; - for (auto va : vars) - { -#ifdef DEBUG - printf("gadget_from_r1cs: translating a block of variables with length %zu\n", va.size()); -#endif - for (auto v : va) - { - cs_to_vars[cs_var_idx] = v.index; - -#ifdef DEBUG - if (v.index != 0) - { - // handle annotations, except for re-annotating constant term - const std::map::const_iterator it = cs.variable_annotations.find(cs_var_idx); - - std::string annotation = FMT(annotation_prefix, " variable_%zu", cs_var_idx); - if (it != cs.variable_annotations.end()) - { - annotation = annotation_prefix + " " + it->second; - } - - pb.augment_variable_annotation(v, annotation); - } -#endif - ++cs_var_idx; - } - } - -#ifdef DEBUG - printf("gadget_from_r1cs: sum of all block lengths: %zu\n", cs_var_idx-1); - printf("gadget_from_r1cs: cs.num_variables(): %zu\n", cs.num_variables()); -#endif - - assert(cs_var_idx - 1 == cs.num_variables()); -} - -template -void gadget_from_r1cs::generate_r1cs_constraints() -{ - for (size_t i = 0; i < cs.num_constraints(); ++i) - { - const r1cs_constraint &constr = cs.constraints[i]; - r1cs_constraint translated_constr; - - for (const linear_term &t: constr.a.terms) - { - translated_constr.a.terms.emplace_back(linear_term(pb_variable(cs_to_vars[t.index]), t.coeff)); - } - - for (const linear_term &t: constr.b.terms) - { - translated_constr.b.terms.emplace_back(linear_term(pb_variable(cs_to_vars[t.index]), t.coeff)); - } - - for (const linear_term &t: constr.c.terms) - { - translated_constr.c.terms.emplace_back(linear_term(pb_variable(cs_to_vars[t.index]), t.coeff)); - } - - std::string annotation = FMT(this->annotation_prefix, " constraint_%zu", i); - -#ifdef DEBUG - auto it = cs.constraint_annotations.find(i); - if (it != cs.constraint_annotations.end()) - { - annotation = this->annotation_prefix + " " + it->second; - } -#endif - this->pb.add_r1cs_constraint(translated_constr, annotation); - } -} - -template -void gadget_from_r1cs::generate_r1cs_witness(const r1cs_primary_input &primary_input, - const r1cs_auxiliary_input &auxiliary_input) -{ - assert(cs.num_inputs() == primary_input.size()); - assert(cs.num_variables() == primary_input.size() + auxiliary_input.size()); - - for (size_t i = 0; i < primary_input.size(); ++i) - { - this->pb.val(pb_variable(cs_to_vars[i+1])) = primary_input[i]; - } - - for (size_t i = 0; i < auxiliary_input.size(); ++i) - { - this->pb.val(pb_variable(cs_to_vars[primary_input.size()+i+1])) = auxiliary_input[i]; - } -} - -} // libsnark - -#endif // GADGET_FROM_R1CS_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/digest_selector_gadget.hpp b/src/snark/libsnark/gadgetlib1/gadgets/hashes/digest_selector_gadget.hpp deleted file mode 100644 index a7598b9be..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/digest_selector_gadget.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ -#ifndef DIGEST_SELECTOR_GADGET_HPP_ -#define DIGEST_SELECTOR_GADGET_HPP_ - -#include - -#include "gadgetlib1/gadgets/basic_gadgets.hpp" -#include "gadgetlib1/gadgets/hashes/hash_io.hpp" - -namespace libsnark { - -template -class digest_selector_gadget : public gadget { -public: - size_t digest_size; - digest_variable input; - pb_linear_combination is_right; - digest_variable left; - digest_variable right; - - digest_selector_gadget(protoboard &pb, - const size_t digest_size, - const digest_variable &input, - const pb_linear_combination &is_right, - const digest_variable &left, - const digest_variable &right, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -} // libsnark - -#include "gadgetlib1/gadgets/hashes/digest_selector_gadget.tcc" - -#endif // DIGEST_SELECTOR_GADGET_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/digest_selector_gadget.tcc b/src/snark/libsnark/gadgetlib1/gadgets/hashes/digest_selector_gadget.tcc deleted file mode 100644 index 422ee170a..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/digest_selector_gadget.tcc +++ /dev/null @@ -1,62 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ -#ifndef DIGEST_SELECTOR_GADGET_TCC_ -#define DIGEST_SELECTOR_GADGET_TCC_ - -namespace libsnark { - -template -digest_selector_gadget::digest_selector_gadget(protoboard &pb, - const size_t digest_size, - const digest_variable &input, - const pb_linear_combination &is_right, - const digest_variable &left, - const digest_variable &right, - const std::string &annotation_prefix) : -gadget(pb, annotation_prefix), digest_size(digest_size), input(input), is_right(is_right), left(left), right(right) -{ -} - -template -void digest_selector_gadget::generate_r1cs_constraints() -{ - for (size_t i = 0; i < digest_size; ++i) - { - /* - input = is_right * right + (1-is_right) * left - input - left = is_right(right - left) - */ - this->pb.add_r1cs_constraint(r1cs_constraint(is_right, right.bits[i] - left.bits[i], input.bits[i] - left.bits[i]), - FMT(this->annotation_prefix, " propagate_%zu", i)); - } -} - -template -void digest_selector_gadget::generate_r1cs_witness() -{ - is_right.evaluate(this->pb); - - assert(this->pb.lc_val(is_right) == FieldT::one() || this->pb.lc_val(is_right) == FieldT::zero()); - if (this->pb.lc_val(is_right) == FieldT::one()) - { - for (size_t i = 0; i < digest_size; ++i) - { - this->pb.val(right.bits[i]) = this->pb.val(input.bits[i]); - } - } - else - { - for (size_t i = 0; i < digest_size; ++i) - { - this->pb.val(left.bits[i]) = this->pb.val(input.bits[i]); - } - } -} - -} // libsnark - -#endif // DIGEST_SELECTOR_GADGET_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/hash_io.hpp b/src/snark/libsnark/gadgetlib1/gadgets/hashes/hash_io.hpp deleted file mode 100644 index 80ca19c61..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/hash_io.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ -#ifndef HASH_IO_HPP_ -#define HASH_IO_HPP_ -#include -#include -#include "gadgetlib1/gadgets/basic_gadgets.hpp" - -namespace libsnark { - -template -class digest_variable : public gadget { -public: - size_t digest_size; - pb_variable_array bits; - - digest_variable(protoboard &pb, - const size_t digest_size, - const std::string &annotation_prefix); - - digest_variable(protoboard &pb, - const size_t digest_size, - const pb_variable_array &partial_bits, - const pb_variable &padding, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(const bit_vector& contents); - bit_vector get_digest() const; -}; - -template -class block_variable : public gadget { -public: - size_t block_size; - pb_variable_array bits; - - block_variable(protoboard &pb, - const size_t block_size, - const std::string &annotation_prefix); - - block_variable(protoboard &pb, - const std::vector > &parts, - const std::string &annotation_prefix); - - block_variable(protoboard &pb, - const digest_variable &left, - const digest_variable &right, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(const bit_vector& contents); - bit_vector get_block() const; -}; - -} // libsnark -#include "gadgetlib1/gadgets/hashes/hash_io.tcc" - -#endif // HASH_IO_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/hash_io.tcc b/src/snark/libsnark/gadgetlib1/gadgets/hashes/hash_io.tcc deleted file mode 100644 index b122d8f98..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/hash_io.tcc +++ /dev/null @@ -1,105 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ -#ifndef HASH_IO_TCC_ -#define HASH_IO_TCC_ - -namespace libsnark { - -template -digest_variable::digest_variable(protoboard &pb, - const size_t digest_size, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), digest_size(digest_size) -{ - bits.allocate(pb, digest_size, FMT(this->annotation_prefix, " bits")); -} - -template -digest_variable::digest_variable(protoboard &pb, - const size_t digest_size, - const pb_variable_array &partial_bits, - const pb_variable &padding, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), digest_size(digest_size) -{ - assert(bits.size() <= digest_size); - bits = partial_bits; - while (bits.size() != digest_size) - { - bits.emplace_back(padding); - } -} - -template -void digest_variable::generate_r1cs_constraints() -{ - for (size_t i = 0; i < digest_size; ++i) - { - generate_boolean_r1cs_constraint(this->pb, bits[i], FMT(this->annotation_prefix, " bits_%zu", i)); - } -} - -template -void digest_variable::generate_r1cs_witness(const bit_vector& contents) -{ - bits.fill_with_bits(this->pb, contents); -} - -template -bit_vector digest_variable::get_digest() const -{ - return bits.get_bits(this->pb); -} - -template -block_variable::block_variable(protoboard &pb, - const size_t block_size, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), block_size(block_size) -{ - bits.allocate(pb, block_size, FMT(this->annotation_prefix, " bits")); -} - -template -block_variable::block_variable(protoboard &pb, - const std::vector > &parts, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix) -{ - for (auto &part : parts) - { - bits.insert(bits.end(), part.begin(), part.end()); - } -} - -template -block_variable::block_variable(protoboard &pb, - const digest_variable &left, - const digest_variable &right, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix) -{ - assert(left.bits.size() == right.bits.size()); - block_size = 2 * left.bits.size(); - bits.insert(bits.end(), left.bits.begin(), left.bits.end()); - bits.insert(bits.end(), right.bits.begin(), right.bits.end()); -} - -template -void block_variable::generate_r1cs_witness(const bit_vector& contents) -{ - bits.fill_with_bits(this->pb, contents); -} - -template -bit_vector block_variable::get_block() const -{ - return bits.get_bits(this->pb); -} - -} // libsnark -#endif // HASH_IO_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_aux.hpp b/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_aux.hpp deleted file mode 100644 index e0c7a7e0b..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_aux.hpp +++ /dev/null @@ -1,160 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for auxiliary gadgets for the SHA256 gadget. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SHA256_AUX_HPP_ -#define SHA256_AUX_HPP_ - -#include "gadgetlib1/gadgets/basic_gadgets.hpp" - -namespace libsnark { - -template -class lastbits_gadget : public gadget { -public: - pb_variable X; - size_t X_bits; - pb_variable result; - pb_linear_combination_array result_bits; - - pb_linear_combination_array full_bits; - std::shared_ptr > unpack_bits; - std::shared_ptr > pack_result; - - lastbits_gadget(protoboard &pb, - const pb_variable &X, - const size_t X_bits, - const pb_variable &result, - const pb_linear_combination_array &result_bits, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -template -class XOR3_gadget : public gadget { -private: - pb_variable tmp; -public: - pb_linear_combination A; - pb_linear_combination B; - pb_linear_combination C; - bool assume_C_is_zero; - pb_linear_combination out; - - XOR3_gadget(protoboard &pb, - const pb_linear_combination &A, - const pb_linear_combination &B, - const pb_linear_combination &C, - const bool assume_C_is_zero, - const pb_linear_combination &out, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -/* Page 10 of http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf */ -template -class small_sigma_gadget : public gadget { -private: - pb_variable_array W; - pb_variable result; -public: - pb_variable_array result_bits; - std::vector > > compute_bits; - std::shared_ptr > pack_result; - - small_sigma_gadget(protoboard &pb, - const pb_variable_array &W, - const pb_variable &result, - const size_t rot1, - const size_t rot2, - const size_t shift, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -/* Page 10 of http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf */ -template -class big_sigma_gadget : public gadget { -private: - pb_linear_combination_array W; - pb_variable result; -public: - pb_variable_array result_bits; - std::vector > > compute_bits; - std::shared_ptr > pack_result; - - big_sigma_gadget(protoboard &pb, - const pb_linear_combination_array &W, - const pb_variable &result, - const size_t rot1, - const size_t rot2, - const size_t rot3, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -/* Page 10 of http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf */ -template -class choice_gadget : public gadget { -private: - pb_variable_array result_bits; -public: - pb_linear_combination_array X; - pb_linear_combination_array Y; - pb_linear_combination_array Z; - pb_variable result; - std::shared_ptr > pack_result; - - choice_gadget(protoboard &pb, - const pb_linear_combination_array &X, - const pb_linear_combination_array &Y, - const pb_linear_combination_array &Z, - const pb_variable &result, const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -/* Page 10 of http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf */ -template -class majority_gadget : public gadget { -private: - pb_variable_array result_bits; - std::shared_ptr > pack_result; -public: - pb_linear_combination_array X; - pb_linear_combination_array Y; - pb_linear_combination_array Z; - pb_variable result; - - majority_gadget(protoboard &pb, - const pb_linear_combination_array &X, - const pb_linear_combination_array &Y, - const pb_linear_combination_array &Z, - const pb_variable &result, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -} // libsnark - -#include "gadgetlib1/gadgets/hashes/sha256/sha256_aux.tcc" - -#endif // SHA256_AUX_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_aux.tcc b/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_aux.tcc deleted file mode 100644 index 0885f0b6d..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_aux.tcc +++ /dev/null @@ -1,297 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for auxiliary gadgets for the SHA256 gadget. - - See sha256_aux.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SHA256_AUX_TCC_ -#define SHA256_AUX_TCC_ - -namespace libsnark { - -template -lastbits_gadget::lastbits_gadget(protoboard &pb, - const pb_variable &X, - const size_t X_bits, - const pb_variable &result, - const pb_linear_combination_array &result_bits, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - X(X), - X_bits(X_bits), - result(result), - result_bits(result_bits) -{ - full_bits = result_bits; - for (size_t i = result_bits.size(); i < X_bits; ++i) - { - pb_variable full_bits_overflow; - full_bits_overflow.allocate(pb, FMT(this->annotation_prefix, " full_bits_%zu", i)); - full_bits.emplace_back(full_bits_overflow); - } - - unpack_bits.reset(new packing_gadget(pb, full_bits, X, FMT(this->annotation_prefix, " unpack_bits"))); - pack_result.reset(new packing_gadget(pb, result_bits, result, FMT(this->annotation_prefix, " pack_result"))); -} - -template -void lastbits_gadget::generate_r1cs_constraints() -{ - unpack_bits->generate_r1cs_constraints(true); - pack_result->generate_r1cs_constraints(false); -} - -template -void lastbits_gadget::generate_r1cs_witness() -{ - unpack_bits->generate_r1cs_witness_from_packed(); - pack_result->generate_r1cs_witness_from_bits(); -} - -template -XOR3_gadget::XOR3_gadget(protoboard &pb, - const pb_linear_combination &A, - const pb_linear_combination &B, - const pb_linear_combination &C, - const bool assume_C_is_zero, - const pb_linear_combination &out, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - A(A), - B(B), - C(C), - assume_C_is_zero(assume_C_is_zero), - out(out) -{ - if (!assume_C_is_zero) - { - tmp.allocate(pb, FMT(this->annotation_prefix, " tmp")); - } -} - -template -void XOR3_gadget::generate_r1cs_constraints() -{ - /* - tmp = A + B - 2AB i.e. tmp = A xor B - out = tmp + C - 2tmp C i.e. out = tmp xor C - */ - if (assume_C_is_zero) - { - this->pb.add_r1cs_constraint(r1cs_constraint(2*A, B, A + B - out), FMT(this->annotation_prefix, " implicit_tmp_equals_out")); - } - else - { - this->pb.add_r1cs_constraint(r1cs_constraint(2*A, B, A + B - tmp), FMT(this->annotation_prefix, " tmp")); - this->pb.add_r1cs_constraint(r1cs_constraint(2 * tmp, C, tmp + C - out), FMT(this->annotation_prefix, " out")); - } -} - -template -void XOR3_gadget::generate_r1cs_witness() -{ - if (assume_C_is_zero) - { - this->pb.lc_val(out) = this->pb.lc_val(A) + this->pb.lc_val(B) - FieldT(2) * this->pb.lc_val(A) * this->pb.lc_val(B); - } - else - { - this->pb.val(tmp) = this->pb.lc_val(A) + this->pb.lc_val(B) - FieldT(2) * this->pb.lc_val(A) * this->pb.lc_val(B); - this->pb.lc_val(out) = this->pb.val(tmp) + this->pb.lc_val(C) - FieldT(2) * this->pb.val(tmp) * this->pb.lc_val(C); - } -} - -#define SHA256_GADGET_ROTR(A, i, k) A[((i)+(k)) % 32] - -/* Page 10 of http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf */ -template -small_sigma_gadget::small_sigma_gadget(protoboard &pb, - const pb_variable_array &W, - const pb_variable &result, - const size_t rot1, - const size_t rot2, - const size_t shift, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - W(W), - result(result) -{ - result_bits.allocate(pb, 32, FMT(this->annotation_prefix, " result_bits")); - compute_bits.resize(32); - for (size_t i = 0; i < 32; ++i) - { - compute_bits[i].reset(new XOR3_gadget(pb, SHA256_GADGET_ROTR(W, i, rot1), SHA256_GADGET_ROTR(W, i, rot2), - (i + shift < 32 ? W[i+shift] : ONE), - (i + shift >= 32), result_bits[i], - FMT(this->annotation_prefix, " compute_bits_%zu", i))); - } - pack_result.reset(new packing_gadget(pb, result_bits, result, FMT(this->annotation_prefix, " pack_result"))); -} - -template -void small_sigma_gadget::generate_r1cs_constraints() -{ - for (size_t i = 0; i < 32; ++i) - { - compute_bits[i]->generate_r1cs_constraints(); - } - - pack_result->generate_r1cs_constraints(false); -} - -template -void small_sigma_gadget::generate_r1cs_witness() -{ - for (size_t i = 0; i < 32; ++i) - { - compute_bits[i]->generate_r1cs_witness(); - } - - pack_result->generate_r1cs_witness_from_bits(); -} - -template -big_sigma_gadget::big_sigma_gadget(protoboard &pb, - const pb_linear_combination_array &W, - const pb_variable &result, - const size_t rot1, - const size_t rot2, - const size_t rot3, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - W(W), - result(result) -{ - result_bits.allocate(pb, 32, FMT(this->annotation_prefix, " result_bits")); - compute_bits.resize(32); - for (size_t i = 0; i < 32; ++i) - { - compute_bits[i].reset(new XOR3_gadget(pb, SHA256_GADGET_ROTR(W, i, rot1), SHA256_GADGET_ROTR(W, i, rot2), SHA256_GADGET_ROTR(W, i, rot3), false, result_bits[i], - FMT(this->annotation_prefix, " compute_bits_%zu", i))); - } - - pack_result.reset(new packing_gadget(pb, result_bits, result, FMT(this->annotation_prefix, " pack_result"))); -} - -template -void big_sigma_gadget::generate_r1cs_constraints() -{ - for (size_t i = 0; i < 32; ++i) - { - compute_bits[i]->generate_r1cs_constraints(); - } - - pack_result->generate_r1cs_constraints(false); -} - -template -void big_sigma_gadget::generate_r1cs_witness() -{ - for (size_t i = 0; i < 32; ++i) - { - compute_bits[i]->generate_r1cs_witness(); - } - - pack_result->generate_r1cs_witness_from_bits(); -} - -/* Page 10 of http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf */ -template -choice_gadget::choice_gadget(protoboard &pb, - const pb_linear_combination_array &X, - const pb_linear_combination_array &Y, - const pb_linear_combination_array &Z, - const pb_variable &result, const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - X(X), - Y(Y), - Z(Z), - result(result) -{ - result_bits.allocate(pb, 32, FMT(this->annotation_prefix, " result_bits")); - pack_result.reset(new packing_gadget(pb, result_bits, result, FMT(this->annotation_prefix, " result"))); -} - -template -void choice_gadget::generate_r1cs_constraints() -{ - for (size_t i = 0; i < 32; ++i) - { - /* - result = x * y + (1-x) * z - result - z = x * (y - z) - */ - this->pb.add_r1cs_constraint(r1cs_constraint(X[i], Y[i] - Z[i], result_bits[i] - Z[i]), FMT(this->annotation_prefix, " result_bits_%zu", i)); - } - pack_result->generate_r1cs_constraints(false); -} - -template -void choice_gadget::generate_r1cs_witness() -{ - for (size_t i = 0; i < 32; ++i) - { - this->pb.val(result_bits[i]) = this->pb.lc_val(X[i]) * this->pb.lc_val(Y[i]) + (FieldT::one() - this->pb.lc_val(X[i])) * this->pb.lc_val(Z[i]); - } - pack_result->generate_r1cs_witness_from_bits(); -} - -/* Page 10 of http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf */ -template -majority_gadget::majority_gadget(protoboard &pb, - const pb_linear_combination_array &X, - const pb_linear_combination_array &Y, - const pb_linear_combination_array &Z, - const pb_variable &result, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - X(X), - Y(Y), - Z(Z), - result(result) -{ - result_bits.allocate(pb, 32, FMT(this->annotation_prefix, " result_bits")); - pack_result.reset(new packing_gadget(pb, result_bits, result, FMT(this->annotation_prefix, " result"))); -} - -template -void majority_gadget::generate_r1cs_constraints() -{ - for (size_t i = 0; i < 32; ++i) - { - /* - 2*result + aux = x + y + z - x, y, z, aux -- bits - aux = x + y + z - 2*result - */ - generate_boolean_r1cs_constraint(this->pb, result_bits[i], FMT(this->annotation_prefix, " result_%zu", i)); - this->pb.add_r1cs_constraint(r1cs_constraint(X[i] + Y[i] + Z[i] - 2 * result_bits[i], - 1 - (X[i] + Y[i] + Z[i] - 2 * result_bits[i]), - 0), - FMT(this->annotation_prefix, " result_bits_%zu", i)); - } - pack_result->generate_r1cs_constraints(false); -} - -template -void majority_gadget::generate_r1cs_witness() -{ - for (size_t i = 0; i < 32; ++i) - { - const uint64_t v = (this->pb.lc_val(X[i]) + this->pb.lc_val(Y[i]) + this->pb.lc_val(Z[i])).as_uint64(); - this->pb.val(result_bits[i]) = FieldT(v / 2); - } - - pack_result->generate_r1cs_witness_from_bits(); -} - -} // libsnark - -#endif // SHA256_AUX_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_components.hpp b/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_components.hpp deleted file mode 100644 index 2f7e71e35..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_components.hpp +++ /dev/null @@ -1,108 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for gadgets for the SHA256 message schedule and round function. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SHA256_COMPONENTS_HPP_ -#define SHA256_COMPONENTS_HPP_ - -#include "gadgetlib1/gadgets/basic_gadgets.hpp" -#include "gadgetlib1/gadgets/hashes/hash_io.hpp" -#include "gadgetlib1/gadgets/hashes/sha256/sha256_aux.hpp" - -namespace libsnark { - -const size_t SHA256_digest_size = 256; -const size_t SHA256_block_size = 512; - -template -pb_linear_combination_array SHA256_default_IV(protoboard &pb); - -template -class sha256_message_schedule_gadget : public gadget { -public: - std::vector > W_bits; - std::vector > > pack_W; - - std::vector > sigma0; - std::vector > sigma1; - std::vector > > compute_sigma0; - std::vector > > compute_sigma1; - std::vector > unreduced_W; - std::vector > > mod_reduce_W; -public: - pb_variable_array M; - pb_variable_array packed_W; - sha256_message_schedule_gadget(protoboard &pb, - const pb_variable_array &M, - const pb_variable_array &packed_W, - const std::string &annotation_prefix); - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -template -class sha256_round_function_gadget : public gadget { -public: - pb_variable sigma0; - pb_variable sigma1; - std::shared_ptr > compute_sigma0; - std::shared_ptr > compute_sigma1; - pb_variable choice; - pb_variable majority; - std::shared_ptr > compute_choice; - std::shared_ptr > compute_majority; - pb_variable packed_d; - std::shared_ptr > pack_d; - pb_variable packed_h; - std::shared_ptr > pack_h; - pb_variable unreduced_new_a; - pb_variable unreduced_new_e; - std::shared_ptr > mod_reduce_new_a; - std::shared_ptr > mod_reduce_new_e; - pb_variable packed_new_a; - pb_variable packed_new_e; -public: - pb_linear_combination_array a; - pb_linear_combination_array b; - pb_linear_combination_array c; - pb_linear_combination_array d; - pb_linear_combination_array e; - pb_linear_combination_array f; - pb_linear_combination_array g; - pb_linear_combination_array h; - pb_variable W; - uint32_t K; - pb_linear_combination_array new_a; - pb_linear_combination_array new_e; - - sha256_round_function_gadget(protoboard &pb, - const pb_linear_combination_array &a, - const pb_linear_combination_array &b, - const pb_linear_combination_array &c, - const pb_linear_combination_array &d, - const pb_linear_combination_array &e, - const pb_linear_combination_array &f, - const pb_linear_combination_array &g, - const pb_linear_combination_array &h, - const pb_variable &W, - const uint32_t &K, - const pb_linear_combination_array &new_a, - const pb_linear_combination_array &new_e, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -} // libsnark - -#include "gadgetlib1/gadgets/hashes/sha256/sha256_components.tcc" - -#endif // SHA256_COMPONENTS_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_components.tcc b/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_components.tcc deleted file mode 100644 index 41ad20883..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_components.tcc +++ /dev/null @@ -1,250 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for gadgets for the SHA256 message schedule and round function. - - See sha256_components.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SHA256_COMPONENTS_TCC_ -#define SHA256_COMPONENTS_TCC_ - -namespace libsnark { - -const uint32_t SHA256_K[64] = { - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 -}; - -const uint32_t SHA256_H[8] = { - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 -}; - -template -pb_linear_combination_array SHA256_default_IV(protoboard &pb) -{ - pb_linear_combination_array result; - result.reserve(SHA256_digest_size); - - for (size_t i = 0; i < SHA256_digest_size; ++i) - { - int iv_val = (SHA256_H[i / 32] >> (31-(i % 32))) & 1; - - pb_linear_combination iv_element; - iv_element.assign(pb, iv_val * ONE); - iv_element.evaluate(pb); - - result.emplace_back(iv_element); - } - - return result; -} - -template -sha256_message_schedule_gadget::sha256_message_schedule_gadget(protoboard &pb, - const pb_variable_array &M, - const pb_variable_array &packed_W, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - M(M), - packed_W(packed_W) -{ - W_bits.resize(64); - - pack_W.resize(16); - for (size_t i = 0; i < 16; ++i) - { - W_bits[i] = pb_variable_array(M.rbegin() + (15-i) * 32, M.rbegin() + (16-i) * 32); - pack_W[i].reset(new packing_gadget(pb, W_bits[i], packed_W[i], FMT(this->annotation_prefix, " pack_W_%zu", i))); - } - - /* NB: some of those will be un-allocated */ - sigma0.resize(64); - sigma1.resize(64); - compute_sigma0.resize(64); - compute_sigma1.resize(64); - unreduced_W.resize(64); - mod_reduce_W.resize(64); - - for (size_t i = 16; i < 64; ++i) - { - /* allocate result variables for sigma0/sigma1 invocations */ - sigma0[i].allocate(pb, FMT(this->annotation_prefix, " sigma0_%zu", i)); - sigma1[i].allocate(pb, FMT(this->annotation_prefix, " sigma1_%zu", i)); - - /* compute sigma0/sigma1 */ - compute_sigma0[i].reset(new small_sigma_gadget(pb, W_bits[i-15], sigma0[i], 7, 18, 3, FMT(this->annotation_prefix, " compute_sigma0_%zu", i))); - compute_sigma1[i].reset(new small_sigma_gadget(pb, W_bits[i-2], sigma1[i], 17, 19, 10, FMT(this->annotation_prefix, " compute_sigma1_%zu", i))); - - /* unreduced_W = sigma0(W_{i-15}) + sigma1(W_{i-2}) + W_{i-7} + W_{i-16} before modulo 2^32 */ - unreduced_W[i].allocate(pb, FMT(this->annotation_prefix, "unreduced_W_%zu", i)); - - /* allocate the bit representation of packed_W[i] */ - W_bits[i].allocate(pb, 32, FMT(this->annotation_prefix, " W_bits_%zu", i)); - - /* and finally reduce this into packed and bit representations */ - mod_reduce_W[i].reset(new lastbits_gadget(pb, unreduced_W[i], 32+2, packed_W[i], W_bits[i], FMT(this->annotation_prefix, " mod_reduce_W_%zu", i))); - } -} - -template -void sha256_message_schedule_gadget::generate_r1cs_constraints() -{ - for (size_t i = 0; i < 16; ++i) - { - pack_W[i]->generate_r1cs_constraints(false); // do not enforce bitness here; caller be aware. - } - - for (size_t i = 16; i < 64; ++i) - { - compute_sigma0[i]->generate_r1cs_constraints(); - compute_sigma1[i]->generate_r1cs_constraints(); - - this->pb.add_r1cs_constraint(r1cs_constraint(1, - sigma0[i] + sigma1[i] + packed_W[i-16] + packed_W[i-7], - unreduced_W[i]), - FMT(this->annotation_prefix, " unreduced_W_%zu", i)); - - mod_reduce_W[i]->generate_r1cs_constraints(); - } -} - -template -void sha256_message_schedule_gadget::generate_r1cs_witness() -{ - for (size_t i = 0; i < 16; ++i) - { - pack_W[i]->generate_r1cs_witness_from_bits(); - } - - for (size_t i = 16; i < 64; ++i) - { - compute_sigma0[i]->generate_r1cs_witness(); - compute_sigma1[i]->generate_r1cs_witness(); - - this->pb.val(unreduced_W[i]) = this->pb.val(sigma0[i]) + this->pb.val(sigma1[i]) + this->pb.val(packed_W[i-16]) + this->pb.val(packed_W[i-7]); - mod_reduce_W[i]->generate_r1cs_witness(); - } -} - -template -sha256_round_function_gadget::sha256_round_function_gadget(protoboard &pb, - const pb_linear_combination_array &a, - const pb_linear_combination_array &b, - const pb_linear_combination_array &c, - const pb_linear_combination_array &d, - const pb_linear_combination_array &e, - const pb_linear_combination_array &f, - const pb_linear_combination_array &g, - const pb_linear_combination_array &h, - const pb_variable &W, - const uint32_t &K, - const pb_linear_combination_array &new_a, - const pb_linear_combination_array &new_e, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - a(a), - b(b), - c(c), - d(d), - e(e), - f(f), - g(g), - h(h), - W(W), - K(K), - new_a(new_a), - new_e(new_e) -{ - /* compute sigma0 and sigma1 */ - sigma0.allocate(pb, FMT(this->annotation_prefix, " sigma0")); - sigma1.allocate(pb, FMT(this->annotation_prefix, " sigma1")); - compute_sigma0.reset(new big_sigma_gadget(pb, a, sigma0, 2, 13, 22, FMT(this->annotation_prefix, " compute_sigma0"))); - compute_sigma1.reset(new big_sigma_gadget(pb, e, sigma1, 6, 11, 25, FMT(this->annotation_prefix, " compute_sigma1"))); - - /* compute choice */ - choice.allocate(pb, FMT(this->annotation_prefix, " choice")); - compute_choice.reset(new choice_gadget(pb, e, f, g, choice, FMT(this->annotation_prefix, " compute_choice"))); - - /* compute majority */ - majority.allocate(pb, FMT(this->annotation_prefix, " majority")); - compute_majority.reset(new majority_gadget(pb, a, b, c, majority, FMT(this->annotation_prefix, " compute_majority"))); - - /* pack d */ - packed_d.allocate(pb, FMT(this->annotation_prefix, " packed_d")); - pack_d.reset(new packing_gadget(pb, d, packed_d, FMT(this->annotation_prefix, " pack_d"))); - - /* pack h */ - packed_h.allocate(pb, FMT(this->annotation_prefix, " packed_h")); - pack_h.reset(new packing_gadget(pb, h, packed_h, FMT(this->annotation_prefix, " pack_h"))); - - /* compute the actual results for the round */ - unreduced_new_a.allocate(pb, FMT(this->annotation_prefix, " unreduced_new_a")); - unreduced_new_e.allocate(pb, FMT(this->annotation_prefix, " unreduced_new_e")); - - packed_new_a.allocate(pb, FMT(this->annotation_prefix, " packed_new_a")); - packed_new_e.allocate(pb, FMT(this->annotation_prefix, " packed_new_e")); - - mod_reduce_new_a.reset(new lastbits_gadget(pb, unreduced_new_a, 32+3, packed_new_a, new_a, FMT(this->annotation_prefix, " mod_reduce_new_a"))); - mod_reduce_new_e.reset(new lastbits_gadget(pb, unreduced_new_e, 32+3, packed_new_e, new_e, FMT(this->annotation_prefix, " mod_reduce_new_e"))); -} - -template -void sha256_round_function_gadget::generate_r1cs_constraints() -{ - compute_sigma0->generate_r1cs_constraints(); - compute_sigma1->generate_r1cs_constraints(); - - compute_choice->generate_r1cs_constraints(); - compute_majority->generate_r1cs_constraints(); - - pack_d->generate_r1cs_constraints(false); - pack_h->generate_r1cs_constraints(false); - - this->pb.add_r1cs_constraint(r1cs_constraint(1, - packed_h + sigma1 + choice + K + W + sigma0 + majority, - unreduced_new_a), - FMT(this->annotation_prefix, " unreduced_new_a")); - - this->pb.add_r1cs_constraint(r1cs_constraint(1, - packed_d + packed_h + sigma1 + choice + K + W, - unreduced_new_e), - FMT(this->annotation_prefix, " unreduced_new_e")); - - mod_reduce_new_a->generate_r1cs_constraints(); - mod_reduce_new_e->generate_r1cs_constraints(); -} - -template -void sha256_round_function_gadget::generate_r1cs_witness() -{ - compute_sigma0->generate_r1cs_witness(); - compute_sigma1->generate_r1cs_witness(); - - compute_choice->generate_r1cs_witness(); - compute_majority->generate_r1cs_witness(); - - pack_d->generate_r1cs_witness_from_bits(); - pack_h->generate_r1cs_witness_from_bits(); - - this->pb.val(unreduced_new_a) = this->pb.val(packed_h) + this->pb.val(sigma1) + this->pb.val(choice) + FieldT(K) + this->pb.val(W) + this->pb.val(sigma0) + this->pb.val(majority); - this->pb.val(unreduced_new_e) = this->pb.val(packed_d) + this->pb.val(packed_h) + this->pb.val(sigma1) + this->pb.val(choice) + FieldT(K) + this->pb.val(W); - - mod_reduce_new_a->generate_r1cs_witness(); - mod_reduce_new_e->generate_r1cs_witness(); -} - -} // libsnark - -#endif // SHA256_COMPONENTS_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_gadget.hpp b/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_gadget.hpp deleted file mode 100644 index 8cb6365c8..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_gadget.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for top-level SHA256 gadgets. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SHA256_GADGET_HPP_ -#define SHA256_GADGET_HPP_ - -#include "common/data_structures/merkle_tree.hpp" -#include "gadgetlib1/gadgets/basic_gadgets.hpp" -#include "gadgetlib1/gadgets/hashes/hash_io.hpp" -#include "gadgetlib1/gadgets/hashes/sha256/sha256_components.hpp" - -namespace libsnark { - -/** - * Gadget for the SHA256 compression function. - */ -template -class sha256_compression_function_gadget : public gadget { -public: - std::vector > round_a; - std::vector > round_b; - std::vector > round_c; - std::vector > round_d; - std::vector > round_e; - std::vector > round_f; - std::vector > round_g; - std::vector > round_h; - - pb_variable_array packed_W; - std::shared_ptr > message_schedule; - std::vector > round_functions; - - pb_variable_array unreduced_output; - pb_variable_array reduced_output; - std::vector > reduce_output; -public: - pb_linear_combination_array prev_output; - pb_variable_array new_block; - digest_variable output; - - sha256_compression_function_gadget(protoboard &pb, - const pb_linear_combination_array &prev_output, - const pb_variable_array &new_block, - const digest_variable &output, - const std::string &annotation_prefix); - void generate_r1cs_constraints(); - void generate_r1cs_witness(); -}; - -/** - * Gadget for the SHA256 compression function, viewed as a 2-to-1 hash - * function, and using the same initialization vector as in SHA256 - * specification. Thus, any collision for - * sha256_two_to_one_hash_gadget trivially extends to a collision for - * full SHA256 (by appending the same padding). - */ -template -class sha256_two_to_one_hash_gadget : public gadget { -public: - typedef bit_vector hash_value_type; - typedef merkle_authentication_path merkle_authentication_path_type; - - std::shared_ptr > f; - - sha256_two_to_one_hash_gadget(protoboard &pb, - const digest_variable &left, - const digest_variable &right, - const digest_variable &output, - const std::string &annotation_prefix); - sha256_two_to_one_hash_gadget(protoboard &pb, - const size_t block_length, - const block_variable &input_block, - const digest_variable &output, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(const bool ensure_output_bitness=true); // TODO: ignored for now - void generate_r1cs_witness(); - - static size_t get_block_len(); - static size_t get_digest_len(); - static bit_vector get_hash(const bit_vector &input); - - static size_t expected_constraints(const bool ensure_output_bitness=true); // TODO: ignored for now -}; - -} // libsnark - -#include "gadgetlib1/gadgets/hashes/sha256/sha256_gadget.tcc" - -#endif // SHA256_GADGET_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_gadget.tcc b/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_gadget.tcc deleted file mode 100644 index 3004f9e83..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_gadget.tcc +++ /dev/null @@ -1,230 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for top-level SHA256 gadgets. - - See sha256_gadget.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef SHA256_GADGET_TCC_ -#define SHA256_GADGET_TCC_ - -namespace libsnark { - -template -sha256_compression_function_gadget::sha256_compression_function_gadget(protoboard &pb, - const pb_linear_combination_array &prev_output, - const pb_variable_array &new_block, - const digest_variable &output, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - prev_output(prev_output), - new_block(new_block), - output(output) -{ - /* message schedule and inputs for it */ - packed_W.allocate(pb, 64, FMT(this->annotation_prefix, " packed_W")); - message_schedule.reset(new sha256_message_schedule_gadget(pb, new_block, packed_W, FMT(this->annotation_prefix, " message_schedule"))); - - /* initalize */ - round_a.push_back(pb_linear_combination_array(prev_output.rbegin() + 7*32, prev_output.rbegin() + 8*32)); - round_b.push_back(pb_linear_combination_array(prev_output.rbegin() + 6*32, prev_output.rbegin() + 7*32)); - round_c.push_back(pb_linear_combination_array(prev_output.rbegin() + 5*32, prev_output.rbegin() + 6*32)); - round_d.push_back(pb_linear_combination_array(prev_output.rbegin() + 4*32, prev_output.rbegin() + 5*32)); - round_e.push_back(pb_linear_combination_array(prev_output.rbegin() + 3*32, prev_output.rbegin() + 4*32)); - round_f.push_back(pb_linear_combination_array(prev_output.rbegin() + 2*32, prev_output.rbegin() + 3*32)); - round_g.push_back(pb_linear_combination_array(prev_output.rbegin() + 1*32, prev_output.rbegin() + 2*32)); - round_h.push_back(pb_linear_combination_array(prev_output.rbegin() + 0*32, prev_output.rbegin() + 1*32)); - - /* do the rounds */ - for (size_t i = 0; i < 64; ++i) - { - round_h.push_back(round_g[i]); - round_g.push_back(round_f[i]); - round_f.push_back(round_e[i]); - round_d.push_back(round_c[i]); - round_c.push_back(round_b[i]); - round_b.push_back(round_a[i]); - - pb_variable_array new_round_a_variables; - new_round_a_variables.allocate(pb, 32, FMT(this->annotation_prefix, " new_round_a_variables_%zu", i+1)); - round_a.emplace_back(new_round_a_variables); - - pb_variable_array new_round_e_variables; - new_round_e_variables.allocate(pb, 32, FMT(this->annotation_prefix, " new_round_e_variables_%zu", i+1)); - round_e.emplace_back(new_round_e_variables); - - round_functions.push_back(sha256_round_function_gadget(pb, - round_a[i], round_b[i], round_c[i], round_d[i], - round_e[i], round_f[i], round_g[i], round_h[i], - packed_W[i], SHA256_K[i], round_a[i+1], round_e[i+1], - FMT(this->annotation_prefix, " round_functions_%zu", i))); - } - - /* finalize */ - unreduced_output.allocate(pb, 8, FMT(this->annotation_prefix, " unreduced_output")); - reduced_output.allocate(pb, 8, FMT(this->annotation_prefix, " reduced_output")); - for (size_t i = 0; i < 8; ++i) - { - reduce_output.push_back(lastbits_gadget(pb, - unreduced_output[i], - 32+1, - reduced_output[i], - pb_variable_array(output.bits.rbegin() + (7-i) * 32, output.bits.rbegin() + (8-i) * 32), - FMT(this->annotation_prefix, " reduce_output_%zu", i))); - } -} - -template -void sha256_compression_function_gadget::generate_r1cs_constraints() -{ - message_schedule->generate_r1cs_constraints(); - for (size_t i = 0; i < 64; ++i) - { - round_functions[i].generate_r1cs_constraints(); - } - - for (size_t i = 0; i < 4; ++i) - { - this->pb.add_r1cs_constraint(r1cs_constraint(1, - round_functions[3-i].packed_d + round_functions[63-i].packed_new_a, - unreduced_output[i]), - FMT(this->annotation_prefix, " unreduced_output_%zu", i)); - - this->pb.add_r1cs_constraint(r1cs_constraint(1, - round_functions[3-i].packed_h + round_functions[63-i].packed_new_e, - unreduced_output[4+i]), - FMT(this->annotation_prefix, " unreduced_output_%zu", 4+i)); - } - - for (size_t i = 0; i < 8; ++i) - { - reduce_output[i].generate_r1cs_constraints(); - } -} - -template -void sha256_compression_function_gadget::generate_r1cs_witness() -{ - message_schedule->generate_r1cs_witness(); - -#ifdef DEBUG - printf("Input:\n"); - for (size_t j = 0; j < 16; ++j) - { - printf("%lx ", this->pb.val(packed_W[j]).as_uint64()); - } - printf("\n"); -#endif - - for (size_t i = 0; i < 64; ++i) - { - round_functions[i].generate_r1cs_witness(); - } - - for (size_t i = 0; i < 4; ++i) - { - this->pb.val(unreduced_output[i]) = this->pb.val(round_functions[3-i].packed_d) + this->pb.val(round_functions[63-i].packed_new_a); - this->pb.val(unreduced_output[4+i]) = this->pb.val(round_functions[3-i].packed_h) + this->pb.val(round_functions[63-i].packed_new_e); - } - - for (size_t i = 0; i < 8; ++i) - { - reduce_output[i].generate_r1cs_witness(); - } - -#ifdef DEBUG - printf("Output:\n"); - for (size_t j = 0; j < 8; ++j) - { - printf("%lx ", this->pb.val(reduced_output[j]).as_uint64()); - } - printf("\n"); -#endif -} - -template -sha256_two_to_one_hash_gadget::sha256_two_to_one_hash_gadget(protoboard &pb, - const digest_variable &left, - const digest_variable &right, - const digest_variable &output, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix) -{ - /* concatenate block = left || right */ - pb_variable_array block; - block.insert(block.end(), left.bits.begin(), left.bits.end()); - block.insert(block.end(), right.bits.begin(), right.bits.end()); - - /* compute the hash itself */ - f.reset(new sha256_compression_function_gadget(pb, SHA256_default_IV(pb), block, output, FMT(this->annotation_prefix, " f"))); -} - -template -sha256_two_to_one_hash_gadget::sha256_two_to_one_hash_gadget(protoboard &pb, - const size_t block_length, - const block_variable &input_block, - const digest_variable &output, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix) -{ - assert(block_length == SHA256_block_size); - assert(input_block.bits.size() == block_length); - f.reset(new sha256_compression_function_gadget(pb, SHA256_default_IV(pb), input_block.bits, output, FMT(this->annotation_prefix, " f"))); -} - -template -void sha256_two_to_one_hash_gadget::generate_r1cs_constraints(const bool ensure_output_bitness) -{ - UNUSED(ensure_output_bitness); - f->generate_r1cs_constraints(); -} - -template -void sha256_two_to_one_hash_gadget::generate_r1cs_witness() -{ - f->generate_r1cs_witness(); -} - -template -size_t sha256_two_to_one_hash_gadget::get_block_len() -{ - return SHA256_block_size; -} - -template -size_t sha256_two_to_one_hash_gadget::get_digest_len() -{ - return SHA256_digest_size; -} - -template -bit_vector sha256_two_to_one_hash_gadget::get_hash(const bit_vector &input) -{ - protoboard pb; - - block_variable input_variable(pb, SHA256_block_size, "input"); - digest_variable output_variable(pb, SHA256_digest_size, "output"); - sha256_two_to_one_hash_gadget f(pb, SHA256_block_size, input_variable, output_variable, "f"); - - input_variable.generate_r1cs_witness(input); - f.generate_r1cs_witness(); - - return output_variable.get_digest(); -} - -template -size_t sha256_two_to_one_hash_gadget::expected_constraints(const bool ensure_output_bitness) -{ - UNUSED(ensure_output_bitness); - return 27280; /* hardcoded for now */ -} - -} // libsnark - -#endif // SHA256_GADGET_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/generate_sha256_gadget_tests.py b/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/generate_sha256_gadget_tests.py deleted file mode 100644 index 452317ffb..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/generate_sha256_gadget_tests.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python -## -# @author This file is part of libsnark, developed by SCIPR Lab -# and contributors (see AUTHORS). -# @copyright MIT license (see LICENSE file) - -import random -import pypy_sha256 # PyPy's implementation of SHA256 compression function; see copyright and authorship notice within. - -BLOCK_LEN = 512 -BLOCK_BYTES = BLOCK_LEN // 8 -HASH_LEN = 256 -HASH_BYTES = HASH_LEN // 8 - -def gen_random_bytes(n): - return [random.randint(0, 255) for i in xrange(n)] - -def words_to_bytes(arr): - return sum(([x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff] for x in arr), []) - -def bytes_to_words(arr): - l = len(arr) - assert l % 4 == 0 - return [(arr[i*4 + 3] << 24) + (arr[i*4+2] << 16) + (arr[i*4+1] << 8) + arr[i*4] for i in xrange(l//4)] - -def cpp_val(s, log_radix=32): - if log_radix == 8: - hexfmt = '0x%02x' - elif log_radix == 32: - hexfmt = '0x%08x' - s = bytes_to_words(s) - else: - raise - return 'int_list_to_bits({%s}, %d)' % (', '.join(hexfmt % x for x in s), log_radix) - -def H_bytes(x): - assert len(x) == BLOCK_BYTES - state = pypy_sha256.sha_init() - state['data'] = words_to_bytes(bytes_to_words(x)) - pypy_sha256.sha_transform(state) - return words_to_bytes(bytes_to_words(words_to_bytes(state['digest']))) - -def generate_sha256_gadget_tests(): - left = gen_random_bytes(HASH_BYTES) - right = gen_random_bytes(HASH_BYTES) - hash = H_bytes(left + right) - - print "const bit_vector left_bv = %s;" % cpp_val(left) - print "const bit_vector right_bv = %s;" % cpp_val(right) - print "const bit_vector hash_bv = %s;" % cpp_val(hash) - -if __name__ == '__main__': - random.seed(0) # for reproducibility - generate_sha256_gadget_tests() - diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/pypy_sha256.py b/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/pypy_sha256.py deleted file mode 100644 index 496989c11..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/pypy_sha256.py +++ /dev/null @@ -1,263 +0,0 @@ -#!/usr/bin/env python -# -# SHA256 compression function implementation below is a verbatim copy of PyPy's implementation from -# https://bitbucket.org/pypy/pypy/raw/f1f064b3faf1e012f7a9a9ab08f18074637ebe8a/lib_pypy/_sha256.py . -# -# It is licensed under the MIT license and copyright PyPy Copyright holders 2003-2015 -# See https://bitbucket.org/pypy/pypy/src/tip/LICENSE for the full copyright notice. -# - -SHA_BLOCKSIZE = 64 -SHA_DIGESTSIZE = 32 - - -def new_shaobject(): - return { - 'digest': [0]*8, - 'count_lo': 0, - 'count_hi': 0, - 'data': [0]* SHA_BLOCKSIZE, - 'local': 0, - 'digestsize': 0 - } - -ROR = lambda x, y: (((x & 0xffffffff) >> (y & 31)) | (x << (32 - (y & 31)))) & 0xffffffff -Ch = lambda x, y, z: (z ^ (x & (y ^ z))) -Maj = lambda x, y, z: (((x | y) & z) | (x & y)) -S = lambda x, n: ROR(x, n) -R = lambda x, n: (x & 0xffffffff) >> n -Sigma0 = lambda x: (S(x, 2) ^ S(x, 13) ^ S(x, 22)) -Sigma1 = lambda x: (S(x, 6) ^ S(x, 11) ^ S(x, 25)) -Gamma0 = lambda x: (S(x, 7) ^ S(x, 18) ^ R(x, 3)) -Gamma1 = lambda x: (S(x, 17) ^ S(x, 19) ^ R(x, 10)) - -def sha_transform(sha_info): - W = [] - - d = sha_info['data'] - for i in range(0,16): - W.append( (d[4*i]<<24) + (d[4*i+1]<<16) + (d[4*i+2]<<8) + d[4*i+3]) - - for i in range(16,64): - W.append( (Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16]) & 0xffffffff ) - - ss = sha_info['digest'][:] - - def RND(a,b,c,d,e,f,g,h,i,ki): - t0 = h + Sigma1(e) + Ch(e, f, g) + ki + W[i]; - t1 = Sigma0(a) + Maj(a, b, c); - d += t0; - h = t0 + t1; - return d & 0xffffffff, h & 0xffffffff - - ss[3], ss[7] = RND(ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],0,0x428a2f98); - ss[2], ss[6] = RND(ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],1,0x71374491); - ss[1], ss[5] = RND(ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],2,0xb5c0fbcf); - ss[0], ss[4] = RND(ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],3,0xe9b5dba5); - ss[7], ss[3] = RND(ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],4,0x3956c25b); - ss[6], ss[2] = RND(ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],5,0x59f111f1); - ss[5], ss[1] = RND(ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],6,0x923f82a4); - ss[4], ss[0] = RND(ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],7,0xab1c5ed5); - ss[3], ss[7] = RND(ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],8,0xd807aa98); - ss[2], ss[6] = RND(ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],9,0x12835b01); - ss[1], ss[5] = RND(ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],10,0x243185be); - ss[0], ss[4] = RND(ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],11,0x550c7dc3); - ss[7], ss[3] = RND(ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],12,0x72be5d74); - ss[6], ss[2] = RND(ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],13,0x80deb1fe); - ss[5], ss[1] = RND(ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],14,0x9bdc06a7); - ss[4], ss[0] = RND(ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],15,0xc19bf174); - ss[3], ss[7] = RND(ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],16,0xe49b69c1); - ss[2], ss[6] = RND(ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],17,0xefbe4786); - ss[1], ss[5] = RND(ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],18,0x0fc19dc6); - ss[0], ss[4] = RND(ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],19,0x240ca1cc); - ss[7], ss[3] = RND(ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],20,0x2de92c6f); - ss[6], ss[2] = RND(ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],21,0x4a7484aa); - ss[5], ss[1] = RND(ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],22,0x5cb0a9dc); - ss[4], ss[0] = RND(ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],23,0x76f988da); - ss[3], ss[7] = RND(ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],24,0x983e5152); - ss[2], ss[6] = RND(ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],25,0xa831c66d); - ss[1], ss[5] = RND(ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],26,0xb00327c8); - ss[0], ss[4] = RND(ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],27,0xbf597fc7); - ss[7], ss[3] = RND(ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],28,0xc6e00bf3); - ss[6], ss[2] = RND(ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],29,0xd5a79147); - ss[5], ss[1] = RND(ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],30,0x06ca6351); - ss[4], ss[0] = RND(ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],31,0x14292967); - ss[3], ss[7] = RND(ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],32,0x27b70a85); - ss[2], ss[6] = RND(ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],33,0x2e1b2138); - ss[1], ss[5] = RND(ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],34,0x4d2c6dfc); - ss[0], ss[4] = RND(ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],35,0x53380d13); - ss[7], ss[3] = RND(ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],36,0x650a7354); - ss[6], ss[2] = RND(ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],37,0x766a0abb); - ss[5], ss[1] = RND(ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],38,0x81c2c92e); - ss[4], ss[0] = RND(ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],39,0x92722c85); - ss[3], ss[7] = RND(ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],40,0xa2bfe8a1); - ss[2], ss[6] = RND(ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],41,0xa81a664b); - ss[1], ss[5] = RND(ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],42,0xc24b8b70); - ss[0], ss[4] = RND(ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],43,0xc76c51a3); - ss[7], ss[3] = RND(ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],44,0xd192e819); - ss[6], ss[2] = RND(ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],45,0xd6990624); - ss[5], ss[1] = RND(ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],46,0xf40e3585); - ss[4], ss[0] = RND(ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],47,0x106aa070); - ss[3], ss[7] = RND(ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],48,0x19a4c116); - ss[2], ss[6] = RND(ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],49,0x1e376c08); - ss[1], ss[5] = RND(ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],50,0x2748774c); - ss[0], ss[4] = RND(ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],51,0x34b0bcb5); - ss[7], ss[3] = RND(ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],52,0x391c0cb3); - ss[6], ss[2] = RND(ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],53,0x4ed8aa4a); - ss[5], ss[1] = RND(ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],54,0x5b9cca4f); - ss[4], ss[0] = RND(ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],55,0x682e6ff3); - ss[3], ss[7] = RND(ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],56,0x748f82ee); - ss[2], ss[6] = RND(ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],57,0x78a5636f); - ss[1], ss[5] = RND(ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],58,0x84c87814); - ss[0], ss[4] = RND(ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],59,0x8cc70208); - ss[7], ss[3] = RND(ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],60,0x90befffa); - ss[6], ss[2] = RND(ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],61,0xa4506ceb); - ss[5], ss[1] = RND(ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],62,0xbef9a3f7); - ss[4], ss[0] = RND(ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],63,0xc67178f2); - - dig = [] - for i, x in enumerate(sha_info['digest']): - dig.append( (x + ss[i]) & 0xffffffff ) - sha_info['digest'] = dig - -def sha_init(): - sha_info = new_shaobject() - sha_info['digest'] = [0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19] - sha_info['count_lo'] = 0 - sha_info['count_hi'] = 0 - sha_info['local'] = 0 - sha_info['digestsize'] = 32 - return sha_info - -def sha224_init(): - sha_info = new_shaobject() - sha_info['digest'] = [0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4] - sha_info['count_lo'] = 0 - sha_info['count_hi'] = 0 - sha_info['local'] = 0 - sha_info['digestsize'] = 28 - return sha_info - -def sha_update(sha_info, buffer): - if isinstance(buffer, str): - raise TypeError("Unicode strings must be encoded before hashing") - count = len(buffer) - buffer_idx = 0 - clo = (sha_info['count_lo'] + (count << 3)) & 0xffffffff - if clo < sha_info['count_lo']: - sha_info['count_hi'] += 1 - sha_info['count_lo'] = clo - - sha_info['count_hi'] += (count >> 29) - - if sha_info['local']: - i = SHA_BLOCKSIZE - sha_info['local'] - if i > count: - i = count - - # copy buffer - sha_info['data'][sha_info['local']:sha_info['local']+i] = buffer[buffer_idx:buffer_idx+i] - - count -= i - buffer_idx += i - - sha_info['local'] += i - if sha_info['local'] == SHA_BLOCKSIZE: - sha_transform(sha_info) - sha_info['local'] = 0 - else: - return - - while count >= SHA_BLOCKSIZE: - # copy buffer - sha_info['data'] = list(buffer[buffer_idx:buffer_idx + SHA_BLOCKSIZE]) - count -= SHA_BLOCKSIZE - buffer_idx += SHA_BLOCKSIZE - sha_transform(sha_info) - - - # copy buffer - pos = sha_info['local'] - sha_info['data'][pos:pos+count] = buffer[buffer_idx:buffer_idx + count] - sha_info['local'] = count - -def sha_final(sha_info): - lo_bit_count = sha_info['count_lo'] - hi_bit_count = sha_info['count_hi'] - count = (lo_bit_count >> 3) & 0x3f - sha_info['data'][count] = 0x80; - count += 1 - if count > SHA_BLOCKSIZE - 8: - # zero the bytes in data after the count - sha_info['data'] = sha_info['data'][:count] + ([0] * (SHA_BLOCKSIZE - count)) - sha_transform(sha_info) - # zero bytes in data - sha_info['data'] = [0] * SHA_BLOCKSIZE - else: - sha_info['data'] = sha_info['data'][:count] + ([0] * (SHA_BLOCKSIZE - count)) - - sha_info['data'][56] = (hi_bit_count >> 24) & 0xff - sha_info['data'][57] = (hi_bit_count >> 16) & 0xff - sha_info['data'][58] = (hi_bit_count >> 8) & 0xff - sha_info['data'][59] = (hi_bit_count >> 0) & 0xff - sha_info['data'][60] = (lo_bit_count >> 24) & 0xff - sha_info['data'][61] = (lo_bit_count >> 16) & 0xff - sha_info['data'][62] = (lo_bit_count >> 8) & 0xff - sha_info['data'][63] = (lo_bit_count >> 0) & 0xff - - sha_transform(sha_info) - - dig = [] - for i in sha_info['digest']: - dig.extend([ ((i>>24) & 0xff), ((i>>16) & 0xff), ((i>>8) & 0xff), (i & 0xff) ]) - return ''.join([chr(i) for i in dig]) - -class sha256(object): - digest_size = digestsize = SHA_DIGESTSIZE - block_size = SHA_BLOCKSIZE - - def __init__(self, s=None): - self._sha = sha_init() - if s: - sha_update(self._sha, s) - - def update(self, s): - sha_update(self._sha, s) - - def digest(self): - return sha_final(self._sha.copy())[:self._sha['digestsize']] - - def hexdigest(self): - return ''.join(['%.2x' % ord(i) for i in self.digest()]) - - def copy(self): - new = sha256.__new__(sha256) - new._sha = self._sha.copy() - return new - -class sha224(sha256): - digest_size = digestsize = 28 - - def __init__(self, s=None): - self._sha = sha224_init() - if s: - sha_update(self._sha, s) - - def copy(self): - new = sha224.__new__(sha224) - new._sha = self._sha.copy() - return new - -def test(): - a_str = "just a test string" - - assert 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' == sha256().hexdigest() - assert 'd7b553c6f09ac85d142415f857c5310f3bbbe7cdd787cce4b985acedd585266f' == sha256(a_str).hexdigest() - assert '8113ebf33c97daa9998762aacafe750c7cefc2b2f173c90c59663a57fe626f21' == sha256(a_str*7).hexdigest() - - s = sha256(a_str) - s.update(a_str) - assert '03d9963e05a094593190b6fc794cb1a3e1ac7d7883f0b5855268afeccc70d461' == s.hexdigest() - -if __name__ == "__main__": - test() diff --git a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/test_sha256_gadget.cpp b/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/test_sha256_gadget.cpp deleted file mode 100644 index 0bfaf3a12..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/hashes/sha256/tests/test_sha256_gadget.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#include "common/default_types/ec_pp.hpp" -#include "common/utils.hpp" -#include "common/profiling.hpp" -#include "gadgetlib1/gadgets/hashes/sha256/sha256_gadget.hpp" - -#include - -using namespace libsnark; - -template -void test_two_to_one() -{ - protoboard pb; - - digest_variable left(pb, SHA256_digest_size, "left"); - digest_variable right(pb, SHA256_digest_size, "right"); - digest_variable output(pb, SHA256_digest_size, "output"); - - sha256_two_to_one_hash_gadget f(pb, left, right, output, "f"); - f.generate_r1cs_constraints(); - printf("Number of constraints for sha256_two_to_one_hash_gadget: %zu\n", pb.num_constraints()); - - const bit_vector left_bv = int_list_to_bits({0x426bc2d8, 0x4dc86782, 0x81e8957a, 0x409ec148, 0xe6cffbe8, 0xafe6ba4f, 0x9c6f1978, 0xdd7af7e9}, 32); - const bit_vector right_bv = int_list_to_bits({0x038cce42, 0xabd366b8, 0x3ede7e00, 0x9130de53, 0x72cdf73d, 0xee825114, 0x8cb48d1b, 0x9af68ad0}, 32); - const bit_vector hash_bv = int_list_to_bits({0xeffd0b7f, 0x1ccba116, 0x2ee816f7, 0x31c62b48, 0x59305141, 0x990e5c0a, 0xce40d33d, 0x0b1167d1}, 32); - - left.generate_r1cs_witness(left_bv); - right.generate_r1cs_witness(right_bv); - - f.generate_r1cs_witness(); - output.generate_r1cs_witness(hash_bv); - - EXPECT_TRUE(pb.is_satisfied()); -} - -TEST(gadgetlib1, sha256) -{ - start_profiling(); - default_ec_pp::init_public_params(); - test_two_to_one >(); -} diff --git a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_authentication_path_variable.hpp b/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_authentication_path_variable.hpp deleted file mode 100644 index 0efa7cf4d..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_authentication_path_variable.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef MERKLE_AUTHENTICATION_PATH_VARIABLE_HPP_ -#define MERKLE_AUTHENTICATION_PATH_VARIABLE_HPP_ - -#include "common/data_structures/merkle_tree.hpp" -#include "gadgetlib1/gadget.hpp" -#include "gadgetlib1/gadgets/hashes/hash_io.hpp" - -namespace libsnark { - -template -class merkle_authentication_path_variable : public gadget { -public: - - const size_t tree_depth; - std::vector > left_digests; - std::vector > right_digests; - - merkle_authentication_path_variable(protoboard &pb, - const size_t tree_depth, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(const size_t address, const merkle_authentication_path &path); - merkle_authentication_path get_authentication_path(const size_t address) const; -}; - -} // libsnark - -#include "gadgetlib1/gadgets/merkle_tree/merkle_authentication_path_variable.tcc" - -#endif // MERKLE_AUTHENTICATION_PATH_VARIABLE_HPP diff --git a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_authentication_path_variable.tcc b/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_authentication_path_variable.tcc deleted file mode 100644 index b3d805d8e..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_authentication_path_variable.tcc +++ /dev/null @@ -1,76 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef MERKLE_AUTHENTICATION_PATH_VARIABLE_TCC_ -#define MERKLE_AUTHENTICATION_PATH_VARIABLE_TCC_ - -namespace libsnark { - -template -merkle_authentication_path_variable::merkle_authentication_path_variable(protoboard &pb, - const size_t tree_depth, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - tree_depth(tree_depth) -{ - for (size_t i = 0; i < tree_depth; ++i) - { - left_digests.emplace_back(digest_variable(pb, HashT::get_digest_len(), FMT(annotation_prefix, " left_digests_%zu", i))); - right_digests.emplace_back(digest_variable(pb, HashT::get_digest_len(), FMT(annotation_prefix, " right_digests_%zu", i))); - } -} - -template -void merkle_authentication_path_variable::generate_r1cs_constraints() -{ - for (size_t i = 0; i < tree_depth; ++i) - { - left_digests[i].generate_r1cs_constraints(); - right_digests[i].generate_r1cs_constraints(); - } -} - -template -void merkle_authentication_path_variable::generate_r1cs_witness(const size_t address, const merkle_authentication_path &path) -{ - assert(path.size() == tree_depth); - - for (size_t i = 0; i < tree_depth; ++i) - { - if (address & (UINT64_C(1) << (tree_depth-1-i))) - { - left_digests[i].generate_r1cs_witness(path[i]); - } - else - { - right_digests[i].generate_r1cs_witness(path[i]); - } - } -} - -template -merkle_authentication_path merkle_authentication_path_variable::get_authentication_path(const size_t address) const -{ - merkle_authentication_path result; - for (size_t i = 0; i < tree_depth; ++i) - { - if (address & (UINT64_C(1) << (tree_depth-1-i))) - { - result.emplace_back(left_digests[i].get_digest()); - } - else - { - result.emplace_back(right_digests[i].get_digest()); - } - } - - return result; -} - -} // libsnark - -#endif // MERKLE_AUTHENTICATION_PATH_VARIABLE_TCC diff --git a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_read_gadget.hpp b/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_read_gadget.hpp deleted file mode 100644 index b1e3a4f05..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_read_gadget.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for the Merkle tree check read gadget. - - The gadget checks the following: given a root R, address A, value V, and - authentication path P, check that P is a valid authentication path for the - value V as the A-th leaf in a Merkle tree with root R. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef MERKLE_TREE_CHECK_READ_GADGET_HPP_ -#define MERKLE_TREE_CHECK_READ_GADGET_HPP_ - -#include "common/data_structures/merkle_tree.hpp" -#include "gadgetlib1/gadget.hpp" -#include "gadgetlib1/gadgets/hashes/hash_io.hpp" -#include "gadgetlib1/gadgets/hashes/digest_selector_gadget.hpp" -#include "gadgetlib1/gadgets/merkle_tree/merkle_authentication_path_variable.hpp" - -namespace libsnark { - -template -class merkle_tree_check_read_gadget : public gadget { -private: - - std::vector hashers; - std::vector > hasher_inputs; - std::vector > propagators; - std::vector > internal_output; - - std::shared_ptr > computed_root; - std::shared_ptr > check_root; - -public: - - const size_t digest_size; - const size_t tree_depth; - pb_linear_combination_array address_bits; - digest_variable leaf; - digest_variable root; - merkle_authentication_path_variable path; - pb_linear_combination read_successful; - - merkle_tree_check_read_gadget(protoboard &pb, - const size_t tree_depth, - const pb_linear_combination_array &address_bits, - const digest_variable &leaf_digest, - const digest_variable &root_digest, - const merkle_authentication_path_variable &path, - const pb_linear_combination &read_successful, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); - - static size_t root_size_in_bits(); - /* for debugging purposes */ - static size_t expected_constraints(const size_t tree_depth); -}; - -template -void test_merkle_tree_check_read_gadget(); - -} // libsnark - -#include "gadgetlib1/gadgets/merkle_tree/merkle_tree_check_read_gadget.tcc" - -#endif // MERKLE_TREE_CHECK_READ_GADGET_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_read_gadget.tcc b/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_read_gadget.tcc deleted file mode 100644 index 29ce1b8ac..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_read_gadget.tcc +++ /dev/null @@ -1,196 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for the Merkle tree check read. - - See merkle_tree_check_read_gadget.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef MERKLE_TREE_CHECK_READ_GADGET_TCC_ -#define MERKLE_TREE_CHECK_READ_GADGET_TCC_ - -namespace libsnark { - -template -merkle_tree_check_read_gadget::merkle_tree_check_read_gadget(protoboard &pb, - const size_t tree_depth, - const pb_linear_combination_array &address_bits, - const digest_variable &leaf, - const digest_variable &root, - const merkle_authentication_path_variable &path, - const pb_linear_combination &read_successful, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - digest_size(HashT::get_digest_len()), - tree_depth(tree_depth), - address_bits(address_bits), - leaf(leaf), - root(root), - path(path), - read_successful(read_successful) -{ - /* - The tricky part here is ordering. For Merkle tree - authentication paths, path[0] corresponds to one layer below - the root (and path[tree_depth-1] corresponds to the layer - containing the leaf), while address_bits has the reverse order: - address_bits[0] is LSB, and corresponds to layer containing the - leaf, and address_bits[tree_depth-1] is MSB, and corresponds to - the subtree directly under the root. - */ - assert(tree_depth > 0); - assert(tree_depth == address_bits.size()); - - for (size_t i = 0; i < tree_depth-1; ++i) - { - internal_output.emplace_back(digest_variable(pb, digest_size, FMT(this->annotation_prefix, " internal_output_%zu", i))); - } - - computed_root.reset(new digest_variable(pb, digest_size, FMT(this->annotation_prefix, " computed_root"))); - - for (size_t i = 0; i < tree_depth; ++i) - { - block_variable inp(pb, path.left_digests[i], path.right_digests[i], FMT(this->annotation_prefix, " inp_%zu", i)); - hasher_inputs.emplace_back(inp); - hashers.emplace_back(HashT(pb, 2*digest_size, inp, (i == 0 ? *computed_root : internal_output[i-1]), - FMT(this->annotation_prefix, " load_hashers_%zu", i))); - } - - for (size_t i = 0; i < tree_depth; ++i) - { - /* - The propagators take a computed hash value (or leaf in the - base case) and propagate it one layer up, either in the left - or the right slot of authentication_path_variable. - */ - propagators.emplace_back(digest_selector_gadget(pb, digest_size, i < tree_depth - 1 ? internal_output[i] : leaf, - address_bits[tree_depth-1-i], path.left_digests[i], path.right_digests[i], - FMT(this->annotation_prefix, " digest_selector_%zu", i))); - } - - check_root.reset(new bit_vector_copy_gadget(pb, computed_root->bits, root.bits, read_successful, FieldT::capacity(), FMT(annotation_prefix, " check_root"))); -} - -template -void merkle_tree_check_read_gadget::generate_r1cs_constraints() -{ - /* ensure correct hash computations */ - for (size_t i = 0; i < tree_depth; ++i) - { - // Note that we check root outside and have enforced booleanity of path.left_digests/path.right_digests outside in path.generate_r1cs_constraints - hashers[i].generate_r1cs_constraints(false); - } - - /* ensure consistency of path.left_digests/path.right_digests with internal_output */ - for (size_t i = 0; i < tree_depth; ++i) - { - propagators[i].generate_r1cs_constraints(); - } - - check_root->generate_r1cs_constraints(false, false); -} - -template -void merkle_tree_check_read_gadget::generate_r1cs_witness() -{ - /* do the hash computations bottom-up */ - for (int i = tree_depth-1; i >= 0; --i) - { - /* propagate previous input */ - propagators[i].generate_r1cs_witness(); - - /* compute hash */ - hashers[i].generate_r1cs_witness(); - } - - check_root->generate_r1cs_witness(); -} - -template -size_t merkle_tree_check_read_gadget::root_size_in_bits() -{ - return HashT::get_digest_len(); -} - -template -size_t merkle_tree_check_read_gadget::expected_constraints(const size_t tree_depth) -{ - /* NB: this includes path constraints */ - const size_t hasher_constraints = tree_depth * HashT::expected_constraints(false); - const size_t propagator_constraints = tree_depth * HashT::get_digest_len(); - const size_t authentication_path_constraints = 2 * tree_depth * HashT::get_digest_len(); - const size_t check_root_constraints = 3 * div_ceil(HashT::get_digest_len(), FieldT::capacity()); - - return hasher_constraints + propagator_constraints + authentication_path_constraints + check_root_constraints; -} - -template -void test_merkle_tree_check_read_gadget() -{ - /* prepare test */ - const size_t digest_len = HashT::get_digest_len(); - const size_t tree_depth = 16; - std::vector path(tree_depth); - - bit_vector prev_hash(digest_len); - std::generate(prev_hash.begin(), prev_hash.end(), [&]() { return std::rand() % 2; }); - bit_vector leaf = prev_hash; - - bit_vector address_bits; - - size_t address = 0; - for (int64_t level = tree_depth-1; level >= 0; --level) - { - const bool computed_is_right = (std::rand() % 2); - address |= (computed_is_right ? UINT64_C(1) << (tree_depth-1-level) : 0); - address_bits.push_back(computed_is_right); - bit_vector other(digest_len); - std::generate(other.begin(), other.end(), [&]() { return std::rand() % 2; }); - - bit_vector block = prev_hash; - block.insert(computed_is_right ? block.begin() : block.end(), other.begin(), other.end()); - bit_vector h = HashT::get_hash(block); - - path[level] = other; - - prev_hash = h; - } - bit_vector root = prev_hash; - - /* execute test */ - protoboard pb; - pb_variable_array address_bits_va; - address_bits_va.allocate(pb, tree_depth, "address_bits"); - digest_variable leaf_digest(pb, digest_len, "input_block"); - digest_variable root_digest(pb, digest_len, "output_digest"); - merkle_authentication_path_variable path_var(pb, tree_depth, "path_var"); - merkle_tree_check_read_gadget ml(pb, tree_depth, address_bits_va, leaf_digest, root_digest, path_var, ONE, "ml"); - - path_var.generate_r1cs_constraints(); - ml.generate_r1cs_constraints(); - - address_bits_va.fill_with_bits(pb, address_bits); - assert(address_bits_va.get_field_element_from_bits(pb).as_uint64() == address); - leaf_digest.generate_r1cs_witness(leaf); - path_var.generate_r1cs_witness(address, path); - ml.generate_r1cs_witness(); - - /* make sure that read checker didn't accidentally overwrite anything */ - address_bits_va.fill_with_bits(pb, address_bits); - leaf_digest.generate_r1cs_witness(leaf); - root_digest.generate_r1cs_witness(root); - assert(pb.is_satisfied()); - - const size_t num_constraints = pb.num_constraints(); - const size_t expected_constraints = merkle_tree_check_read_gadget::expected_constraints(tree_depth); - assert(num_constraints == expected_constraints); -} - -} // libsnark - -#endif // MERKLE_TREE_CHECK_READ_GADGET_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_update_gadget.hpp b/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_update_gadget.hpp deleted file mode 100644 index 6ec0ca11f..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_update_gadget.hpp +++ /dev/null @@ -1,90 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for the Merkle tree check read gadget. - - The gadget checks the following: given two roots R1 and R2, address A, two - values V1 and V2, and authentication path P, check that - - P is a valid authentication path for the value V1 as the A-th leaf in a Merkle tree with root R1, and - - P is a valid authentication path for the value V2 as the A-th leaf in a Merkle tree with root R2. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef MERKLE_TREE_CHECK_UPDATE_GADGET_HPP_ -#define MERKLE_TREE_CHECK_UPDATE_GADGET_HPP_ - -#include "common/data_structures/merkle_tree.hpp" -#include "gadgetlib1/gadget.hpp" -#include "gadgetlib1/gadgets/hashes/hash_io.hpp" -#include "gadgetlib1/gadgets/hashes/digest_selector_gadget.hpp" -#include "gadgetlib1/gadgets/merkle_tree/merkle_authentication_path_variable.hpp" - -namespace libsnark { - -template -class merkle_tree_check_update_gadget : public gadget { -private: - - std::vector prev_hashers; - std::vector > prev_hasher_inputs; - std::vector > prev_propagators; - std::vector > prev_internal_output; - - std::vector next_hashers; - std::vector > next_hasher_inputs; - std::vector > next_propagators; - std::vector > next_internal_output; - - std::shared_ptr > computed_next_root; - std::shared_ptr > check_next_root; - -public: - - const size_t digest_size; - const size_t tree_depth; - - pb_variable_array address_bits; - digest_variable prev_leaf_digest; - digest_variable prev_root_digest; - merkle_authentication_path_variable prev_path; - digest_variable next_leaf_digest; - digest_variable next_root_digest; - merkle_authentication_path_variable next_path; - pb_linear_combination update_successful; - - /* Note that while it is necessary to generate R1CS constraints - for prev_path, it is not necessary to do so for next_path. See - comment in the implementation of generate_r1cs_constraints() */ - - merkle_tree_check_update_gadget(protoboard &pb, - const size_t tree_depth, - const pb_variable_array &address_bits, - const digest_variable &prev_leaf_digest, - const digest_variable &prev_root_digest, - const merkle_authentication_path_variable &prev_path, - const digest_variable &next_leaf_digest, - const digest_variable &next_root_digest, - const merkle_authentication_path_variable &next_path, - const pb_linear_combination &update_successful, - const std::string &annotation_prefix); - - void generate_r1cs_constraints(); - void generate_r1cs_witness(); - - static size_t root_size_in_bits(); - /* for debugging purposes */ - static size_t expected_constraints(const size_t tree_depth); -}; - -template -void test_merkle_tree_check_update_gadget(); - -} // libsnark - -#include "gadgetlib1/gadgets/merkle_tree/merkle_tree_check_update_gadget.tcc" - -#endif // MERKLE_TREE_CHECK_UPDATE_GADGET_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_update_gadget.tcc b/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_update_gadget.tcc deleted file mode 100644 index 507c7526d..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_update_gadget.tcc +++ /dev/null @@ -1,265 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for the Merkle tree check update gadget. - - See merkle_tree_check_update_gadget.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef MERKLE_TREE_CHECK_UPDATE_GADGET_TCC_ -#define MERKLE_TREE_CHECK_UPDATE_GADGET_TCC_ - -namespace libsnark { - -template -merkle_tree_check_update_gadget::merkle_tree_check_update_gadget(protoboard &pb, - const size_t tree_depth, - const pb_variable_array &address_bits, - const digest_variable &prev_leaf_digest, - const digest_variable &prev_root_digest, - const merkle_authentication_path_variable &prev_path, - const digest_variable &next_leaf_digest, - const digest_variable &next_root_digest, - const merkle_authentication_path_variable &next_path, - const pb_linear_combination &update_successful, - const std::string &annotation_prefix) : - gadget(pb, annotation_prefix), - digest_size(HashT::get_digest_len()), - tree_depth(tree_depth), - address_bits(address_bits), - prev_leaf_digest(prev_leaf_digest), - prev_root_digest(prev_root_digest), - prev_path(prev_path), - next_leaf_digest(next_leaf_digest), - next_root_digest(next_root_digest), - next_path(next_path), - update_successful(update_successful) -{ - assert(tree_depth > 0); - assert(tree_depth == address_bits.size()); - - for (size_t i = 0; i < tree_depth-1; ++i) - { - prev_internal_output.emplace_back(digest_variable(pb, digest_size, FMT(this->annotation_prefix, " prev_internal_output_%zu", i))); - next_internal_output.emplace_back(digest_variable(pb, digest_size, FMT(this->annotation_prefix, " next_internal_output_%zu", i))); - } - - computed_next_root.reset(new digest_variable(pb, digest_size, FMT(this->annotation_prefix, " computed_root"))); - - for (size_t i = 0; i < tree_depth; ++i) - { - block_variable prev_inp(pb, prev_path.left_digests[i], prev_path.right_digests[i], FMT(this->annotation_prefix, " prev_inp_%zu", i)); - prev_hasher_inputs.emplace_back(prev_inp); - prev_hashers.emplace_back(HashT(pb, 2*digest_size, prev_inp, (i == 0 ? prev_root_digest : prev_internal_output[i-1]), - FMT(this->annotation_prefix, " prev_hashers_%zu", i))); - - block_variable next_inp(pb, next_path.left_digests[i], next_path.right_digests[i], FMT(this->annotation_prefix, " next_inp_%zu", i)); - next_hasher_inputs.emplace_back(next_inp); - next_hashers.emplace_back(HashT(pb, 2*digest_size, next_inp, (i == 0 ? *computed_next_root : next_internal_output[i-1]), - FMT(this->annotation_prefix, " next_hashers_%zu", i))); - } - - for (size_t i = 0; i < tree_depth; ++i) - { - prev_propagators.emplace_back(digest_selector_gadget(pb, digest_size, i < tree_depth -1 ? prev_internal_output[i] : prev_leaf_digest, - address_bits[tree_depth-1-i], prev_path.left_digests[i], prev_path.right_digests[i], - FMT(this->annotation_prefix, " prev_propagators_%zu", i))); - next_propagators.emplace_back(digest_selector_gadget(pb, digest_size, i < tree_depth -1 ? next_internal_output[i] : next_leaf_digest, - address_bits[tree_depth-1-i], next_path.left_digests[i], next_path.right_digests[i], - FMT(this->annotation_prefix, " next_propagators_%zu", i))); - } - - check_next_root.reset(new bit_vector_copy_gadget(pb, computed_next_root->bits, next_root_digest.bits, update_successful, FieldT::capacity(), FMT(annotation_prefix, " check_next_root"))); -} - -template -void merkle_tree_check_update_gadget::generate_r1cs_constraints() -{ - /* ensure correct hash computations */ - for (size_t i = 0; i < tree_depth; ++i) - { - prev_hashers[i].generate_r1cs_constraints(false); // we check root outside and prev_left/prev_right above - next_hashers[i].generate_r1cs_constraints(true); // however we must check right side hashes - } - - /* ensure consistency of internal_left/internal_right with internal_output */ - for (size_t i = 0; i < tree_depth; ++i) - { - prev_propagators[i].generate_r1cs_constraints(); - next_propagators[i].generate_r1cs_constraints(); - } - - /* ensure that prev auxiliary input and next auxiliary input match */ - for (size_t i = 0; i < tree_depth; ++i) - { - for (size_t j = 0; j < digest_size; ++j) - { - /* - addr * (prev_left - next_left) + (1 - addr) * (prev_right - next_right) = 0 - addr * (prev_left - next_left - prev_right + next_right) = next_right - prev_right - */ - this->pb.add_r1cs_constraint(r1cs_constraint(address_bits[tree_depth-1-i], - prev_path.left_digests[i].bits[j] - next_path.left_digests[i].bits[j] - prev_path.right_digests[i].bits[j] + next_path.right_digests[i].bits[j], - next_path.right_digests[i].bits[j] - prev_path.right_digests[i].bits[j]), - FMT(this->annotation_prefix, " aux_check_%zu_%zu", i, j)); - } - } - - /* Note that while it is necessary to generate R1CS constraints - for prev_path, it is not necessary to do so for next_path. - - This holds, because { next_path.left_inputs[i], - next_path.right_inputs[i] } is a pair { hash_output, - auxiliary_input }. The bitness for hash_output is enforced - above by next_hashers[i].generate_r1cs_constraints. - - Because auxiliary input is the same for prev_path and next_path - (enforced above), we have that auxiliary_input part is also - constrained to be boolean, because prev_path is *all* - constrained to be all boolean. */ - - check_next_root->generate_r1cs_constraints(false, false); -} - -template -void merkle_tree_check_update_gadget::generate_r1cs_witness() -{ - /* do the hash computations bottom-up */ - for (int i = tree_depth-1; i >= 0; --i) - { - /* ensure consistency of prev_path and next_path */ - if (this->pb.val(address_bits[tree_depth-1-i]) == FieldT::one()) - { - next_path.left_digests[i].generate_r1cs_witness(prev_path.left_digests[i].get_digest()); - } - else - { - next_path.right_digests[i].generate_r1cs_witness(prev_path.right_digests[i].get_digest()); - } - - /* propagate previous input */ - prev_propagators[i].generate_r1cs_witness(); - next_propagators[i].generate_r1cs_witness(); - - /* compute hash */ - prev_hashers[i].generate_r1cs_witness(); - next_hashers[i].generate_r1cs_witness(); - } - - check_next_root->generate_r1cs_witness(); -} - -template -size_t merkle_tree_check_update_gadget::root_size_in_bits() -{ - return HashT::get_digest_len(); -} - -template -size_t merkle_tree_check_update_gadget::expected_constraints(const size_t tree_depth) -{ - /* NB: this includes path constraints */ - const size_t prev_hasher_constraints = tree_depth * HashT::expected_constraints(false); - const size_t next_hasher_constraints = tree_depth * HashT::expected_constraints(true); - const size_t prev_authentication_path_constraints = 2 * tree_depth * HashT::get_digest_len(); - const size_t prev_propagator_constraints = tree_depth * HashT::get_digest_len(); - const size_t next_propagator_constraints = tree_depth * HashT::get_digest_len(); - const size_t check_next_root_constraints = 3 * div_ceil(HashT::get_digest_len(), FieldT::capacity()); - const size_t aux_equality_constraints = tree_depth * HashT::get_digest_len(); - - return (prev_hasher_constraints + next_hasher_constraints + prev_authentication_path_constraints + - prev_propagator_constraints + next_propagator_constraints + check_next_root_constraints + - aux_equality_constraints); -} - -template -void test_merkle_tree_check_update_gadget() -{ - /* prepare test */ - const size_t digest_len = HashT::get_digest_len(); - - const size_t tree_depth = 16; - std::vector prev_path(tree_depth); - - bit_vector prev_load_hash(digest_len); - std::generate(prev_load_hash.begin(), prev_load_hash.end(), [&]() { return std::rand() % 2; }); - bit_vector prev_store_hash(digest_len); - std::generate(prev_store_hash.begin(), prev_store_hash.end(), [&]() { return std::rand() % 2; }); - - bit_vector loaded_leaf = prev_load_hash; - bit_vector stored_leaf = prev_store_hash; - - bit_vector address_bits; - - size_t address = 0; - for (int64_t level = tree_depth-1; level >= 0; --level) - { - const bool computed_is_right = (std::rand() % 2); - address |= (computed_is_right ? UINT64_C(1) << (tree_depth-1-level) : 0); - address_bits.push_back(computed_is_right); - bit_vector other(digest_len); - std::generate(other.begin(), other.end(), [&]() { return std::rand() % 2; }); - - bit_vector load_block = prev_load_hash; - load_block.insert(computed_is_right ? load_block.begin() : load_block.end(), other.begin(), other.end()); - bit_vector store_block = prev_store_hash; - store_block.insert(computed_is_right ? store_block.begin() : store_block.end(), other.begin(), other.end()); - - bit_vector load_h = HashT::get_hash(load_block); - bit_vector store_h = HashT::get_hash(store_block); - - prev_path[level] = other; - - prev_load_hash = load_h; - prev_store_hash = store_h; - } - - bit_vector load_root = prev_load_hash; - bit_vector store_root = prev_store_hash; - - /* execute the test */ - protoboard pb; - pb_variable_array address_bits_va; - address_bits_va.allocate(pb, tree_depth, "address_bits"); - digest_variable prev_leaf_digest(pb, digest_len, "prev_leaf_digest"); - digest_variable prev_root_digest(pb, digest_len, "prev_root_digest"); - merkle_authentication_path_variable prev_path_var(pb, tree_depth, "prev_path_var"); - digest_variable next_leaf_digest(pb, digest_len, "next_leaf_digest"); - digest_variable next_root_digest(pb, digest_len, "next_root_digest"); - merkle_authentication_path_variable next_path_var(pb, tree_depth, "next_path_var"); - merkle_tree_check_update_gadget mls(pb, tree_depth, address_bits_va, - prev_leaf_digest, prev_root_digest, prev_path_var, - next_leaf_digest, next_root_digest, next_path_var, ONE, "mls"); - - prev_path_var.generate_r1cs_constraints(); - mls.generate_r1cs_constraints(); - - address_bits_va.fill_with_bits(pb, address_bits); - assert(address_bits_va.get_field_element_from_bits(pb).as_uint64() == address); - prev_leaf_digest.generate_r1cs_witness(loaded_leaf); - prev_path_var.generate_r1cs_witness(address, prev_path); - next_leaf_digest.generate_r1cs_witness(stored_leaf); - address_bits_va.fill_with_bits(pb, address_bits); - mls.generate_r1cs_witness(); - - /* make sure that update check will check for the right things */ - prev_leaf_digest.generate_r1cs_witness(loaded_leaf); - next_leaf_digest.generate_r1cs_witness(stored_leaf); - prev_root_digest.generate_r1cs_witness(load_root); - next_root_digest.generate_r1cs_witness(store_root); - address_bits_va.fill_with_bits(pb, address_bits); - assert(pb.is_satisfied()); - - const size_t num_constraints = pb.num_constraints(); - const size_t expected_constraints = merkle_tree_check_update_gadget::expected_constraints(tree_depth); - assert(num_constraints == expected_constraints); -} - -} // libsnark - -#endif // MERKLE_TREE_CHECK_UPDATE_GADGET_TCC_ diff --git a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/tests/test_merkle_tree_gadgets.cpp b/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/tests/test_merkle_tree_gadgets.cpp deleted file mode 100644 index 27b52f9ec..000000000 --- a/src/snark/libsnark/gadgetlib1/gadgets/merkle_tree/tests/test_merkle_tree_gadgets.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#include "algebra/curves/alt_bn128/alt_bn128_pp.hpp" -#ifdef CURVE_BN128 -#include "algebra/curves/bn128/bn128_pp.hpp" -#endif -#include "gadgetlib1/gadgets/merkle_tree/merkle_tree_check_read_gadget.hpp" -#include "gadgetlib1/gadgets/merkle_tree/merkle_tree_check_update_gadget.hpp" -#include "gadgetlib1/gadgets/hashes/sha256/sha256_gadget.hpp" - -#include - -using namespace libsnark; - -template -void test_all_merkle_tree_gadgets() -{ - typedef Fr FieldT; - test_merkle_tree_check_read_gadget >(); - - test_merkle_tree_check_update_gadget >(); -} - -TEST(gadgetlib1, merkle_tree) -{ - start_profiling(); - - alt_bn128_pp::init_public_params(); - test_all_merkle_tree_gadgets(); - -#ifdef CURVE_BN128 // BN128 has fancy dependencies so it may be disabled - bn128_pp::init_public_params(); - test_all_merkle_tree_gadgets(); -#endif -} diff --git a/src/snark/libsnark/gadgetlib1/pb_variable.hpp b/src/snark/libsnark/gadgetlib1/pb_variable.hpp deleted file mode 100644 index caa44cec1..000000000 --- a/src/snark/libsnark/gadgetlib1/pb_variable.hpp +++ /dev/null @@ -1,144 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef PB_VARIABLE_HPP_ -#define PB_VARIABLE_HPP_ - -#include -#include -#include -#include "common/utils.hpp" -#include "relations/variable.hpp" - -namespace libsnark { - -typedef size_t lc_index_t; - -template -class protoboard; - -template -class pb_variable : public variable { -public: - pb_variable(const var_index_t index = 0) : variable(index) {}; - - void allocate(protoboard &pb, const std::string &annotation=""); -}; - -template -class pb_variable_array : private std::vector > -{ - typedef std::vector > contents; -public: - using typename contents::iterator; - using typename contents::const_iterator; - using typename contents::reverse_iterator; - using typename contents::const_reverse_iterator; - - using contents::begin; - using contents::end; - using contents::rbegin; - using contents::rend; - using contents::emplace_back; - using contents::insert; - using contents::reserve; - using contents::size; - using contents::empty; - using contents::operator[]; - using contents::resize; - - pb_variable_array() : contents() {}; - pb_variable_array(size_t count, const pb_variable &value) : contents(count, value) {}; - pb_variable_array(typename contents::const_iterator first, typename contents::const_iterator last) : contents(first, last) {}; - pb_variable_array(typename contents::const_reverse_iterator first, typename contents::const_reverse_iterator last) : contents(first, last) {}; - void allocate(protoboard &pb, const size_t n, const std::string &annotation_prefix=""); - - void fill_with_field_elements(protoboard &pb, const std::vector& vals) const; - void fill_with_bits(protoboard &pb, const bit_vector& bits) const; - void fill_with_bits_of_uint64(protoboard &pb, const uint64_t i) const; - void fill_with_bits_of_field_element(protoboard &pb, const FieldT &r) const; - - std::vector get_vals(const protoboard &pb) const; - bit_vector get_bits(const protoboard &pb) const; - - FieldT get_field_element_from_bits(const protoboard &pb) const; -}; - -/* index 0 corresponds to the constant term (used in legacy code) */ -#define ONE pb_variable(0) - -template -class pb_linear_combination : public linear_combination { -public: - bool is_variable; - lc_index_t index; - - pb_linear_combination(); - pb_linear_combination(const pb_variable &var); - - void assign(protoboard &pb, const linear_combination &lc); - void evaluate(protoboard &pb) const; - - bool is_constant() const; - FieldT constant_term() const; -}; - -template -class pb_linear_combination_array : private std::vector > -{ - typedef std::vector > contents; -public: - using typename contents::iterator; - using typename contents::const_iterator; - using typename contents::reverse_iterator; - using typename contents::const_reverse_iterator; - - using contents::begin; - using contents::end; - using contents::rbegin; - using contents::rend; - using contents::emplace_back; - using contents::insert; - using contents::reserve; - using contents::size; - using contents::empty; - using contents::operator[]; - using contents::resize; - - pb_linear_combination_array() : contents() {}; - pb_linear_combination_array(const pb_variable_array &arr) { for (auto &v : arr) this->emplace_back(pb_linear_combination(v)); }; - pb_linear_combination_array(size_t count) : contents(count) {}; - pb_linear_combination_array(size_t count, const pb_linear_combination &value) : contents(count, value) {}; - pb_linear_combination_array(typename contents::const_iterator first, typename contents::const_iterator last) : contents(first, last) {}; - pb_linear_combination_array(typename contents::const_reverse_iterator first, typename contents::const_reverse_iterator last) : contents(first, last) {}; - - void evaluate(protoboard &pb) const; - - void fill_with_field_elements(protoboard &pb, const std::vector& vals) const; - void fill_with_bits(protoboard &pb, const bit_vector& bits) const; - void fill_with_bits_of_uint64(protoboard &pb, const uint64_t i) const; - void fill_with_bits_of_field_element(protoboard &pb, const FieldT &r) const; - - std::vector get_vals(const protoboard &pb) const; - bit_vector get_bits(const protoboard &pb) const; - - FieldT get_field_element_from_bits(const protoboard &pb) const; -}; - -template -linear_combination pb_sum(const pb_linear_combination_array &v); - -template -linear_combination pb_packing_sum(const pb_linear_combination_array &v); - -template -linear_combination pb_coeff_sum(const pb_linear_combination_array &v, const std::vector &coeffs); - -} // libsnark -#include "gadgetlib1/pb_variable.tcc" - -#endif // PB_VARIABLE_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/pb_variable.tcc b/src/snark/libsnark/gadgetlib1/pb_variable.tcc deleted file mode 100644 index b4c6ad4f9..000000000 --- a/src/snark/libsnark/gadgetlib1/pb_variable.tcc +++ /dev/null @@ -1,330 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef PB_VARIABLE_TCC_ -#define PB_VARIABLE_TCC_ -#include -#include "gadgetlib1/protoboard.hpp" -#include "common/utils.hpp" - -namespace libsnark { - -template -void pb_variable::allocate(protoboard &pb, const std::string &annotation) -{ - this->index = pb.allocate_var_index(annotation); -} - -/* allocates pb_variable array in MSB->LSB order */ -template -void pb_variable_array::allocate(protoboard &pb, const size_t n, const std::string &annotation_prefix) -{ -#ifdef DEBUG - assert(annotation_prefix != ""); -#endif - (*this).resize(n); - - for (size_t i = 0; i < n; ++i) - { - (*this)[i].allocate(pb, FMT(annotation_prefix, "_%zu", i)); - } -} - -template -void pb_variable_array::fill_with_field_elements(protoboard &pb, const std::vector& vals) const -{ - assert(this->size() == vals.size()); - for (size_t i = 0; i < vals.size(); ++i) - { - pb.val((*this)[i]) = vals[i]; - } -} - -template -void pb_variable_array::fill_with_bits(protoboard &pb, const bit_vector& bits) const -{ - assert(this->size() == bits.size()); - for (size_t i = 0; i < bits.size(); ++i) - { - pb.val((*this)[i]) = (bits[i] ? FieldT::one() : FieldT::zero()); - } -} - -template -void pb_variable_array::fill_with_bits_of_field_element(protoboard &pb, const FieldT &r) const -{ - const bigint rint = r.as_bigint(); - for (size_t i = 0; i < this->size(); ++i) - { - pb.val((*this)[i]) = rint.test_bit(i) ? FieldT::one() : FieldT::zero(); - } -} - -template -void pb_variable_array::fill_with_bits_of_uint64(protoboard &pb, const uint64_t i) const -{ - this->fill_with_bits_of_field_element(pb, FieldT(i, true)); -} - -template -std::vector pb_variable_array::get_vals(const protoboard &pb) const -{ - std::vector result(this->size()); - for (size_t i = 0; i < this->size(); ++i) - { - result[i] = pb.val((*this)[i]); - } - return result; -} - -template -bit_vector pb_variable_array::get_bits(const protoboard &pb) const -{ - bit_vector result; - for (size_t i = 0; i < this->size(); ++i) - { - const FieldT v = pb.val((*this)[i]); - assert(v == FieldT::zero() || v == FieldT::one()); - result.push_back(v == FieldT::one()); - } - return result; -} - -template -FieldT pb_variable_array::get_field_element_from_bits(const protoboard &pb) const -{ - FieldT result = FieldT::zero(); - - for (size_t i = 0; i < this->size(); ++i) - { - /* push in the new bit */ - const FieldT v = pb.val((*this)[this->size()-1-i]); - assert(v == FieldT::zero() || v == FieldT::one()); - result += result + v; - } - - return result; -} - -template -pb_linear_combination::pb_linear_combination() -{ - this->is_variable = false; - this->index = 0; -} - -template -pb_linear_combination::pb_linear_combination(const pb_variable &var) -{ - this->is_variable = true; - this->index = var.index; - this->terms.emplace_back(linear_term(var)); -} - -template -void pb_linear_combination::assign(protoboard &pb, const linear_combination &lc) -{ - assert(this->is_variable == false); - this->index = pb.allocate_lc_index(); - this->terms = lc.terms; -} - -template -void pb_linear_combination::evaluate(protoboard &pb) const -{ - if (this->is_variable) - { - return; // do nothing - } - - FieldT sum = 0; - for (auto term : this->terms) - { - sum += term.coeff * pb.val(pb_variable(term.index)); - } - - pb.lc_val(*this) = sum; -} - -template -bool pb_linear_combination::is_constant() const -{ - if (is_variable) - { - return (index == 0); - } - else - { - for (auto term : this->terms) - { - if (term.index != 0) - { - return false; - } - } - - return true; - } -} - -template -FieldT pb_linear_combination::constant_term() const -{ - if (is_variable) - { - return (index == 0 ? FieldT::one() : FieldT::zero()); - } - else - { - FieldT result = FieldT::zero(); - for (auto term : this->terms) - { - if (term.index == 0) - { - result += term.coeff; - } - } - return result; - } -} - -template -void pb_linear_combination_array::evaluate(protoboard &pb) const -{ - for (size_t i = 0; i < this->size(); ++i) - { - (*this)[i].evaluate(pb); - } -} - -template -void pb_linear_combination_array::fill_with_field_elements(protoboard &pb, const std::vector& vals) const -{ - assert(this->size() == vals.size()); - for (size_t i = 0; i < vals.size(); ++i) - { - pb.lc_val((*this)[i]) = vals[i]; - } -} - -template -void pb_linear_combination_array::fill_with_bits(protoboard &pb, const bit_vector& bits) const -{ - assert(this->size() == bits.size()); - for (size_t i = 0; i < bits.size(); ++i) - { - pb.lc_val((*this)[i]) = (bits[i] ? FieldT::one() : FieldT::zero()); - } -} - -template -void pb_linear_combination_array::fill_with_bits_of_field_element(protoboard &pb, const FieldT &r) const -{ - const bigint rint = r.as_bigint(); - for (size_t i = 0; i < this->size(); ++i) - { - pb.lc_val((*this)[i]) = rint.test_bit(i) ? FieldT::one() : FieldT::zero(); - } -} - -template -void pb_linear_combination_array::fill_with_bits_of_uint64(protoboard &pb, const uint64_t i) const -{ - this->fill_with_bits_of_field_element(pb, FieldT(i)); -} - -template -std::vector pb_linear_combination_array::get_vals(const protoboard &pb) const -{ - std::vector result(this->size()); - for (size_t i = 0; i < this->size(); ++i) - { - result[i] = pb.lc_val((*this)[i]); - } - return result; -} - -template -bit_vector pb_linear_combination_array::get_bits(const protoboard &pb) const -{ - bit_vector result; - for (size_t i = 0; i < this->size(); ++i) - { - const FieldT v = pb.lc_val((*this)[i]); - assert(v == FieldT::zero() || v == FieldT::one()); - result.push_back(v == FieldT::one()); - } - return result; -} - -template -FieldT pb_linear_combination_array::get_field_element_from_bits(const protoboard &pb) const -{ - FieldT result = FieldT::zero(); - - for (size_t i = 0; i < this->size(); ++i) - { - /* push in the new bit */ - const FieldT v = pb.lc_val((*this)[this->size()-1-i]); - assert(v == FieldT::zero() || v == FieldT::one()); - result += result + v; - } - - return result; -} - -template -linear_combination pb_sum(const pb_linear_combination_array &v) -{ - linear_combination result; - for (auto &term : v) - { - result = result + term; - } - - return result; -} - -template -linear_combination pb_packing_sum(const pb_linear_combination_array &v) -{ - FieldT twoi = FieldT::one(); // will hold 2^i entering each iteration - std::vector > all_terms; - for (auto &lc : v) - { - for (auto &term : lc.terms) - { - all_terms.emplace_back(twoi * term); - } - twoi += twoi; - } - - return linear_combination(all_terms); -} - -template -linear_combination pb_coeff_sum(const pb_linear_combination_array &v, const std::vector &coeffs) -{ - assert(v.size() == coeffs.size()); - std::vector > all_terms; - - auto coeff_it = coeffs.begin(); - for (auto &lc : v) - { - for (auto &term : lc.terms) - { - all_terms.emplace_back((*coeff_it) * term); - } - ++coeff_it; - } - - return linear_combination(all_terms); -} - - -} // libsnark -#endif // PB_VARIABLE_TCC diff --git a/src/snark/libsnark/gadgetlib1/protoboard.hpp b/src/snark/libsnark/gadgetlib1/protoboard.hpp deleted file mode 100644 index a910a6df9..000000000 --- a/src/snark/libsnark/gadgetlib1/protoboard.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef PROTOBOARD_HPP_ -#define PROTOBOARD_HPP_ - -#include -#include -#include -#include -#include -#include "gadgetlib1/pb_variable.hpp" -#include "relations/constraint_satisfaction_problems/r1cs/r1cs.hpp" -#include "common/utils.hpp" - -namespace libsnark { - -template -class r1cs_constraint; - -template -class r1cs_constraint_system; - -template -class protoboard { -private: - FieldT constant_term; /* only here, because pb.val() needs to be able to return reference to the constant 1 term */ - r1cs_variable_assignment values; /* values[0] will hold the value of the first allocated variable of the protoboard, *NOT* constant 1 */ - var_index_t next_free_var; - lc_index_t next_free_lc; - std::vector lc_values; -public: - r1cs_constraint_system constraint_system; - - protoboard(); - - void clear_values(); - - FieldT& val(const pb_variable &var); - FieldT val(const pb_variable &var) const; - - FieldT& lc_val(const pb_linear_combination &lc); - FieldT lc_val(const pb_linear_combination &lc) const; - - void add_r1cs_constraint(const r1cs_constraint &constr, const std::string &annotation=""); - void augment_variable_annotation(const pb_variable &v, const std::string &postfix); - bool is_satisfied() const; - void dump_variables() const; - - size_t num_constraints() const; - size_t num_inputs() const; - size_t num_variables() const; - - void set_input_sizes(const size_t primary_input_size); - - r1cs_variable_assignment full_variable_assignment() const; - r1cs_primary_input primary_input() const; - r1cs_auxiliary_input auxiliary_input() const; - r1cs_constraint_system get_constraint_system() const; - - friend class pb_variable; - friend class pb_linear_combination; - -private: - var_index_t allocate_var_index(const std::string &annotation=""); - lc_index_t allocate_lc_index(); -}; - -} // libsnark -#include "gadgetlib1/protoboard.tcc" -#endif // PROTOBOARD_HPP_ diff --git a/src/snark/libsnark/gadgetlib1/protoboard.tcc b/src/snark/libsnark/gadgetlib1/protoboard.tcc deleted file mode 100644 index 882af28e6..000000000 --- a/src/snark/libsnark/gadgetlib1/protoboard.tcc +++ /dev/null @@ -1,189 +0,0 @@ -/** @file - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef PROTOBOARD_TCC_ -#define PROTOBOARD_TCC_ - -#include -#include -#include "common/profiling.hpp" - -namespace libsnark { - -template -protoboard::protoboard() -{ - constant_term = FieldT::one(); - -#ifdef DEBUG - constraint_system.variable_annotations[0] = "ONE"; -#endif - - next_free_var = 1; /* to account for constant 1 term */ - next_free_lc = 0; -} - -template -void protoboard::clear_values() -{ - std::fill(values.begin(), values.end(), FieldT::zero()); -} - -template -var_index_t protoboard::allocate_var_index(const std::string &annotation) -{ -#ifdef DEBUG - assert(annotation != ""); - constraint_system.variable_annotations[next_free_var] = annotation; -#else - UNUSED(annotation); -#endif - ++constraint_system.auxiliary_input_size; - values.emplace_back(FieldT::zero()); - return next_free_var++; -} - -template -lc_index_t protoboard::allocate_lc_index() -{ - lc_values.emplace_back(FieldT::zero()); - return next_free_lc++; -} - -template -FieldT& protoboard::val(const pb_variable &var) -{ - assert(var.index <= values.size()); - return (var.index == 0 ? constant_term : values[var.index-1]); -} - -template -FieldT protoboard::val(const pb_variable &var) const -{ - assert(var.index <= values.size()); - return (var.index == 0 ? constant_term : values[var.index-1]); -} - -template -FieldT& protoboard::lc_val(const pb_linear_combination &lc) -{ - if (lc.is_variable) - { - return this->val(pb_variable(lc.index)); - } - else - { - assert(lc.index < lc_values.size()); - return lc_values[lc.index]; - } -} - -template -FieldT protoboard::lc_val(const pb_linear_combination &lc) const -{ - if (lc.is_variable) - { - return this->val(pb_variable(lc.index)); - } - else - { - assert(lc.index < lc_values.size()); - return lc_values[lc.index]; - } -} - -template -void protoboard::add_r1cs_constraint(const r1cs_constraint &constr, const std::string &annotation) -{ -#ifdef DEBUG - assert(annotation != ""); - constraint_system.constraint_annotations[constraint_system.constraints.size()] = annotation; -#else - UNUSED(annotation); -#endif - constraint_system.constraints.emplace_back(constr); -} - -template -void protoboard::augment_variable_annotation(const pb_variable &v, const std::string &postfix) -{ -#ifdef DEBUG - auto it = constraint_system.variable_annotations.find(v.index); - constraint_system.variable_annotations[v.index] = (it == constraint_system.variable_annotations.end() ? "" : it->second + " ") + postfix; -#endif -} - -template -bool protoboard::is_satisfied() const -{ - return constraint_system.is_satisfied(primary_input(), auxiliary_input()); -} - -template -void protoboard::dump_variables() const -{ -#ifdef DEBUG - for (size_t i = 0; i < constraint_system.num_variables; ++i) - { - printf("%-40s --> ", constraint_system.variable_annotations[i].c_str()); - values[i].as_bigint().print_hex(); - } -#endif -} - -template -size_t protoboard::num_constraints() const -{ - return constraint_system.num_constraints(); -} - -template -size_t protoboard::num_inputs() const -{ - return constraint_system.num_inputs(); -} - -template -size_t protoboard::num_variables() const -{ - return next_free_var - 1; -} - -template -void protoboard::set_input_sizes(const size_t primary_input_size) -{ - assert(primary_input_size <= num_variables()); - constraint_system.primary_input_size = primary_input_size; - constraint_system.auxiliary_input_size = num_variables() - primary_input_size; -} - -template -r1cs_variable_assignment protoboard::full_variable_assignment() const -{ - return values; -} - -template -r1cs_primary_input protoboard::primary_input() const -{ - return r1cs_primary_input(values.begin(), values.begin() + num_inputs()); -} - -template -r1cs_auxiliary_input protoboard::auxiliary_input() const -{ - return r1cs_primary_input(values.begin() + num_inputs(), values.end()); -} - -template -r1cs_constraint_system protoboard::get_constraint_system() const -{ - return constraint_system; -} - -} // libsnark -#endif // PROTOBOARD_TCC_ diff --git a/src/snark/libsnark/gtests.cpp b/src/snark/libsnark/gtests.cpp deleted file mode 100644 index 74c66bdad..000000000 --- a/src/snark/libsnark/gtests.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include - -#include "common/profiling.hpp" - -int main(int argc, char **argv) { - libsnark::inhibit_profiling_info = true; - libsnark::inhibit_profiling_counters = true; - - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - diff --git a/src/snark/libsnark/reductions/r1cs_to_qap/r1cs_to_qap.hpp b/src/snark/libsnark/reductions/r1cs_to_qap/r1cs_to_qap.hpp deleted file mode 100644 index 86831cb1d..000000000 --- a/src/snark/libsnark/reductions/r1cs_to_qap/r1cs_to_qap.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for a R1CS-to-QAP reduction, that is, constructing - a QAP ("Quadratic Arithmetic Program") from a R1CS ("Rank-1 Constraint System"). - - QAPs are defined in \[GGPR13], and constructed for R1CS also in \[GGPR13]. - - The implementation of the reduction follows, extends, and optimizes - the efficient approach described in Appendix E of \[BCGTV13]. - - References: - - \[BCGTV13] - "SNARKs for C: Verifying Program Executions Succinctly and in Zero Knowledge", - Eli Ben-Sasson, Alessandro Chiesa, Daniel Genkin, Eran Tromer, Madars Virza, - CRYPTO 2013, - - - \[GGPR13]: - "Quadratic span programs and succinct NIZKs without PCPs", - Rosario Gennaro, Craig Gentry, Bryan Parno, Mariana Raykova, - EUROCRYPT 2013, - - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef R1CS_TO_QAP_HPP_ -#define R1CS_TO_QAP_HPP_ - -#include "relations/arithmetic_programs/qap/qap.hpp" -#include "relations/constraint_satisfaction_problems/r1cs/r1cs.hpp" - -namespace libsnark { - -/** - * Instance map for the R1CS-to-QAP reduction. - */ -template -qap_instance r1cs_to_qap_instance_map(const r1cs_constraint_system &cs); - -/** - * Instance map for the R1CS-to-QAP reduction followed by evaluation of the resulting QAP instance. - */ -template -qap_instance_evaluation r1cs_to_qap_instance_map_with_evaluation(const r1cs_constraint_system &cs, - const FieldT &t); - -/** - * Witness map for the R1CS-to-QAP reduction. - * - * The witness map takes zero knowledge into account when d1,d2,d3 are random. - */ -template -qap_witness r1cs_to_qap_witness_map(const r1cs_constraint_system &cs, - const r1cs_primary_input &primary_input, - const r1cs_auxiliary_input &auxiliary_input, - const FieldT &d1, - const FieldT &d2, - const FieldT &d3); - -} // libsnark - -#include "reductions/r1cs_to_qap/r1cs_to_qap.tcc" - -#endif // R1CS_TO_QAP_HPP_ diff --git a/src/snark/libsnark/reductions/r1cs_to_qap/r1cs_to_qap.tcc b/src/snark/libsnark/reductions/r1cs_to_qap/r1cs_to_qap.tcc deleted file mode 100644 index 3d0bee273..000000000 --- a/src/snark/libsnark/reductions/r1cs_to_qap/r1cs_to_qap.tcc +++ /dev/null @@ -1,338 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for a R1CS-to-QAP reduction. - - See r1cs_to_qap.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef R1CS_TO_QAP_TCC_ -#define R1CS_TO_QAP_TCC_ - -#include "common/profiling.hpp" -#include "common/utils.hpp" -#include "algebra/evaluation_domain/evaluation_domain.hpp" - -namespace libsnark { - -/** - * Instance map for the R1CS-to-QAP reduction. - * - * Namely, given a R1CS constraint system cs, construct a QAP instance for which: - * A := (A_0(z),A_1(z),...,A_m(z)) - * B := (B_0(z),B_1(z),...,B_m(z)) - * C := (C_0(z),C_1(z),...,C_m(z)) - * where - * m = number of variables of the QAP - * and - * each A_i,B_i,C_i is expressed in the Lagrange basis. - */ -template -qap_instance r1cs_to_qap_instance_map(const r1cs_constraint_system &cs) -{ - enter_block("Call to r1cs_to_qap_instance_map"); - - const std::shared_ptr > domain = get_evaluation_domain(cs.num_constraints() + cs.num_inputs() + 1); - - std::vector > A_in_Lagrange_basis(cs.num_variables()+1); - std::vector > B_in_Lagrange_basis(cs.num_variables()+1); - std::vector > C_in_Lagrange_basis(cs.num_variables()+1); - - enter_block("Compute polynomials A, B, C in Lagrange basis"); - /** - * add and process the constraints - * input_i * 0 = 0 - * to ensure soundness of input consistency - */ - for (size_t i = 0; i <= cs.num_inputs(); ++i) - { - A_in_Lagrange_basis[i][cs.num_constraints() + i] = FieldT::one(); - } - /* process all other constraints */ - for (size_t i = 0; i < cs.num_constraints(); ++i) - { - for (size_t j = 0; j < cs.constraints[i].a.terms.size(); ++j) - { - A_in_Lagrange_basis[cs.constraints[i].a.terms[j].index][i] += - cs.constraints[i].a.terms[j].coeff; - } - - for (size_t j = 0; j < cs.constraints[i].b.terms.size(); ++j) - { - B_in_Lagrange_basis[cs.constraints[i].b.terms[j].index][i] += - cs.constraints[i].b.terms[j].coeff; - } - - for (size_t j = 0; j < cs.constraints[i].c.terms.size(); ++j) - { - C_in_Lagrange_basis[cs.constraints[i].c.terms[j].index][i] += - cs.constraints[i].c.terms[j].coeff; - } - } - leave_block("Compute polynomials A, B, C in Lagrange basis"); - - leave_block("Call to r1cs_to_qap_instance_map"); - - return qap_instance(domain, - cs.num_variables(), - domain->m, - cs.num_inputs(), - std::move(A_in_Lagrange_basis), - std::move(B_in_Lagrange_basis), - std::move(C_in_Lagrange_basis)); -} - -/** - * Instance map for the R1CS-to-QAP reduction followed by evaluation of the resulting QAP instance. - * - * Namely, given a R1CS constraint system cs and a field element t, construct - * a QAP instance (evaluated at t) for which: - * At := (A_0(t),A_1(t),...,A_m(t)) - * Bt := (B_0(t),B_1(t),...,B_m(t)) - * Ct := (C_0(t),C_1(t),...,C_m(t)) - * Ht := (1,t,t^2,...,t^n) - * Zt := Z(t) = "vanishing polynomial of a certain set S, evaluated at t" - * where - * m = number of variables of the QAP - * n = degree of the QAP - */ -template -qap_instance_evaluation r1cs_to_qap_instance_map_with_evaluation(const r1cs_constraint_system &cs, - const FieldT &t) -{ - enter_block("Call to r1cs_to_qap_instance_map_with_evaluation"); - - const std::shared_ptr > domain = get_evaluation_domain(cs.num_constraints() + cs.num_inputs() + 1); - - std::vector At, Bt, Ct, Ht; - - At.resize(cs.num_variables()+1, FieldT::zero()); - Bt.resize(cs.num_variables()+1, FieldT::zero()); - Ct.resize(cs.num_variables()+1, FieldT::zero()); - Ht.reserve(domain->m+1); - - const FieldT Zt = domain->compute_Z(t); - - enter_block("Compute evaluations of A, B, C, H at t"); - const std::vector u = domain->lagrange_coeffs(t); - /** - * add and process the constraints - * input_i * 0 = 0 - * to ensure soundness of input consistency - */ - for (size_t i = 0; i <= cs.num_inputs(); ++i) - { - At[i] = u[cs.num_constraints() + i]; - } - /* process all other constraints */ - for (size_t i = 0; i < cs.num_constraints(); ++i) - { - for (size_t j = 0; j < cs.constraints[i].a.terms.size(); ++j) - { - At[cs.constraints[i].a.terms[j].index] += - u[i]*cs.constraints[i].a.terms[j].coeff; - } - - for (size_t j = 0; j < cs.constraints[i].b.terms.size(); ++j) - { - Bt[cs.constraints[i].b.terms[j].index] += - u[i]*cs.constraints[i].b.terms[j].coeff; - } - - for (size_t j = 0; j < cs.constraints[i].c.terms.size(); ++j) - { - Ct[cs.constraints[i].c.terms[j].index] += - u[i]*cs.constraints[i].c.terms[j].coeff; - } - } - - FieldT ti = FieldT::one(); - for (size_t i = 0; i < domain->m+1; ++i) - { - Ht.emplace_back(ti); - ti *= t; - } - leave_block("Compute evaluations of A, B, C, H at t"); - - leave_block("Call to r1cs_to_qap_instance_map_with_evaluation"); - - return qap_instance_evaluation(domain, - cs.num_variables(), - domain->m, - cs.num_inputs(), - t, - std::move(At), - std::move(Bt), - std::move(Ct), - std::move(Ht), - Zt); -} - -/** - * Witness map for the R1CS-to-QAP reduction. - * - * The witness map takes zero knowledge into account when d1,d2,d3 are random. - * - * More precisely, compute the coefficients - * h_0,h_1,...,h_n - * of the polynomial - * H(z) := (A(z)*B(z)-C(z))/Z(z) - * where - * A(z) := A_0(z) + \sum_{k=1}^{m} w_k A_k(z) + d1 * Z(z) - * B(z) := B_0(z) + \sum_{k=1}^{m} w_k B_k(z) + d2 * Z(z) - * C(z) := C_0(z) + \sum_{k=1}^{m} w_k C_k(z) + d3 * Z(z) - * Z(z) := "vanishing polynomial of set S" - * and - * m = number of variables of the QAP - * n = degree of the QAP - * - * This is done as follows: - * (1) compute evaluations of A,B,C on S = {sigma_1,...,sigma_n} - * (2) compute coefficients of A,B,C - * (3) compute evaluations of A,B,C on T = "coset of S" - * (4) compute evaluation of H on T - * (5) compute coefficients of H - * (6) patch H to account for d1,d2,d3 (i.e., add coefficients of the polynomial (A d2 + B d1 - d3) + d1*d2*Z ) - * - * The code below is not as simple as the above high-level description due to - * some reshuffling to save space. - */ -template -qap_witness r1cs_to_qap_witness_map(const r1cs_constraint_system &cs, - const r1cs_primary_input &primary_input, - const r1cs_auxiliary_input &auxiliary_input, - const FieldT &d1, - const FieldT &d2, - const FieldT &d3) -{ - enter_block("Call to r1cs_to_qap_witness_map"); - - /* sanity check */ - assert(cs.is_satisfied(primary_input, auxiliary_input)); - - const std::shared_ptr > domain = get_evaluation_domain(cs.num_constraints() + cs.num_inputs() + 1); - - r1cs_variable_assignment full_variable_assignment = primary_input; - full_variable_assignment.insert(full_variable_assignment.end(), auxiliary_input.begin(), auxiliary_input.end()); - - enter_block("Compute evaluation of polynomials A, B on set S"); - std::vector aA(domain->m, FieldT::zero()), aB(domain->m, FieldT::zero()); - - /* account for the additional constraints input_i * 0 = 0 */ - for (size_t i = 0; i <= cs.num_inputs(); ++i) - { - aA[i+cs.num_constraints()] = (i > 0 ? full_variable_assignment[i-1] : FieldT::one()); - } - /* account for all other constraints */ - for (size_t i = 0; i < cs.num_constraints(); ++i) - { - aA[i] += cs.constraints[i].a.evaluate(full_variable_assignment); - aB[i] += cs.constraints[i].b.evaluate(full_variable_assignment); - } - leave_block("Compute evaluation of polynomials A, B on set S"); - - enter_block("Compute coefficients of polynomial A"); - domain->iFFT(aA); - leave_block("Compute coefficients of polynomial A"); - - enter_block("Compute coefficients of polynomial B"); - domain->iFFT(aB); - leave_block("Compute coefficients of polynomial B"); - - enter_block("Compute ZK-patch"); - std::vector coefficients_for_H(domain->m+1, FieldT::zero()); -#ifdef MULTICORE -#pragma omp parallel for -#endif - /* add coefficients of the polynomial (d2*A + d1*B - d3) + d1*d2*Z */ - for (size_t i = 0; i < domain->m; ++i) - { - coefficients_for_H[i] = d2*aA[i] + d1*aB[i]; - } - coefficients_for_H[0] -= d3; - domain->add_poly_Z(d1*d2, coefficients_for_H); - leave_block("Compute ZK-patch"); - - enter_block("Compute evaluation of polynomial A on set T"); - domain->cosetFFT(aA, FieldT::multiplicative_generator); - leave_block("Compute evaluation of polynomial A on set T"); - - enter_block("Compute evaluation of polynomial B on set T"); - domain->cosetFFT(aB, FieldT::multiplicative_generator); - leave_block("Compute evaluation of polynomial B on set T"); - - enter_block("Compute evaluation of polynomial H on set T"); - std::vector &H_tmp = aA; // can overwrite aA because it is not used later -#ifdef MULTICORE -#pragma omp parallel for -#endif - for (size_t i = 0; i < domain->m; ++i) - { - H_tmp[i] = aA[i]*aB[i]; - } - std::vector().swap(aB); // destroy aB - - enter_block("Compute evaluation of polynomial C on set S"); - std::vector aC(domain->m, FieldT::zero()); - for (size_t i = 0; i < cs.num_constraints(); ++i) - { - aC[i] += cs.constraints[i].c.evaluate(full_variable_assignment); - } - leave_block("Compute evaluation of polynomial C on set S"); - - enter_block("Compute coefficients of polynomial C"); - domain->iFFT(aC); - leave_block("Compute coefficients of polynomial C"); - - enter_block("Compute evaluation of polynomial C on set T"); - domain->cosetFFT(aC, FieldT::multiplicative_generator); - leave_block("Compute evaluation of polynomial C on set T"); - -#ifdef MULTICORE -#pragma omp parallel for -#endif - for (size_t i = 0; i < domain->m; ++i) - { - H_tmp[i] = (H_tmp[i]-aC[i]); - } - - enter_block("Divide by Z on set T"); - domain->divide_by_Z_on_coset(H_tmp); - leave_block("Divide by Z on set T"); - - leave_block("Compute evaluation of polynomial H on set T"); - - enter_block("Compute coefficients of polynomial H"); - domain->icosetFFT(H_tmp, FieldT::multiplicative_generator); - leave_block("Compute coefficients of polynomial H"); - - enter_block("Compute sum of H and ZK-patch"); -#ifdef MULTICORE -#pragma omp parallel for -#endif - for (size_t i = 0; i < domain->m; ++i) - { - coefficients_for_H[i] += H_tmp[i]; - } - leave_block("Compute sum of H and ZK-patch"); - - leave_block("Call to r1cs_to_qap_witness_map"); - - return qap_witness(cs.num_variables(), - domain->m, - cs.num_inputs(), - d1, - d2, - d3, - full_variable_assignment, - std::move(coefficients_for_H)); -} - -} // libsnark - -#endif // R1CS_TO_QAP_TCC_ diff --git a/src/snark/libsnark/relations/arithmetic_programs/qap/qap.hpp b/src/snark/libsnark/relations/arithmetic_programs/qap/qap.hpp deleted file mode 100644 index 4991d203b..000000000 --- a/src/snark/libsnark/relations/arithmetic_programs/qap/qap.hpp +++ /dev/null @@ -1,193 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for a QAP ("Quadratic Arithmetic Program"). - - QAPs are defined in \[GGPR13]. - - References: - - \[GGPR13]: - "Quadratic span programs and succinct NIZKs without PCPs", - Rosario Gennaro, Craig Gentry, Bryan Parno, Mariana Raykova, - EUROCRYPT 2013, - - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef QAP_HPP_ -#define QAP_HPP_ - -#include "algebra/evaluation_domain/evaluation_domain.hpp" - -namespace libsnark { - -/* forward declaration */ -template -class qap_witness; - -/** - * A QAP instance. - * - * Specifically, the datastructure stores: - * - a choice of domain (corresponding to a certain subset of the field); - * - the number of variables, the degree, and the number of inputs; and - * - coefficients of the A,B,C polynomials in the Lagrange basis. - * - * There is no need to store the Z polynomial because it is uniquely - * determined by the domain (as Z is its vanishing polynomial). - */ -template -class qap_instance { -private: - size_t num_variables_; - size_t degree_; - size_t num_inputs_; - -public: - std::shared_ptr > domain; - - std::vector > A_in_Lagrange_basis; - std::vector > B_in_Lagrange_basis; - std::vector > C_in_Lagrange_basis; - - qap_instance(const std::shared_ptr > &domain, - const size_t num_variables, - const size_t degree, - const size_t num_inputs, - const std::vector > &A_in_Lagrange_basis, - const std::vector > &B_in_Lagrange_basis, - const std::vector > &C_in_Lagrange_basis); - - qap_instance(const std::shared_ptr > &domain, - const size_t num_variables, - const size_t degree, - const size_t num_inputs, - std::vector > &&A_in_Lagrange_basis, - std::vector > &&B_in_Lagrange_basis, - std::vector > &&C_in_Lagrange_basis); - - qap_instance(const qap_instance &other) = default; - qap_instance(qap_instance &&other) = default; - qap_instance& operator=(const qap_instance &other) = default; - qap_instance& operator=(qap_instance &&other) = default; - - size_t num_variables() const; - size_t degree() const; - size_t num_inputs() const; - - bool is_satisfied(const qap_witness &witness) const; -}; - -/** - * A QAP instance evaluation is a QAP instance that is evaluated at a field element t. - * - * Specifically, the datastructure stores: - * - a choice of domain (corresponding to a certain subset of the field); - * - the number of variables, the degree, and the number of inputs; - * - a field element t; - * - evaluations of the A,B,C (and Z) polynomials at t; - * - evaluations of all monomials of t; - * - counts about how many of the above evaluations are in fact non-zero. - */ -template -class qap_instance_evaluation { -private: - size_t num_variables_; - size_t degree_; - size_t num_inputs_; -public: - std::shared_ptr > domain; - - FieldT t; - - std::vector At, Bt, Ct, Ht; - - FieldT Zt; - - qap_instance_evaluation(const std::shared_ptr > &domain, - const size_t num_variables, - const size_t degree, - const size_t num_inputs, - const FieldT &t, - const std::vector &At, - const std::vector &Bt, - const std::vector &Ct, - const std::vector &Ht, - const FieldT &Zt); - qap_instance_evaluation(const std::shared_ptr > &domain, - const size_t num_variables, - const size_t degree, - const size_t num_inputs, - const FieldT &t, - std::vector &&At, - std::vector &&Bt, - std::vector &&Ct, - std::vector &&Ht, - const FieldT &Zt); - - qap_instance_evaluation(const qap_instance_evaluation &other) = default; - qap_instance_evaluation(qap_instance_evaluation &&other) = default; - qap_instance_evaluation& operator=(const qap_instance_evaluation &other) = default; - qap_instance_evaluation& operator=(qap_instance_evaluation &&other) = default; - - size_t num_variables() const; - size_t degree() const; - size_t num_inputs() const; - - bool is_satisfied(const qap_witness &witness) const; -}; - -/** - * A QAP witness. - */ -template -class qap_witness { -private: - size_t num_variables_; - size_t degree_; - size_t num_inputs_; - -public: - FieldT d1, d2, d3; - - std::vector coefficients_for_ABCs; - std::vector coefficients_for_H; - - qap_witness(const size_t num_variables, - const size_t degree, - const size_t num_inputs, - const FieldT &d1, - const FieldT &d2, - const FieldT &d3, - const std::vector &coefficients_for_ABCs, - const std::vector &coefficients_for_H); - - qap_witness(const size_t num_variables, - const size_t degree, - const size_t num_inputs, - const FieldT &d1, - const FieldT &d2, - const FieldT &d3, - const std::vector &coefficients_for_ABCs, - std::vector &&coefficients_for_H); - - qap_witness(const qap_witness &other) = default; - qap_witness(qap_witness &&other) = default; - qap_witness& operator=(const qap_witness &other) = default; - qap_witness& operator=(qap_witness &&other) = default; - - size_t num_variables() const; - size_t degree() const; - size_t num_inputs() const; -}; - -} // libsnark - -#include "relations/arithmetic_programs/qap/qap.tcc" - -#endif // QAP_HPP_ diff --git a/src/snark/libsnark/relations/arithmetic_programs/qap/qap.tcc b/src/snark/libsnark/relations/arithmetic_programs/qap/qap.tcc deleted file mode 100644 index a4a3c96a2..000000000 --- a/src/snark/libsnark/relations/arithmetic_programs/qap/qap.tcc +++ /dev/null @@ -1,324 +0,0 @@ -/** @file -***************************************************************************** - -Implementation of interfaces for a QAP ("Quadratic Arithmetic Program"). - -See qap.hpp . - -***************************************************************************** -* @author This file is part of libsnark, developed by SCIPR Lab -* and contributors (see AUTHORS). -* @copyright MIT license (see LICENSE file) -*****************************************************************************/ - -#ifndef QAP_TCC_ -#define QAP_TCC_ - -#include "common/profiling.hpp" -#include "common/utils.hpp" -#include "algebra/evaluation_domain/evaluation_domain.hpp" -#include "algebra/scalar_multiplication/multiexp.hpp" - -namespace libsnark { - -template -qap_instance::qap_instance(const std::shared_ptr > &domain, - const size_t num_variables, - const size_t degree, - const size_t num_inputs, - const std::vector > &A_in_Lagrange_basis, - const std::vector > &B_in_Lagrange_basis, - const std::vector > &C_in_Lagrange_basis) : - num_variables_(num_variables), - degree_(degree), - num_inputs_(num_inputs), - domain(domain), - A_in_Lagrange_basis(A_in_Lagrange_basis), - B_in_Lagrange_basis(B_in_Lagrange_basis), - C_in_Lagrange_basis(C_in_Lagrange_basis) -{ -} - -template -qap_instance::qap_instance(const std::shared_ptr > &domain, - const size_t num_variables, - const size_t degree, - const size_t num_inputs, - std::vector > &&A_in_Lagrange_basis, - std::vector > &&B_in_Lagrange_basis, - std::vector > &&C_in_Lagrange_basis) : - num_variables_(num_variables), - degree_(degree), - num_inputs_(num_inputs), - domain(domain), - A_in_Lagrange_basis(std::move(A_in_Lagrange_basis)), - B_in_Lagrange_basis(std::move(B_in_Lagrange_basis)), - C_in_Lagrange_basis(std::move(C_in_Lagrange_basis)) -{ -} - -template -size_t qap_instance::num_variables() const -{ - return num_variables_; -} - -template -size_t qap_instance::degree() const -{ - return degree_; -} - -template -size_t qap_instance::num_inputs() const -{ - return num_inputs_; -} - -template -bool qap_instance::is_satisfied(const qap_witness &witness) const -{ - const FieldT t = FieldT::random_element(); - - std::vector At(this->num_variables()+1, FieldT::zero()); - std::vector Bt(this->num_variables()+1, FieldT::zero()); - std::vector Ct(this->num_variables()+1, FieldT::zero()); - std::vector Ht(this->degree()+1); - - const FieldT Zt = this->domain->compute_Z(t); - - const std::vector u = this->domain->lagrange_coeffs(t); - - for (size_t i = 0; i < this->num_variables()+1; ++i) - { - for (auto &el : A_in_Lagrange_basis[i]) - { - At[i] += u[el.first] * el.second; - } - - for (auto &el : B_in_Lagrange_basis[i]) - { - Bt[i] += u[el.first] * el.second; - } - - for (auto &el : C_in_Lagrange_basis[i]) - { - Ct[i] += u[el.first] * el.second; - } - } - - FieldT ti = FieldT::one(); - for (size_t i = 0; i < this->degree()+1; ++i) - { - Ht[i] = ti; - ti *= t; - } - - const qap_instance_evaluation eval_qap_inst(this->domain, - this->num_variables(), - this->degree(), - this->num_inputs(), - t, - std::move(At), - std::move(Bt), - std::move(Ct), - std::move(Ht), - Zt); - return eval_qap_inst.is_satisfied(witness); -} - -template -qap_instance_evaluation::qap_instance_evaluation(const std::shared_ptr > &domain, - const size_t num_variables, - const size_t degree, - const size_t num_inputs, - const FieldT &t, - const std::vector &At, - const std::vector &Bt, - const std::vector &Ct, - const std::vector &Ht, - const FieldT &Zt) : - num_variables_(num_variables), - degree_(degree), - num_inputs_(num_inputs), - domain(domain), - t(t), - At(At), - Bt(Bt), - Ct(Ct), - Ht(Ht), - Zt(Zt) -{ -} - -template -qap_instance_evaluation::qap_instance_evaluation(const std::shared_ptr > &domain, - const size_t num_variables, - const size_t degree, - const size_t num_inputs, - const FieldT &t, - std::vector &&At, - std::vector &&Bt, - std::vector &&Ct, - std::vector &&Ht, - const FieldT &Zt) : - num_variables_(num_variables), - degree_(degree), - num_inputs_(num_inputs), - domain(domain), - t(t), - At(std::move(At)), - Bt(std::move(Bt)), - Ct(std::move(Ct)), - Ht(std::move(Ht)), - Zt(Zt) -{ -} - -template -size_t qap_instance_evaluation::num_variables() const -{ - return num_variables_; -} - -template -size_t qap_instance_evaluation::degree() const -{ - return degree_; -} - -template -size_t qap_instance_evaluation::num_inputs() const -{ - return num_inputs_; -} - -template -bool qap_instance_evaluation::is_satisfied(const qap_witness &witness) const -{ - - if (this->num_variables() != witness.num_variables()) - { - return false; - } - - if (this->degree() != witness.degree()) - { - return false; - } - - if (this->num_inputs() != witness.num_inputs()) - { - return false; - } - - if (this->num_variables() != witness.coefficients_for_ABCs.size()) - { - return false; - } - - if (this->degree()+1 != witness.coefficients_for_H.size()) - { - return false; - } - - if (this->At.size() != this->num_variables()+1 || this->Bt.size() != this->num_variables()+1 || this->Ct.size() != this->num_variables()+1) - { - return false; - } - - if (this->Ht.size() != this->degree()+1) - { - return false; - } - - if (this->Zt != this->domain->compute_Z(this->t)) - { - return false; - } - - FieldT ans_A = this->At[0] + witness.d1*this->Zt; - FieldT ans_B = this->Bt[0] + witness.d2*this->Zt; - FieldT ans_C = this->Ct[0] + witness.d3*this->Zt; - FieldT ans_H = FieldT::zero(); - - ans_A = ans_A + naive_plain_exp(this->At.begin()+1, this->At.begin()+1+this->num_variables(), - witness.coefficients_for_ABCs.begin(), witness.coefficients_for_ABCs.begin()+this->num_variables()); - ans_B = ans_B + naive_plain_exp(this->Bt.begin()+1, this->Bt.begin()+1+this->num_variables(), - witness.coefficients_for_ABCs.begin(), witness.coefficients_for_ABCs.begin()+this->num_variables()); - ans_C = ans_C + naive_plain_exp(this->Ct.begin()+1, this->Ct.begin()+1+this->num_variables(), - witness.coefficients_for_ABCs.begin(), witness.coefficients_for_ABCs.begin()+this->num_variables()); - ans_H = ans_H + naive_plain_exp(this->Ht.begin(), this->Ht.begin()+this->degree()+1, - witness.coefficients_for_H.begin(), witness.coefficients_for_H.begin()+this->degree()+1); - - if (ans_A * ans_B - ans_C != ans_H * this->Zt) - { - return false; - } - - return true; -} - -template -qap_witness::qap_witness(const size_t num_variables, - const size_t degree, - const size_t num_inputs, - const FieldT &d1, - const FieldT &d2, - const FieldT &d3, - const std::vector &coefficients_for_ABCs, - const std::vector &coefficients_for_H) : - num_variables_(num_variables), - degree_(degree), - num_inputs_(num_inputs), - d1(d1), - d2(d2), - d3(d3), - coefficients_for_ABCs(coefficients_for_ABCs), - coefficients_for_H(coefficients_for_H) -{ -} - -template -qap_witness::qap_witness(const size_t num_variables, - const size_t degree, - const size_t num_inputs, - const FieldT &d1, - const FieldT &d2, - const FieldT &d3, - const std::vector &coefficients_for_ABCs, - std::vector &&coefficients_for_H) : - num_variables_(num_variables), - degree_(degree), - num_inputs_(num_inputs), - d1(d1), - d2(d2), - d3(d3), - coefficients_for_ABCs(coefficients_for_ABCs), - coefficients_for_H(std::move(coefficients_for_H)) -{ -} - - -template -size_t qap_witness::num_variables() const -{ - return num_variables_; -} - -template -size_t qap_witness::degree() const -{ - return degree_; -} - -template -size_t qap_witness::num_inputs() const -{ - return num_inputs_; -} - - -} // libsnark - -#endif // QAP_TCC_ diff --git a/src/snark/libsnark/relations/arithmetic_programs/qap/tests/test_qap.cpp b/src/snark/libsnark/relations/arithmetic_programs/qap/tests/test_qap.cpp deleted file mode 100644 index 3c7b87057..000000000 --- a/src/snark/libsnark/relations/arithmetic_programs/qap/tests/test_qap.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/** - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ -#include -#include -#include -#include -#include - -#include "algebra/curves/alt_bn128/alt_bn128_pp.hpp" -#include "algebra/fields/field_utils.hpp" -#include "common/profiling.hpp" -#include "common/utils.hpp" -#include "reductions/r1cs_to_qap/r1cs_to_qap.hpp" -#include "relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.hpp" - -#include - -using namespace libsnark; - -template -void test_qap(const size_t qap_degree, const size_t num_inputs, const bool binary_input) -{ - /* - We construct an instance where the QAP degree is qap_degree. - So we generate an instance of R1CS where the number of constraints qap_degree - num_inputs - 1. - See the transformation from R1CS to QAP for why this is the case. - So we need that qap_degree >= num_inputs + 1. - */ - ASSERT_LE(num_inputs + 1, qap_degree); - enter_block("Call to test_qap"); - - const size_t num_constraints = qap_degree - num_inputs - 1; - - print_indent(); printf("* QAP degree: %zu\n", qap_degree); - print_indent(); printf("* Number of inputs: %zu\n", num_inputs); - print_indent(); printf("* Number of R1CS constraints: %zu\n", num_constraints); - print_indent(); printf("* Input type: %s\n", binary_input ? "binary" : "field"); - - enter_block("Generate constraint system and assignment"); - r1cs_example example; - if (binary_input) - { - example = generate_r1cs_example_with_binary_input(num_constraints, num_inputs); - } - else - { - example = generate_r1cs_example_with_field_input(num_constraints, num_inputs); - } - leave_block("Generate constraint system and assignment"); - - enter_block("Check satisfiability of constraint system"); - EXPECT_TRUE(example.constraint_system.is_satisfied(example.primary_input, example.auxiliary_input)); - leave_block("Check satisfiability of constraint system"); - - const FieldT t = FieldT::random_element(), - d1 = FieldT::random_element(), - d2 = FieldT::random_element(), - d3 = FieldT::random_element(); - - enter_block("Compute QAP instance 1"); - qap_instance qap_inst_1 = r1cs_to_qap_instance_map(example.constraint_system); - leave_block("Compute QAP instance 1"); - - enter_block("Compute QAP instance 2"); - qap_instance_evaluation qap_inst_2 = r1cs_to_qap_instance_map_with_evaluation(example.constraint_system, t); - leave_block("Compute QAP instance 2"); - - enter_block("Compute QAP witness"); - qap_witness qap_wit = r1cs_to_qap_witness_map(example.constraint_system, example.primary_input, example.auxiliary_input, d1, d2, d3); - leave_block("Compute QAP witness"); - - enter_block("Check satisfiability of QAP instance 1"); - EXPECT_TRUE(qap_inst_1.is_satisfied(qap_wit)); - leave_block("Check satisfiability of QAP instance 1"); - - enter_block("Check satisfiability of QAP instance 2"); - EXPECT_TRUE(qap_inst_2.is_satisfied(qap_wit)); - leave_block("Check satisfiability of QAP instance 2"); - - leave_block("Call to test_qap"); -} - -TEST(relations, qap) -{ - start_profiling(); - - const size_t num_inputs = 10; - - enter_block("Test QAP with binary input"); - - test_qap >(UINT64_C(1) << 21, num_inputs, true); - - leave_block("Test QAP with binary input"); - - enter_block("Test QAP with field input"); - - test_qap >(UINT64_C(1) << 21, num_inputs, false); - - leave_block("Test QAP with field input"); -} diff --git a/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.hpp b/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.hpp deleted file mode 100644 index 47003e959..000000000 --- a/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for a R1CS example, as well as functions to sample - R1CS examples with prescribed parameters (according to some distribution). - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef R1CS_EXAMPLES_HPP_ -#define R1CS_EXAMPLES_HPP_ - -#include "relations/constraint_satisfaction_problems/r1cs/r1cs.hpp" - -namespace libsnark { - -/** - * A R1CS example comprises a R1CS constraint system, R1CS input, and R1CS witness. - */ -template -struct r1cs_example { - r1cs_constraint_system constraint_system; - r1cs_primary_input primary_input; - r1cs_auxiliary_input auxiliary_input; - - r1cs_example() = default; - r1cs_example(const r1cs_example &other) = default; - r1cs_example(const r1cs_constraint_system &constraint_system, - const r1cs_primary_input &primary_input, - const r1cs_auxiliary_input &auxiliary_input) : - constraint_system(constraint_system), - primary_input(primary_input), - auxiliary_input(auxiliary_input) - {}; - r1cs_example(r1cs_constraint_system &&constraint_system, - r1cs_primary_input &&primary_input, - r1cs_auxiliary_input &&auxiliary_input) : - constraint_system(std::move(constraint_system)), - primary_input(std::move(primary_input)), - auxiliary_input(std::move(auxiliary_input)) - {}; -}; - -/** - * Generate a R1CS example such that: - * - the number of constraints of the R1CS constraint system is num_constraints; - * - the number of variables of the R1CS constraint system is (approximately) num_constraints; - * - the number of inputs of the R1CS constraint system is num_inputs; - * - the R1CS input consists of ``full'' field elements (typically require the whole log|Field| bits to represent). - */ -template -r1cs_example generate_r1cs_example_with_field_input(const size_t num_constraints, - const size_t num_inputs); - -/** - * Generate a R1CS example such that: - * - the number of constraints of the R1CS constraint system is num_constraints; - * - the number of variables of the R1CS constraint system is (approximately) num_constraints; - * - the number of inputs of the R1CS constraint system is num_inputs; - * - the R1CS input consists of binary values (as opposed to ``full'' field elements). - */ -template -r1cs_example generate_r1cs_example_with_binary_input(const size_t num_constraints, - const size_t num_inputs); - -} // libsnark - -#include "relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.tcc" - -#endif // R1CS_EXAMPLES_HPP_ diff --git a/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.tcc b/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.tcc deleted file mode 100644 index defa07721..000000000 --- a/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.tcc +++ /dev/null @@ -1,164 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of functions to sample R1CS examples with prescribed parameters - (according to some distribution). - - See r1cs_examples.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef R1CS_EXAMPLES_TCC_ -#define R1CS_EXAMPLES_TCC_ - -#include - -#include "common/utils.hpp" - -namespace libsnark { - -template -r1cs_example generate_r1cs_example_with_field_input(const size_t num_constraints, - const size_t num_inputs) -{ - enter_block("Call to generate_r1cs_example_with_field_input"); - - assert(num_inputs <= num_constraints + 2); - - r1cs_constraint_system cs; - cs.primary_input_size = num_inputs; - cs.auxiliary_input_size = 2 + num_constraints - num_inputs; // TODO: explain this - - r1cs_variable_assignment full_variable_assignment; - FieldT a = FieldT::random_element(); - FieldT b = FieldT::random_element(); - full_variable_assignment.push_back(a); - full_variable_assignment.push_back(b); - - for (size_t i = 0; i < num_constraints-1; ++i) - { - linear_combination A, B, C; - - if (i % 2) - { - // a * b = c - A.add_term(i+1, 1); - B.add_term(i+2, 1); - C.add_term(i+3, 1); - FieldT tmp = a*b; - full_variable_assignment.push_back(tmp); - a = b; b = tmp; - } - else - { - // a + b = c - B.add_term(0, 1); - A.add_term(i+1, 1); - A.add_term(i+2, 1); - C.add_term(i+3, 1); - FieldT tmp = a+b; - full_variable_assignment.push_back(tmp); - a = b; b = tmp; - } - - cs.add_constraint(r1cs_constraint(A, B, C)); - } - - linear_combination A, B, C; - FieldT fin = FieldT::zero(); - for (size_t i = 1; i < cs.num_variables(); ++i) - { - A.add_term(i, 1); - B.add_term(i, 1); - fin = fin + full_variable_assignment[i-1]; - } - C.add_term(cs.num_variables(), 1); - cs.add_constraint(r1cs_constraint(A, B, C)); - full_variable_assignment.push_back(fin.squared()); - - /* split variable assignment */ - r1cs_primary_input primary_input(full_variable_assignment.begin(), full_variable_assignment.begin() + num_inputs); - r1cs_primary_input auxiliary_input(full_variable_assignment.begin() + num_inputs, full_variable_assignment.end()); - - /* sanity checks */ - assert(cs.num_variables() == full_variable_assignment.size()); - assert(cs.num_variables() >= num_inputs); - assert(cs.num_inputs() == num_inputs); - assert(cs.num_constraints() == num_constraints); - assert(cs.is_satisfied(primary_input, auxiliary_input)); - - leave_block("Call to generate_r1cs_example_with_field_input"); - - return r1cs_example(std::move(cs), std::move(primary_input), std::move(auxiliary_input)); -} - -template -r1cs_example generate_r1cs_example_with_binary_input(const size_t num_constraints, - const size_t num_inputs) -{ - enter_block("Call to generate_r1cs_example_with_binary_input"); - - assert(num_inputs >= 1); - - r1cs_constraint_system cs; - cs.primary_input_size = num_inputs; - cs.auxiliary_input_size = num_constraints; /* we will add one auxiliary variable per constraint */ - - r1cs_variable_assignment full_variable_assignment; - for (size_t i = 0; i < num_inputs; ++i) - { - full_variable_assignment.push_back(FieldT(std::rand() % 2)); - } - - size_t lastvar = num_inputs-1; - for (size_t i = 0; i < num_constraints; ++i) - { - ++lastvar; - const size_t u = (i == 0 ? std::rand() % num_inputs : std::rand() % i); - const size_t v = (i == 0 ? std::rand() % num_inputs : std::rand() % i); - - /* chose two random bits and XOR them together: - res = u + v - 2 * u * v - 2 * u * v = u + v - res - */ - linear_combination A, B, C; - A.add_term(u+1, 2); - B.add_term(v+1, 1); - if (u == v) - { - C.add_term(u+1, 2); - } - else - { - C.add_term(u+1, 1); - C.add_term(v+1, 1); - } - C.add_term(lastvar+1, -FieldT::one()); - - cs.add_constraint(r1cs_constraint(A, B, C)); - full_variable_assignment.push_back(full_variable_assignment[u] + full_variable_assignment[v] - full_variable_assignment[u] * full_variable_assignment[v] - full_variable_assignment[u] * full_variable_assignment[v]); - } - - /* split variable assignment */ - r1cs_primary_input primary_input(full_variable_assignment.begin(), full_variable_assignment.begin() + num_inputs); - r1cs_primary_input auxiliary_input(full_variable_assignment.begin() + num_inputs, full_variable_assignment.end()); - - /* sanity checks */ - assert(cs.num_variables() == full_variable_assignment.size()); - assert(cs.num_variables() >= num_inputs); - assert(cs.num_inputs() == num_inputs); - assert(cs.num_constraints() == num_constraints); - assert(cs.is_satisfied(primary_input, auxiliary_input)); - - leave_block("Call to generate_r1cs_example_with_binary_input"); - - return r1cs_example(std::move(cs), std::move(primary_input), std::move(auxiliary_input)); -} - -} // libsnark - -#endif // R1CS_EXAMPLES_TCC diff --git a/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.hpp b/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.hpp deleted file mode 100644 index ca3acb3a9..000000000 --- a/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.hpp +++ /dev/null @@ -1,153 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for: - - a R1CS constraint, - - a R1CS variable assignment, and - - a R1CS constraint system. - - Above, R1CS stands for "Rank-1 Constraint System". - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef R1CS_HPP_ -#define R1CS_HPP_ - -#include -#include -#include -#include -#include - -#include "relations/variable.hpp" - -namespace libsnark { - -/************************* R1CS constraint ***********************************/ - -template -class r1cs_constraint; - -template -std::ostream& operator<<(std::ostream &out, const r1cs_constraint &c); - -template -std::istream& operator>>(std::istream &in, r1cs_constraint &c); - -/** - * A R1CS constraint is a formal expression of the form - * - * < A , X > * < B , X > = < C , X > , - * - * where X = (x_0,x_1,...,x_m) is a vector of formal variables and A,B,C each - * consist of 1+m elements in . - * - * A R1CS constraint is used to construct a R1CS constraint system (see below). - */ -template -class r1cs_constraint { -public: - - linear_combination a, b, c; - - r1cs_constraint() {}; - r1cs_constraint(const linear_combination &a, - const linear_combination &b, - const linear_combination &c); - - r1cs_constraint(const std::initializer_list > &A, - const std::initializer_list > &B, - const std::initializer_list > &C); - - bool operator==(const r1cs_constraint &other) const; - - friend std::ostream& operator<< (std::ostream &out, const r1cs_constraint &c); - friend std::istream& operator>> (std::istream &in, r1cs_constraint &c); -}; - -/************************* R1CS variable assignment **************************/ - -/** - * A R1CS variable assignment is a vector of elements that represents - * a candidate solution to a R1CS constraint system (see below). - */ - -/* TODO: specify that it does *NOT* include the constant 1 */ -template -using r1cs_primary_input = std::vector; - -template -using r1cs_auxiliary_input = std::vector; - -template -using r1cs_variable_assignment = std::vector; /* note the changed name! (TODO: remove this comment after primary_input transition is complete) */ - -/************************* R1CS constraint system ****************************/ - -template -class r1cs_constraint_system; - -template -std::ostream& operator<<(std::ostream &out, const r1cs_constraint_system &cs); - -template -std::istream& operator>>(std::istream &in, r1cs_constraint_system &cs); - -/** - * A system of R1CS constraints looks like - * - * { < A_k , X > * < B_k , X > = < C_k , X > }_{k=1}^{n} . - * - * In other words, the system is satisfied if and only if there exist a - * USCS variable assignment for which each R1CS constraint is satisfied. - * - * NOTE: - * The 0-th variable (i.e., "x_{0}") always represents the constant 1. - * Thus, the 0-th variable is not included in num_variables. - */ -template -class r1cs_constraint_system { -public: - size_t primary_input_size; - size_t auxiliary_input_size; - - std::vector > constraints; - - r1cs_constraint_system() : primary_input_size(0), auxiliary_input_size(0) {} - - size_t num_inputs() const; - size_t num_variables() const; - size_t num_constraints() const; - -#ifdef DEBUG - std::map constraint_annotations; - std::map variable_annotations; -#endif - - bool is_valid() const; - bool is_satisfied(const r1cs_primary_input &primary_input, - const r1cs_auxiliary_input &auxiliary_input) const; - - void add_constraint(const r1cs_constraint &c); - void add_constraint(const r1cs_constraint &c, const std::string &annotation); - - void swap_AB_if_beneficial(); - - bool operator==(const r1cs_constraint_system &other) const; - - friend std::ostream& operator<< (std::ostream &out, const r1cs_constraint_system &cs); - friend std::istream& operator>> (std::istream &in, r1cs_constraint_system &cs); - - void report_linear_constraint_statistics() const; -}; - - -} // libsnark - -#include "relations/constraint_satisfaction_problems/r1cs/r1cs.tcc" - -#endif // R1CS_HPP_ diff --git a/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.tcc b/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.tcc deleted file mode 100644 index 0faa56a87..000000000 --- a/src/snark/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.tcc +++ /dev/null @@ -1,310 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for: - - a R1CS constraint, - - a R1CS variable assignment, and - - a R1CS constraint system. - - See r1cs.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef R1CS_TCC_ -#define R1CS_TCC_ - -#include -#include -#include -#include "common/utils.hpp" -#include "common/profiling.hpp" -#include "algebra/fields/bigint.hpp" - -namespace libsnark { - -template -r1cs_constraint::r1cs_constraint(const linear_combination &a, - const linear_combination &b, - const linear_combination &c) : - a(a), b(b), c(c) -{ -} - -template -r1cs_constraint::r1cs_constraint(const std::initializer_list > &A, - const std::initializer_list > &B, - const std::initializer_list > &C) -{ - for (auto lc_A : A) - { - a.terms.insert(a.terms.end(), lc_A.terms.begin(), lc_A.terms.end()); - } - for (auto lc_B : B) - { - b.terms.insert(b.terms.end(), lc_B.terms.begin(), lc_B.terms.end()); - } - for (auto lc_C : C) - { - c.terms.insert(c.terms.end(), lc_C.terms.begin(), lc_C.terms.end()); - } -} - -template -bool r1cs_constraint::operator==(const r1cs_constraint &other) const -{ - return (this->a == other.a && - this->b == other.b && - this->c == other.c); -} - -template -std::ostream& operator<<(std::ostream &out, const r1cs_constraint &c) -{ - out << c.a; - out << c.b; - out << c.c; - - return out; -} - -template -std::istream& operator>>(std::istream &in, r1cs_constraint &c) -{ - in >> c.a; - in >> c.b; - in >> c.c; - - return in; -} - -template -size_t r1cs_constraint_system::num_inputs() const -{ - return primary_input_size; -} - -template -size_t r1cs_constraint_system::num_variables() const -{ - return primary_input_size + auxiliary_input_size; -} - - -template -size_t r1cs_constraint_system::num_constraints() const -{ - return constraints.size(); -} - -template -bool r1cs_constraint_system::is_valid() const -{ - if (this->num_inputs() > this->num_variables()) return false; - - for (size_t c = 0; c < constraints.size(); ++c) - { - if (!(constraints[c].a.is_valid(this->num_variables()) && - constraints[c].b.is_valid(this->num_variables()) && - constraints[c].c.is_valid(this->num_variables()))) - { - return false; - } - } - - return true; -} - -template -void dump_r1cs_constraint(const r1cs_constraint &constraint, - const r1cs_variable_assignment &full_variable_assignment, - const std::map &variable_annotations) -{ - printf("terms for a:\n"); constraint.a.print_with_assignment(full_variable_assignment, variable_annotations); - printf("terms for b:\n"); constraint.b.print_with_assignment(full_variable_assignment, variable_annotations); - printf("terms for c:\n"); constraint.c.print_with_assignment(full_variable_assignment, variable_annotations); -} - -template -bool r1cs_constraint_system::is_satisfied(const r1cs_primary_input &primary_input, - const r1cs_auxiliary_input &auxiliary_input) const -{ - assert(primary_input.size() == num_inputs()); - assert(primary_input.size() + auxiliary_input.size() == num_variables()); - - r1cs_variable_assignment full_variable_assignment = primary_input; - full_variable_assignment.insert(full_variable_assignment.end(), auxiliary_input.begin(), auxiliary_input.end()); - - for (size_t c = 0; c < constraints.size(); ++c) - { - const FieldT ares = constraints[c].a.evaluate(full_variable_assignment); - const FieldT bres = constraints[c].b.evaluate(full_variable_assignment); - const FieldT cres = constraints[c].c.evaluate(full_variable_assignment); - - if (!(ares*bres == cres)) - { -#ifdef DEBUG - auto it = constraint_annotations.find(c); - printf("constraint %zu (%s) unsatisfied\n", c, (it == constraint_annotations.end() ? "no annotation" : it->second.c_str())); - printf(" = "); ares.print(); - printf(" = "); bres.print(); - printf(" = "); cres.print(); - printf("constraint was:\n"); - dump_r1cs_constraint(constraints[c], full_variable_assignment, variable_annotations); -#endif // DEBUG - return false; - } - } - - return true; -} - -template -void r1cs_constraint_system::add_constraint(const r1cs_constraint &c) -{ - constraints.emplace_back(c); -} - -template -void r1cs_constraint_system::add_constraint(const r1cs_constraint &c, const std::string &annotation) -{ -#ifdef DEBUG - constraint_annotations[constraints.size()] = annotation; -#endif - constraints.emplace_back(c); -} - -template -void r1cs_constraint_system::swap_AB_if_beneficial() -{ - enter_block("Call to r1cs_constraint_system::swap_AB_if_beneficial"); - - enter_block("Estimate densities"); - bit_vector touched_by_A(this->num_variables() + 1, false), touched_by_B(this->num_variables() + 1, false); - - for (size_t i = 0; i < this->constraints.size(); ++i) - { - for (size_t j = 0; j < this->constraints[i].a.terms.size(); ++j) - { - touched_by_A[this->constraints[i].a.terms[j].index] = true; - } - - for (size_t j = 0; j < this->constraints[i].b.terms.size(); ++j) - { - touched_by_B[this->constraints[i].b.terms[j].index] = true; - } - } - - size_t non_zero_A_count = 0, non_zero_B_count = 0; - for (size_t i = 0; i < this->num_variables() + 1; ++i) - { - non_zero_A_count += touched_by_A[i] ? 1 : 0; - non_zero_B_count += touched_by_B[i] ? 1 : 0; - } - - if (!inhibit_profiling_info) - { - print_indent(); printf("* Non-zero A-count (estimate): %zu\n", non_zero_A_count); - print_indent(); printf("* Non-zero B-count (estimate): %zu\n", non_zero_B_count); - } - leave_block("Estimate densities"); - - if (non_zero_B_count > non_zero_A_count) - { - enter_block("Perform the swap"); - for (size_t i = 0; i < this->constraints.size(); ++i) - { - std::swap(this->constraints[i].a, this->constraints[i].b); - } - leave_block("Perform the swap"); - } - else - { - print_indent(); printf("Swap is not beneficial, not performing\n"); - } - - leave_block("Call to r1cs_constraint_system::swap_AB_if_beneficial"); -} - -template -bool r1cs_constraint_system::operator==(const r1cs_constraint_system &other) const -{ - return (this->constraints == other.constraints && - this->primary_input_size == other.primary_input_size && - this->auxiliary_input_size == other.auxiliary_input_size); -} - -template -std::ostream& operator<<(std::ostream &out, const r1cs_constraint_system &cs) -{ - out << cs.primary_input_size << "\n"; - out << cs.auxiliary_input_size << "\n"; - - out << cs.num_constraints() << "\n"; - for (const r1cs_constraint& c : cs.constraints) - { - out << c; - } - - return out; -} - -template -std::istream& operator>>(std::istream &in, r1cs_constraint_system &cs) -{ - in >> cs.primary_input_size; - in >> cs.auxiliary_input_size; - - cs.constraints.clear(); - - size_t s; - in >> s; - - char b; - in.read(&b, 1); - - cs.constraints.reserve(s); - - for (size_t i = 0; i < s; ++i) - { - r1cs_constraint c; - in >> c; - cs.constraints.emplace_back(c); - } - - return in; -} - -template -void r1cs_constraint_system::report_linear_constraint_statistics() const -{ -#ifdef DEBUG - for (size_t i = 0; i < constraints.size(); ++i) - { - auto &constr = constraints[i]; - bool a_is_const = true; - for (auto &t : constr.a.terms) - { - a_is_const = a_is_const && (t.index == 0); - } - - bool b_is_const = true; - for (auto &t : constr.b.terms) - { - b_is_const = b_is_const && (t.index == 0); - } - - if (a_is_const || b_is_const) - { - auto it = constraint_annotations.find(i); - printf("%s\n", (it == constraint_annotations.end() ? FORMAT("", "constraint_%zu", i) : it->second).c_str()); - } - } -#endif -} - -} // libsnark -#endif // R1CS_TCC_ diff --git a/src/snark/libsnark/relations/variable.hpp b/src/snark/libsnark/relations/variable.hpp deleted file mode 100644 index 84c65e810..000000000 --- a/src/snark/libsnark/relations/variable.hpp +++ /dev/null @@ -1,213 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for: - - a variable (i.e., x_i), - - a linear term (i.e., a_i * x_i), and - - a linear combination (i.e., sum_i a_i * x_i). - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef VARIABLE_HPP_ -#define VARIABLE_HPP_ - -#include -#include -#include -#include - -namespace libsnark { - -/** - * Mnemonic typedefs. - */ -typedef size_t var_index_t; -typedef int64_t integer_coeff_t; - -/** - * Forward declaration. - */ -template -class linear_term; - -/** - * Forward declaration. - */ -template -class linear_combination; - -/********************************* Variable **********************************/ - -/** - * A variable represents a formal expression of the form "x_{index}". - */ -template -class variable { -public: - - var_index_t index; - - variable(const var_index_t index = 0) : index(index) {}; - - linear_term operator*(const integer_coeff_t int_coeff) const; - linear_term operator*(const FieldT &field_coeff) const; - - linear_combination operator+(const linear_combination &other) const; - linear_combination operator-(const linear_combination &other) const; - - linear_term operator-() const; - - bool operator==(const variable &other) const; -}; - -template -linear_term operator*(const integer_coeff_t int_coeff, const variable &var); - -template -linear_term operator*(const FieldT &field_coeff, const variable &var); - -template -linear_combination operator+(const integer_coeff_t int_coeff, const variable &var); - -template -linear_combination operator+(const FieldT &field_coeff, const variable &var); - -template -linear_combination operator-(const integer_coeff_t int_coeff, const variable &var); - -template -linear_combination operator-(const FieldT &field_coeff, const variable &var); - - -/****************************** Linear term **********************************/ - -/** - * A linear term represents a formal expression of the form "coeff * x_{index}". - */ -template -class linear_term { -public: - - var_index_t index = 0; - FieldT coeff; - - linear_term() {}; - linear_term(const variable &var); - linear_term(const variable &var, const integer_coeff_t int_coeff); - linear_term(const variable &var, const FieldT &field_coeff); - - linear_term operator*(const integer_coeff_t int_coeff) const; - linear_term operator*(const FieldT &field_coeff) const; - - linear_combination operator+(const linear_combination &other) const; - linear_combination operator-(const linear_combination &other) const; - - linear_term operator-() const; - - bool operator==(const linear_term &other) const; -}; - -template -linear_term operator*(const integer_coeff_t int_coeff, const linear_term <); - -template -linear_term operator*(const FieldT &field_coeff, const linear_term <); - -template -linear_combination operator+(const integer_coeff_t int_coeff, const linear_term <); - -template -linear_combination operator+(const FieldT &field_coeff, const linear_term <); - -template -linear_combination operator-(const integer_coeff_t int_coeff, const linear_term <); - -template -linear_combination operator-(const FieldT &field_coeff, const linear_term <); - - -/***************************** Linear combination ****************************/ - -template -class linear_combination; - -template -std::ostream& operator<<(std::ostream &out, const linear_combination &lc); - -template -std::istream& operator>>(std::istream &in, linear_combination &lc); - -/** - * A linear combination represents a formal expression of the form "sum_i coeff_i * x_{index_i}". - */ -template -class linear_combination { -public: - - std::vector > terms; - - linear_combination() {}; - linear_combination(const integer_coeff_t int_coeff); - linear_combination(const FieldT &field_coeff); - linear_combination(const variable &var); - linear_combination(const linear_term <); - linear_combination(const std::vector > &all_terms); - - /* for supporting range-based for loops over linear_combination */ - typename std::vector >::const_iterator begin() const; - typename std::vector >::const_iterator end() const; - - void add_term(const variable &var); - void add_term(const variable &var, const integer_coeff_t int_coeff); - void add_term(const variable &var, const FieldT &field_coeff); - - void add_term(const linear_term <); - - FieldT evaluate(const std::vector &assignment) const; - - linear_combination operator*(const integer_coeff_t int_coeff) const; - linear_combination operator*(const FieldT &field_coeff) const; - - linear_combination operator+(const linear_combination &other) const; - - linear_combination operator-(const linear_combination &other) const; - linear_combination operator-() const; - - bool operator==(const linear_combination &other) const; - - bool is_valid(const size_t num_variables) const; - - void print(const std::map &variable_annotations = std::map()) const; - void print_with_assignment(const std::vector &full_assignment, const std::map &variable_annotations = std::map()) const; - - friend std::ostream& operator<< (std::ostream &out, const linear_combination &lc); - friend std::istream& operator>> (std::istream &in, linear_combination &lc); -}; - -template -linear_combination operator*(const integer_coeff_t int_coeff, const linear_combination &lc); - -template -linear_combination operator*(const FieldT &field_coeff, const linear_combination &lc); - -template -linear_combination operator+(const integer_coeff_t int_coeff, const linear_combination &lc); - -template -linear_combination operator+(const FieldT &field_coeff, const linear_combination &lc); - -template -linear_combination operator-(const integer_coeff_t int_coeff, const linear_combination &lc); - -template -linear_combination operator-(const FieldT &field_coeff, const linear_combination &lc); - -} // libsnark - -#include "relations/variable.tcc" - -#endif // VARIABLE_HPP_ diff --git a/src/snark/libsnark/relations/variable.tcc b/src/snark/libsnark/relations/variable.tcc deleted file mode 100644 index 4c4cab97f..000000000 --- a/src/snark/libsnark/relations/variable.tcc +++ /dev/null @@ -1,512 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of interfaces for: - - a variable (i.e., x_i), - - a linear term (i.e., a_i * x_i), and - - a linear combination (i.e., sum_i a_i * x_i). - - See variabe.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef VARIABLE_TCC_ -#define VARIABLE_TCC_ - -#include -#include - -#include "algebra/fields/bigint.hpp" - -namespace libsnark { - -template -linear_term variable::operator*(const integer_coeff_t int_coeff) const -{ - return linear_term(*this, int_coeff); -} - -template -linear_term variable::operator*(const FieldT &field_coeff) const -{ - return linear_term(*this, field_coeff); -} - -template -linear_combination variable::operator+(const linear_combination &other) const -{ - linear_combination result; - - result.add_term(*this); - result.terms.insert(result.terms.begin(), other.terms.begin(), other.terms.end()); - - return result; -} - -template -linear_combination variable::operator-(const linear_combination &other) const -{ - return (*this) + (-other); -} - -template -linear_term variable::operator-() const -{ - return linear_term(*this, -FieldT::one()); -} - -template -bool variable::operator==(const variable &other) const -{ - return (this->index == other.index); -} - -template -linear_term operator*(const integer_coeff_t int_coeff, const variable &var) -{ - return linear_term(var, int_coeff); -} - -template -linear_term operator*(const FieldT &field_coeff, const variable &var) -{ - return linear_term(var, field_coeff); -} - -template -linear_combination operator+(const integer_coeff_t int_coeff, const variable &var) -{ - return linear_combination(int_coeff) + var; -} - -template -linear_combination operator+(const FieldT &field_coeff, const variable &var) -{ - return linear_combination(field_coeff) + var; -} - -template -linear_combination operator-(const integer_coeff_t int_coeff, const variable &var) -{ - return linear_combination(int_coeff) - var; -} - -template -linear_combination operator-(const FieldT &field_coeff, const variable &var) -{ - return linear_combination(field_coeff) - var; -} - -template -linear_term::linear_term(const variable &var) : - index(var.index), coeff(FieldT::one()) -{ -} - -template -linear_term::linear_term(const variable &var, const integer_coeff_t int_coeff) : - index(var.index), coeff(FieldT(int_coeff)) -{ -} - -template -linear_term::linear_term(const variable &var, const FieldT &coeff) : - index(var.index), coeff(coeff) -{ -} - -template -linear_term linear_term::operator*(const integer_coeff_t int_coeff) const -{ - return (this->operator*(FieldT(int_coeff))); -} - -template -linear_term linear_term::operator*(const FieldT &field_coeff) const -{ - return linear_term(this->index, field_coeff * this->coeff); -} - -template -linear_combination operator+(const integer_coeff_t int_coeff, const linear_term <) -{ - return linear_combination(int_coeff) + lt; -} - -template -linear_combination operator+(const FieldT &field_coeff, const linear_term <) -{ - return linear_combination(field_coeff) + lt; -} - -template -linear_combination operator-(const integer_coeff_t int_coeff, const linear_term <) -{ - return linear_combination(int_coeff) - lt; -} - -template -linear_combination operator-(const FieldT &field_coeff, const linear_term <) -{ - return linear_combination(field_coeff) - lt; -} - -template -linear_combination linear_term::operator+(const linear_combination &other) const -{ - return linear_combination(*this) + other; -} - -template -linear_combination linear_term::operator-(const linear_combination &other) const -{ - return (*this) + (-other); -} - -template -linear_term linear_term::operator-() const -{ - return linear_term(this->index, -this->coeff); -} - -template -bool linear_term::operator==(const linear_term &other) const -{ - return (this->index == other.index && - this->coeff == other.coeff); -} - -template -linear_term operator*(const integer_coeff_t int_coeff, const linear_term <) -{ - return FieldT(int_coeff) * lt; -} - -template -linear_term operator*(const FieldT &field_coeff, const linear_term <) -{ - return linear_term(lt.index, field_coeff * lt.coeff); -} - -template -linear_combination::linear_combination(const integer_coeff_t int_coeff) -{ - this->add_term(linear_term(0, int_coeff)); -} - -template -linear_combination::linear_combination(const FieldT &field_coeff) -{ - this->add_term(linear_term(0, field_coeff)); -} - -template -linear_combination::linear_combination(const variable &var) -{ - this->add_term(var); -} - -template -linear_combination::linear_combination(const linear_term <) -{ - this->add_term(lt); -} - -template -typename std::vector >::const_iterator linear_combination::begin() const -{ - return terms.begin(); -} - -template -typename std::vector >::const_iterator linear_combination::end() const -{ - return terms.end(); -} - -template -void linear_combination::add_term(const variable &var) -{ - this->terms.emplace_back(linear_term(var.index, FieldT::one())); -} - -template -void linear_combination::add_term(const variable &var, const integer_coeff_t int_coeff) -{ - this->terms.emplace_back(linear_term(var.index, int_coeff)); -} - -template -void linear_combination::add_term(const variable &var, const FieldT &coeff) -{ - this->terms.emplace_back(linear_term(var.index, coeff)); -} - -template -void linear_combination::add_term(const linear_term &other) -{ - this->terms.emplace_back(other); -} - -template -linear_combination linear_combination::operator*(const integer_coeff_t int_coeff) const -{ - return (*this) * FieldT(int_coeff); -} - -template -FieldT linear_combination::evaluate(const std::vector &assignment) const -{ - FieldT acc = FieldT::zero(); - for (auto < : terms) - { - acc += (lt.index == 0 ? FieldT::one() : assignment[lt.index-1]) * lt.coeff; - } - return acc; -} - -template -linear_combination linear_combination::operator*(const FieldT &field_coeff) const -{ - linear_combination result; - result.terms.reserve(this->terms.size()); - for (const linear_term < : this->terms) - { - result.terms.emplace_back(lt * field_coeff); - } - return result; -} - -template -linear_combination linear_combination::operator+(const linear_combination &other) const -{ - linear_combination result; - - auto it1 = this->terms.begin(); - auto it2 = other.terms.begin(); - - /* invariant: it1 and it2 always point to unprocessed items in the corresponding linear combinations */ - while (it1 != this->terms.end() && it2 != other.terms.end()) - { - if (it1->index < it2->index) - { - result.terms.emplace_back(*it1); - ++it1; - } - else if (it1->index > it2->index) - { - result.terms.emplace_back(*it2); - ++it2; - } - else - { - /* it1->index == it2->index */ - result.terms.emplace_back(linear_term(variable(it1->index), it1->coeff + it2->coeff)); - ++it1; - ++it2; - } - } - - if (it1 != this->terms.end()) - { - result.terms.insert(result.terms.end(), it1, this->terms.end()); - } - else - { - result.terms.insert(result.terms.end(), it2, other.terms.end()); - } - - return result; -} - -template -linear_combination linear_combination::operator-(const linear_combination &other) const -{ - return (*this) + (-other); -} - -template -linear_combination linear_combination::operator-() const -{ - return (*this) * (-FieldT::one()); -} - -template -bool linear_combination::operator==(const linear_combination &other) const -{ - return (this->terms == other.terms); -} - -template -bool linear_combination::is_valid(const size_t num_variables) const -{ - /* check that all terms in linear combination are sorted */ - for (size_t i = 1; i < terms.size(); ++i) - { - if (terms[i-1].index >= terms[i].index) - { - return false; - } - } - - /* check that the variables are in proper range. as the variables - are sorted, it suffices to check the last term */ - if ((--terms.end())->index >= num_variables) - { - return false; - } - - return true; -} - -template -void linear_combination::print(const std::map &variable_annotations) const -{ - for (auto < : terms) - { - if (lt.index == 0) - { - printf(" 1 * "); - lt.coeff.print(); - } - else - { - auto it = variable_annotations.find(lt.index); - printf(" x_%zu (%s) * ", lt.index, (it == variable_annotations.end() ? "no annotation" : it->second.c_str())); - lt.coeff.print(); - } - } -} - -template -void linear_combination::print_with_assignment(const std::vector &full_assignment, const std::map &variable_annotations) const -{ - for (auto < : terms) - { - if (lt.index == 0) - { - printf(" 1 * "); - lt.coeff.print(); - } - else - { - printf(" x_%zu * ", lt.index); - lt.coeff.print(); - - auto it = variable_annotations.find(lt.index); - printf(" where x_%zu (%s) was assigned value ", lt.index, - (it == variable_annotations.end() ? "no annotation" : it->second.c_str())); - full_assignment[lt.index-1].print(); - printf(" i.e. negative of "); - (-full_assignment[lt.index-1]).print(); - } - } -} - -template -std::ostream& operator<<(std::ostream &out, const linear_combination &lc) -{ - out << lc.terms.size() << "\n"; - for (const linear_term& lt : lc.terms) - { - out << lt.index << "\n"; - out << lt.coeff << OUTPUT_NEWLINE; - } - - return out; -} - -template -std::istream& operator>>(std::istream &in, linear_combination &lc) -{ - lc.terms.clear(); - - size_t s; - in >> s; - - consume_newline(in); - - lc.terms.reserve(s); - - for (size_t i = 0; i < s; ++i) - { - linear_term lt; - in >> lt.index; - consume_newline(in); - in >> lt.coeff; - consume_OUTPUT_NEWLINE(in); - lc.terms.emplace_back(lt); - } - - return in; -} - -template -linear_combination operator*(const integer_coeff_t int_coeff, const linear_combination &lc) -{ - return lc * int_coeff; -} - -template -linear_combination operator*(const FieldT &field_coeff, const linear_combination &lc) -{ - return lc * field_coeff; -} - -template -linear_combination operator+(const integer_coeff_t int_coeff, const linear_combination &lc) -{ - return linear_combination(int_coeff) + lc; -} - -template -linear_combination operator+(const FieldT &field_coeff, const linear_combination &lc) -{ - return linear_combination(field_coeff) + lc; -} - -template -linear_combination operator-(const integer_coeff_t int_coeff, const linear_combination &lc) -{ - return linear_combination(int_coeff) - lc; -} - -template -linear_combination operator-(const FieldT &field_coeff, const linear_combination &lc) -{ - return linear_combination(field_coeff) - lc; -} - -template -linear_combination::linear_combination(const std::vector > &all_terms) -{ - if (all_terms.empty()) - { - return; - } - - terms = all_terms; - std::sort(terms.begin(), terms.end(), [](linear_term a, linear_term b) { return a.index < b.index; }); - - auto result_it = terms.begin(); - for (auto it = ++terms.begin(); it != terms.end(); ++it) - { - if (it->index == result_it->index) - { - result_it->coeff += it->coeff; - } - else - { - *(++result_it) = *it; - } - } - terms.resize((result_it - terms.begin()) + 1); -} - -} // libsnark - -#endif // VARIABLE_TCC diff --git a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.hpp b/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.hpp deleted file mode 100644 index fcd28abf3..000000000 --- a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of functionality that runs the R1CS ppzkSNARK for - a given R1CS example. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef RUN_R1CS_PPZKSNARK_HPP_ -#define RUN_R1CS_PPZKSNARK_HPP_ - -#include "relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.hpp" - -namespace libsnark { - -/** - * Runs the ppzkSNARK (generator, prover, and verifier) for a given - * R1CS example (specified by a constraint system, input, and witness). - * - * Optionally, also test the serialization routines for keys and proofs. - * (This takes additional time.) - */ -template -bool run_r1cs_ppzksnark(const r1cs_example > &example, - const bool test_serialization); - -} // libsnark - -#include "zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.tcc" - -#endif // RUN_R1CS_PPZKSNARK_HPP_ diff --git a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.tcc b/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.tcc deleted file mode 100644 index 00af6fe25..000000000 --- a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.tcc +++ /dev/null @@ -1,114 +0,0 @@ -/** @file - ***************************************************************************** - - Implementation of functionality that runs the R1CS ppzkSNARK for - a given R1CS example. - - See run_r1cs_ppzksnark.hpp . - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef RUN_R1CS_PPZKSNARK_TCC_ -#define RUN_R1CS_PPZKSNARK_TCC_ - -#include "zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.hpp" - -#include -#include - -#include "common/profiling.hpp" - -namespace libsnark { - -template -typename std::enable_if::type -test_affine_verifier(const r1cs_ppzksnark_verification_key &vk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_proof &proof, - const bool expected_answer) -{ - print_header("R1CS ppzkSNARK Affine Verifier"); - const bool answer = r1cs_ppzksnark_affine_verifier_weak_IC(vk, primary_input, proof); - assert(answer == expected_answer); -} - -template -typename std::enable_if::type -test_affine_verifier(const r1cs_ppzksnark_verification_key &vk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_proof &proof, - const bool expected_answer) -{ - UNUSED(vk, primary_input, proof, expected_answer); - print_header("R1CS ppzkSNARK Affine Verifier"); - printf("Affine verifier is not supported; not testing anything.\n"); -} - -/** - * The code below provides an example of all stages of running a R1CS ppzkSNARK. - * - * Of course, in a real-life scenario, we would have three distinct entities, - * mangled into one in the demonstration below. The three entities are as follows. - * (1) The "generator", which runs the ppzkSNARK generator on input a given - * constraint system CS to create a proving and a verification key for CS. - * (2) The "prover", which runs the ppzkSNARK prover on input the proving key, - * a primary input for CS, and an auxiliary input for CS. - * (3) The "verifier", which runs the ppzkSNARK verifier on input the verification key, - * a primary input for CS, and a proof. - */ -template -bool run_r1cs_ppzksnark(const r1cs_example > &example, - const bool test_serialization) -{ - enter_block("Call to run_r1cs_ppzksnark"); - - print_header("R1CS ppzkSNARK Generator"); - r1cs_ppzksnark_keypair keypair = r1cs_ppzksnark_generator(example.constraint_system); - printf("\n"); print_indent(); print_mem("after generator"); - - print_header("Preprocess verification key"); - r1cs_ppzksnark_processed_verification_key pvk = r1cs_ppzksnark_verifier_process_vk(keypair.vk); - - if (test_serialization) - { - enter_block("Test serialization of keys"); - keypair.pk = reserialize >(keypair.pk); - keypair.vk = reserialize >(keypair.vk); - pvk = reserialize >(pvk); - leave_block("Test serialization of keys"); - } - - print_header("R1CS ppzkSNARK Prover"); - r1cs_ppzksnark_proof proof = r1cs_ppzksnark_prover(keypair.pk, example.primary_input, example.auxiliary_input, example.constraint_system); - printf("\n"); print_indent(); print_mem("after prover"); - - if (test_serialization) - { - enter_block("Test serialization of proof"); - proof = reserialize >(proof); - leave_block("Test serialization of proof"); - } - - print_header("R1CS ppzkSNARK Verifier"); - const bool ans = r1cs_ppzksnark_verifier_strong_IC(keypair.vk, example.primary_input, proof); - printf("\n"); print_indent(); print_mem("after verifier"); - printf("* The verification result is: %s\n", (ans ? "PASS" : "FAIL")); - - print_header("R1CS ppzkSNARK Online Verifier"); - const bool ans2 = r1cs_ppzksnark_online_verifier_strong_IC(pvk, example.primary_input, proof); - assert(ans == ans2); - - test_affine_verifier(keypair.vk, example.primary_input, proof, ans); - - leave_block("Call to run_r1cs_ppzksnark"); - - return ans; -} - -} // libsnark - -#endif // RUN_R1CS_PPZKSNARK_TCC_ diff --git a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/profiling/profile_r1cs_ppzksnark.cpp b/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/profiling/profile_r1cs_ppzksnark.cpp deleted file mode 100644 index 5c5415028..000000000 --- a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/profiling/profile_r1cs_ppzksnark.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/** @file - ***************************************************************************** - Profiling program that exercises the ppzkSNARK (first generator, then prover, - then verifier) on a synthetic R1CS instance. - - The command - - $ src/zk_proof_systems/ppzksnark/r1cs_ppzksnark/profiling/profile_r1cs_ppzksnark 1000 10 Fr - - exercises the ppzkSNARK (first generator, then prover, then verifier) on an R1CS instance with 1000 equations and an input consisting of 10 field elements. - - (If you get the error `zmInit ERR:can't protect`, see the discussion [above](#elliptic-curve-choices).) - - The command - - $ src/zk_proof_systems/ppzksnark/r1cs_ppzksnark/profiling/profile_r1cs_ppzksnark 1000 10 bytes - - does the same but now the input consists of 10 bytes. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ -#include -#include - -#include "common/default_types/r1cs_ppzksnark_pp.hpp" -#include "common/profiling.hpp" -#include "common/utils.hpp" -#include "relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.hpp" -#include "zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.hpp" - -using namespace libsnark; - -int main(int argc, const char * argv[]) -{ - default_r1cs_ppzksnark_pp::init_public_params(); - start_profiling(); - - if (argc == 2 && strcmp(argv[1], "-v") == 0) - { - print_compilation_info(); - return 0; - } - - if (argc != 3 && argc != 4) - { - printf("usage: %s num_constraints input_size [Fr|bytes]\n", argv[0]); - return 1; - } - const int num_constraints = atoi(argv[1]); - int input_size = atoi(argv[2]); - if (argc == 4) - { - assert(strcmp(argv[3], "Fr") == 0 || strcmp(argv[3], "bytes") == 0); - if (strcmp(argv[3], "bytes") == 0) - { - input_size = div_ceil(8 * input_size, Fr::capacity()); - } - } - - enter_block("Generate R1CS example"); - r1cs_example > example = generate_r1cs_example_with_field_input >(num_constraints, input_size); - leave_block("Generate R1CS example"); - - print_header("(enter) Profile R1CS ppzkSNARK"); - const bool test_serialization = true; - run_r1cs_ppzksnark(example, test_serialization); - print_header("(leave) Profile R1CS ppzkSNARK"); -} diff --git a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.hpp b/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.hpp deleted file mode 100644 index 6095d6a08..000000000 --- a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.hpp +++ /dev/null @@ -1,486 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of interfaces for a ppzkSNARK for R1CS. - - This includes: - - class for proving key - - class for verification key - - class for processed verification key - - class for key pair (proving key & verification key) - - class for proof - - generator algorithm - - prover algorithm - - verifier algorithm (with strong or weak input consistency) - - online verifier algorithm (with strong or weak input consistency) - - The implementation instantiates (a modification of) the protocol of \[PGHR13], - by following extending, and optimizing the approach described in \[BCTV14]. - - - Acronyms: - - - R1CS = "Rank-1 Constraint Systems" - - ppzkSNARK = "PreProcessing Zero-Knowledge Succinct Non-interactive ARgument of Knowledge" - - References: - - \[BCTV14]: - "Succinct Non-Interactive Zero Knowledge for a von Neumann Architecture", - Eli Ben-Sasson, Alessandro Chiesa, Eran Tromer, Madars Virza, - USENIX Security 2014, - - - \[PGHR13]: - "Pinocchio: Nearly practical verifiable computation", - Bryan Parno, Craig Gentry, Jon Howell, Mariana Raykova, - IEEE S&P 2013, - - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef R1CS_PPZKSNARK_HPP_ -#define R1CS_PPZKSNARK_HPP_ - -#include - -#include "algebra/curves/public_params.hpp" -#include "common/data_structures/accumulation_vector.hpp" -#include "algebra/knowledge_commitment/knowledge_commitment.hpp" -#include "relations/constraint_satisfaction_problems/r1cs/r1cs.hpp" -#include "zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark_params.hpp" - -namespace libsnark { - -/******************************** Proving key ********************************/ - -template -class r1cs_ppzksnark_proving_key; - -template -std::ostream& operator<<(std::ostream &out, const r1cs_ppzksnark_proving_key &pk); - -template -std::istream& operator>>(std::istream &in, r1cs_ppzksnark_proving_key &pk); - -/** - * A proving key for the R1CS ppzkSNARK. - */ -template -class r1cs_ppzksnark_proving_key { -public: - knowledge_commitment_vector, G1 > A_query; - knowledge_commitment_vector, G1 > B_query; - knowledge_commitment_vector, G1 > C_query; - G1_vector H_query; - G1_vector K_query; - - r1cs_ppzksnark_proving_key() {}; - r1cs_ppzksnark_proving_key& operator=(const r1cs_ppzksnark_proving_key &other) = default; - r1cs_ppzksnark_proving_key(const r1cs_ppzksnark_proving_key &other) = default; - r1cs_ppzksnark_proving_key(r1cs_ppzksnark_proving_key &&other) = default; - r1cs_ppzksnark_proving_key(knowledge_commitment_vector, G1 > &&A_query, - knowledge_commitment_vector, G1 > &&B_query, - knowledge_commitment_vector, G1 > &&C_query, - G1_vector &&H_query, - G1_vector &&K_query) : - A_query(std::move(A_query)), - B_query(std::move(B_query)), - C_query(std::move(C_query)), - H_query(std::move(H_query)), - K_query(std::move(K_query)) - {}; - - size_t G1_size() const - { - return 2*(A_query.domain_size() + C_query.domain_size()) + B_query.domain_size() + H_query.size() + K_query.size(); - } - - size_t G2_size() const - { - return B_query.domain_size(); - } - - size_t G1_sparse_size() const - { - return 2*(A_query.size() + C_query.size()) + B_query.size() + H_query.size() + K_query.size(); - } - - size_t G2_sparse_size() const - { - return B_query.size(); - } - - size_t size_in_bits() const - { - return A_query.size_in_bits() + B_query.size_in_bits() + C_query.size_in_bits() + libsnark::size_in_bits(H_query) + libsnark::size_in_bits(K_query); - } - - void print_size() const - { - print_indent(); printf("* G1 elements in PK: %zu\n", this->G1_size()); - print_indent(); printf("* Non-zero G1 elements in PK: %zu\n", this->G1_sparse_size()); - print_indent(); printf("* G2 elements in PK: %zu\n", this->G2_size()); - print_indent(); printf("* Non-zero G2 elements in PK: %zu\n", this->G2_sparse_size()); - print_indent(); printf("* PK size in bits: %zu\n", this->size_in_bits()); - } - - bool operator==(const r1cs_ppzksnark_proving_key &other) const; - friend std::ostream& operator<< (std::ostream &out, const r1cs_ppzksnark_proving_key &pk); - friend std::istream& operator>> (std::istream &in, r1cs_ppzksnark_proving_key &pk); -}; - - -/******************************* Verification key ****************************/ - -template -class r1cs_ppzksnark_verification_key; - -template -std::ostream& operator<<(std::ostream &out, const r1cs_ppzksnark_verification_key &vk); - -template -std::istream& operator>>(std::istream &in, r1cs_ppzksnark_verification_key &vk); - -/** - * A verification key for the R1CS ppzkSNARK. - */ -template -class r1cs_ppzksnark_verification_key { -public: - G2 alphaA_g2; - G1 alphaB_g1; - G2 alphaC_g2; - G2 gamma_g2; - G1 gamma_beta_g1; - G2 gamma_beta_g2; - G2 rC_Z_g2; - - accumulation_vector > encoded_IC_query; - - r1cs_ppzksnark_verification_key() = default; - r1cs_ppzksnark_verification_key(const G2 &alphaA_g2, - const G1 &alphaB_g1, - const G2 &alphaC_g2, - const G2 &gamma_g2, - const G1 &gamma_beta_g1, - const G2 &gamma_beta_g2, - const G2 &rC_Z_g2, - const accumulation_vector > &eIC) : - alphaA_g2(alphaA_g2), - alphaB_g1(alphaB_g1), - alphaC_g2(alphaC_g2), - gamma_g2(gamma_g2), - gamma_beta_g1(gamma_beta_g1), - gamma_beta_g2(gamma_beta_g2), - rC_Z_g2(rC_Z_g2), - encoded_IC_query(eIC) - {}; - - size_t G1_size() const - { - return 2 + encoded_IC_query.size(); - } - - size_t G2_size() const - { - return 5; - } - - size_t size_in_bits() const - { - return (2 * G1::size_in_bits() + encoded_IC_query.size_in_bits() + 5 * G2::size_in_bits()); - } - - void print_size() const - { - print_indent(); printf("* G1 elements in VK: %zu\n", this->G1_size()); - print_indent(); printf("* G2 elements in VK: %zu\n", this->G2_size()); - print_indent(); printf("* VK size in bits: %zu\n", this->size_in_bits()); - } - - bool operator==(const r1cs_ppzksnark_verification_key &other) const; - friend std::ostream& operator<< (std::ostream &out, const r1cs_ppzksnark_verification_key &vk); - friend std::istream& operator>> (std::istream &in, r1cs_ppzksnark_verification_key &vk); - - static r1cs_ppzksnark_verification_key dummy_verification_key(const size_t input_size); -}; - - -/************************ Processed verification key *************************/ - -template -class r1cs_ppzksnark_processed_verification_key; - -template -std::ostream& operator<<(std::ostream &out, const r1cs_ppzksnark_processed_verification_key &pvk); - -template -std::istream& operator>>(std::istream &in, r1cs_ppzksnark_processed_verification_key &pvk); - -/** - * A processed verification key for the R1CS ppzkSNARK. - * - * Compared to a (non-processed) verification key, a processed verification key - * contains a small constant amount of additional pre-computed information that - * enables a faster verification time. - */ -template -class r1cs_ppzksnark_processed_verification_key { -public: - G2_precomp pp_G2_one_precomp; - G2_precomp vk_alphaA_g2_precomp; - G1_precomp vk_alphaB_g1_precomp; - G2_precomp vk_alphaC_g2_precomp; - G2_precomp vk_rC_Z_g2_precomp; - G2_precomp vk_gamma_g2_precomp; - G1_precomp vk_gamma_beta_g1_precomp; - G2_precomp vk_gamma_beta_g2_precomp; - - accumulation_vector > encoded_IC_query; - - bool operator==(const r1cs_ppzksnark_processed_verification_key &other) const; - friend std::ostream& operator<< (std::ostream &out, const r1cs_ppzksnark_processed_verification_key &pvk); - friend std::istream& operator>> (std::istream &in, r1cs_ppzksnark_processed_verification_key &pvk); -}; - - -/********************************** Key pair *********************************/ - -/** - * A key pair for the R1CS ppzkSNARK, which consists of a proving key and a verification key. - */ -template -class r1cs_ppzksnark_keypair { -public: - r1cs_ppzksnark_proving_key pk; - r1cs_ppzksnark_verification_key vk; - - r1cs_ppzksnark_keypair() = default; - r1cs_ppzksnark_keypair(const r1cs_ppzksnark_keypair &other) = default; - r1cs_ppzksnark_keypair(r1cs_ppzksnark_proving_key &&pk, - r1cs_ppzksnark_verification_key &&vk) : - pk(std::move(pk)), - vk(std::move(vk)) - {} - - r1cs_ppzksnark_keypair(r1cs_ppzksnark_keypair &&other) = default; -}; - - -/*********************************** Proof ***********************************/ - -template -class r1cs_ppzksnark_proof; - -template -std::ostream& operator<<(std::ostream &out, const r1cs_ppzksnark_proof &proof); - -template -std::istream& operator>>(std::istream &in, r1cs_ppzksnark_proof &proof); - -/** - * A proof for the R1CS ppzkSNARK. - * - * While the proof has a structure, externally one merely opaquely produces, - * serializes/deserializes, and verifies proofs. We only expose some information - * about the structure for statistics purposes. - */ -template -class r1cs_ppzksnark_proof { -public: - knowledge_commitment, G1 > g_A; - knowledge_commitment, G1 > g_B; - knowledge_commitment, G1 > g_C; - G1 g_H; - G1 g_K; - - r1cs_ppzksnark_proof() - { - // invalid proof with valid curve points - this->g_A.g = G1 ::one(); - this->g_A.h = G1::one(); - this->g_B.g = G2 ::one(); - this->g_B.h = G1::one(); - this->g_C.g = G1 ::one(); - this->g_C.h = G1::one(); - this->g_H = G1::one(); - this->g_K = G1::one(); - } - r1cs_ppzksnark_proof(knowledge_commitment, G1 > &&g_A, - knowledge_commitment, G1 > &&g_B, - knowledge_commitment, G1 > &&g_C, - G1 &&g_H, - G1 &&g_K) : - g_A(std::move(g_A)), - g_B(std::move(g_B)), - g_C(std::move(g_C)), - g_H(std::move(g_H)), - g_K(std::move(g_K)) - {}; - - size_t G1_size() const - { - return 7; - } - - size_t G2_size() const - { - return 1; - } - - size_t size_in_bits() const - { - return G1_size() * G1::size_in_bits() + G2_size() * G2::size_in_bits(); - } - - void print_size() const - { - print_indent(); printf("* G1 elements in proof: %zu\n", this->G1_size()); - print_indent(); printf("* G2 elements in proof: %zu\n", this->G2_size()); - print_indent(); printf("* Proof size in bits: %zu\n", this->size_in_bits()); - } - - bool is_well_formed() const - { - return (g_A.g.is_well_formed() && g_A.h.is_well_formed() && - g_B.g.is_well_formed() && g_B.h.is_well_formed() && - g_C.g.is_well_formed() && g_C.h.is_well_formed() && - g_H.is_well_formed() && - g_K.is_well_formed()); - } - - bool operator==(const r1cs_ppzksnark_proof &other) const; - friend std::ostream& operator<< (std::ostream &out, const r1cs_ppzksnark_proof &proof); - friend std::istream& operator>> (std::istream &in, r1cs_ppzksnark_proof &proof); -}; - - -/***************************** Main algorithms *******************************/ - -/** - * A generator algorithm for the R1CS ppzkSNARK. - * - * Given a R1CS constraint system CS, this algorithm produces proving and verification keys for CS. - */ -template -r1cs_ppzksnark_keypair r1cs_ppzksnark_generator(const r1cs_ppzksnark_constraint_system &cs); - -template -r1cs_ppzksnark_keypair r1cs_ppzksnark_generator( - const r1cs_ppzksnark_constraint_system &cs, - const Fr& t, - const Fr& alphaA, - const Fr& alphaB, - const Fr& alphaC, - const Fr& rA, - const Fr& rB, - const Fr& beta, - const Fr& gamma -); - -/** - * A prover algorithm for the R1CS ppzkSNARK. - * - * Given a R1CS primary input X and a R1CS auxiliary input Y, this algorithm - * produces a proof (of knowledge) that attests to the following statement: - * ``there exists Y such that CS(X,Y)=0''. - * Above, CS is the R1CS constraint system that was given as input to the generator algorithm. - */ -template -r1cs_ppzksnark_proof r1cs_ppzksnark_prover(const r1cs_ppzksnark_proving_key &pk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_auxiliary_input &auxiliary_input, - const r1cs_ppzksnark_constraint_system &constraint_system); - -template -r1cs_ppzksnark_proof r1cs_ppzksnark_prover_streaming(std::ifstream &proving_key_file, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_auxiliary_input &auxiliary_input, - const r1cs_ppzksnark_constraint_system &constraint_system); - -/* - Below are four variants of verifier algorithm for the R1CS ppzkSNARK. - - These are the four cases that arise from the following two choices: - - (1) The verifier accepts a (non-processed) verification key or, instead, a processed verification key. - In the latter case, we call the algorithm an "online verifier". - - (2) The verifier checks for "weak" input consistency or, instead, "strong" input consistency. - Strong input consistency requires that |primary_input| = CS.num_inputs, whereas - weak input consistency requires that |primary_input| <= CS.num_inputs (and - the primary input is implicitly padded with zeros up to length CS.num_inputs). - */ - -/** - * A verifier algorithm for the R1CS ppzkSNARK that: - * (1) accepts a non-processed verification key, and - * (2) has weak input consistency. - */ -template -bool r1cs_ppzksnark_verifier_weak_IC(const r1cs_ppzksnark_verification_key &vk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_proof &proof); - -/** - * A verifier algorithm for the R1CS ppzkSNARK that: - * (1) accepts a non-processed verification key, and - * (2) has strong input consistency. - */ -template -bool r1cs_ppzksnark_verifier_strong_IC(const r1cs_ppzksnark_verification_key &vk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_proof &proof); - -/** - * Convert a (non-processed) verification key into a processed verification key. - */ -template -r1cs_ppzksnark_processed_verification_key r1cs_ppzksnark_verifier_process_vk(const r1cs_ppzksnark_verification_key &vk); - -/** - * A verifier algorithm for the R1CS ppzkSNARK that: - * (1) accepts a processed verification key, and - * (2) has weak input consistency. - */ -template -bool r1cs_ppzksnark_online_verifier_weak_IC(const r1cs_ppzksnark_processed_verification_key &pvk, - const r1cs_ppzksnark_primary_input &input, - const r1cs_ppzksnark_proof &proof); - -/** - * A verifier algorithm for the R1CS ppzkSNARK that: - * (1) accepts a processed verification key, and - * (2) has strong input consistency. - */ -template -bool r1cs_ppzksnark_online_verifier_strong_IC(const r1cs_ppzksnark_processed_verification_key &pvk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_proof &proof); - -/****************************** Miscellaneous ********************************/ - -/** - * For debugging purposes (of r1cs_ppzksnark_r1cs_ppzksnark_verifier_gadget): - * - * A verifier algorithm for the R1CS ppzkSNARK that: - * (1) accepts a non-processed verification key, - * (2) has weak input consistency, and - * (3) uses affine coordinates for elliptic-curve computations. - */ -template -bool r1cs_ppzksnark_affine_verifier_weak_IC(const r1cs_ppzksnark_verification_key &vk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_proof &proof); - - -} // libsnark - -#include "zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc" - -#endif // R1CS_PPZKSNARK_HPP_ diff --git a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc b/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc deleted file mode 100644 index 9cc392e53..000000000 --- a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc +++ /dev/null @@ -1,886 +0,0 @@ -/** @file -***************************************************************************** - -Implementation of interfaces for a ppzkSNARK for R1CS. - -See r1cs_ppzksnark.hpp . - -***************************************************************************** -* @author This file is part of libsnark, developed by SCIPR Lab -* and contributors (see AUTHORS). -* @copyright MIT license (see LICENSE file) -*****************************************************************************/ - -#ifndef R1CS_PPZKSNARK_TCC_ -#define R1CS_PPZKSNARK_TCC_ - -#include -#include -#include -#include -#include - -#include "common/profiling.hpp" -#include "common/utils.hpp" -#include "algebra/scalar_multiplication/multiexp.hpp" -#include "algebra/scalar_multiplication/kc_multiexp.hpp" -#include "reductions/r1cs_to_qap/r1cs_to_qap.hpp" - -namespace libsnark { - -template -bool r1cs_ppzksnark_proving_key::operator==(const r1cs_ppzksnark_proving_key &other) const -{ - return (this->A_query == other.A_query && - this->B_query == other.B_query && - this->C_query == other.C_query && - this->H_query == other.H_query && - this->K_query == other.K_query); -} - -template -std::ostream& operator<<(std::ostream &out, const r1cs_ppzksnark_proving_key &pk) -{ - out << pk.A_query; - out << pk.B_query; - out << pk.C_query; - out << pk.H_query; - out << pk.K_query; - - return out; -} - -template -std::istream& operator>>(std::istream &in, r1cs_ppzksnark_proving_key &pk) -{ - in >> pk.A_query; - in >> pk.B_query; - in >> pk.C_query; - in >> pk.H_query; - in >> pk.K_query; - - return in; -} - -template -bool r1cs_ppzksnark_verification_key::operator==(const r1cs_ppzksnark_verification_key &other) const -{ - return (this->alphaA_g2 == other.alphaA_g2 && - this->alphaB_g1 == other.alphaB_g1 && - this->alphaC_g2 == other.alphaC_g2 && - this->gamma_g2 == other.gamma_g2 && - this->gamma_beta_g1 == other.gamma_beta_g1 && - this->gamma_beta_g2 == other.gamma_beta_g2 && - this->rC_Z_g2 == other.rC_Z_g2 && - this->encoded_IC_query == other.encoded_IC_query); -} - -template -std::ostream& operator<<(std::ostream &out, const r1cs_ppzksnark_verification_key &vk) -{ - out << vk.alphaA_g2 << OUTPUT_NEWLINE; - out << vk.alphaB_g1 << OUTPUT_NEWLINE; - out << vk.alphaC_g2 << OUTPUT_NEWLINE; - out << vk.gamma_g2 << OUTPUT_NEWLINE; - out << vk.gamma_beta_g1 << OUTPUT_NEWLINE; - out << vk.gamma_beta_g2 << OUTPUT_NEWLINE; - out << vk.rC_Z_g2 << OUTPUT_NEWLINE; - out << vk.encoded_IC_query << OUTPUT_NEWLINE; - - return out; -} - -template -std::istream& operator>>(std::istream &in, r1cs_ppzksnark_verification_key &vk) -{ - in >> vk.alphaA_g2; - consume_OUTPUT_NEWLINE(in); - in >> vk.alphaB_g1; - consume_OUTPUT_NEWLINE(in); - in >> vk.alphaC_g2; - consume_OUTPUT_NEWLINE(in); - in >> vk.gamma_g2; - consume_OUTPUT_NEWLINE(in); - in >> vk.gamma_beta_g1; - consume_OUTPUT_NEWLINE(in); - in >> vk.gamma_beta_g2; - consume_OUTPUT_NEWLINE(in); - in >> vk.rC_Z_g2; - consume_OUTPUT_NEWLINE(in); - in >> vk.encoded_IC_query; - consume_OUTPUT_NEWLINE(in); - - return in; -} - -template -bool r1cs_ppzksnark_processed_verification_key::operator==(const r1cs_ppzksnark_processed_verification_key &other) const -{ - return (this->pp_G2_one_precomp == other.pp_G2_one_precomp && - this->vk_alphaA_g2_precomp == other.vk_alphaA_g2_precomp && - this->vk_alphaB_g1_precomp == other.vk_alphaB_g1_precomp && - this->vk_alphaC_g2_precomp == other.vk_alphaC_g2_precomp && - this->vk_rC_Z_g2_precomp == other.vk_rC_Z_g2_precomp && - this->vk_gamma_g2_precomp == other.vk_gamma_g2_precomp && - this->vk_gamma_beta_g1_precomp == other.vk_gamma_beta_g1_precomp && - this->vk_gamma_beta_g2_precomp == other.vk_gamma_beta_g2_precomp && - this->encoded_IC_query == other.encoded_IC_query); -} - -template -std::ostream& operator<<(std::ostream &out, const r1cs_ppzksnark_processed_verification_key &pvk) -{ - out << pvk.pp_G2_one_precomp << OUTPUT_NEWLINE; - out << pvk.vk_alphaA_g2_precomp << OUTPUT_NEWLINE; - out << pvk.vk_alphaB_g1_precomp << OUTPUT_NEWLINE; - out << pvk.vk_alphaC_g2_precomp << OUTPUT_NEWLINE; - out << pvk.vk_rC_Z_g2_precomp << OUTPUT_NEWLINE; - out << pvk.vk_gamma_g2_precomp << OUTPUT_NEWLINE; - out << pvk.vk_gamma_beta_g1_precomp << OUTPUT_NEWLINE; - out << pvk.vk_gamma_beta_g2_precomp << OUTPUT_NEWLINE; - out << pvk.encoded_IC_query << OUTPUT_NEWLINE; - - return out; -} - -template -std::istream& operator>>(std::istream &in, r1cs_ppzksnark_processed_verification_key &pvk) -{ - in >> pvk.pp_G2_one_precomp; - consume_OUTPUT_NEWLINE(in); - in >> pvk.vk_alphaA_g2_precomp; - consume_OUTPUT_NEWLINE(in); - in >> pvk.vk_alphaB_g1_precomp; - consume_OUTPUT_NEWLINE(in); - in >> pvk.vk_alphaC_g2_precomp; - consume_OUTPUT_NEWLINE(in); - in >> pvk.vk_rC_Z_g2_precomp; - consume_OUTPUT_NEWLINE(in); - in >> pvk.vk_gamma_g2_precomp; - consume_OUTPUT_NEWLINE(in); - in >> pvk.vk_gamma_beta_g1_precomp; - consume_OUTPUT_NEWLINE(in); - in >> pvk.vk_gamma_beta_g2_precomp; - consume_OUTPUT_NEWLINE(in); - in >> pvk.encoded_IC_query; - consume_OUTPUT_NEWLINE(in); - - return in; -} - -template -bool r1cs_ppzksnark_proof::operator==(const r1cs_ppzksnark_proof &other) const -{ - return (this->g_A == other.g_A && - this->g_B == other.g_B && - this->g_C == other.g_C && - this->g_H == other.g_H && - this->g_K == other.g_K); -} - -template -std::ostream& operator<<(std::ostream &out, const r1cs_ppzksnark_proof &proof) -{ - out << proof.g_A << OUTPUT_NEWLINE; - out << proof.g_B << OUTPUT_NEWLINE; - out << proof.g_C << OUTPUT_NEWLINE; - out << proof.g_H << OUTPUT_NEWLINE; - out << proof.g_K << OUTPUT_NEWLINE; - - return out; -} - -template -std::istream& operator>>(std::istream &in, r1cs_ppzksnark_proof &proof) -{ - in >> proof.g_A; - consume_OUTPUT_NEWLINE(in); - in >> proof.g_B; - consume_OUTPUT_NEWLINE(in); - in >> proof.g_C; - consume_OUTPUT_NEWLINE(in); - in >> proof.g_H; - consume_OUTPUT_NEWLINE(in); - in >> proof.g_K; - consume_OUTPUT_NEWLINE(in); - - return in; -} - -template -r1cs_ppzksnark_verification_key r1cs_ppzksnark_verification_key::dummy_verification_key(const size_t input_size) -{ - r1cs_ppzksnark_verification_key result; - result.alphaA_g2 = Fr::random_element() * G2::one(); - result.alphaB_g1 = Fr::random_element() * G1::one(); - result.alphaC_g2 = Fr::random_element() * G2::one(); - result.gamma_g2 = Fr::random_element() * G2::one(); - result.gamma_beta_g1 = Fr::random_element() * G1::one(); - result.gamma_beta_g2 = Fr::random_element() * G2::one(); - result.rC_Z_g2 = Fr::random_element() * G2::one(); - - G1 base = Fr::random_element() * G1::one(); - G1_vector v; - for (size_t i = 0; i < input_size; ++i) - { - v.emplace_back(Fr::random_element() * G1::one()); - } - - result.encoded_IC_query = accumulation_vector >(std::move(base), std::move(v)); - - return result; -} - -template -r1cs_ppzksnark_keypair r1cs_ppzksnark_generator(const r1cs_ppzksnark_constraint_system &cs) -{ - /* draw random element at which the QAP is evaluated */ - const Fr t = Fr::random_element(); - - const Fr alphaA = Fr::random_element(), - alphaB = Fr::random_element(), - alphaC = Fr::random_element(), - rA = Fr::random_element(), - rB = Fr::random_element(), - beta = Fr::random_element(), - gamma = Fr::random_element(); - - return r1cs_ppzksnark_generator(cs, t, alphaA, alphaB, alphaC, rA, rB, beta, gamma); -} - -template -r1cs_ppzksnark_keypair r1cs_ppzksnark_generator( - const r1cs_ppzksnark_constraint_system &cs, - const Fr& t, - const Fr& alphaA, - const Fr& alphaB, - const Fr& alphaC, - const Fr& rA, - const Fr& rB, - const Fr& beta, - const Fr& gamma -) -{ - enter_block("Call to r1cs_ppzksnark_generator"); - - /* make the B_query "lighter" if possible */ - r1cs_ppzksnark_constraint_system cs_copy(cs); - cs_copy.swap_AB_if_beneficial(); - - qap_instance_evaluation > qap_inst = r1cs_to_qap_instance_map_with_evaluation(cs_copy, t); - - print_indent(); printf("* QAP number of variables: %zu\n", qap_inst.num_variables()); - print_indent(); printf("* QAP pre degree: %zu\n", cs_copy.constraints.size()); - print_indent(); printf("* QAP degree: %zu\n", qap_inst.degree()); - print_indent(); printf("* QAP number of input variables: %zu\n", qap_inst.num_inputs()); - - enter_block("Compute query densities"); - size_t non_zero_At = 0, non_zero_Bt = 0, non_zero_Ct = 0, non_zero_Ht = 0; - for (size_t i = 0; i < qap_inst.num_variables()+1; ++i) - { - if (!qap_inst.At[i].is_zero()) - { - ++non_zero_At; - } - if (!qap_inst.Bt[i].is_zero()) - { - ++non_zero_Bt; - } - if (!qap_inst.Ct[i].is_zero()) - { - ++non_zero_Ct; - } - } - for (size_t i = 0; i < qap_inst.degree()+1; ++i) - { - if (!qap_inst.Ht[i].is_zero()) - { - ++non_zero_Ht; - } - } - leave_block("Compute query densities"); - - Fr_vector At = std::move(qap_inst.At); // qap_inst.At is now in unspecified state, but we do not use it later - Fr_vector Bt = std::move(qap_inst.Bt); // qap_inst.Bt is now in unspecified state, but we do not use it later - Fr_vector Ct = std::move(qap_inst.Ct); // qap_inst.Ct is now in unspecified state, but we do not use it later - Fr_vector Ht = std::move(qap_inst.Ht); // qap_inst.Ht is now in unspecified state, but we do not use it later - - /* append Zt to At,Bt,Ct with */ - At.emplace_back(qap_inst.Zt); - Bt.emplace_back(qap_inst.Zt); - Ct.emplace_back(qap_inst.Zt); - - const Fr rC = rA * rB; - - // construct the same-coefficient-check query (must happen before zeroing out the prefix of At) - Fr_vector Kt; - Kt.reserve(qap_inst.num_variables()+4); - for (size_t i = 0; i < qap_inst.num_variables()+1; ++i) - { - Kt.emplace_back( beta * (rA * At[i] + rB * Bt[i] + rC * Ct[i] ) ); - } - Kt.emplace_back(beta * rA * qap_inst.Zt); - Kt.emplace_back(beta * rB * qap_inst.Zt); - Kt.emplace_back(beta * rC * qap_inst.Zt); - - /* zero out prefix of At and stick it into IC coefficients */ - Fr_vector IC_coefficients; - IC_coefficients.reserve(qap_inst.num_inputs() + 1); - for (size_t i = 0; i < qap_inst.num_inputs() + 1; ++i) - { - IC_coefficients.emplace_back(At[i]); - assert(!IC_coefficients[i].is_zero()); - At[i] = Fr::zero(); - } - - const size_t g1_exp_count = 2*(non_zero_At - qap_inst.num_inputs() + non_zero_Ct) + non_zero_Bt + non_zero_Ht + Kt.size(); - const size_t g2_exp_count = non_zero_Bt; - - size_t g1_window = get_exp_window_size >(g1_exp_count); - size_t g2_window = get_exp_window_size >(g2_exp_count); - print_indent(); printf("* G1 window: %zu\n", g1_window); - print_indent(); printf("* G2 window: %zu\n", g2_window); - -#ifdef MULTICORE - const size_t chunks = omp_get_max_threads(); // to override, set OMP_NUM_THREADS env var or call omp_set_num_threads() -#else - const size_t chunks = 1; -#endif - - enter_block("Generating G1 multiexp table"); - window_table > g1_table = get_window_table(Fr::size_in_bits(), g1_window, G1::one()); - leave_block("Generating G1 multiexp table"); - - enter_block("Generating G2 multiexp table"); - window_table > g2_table = get_window_table(Fr::size_in_bits(), g2_window, G2::one()); - leave_block("Generating G2 multiexp table"); - - enter_block("Generate R1CS proving key"); - - enter_block("Generate knowledge commitments"); - enter_block("Compute the A-query", false); - knowledge_commitment_vector, G1 > A_query = kc_batch_exp(Fr::size_in_bits(), g1_window, g1_window, g1_table, g1_table, rA, rA*alphaA, At, chunks); - leave_block("Compute the A-query", false); - - enter_block("Compute the B-query", false); - knowledge_commitment_vector, G1 > B_query = kc_batch_exp(Fr::size_in_bits(), g2_window, g1_window, g2_table, g1_table, rB, rB*alphaB, Bt, chunks); - leave_block("Compute the B-query", false); - - enter_block("Compute the C-query", false); - knowledge_commitment_vector, G1 > C_query = kc_batch_exp(Fr::size_in_bits(), g1_window, g1_window, g1_table, g1_table, rC, rC*alphaC, Ct, chunks); - leave_block("Compute the C-query", false); - - enter_block("Compute the H-query", false); - G1_vector H_query = batch_exp(Fr::size_in_bits(), g1_window, g1_table, Ht); - leave_block("Compute the H-query", false); - - enter_block("Compute the K-query", false); - G1_vector K_query = batch_exp(Fr::size_in_bits(), g1_window, g1_table, Kt); -#ifdef USE_MIXED_ADDITION - batch_to_special >(K_query); -#endif - leave_block("Compute the K-query", false); - - leave_block("Generate knowledge commitments"); - - leave_block("Generate R1CS proving key"); - - enter_block("Generate R1CS verification key"); - G2 alphaA_g2 = alphaA * G2::one(); - G1 alphaB_g1 = alphaB * G1::one(); - G2 alphaC_g2 = alphaC * G2::one(); - G2 gamma_g2 = gamma * G2::one(); - G1 gamma_beta_g1 = (gamma * beta) * G1::one(); - G2 gamma_beta_g2 = (gamma * beta) * G2::one(); - G2 rC_Z_g2 = (rC * qap_inst.Zt) * G2::one(); - - enter_block("Encode IC query for R1CS verification key"); - G1 encoded_IC_base = (rA * IC_coefficients[0]) * G1::one(); - Fr_vector multiplied_IC_coefficients; - multiplied_IC_coefficients.reserve(qap_inst.num_inputs()); - for (size_t i = 1; i < qap_inst.num_inputs() + 1; ++i) - { - multiplied_IC_coefficients.emplace_back(rA * IC_coefficients[i]); - } - G1_vector encoded_IC_values = batch_exp(Fr::size_in_bits(), g1_window, g1_table, multiplied_IC_coefficients); - - leave_block("Encode IC query for R1CS verification key"); - leave_block("Generate R1CS verification key"); - - leave_block("Call to r1cs_ppzksnark_generator"); - - accumulation_vector > encoded_IC_query(std::move(encoded_IC_base), std::move(encoded_IC_values)); - - r1cs_ppzksnark_verification_key vk = r1cs_ppzksnark_verification_key(alphaA_g2, - alphaB_g1, - alphaC_g2, - gamma_g2, - gamma_beta_g1, - gamma_beta_g2, - rC_Z_g2, - encoded_IC_query); - r1cs_ppzksnark_proving_key pk = r1cs_ppzksnark_proving_key(std::move(A_query), - std::move(B_query), - std::move(C_query), - std::move(H_query), - std::move(K_query)); - - pk.print_size(); - vk.print_size(); - - return r1cs_ppzksnark_keypair(std::move(pk), std::move(vk)); -} - -template -knowledge_commitment r1cs_compute_proof_kc(const qap_witness > &qap_wit, - const knowledge_commitment_vector &kcv, - const Fr &zk_shift) -{ - knowledge_commitment returnval = kcv[0] + (zk_shift * kcv[qap_wit.num_variables()+1]); - -#ifdef DEBUG - assert(kcv.domain_size() == qap_wit.num_variables()+2); -#endif - -#ifdef MULTICORE - const size_t chunks = omp_get_max_threads(); // to override, set OMP_NUM_THREADS env var or call omp_set_num_threads() -#else - const size_t chunks = 1; -#endif - - returnval = returnval + kc_multi_exp_with_mixed_addition >( - kcv, - 1, - 1 + qap_wit.num_variables(), - qap_wit.coefficients_for_ABCs.begin(), - qap_wit.coefficients_for_ABCs.begin()+qap_wit.num_variables(), - chunks, - true - ); - - return returnval; -} - - - -template -G1 r1cs_compute_proof_K(const qap_witness> &qap_wit, const G1_vector &K_query, const G1 &zk_shift) -{ -#ifdef DEBUG - assert(K_query.size() == qap_wit.num_variables()+4); -#endif - -#ifdef MULTICORE - const size_t chunks = omp_get_max_threads(); // to override, set OMP_NUM_THREADS env var or call omp_set_num_threads() -#else - const size_t chunks = 1; -#endif - - G1 g_K = K_query[0] + zk_shift; - g_K = g_K + multi_exp_with_mixed_addition, Fr >( - K_query.begin()+1, - K_query.begin()+1+qap_wit.num_variables(), - qap_wit.coefficients_for_ABCs.begin(), - qap_wit.coefficients_for_ABCs.begin()+qap_wit.num_variables(), - chunks, - true - ); - - return g_K; -} - - -template -G1 r1cs_compute_proof_H(const qap_witness > &qap_wit, const G1_vector &H_query) -{ - G1 g_H = G1::zero(); - -#ifdef DEBUG - assert(H_query.size() == qap_wit.degree()+1); -#endif - -#ifdef MULTICORE - const size_t chunks = omp_get_max_threads(); // to override, set OMP_NUM_THREADS env var or call omp_set_num_threads() -#else - const size_t chunks = 1; -#endif - - g_H = g_H + multi_exp, Fr >( - H_query.begin(), - H_query.begin()+qap_wit.degree()+1, - qap_wit.coefficients_for_H.begin(), - qap_wit.coefficients_for_H.begin()+qap_wit.degree()+1, - chunks, - true - ); - - return g_H; -} - -template -r1cs_ppzksnark_proof r1cs_ppzksnark_prover(const r1cs_ppzksnark_proving_key &pk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_auxiliary_input &auxiliary_input, - const r1cs_ppzksnark_constraint_system &constraint_system) -{ - enter_block("Call to r1cs_ppzksnark_prover"); - -#ifdef DEBUG - assert(constraint_system.is_satisfied(primary_input, auxiliary_input)); -#endif - - const Fr d1 = Fr::random_element(), - d2 = Fr::random_element(), - d3 = Fr::random_element(); - - enter_block("Compute the polynomial H"); - const qap_witness > qap_wit = r1cs_to_qap_witness_map(constraint_system, primary_input, auxiliary_input, d1, d2, d3); - leave_block("Compute the polynomial H"); - -#ifdef DEBUG - const Fr t = Fr::random_element(); - qap_instance_evaluation > qap_inst = r1cs_to_qap_instance_map_with_evaluation(constraint_system, t); - assert(qap_inst.is_satisfied(qap_wit)); -#endif - -#ifdef DEBUG - for (size_t i = 0; i < qap_wit.num_inputs() + 1; ++i) - { - assert(pk.A_query[i].g == G1::zero()); - } -#endif - - enter_block("Compute the proof"); - - enter_block("Compute answer to A-query", false); - auto g_A = r1cs_compute_proof_kc, G1 >(qap_wit, pk.A_query, qap_wit.d1); - leave_block("Compute answer to A-query", false); - - enter_block("Compute answer to B-query", false); - auto g_B = r1cs_compute_proof_kc, G1 >(qap_wit, pk.B_query, qap_wit.d2); - leave_block("Compute answer to B-query", false); - - enter_block("Compute answer to C-query", false); - auto g_C = r1cs_compute_proof_kc, G1 >(qap_wit, pk.C_query, qap_wit.d3); - leave_block("Compute answer to C-query", false); - - enter_block("Compute answer to H-query", false); - auto g_H = r1cs_compute_proof_H(qap_wit, pk.H_query); - leave_block("Compute answer to H-query", false); - - enter_block("Compute answer to K-query", false); - G1 zk_shift = qap_wit.d1*pk.K_query[qap_wit.num_variables()+1] + - qap_wit.d2*pk.K_query[qap_wit.num_variables()+2] + - qap_wit.d3*pk.K_query[qap_wit.num_variables()+3]; - G1 g_K = r1cs_compute_proof_K(qap_wit, pk.K_query, zk_shift); - leave_block("Compute answer to K-query", false); - - leave_block("Compute the proof"); - - leave_block("Call to r1cs_ppzksnark_prover"); - - r1cs_ppzksnark_proof proof = r1cs_ppzksnark_proof(std::move(g_A), std::move(g_B), std::move(g_C), std::move(g_H), std::move(g_K)); - - return proof; -} - -template -r1cs_ppzksnark_proof r1cs_ppzksnark_prover_streaming(std::ifstream &proving_key_file, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_auxiliary_input &auxiliary_input, - const r1cs_ppzksnark_constraint_system &constraint_system) -{ - enter_block("Call to r1cs_ppzksnark_prover_streaming"); - - const Fr d1 = Fr::random_element(), - d2 = Fr::random_element(), - d3 = Fr::random_element(); - - enter_block("Compute the polynomial H"); - const qap_witness > qap_wit = r1cs_to_qap_witness_map(constraint_system, primary_input, auxiliary_input, d1, d2, d3); - leave_block("Compute the polynomial H"); - - enter_block("Compute the proof"); - - r1cs_ppzksnark_proof proof; - - enter_block("Compute answer to A-query", false); - { - knowledge_commitment_vector, G1 > A_query; - proving_key_file >> A_query; - proof.g_A = r1cs_compute_proof_kc, G1 >(qap_wit, A_query, qap_wit.d1); - } - leave_block("Compute answer to A-query", false); - - enter_block("Compute answer to B-query", false); - { - knowledge_commitment_vector, G1 > B_query; - proving_key_file >> B_query; - proof.g_B = r1cs_compute_proof_kc, G1 >(qap_wit, B_query, qap_wit.d2); - } - leave_block("Compute answer to B-query", false); - - enter_block("Compute answer to C-query", false); - { - knowledge_commitment_vector, G1 > C_query; - proving_key_file >> C_query; - proof.g_C = r1cs_compute_proof_kc, G1 >(qap_wit, C_query, qap_wit.d3); - } - leave_block("Compute answer to C-query", false); - - enter_block("Compute answer to H-query", false); - { - G1_vector H_query; - proving_key_file >> H_query; - proof.g_H = r1cs_compute_proof_H(qap_wit, H_query); - } - leave_block("Compute answer to H-query", false); - - enter_block("Compute answer to K-query", false); - { - G1_vector K_query; - proving_key_file >> K_query; - G1 zk_shift = qap_wit.d1*K_query[qap_wit.num_variables()+1] + - qap_wit.d2*K_query[qap_wit.num_variables()+2] + - qap_wit.d3*K_query[qap_wit.num_variables()+3]; - proof.g_K = r1cs_compute_proof_K(qap_wit, K_query, zk_shift); - } - leave_block("Compute answer to K-query", false); - - leave_block("Compute the proof"); - - leave_block("Call to r1cs_ppzksnark_prover_streaming"); - - return proof; -} - -template -r1cs_ppzksnark_processed_verification_key r1cs_ppzksnark_verifier_process_vk(const r1cs_ppzksnark_verification_key &vk) -{ - enter_block("Call to r1cs_ppzksnark_verifier_process_vk"); - - r1cs_ppzksnark_processed_verification_key pvk; - pvk.pp_G2_one_precomp = ppT::precompute_G2(G2::one()); - pvk.vk_alphaA_g2_precomp = ppT::precompute_G2(vk.alphaA_g2); - pvk.vk_alphaB_g1_precomp = ppT::precompute_G1(vk.alphaB_g1); - pvk.vk_alphaC_g2_precomp = ppT::precompute_G2(vk.alphaC_g2); - pvk.vk_rC_Z_g2_precomp = ppT::precompute_G2(vk.rC_Z_g2); - pvk.vk_gamma_g2_precomp = ppT::precompute_G2(vk.gamma_g2); - pvk.vk_gamma_beta_g1_precomp = ppT::precompute_G1(vk.gamma_beta_g1); - pvk.vk_gamma_beta_g2_precomp = ppT::precompute_G2(vk.gamma_beta_g2); - - pvk.encoded_IC_query = vk.encoded_IC_query; - - leave_block("Call to r1cs_ppzksnark_verifier_process_vk"); - - return pvk; -} - -template -bool r1cs_ppzksnark_online_verifier_weak_IC(const r1cs_ppzksnark_processed_verification_key &pvk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_proof &proof) -{ - assert(pvk.encoded_IC_query.domain_size() >= primary_input.size()); - - const accumulation_vector > accumulated_IC = pvk.encoded_IC_query.template accumulate_chunk >(primary_input.begin(), primary_input.end(), 0); - const G1 &acc = accumulated_IC.first; - - if (!proof.is_well_formed()) - { - return false; - } - - G1_precomp proof_g_A_g_precomp = ppT::precompute_G1(proof.g_A.g); - G1_precomp proof_g_A_h_precomp = ppT::precompute_G1(proof.g_A.h); - Fqk kc_A_1 = ppT::miller_loop(proof_g_A_g_precomp, pvk.vk_alphaA_g2_precomp); - Fqk kc_A_2 = ppT::miller_loop(proof_g_A_h_precomp, pvk.pp_G2_one_precomp); - GT kc_A = ppT::final_exponentiation(kc_A_1 * kc_A_2.unitary_inverse()); - if (kc_A != GT::one()) - { - return false; - } - - G2_precomp proof_g_B_g_precomp = ppT::precompute_G2(proof.g_B.g); - G1_precomp proof_g_B_h_precomp = ppT::precompute_G1(proof.g_B.h); - Fqk kc_B_1 = ppT::miller_loop(pvk.vk_alphaB_g1_precomp, proof_g_B_g_precomp); - Fqk kc_B_2 = ppT::miller_loop(proof_g_B_h_precomp, pvk.pp_G2_one_precomp); - GT kc_B = ppT::final_exponentiation(kc_B_1 * kc_B_2.unitary_inverse()); - if (kc_B != GT::one()) - { - return false; - } - - G1_precomp proof_g_C_g_precomp = ppT::precompute_G1(proof.g_C.g); - G1_precomp proof_g_C_h_precomp = ppT::precompute_G1(proof.g_C.h); - Fqk kc_C_1 = ppT::miller_loop(proof_g_C_g_precomp, pvk.vk_alphaC_g2_precomp); - Fqk kc_C_2 = ppT::miller_loop(proof_g_C_h_precomp, pvk.pp_G2_one_precomp); - GT kc_C = ppT::final_exponentiation(kc_C_1 * kc_C_2.unitary_inverse()); - if (kc_C != GT::one()) - { - return false; - } - - // check that g^((A+acc)*B)=g^(H*\Prod(t-\sigma)+C) - // equivalently, via pairings, that e(g^(A+acc), g^B) = e(g^H, g^Z) + e(g^C, g^1) - G1_precomp proof_g_A_g_acc_precomp = ppT::precompute_G1(proof.g_A.g + acc); - G1_precomp proof_g_H_precomp = ppT::precompute_G1(proof.g_H); - Fqk QAP_1 = ppT::miller_loop(proof_g_A_g_acc_precomp, proof_g_B_g_precomp); - Fqk QAP_23 = ppT::double_miller_loop(proof_g_H_precomp, pvk.vk_rC_Z_g2_precomp, proof_g_C_g_precomp, pvk.pp_G2_one_precomp); - GT QAP = ppT::final_exponentiation(QAP_1 * QAP_23.unitary_inverse()); - if (QAP != GT::one()) - { - return false; - } - - G1_precomp proof_g_K_precomp = ppT::precompute_G1(proof.g_K); - G1_precomp proof_g_A_g_acc_C_precomp = ppT::precompute_G1((proof.g_A.g + acc) + proof.g_C.g); - Fqk K_1 = ppT::miller_loop(proof_g_K_precomp, pvk.vk_gamma_g2_precomp); - Fqk K_23 = ppT::double_miller_loop(proof_g_A_g_acc_C_precomp, pvk.vk_gamma_beta_g2_precomp, pvk.vk_gamma_beta_g1_precomp, proof_g_B_g_precomp); - GT K = ppT::final_exponentiation(K_1 * K_23.unitary_inverse()); - if (K != GT::one()) - { - return false; - } - - return true; -} - -template -bool r1cs_ppzksnark_verifier_weak_IC(const r1cs_ppzksnark_verification_key &vk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_proof &proof) -{ - enter_block("Call to r1cs_ppzksnark_verifier_weak_IC"); - r1cs_ppzksnark_processed_verification_key pvk = r1cs_ppzksnark_verifier_process_vk(vk); - bool result = r1cs_ppzksnark_online_verifier_weak_IC(pvk, primary_input, proof); - leave_block("Call to r1cs_ppzksnark_verifier_weak_IC"); - return result; -} - -template -bool r1cs_ppzksnark_online_verifier_strong_IC(const r1cs_ppzksnark_processed_verification_key &pvk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_proof &proof) -{ - bool result = true; - enter_block("Call to r1cs_ppzksnark_online_verifier_strong_IC"); - - if (pvk.encoded_IC_query.domain_size() != primary_input.size()) - { - print_indent(); printf("Input length differs from expected (got %zu, expected %zu).\n", primary_input.size(), pvk.encoded_IC_query.domain_size()); - result = false; - } - else - { - result = r1cs_ppzksnark_online_verifier_weak_IC(pvk, primary_input, proof); - } - - leave_block("Call to r1cs_ppzksnark_online_verifier_strong_IC"); - return result; -} - -template -bool r1cs_ppzksnark_verifier_strong_IC(const r1cs_ppzksnark_verification_key &vk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_proof &proof) -{ - enter_block("Call to r1cs_ppzksnark_verifier_strong_IC"); - r1cs_ppzksnark_processed_verification_key pvk = r1cs_ppzksnark_verifier_process_vk(vk); - bool result = r1cs_ppzksnark_online_verifier_strong_IC(pvk, primary_input, proof); - leave_block("Call to r1cs_ppzksnark_verifier_strong_IC"); - return result; -} - -template -bool r1cs_ppzksnark_affine_verifier_weak_IC(const r1cs_ppzksnark_verification_key &vk, - const r1cs_ppzksnark_primary_input &primary_input, - const r1cs_ppzksnark_proof &proof) -{ - enter_block("Call to r1cs_ppzksnark_affine_verifier_weak_IC"); - assert(vk.encoded_IC_query.domain_size() >= primary_input.size()); - - affine_ate_G2_precomp pvk_pp_G2_one_precomp = ppT::affine_ate_precompute_G2(G2::one()); - affine_ate_G2_precomp pvk_vk_alphaA_g2_precomp = ppT::affine_ate_precompute_G2(vk.alphaA_g2); - affine_ate_G1_precomp pvk_vk_alphaB_g1_precomp = ppT::affine_ate_precompute_G1(vk.alphaB_g1); - affine_ate_G2_precomp pvk_vk_alphaC_g2_precomp = ppT::affine_ate_precompute_G2(vk.alphaC_g2); - affine_ate_G2_precomp pvk_vk_rC_Z_g2_precomp = ppT::affine_ate_precompute_G2(vk.rC_Z_g2); - affine_ate_G2_precomp pvk_vk_gamma_g2_precomp = ppT::affine_ate_precompute_G2(vk.gamma_g2); - affine_ate_G1_precomp pvk_vk_gamma_beta_g1_precomp = ppT::affine_ate_precompute_G1(vk.gamma_beta_g1); - affine_ate_G2_precomp pvk_vk_gamma_beta_g2_precomp = ppT::affine_ate_precompute_G2(vk.gamma_beta_g2); - - enter_block("Compute input-dependent part of A"); - const accumulation_vector > accumulated_IC = vk.encoded_IC_query.template accumulate_chunk >(primary_input.begin(), primary_input.end(), 0); - assert(accumulated_IC.is_fully_accumulated()); - const G1 &acc = accumulated_IC.first; - leave_block("Compute input-dependent part of A"); - - bool result = true; - enter_block("Check knowledge commitment for A is valid"); - affine_ate_G1_precomp proof_g_A_g_precomp = ppT::affine_ate_precompute_G1(proof.g_A.g); - affine_ate_G1_precomp proof_g_A_h_precomp = ppT::affine_ate_precompute_G1(proof.g_A.h); - Fqk kc_A_miller = ppT::affine_ate_e_over_e_miller_loop(proof_g_A_g_precomp, pvk_vk_alphaA_g2_precomp, proof_g_A_h_precomp, pvk_pp_G2_one_precomp); - GT kc_A = ppT::final_exponentiation(kc_A_miller); - - if (kc_A != GT::one()) - { - print_indent(); printf("Knowledge commitment for A query incorrect.\n"); - result = false; - } - leave_block("Check knowledge commitment for A is valid"); - - enter_block("Check knowledge commitment for B is valid"); - affine_ate_G2_precomp proof_g_B_g_precomp = ppT::affine_ate_precompute_G2(proof.g_B.g); - affine_ate_G1_precomp proof_g_B_h_precomp = ppT::affine_ate_precompute_G1(proof.g_B.h); - Fqk kc_B_miller = ppT::affine_ate_e_over_e_miller_loop(pvk_vk_alphaB_g1_precomp, proof_g_B_g_precomp, proof_g_B_h_precomp, pvk_pp_G2_one_precomp); - GT kc_B = ppT::final_exponentiation(kc_B_miller); - if (kc_B != GT::one()) - { - print_indent(); printf("Knowledge commitment for B query incorrect.\n"); - result = false; - } - leave_block("Check knowledge commitment for B is valid"); - - enter_block("Check knowledge commitment for C is valid"); - affine_ate_G1_precomp proof_g_C_g_precomp = ppT::affine_ate_precompute_G1(proof.g_C.g); - affine_ate_G1_precomp proof_g_C_h_precomp = ppT::affine_ate_precompute_G1(proof.g_C.h); - Fqk kc_C_miller = ppT::affine_ate_e_over_e_miller_loop(proof_g_C_g_precomp, pvk_vk_alphaC_g2_precomp, proof_g_C_h_precomp, pvk_pp_G2_one_precomp); - GT kc_C = ppT::final_exponentiation(kc_C_miller); - if (kc_C != GT::one()) - { - print_indent(); printf("Knowledge commitment for C query incorrect.\n"); - result = false; - } - leave_block("Check knowledge commitment for C is valid"); - - enter_block("Check QAP divisibility"); - affine_ate_G1_precomp proof_g_A_g_acc_precomp = ppT::affine_ate_precompute_G1(proof.g_A.g + acc); - affine_ate_G1_precomp proof_g_H_precomp = ppT::affine_ate_precompute_G1(proof.g_H); - Fqk QAP_miller = ppT::affine_ate_e_times_e_over_e_miller_loop(proof_g_H_precomp, pvk_vk_rC_Z_g2_precomp, proof_g_C_g_precomp, pvk_pp_G2_one_precomp, proof_g_A_g_acc_precomp, proof_g_B_g_precomp); - GT QAP = ppT::final_exponentiation(QAP_miller); - if (QAP != GT::one()) - { - print_indent(); printf("QAP divisibility check failed.\n"); - result = false; - } - leave_block("Check QAP divisibility"); - - enter_block("Check same coefficients were used"); - affine_ate_G1_precomp proof_g_K_precomp = ppT::affine_ate_precompute_G1(proof.g_K); - affine_ate_G1_precomp proof_g_A_g_acc_C_precomp = ppT::affine_ate_precompute_G1((proof.g_A.g + acc) + proof.g_C.g); - Fqk K_miller = ppT::affine_ate_e_times_e_over_e_miller_loop(proof_g_A_g_acc_C_precomp, pvk_vk_gamma_beta_g2_precomp, pvk_vk_gamma_beta_g1_precomp, proof_g_B_g_precomp, proof_g_K_precomp, pvk_vk_gamma_g2_precomp); - GT K = ppT::final_exponentiation(K_miller); - if (K != GT::one()) - { - print_indent(); printf("Same-coefficient check failed.\n"); - result = false; - } - leave_block("Check same coefficients were used"); - - leave_block("Call to r1cs_ppzksnark_affine_verifier_weak_IC"); - - return result; -} - -} // libsnark -#endif // R1CS_PPZKSNARK_TCC_ diff --git a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark_params.hpp b/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark_params.hpp deleted file mode 100644 index 4054b8e3b..000000000 --- a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark_params.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/** @file - ***************************************************************************** - - Declaration of public-parameter selector for the R1CS ppzkSNARK. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ - -#ifndef R1CS_PPZKSNARK_PARAMS_HPP_ -#define R1CS_PPZKSNARK_PARAMS_HPP_ - -#include "relations/constraint_satisfaction_problems/r1cs/r1cs.hpp" - -namespace libsnark { - -/** - * Below are various template aliases (used for convenience). - */ - -template -using r1cs_ppzksnark_constraint_system = r1cs_constraint_system >; - -template -using r1cs_ppzksnark_primary_input = r1cs_primary_input >; - -template -using r1cs_ppzksnark_auxiliary_input = r1cs_auxiliary_input >; - -} // libsnark - -#endif // R1CS_PPZKSNARK_PARAMS_HPP_ diff --git a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/tests/test_r1cs_ppzksnark.cpp b/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/tests/test_r1cs_ppzksnark.cpp deleted file mode 100644 index 6c6e51857..000000000 --- a/src/snark/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/tests/test_r1cs_ppzksnark.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/** @file - ***************************************************************************** - Test program that exercises the ppzkSNARK (first generator, then - prover, then verifier) on a synthetic R1CS instance. - - ***************************************************************************** - * @author This file is part of libsnark, developed by SCIPR Lab - * and contributors (see AUTHORS). - * @copyright MIT license (see LICENSE file) - *****************************************************************************/ -#include -#include - -#include "algebra/curves/alt_bn128/alt_bn128_pp.hpp" -#include "common/profiling.hpp" -#include "common/utils.hpp" -#include "relations/constraint_satisfaction_problems/r1cs/examples/r1cs_examples.hpp" -#include "zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.hpp" - -#include - -using namespace libsnark; - -template -void test_r1cs_ppzksnark(size_t num_constraints, - size_t input_size) -{ - print_header("(enter) Test R1CS ppzkSNARK"); - - const bool test_serialization = true; - r1cs_example > example = generate_r1cs_example_with_binary_input >(num_constraints, input_size); - example.constraint_system.swap_AB_if_beneficial(); - const bool bit = run_r1cs_ppzksnark(example, test_serialization); - EXPECT_TRUE(bit); - - print_header("(leave) Test R1CS ppzkSNARK"); -} - -TEST(zk_proof_systems, r1cs_ppzksnark) -{ - start_profiling(); - - test_r1cs_ppzksnark(1000, 20); -} diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp index 9e0c0f993..fcaadf4b8 100644 --- a/src/test/rpc_wallet_tests.cpp +++ b/src/test/rpc_wallet_tests.cpp @@ -1035,15 +1035,17 @@ BOOST_AUTO_TEST_CASE(asyncrpcoperation_sign_send_raw_transaction) { BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) { SelectParams(CBaseChainParams::TESTNET); + auto consensusParams = Params().GetConsensus(); LOCK(pwalletMain->cs_wallet); UniValue retValue; // Mutable tx containing contextual information we need to build tx - retValue = CallRPC("getblockcount"); - int nHeight = retValue.get_int(); - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nHeight + 1); + // We removed the ability to create pre-Sapling Sprout proofs, so we can + // only create Sapling-onwards transactions. + int nHeight = consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(consensusParams, nHeight + 1); if (mtx.nVersion == 1) { mtx.nVersion = 2; } @@ -1589,16 +1591,15 @@ BOOST_AUTO_TEST_CASE(rpc_z_shieldcoinbase_parameters) BOOST_AUTO_TEST_CASE(rpc_z_shieldcoinbase_internals) { SelectParams(CBaseChainParams::TESTNET); + auto consensusParams = Params().GetConsensus(); LOCK(pwalletMain->cs_wallet); // Mutable tx containing contextual information we need to build tx - UniValue retValue = CallRPC("getblockcount"); - int nHeight = retValue.get_int(); - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nHeight + 1); - if (mtx.nVersion == 1) { - mtx.nVersion = 2; - } + // We removed the ability to create pre-Sapling Sprout proofs, so we can + // only create Sapling-onwards transactions. + int nHeight = consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(consensusParams, nHeight + 1); // Test that option -mempooltxinputlimit is respected. mapArgs["-mempooltxinputlimit"] = "1"; @@ -1817,13 +1818,17 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters) BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals) { SelectParams(CBaseChainParams::TESTNET); + auto consensusParams = Params().GetConsensus(); LOCK(pwalletMain->cs_wallet); + UniValue retValue; + // Mutable tx containing contextual information we need to build tx - UniValue retValue = CallRPC("getblockcount"); - int nHeight = retValue.get_int(); - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nHeight + 1); + // We removed the ability to create pre-Sapling Sprout proofs, so we can + // only create Sapling-onwards transactions. + int nHeight = consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(consensusParams, nHeight + 1); // Test that option -mempooltxinputlimit is respected. mapArgs["-mempooltxinputlimit"] = "1"; diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp index d56c3a80f..fc91ea3e0 100644 --- a/src/test/sighash_tests.cpp +++ b/src/test/sighash_tests.cpp @@ -167,7 +167,8 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle, uint32_t co tx.vShieldedOutput.push_back(odesc); } } - if (tx.nVersion >= 2) { + // We have removed pre-Sapling Sprout support. + if (tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION) { for (int js = 0; js < joinsplits; js++) { JSDescription jsdesc; if (insecure_rand() % 2 == 0) { @@ -183,12 +184,10 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle, uint32_t co jsdesc.randomSeed = GetRandHash(); randombytes_buf(jsdesc.ciphertexts[0].begin(), jsdesc.ciphertexts[0].size()); randombytes_buf(jsdesc.ciphertexts[1].begin(), jsdesc.ciphertexts[1].size()); - if (tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION) { + { libzcash::GrothProof zkproof; randombytes_buf(zkproof.begin(), zkproof.size()); jsdesc.proof = zkproof; - } else { - jsdesc.proof = libzcash::PHGRProof::random_invalid(); } jsdesc.macs[0] = GetRandHash(); jsdesc.macs[1] = GetRandHash(); diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 03f98870c..02b6f8d33 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -37,9 +37,7 @@ extern void noui_connect(); JoinSplitTestingSetup::JoinSplitTestingSetup() { - boost::filesystem::path pk_path = ZC_GetParamsDir() / "sprout-proving.key"; - boost::filesystem::path vk_path = ZC_GetParamsDir() / "sprout-verifying.key"; - pzcashParams = ZCJoinSplit::Prepared(vk_path.string(), pk_path.string()); + pzcashParams = ZCJoinSplit::Prepared(); boost::filesystem::path sapling_spend = ZC_GetParamsDir() / "sapling-spend.params"; boost::filesystem::path sapling_output = ZC_GetParamsDir() / "sapling-output.params"; diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index d05bacf89..4a45ed079 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -373,14 +373,15 @@ BOOST_AUTO_TEST_CASE(test_basic_joinsplit_verification) auto verifier = libzcash::ProofVerifier::Strict(); { - JSDescription jsdesc(false, *pzcashParams, joinSplitPubKey, rt, inputs, outputs, 0, 0); + JSDescription jsdesc(*pzcashParams, joinSplitPubKey, rt, inputs, outputs, 0, 0); BOOST_CHECK(jsdesc.Verify(*pzcashParams, verifier, joinSplitPubKey)); CDataStream ss(SER_DISK, CLIENT_VERSION); - ss << jsdesc; + auto os = WithVersion(&ss, SAPLING_TX_VERSION | 1 << 31); + os << jsdesc; JSDescription jsdesc_deserialized; - ss >> jsdesc_deserialized; + os >> jsdesc_deserialized; BOOST_CHECK(jsdesc_deserialized == jsdesc); BOOST_CHECK(jsdesc_deserialized.Verify(*pzcashParams, verifier, joinSplitPubKey)); @@ -388,13 +389,13 @@ BOOST_AUTO_TEST_CASE(test_basic_joinsplit_verification) { // Ensure that the balance equation is working. - BOOST_CHECK_THROW(JSDescription(false, *pzcashParams, joinSplitPubKey, rt, inputs, outputs, 10, 0), std::invalid_argument); - BOOST_CHECK_THROW(JSDescription(false, *pzcashParams, joinSplitPubKey, rt, inputs, outputs, 0, 10), std::invalid_argument); + BOOST_CHECK_THROW(JSDescription(*pzcashParams, joinSplitPubKey, rt, inputs, outputs, 10, 0), std::invalid_argument); + BOOST_CHECK_THROW(JSDescription(*pzcashParams, joinSplitPubKey, rt, inputs, outputs, 0, 10), std::invalid_argument); } { // Ensure that it won't verify if the root is changed. - auto test = JSDescription(false, *pzcashParams, joinSplitPubKey, rt, inputs, outputs, 0, 0); + auto test = JSDescription(*pzcashParams, joinSplitPubKey, rt, inputs, outputs, 0, 0); test.anchor = GetRandHash(); BOOST_CHECK(!test.Verify(*pzcashParams, verifier, joinSplitPubKey)); } diff --git a/src/transaction_builder.cpp b/src/transaction_builder.cpp index ca3b9bf66..8e34af627 100644 --- a/src/transaction_builder.cpp +++ b/src/transaction_builder.cpp @@ -694,8 +694,8 @@ void TransactionBuilder::CreateJSDescription( uint256 esk; // payment disclosure - secret // Generate the proof, this can take over a minute. + assert(mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION)); JSDescription jsdesc = JSDescription::Randomized( - mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION), *sproutParams, mtx.joinSplitPubKey, vjsin[0].witness.root(), diff --git a/src/utiltest.cpp b/src/utiltest.cpp index a942c020a..9f80bc034 100644 --- a/src/utiltest.cpp +++ b/src/utiltest.cpp @@ -14,8 +14,14 @@ CMutableTransaction GetValidSproutReceiveTransaction(ZCJoinSplit& params, const libzcash::SproutSpendingKey& sk, CAmount value, bool randomInputs, - int32_t version /* = 2 */) { + uint32_t versionGroupId, /* = SAPLING_VERSION_GROUP_ID */ + int32_t version /* = SAPLING_TX_VERSION */) { + // We removed the ability to create pre-Sapling Sprout transactions + assert(version >= SAPLING_TX_VERSION); + CMutableTransaction mtx; + mtx.fOverwintered = true; + mtx.nVersionGroupId = versionGroupId; mtx.nVersion = version; mtx.vin.resize(2); if (randomInputs) { @@ -46,7 +52,7 @@ CMutableTransaction GetValidSproutReceiveTransaction(ZCJoinSplit& params, // Prepare JoinSplits uint256 rt; - JSDescription jsdesc {false, params, mtx.joinSplitPubKey, rt, + JSDescription jsdesc {params, mtx.joinSplitPubKey, rt, inputs, outputs, 2*value, 0, false}; mtx.vJoinSplit.push_back(jsdesc); @@ -78,10 +84,11 @@ CWalletTx GetValidSproutReceive(ZCJoinSplit& params, const libzcash::SproutSpendingKey& sk, CAmount value, bool randomInputs, - int32_t version /* = 2 */) + uint32_t versionGroupId, /* = SAPLING_VERSION_GROUP_ID */ + int32_t version /* = SAPLING_TX_VERSION */) { CMutableTransaction mtx = GetValidSproutReceiveTransaction( - params, sk, value, randomInputs, version + params, sk, value, randomInputs, versionGroupId, version ); CTransaction tx {mtx}; CWalletTx wtx {NULL, tx}; @@ -92,10 +99,11 @@ CWalletTx GetInvalidCommitmentSproutReceive(ZCJoinSplit& params, const libzcash::SproutSpendingKey& sk, CAmount value, bool randomInputs, - int32_t version /* = 2 */) + uint32_t versionGroupId, /* = SAPLING_VERSION_GROUP_ID */ + int32_t version /* = SAPLING_TX_VERSION */) { CMutableTransaction mtx = GetValidSproutReceiveTransaction( - params, sk, value, randomInputs, version + params, sk, value, randomInputs, versionGroupId, version ); mtx.vJoinSplit[0].commitments[0] = uint256(); mtx.vJoinSplit[0].commitments[1] = uint256(); @@ -123,6 +131,9 @@ CWalletTx GetValidSproutSpend(ZCJoinSplit& params, const libzcash::SproutNote& note, CAmount value) { CMutableTransaction mtx; + mtx.fOverwintered = true; + mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; + mtx.nVersion = SAPLING_TX_VERSION; mtx.vout.resize(2); mtx.vout[0].nValue = value; mtx.vout[1].nValue = 0; @@ -167,7 +178,7 @@ CWalletTx GetValidSproutSpend(ZCJoinSplit& params, // Prepare JoinSplits uint256 rt = tree.root(); - JSDescription jsdesc {false, params, mtx.joinSplitPubKey, rt, + JSDescription jsdesc {params, mtx.joinSplitPubKey, rt, inputs, outputs, 0, value, false}; mtx.vJoinSplit.push_back(jsdesc); diff --git a/src/utiltest.h b/src/utiltest.h index be9058695..141da8d4d 100644 --- a/src/utiltest.h +++ b/src/utiltest.h @@ -17,12 +17,14 @@ CWalletTx GetValidSproutReceive(ZCJoinSplit& params, const libzcash::SproutSpendingKey& sk, CAmount value, bool randomInputs, - int32_t version = 2); + uint32_t versionGroupId = SAPLING_VERSION_GROUP_ID, + int32_t version = SAPLING_TX_VERSION); CWalletTx GetInvalidCommitmentSproutReceive(ZCJoinSplit& params, const libzcash::SproutSpendingKey& sk, CAmount value, bool randomInputs, - int32_t version = 2); + uint32_t versionGroupId = SAPLING_VERSION_GROUP_ID, + int32_t version = SAPLING_TX_VERSION); libzcash::SproutNote GetSproutNote(ZCJoinSplit& params, const libzcash::SproutSpendingKey& sk, const CTransaction& tx, size_t js, size_t n); diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index b8bc0ff7b..a97404510 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -802,8 +802,8 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit( uint256 esk; // payment disclosure - secret + assert(mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION)); JSDescription jsdesc = JSDescription::Randomized( - mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION), *pzcashParams, joinSplitPubKey_, anchor, diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index d5a2a0a79..7ff782f9f 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -1079,8 +1079,8 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit( uint256 esk; // payment disclosure - secret + assert(mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION)); JSDescription jsdesc = JSDescription::Randomized( - mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION), *pzcashParams, joinSplitPubKey_, anchor, diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index 9bc1cbcc2..1d7d3ef0a 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -318,8 +318,8 @@ UniValue AsyncRPCOperation_shieldcoinbase::perform_joinsplit(ShieldCoinbaseJSInf uint256 esk; // payment disclosure - secret + assert(mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION)); JSDescription jsdesc = JSDescription::Randomized( - mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION), *pzcashParams, joinSplitPubKey_, anchor, diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index b56724df9..e49b74fd8 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -71,12 +71,24 @@ class TestWallet : public CWallet { } }; -CWalletTx GetValidSproutReceive(const libzcash::SproutSpendingKey& sk, CAmount value, bool randomInputs, int32_t version = 2) { - return GetValidSproutReceive(*params, sk, value, randomInputs, version); +CWalletTx GetValidSproutReceive( + const libzcash::SproutSpendingKey& sk, + CAmount value, + bool randomInputs, + int32_t versionGroupId = SAPLING_VERSION_GROUP_ID, + int32_t version = SAPLING_TX_VERSION) +{ + return GetValidSproutReceive(*params, sk, value, randomInputs, versionGroupId, version); } -CWalletTx GetInvalidCommitmentSproutReceive(const libzcash::SproutSpendingKey& sk, CAmount value, bool randomInputs, int32_t version = 2) { - return GetInvalidCommitmentSproutReceive(*params, sk, value, randomInputs, version); +CWalletTx GetInvalidCommitmentSproutReceive( + const libzcash::SproutSpendingKey& sk, + CAmount value, + bool randomInputs, + int32_t versionGroupId = SAPLING_VERSION_GROUP_ID, + int32_t version = SAPLING_TX_VERSION) +{ + return GetInvalidCommitmentSproutReceive(*params, sk, value, randomInputs, versionGroupId, version); } libzcash::SproutNote GetSproutNote(const libzcash::SproutSpendingKey& sk, @@ -105,7 +117,7 @@ std::pair CreateValidBlock(TestWallet& wallet, CBlock& block, SproutMerkleTree& sproutTree, SaplingMerkleTree& saplingTree) { - auto wtx = GetValidSproutReceive(sk, 50, true, 4); + auto wtx = GetValidSproutReceive(sk, 50, true); auto note = GetSproutNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); @@ -158,10 +170,11 @@ TEST(WalletTests, SproutNoteDataSerialisation) { noteData[jsoutpt] = nd; CDataStream ss(SER_DISK, CLIENT_VERSION); - ss << noteData; + auto os = WithVersion(&ss, SAPLING_TX_VERSION | 1 << 31); + os << noteData; mapSproutNoteData_t noteData2; - ss >> noteData2; + os >> noteData2; EXPECT_EQ(noteData, noteData2); EXPECT_EQ(noteData[jsoutpt].witnesses, noteData2[jsoutpt].witnesses); @@ -169,7 +182,8 @@ TEST(WalletTests, SproutNoteDataSerialisation) { TEST(WalletTests, FindUnspentSproutNotes) { - SelectParams(CBaseChainParams::TESTNET); + auto consensusParams = RegtestActivateSapling(); + CWallet wallet; auto sk = libzcash::SproutSpendingKey::random(); wallet.AddSproutSpendingKey(sk); @@ -338,6 +352,9 @@ TEST(WalletTests, FindUnspentSproutNotes) { mapBlockIndex.erase(blockHash); mapBlockIndex.erase(blockHash2); mapBlockIndex.erase(blockHash3); + + // Revert to default + RegtestDeactivateSapling(); } @@ -1121,7 +1138,7 @@ TEST(WalletTests, CachedWitnessesEmptyChain) { auto sk = libzcash::SproutSpendingKey::random(); wallet.AddSproutSpendingKey(sk); - auto wtx = GetValidSproutReceive(sk, 10, true, 4); + auto wtx = GetValidSproutReceive(sk, 10, true); auto note = GetSproutNote(sk, wtx, 0, 0); auto note2 = GetSproutNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); @@ -1202,7 +1219,7 @@ TEST(WalletTests, CachedWitnessesChainTip) { { // Second transaction - auto wtx = GetValidSproutReceive(sk, 50, true, 4); + auto wtx = GetValidSproutReceive(sk, 50, true); auto note = GetSproutNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); @@ -1311,7 +1328,7 @@ TEST(WalletTests, CachedWitnessesDecrementFirst) { { // Third transaction - never mined - auto wtx = GetValidSproutReceive(sk, 20, true, 4); + auto wtx = GetValidSproutReceive(sk, 20, true); auto note = GetSproutNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); @@ -1449,7 +1466,7 @@ TEST(WalletTests, ClearNoteWitnessCache) { auto sk = libzcash::SproutSpendingKey::random(); wallet.AddSproutSpendingKey(sk); - auto wtx = GetValidSproutReceive(sk, 10, true, 4); + auto wtx = GetValidSproutReceive(sk, 10, true); auto hash = wtx.GetHash(); auto note = GetSproutNote(sk, wtx, 0, 0); auto nullifier = note.nullifier(sk); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c62e86dc8..02ef5f575 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2689,8 +2689,7 @@ UniValue zc_sample_joinsplit(const UniValue& params, bool fHelp) uint256 joinSplitPubKey; uint256 anchor = SproutMerkleTree().root(); - JSDescription samplejoinsplit(true, - *pzcashParams, + JSDescription samplejoinsplit(*pzcashParams, joinSplitPubKey, anchor, {JSInput(), JSInput()}, @@ -2751,7 +2750,7 @@ UniValue zc_benchmark(const UniValue& params, bool fHelp) if (benchmarktype == "sleep") { sample_times.push_back(benchmark_sleep()); } else if (benchmarktype == "parameterloading") { - sample_times.push_back(benchmark_parameter_loading()); + throw JSONRPCError(RPC_TYPE_ERROR, "Pre-Sapling Sprout parameters have been removed"); } else if (benchmarktype == "createjoinsplit") { if (params.size() < 3) { sample_times.push_back(benchmark_create_joinsplit()); @@ -3052,11 +3051,11 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp) crypto_sign_keypair(joinSplitPubKey.begin(), joinSplitPrivKey); CMutableTransaction mtx(tx); - mtx.nVersion = 2; + mtx.nVersion = 4; + mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.joinSplitPubKey = joinSplitPubKey; - JSDescription jsdesc(false, - *pzcashParams, + JSDescription jsdesc(*pzcashParams, joinSplitPubKey, anchor, {vjsin[0], vjsin[1]}, @@ -4104,6 +4103,15 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) o.push_back(Pair("fee", std::stod(FormatMoney(nFee)))); UniValue contextInfo = o; + if (!fromTaddr || !zaddrRecipients.empty()) { + // We have shielded inputs or outputs, and therefore cannot create + // transactions before Sapling activates. + if (!Params().GetConsensus().NetworkUpgradeActive(nextBlockHeight, Consensus::UPGRADE_SAPLING)) { + throw JSONRPCError( + RPC_INVALID_PARAMETER, "Cannot create shielded transactions before Sapling has activated"); + } + } + // Builder (used if Sapling addresses are involved) boost::optional builder; if (noSproutAddrs) { @@ -4341,21 +4349,17 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) } int nextBlockHeight = chainActive.Height() + 1; + const bool saplingActive = Params().GetConsensus().NetworkUpgradeActive(nextBlockHeight, Consensus::UPGRADE_SAPLING); + + // We cannot create shielded transactions before Sapling activates. + if (!saplingActive) { + throw JSONRPCError( + RPC_INVALID_PARAMETER, "Cannot create shielded transactions before Sapling has activated"); + } + bool overwinterActive = Params().GetConsensus().NetworkUpgradeActive(nextBlockHeight, Consensus::UPGRADE_OVERWINTER); + assert(overwinterActive); unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING; - if (!Params().GetConsensus().NetworkUpgradeActive(nextBlockHeight, Consensus::UPGRADE_SAPLING)) { - max_tx_size = MAX_TX_SIZE_BEFORE_SAPLING; - auto res = DecodePaymentAddress(destaddress); - // If Sapling is not active, do not allow sending to a Sapling address. - if (IsValidPaymentAddress(res)) { - bool toSapling = boost::get(&res) != nullptr; - if (toSapling) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, Sapling has not activated"); - } - } else { - throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ") + destaddress ); - } - } // Prepare to get coinbase utxos std::vector inputs; @@ -4858,6 +4862,15 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) contextInfo.push_back(Pair("toaddress", params[1])); contextInfo.push_back(Pair("fee", ValueFromAmount(nFee))); + if (!sproutNoteInputs.empty() || !saplingNoteInputs.empty() || !IsValidDestination(taddr)) { + // We have shielded inputs or the recipient is a shielded address, and + // therefore we cannot create transactions before Sapling activates. + if (!saplingActive) { + throw JSONRPCError( + RPC_INVALID_PARAMETER, "Cannot create shielded transactions before Sapling has activated"); + } + } + // Contextual transaction we will build on CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction( Params().GetConsensus(), diff --git a/src/zcash/JoinSplit.cpp b/src/zcash/JoinSplit.cpp index 669b5f63a..92217bdd5 100644 --- a/src/zcash/JoinSplit.cpp +++ b/src/zcash/JoinSplit.cpp @@ -10,10 +10,6 @@ #include #include #include -#include -#include -#include -#include #include "tinyformat.h" #include "sync.h" #include "amount.h" @@ -22,135 +18,17 @@ #include "streams.h" #include "version.h" -using namespace libsnark; - namespace libzcash { -#include "zcash/circuit/gadget.tcc" - static CCriticalSection cs_ParamsIO; -template -void saveToFile(const std::string path, T& obj) { - LOCK(cs_ParamsIO); - - std::stringstream ss; - ss << obj; - std::ofstream fh; - fh.open(path, std::ios::binary); - ss.rdbuf()->pubseekpos(0, std::ios_base::out); - fh << ss.rdbuf(); - fh.flush(); - fh.close(); -} - -template -void loadFromFile(const std::string path, T& objIn) { - LOCK(cs_ParamsIO); - - std::stringstream ss; - std::ifstream fh(path, std::ios::binary); - - if(!fh.is_open()) { - throw std::runtime_error(strprintf("could not load param file at %s", path)); - } - - ss << fh.rdbuf(); - fh.close(); - - ss.rdbuf()->pubseekpos(0, std::ios_base::in); - - T obj; - ss >> obj; - - objIn = std::move(obj); -} - template class JoinSplitCircuit : public JoinSplit { public: - typedef default_r1cs_ppzksnark_pp ppzksnark_ppT; - typedef Fr FieldT; - - r1cs_ppzksnark_verification_key vk; - r1cs_ppzksnark_processed_verification_key vk_precomp; - std::string pkPath; - - JoinSplitCircuit(const std::string vkPath, const std::string pkPath) : pkPath(pkPath) { - loadFromFile(vkPath, vk); - vk_precomp = r1cs_ppzksnark_verifier_process_vk(vk); - } + JoinSplitCircuit() {} ~JoinSplitCircuit() {} - static void generate(const std::string r1csPath, - const std::string vkPath, - const std::string pkPath) - { - protoboard pb; - - joinsplit_gadget g(pb); - g.generate_r1cs_constraints(); - - auto r1cs = pb.get_constraint_system(); - - saveToFile(r1csPath, r1cs); - - r1cs_ppzksnark_keypair keypair = r1cs_ppzksnark_generator(r1cs); - - saveToFile(vkPath, keypair.vk); - saveToFile(pkPath, keypair.pk); - } - - void saveR1CS(std::string path) - { - protoboard pb; - joinsplit_gadget g(pb); - g.generate_r1cs_constraints(); - r1cs_constraint_system r1cs = pb.get_constraint_system(); - - saveToFile(path, r1cs); - } - - bool verify( - const PHGRProof& proof, - ProofVerifier& verifier, - const uint256& joinSplitPubKey, - const uint256& randomSeed, - const std::array& macs, - const std::array& nullifiers, - const std::array& commitments, - uint64_t vpub_old, - uint64_t vpub_new, - const uint256& rt - ) { - try { - auto r1cs_proof = proof.to_libsnark_proof>(); - - uint256 h_sig = this->h_sig(randomSeed, nullifiers, joinSplitPubKey); - - auto witness = joinsplit_gadget::witness_map( - rt, - h_sig, - macs, - nullifiers, - commitments, - vpub_old, - vpub_new - ); - - return verifier.check( - vk, - vk_precomp, - witness, - r1cs_proof - ); - } catch (...) { - return false; - } - } - SproutProof prove( - bool makeGrothProof, const std::array& inputs, const std::array& outputs, std::array& out_notes, @@ -281,118 +159,53 @@ class JoinSplitCircuit : public JoinSplit { out_macs[i] = PRF_pk(inputs[i].key, i, h_sig); } - if (makeGrothProof) { - if (!computeProof) { - return GrothProof(); - } - - GrothProof proof; - - CDataStream ss1(SER_NETWORK, PROTOCOL_VERSION); - ss1 << inputs[0].witness.path(); - std::vector auth1(ss1.begin(), ss1.end()); - - CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); - ss2 << inputs[1].witness.path(); - std::vector auth2(ss2.begin(), ss2.end()); - - librustzcash_sprout_prove( - proof.begin(), - - phi.begin(), - rt.begin(), - h_sig.begin(), - - inputs[0].key.begin(), - inputs[0].note.value(), - inputs[0].note.rho.begin(), - inputs[0].note.r.begin(), - auth1.data(), - - inputs[1].key.begin(), - inputs[1].note.value(), - inputs[1].note.rho.begin(), - inputs[1].note.r.begin(), - auth2.data(), - - out_notes[0].a_pk.begin(), - out_notes[0].value(), - out_notes[0].r.begin(), - - out_notes[1].a_pk.begin(), - out_notes[1].value(), - out_notes[1].r.begin(), - - vpub_old, - vpub_new - ); - - return proof; - } - if (!computeProof) { - return PHGRProof(); - } - - protoboard pb; - { - joinsplit_gadget g(pb); - g.generate_r1cs_constraints(); - g.generate_r1cs_witness( - phi, - rt, - h_sig, - inputs, - out_notes, - vpub_old, - vpub_new - ); + return GrothProof(); } - // The constraint system must be satisfied or there is an unimplemented - // or incorrect sanity check above. Or the constraint system is broken! - assert(pb.is_satisfied()); - - // TODO: These are copies, which is not strictly necessary. - std::vector primary_input = pb.primary_input(); - std::vector aux_input = pb.auxiliary_input(); - - // Swap A and B if it's beneficial (less arithmetic in G2) - // In our circuit, we already know that it's beneficial - // to swap, but it takes so little time to perform this - // estimate that it doesn't matter if we check every time. - pb.constraint_system.swap_AB_if_beneficial(); - - std::ifstream fh(pkPath, std::ios::binary); - - if(!fh.is_open()) { - throw std::runtime_error(strprintf("could not load param file at %s", pkPath)); - } - - return PHGRProof(r1cs_ppzksnark_prover_streaming( - fh, - primary_input, - aux_input, - pb.constraint_system - )); + GrothProof proof; + + CDataStream ss1(SER_NETWORK, PROTOCOL_VERSION); + ss1 << inputs[0].witness.path(); + std::vector auth1(ss1.begin(), ss1.end()); + + CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); + ss2 << inputs[1].witness.path(); + std::vector auth2(ss2.begin(), ss2.end()); + + librustzcash_sprout_prove( + proof.begin(), + phi.begin(), + rt.begin(), + h_sig.begin(), + inputs[0].key.begin(), + inputs[0].note.value(), + inputs[0].note.rho.begin(), + inputs[0].note.r.begin(), + auth1.data(), + inputs[1].key.begin(), + inputs[1].note.value(), + inputs[1].note.rho.begin(), + inputs[1].note.r.begin(), + auth2.data(), + out_notes[0].a_pk.begin(), + out_notes[0].value(), + out_notes[0].r.begin(), + out_notes[1].a_pk.begin(), + out_notes[1].value(), + out_notes[1].r.begin(), + vpub_old, + vpub_new + ); + + return proof; } }; template -void JoinSplit::Generate(const std::string r1csPath, - const std::string vkPath, - const std::string pkPath) -{ - initialize_curve_params(); - JoinSplitCircuit::generate(r1csPath, vkPath, pkPath); -} - -template -JoinSplit* JoinSplit::Prepared(const std::string vkPath, - const std::string pkPath) +JoinSplit* JoinSplit::Prepared() { - initialize_curve_params(); - return new JoinSplitCircuit(vkPath, pkPath); + return new JoinSplitCircuit(); } template diff --git a/src/zcash/JoinSplit.hpp b/src/zcash/JoinSplit.hpp index 2d3a61a6d..09e31570f 100644 --- a/src/zcash/JoinSplit.hpp +++ b/src/zcash/JoinSplit.hpp @@ -56,22 +56,15 @@ class JoinSplit { public: virtual ~JoinSplit() {} - static void Generate(const std::string r1csPath, - const std::string vkPath, - const std::string pkPath); - static JoinSplit* Prepared(const std::string vkPath, - const std::string pkPath); + static JoinSplit* Prepared(); static uint256 h_sig(const uint256& randomSeed, const std::array& nullifiers, const uint256& joinSplitPubKey ); - virtual void saveR1CS(std::string path) = 0; - // Compute nullifiers, macs, note commitments & encryptions, and SNARK proof virtual SproutProof prove( - bool makeGrothProof, const std::array& inputs, const std::array& outputs, std::array& out_notes, @@ -92,19 +85,6 @@ class JoinSplit { uint256 *out_esk = nullptr ) = 0; - virtual bool verify( - const PHGRProof& proof, - ProofVerifier& verifier, - const uint256& joinSplitPubKey, - const uint256& randomSeed, - const std::array& hmacs, - const std::array& nullifiers, - const std::array& commitments, - uint64_t vpub_old, - uint64_t vpub_new, - const uint256& rt - ) = 0; - protected: JoinSplit() {} }; diff --git a/src/zcash/Proof.cpp b/src/zcash/Proof.cpp index af87d1b81..7ab1298a8 100644 --- a/src/zcash/Proof.cpp +++ b/src/zcash/Proof.cpp @@ -3,249 +3,16 @@ #include "crypto/common.h" #include -#include -#include #include -using namespace libsnark; - -typedef alt_bn128_pp curve_pp; -typedef alt_bn128_pp::G1_type curve_G1; -typedef alt_bn128_pp::G2_type curve_G2; -typedef alt_bn128_pp::GT_type curve_GT; -typedef alt_bn128_pp::Fp_type curve_Fr; -typedef alt_bn128_pp::Fq_type curve_Fq; -typedef alt_bn128_pp::Fqe_type curve_Fq2; - -BOOST_STATIC_ASSERT(sizeof(mp_limb_t) == 8); - namespace libzcash { -// FE2IP as defined in the protocol spec and IEEE Std 1363a-2004. -bigint<8> fq2_to_bigint(const curve_Fq2 &e) -{ - auto modq = curve_Fq::field_char(); - auto c0 = e.c0.as_bigint(); - auto c1 = e.c1.as_bigint(); - - bigint<8> temp = c1 * modq; - temp += c0; - return temp; -} - -// Writes a bigint in big endian -template -void write_bigint(base_blob<8 * LIMBS * sizeof(mp_limb_t)> &blob, const bigint &val) -{ - auto ptr = blob.begin(); - for (ssize_t i = LIMBS-1; i >= 0; i--, ptr += 8) { - WriteBE64(ptr, val.data[i]); - } -} - -// Reads a bigint from big endian -template -bigint read_bigint(const base_blob<8 * LIMBS * sizeof(mp_limb_t)> &blob) -{ - bigint ret; - - auto ptr = blob.begin(); - - for (ssize_t i = LIMBS-1; i >= 0; i--, ptr += 8) { - ret.data[i] = ReadBE64(ptr); - } - - return ret; -} - -template<> -Fq::Fq(curve_Fq element) : data() -{ - write_bigint<4>(data, element.as_bigint()); -} - -template<> -curve_Fq Fq::to_libsnark_fq() const -{ - auto element_bigint = read_bigint<4>(data); - - // Check that the integer is smaller than the modulus - auto modq = curve_Fq::field_char(); - element_bigint.limit(modq, "element is not in Fq"); - - return curve_Fq(element_bigint); -} - -template<> -Fq2::Fq2(curve_Fq2 element) : data() -{ - write_bigint<8>(data, fq2_to_bigint(element)); -} - -template<> -curve_Fq2 Fq2::to_libsnark_fq2() const -{ - bigint<4> modq = curve_Fq::field_char(); - bigint<8> combined = read_bigint<8>(data); - bigint<5> res; - bigint<4> c0; - bigint<8>::div_qr(res, c0, combined, modq); - bigint<4> c1 = res.shorten(modq, "element is not in Fq2"); - - return curve_Fq2(curve_Fq(c0), curve_Fq(c1)); -} - -template<> -CompressedG1::CompressedG1(curve_G1 point) -{ - if (point.is_zero()) { - throw std::domain_error("curve point is zero"); - } - - point.to_affine_coordinates(); - - x = Fq(point.X); - y_lsb = point.Y.as_bigint().data[0] & 1; -} - -template<> -curve_G1 CompressedG1::to_libsnark_g1() const -{ - curve_Fq x_coordinate = x.to_libsnark_fq(); - - // y = +/- sqrt(x^3 + b) - auto y_coordinate = ((x_coordinate.squared() * x_coordinate) + alt_bn128_coeff_b).sqrt(); - - if ((y_coordinate.as_bigint().data[0] & 1) != y_lsb) { - y_coordinate = -y_coordinate; - } - - curve_G1 r = curve_G1::one(); - r.X = x_coordinate; - r.Y = y_coordinate; - r.Z = curve_Fq::one(); - - assert(r.is_well_formed()); - - return r; -} - -template<> -CompressedG2::CompressedG2(curve_G2 point) -{ - if (point.is_zero()) { - throw std::domain_error("curve point is zero"); - } - - point.to_affine_coordinates(); - - x = Fq2(point.X); - y_gt = fq2_to_bigint(point.Y) > fq2_to_bigint(-(point.Y)); -} - -template<> -curve_G2 CompressedG2::to_libsnark_g2() const -{ - auto x_coordinate = x.to_libsnark_fq2(); - - // y = +/- sqrt(x^3 + b) - auto y_coordinate = ((x_coordinate.squared() * x_coordinate) + alt_bn128_twist_coeff_b).sqrt(); - auto y_coordinate_neg = -y_coordinate; - - if ((fq2_to_bigint(y_coordinate) > fq2_to_bigint(y_coordinate_neg)) != y_gt) { - y_coordinate = y_coordinate_neg; - } - - curve_G2 r = curve_G2::one(); - r.X = x_coordinate; - r.Y = y_coordinate; - r.Z = curve_Fq2::one(); - - assert(r.is_well_formed()); - - if (alt_bn128_modulus_r * r != curve_G2::zero()) { - throw std::runtime_error("point is not in G2"); - } - - return r; -} - -template<> -PHGRProof::PHGRProof(const r1cs_ppzksnark_proof &proof) -{ - g_A = CompressedG1(proof.g_A.g); - g_A_prime = CompressedG1(proof.g_A.h); - g_B = CompressedG2(proof.g_B.g); - g_B_prime = CompressedG1(proof.g_B.h); - g_C = CompressedG1(proof.g_C.g); - g_C_prime = CompressedG1(proof.g_C.h); - g_K = CompressedG1(proof.g_K); - g_H = CompressedG1(proof.g_H); -} - -template<> -r1cs_ppzksnark_proof PHGRProof::to_libsnark_proof() const -{ - r1cs_ppzksnark_proof proof; - - proof.g_A.g = g_A.to_libsnark_g1(); - proof.g_A.h = g_A_prime.to_libsnark_g1(); - proof.g_B.g = g_B.to_libsnark_g2(); - proof.g_B.h = g_B_prime.to_libsnark_g1(); - proof.g_C.g = g_C.to_libsnark_g1(); - proof.g_C.h = g_C_prime.to_libsnark_g1(); - proof.g_K = g_K.to_libsnark_g1(); - proof.g_H = g_H.to_libsnark_g1(); - - return proof; -} - -PHGRProof PHGRProof::random_invalid() -{ - PHGRProof p; - p.g_A = curve_G1::random_element(); - p.g_A_prime = curve_G1::random_element(); - p.g_B = curve_G2::random_element(); - p.g_B_prime = curve_G1::random_element(); - p.g_C = curve_G1::random_element(); - p.g_C_prime = curve_G1::random_element(); - - p.g_K = curve_G1::random_element(); - p.g_H = curve_G1::random_element(); - - return p; -} - -static std::once_flag init_public_params_once_flag; - -void initialize_curve_params() -{ - std::call_once (init_public_params_once_flag, curve_pp::init_public_params); -} - ProofVerifier ProofVerifier::Strict() { - initialize_curve_params(); return ProofVerifier(true); } ProofVerifier ProofVerifier::Disabled() { - initialize_curve_params(); return ProofVerifier(false); } -template<> -bool ProofVerifier::check( - const r1cs_ppzksnark_verification_key& vk, - const r1cs_ppzksnark_processed_verification_key& pvk, - const r1cs_primary_input& primary_input, - const r1cs_ppzksnark_proof& proof -) -{ - if (perform_verification) { - return r1cs_ppzksnark_online_verifier_strong_IC(pvk, primary_input, proof); - } else { - return true; - } -} - } diff --git a/src/zcash/Proof.hpp b/src/zcash/Proof.hpp index e06095d57..7c9b7f7f5 100644 --- a/src/zcash/Proof.hpp +++ b/src/zcash/Proof.hpp @@ -16,12 +16,6 @@ class Fq { public: Fq() : data() { } - template - Fq(libsnark_Fq element); - - template - libsnark_Fq to_libsnark_fq() const; - ADD_SERIALIZE_METHODS; template @@ -49,12 +43,6 @@ class Fq2 { public: Fq2() : data() { } - template - Fq2(libsnark_Fq2 element); - - template - libsnark_Fq2 to_libsnark_fq2() const; - ADD_SERIALIZE_METHODS; template @@ -84,12 +72,6 @@ class CompressedG1 { public: CompressedG1() : y_lsb(false), x() { } - template - CompressedG1(libsnark_G1 point); - - template - libsnark_G1 to_libsnark_g1() const; - ADD_SERIALIZE_METHODS; template @@ -134,12 +116,6 @@ class CompressedG2 { public: CompressedG2() : y_gt(false), x() { } - template - CompressedG2(libsnark_G2 point); - - template - libsnark_G2 to_libsnark_g2() const; - ADD_SERIALIZE_METHODS; template @@ -190,17 +166,6 @@ class PHGRProof { public: PHGRProof() : g_A(), g_A_prime(), g_B(), g_B_prime(), g_C(), g_C_prime(), g_K(), g_H() { } - // Produces a compressed proof using a libsnark zkSNARK proof - template - PHGRProof(const libsnark_proof& proof); - - // Produces a libsnark zkSNARK proof out of this proof, - // or throws an exception if it is invalid. - template - libsnark_proof to_libsnark_proof() const; - - static PHGRProof random_invalid(); - ADD_SERIALIZE_METHODS; template diff --git a/src/zcash/circuit/commitment.tcc b/src/zcash/circuit/commitment.tcc deleted file mode 100644 index d1b0b10fa..000000000 --- a/src/zcash/circuit/commitment.tcc +++ /dev/null @@ -1,100 +0,0 @@ -template -class note_commitment_gadget : gadget { -private: - std::shared_ptr> block1; - std::shared_ptr> block2; - std::shared_ptr> hasher1; - std::shared_ptr> intermediate_hash; - std::shared_ptr> hasher2; - -public: - note_commitment_gadget( - protoboard &pb, - pb_variable& ZERO, - pb_variable_array& a_pk, - pb_variable_array& v, - pb_variable_array& rho, - pb_variable_array& r, - std::shared_ptr> result - ) : gadget(pb) { - pb_variable_array leading_byte = - from_bits({1, 0, 1, 1, 0, 0, 0, 0}, ZERO); - - pb_variable_array first_of_rho(rho.begin(), rho.begin()+184); - pb_variable_array last_of_rho(rho.begin()+184, rho.end()); - - intermediate_hash.reset(new digest_variable(pb, 256, "")); - - // final padding - pb_variable_array length_padding = - from_bits({ - // padding - 1,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - - // length of message (840 bits) - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,1,1, - 0,1,0,0,1,0,0,0 - }, ZERO); - - block1.reset(new block_variable(pb, { - leading_byte, - a_pk, - v, - first_of_rho - }, "")); - - block2.reset(new block_variable(pb, { - last_of_rho, - r, - length_padding - }, "")); - - pb_linear_combination_array IV = SHA256_default_IV(pb); - - hasher1.reset(new sha256_compression_function_gadget( - pb, - IV, - block1->bits, - *intermediate_hash, - "")); - - pb_linear_combination_array IV2(intermediate_hash->bits); - - hasher2.reset(new sha256_compression_function_gadget( - pb, - IV2, - block2->bits, - *result, - "")); - } - - void generate_r1cs_constraints() { - hasher1->generate_r1cs_constraints(); - hasher2->generate_r1cs_constraints(); - } - - void generate_r1cs_witness() { - hasher1->generate_r1cs_witness(); - hasher2->generate_r1cs_witness(); - } -}; diff --git a/src/zcash/circuit/gadget.tcc b/src/zcash/circuit/gadget.tcc deleted file mode 100644 index 0a2ec7719..000000000 --- a/src/zcash/circuit/gadget.tcc +++ /dev/null @@ -1,349 +0,0 @@ -#include "zcash/circuit/utils.tcc" -#include "zcash/circuit/prfs.tcc" -#include "zcash/circuit/commitment.tcc" -#include "zcash/circuit/merkle.tcc" -#include "zcash/circuit/note.tcc" - -template -class joinsplit_gadget : gadget { -private: - // Verifier inputs - pb_variable_array zk_packed_inputs; - pb_variable_array zk_unpacked_inputs; - std::shared_ptr> unpacker; - - std::shared_ptr> zk_merkle_root; - std::shared_ptr> zk_h_sig; - std::array>, NumInputs> zk_input_nullifiers; - std::array>, NumInputs> zk_input_macs; - std::array>, NumOutputs> zk_output_commitments; - pb_variable_array zk_vpub_old; - pb_variable_array zk_vpub_new; - - // Aux inputs - pb_variable ZERO; - std::shared_ptr> zk_phi; - pb_variable_array zk_total_uint64; - - // Input note gadgets - std::array>, NumInputs> zk_input_notes; - std::array>, NumInputs> zk_mac_authentication; - - // Output note gadgets - std::array>, NumOutputs> zk_output_notes; - -public: - // PRF_pk only has a 1-bit domain separation "nonce" - // for different macs. - BOOST_STATIC_ASSERT(NumInputs <= 2); - - // PRF_rho only has a 1-bit domain separation "nonce" - // for different output `rho`. - BOOST_STATIC_ASSERT(NumOutputs <= 2); - - joinsplit_gadget(protoboard &pb) : gadget(pb) { - // Verification - { - // The verification inputs are all bit-strings of various - // lengths (256-bit digests and 64-bit integers) and so we - // pack them into as few field elements as possible. (The - // more verification inputs you have, the more expensive - // verification is.) - zk_packed_inputs.allocate(pb, verifying_field_element_size()); - pb.set_input_sizes(verifying_field_element_size()); - - alloc_uint256(zk_unpacked_inputs, zk_merkle_root); - alloc_uint256(zk_unpacked_inputs, zk_h_sig); - - for (size_t i = 0; i < NumInputs; i++) { - alloc_uint256(zk_unpacked_inputs, zk_input_nullifiers[i]); - alloc_uint256(zk_unpacked_inputs, zk_input_macs[i]); - } - - for (size_t i = 0; i < NumOutputs; i++) { - alloc_uint256(zk_unpacked_inputs, zk_output_commitments[i]); - } - - alloc_uint64(zk_unpacked_inputs, zk_vpub_old); - alloc_uint64(zk_unpacked_inputs, zk_vpub_new); - - assert(zk_unpacked_inputs.size() == verifying_input_bit_size()); - - // This gadget will ensure that all of the inputs we provide are - // boolean constrained. - unpacker.reset(new multipacking_gadget( - pb, - zk_unpacked_inputs, - zk_packed_inputs, - FieldT::capacity(), - "unpacker" - )); - } - - // We need a constant "zero" variable in some contexts. In theory - // it should never be necessary, but libsnark does not synthesize - // optimal circuits. - // - // The first variable of our constraint system is constrained - // to be one automatically for us, and is known as `ONE`. - ZERO.allocate(pb); - - zk_phi.reset(new digest_variable(pb, 252, "")); - - zk_total_uint64.allocate(pb, 64); - - for (size_t i = 0; i < NumInputs; i++) { - // Input note gadget for commitments, macs, nullifiers, - // and spend authority. - zk_input_notes[i].reset(new input_note_gadget( - pb, - ZERO, - zk_input_nullifiers[i], - *zk_merkle_root - )); - - // The input keys authenticate h_sig to prevent - // malleability. - zk_mac_authentication[i].reset(new PRF_pk_gadget( - pb, - ZERO, - zk_input_notes[i]->a_sk->bits, - zk_h_sig->bits, - i ? true : false, - zk_input_macs[i] - )); - } - - for (size_t i = 0; i < NumOutputs; i++) { - zk_output_notes[i].reset(new output_note_gadget( - pb, - ZERO, - zk_phi->bits, - zk_h_sig->bits, - i ? true : false, - zk_output_commitments[i] - )); - } - } - - void generate_r1cs_constraints() { - // The true passed here ensures all the inputs - // are boolean constrained. - unpacker->generate_r1cs_constraints(true); - - // Constrain `ZERO` - generate_r1cs_equals_const_constraint(this->pb, ZERO, FieldT::zero(), "ZERO"); - - // Constrain bitness of phi - zk_phi->generate_r1cs_constraints(); - - for (size_t i = 0; i < NumInputs; i++) { - // Constrain the JoinSplit input constraints. - zk_input_notes[i]->generate_r1cs_constraints(); - - // Authenticate h_sig with a_sk - zk_mac_authentication[i]->generate_r1cs_constraints(); - } - - for (size_t i = 0; i < NumOutputs; i++) { - // Constrain the JoinSplit output constraints. - zk_output_notes[i]->generate_r1cs_constraints(); - } - - // Value balance - { - linear_combination left_side = packed_addition(zk_vpub_old); - for (size_t i = 0; i < NumInputs; i++) { - left_side = left_side + packed_addition(zk_input_notes[i]->value); - } - - linear_combination right_side = packed_addition(zk_vpub_new); - for (size_t i = 0; i < NumOutputs; i++) { - right_side = right_side + packed_addition(zk_output_notes[i]->value); - } - - // Ensure that both sides are equal - this->pb.add_r1cs_constraint(r1cs_constraint( - 1, - left_side, - right_side - )); - - // #854: Ensure that left_side is a 64-bit integer. - for (size_t i = 0; i < 64; i++) { - generate_boolean_r1cs_constraint( - this->pb, - zk_total_uint64[i], - "" - ); - } - - this->pb.add_r1cs_constraint(r1cs_constraint( - 1, - left_side, - packed_addition(zk_total_uint64) - )); - } - } - - void generate_r1cs_witness( - const uint252& phi, - const uint256& rt, - const uint256& h_sig, - const std::array& inputs, - const std::array& outputs, - uint64_t vpub_old, - uint64_t vpub_new - ) { - // Witness `zero` - this->pb.val(ZERO) = FieldT::zero(); - - // Witness rt. This is not a sanity check. - // - // This ensures the read gadget constrains - // the intended root in the event that - // both inputs are zero-valued. - zk_merkle_root->bits.fill_with_bits( - this->pb, - uint256_to_bool_vector(rt) - ); - - // Witness public balance values - zk_vpub_old.fill_with_bits( - this->pb, - uint64_to_bool_vector(vpub_old) - ); - zk_vpub_new.fill_with_bits( - this->pb, - uint64_to_bool_vector(vpub_new) - ); - - { - // Witness total_uint64 bits - uint64_t left_side_acc = vpub_old; - for (size_t i = 0; i < NumInputs; i++) { - left_side_acc += inputs[i].note.value(); - } - - zk_total_uint64.fill_with_bits( - this->pb, - uint64_to_bool_vector(left_side_acc) - ); - } - - // Witness phi - zk_phi->bits.fill_with_bits( - this->pb, - uint252_to_bool_vector(phi) - ); - - // Witness h_sig - zk_h_sig->bits.fill_with_bits( - this->pb, - uint256_to_bool_vector(h_sig) - ); - - for (size_t i = 0; i < NumInputs; i++) { - // Witness the input information. - auto merkle_path = inputs[i].witness.path(); - zk_input_notes[i]->generate_r1cs_witness( - merkle_path, - inputs[i].key, - inputs[i].note - ); - - // Witness macs - zk_mac_authentication[i]->generate_r1cs_witness(); - } - - for (size_t i = 0; i < NumOutputs; i++) { - // Witness the output information. - zk_output_notes[i]->generate_r1cs_witness(outputs[i]); - } - - // [SANITY CHECK] Ensure that the intended root - // was witnessed by the inputs, even if the read - // gadget overwrote it. This allows the prover to - // fail instead of the verifier, in the event that - // the roots of the inputs do not match the - // treestate provided to the proving API. - zk_merkle_root->bits.fill_with_bits( - this->pb, - uint256_to_bool_vector(rt) - ); - - // This happens last, because only by now are all the - // verifier inputs resolved. - unpacker->generate_r1cs_witness_from_bits(); - } - - static r1cs_primary_input witness_map( - const uint256& rt, - const uint256& h_sig, - const std::array& macs, - const std::array& nullifiers, - const std::array& commitments, - uint64_t vpub_old, - uint64_t vpub_new - ) { - std::vector verify_inputs; - - insert_uint256(verify_inputs, rt); - insert_uint256(verify_inputs, h_sig); - - for (size_t i = 0; i < NumInputs; i++) { - insert_uint256(verify_inputs, nullifiers[i]); - insert_uint256(verify_inputs, macs[i]); - } - - for (size_t i = 0; i < NumOutputs; i++) { - insert_uint256(verify_inputs, commitments[i]); - } - - insert_uint64(verify_inputs, vpub_old); - insert_uint64(verify_inputs, vpub_new); - - assert(verify_inputs.size() == verifying_input_bit_size()); - auto verify_field_elements = pack_bit_vector_into_field_element_vector(verify_inputs); - assert(verify_field_elements.size() == verifying_field_element_size()); - return verify_field_elements; - } - - static size_t verifying_input_bit_size() { - size_t acc = 0; - - acc += 256; // the merkle root (anchor) - acc += 256; // h_sig - for (size_t i = 0; i < NumInputs; i++) { - acc += 256; // nullifier - acc += 256; // mac - } - for (size_t i = 0; i < NumOutputs; i++) { - acc += 256; // new commitment - } - acc += 64; // vpub_old - acc += 64; // vpub_new - - return acc; - } - - static size_t verifying_field_element_size() { - return div_ceil(verifying_input_bit_size(), FieldT::capacity()); - } - - void alloc_uint256( - pb_variable_array& packed_into, - std::shared_ptr>& var - ) { - var.reset(new digest_variable(this->pb, 256, "")); - packed_into.insert(packed_into.end(), var->bits.begin(), var->bits.end()); - } - - void alloc_uint64( - pb_variable_array& packed_into, - pb_variable_array& integer - ) { - integer.allocate(this->pb, 64, ""); - packed_into.insert(packed_into.end(), integer.begin(), integer.end()); - } -}; diff --git a/src/zcash/circuit/merkle.tcc b/src/zcash/circuit/merkle.tcc deleted file mode 100644 index 09f02ae9f..000000000 --- a/src/zcash/circuit/merkle.tcc +++ /dev/null @@ -1,60 +0,0 @@ -template -class merkle_tree_gadget : gadget { -private: - typedef sha256_two_to_one_hash_gadget sha256_gadget; - - pb_variable_array positions; - std::shared_ptr> authvars; - std::shared_ptr> auth; - -public: - merkle_tree_gadget( - protoboard& pb, - digest_variable leaf, - digest_variable root, - pb_variable& enforce - ) : gadget(pb) { - positions.allocate(pb, INCREMENTAL_MERKLE_TREE_DEPTH); - authvars.reset(new merkle_authentication_path_variable( - pb, INCREMENTAL_MERKLE_TREE_DEPTH, "auth" - )); - auth.reset(new merkle_tree_check_read_gadget( - pb, - INCREMENTAL_MERKLE_TREE_DEPTH, - positions, - leaf, - root, - *authvars, - enforce, - "" - )); - } - - void generate_r1cs_constraints() { - for (size_t i = 0; i < INCREMENTAL_MERKLE_TREE_DEPTH; i++) { - // TODO: This might not be necessary, and doesn't - // appear to be done in libsnark's tests, but there - // is no documentation, so let's do it anyway to - // be safe. - generate_boolean_r1cs_constraint( - this->pb, - positions[i], - "boolean_positions" - ); - } - - authvars->generate_r1cs_constraints(); - auth->generate_r1cs_constraints(); - } - - void generate_r1cs_witness(const MerklePath& path) { - // TODO: Change libsnark so that it doesn't require this goofy - // number thing in its API. - size_t path_index = convertVectorToInt(path.index); - - positions.fill_with_bits_of_uint64(this->pb, path_index); - - authvars->generate_r1cs_witness(path_index, path.authentication_path); - auth->generate_r1cs_witness(); - } -}; diff --git a/src/zcash/circuit/note.tcc b/src/zcash/circuit/note.tcc deleted file mode 100644 index c598c62ee..000000000 --- a/src/zcash/circuit/note.tcc +++ /dev/null @@ -1,244 +0,0 @@ -template -class note_gadget : public gadget { -public: - pb_variable_array value; - std::shared_ptr> r; - - note_gadget(protoboard &pb) : gadget(pb) { - value.allocate(pb, 64); - r.reset(new digest_variable(pb, 256, "")); - } - - void generate_r1cs_constraints() { - for (size_t i = 0; i < 64; i++) { - generate_boolean_r1cs_constraint( - this->pb, - value[i], - "boolean_value" - ); - } - - r->generate_r1cs_constraints(); - } - - void generate_r1cs_witness(const SproutNote& note) { - r->bits.fill_with_bits(this->pb, uint256_to_bool_vector(note.r)); - value.fill_with_bits(this->pb, uint64_to_bool_vector(note.value())); - } -}; - -template -class input_note_gadget : public note_gadget { -private: - std::shared_ptr> a_pk; - std::shared_ptr> rho; - - std::shared_ptr> commitment; - std::shared_ptr> commit_to_inputs; - - pb_variable value_enforce; - std::shared_ptr> witness_input; - - std::shared_ptr> spend_authority; - std::shared_ptr> expose_nullifiers; -public: - std::shared_ptr> a_sk; - - input_note_gadget( - protoboard& pb, - pb_variable& ZERO, - std::shared_ptr> nullifier, - digest_variable rt - ) : note_gadget(pb) { - a_sk.reset(new digest_variable(pb, 252, "")); - a_pk.reset(new digest_variable(pb, 256, "")); - rho.reset(new digest_variable(pb, 256, "")); - commitment.reset(new digest_variable(pb, 256, "")); - - spend_authority.reset(new PRF_addr_a_pk_gadget( - pb, - ZERO, - a_sk->bits, - a_pk - )); - - expose_nullifiers.reset(new PRF_nf_gadget( - pb, - ZERO, - a_sk->bits, - rho->bits, - nullifier - )); - - commit_to_inputs.reset(new note_commitment_gadget( - pb, - ZERO, - a_pk->bits, - this->value, - rho->bits, - this->r->bits, - commitment - )); - - value_enforce.allocate(pb); - - witness_input.reset(new merkle_tree_gadget( - pb, - *commitment, - rt, - value_enforce - )); - } - - void generate_r1cs_constraints() { - note_gadget::generate_r1cs_constraints(); - - a_sk->generate_r1cs_constraints(); - rho->generate_r1cs_constraints(); - - spend_authority->generate_r1cs_constraints(); - expose_nullifiers->generate_r1cs_constraints(); - - commit_to_inputs->generate_r1cs_constraints(); - - // value * (1 - enforce) = 0 - // Given `enforce` is boolean constrained: - // If `value` is zero, `enforce` _can_ be zero. - // If `value` is nonzero, `enforce` _must_ be one. - generate_boolean_r1cs_constraint(this->pb, value_enforce,""); - - this->pb.add_r1cs_constraint(r1cs_constraint( - packed_addition(this->value), - (1 - value_enforce), - 0 - ), ""); - - witness_input->generate_r1cs_constraints(); - } - - void generate_r1cs_witness( - const MerklePath& path, - const SproutSpendingKey& key, - const SproutNote& note - ) { - note_gadget::generate_r1cs_witness(note); - - // Witness a_sk for the input - a_sk->bits.fill_with_bits( - this->pb, - uint252_to_bool_vector(key) - ); - - // Witness a_pk for a_sk with PRF_addr - spend_authority->generate_r1cs_witness(); - - // [SANITY CHECK] Witness a_pk with note information - a_pk->bits.fill_with_bits( - this->pb, - uint256_to_bool_vector(note.a_pk) - ); - - // Witness rho for the input note - rho->bits.fill_with_bits( - this->pb, - uint256_to_bool_vector(note.rho) - ); - - // Witness the nullifier for the input note - expose_nullifiers->generate_r1cs_witness(); - - // Witness the commitment of the input note - commit_to_inputs->generate_r1cs_witness(); - - // [SANITY CHECK] Ensure the commitment is - // valid. - commitment->bits.fill_with_bits( - this->pb, - uint256_to_bool_vector(note.cm()) - ); - - // Set enforce flag for nonzero input value - this->pb.val(value_enforce) = (note.value() != 0) ? FieldT::one() : FieldT::zero(); - - // Witness merkle tree authentication path - witness_input->generate_r1cs_witness(path); - } -}; - -template -class output_note_gadget : public note_gadget { -private: - std::shared_ptr> rho; - std::shared_ptr> a_pk; - - std::shared_ptr> prevent_faerie_gold; - std::shared_ptr> commit_to_outputs; - -public: - output_note_gadget( - protoboard& pb, - pb_variable& ZERO, - pb_variable_array& phi, - pb_variable_array& h_sig, - bool nonce, - std::shared_ptr> commitment - ) : note_gadget(pb) { - rho.reset(new digest_variable(pb, 256, "")); - a_pk.reset(new digest_variable(pb, 256, "")); - - // Do not allow the caller to choose the same "rho" - // for any two valid notes in a given view of the - // blockchain. See protocol specification for more - // details. - prevent_faerie_gold.reset(new PRF_rho_gadget( - pb, - ZERO, - phi, - h_sig, - nonce, - rho - )); - - // Commit to the output notes publicly without - // disclosing them. - commit_to_outputs.reset(new note_commitment_gadget( - pb, - ZERO, - a_pk->bits, - this->value, - rho->bits, - this->r->bits, - commitment - )); - } - - void generate_r1cs_constraints() { - note_gadget::generate_r1cs_constraints(); - - a_pk->generate_r1cs_constraints(); - - prevent_faerie_gold->generate_r1cs_constraints(); - - commit_to_outputs->generate_r1cs_constraints(); - } - - void generate_r1cs_witness(const SproutNote& note) { - note_gadget::generate_r1cs_witness(note); - - prevent_faerie_gold->generate_r1cs_witness(); - - // [SANITY CHECK] Witness rho ourselves with the - // note information. - rho->bits.fill_with_bits( - this->pb, - uint256_to_bool_vector(note.rho) - ); - - a_pk->bits.fill_with_bits( - this->pb, - uint256_to_bool_vector(note.a_pk) - ); - - commit_to_outputs->generate_r1cs_witness(); - } -}; diff --git a/src/zcash/circuit/prfs.tcc b/src/zcash/circuit/prfs.tcc deleted file mode 100644 index 3f50ac9e5..000000000 --- a/src/zcash/circuit/prfs.tcc +++ /dev/null @@ -1,109 +0,0 @@ -template -class PRF_gadget : gadget { -private: - std::shared_ptr> block; - std::shared_ptr> hasher; - std::shared_ptr> result; - -public: - PRF_gadget( - protoboard& pb, - pb_variable& ZERO, - bool a, - bool b, - bool c, - bool d, - pb_variable_array x, - pb_variable_array y, - std::shared_ptr> result - ) : gadget(pb), result(result) { - - pb_linear_combination_array IV = SHA256_default_IV(pb); - - pb_variable_array discriminants; - discriminants.emplace_back(a ? ONE : ZERO); - discriminants.emplace_back(b ? ONE : ZERO); - discriminants.emplace_back(c ? ONE : ZERO); - discriminants.emplace_back(d ? ONE : ZERO); - - block.reset(new block_variable(pb, { - discriminants, - x, - y - }, "PRF_block")); - - hasher.reset(new sha256_compression_function_gadget( - pb, - IV, - block->bits, - *result, - "PRF_hasher")); - } - - void generate_r1cs_constraints() { - hasher->generate_r1cs_constraints(); - } - - void generate_r1cs_witness() { - hasher->generate_r1cs_witness(); - } -}; - -template -pb_variable_array gen256zeroes(pb_variable& ZERO) { - pb_variable_array ret; - while (ret.size() < 256) { - ret.emplace_back(ZERO); - } - - return ret; -} - -template -class PRF_addr_a_pk_gadget : public PRF_gadget { -public: - PRF_addr_a_pk_gadget( - protoboard& pb, - pb_variable& ZERO, - pb_variable_array& a_sk, - std::shared_ptr> result - ) : PRF_gadget(pb, ZERO, 1, 1, 0, 0, a_sk, gen256zeroes(ZERO), result) {} -}; - -template -class PRF_nf_gadget : public PRF_gadget { -public: - PRF_nf_gadget( - protoboard& pb, - pb_variable& ZERO, - pb_variable_array& a_sk, - pb_variable_array& rho, - std::shared_ptr> result - ) : PRF_gadget(pb, ZERO, 1, 1, 1, 0, a_sk, rho, result) {} -}; - -template -class PRF_pk_gadget : public PRF_gadget { -public: - PRF_pk_gadget( - protoboard& pb, - pb_variable& ZERO, - pb_variable_array& a_sk, - pb_variable_array& h_sig, - bool nonce, - std::shared_ptr> result - ) : PRF_gadget(pb, ZERO, 0, nonce, 0, 0, a_sk, h_sig, result) {} -}; - -template -class PRF_rho_gadget : public PRF_gadget { -public: - PRF_rho_gadget( - protoboard& pb, - pb_variable& ZERO, - pb_variable_array& phi, - pb_variable_array& h_sig, - bool nonce, - std::shared_ptr> result - ) : PRF_gadget(pb, ZERO, 0, nonce, 1, 0, phi, h_sig, result) {} -}; diff --git a/src/zcash/circuit/utils.tcc b/src/zcash/circuit/utils.tcc deleted file mode 100644 index 83fed3646..000000000 --- a/src/zcash/circuit/utils.tcc +++ /dev/null @@ -1,75 +0,0 @@ -#include "uint252.h" - -template -pb_variable_array from_bits(std::vector bits, pb_variable& ZERO) { - pb_variable_array acc; - - for(bool bit : bits) { - acc.emplace_back(bit ? ONE : ZERO); - } - - return acc; -} - -std::vector trailing252(std::vector input) { - if (input.size() != 256) { - throw std::length_error("trailing252 input invalid length"); - } - - return std::vector(input.begin() + 4, input.end()); -} - -template -std::vector to_bool_vector(T input) { - std::vector input_v(input.begin(), input.end()); - - return convertBytesVectorToVector(input_v); -} - -std::vector uint256_to_bool_vector(uint256 input) { - return to_bool_vector(input); -} - -std::vector uint252_to_bool_vector(uint252 input) { - return trailing252(to_bool_vector(input)); -} - -std::vector uint64_to_bool_vector(uint64_t input) { - auto num_bv = convertIntToVectorLE(input); - - return convertBytesVectorToVector(num_bv); -} - -void insert_uint256(std::vector& into, uint256 from) { - std::vector blob = uint256_to_bool_vector(from); - into.insert(into.end(), blob.begin(), blob.end()); -} - -void insert_uint64(std::vector& into, uint64_t from) { - std::vector num = uint64_to_bool_vector(from); - into.insert(into.end(), num.begin(), num.end()); -} - -template -T swap_endianness_u64(T v) { - if (v.size() != 64) { - throw std::length_error("invalid bit length for 64-bit unsigned integer"); - } - - for (size_t i = 0; i < 4; i++) { - for (size_t j = 0; j < 8; j++) { - std::swap(v[i*8 + j], v[((7-i)*8)+j]); - } - } - - return v; -} - -template -linear_combination packed_addition(pb_variable_array input) { - auto input_swapped = swap_endianness_u64(input); - - return pb_packing_sum(pb_variable_array( - input_swapped.rbegin(), input_swapped.rend() - )); -} diff --git a/src/zcbenchmarks.cpp b/src/zcbenchmarks.cpp index 14268f39e..fb44f9e71 100644 --- a/src/zcbenchmarks.cpp +++ b/src/zcbenchmarks.cpp @@ -91,24 +91,6 @@ double benchmark_sleep() return timer_stop(tv_start); } -double benchmark_parameter_loading() -{ - // FIXME: this is duplicated with the actual loading code - boost::filesystem::path pk_path = ZC_GetParamsDir() / "sprout-proving.key"; - boost::filesystem::path vk_path = ZC_GetParamsDir() / "sprout-verifying.key"; - - struct timeval tv_start; - timer_start(tv_start); - - auto newParams = ZCJoinSplit::Prepared(vk_path.string(), pk_path.string()); - - double ret = timer_stop(tv_start); - - delete newParams; - - return ret; -} - double benchmark_create_joinsplit() { uint256 joinSplitPubKey; @@ -118,8 +100,7 @@ double benchmark_create_joinsplit() struct timeval tv_start; timer_start(tv_start); - JSDescription jsdesc(true, - *pzcashParams, + JSDescription jsdesc(*pzcashParams, joinSplitPubKey, anchor, {JSInput(), JSInput()}, diff --git a/src/zcbenchmarks.h b/src/zcbenchmarks.h index 721251eb5..60ad5b282 100644 --- a/src/zcbenchmarks.h +++ b/src/zcbenchmarks.h @@ -5,7 +5,6 @@ #include extern double benchmark_sleep(); -extern double benchmark_parameter_loading(); extern double benchmark_create_joinsplit(); extern std::vector benchmark_create_joinsplit_threaded(int nThreads); extern double benchmark_solve_equihash(); diff --git a/zcutil/fetch-params.sh b/zcutil/fetch-params.sh index 5a7520a5e..64bc6ad3c 100755 --- a/zcutil/fetch-params.sh +++ b/zcutil/fetch-params.sh @@ -8,8 +8,6 @@ else PARAMS_DIR="$HOME/.zcash-params" fi -SPROUT_PKEY_NAME='sprout-proving.key' -SPROUT_VKEY_NAME='sprout-verifying.key' SAPLING_SPEND_NAME='sapling-spend.params' SAPLING_OUTPUT_NAME='sapling-output.params' SAPLING_SPROUT_GROTH16_NAME='sprout-groth16.params' @@ -221,10 +219,6 @@ EOF cd "$PARAMS_DIR" - # Sprout parameters: - fetch_params "$SPROUT_PKEY_NAME" "$PARAMS_DIR/$SPROUT_PKEY_NAME" "8bc20a7f013b2b58970cddd2e7ea028975c88ae7ceb9259a5344a16bc2c0eef7" - fetch_params "$SPROUT_VKEY_NAME" "$PARAMS_DIR/$SPROUT_VKEY_NAME" "4bd498dae0aacfd8e98dc306338d017d9c08dd0918ead18172bd0aec2fc5df82" - # Sapling parameters: fetch_params "$SAPLING_SPEND_NAME" "$PARAMS_DIR/$SAPLING_SPEND_NAME" "8e48ffd23abb3a5fd9c5589204f32d9c31285a04b78096ba40a79b75677efc13" fetch_params "$SAPLING_OUTPUT_NAME" "$PARAMS_DIR/$SAPLING_OUTPUT_NAME" "2f0ebbcbb9bb0bcffe95a397e7eba89c29eb4dde6191c339db88570e3f3fb0e4" From c72578a784ba029e8c390839a212e254d2a2976d Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Sat, 13 Jul 2024 16:29:10 +0000 Subject: [PATCH 012/162] Remove OpenSSL dependencies --- .gitignore | 1 + COPYING | 5 - configure.ac | 17 - contrib/debian/copyright | 135 +------- depends/packages/openssl.mk | 116 ------- depends/packages/packages.mk | 2 +- doc/man/bitcoinz-cli.1 | 4 - doc/man/bitcoinz-tx.1 | 4 - doc/man/bitcoinzd.1 | 4 - libzcashconsensus.pc.in | 1 - src/Makefile.am | 18 +- src/Makefile.gtest.include | 39 ++- src/Makefile.test.include | 5 +- src/addrman.cpp | 8 +- src/addrman.h | 3 + src/compat.h | 10 + src/crypto/aes.cpp | 215 ++++++++++++ src/crypto/aes.h | 118 +++++++ src/crypto/ctaes/COPYING | 21 ++ src/crypto/ctaes/README.md | 41 +++ src/crypto/ctaes/bench.c | 170 ++++++++++ src/crypto/ctaes/ctaes.c | 556 +++++++++++++++++++++++++++++++ src/crypto/ctaes/ctaes.h | 41 +++ src/crypto/ctaes/test.c | 110 ++++++ src/init.cpp | 2 - src/key.h | 4 +- src/main.cpp | 11 +- src/memusage.h | 2 +- src/net.cpp | 3 +- src/net.h | 4 +- src/netbase.cpp | 4 +- src/random.cpp | 10 +- src/random.h | 37 +- src/support/cleanse.cpp | 29 +- src/support/cleanse.h | 2 + src/test/addrman_tests.cpp | 2 +- src/test/bignum.h | 193 ----------- src/test/coins_tests.cpp | 2 +- src/test/crypto_tests.cpp | 124 ++++++- src/test/pmt_tests.cpp | 2 +- src/test/prevector_tests.cpp | 8 +- src/test/sanity_tests.cpp | 2 +- src/test/scheduler_tests.cpp | 4 +- src/test/scriptnum10.h | 208 ++++++++++++ src/test/scriptnum_tests.cpp | 205 +++++++----- src/test/sighash_tests.cpp | 2 +- src/test/skiplist_tests.cpp | 2 +- src/test/test_bitcoin.cpp | 1 + src/test/test_random.h | 23 ++ src/test/util_tests.cpp | 2 +- src/txmempool.cpp | 2 +- src/txmempool.h | 1 + src/util.cpp | 47 +-- src/wallet/crypter.cpp | 97 +++--- src/wallet/crypter.h | 32 +- src/wallet/db.h | 43 +-- src/wallet/test/crypto_tests.cpp | 129 +++++++ src/wallet/wallet.cpp | 4 +- 58 files changed, 2122 insertions(+), 765 deletions(-) delete mode 100644 depends/packages/openssl.mk create mode 100644 src/crypto/aes.cpp create mode 100644 src/crypto/aes.h create mode 100644 src/crypto/ctaes/COPYING create mode 100644 src/crypto/ctaes/README.md create mode 100644 src/crypto/ctaes/bench.c create mode 100644 src/crypto/ctaes/ctaes.c create mode 100644 src/crypto/ctaes/ctaes.h create mode 100644 src/crypto/ctaes/test.c delete mode 100644 src/test/bignum.h create mode 100644 src/test/scriptnum10.h create mode 100644 src/test/test_random.h create mode 100644 src/wallet/test/crypto_tests.cpp diff --git a/.gitignore b/.gitignore index e8642c1dc..52f05ecd2 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ build-aux/test-driver config.log config.status configure +configure~ libtool src/config/bitcoin-config.h src/config/bitcoin-config.h.in diff --git a/COPYING b/COPYING index 2dd806c6c..6e5e8e4ad 100644 --- a/COPYING +++ b/COPYING @@ -28,11 +28,6 @@ Dependencies downloaded as part of the build process may be covered by other open-source licenses. For further details see 'contrib/debian/copyright'. -This product includes software developed by the OpenSSL Project for use in the -OpenSSL Toolkit (https://www.openssl.org/). This product includes cryptographic -software written by Eric Young (eay@cryptsoft.com). - - Although almost all of the Zcash code is licensed under "permissive" open source licenses, users and distributors should note that when built using the default build options, Zcash depends on Oracle Berkeley DB 6.2.x, which is licensed diff --git a/configure.ac b/configure.ac index 00e7fb9ae..df7035a5c 100644 --- a/configure.ac +++ b/configure.ac @@ -321,12 +321,7 @@ case $host in dnl It's safe to add these paths even if the functionality is disabled by dnl the user (--without-wallet for example). - openssl_prefix=`$BREW --prefix openssl 2>/dev/null` bdb_prefix=`$BREW --prefix berkeley-db4 2>/dev/null` - if test x$openssl_prefix != x; then - PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH" - export PKG_CONFIG_PATH - fi if test x$bdb_prefix != x; then CPPFLAGS="$CPPFLAGS -I$bdb_prefix/include" LIBS="$LIBS -L$bdb_prefix/lib" @@ -671,8 +666,6 @@ if test x$use_pkgconfig = xyes; then m4_ifdef( [PKG_CHECK_MODULES], [ - PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)]) - PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)]) if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then PKG_CHECK_MODULES([EVENT], [libevent],, [AC_MSG_ERROR(libevent not found.)]) if test x$TARGET_OS != xwindows; then @@ -692,14 +685,6 @@ if test x$use_pkgconfig = xyes; then ] ) else - # BUG: Fix this: - echo 'BUG: configure does not yet check for the following dependencies if pkg-config is not on the system: libcrypto++' - - AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing)) - AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing)) - - AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),) - AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing)) if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then AC_CHECK_HEADER([event2/event.h],, AC_MSG_ERROR(libevent headers missing),) @@ -872,8 +857,6 @@ AC_SUBST(LIBTOOL_APP_LDFLAGS) AC_SUBST(BOOST_LIBS) AC_SUBST(TESTDEFS) AC_SUBST(LEVELDB_TARGET_FLAGS) -AC_SUBST(CRYPTO_LIBS) -AC_SUBST(SSL_LIBS) AC_SUBST(EVENT_LIBS) AC_SUBST(EVENT_PTHREADS_LIBS) AC_SUBST(ZMQ_LIBS) diff --git a/contrib/debian/copyright b/contrib/debian/copyright index 27e65b74d..3c801afc3 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -28,10 +28,6 @@ Copyright: 1990, 2016 Oracle and/or its affiliates; 2000-2005 INRIA, France Telecom License: BDB -Files: depends/sources/openssl-*.tar.gz -Copyright: 1998-2016 The OpenSSL Project and 1995-1998 Eric Young -License: OpenSSL+SSLeay - Files: depends/sources/zeromq-*.tar.gz Copyright: 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. @@ -57,6 +53,15 @@ Files: depends/sources/utfcpp-*.tar.gz Copyright: 2006 Nemanja Trifunovic License: Boost-Software-License-1.0 +Files: src/crypto/ctaes/* +Copyright: Copyright (c) 2016 Pieter Wuille +License: Expat + +Files: src/secp256k1/* +Copyright: Copyright (c) 2013 Pieter Wuille +License: Expat +Comment: This copyright entry excludes files explicitly listed below. + Files: src/secp256k1/build-aux/m4/ax_jni_include_dir.m4 Copyright: 2008 Don Anderson License: GNU-All-permissive-License @@ -847,128 +852,6 @@ License: BDB * THE POSSIBILITY OF SUCH DAMAGE. */ -License: OpenSSL+SSLeay - The OpenSSL toolkit stays under a dual license, i.e. both the conditions of - the OpenSSL License and the original SSLeay license apply to the toolkit. - See below for the actual license texts. - . - OpenSSL License - --------------- - . - /* ==================================================================== - * Copyright (c) 1998-2016 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - . - Original SSLeay License - ----------------------- - . - /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - License: BSD-3clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/depends/packages/openssl.mk b/depends/packages/openssl.mk deleted file mode 100644 index f2d792bc1..000000000 --- a/depends/packages/openssl.mk +++ /dev/null @@ -1,116 +0,0 @@ -package=openssl -$(package)_version=1.1.1a -$(package)_download_path=https://www.openssl.org/source -$(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=fc20130f8b7cbd2fb918b2f14e2f429e109c31ddd0fb38fc5d71d9ffed3f9f41 - -define $(package)_set_vars -$(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" -$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl -$(package)_config_opts+=no-afalgeng -$(package)_config_opts+=no-asm -$(package)_config_opts+=no-async -$(package)_config_opts+=no-bf -$(package)_config_opts+=no-blake2 -$(package)_config_opts+=no-camellia -$(package)_config_opts+=no-capieng -$(package)_config_opts+=no-cast -$(package)_config_opts+=no-chacha -$(package)_config_opts+=no-cmac -$(package)_config_opts+=no-cms -$(package)_config_opts+=no-comp -$(package)_config_opts+=no-crypto-mdebug -$(package)_config_opts+=no-crypto-mdebug-backtrace -$(package)_config_opts+=no-ct -$(package)_config_opts+=no-des -$(package)_config_opts+=no-dgram -$(package)_config_opts+=no-dsa -$(package)_config_opts+=no-dso -$(package)_config_opts+=no-dtls -$(package)_config_opts+=no-dtls1 -$(package)_config_opts+=no-dtls1-method -$(package)_config_opts+=no-dynamic-engine -$(package)_config_opts+=no-ec2m -$(package)_config_opts+=no-ec_nistp_64_gcc_128 -$(package)_config_opts+=no-egd -$(package)_config_opts+=no-engine -$(package)_config_opts+=no-err -$(package)_config_opts+=no-gost -$(package)_config_opts+=no-heartbeats -$(package)_config_opts+=no-idea -$(package)_config_opts+=no-md2 -$(package)_config_opts+=no-md4 -$(package)_config_opts+=no-mdc2 -$(package)_config_opts+=no-multiblock -$(package)_config_opts+=no-nextprotoneg -$(package)_config_opts+=no-ocb -$(package)_config_opts+=no-ocsp -$(package)_config_opts+=no-poly1305 -$(package)_config_opts+=no-posix-io -$(package)_config_opts+=no-psk -$(package)_config_opts+=no-rc2 -$(package)_config_opts+=no-rc4 -$(package)_config_opts+=no-rc5 -$(package)_config_opts+=no-rdrand -$(package)_config_opts+=no-rfc3779 -$(package)_config_opts+=no-rmd160 -$(package)_config_opts+=no-scrypt -$(package)_config_opts+=no-sctp -$(package)_config_opts+=no-seed -$(package)_config_opts+=no-shared -$(package)_config_opts+=no-sock -$(package)_config_opts+=no-srp -$(package)_config_opts+=no-srtp -$(package)_config_opts+=no-ssl -$(package)_config_opts+=no-ssl3 -$(package)_config_opts+=no-ssl3-method -$(package)_config_opts+=no-ssl-trace -$(package)_config_opts+=no-stdio -$(package)_config_opts+=no-tls -$(package)_config_opts+=no-tls1 -$(package)_config_opts+=no-tls1-method -$(package)_config_opts+=no-ts -$(package)_config_opts+=no-ui -$(package)_config_opts+=no-unit-test -$(package)_config_opts+=no-weak-ssl-ciphers -$(package)_config_opts+=no-whirlpool -$(package)_config_opts+=no-zlib -$(package)_config_opts+=no-zlib-dynamic -$(package)_config_opts+=$($(package)_cflags) $($(package)_cppflags) -$(package)_config_opts+=-DPURIFY -$(package)_config_opts_linux=-fPIC -Wa,--noexecstack -$(package)_config_opts_x86_64_linux=linux-x86_64 -$(package)_config_opts_freebsd=-fPIC -Wa,--noexecstack -$(package)_config_opts_i686_linux=linux-generic32 -$(package)_config_opts_arm_linux=linux-generic32 -$(package)_config_opts_aarch64_linux=linux-generic64 -$(package)_config_opts_mipsel_linux=linux-generic32 -$(package)_config_opts_mips_linux=linux-generic32 -$(package)_config_opts_powerpc_linux=linux-generic32 -$(package)_config_opts_x86_64_darwin=darwin64-x86_64-cc -$(package)_config_opts_x86_64_freebsd=BSD-x86_64 -$(package)_config_opts_i686_freebsd=BSD-generic32 -$(package)_config_opts_x86_64_mingw32=mingw64 -$(package)_config_opts_i686_mingw32=mingw -endef - -define $(package)_preprocess_cmds - sed -i.old 's/built on: $$$$date/built on: date not available/' util/mkbuildinf.pl && \ - sed -i.old "s|\"engines\", \"apps\", \"test\"|\"engines\"|" Configure -endef - -define $(package)_config_cmds - ./Configure $($(package)_config_opts) -endef - -define $(package)_build_cmds - $(MAKE) -j1 build_libs libcrypto.pc libssl.pc openssl.pc -endef - -define $(package)_stage_cmds - $(MAKE) DESTDIR=$($(package)_staging_dir) -j1 install_sw -endef - -define $(package)_postprocess_cmds - rm -rf share bin etc -endef diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 6f9b1883d..4297566e6 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -35,7 +35,7 @@ rust_crates := \ rust_packages := rust $(rust_crates) librustzcash proton_packages := proton zcash_packages := libsodium utfcpp -packages := boost openssl libevent zeromq $(zcash_packages) googletest +packages := boost libevent zeromq $(zcash_packages) googletest native_packages := native_ccache wallet_packages=bdb diff --git a/doc/man/bitcoinz-cli.1 b/doc/man/bitcoinz-cli.1 index 34c461886..896a33996 100644 --- a/doc/man/bitcoinz-cli.1 +++ b/doc/man/bitcoinz-cli.1 @@ -83,7 +83,3 @@ This is experimental software. Distributed under the MIT software license, see the accompanying file COPYING or . - -This product includes software developed by the OpenSSL Project for use in the -OpenSSL Toolkit and cryptographic software written -by Eric Young. diff --git a/doc/man/bitcoinz-tx.1 b/doc/man/bitcoinz-tx.1 index 9eb45c1c9..fac69d5c3 100644 --- a/doc/man/bitcoinz-tx.1 +++ b/doc/man/bitcoinz-tx.1 @@ -96,7 +96,3 @@ This is experimental software. Distributed under the MIT software license, see the accompanying file COPYING or . - -This product includes software developed by the OpenSSL Project for use in the -OpenSSL Toolkit and cryptographic software written -by Eric Young. diff --git a/doc/man/bitcoinzd.1 b/doc/man/bitcoinzd.1 index ee85749ca..fad42d93f 100644 --- a/doc/man/bitcoinzd.1 +++ b/doc/man/bitcoinzd.1 @@ -496,7 +496,3 @@ This is experimental software. Distributed under the MIT software license, see the accompanying file COPYING or . - -This product includes software developed by the OpenSSL Project for use in the -OpenSSL Toolkit and cryptographic software written -by Eric Young. diff --git a/libzcashconsensus.pc.in b/libzcashconsensus.pc.in index 5cb2d05e3..7391bb9da 100644 --- a/libzcashconsensus.pc.in +++ b/libzcashconsensus.pc.in @@ -8,4 +8,3 @@ Description: Library for the Zcash consensus protocol. Version: @PACKAGE_VERSION@ Libs: -L${libdir} -lzcashconsensus Cflags: -I${includedir} -Requires.private: libcrypto diff --git a/src/Makefile.am b/src/Makefile.am index 32a31b677..f683f6c69 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,7 @@ $(LIBLEVELDB) $(LIBMEMENV): endif BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config -BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS) +BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) BITCOIN_INCLUDES += -I$(srcdir)/secp256k1/include BITCOIN_INCLUDES += -I$(srcdir)/univalue/include @@ -321,6 +321,8 @@ libbitcoin_wallet_a_SOURCES = \ crypto_libbitcoin_crypto_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_CONFIG_INCLUDES) crypto_libbitcoin_crypto_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) crypto_libbitcoin_crypto_a_SOURCES = \ + crypto/aes.cpp \ + crypto/aes.h \ crypto/common.h \ crypto/equihash.cpp \ crypto/equihash.h \ @@ -452,8 +454,6 @@ bitcoinzd_LDADD = \ bitcoinzd_LDADD += \ $(BOOST_LIBS) \ $(BDB_LIBS) \ - $(SSL_LIBS) \ - $(CRYPTO_LIBS) \ $(EVENT_PTHREADS_LIBS) \ $(EVENT_LIBS) \ $(ZMQ_LIBS) \ @@ -476,8 +476,6 @@ bitcoinz_cli_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_UTIL) \ $(BOOST_LIBS) \ - $(SSL_LIBS) \ - $(CRYPTO_LIBS) \ $(EVENT_LIBS) \ $(LIBZCASH) \ $(LIBBITCOIN_CRYPTO) \ @@ -504,7 +502,7 @@ bitcoinz_tx_LDADD = \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) -bitcoinz_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) +bitcoinz_tx_LDADD += $(BOOST_LIBS) # # zcash protocol primitives # @@ -558,11 +556,17 @@ libzcashconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) endif # +CTAES_DIST = crypto/ctaes/bench.c +CTAES_DIST += crypto/ctaes/ctaes.c +CTAES_DIST += crypto/ctaes/ctaes.h +CTAES_DIST += crypto/ctaes/README.md +CTAES_DIST += crypto/ctaes/test.c + CLEANFILES = leveldb/libleveldb.a leveldb/libmemenv.a *.gcda *.gcno */*.gcno wallet/*/*.gcno DISTCLEANFILES = obj/build.h -EXTRA_DIST = leveldb +EXTRA_DIST = leveldb $(CTAES_DIST) clean-local: -$(MAKE) -C leveldb clean diff --git a/src/Makefile.gtest.include b/src/Makefile.gtest.include index b583ff5ea..bfb855da9 100644 --- a/src/Makefile.gtest.include +++ b/src/Makefile.gtest.include @@ -59,20 +59,33 @@ endif zcash_gtest_CPPFLAGS = $(AM_CPPFLAGS) -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DSTATIC $(BITCOIN_INCLUDES) zcash_gtest_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -zcash_gtest_LDADD = -lgtest -lgmock $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \ - $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) -if ENABLE_ZMQ -zcash_gtest_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) -endif -if ENABLE_WALLET -zcash_gtest_LDADD += $(LIBBITCOIN_WALLET) -endif +zcash_gtest_LDADD = \ + -lgtest -lgmock \ + $(LIBBITCOIN_SERVER) \ + $(LIBBITCOIN_CLI) \ + $(LIBBITCOIN_WALLET) \ + $(LIBBITCOIN_COMMON) \ + $(LIBBITCOIN_UTIL) \ + $(LIBBITCOIN_ZMQ) \ + $(LIBBITCOIN_PROTON) \ + $(LIBBITCOIN_CRYPTO) \ + $(LIBUNIVALUE) \ + $(LIBLEVELDB) \ + $(LIBMEMENV) \ + $(LIBSECP256K1) -zcash_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) - -if ENABLE_PROTON -zcash_gtest_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) -endif +zcash_gtest_LDADD += \ + $(LIBZCASH_CONSENSUS) \ + $(BOOST_LIBS) \ + $(BOOST_UNIT_TEST_FRAMEWORK_LIB) \ + $(BDB_LIBS) \ + $(EVENT_PTHREADS_LIBS) \ + $(EVENT_LIBS) \ + $(ZMQ_LIBS) \ + $(PROTON_LIBS) \ + $(LIBZCASH) \ + $(LIBRUSTZCASH) \ + $(LIBZCASH_LIBS) zcash_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static diff --git a/src/Makefile.test.include b/src/Makefile.test.include index e4f3540d8..9edcb5a32 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -46,7 +46,7 @@ GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.r BITCOIN_TESTS =\ test/arith_uint256_tests.cpp \ - test/bignum.h \ + test/scriptnum10.h \ test/addrman_tests.cpp \ test/alert_tests.cpp \ test/allocator_tests.cpp \ @@ -104,6 +104,7 @@ BITCOIN_TESTS =\ if ENABLE_WALLET BITCOIN_TESTS += \ test/accounting_tests.cpp \ + wallet/test/crypto_tests.cpp \ wallet/test/wallet_tests.cpp \ test/rpc_wallet_tests.cpp endif @@ -118,7 +119,7 @@ test_test_bitcoin_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_C $(LIBLEVELDB) $(LIBMEMENV) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -test_test_bitcoin_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) +test_test_bitcoin_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(LIBZCASH) $(LIBSNARK) $(LIBZCASH_LIBS) test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static if ENABLE_ZMQ diff --git a/src/addrman.cpp b/src/addrman.cpp index 5ae0f1734..33b0c5481 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -352,8 +352,8 @@ CAddrInfo CAddrMan::Select_(bool newOnly) int nKBucket = RandomInt(ADDRMAN_TRIED_BUCKET_COUNT); int nKBucketPos = RandomInt(ADDRMAN_BUCKET_SIZE); while (vvTried[nKBucket][nKBucketPos] == -1) { - nKBucket = (nKBucket + insecure_rand()) % ADDRMAN_TRIED_BUCKET_COUNT; - nKBucketPos = (nKBucketPos + insecure_rand()) % ADDRMAN_BUCKET_SIZE; + nKBucket = (nKBucket + insecure_rand.rand32()) % ADDRMAN_TRIED_BUCKET_COUNT; + nKBucketPos = (nKBucketPos + insecure_rand.rand32()) % ADDRMAN_BUCKET_SIZE; if (i++ > kMaxRetries) return CAddrInfo(); if (i % kRetriesBetweenSleep == 0 && !nKey.IsNull()) @@ -374,8 +374,8 @@ CAddrInfo CAddrMan::Select_(bool newOnly) int nUBucket = RandomInt(ADDRMAN_NEW_BUCKET_COUNT); int nUBucketPos = RandomInt(ADDRMAN_BUCKET_SIZE); while (vvNew[nUBucket][nUBucketPos] == -1) { - nUBucket = (nUBucket + insecure_rand()) % ADDRMAN_NEW_BUCKET_COUNT; - nUBucketPos = (nUBucketPos + insecure_rand()) % ADDRMAN_BUCKET_SIZE; + nUBucket = (nUBucket + insecure_rand.rand32()) % ADDRMAN_NEW_BUCKET_COUNT; + nUBucketPos = (nUBucketPos + insecure_rand.rand32()) % ADDRMAN_BUCKET_SIZE; if (i++ > kMaxRetries) return CAddrInfo(); if (i % kRetriesBetweenSleep == 0 && !nKey.IsNull()) diff --git a/src/addrman.h b/src/addrman.h index bee1bd9f5..2fd80e9f4 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -203,6 +203,9 @@ class CAddrMan //! secret key to randomize bucket select with uint256 nKey; + //! Source of random numbers for randomization in inner loops + FastRandomContext insecure_rand; + //! Find an entry. CAddrInfo* Find(const CNetAddr& addr, int *pnId = NULL); diff --git a/src/compat.h b/src/compat.h index b8c238f22..4d6027c67 100644 --- a/src/compat.h +++ b/src/compat.h @@ -31,6 +31,7 @@ #include #include #include +#include #else #include #include @@ -72,6 +73,15 @@ typedef u_int SOCKET; #else #define MAX_PATH 1024 #endif +#ifdef _MSC_VER +#if !defined(ssize_t) +#ifdef _WIN64 +typedef int64_t ssize_t; +#else +typedef int32_t ssize_t; +#endif +#endif +#endif // As Solaris does not have the MSG_NOSIGNAL flag for send(2) syscall, it is defined as 0 #if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL) diff --git a/src/crypto/aes.cpp b/src/crypto/aes.cpp new file mode 100644 index 000000000..8bd472e85 --- /dev/null +++ b/src/crypto/aes.cpp @@ -0,0 +1,215 @@ +// Copyright (c) 2016 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "aes.h" +#include "crypto/common.h" + +#include +#include + +extern "C" { +#include "crypto/ctaes/ctaes.c" +} + +AES128Encrypt::AES128Encrypt(const unsigned char key[16]) +{ + AES128_init(&ctx, key); +} + +AES128Encrypt::~AES128Encrypt() +{ + memset(&ctx, 0, sizeof(ctx)); +} + +void AES128Encrypt::Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const +{ + AES128_encrypt(&ctx, 1, ciphertext, plaintext); +} + +AES128Decrypt::AES128Decrypt(const unsigned char key[16]) +{ + AES128_init(&ctx, key); +} + +AES128Decrypt::~AES128Decrypt() +{ + memset(&ctx, 0, sizeof(ctx)); +} + +void AES128Decrypt::Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const +{ + AES128_decrypt(&ctx, 1, plaintext, ciphertext); +} + +AES256Encrypt::AES256Encrypt(const unsigned char key[32]) +{ + AES256_init(&ctx, key); +} + +AES256Encrypt::~AES256Encrypt() +{ + memset(&ctx, 0, sizeof(ctx)); +} + +void AES256Encrypt::Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const +{ + AES256_encrypt(&ctx, 1, ciphertext, plaintext); +} + +AES256Decrypt::AES256Decrypt(const unsigned char key[32]) +{ + AES256_init(&ctx, key); +} + +AES256Decrypt::~AES256Decrypt() +{ + memset(&ctx, 0, sizeof(ctx)); +} + +void AES256Decrypt::Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const +{ + AES256_decrypt(&ctx, 1, plaintext, ciphertext); +} + +template +static int CBCEncrypt(const T& enc, const unsigned char iv[AES_BLOCKSIZE], const unsigned char* data, int size, bool pad, unsigned char* out) +{ + int written = 0; + int padsize = size % AES_BLOCKSIZE; + unsigned char mixed[AES_BLOCKSIZE]; + + if (!data || !size || !out) + return 0; + + if (!pad && padsize != 0) + return 0; + + memcpy(mixed, iv, AES_BLOCKSIZE); + + // Write all but the last block + while (written + AES_BLOCKSIZE <= size) { + for (int i = 0; i != AES_BLOCKSIZE; i++) + mixed[i] ^= *data++; + enc.Encrypt(out + written, mixed); + memcpy(mixed, out + written, AES_BLOCKSIZE); + written += AES_BLOCKSIZE; + } + if (pad) { + // For all that remains, pad each byte with the value of the remaining + // space. If there is none, pad by a full block. + for (int i = 0; i != padsize; i++) + mixed[i] ^= *data++; + for (int i = padsize; i != AES_BLOCKSIZE; i++) + mixed[i] ^= AES_BLOCKSIZE - padsize; + enc.Encrypt(out + written, mixed); + written += AES_BLOCKSIZE; + } + return written; +} + +template +static int CBCDecrypt(const T& dec, const unsigned char iv[AES_BLOCKSIZE], const unsigned char* data, int size, bool pad, unsigned char* out) +{ + unsigned char padsize = 0; + int written = 0; + bool fail = false; + const unsigned char* prev = iv; + + if (!data || !size || !out) + return 0; + + if (size % AES_BLOCKSIZE != 0) + return 0; + + // Decrypt all data. Padding will be checked in the output. + while (written != size) { + dec.Decrypt(out, data + written); + for (int i = 0; i != AES_BLOCKSIZE; i++) + *out++ ^= prev[i]; + prev = data + written; + written += AES_BLOCKSIZE; + } + + // When decrypting padding, attempt to run in constant-time + if (pad) { + // If used, padding size is the value of the last decrypted byte. For + // it to be valid, It must be between 1 and AES_BLOCKSIZE. + padsize = *--out; + fail = !padsize | (padsize > AES_BLOCKSIZE); + + // If not well-formed, treat it as though there's no padding. + padsize *= !fail; + + // All padding must equal the last byte otherwise it's not well-formed + for (int i = AES_BLOCKSIZE; i != 0; i--) + fail |= ((i > AES_BLOCKSIZE - padsize) & (*out-- != padsize)); + + written -= padsize; + } + return written * !fail; +} + +AES256CBCEncrypt::AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn) + : enc(key), pad(padIn) +{ + memcpy(iv, ivIn, AES_BLOCKSIZE); +} + +int AES256CBCEncrypt::Encrypt(const unsigned char* data, int size, unsigned char* out) const +{ + return CBCEncrypt(enc, iv, data, size, pad, out); +} + +AES256CBCEncrypt::~AES256CBCEncrypt() +{ + memset(iv, 0, sizeof(iv)); +} + +AES256CBCDecrypt::AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn) + : dec(key), pad(padIn) +{ + memcpy(iv, ivIn, AES_BLOCKSIZE); +} + +int AES256CBCDecrypt::Decrypt(const unsigned char* data, int size, unsigned char* out) const +{ + return CBCDecrypt(dec, iv, data, size, pad, out); +} + +AES256CBCDecrypt::~AES256CBCDecrypt() +{ + memset(iv, 0, sizeof(iv)); +} + +AES128CBCEncrypt::AES128CBCEncrypt(const unsigned char key[AES128_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn) + : enc(key), pad(padIn) +{ + memcpy(iv, ivIn, AES_BLOCKSIZE); +} + +AES128CBCEncrypt::~AES128CBCEncrypt() +{ + memset(iv, 0, AES_BLOCKSIZE); +} + +int AES128CBCEncrypt::Encrypt(const unsigned char* data, int size, unsigned char* out) const +{ + return CBCEncrypt(enc, iv, data, size, pad, out); +} + +AES128CBCDecrypt::AES128CBCDecrypt(const unsigned char key[AES128_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn) + : dec(key), pad(padIn) +{ + memcpy(iv, ivIn, AES_BLOCKSIZE); +} + +AES128CBCDecrypt::~AES128CBCDecrypt() +{ + memset(iv, 0, AES_BLOCKSIZE); +} + +int AES128CBCDecrypt::Decrypt(const unsigned char* data, int size, unsigned char* out) const +{ + return CBCDecrypt(dec, iv, data, size, pad, out); +} diff --git a/src/crypto/aes.h b/src/crypto/aes.h new file mode 100644 index 000000000..8cae357c1 --- /dev/null +++ b/src/crypto/aes.h @@ -0,0 +1,118 @@ +// Copyright (c) 2015 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// +// C++ wrapper around ctaes, a constant-time AES implementation + +#ifndef BITCOIN_CRYPTO_AES_H +#define BITCOIN_CRYPTO_AES_H + +extern "C" { +#include "crypto/ctaes/ctaes.h" +} + +static const int AES_BLOCKSIZE = 16; +static const int AES128_KEYSIZE = 16; +static const int AES256_KEYSIZE = 32; + +/** An encryption class for AES-128. */ +class AES128Encrypt +{ +private: + AES128_ctx ctx; + +public: + AES128Encrypt(const unsigned char key[16]); + ~AES128Encrypt(); + void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const; +}; + +/** A decryption class for AES-128. */ +class AES128Decrypt +{ +private: + AES128_ctx ctx; + +public: + AES128Decrypt(const unsigned char key[16]); + ~AES128Decrypt(); + void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const; +}; + +/** An encryption class for AES-256. */ +class AES256Encrypt +{ +private: + AES256_ctx ctx; + +public: + AES256Encrypt(const unsigned char key[32]); + ~AES256Encrypt(); + void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const; +}; + +/** A decryption class for AES-256. */ +class AES256Decrypt +{ +private: + AES256_ctx ctx; + +public: + AES256Decrypt(const unsigned char key[32]); + ~AES256Decrypt(); + void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const; +}; + +class AES256CBCEncrypt +{ +public: + AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn); + ~AES256CBCEncrypt(); + int Encrypt(const unsigned char* data, int size, unsigned char* out) const; + +private: + const AES256Encrypt enc; + const bool pad; + unsigned char iv[AES_BLOCKSIZE]; +}; + +class AES256CBCDecrypt +{ +public: + AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn); + ~AES256CBCDecrypt(); + int Decrypt(const unsigned char* data, int size, unsigned char* out) const; + +private: + const AES256Decrypt dec; + const bool pad; + unsigned char iv[AES_BLOCKSIZE]; +}; + +class AES128CBCEncrypt +{ +public: + AES128CBCEncrypt(const unsigned char key[AES128_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn); + ~AES128CBCEncrypt(); + int Encrypt(const unsigned char* data, int size, unsigned char* out) const; + +private: + const AES128Encrypt enc; + const bool pad; + unsigned char iv[AES_BLOCKSIZE]; +}; + +class AES128CBCDecrypt +{ +public: + AES128CBCDecrypt(const unsigned char key[AES128_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn); + ~AES128CBCDecrypt(); + int Decrypt(const unsigned char* data, int size, unsigned char* out) const; + +private: + const AES128Decrypt dec; + const bool pad; + unsigned char iv[AES_BLOCKSIZE]; +}; + +#endif // BITCOIN_CRYPTO_AES_H diff --git a/src/crypto/ctaes/COPYING b/src/crypto/ctaes/COPYING new file mode 100644 index 000000000..415b202a2 --- /dev/null +++ b/src/crypto/ctaes/COPYING @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Pieter Wuille + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/crypto/ctaes/README.md b/src/crypto/ctaes/README.md new file mode 100644 index 000000000..0e7fe1775 --- /dev/null +++ b/src/crypto/ctaes/README.md @@ -0,0 +1,41 @@ +ctaes +===== + +Simple C module for constant-time AES encryption and decryption. + +Features: +* Simple, pure C code without any dependencies. +* No tables or data-dependent branches whatsoever, but using bit sliced approach from https://eprint.iacr.org/2009/129.pdf. +* Very small object code: slightly over 4k of executable code when compiled with -Os. +* Slower than implementations based on precomputed tables or specialized instructions, but can do ~15 MB/s on modern CPUs. + +Performance +----------- + +Compiled with GCC 5.3.1 with -O3, on an Intel(R) Core(TM) i7-4800MQ CPU, numbers in CPU cycles: + +| Algorithm | Key schedule | Encryption per byte | Decryption per byte | +| --------- | ------------:| -------------------:| -------------------:| +| AES-128 | 2.8k | 154 | 161 | +| AES-192 | 3.1k | 169 | 181 | +| AES-256 | 4.0k | 191 | 203 | + +Build steps +----------- + +Object code: + + $ gcc -O3 ctaes.c -c -o ctaes.o + +Tests: + + $ gcc -O3 ctaes.c test.c -o test + +Benchmark: + + $ gcc -O3 ctaes.c bench.c -o bench + +Review +------ + +Results of a formal review of the code can be found in http://bitcoin.sipa.be/ctaes/review.zip diff --git a/src/crypto/ctaes/bench.c b/src/crypto/ctaes/bench.c new file mode 100644 index 000000000..a86df496c --- /dev/null +++ b/src/crypto/ctaes/bench.c @@ -0,0 +1,170 @@ +#include +#include +#include "sys/time.h" + +#include "ctaes.h" + +static double gettimedouble(void) { + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_usec * 0.000001 + tv.tv_sec; +} + +static void print_number(double x) { + double y = x; + int c = 0; + if (y < 0.0) { + y = -y; + } + while (y < 100.0) { + y *= 10.0; + c++; + } + printf("%.*f", c, x); +} + +static void run_benchmark(char *name, void (*benchmark)(void*), void (*setup)(void*), void (*teardown)(void*), void* data, int count, int iter) { + int i; + double min = HUGE_VAL; + double sum = 0.0; + double max = 0.0; + for (i = 0; i < count; i++) { + double begin, total; + if (setup != NULL) { + setup(data); + } + begin = gettimedouble(); + benchmark(data); + total = gettimedouble() - begin; + if (teardown != NULL) { + teardown(data); + } + if (total < min) { + min = total; + } + if (total > max) { + max = total; + } + sum += total; + } + printf("%s: min ", name); + print_number(min * 1000000000.0 / iter); + printf("ns / avg "); + print_number((sum / count) * 1000000000.0 / iter); + printf("ns / max "); + print_number(max * 1000000000.0 / iter); + printf("ns\n"); +} + +static void bench_AES128_init(void* data) { + AES128_ctx* ctx = (AES128_ctx*)data; + int i; + for (i = 0; i < 50000; i++) { + AES128_init(ctx, (unsigned char*)ctx); + } +} + +static void bench_AES128_encrypt_setup(void* data) { + AES128_ctx* ctx = (AES128_ctx*)data; + static const unsigned char key[16] = {0}; + AES128_init(ctx, key); +} + +static void bench_AES128_encrypt(void* data) { + const AES128_ctx* ctx = (const AES128_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES128_encrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES128_decrypt(void* data) { + const AES128_ctx* ctx = (const AES128_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES128_decrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES192_init(void* data) { + AES192_ctx* ctx = (AES192_ctx*)data; + int i; + for (i = 0; i < 50000; i++) { + AES192_init(ctx, (unsigned char*)ctx); + } +} + +static void bench_AES192_encrypt_setup(void* data) { + AES192_ctx* ctx = (AES192_ctx*)data; + static const unsigned char key[16] = {0}; + AES192_init(ctx, key); +} + +static void bench_AES192_encrypt(void* data) { + const AES192_ctx* ctx = (const AES192_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES192_encrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES192_decrypt(void* data) { + const AES192_ctx* ctx = (const AES192_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES192_decrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES256_init(void* data) { + AES256_ctx* ctx = (AES256_ctx*)data; + int i; + for (i = 0; i < 50000; i++) { + AES256_init(ctx, (unsigned char*)ctx); + } +} + + +static void bench_AES256_encrypt_setup(void* data) { + AES256_ctx* ctx = (AES256_ctx*)data; + static const unsigned char key[16] = {0}; + AES256_init(ctx, key); +} + +static void bench_AES256_encrypt(void* data) { + const AES256_ctx* ctx = (const AES256_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES256_encrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES256_decrypt(void* data) { + const AES256_ctx* ctx = (const AES256_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES256_decrypt(ctx, 1, scratch, scratch); + } +} + +int main(void) { + AES128_ctx ctx128; + AES192_ctx ctx192; + AES256_ctx ctx256; + run_benchmark("aes128_init", bench_AES128_init, NULL, NULL, &ctx128, 20, 50000); + run_benchmark("aes128_encrypt_byte", bench_AES128_encrypt, bench_AES128_encrypt_setup, NULL, &ctx128, 20, 4000000); + run_benchmark("aes128_decrypt_byte", bench_AES128_decrypt, bench_AES128_encrypt_setup, NULL, &ctx128, 20, 4000000); + run_benchmark("aes192_init", bench_AES192_init, NULL, NULL, &ctx192, 20, 50000); + run_benchmark("aes192_encrypt_byte", bench_AES192_encrypt, bench_AES192_encrypt_setup, NULL, &ctx192, 20, 4000000); + run_benchmark("aes192_decrypt_byte", bench_AES192_decrypt, bench_AES192_encrypt_setup, NULL, &ctx192, 20, 4000000); + run_benchmark("aes256_init", bench_AES256_init, NULL, NULL, &ctx256, 20, 50000); + run_benchmark("aes256_encrypt_byte", bench_AES256_encrypt, bench_AES256_encrypt_setup, NULL, &ctx256, 20, 4000000); + run_benchmark("aes256_decrypt_byte", bench_AES256_decrypt, bench_AES256_encrypt_setup, NULL, &ctx256, 20, 4000000); + return 0; +} diff --git a/src/crypto/ctaes/ctaes.c b/src/crypto/ctaes/ctaes.c new file mode 100644 index 000000000..55962bf25 --- /dev/null +++ b/src/crypto/ctaes/ctaes.c @@ -0,0 +1,556 @@ + /********************************************************************* + * Copyright (c) 2016 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +/* Constant time, unoptimized, concise, plain C, AES implementation + * Based On: + * Emilia Kasper and Peter Schwabe, Faster and Timing-Attack Resistant AES-GCM + * http://www.iacr.org/archive/ches2009/57470001/57470001.pdf + * But using 8 16-bit integers representing a single AES state rather than 8 128-bit + * integers representing 8 AES states. + */ + +#include "ctaes.h" + +/* Slice variable slice_i contains the i'th bit of the 16 state variables in this order: + * 0 1 2 3 + * 4 5 6 7 + * 8 9 10 11 + * 12 13 14 15 + */ + +/** Convert a byte to sliced form, storing it corresponding to given row and column in s */ +static void LoadByte(AES_state* s, unsigned char byte, int r, int c) { + int i; + for (i = 0; i < 8; i++) { + s->slice[i] |= (byte & 1) << (r * 4 + c); + byte >>= 1; + } +} + +/** Load 16 bytes of data into 8 sliced integers */ +static void LoadBytes(AES_state *s, const unsigned char* data16) { + int c; + for (c = 0; c < 4; c++) { + int r; + for (r = 0; r < 4; r++) { + LoadByte(s, *(data16++), r, c); + } + } +} + +/** Convert 8 sliced integers into 16 bytes of data */ +static void SaveBytes(unsigned char* data16, const AES_state *s) { + int c; + for (c = 0; c < 4; c++) { + int r; + for (r = 0; r < 4; r++) { + int b; + uint8_t v = 0; + for (b = 0; b < 8; b++) { + v |= ((s->slice[b] >> (r * 4 + c)) & 1) << b; + } + *(data16++) = v; + } + } +} + +/* S-box implementation based on the gate logic from: + * Joan Boyar and Rene Peralta, A depth-16 circuit for the AES S-box. + * https://eprint.iacr.org/2011/332.pdf +*/ +static void SubBytes(AES_state *s, int inv) { + /* Load the bit slices */ + uint16_t U0 = s->slice[7], U1 = s->slice[6], U2 = s->slice[5], U3 = s->slice[4]; + uint16_t U4 = s->slice[3], U5 = s->slice[2], U6 = s->slice[1], U7 = s->slice[0]; + + uint16_t T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16; + uint16_t T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, D; + uint16_t M1, M6, M11, M13, M15, M20, M21, M22, M23, M25, M37, M38, M39, M40; + uint16_t M41, M42, M43, M44, M45, M46, M47, M48, M49, M50, M51, M52, M53, M54; + uint16_t M55, M56, M57, M58, M59, M60, M61, M62, M63; + + if (inv) { + uint16_t R5, R13, R17, R18, R19; + /* Undo linear postprocessing */ + T23 = U0 ^ U3; + T22 = ~(U1 ^ U3); + T2 = ~(U0 ^ U1); + T1 = U3 ^ U4; + T24 = ~(U4 ^ U7); + R5 = U6 ^ U7; + T8 = ~(U1 ^ T23); + T19 = T22 ^ R5; + T9 = ~(U7 ^ T1); + T10 = T2 ^ T24; + T13 = T2 ^ R5; + T3 = T1 ^ R5; + T25 = ~(U2 ^ T1); + R13 = U1 ^ U6; + T17 = ~(U2 ^ T19); + T20 = T24 ^ R13; + T4 = U4 ^ T8; + R17 = ~(U2 ^ U5); + R18 = ~(U5 ^ U6); + R19 = ~(U2 ^ U4); + D = U0 ^ R17; + T6 = T22 ^ R17; + T16 = R13 ^ R19; + T27 = T1 ^ R18; + T15 = T10 ^ T27; + T14 = T10 ^ R18; + T26 = T3 ^ T16; + } else { + /* Linear preprocessing. */ + T1 = U0 ^ U3; + T2 = U0 ^ U5; + T3 = U0 ^ U6; + T4 = U3 ^ U5; + T5 = U4 ^ U6; + T6 = T1 ^ T5; + T7 = U1 ^ U2; + T8 = U7 ^ T6; + T9 = U7 ^ T7; + T10 = T6 ^ T7; + T11 = U1 ^ U5; + T12 = U2 ^ U5; + T13 = T3 ^ T4; + T14 = T6 ^ T11; + T15 = T5 ^ T11; + T16 = T5 ^ T12; + T17 = T9 ^ T16; + T18 = U3 ^ U7; + T19 = T7 ^ T18; + T20 = T1 ^ T19; + T21 = U6 ^ U7; + T22 = T7 ^ T21; + T23 = T2 ^ T22; + T24 = T2 ^ T10; + T25 = T20 ^ T17; + T26 = T3 ^ T16; + T27 = T1 ^ T12; + D = U7; + } + + /* Non-linear transformation (shared between the forward and backward case) */ + M1 = T13 & T6; + M6 = T3 & T16; + M11 = T1 & T15; + M13 = (T4 & T27) ^ M11; + M15 = (T2 & T10) ^ M11; + M20 = T14 ^ M1 ^ (T23 & T8) ^ M13; + M21 = (T19 & D) ^ M1 ^ T24 ^ M15; + M22 = T26 ^ M6 ^ (T22 & T9) ^ M13; + M23 = (T20 & T17) ^ M6 ^ M15 ^ T25; + M25 = M22 & M20; + M37 = M21 ^ ((M20 ^ M21) & (M23 ^ M25)); + M38 = M20 ^ M25 ^ (M21 | (M20 & M23)); + M39 = M23 ^ ((M22 ^ M23) & (M21 ^ M25)); + M40 = M22 ^ M25 ^ (M23 | (M21 & M22)); + M41 = M38 ^ M40; + M42 = M37 ^ M39; + M43 = M37 ^ M38; + M44 = M39 ^ M40; + M45 = M42 ^ M41; + M46 = M44 & T6; + M47 = M40 & T8; + M48 = M39 & D; + M49 = M43 & T16; + M50 = M38 & T9; + M51 = M37 & T17; + M52 = M42 & T15; + M53 = M45 & T27; + M54 = M41 & T10; + M55 = M44 & T13; + M56 = M40 & T23; + M57 = M39 & T19; + M58 = M43 & T3; + M59 = M38 & T22; + M60 = M37 & T20; + M61 = M42 & T1; + M62 = M45 & T4; + M63 = M41 & T2; + + if (inv){ + /* Undo linear preprocessing */ + uint16_t P0 = M52 ^ M61; + uint16_t P1 = M58 ^ M59; + uint16_t P2 = M54 ^ M62; + uint16_t P3 = M47 ^ M50; + uint16_t P4 = M48 ^ M56; + uint16_t P5 = M46 ^ M51; + uint16_t P6 = M49 ^ M60; + uint16_t P7 = P0 ^ P1; + uint16_t P8 = M50 ^ M53; + uint16_t P9 = M55 ^ M63; + uint16_t P10 = M57 ^ P4; + uint16_t P11 = P0 ^ P3; + uint16_t P12 = M46 ^ M48; + uint16_t P13 = M49 ^ M51; + uint16_t P14 = M49 ^ M62; + uint16_t P15 = M54 ^ M59; + uint16_t P16 = M57 ^ M61; + uint16_t P17 = M58 ^ P2; + uint16_t P18 = M63 ^ P5; + uint16_t P19 = P2 ^ P3; + uint16_t P20 = P4 ^ P6; + uint16_t P22 = P2 ^ P7; + uint16_t P23 = P7 ^ P8; + uint16_t P24 = P5 ^ P7; + uint16_t P25 = P6 ^ P10; + uint16_t P26 = P9 ^ P11; + uint16_t P27 = P10 ^ P18; + uint16_t P28 = P11 ^ P25; + uint16_t P29 = P15 ^ P20; + s->slice[7] = P13 ^ P22; + s->slice[6] = P26 ^ P29; + s->slice[5] = P17 ^ P28; + s->slice[4] = P12 ^ P22; + s->slice[3] = P23 ^ P27; + s->slice[2] = P19 ^ P24; + s->slice[1] = P14 ^ P23; + s->slice[0] = P9 ^ P16; + } else { + /* Linear postprocessing */ + uint16_t L0 = M61 ^ M62; + uint16_t L1 = M50 ^ M56; + uint16_t L2 = M46 ^ M48; + uint16_t L3 = M47 ^ M55; + uint16_t L4 = M54 ^ M58; + uint16_t L5 = M49 ^ M61; + uint16_t L6 = M62 ^ L5; + uint16_t L7 = M46 ^ L3; + uint16_t L8 = M51 ^ M59; + uint16_t L9 = M52 ^ M53; + uint16_t L10 = M53 ^ L4; + uint16_t L11 = M60 ^ L2; + uint16_t L12 = M48 ^ M51; + uint16_t L13 = M50 ^ L0; + uint16_t L14 = M52 ^ M61; + uint16_t L15 = M55 ^ L1; + uint16_t L16 = M56 ^ L0; + uint16_t L17 = M57 ^ L1; + uint16_t L18 = M58 ^ L8; + uint16_t L19 = M63 ^ L4; + uint16_t L20 = L0 ^ L1; + uint16_t L21 = L1 ^ L7; + uint16_t L22 = L3 ^ L12; + uint16_t L23 = L18 ^ L2; + uint16_t L24 = L15 ^ L9; + uint16_t L25 = L6 ^ L10; + uint16_t L26 = L7 ^ L9; + uint16_t L27 = L8 ^ L10; + uint16_t L28 = L11 ^ L14; + uint16_t L29 = L11 ^ L17; + s->slice[7] = L6 ^ L24; + s->slice[6] = ~(L16 ^ L26); + s->slice[5] = ~(L19 ^ L28); + s->slice[4] = L6 ^ L21; + s->slice[3] = L20 ^ L22; + s->slice[2] = L25 ^ L29; + s->slice[1] = ~(L13 ^ L27); + s->slice[0] = ~(L6 ^ L23); + } +} + +#define BIT_RANGE(from,to) (((1 << ((to) - (from))) - 1) << (from)) + +#define BIT_RANGE_LEFT(x,from,to,shift) (((x) & BIT_RANGE((from), (to))) << (shift)) +#define BIT_RANGE_RIGHT(x,from,to,shift) (((x) & BIT_RANGE((from), (to))) >> (shift)) + +static void ShiftRows(AES_state* s) { + int i; + for (i = 0; i < 8; i++) { + uint16_t v = s->slice[i]; + s->slice[i] = + (v & BIT_RANGE(0, 4)) | + BIT_RANGE_LEFT(v, 4, 5, 3) | BIT_RANGE_RIGHT(v, 5, 8, 1) | + BIT_RANGE_LEFT(v, 8, 10, 2) | BIT_RANGE_RIGHT(v, 10, 12, 2) | + BIT_RANGE_LEFT(v, 12, 15, 1) | BIT_RANGE_RIGHT(v, 15, 16, 3); + } +} + +static void InvShiftRows(AES_state* s) { + int i; + for (i = 0; i < 8; i++) { + uint16_t v = s->slice[i]; + s->slice[i] = + (v & BIT_RANGE(0, 4)) | + BIT_RANGE_LEFT(v, 4, 7, 1) | BIT_RANGE_RIGHT(v, 7, 8, 3) | + BIT_RANGE_LEFT(v, 8, 10, 2) | BIT_RANGE_RIGHT(v, 10, 12, 2) | + BIT_RANGE_LEFT(v, 12, 13, 3) | BIT_RANGE_RIGHT(v, 13, 16, 1); + } +} + +#define ROT(x,b) (((x) >> ((b) * 4)) | ((x) << ((4-(b)) * 4))) + +static void MixColumns(AES_state* s, int inv) { + /* The MixColumns transform treats the bytes of the columns of the state as + * coefficients of a 3rd degree polynomial over GF(2^8) and multiplies them + * by the fixed polynomial a(x) = {03}x^3 + {01}x^2 + {01}x + {02}, modulo + * x^4 + {01}. + * + * In the inverse transform, we multiply by the inverse of a(x), + * a^-1(x) = {0b}x^3 + {0d}x^2 + {09}x + {0e}. This is equal to + * a(x) * ({04}x^2 + {05}), so we can reuse the forward transform's code + * (found in OpenSSL's bsaes-x86_64.pl, attributed to Jussi Kivilinna) + * + * In the bitsliced representation, a multiplication of every column by x + * mod x^4 + 1 is simply a right rotation. + */ + + /* Shared for both directions is a multiplication by a(x), which can be + * rewritten as (x^3 + x^2 + x) + {02}*(x^3 + {01}). + * + * First compute s into the s? variables, (x^3 + {01}) * s into the s?_01 + * variables and (x^3 + x^2 + x)*s into the s?_123 variables. + */ + uint16_t s0 = s->slice[0], s1 = s->slice[1], s2 = s->slice[2], s3 = s->slice[3]; + uint16_t s4 = s->slice[4], s5 = s->slice[5], s6 = s->slice[6], s7 = s->slice[7]; + uint16_t s0_01 = s0 ^ ROT(s0, 1), s0_123 = ROT(s0_01, 1) ^ ROT(s0, 3); + uint16_t s1_01 = s1 ^ ROT(s1, 1), s1_123 = ROT(s1_01, 1) ^ ROT(s1, 3); + uint16_t s2_01 = s2 ^ ROT(s2, 1), s2_123 = ROT(s2_01, 1) ^ ROT(s2, 3); + uint16_t s3_01 = s3 ^ ROT(s3, 1), s3_123 = ROT(s3_01, 1) ^ ROT(s3, 3); + uint16_t s4_01 = s4 ^ ROT(s4, 1), s4_123 = ROT(s4_01, 1) ^ ROT(s4, 3); + uint16_t s5_01 = s5 ^ ROT(s5, 1), s5_123 = ROT(s5_01, 1) ^ ROT(s5, 3); + uint16_t s6_01 = s6 ^ ROT(s6, 1), s6_123 = ROT(s6_01, 1) ^ ROT(s6, 3); + uint16_t s7_01 = s7 ^ ROT(s7, 1), s7_123 = ROT(s7_01, 1) ^ ROT(s7, 3); + /* Now compute s = s?_123 + {02} * s?_01. */ + s->slice[0] = s7_01 ^ s0_123; + s->slice[1] = s7_01 ^ s0_01 ^ s1_123; + s->slice[2] = s1_01 ^ s2_123; + s->slice[3] = s7_01 ^ s2_01 ^ s3_123; + s->slice[4] = s7_01 ^ s3_01 ^ s4_123; + s->slice[5] = s4_01 ^ s5_123; + s->slice[6] = s5_01 ^ s6_123; + s->slice[7] = s6_01 ^ s7_123; + if (inv) { + /* In the reverse direction, we further need to multiply by + * {04}x^2 + {05}, which can be written as {04} * (x^2 + {01}) + {01}. + * + * First compute (x^2 + {01}) * s into the t?_02 variables: */ + uint16_t t0_02 = s->slice[0] ^ ROT(s->slice[0], 2); + uint16_t t1_02 = s->slice[1] ^ ROT(s->slice[1], 2); + uint16_t t2_02 = s->slice[2] ^ ROT(s->slice[2], 2); + uint16_t t3_02 = s->slice[3] ^ ROT(s->slice[3], 2); + uint16_t t4_02 = s->slice[4] ^ ROT(s->slice[4], 2); + uint16_t t5_02 = s->slice[5] ^ ROT(s->slice[5], 2); + uint16_t t6_02 = s->slice[6] ^ ROT(s->slice[6], 2); + uint16_t t7_02 = s->slice[7] ^ ROT(s->slice[7], 2); + /* And then update s += {04} * t?_02 */ + s->slice[0] ^= t6_02; + s->slice[1] ^= t6_02 ^ t7_02; + s->slice[2] ^= t0_02 ^ t7_02; + s->slice[3] ^= t1_02 ^ t6_02; + s->slice[4] ^= t2_02 ^ t6_02 ^ t7_02; + s->slice[5] ^= t3_02 ^ t7_02; + s->slice[6] ^= t4_02; + s->slice[7] ^= t5_02; + } +} + +static void AddRoundKey(AES_state* s, const AES_state* round) { + int b; + for (b = 0; b < 8; b++) { + s->slice[b] ^= round->slice[b]; + } +} + +/** column_0(s) = column_c(a) */ +static void GetOneColumn(AES_state* s, const AES_state* a, int c) { + int b; + for (b = 0; b < 8; b++) { + s->slice[b] = (a->slice[b] >> c) & 0x1111; + } +} + +/** column_c1(r) |= (column_0(s) ^= column_c2(a)) */ +static void KeySetupColumnMix(AES_state* s, AES_state* r, const AES_state* a, int c1, int c2) { + int b; + for (b = 0; b < 8; b++) { + r->slice[b] |= ((s->slice[b] ^= ((a->slice[b] >> c2) & 0x1111)) & 0x1111) << c1; + } +} + +/** Rotate the rows in s one position upwards, and xor in r */ +static void KeySetupTransform(AES_state* s, const AES_state* r) { + int b; + for (b = 0; b < 8; b++) { + s->slice[b] = ((s->slice[b] >> 4) | (s->slice[b] << 12)) ^ r->slice[b]; + } +} + +/* Multiply the cells in s by x, as polynomials over GF(2) mod x^8 + x^4 + x^3 + x + 1 */ +static void MultX(AES_state* s) { + uint16_t top = s->slice[7]; + s->slice[7] = s->slice[6]; + s->slice[6] = s->slice[5]; + s->slice[5] = s->slice[4]; + s->slice[4] = s->slice[3] ^ top; + s->slice[3] = s->slice[2] ^ top; + s->slice[2] = s->slice[1]; + s->slice[1] = s->slice[0] ^ top; + s->slice[0] = top; +} + +/** Expand the cipher key into the key schedule. + * + * state must be a pointer to an array of size nrounds + 1. + * key must be a pointer to 4 * nkeywords bytes. + * + * AES128 uses nkeywords = 4, nrounds = 10 + * AES192 uses nkeywords = 6, nrounds = 12 + * AES256 uses nkeywords = 8, nrounds = 14 + */ +static void AES_setup(AES_state* rounds, const uint8_t* key, int nkeywords, int nrounds) +{ + int i; + + /* The one-byte round constant */ + AES_state rcon = {{1,0,0,0,0,0,0,0}}; + /* The number of the word being generated, modulo nkeywords */ + int pos = 0; + /* The column representing the word currently being processed */ + AES_state column; + + for (i = 0; i < nrounds + 1; i++) { + int b; + for (b = 0; b < 8; b++) { + rounds[i].slice[b] = 0; + } + } + + /* The first nkeywords round columns are just taken from the key directly. */ + for (i = 0; i < nkeywords; i++) { + int r; + for (r = 0; r < 4; r++) { + LoadByte(&rounds[i >> 2], *(key++), r, i & 3); + } + } + + GetOneColumn(&column, &rounds[(nkeywords - 1) >> 2], (nkeywords - 1) & 3); + + for (i = nkeywords; i < 4 * (nrounds + 1); i++) { + /* Transform column */ + if (pos == 0) { + SubBytes(&column, 0); + KeySetupTransform(&column, &rcon); + MultX(&rcon); + } else if (nkeywords > 6 && pos == 4) { + SubBytes(&column, 0); + } + if (++pos == nkeywords) pos = 0; + KeySetupColumnMix(&column, &rounds[i >> 2], &rounds[(i - nkeywords) >> 2], i & 3, (i - nkeywords) & 3); + } +} + +static void AES_encrypt(const AES_state* rounds, int nrounds, unsigned char* cipher16, const unsigned char* plain16) { + AES_state s = {{0}}; + int round; + + LoadBytes(&s, plain16); + AddRoundKey(&s, rounds++); + + for (round = 1; round < nrounds; round++) { + SubBytes(&s, 0); + ShiftRows(&s); + MixColumns(&s, 0); + AddRoundKey(&s, rounds++); + } + + SubBytes(&s, 0); + ShiftRows(&s); + AddRoundKey(&s, rounds); + + SaveBytes(cipher16, &s); +} + +static void AES_decrypt(const AES_state* rounds, int nrounds, unsigned char* plain16, const unsigned char* cipher16) { + /* Most AES decryption implementations use the alternate scheme + * (the Equivalent Inverse Cipher), which allows for more code reuse between + * the encryption and decryption code, but requires separate setup for both. + */ + AES_state s = {{0}}; + int round; + + rounds += nrounds; + + LoadBytes(&s, cipher16); + AddRoundKey(&s, rounds--); + + for (round = 1; round < nrounds; round++) { + InvShiftRows(&s); + SubBytes(&s, 1); + AddRoundKey(&s, rounds--); + MixColumns(&s, 1); + } + + InvShiftRows(&s); + SubBytes(&s, 1); + AddRoundKey(&s, rounds); + + SaveBytes(plain16, &s); +} + +void AES128_init(AES128_ctx* ctx, const unsigned char* key16) { + AES_setup(ctx->rk, key16, 4, 10); +} + +void AES128_encrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16) { + while (blocks--) { + AES_encrypt(ctx->rk, 10, cipher16, plain16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES128_decrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16) { + while (blocks--) { + AES_decrypt(ctx->rk, 10, plain16, cipher16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES192_init(AES192_ctx* ctx, const unsigned char* key24) { + AES_setup(ctx->rk, key24, 6, 12); +} + +void AES192_encrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16) { + while (blocks--) { + AES_encrypt(ctx->rk, 12, cipher16, plain16); + cipher16 += 16; + plain16 += 16; + } + +} + +void AES192_decrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16) { + while (blocks--) { + AES_decrypt(ctx->rk, 12, plain16, cipher16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES256_init(AES256_ctx* ctx, const unsigned char* key32) { + AES_setup(ctx->rk, key32, 8, 14); +} + +void AES256_encrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16) { + while (blocks--) { + AES_encrypt(ctx->rk, 14, cipher16, plain16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES256_decrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16) { + while (blocks--) { + AES_decrypt(ctx->rk, 14, plain16, cipher16); + cipher16 += 16; + plain16 += 16; + } +} diff --git a/src/crypto/ctaes/ctaes.h b/src/crypto/ctaes/ctaes.h new file mode 100644 index 000000000..2f0af0421 --- /dev/null +++ b/src/crypto/ctaes/ctaes.h @@ -0,0 +1,41 @@ + /********************************************************************* + * Copyright (c) 2016 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _CTAES_H_ +#define _CTAES_H_ 1 + +#include +#include + +typedef struct { + uint16_t slice[8]; +} AES_state; + +typedef struct { + AES_state rk[11]; +} AES128_ctx; + +typedef struct { + AES_state rk[13]; +} AES192_ctx; + +typedef struct { + AES_state rk[15]; +} AES256_ctx; + +void AES128_init(AES128_ctx* ctx, const unsigned char* key16); +void AES128_encrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16); +void AES128_decrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16); + +void AES192_init(AES192_ctx* ctx, const unsigned char* key24); +void AES192_encrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16); +void AES192_decrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16); + +void AES256_init(AES256_ctx* ctx, const unsigned char* key32); +void AES256_encrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16); +void AES256_decrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16); + +#endif diff --git a/src/crypto/ctaes/test.c b/src/crypto/ctaes/test.c new file mode 100644 index 000000000..21439a16f --- /dev/null +++ b/src/crypto/ctaes/test.c @@ -0,0 +1,110 @@ + /********************************************************************* + * Copyright (c) 2016 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#include "ctaes.h" + +#include +#include +#include + +typedef struct { + int keysize; + const char* key; + const char* plain; + const char* cipher; +} ctaes_test; + +static const ctaes_test ctaes_tests[] = { + /* AES test vectors from FIPS 197. */ + {128, "000102030405060708090a0b0c0d0e0f", "00112233445566778899aabbccddeeff", "69c4e0d86a7b0430d8cdb78070b4c55a"}, + {192, "000102030405060708090a0b0c0d0e0f1011121314151617", "00112233445566778899aabbccddeeff", "dda97ca4864cdfe06eaf70a0ec0d7191"}, + {256, "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "00112233445566778899aabbccddeeff", "8ea2b7ca516745bfeafc49904b496089"}, + + /* AES-ECB test vectors from NIST sp800-38a. */ + {128, "2b7e151628aed2a6abf7158809cf4f3c", "6bc1bee22e409f96e93d7e117393172a", "3ad77bb40d7a3660a89ecaf32466ef97"}, + {128, "2b7e151628aed2a6abf7158809cf4f3c", "ae2d8a571e03ac9c9eb76fac45af8e51", "f5d3d58503b9699de785895a96fdbaaf"}, + {128, "2b7e151628aed2a6abf7158809cf4f3c", "30c81c46a35ce411e5fbc1191a0a52ef", "43b1cd7f598ece23881b00e3ed030688"}, + {128, "2b7e151628aed2a6abf7158809cf4f3c", "f69f2445df4f9b17ad2b417be66c3710", "7b0c785e27e8ad3f8223207104725dd4"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "6bc1bee22e409f96e93d7e117393172a", "bd334f1d6e45f25ff712a214571fa5cc"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "ae2d8a571e03ac9c9eb76fac45af8e51", "974104846d0ad3ad7734ecb3ecee4eef"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "30c81c46a35ce411e5fbc1191a0a52ef", "ef7afd2270e2e60adce0ba2face6444e"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "f69f2445df4f9b17ad2b417be66c3710", "9a4b41ba738d6c72fb16691603c18e0e"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "6bc1bee22e409f96e93d7e117393172a", "f3eed1bdb5d2a03c064b5a7e3db181f8"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "ae2d8a571e03ac9c9eb76fac45af8e51", "591ccb10d410ed26dc5ba74a31362870"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "30c81c46a35ce411e5fbc1191a0a52ef", "b6ed21b99ca6f4f9f153e7b1beafed1d"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "f69f2445df4f9b17ad2b417be66c3710", "23304b7a39f9f3ff067d8d8f9e24ecc7"} +}; + +static void from_hex(unsigned char* data, int len, const char* hex) { + int p; + for (p = 0; p < len; p++) { + int v = 0; + int n; + for (n = 0; n < 2; n++) { + assert((*hex >= '0' && *hex <= '9') || (*hex >= 'a' && *hex <= 'f')); + if (*hex >= '0' && *hex <= '9') { + v |= (*hex - '0') << (4 * (1 - n)); + } else { + v |= (*hex - 'a' + 10) << (4 * (1 - n)); + } + hex++; + } + *(data++) = v; + } + assert(*hex == 0); +} + +int main(void) { + int i; + int fail = 0; + for (i = 0; i < sizeof(ctaes_tests) / sizeof(ctaes_tests[0]); i++) { + unsigned char key[32], plain[16], cipher[16], ciphered[16], deciphered[16]; + const ctaes_test* test = &ctaes_tests[i]; + assert(test->keysize == 128 || test->keysize == 192 || test->keysize == 256); + from_hex(plain, 16, test->plain); + from_hex(cipher, 16, test->cipher); + switch (test->keysize) { + case 128: { + AES128_ctx ctx; + from_hex(key, 16, test->key); + AES128_init(&ctx, key); + AES128_encrypt(&ctx, 1, ciphered, plain); + AES128_decrypt(&ctx, 1, deciphered, cipher); + break; + } + case 192: { + AES192_ctx ctx; + from_hex(key, 24, test->key); + AES192_init(&ctx, key); + AES192_encrypt(&ctx, 1, ciphered, plain); + AES192_decrypt(&ctx, 1, deciphered, cipher); + break; + } + case 256: { + AES256_ctx ctx; + from_hex(key, 32, test->key); + AES256_init(&ctx, key); + AES256_encrypt(&ctx, 1, ciphered, plain); + AES256_decrypt(&ctx, 1, deciphered, cipher); + break; + } + } + if (memcmp(cipher, ciphered, 16)) { + fprintf(stderr, "E(key=\"%s\", plain=\"%s\") != \"%s\"\n", test->key, test->plain, test->cipher); + fail++; + } + if (memcmp(plain, deciphered, 16)) { + fprintf(stderr, "D(key=\"%s\", cipher=\"%s\") != \"%s\"\n", test->key, test->cipher, test->plain); + fail++; + } + } + if (fail == 0) { + fprintf(stderr, "All tests successful\n"); + } else { + fprintf(stderr, "%i tests failed\n", fail); + } + return (fail != 0); +} diff --git a/src/init.cpp b/src/init.cpp index bd72c1418..89c1fa1cd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -58,7 +58,6 @@ #include #include #include -#include #if ENABLE_ZMQ #include "zmq/zmqnotificationinterface.h" @@ -1197,7 +1196,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (fPrintToDebugLog) OpenDebugLog(); - LogPrintf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION)); #ifdef ENABLE_WALLET LogPrintf("Using BerkeleyDB version %s\n", DbEnv::version(0, 0, 0)); #endif diff --git a/src/key.h b/src/key.h index 762fd1ecb..623458752 100644 --- a/src/key.h +++ b/src/key.h @@ -108,14 +108,14 @@ class CKey //! Check whether the public key corresponding to this private key is (to be) compressed. bool IsCompressed() const { return fCompressed; } - //! Initialize from a CPrivKey (serialized OpenSSL private key data). + //! Initialize from a CPrivKey (serialized OpenSSL-format private key data). bool SetPrivKey(const CPrivKey& vchPrivKey, bool fCompressed); //! Generate a new private key using a cryptographic PRNG. void MakeNewKey(bool fCompressed); /** - * Convert the private key to a CPrivKey (serialized OpenSSL private key data). + * Convert the private key to a CPrivKey (serialized OpenSSL-format private key data). * This is expensive. */ CPrivKey GetPrivKey() const; diff --git a/src/main.cpp b/src/main.cpp index b02078c8e..62a9563d6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5495,14 +5495,15 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (fListen && !IsInitialBlockDownload(chainparams)) { CAddress addr = GetLocalAddress(&pfrom->addr); + FastRandomContext insecure_rand; if (addr.IsRoutable()) { LogPrintf("ProcessMessages: advertizing address %s\n", addr.ToString()); - pfrom->PushAddress(addr); + pfrom->PushAddress(addr, insecure_rand); } else if (IsPeerAddrLocalGood(pfrom)) { addr.SetIP(pfrom->addrLocal); LogPrintf("ProcessMessages: advertizing address %s\n", addr.ToString()); - pfrom->PushAddress(addr); + pfrom->PushAddress(addr, insecure_rand); } } @@ -5621,6 +5622,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, uint256 hashRand = ArithToUint256(UintToArith256(hashSalt) ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/(24*60*60))); hashRand = Hash(BEGIN(hashRand), END(hashRand)); multimap mapMix; + FastRandomContext insecure_rand; for (CNode* pnode : vNodes) { if (pnode->nVersion < CADDR_TIME_VERSION) @@ -5633,7 +5635,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } int nRelayNodes = fReachable ? 2 : 1; // limited relaying of addresses outside our network(s) for (multimap::iterator mi = mapMix.begin(); mi != mapMix.end() && nRelayNodes-- > 0; ++mi) - ((*mi).second)->PushAddress(addr); + ((*mi).second)->PushAddress(addr, insecure_rand); } } // Do not store addresses outside our network @@ -6055,8 +6057,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->vAddrToSend.clear(); vector vAddr = addrman.GetAddr(); + FastRandomContext insecure_rand; for (const CAddress &addr : vAddr) - pfrom->PushAddress(addr); + pfrom->PushAddress(addr, insecure_rand); } diff --git a/src/memusage.h b/src/memusage.h index 87e652557..e3e60d0a0 100644 --- a/src/memusage.h +++ b/src/memusage.h @@ -117,4 +117,4 @@ static inline size_t DynamicUsage(const boost::unordered_map& m) } -#endif +#endif // BITCOIN_MEMUSAGE_H diff --git a/src/net.cpp b/src/net.cpp index 5446c053b..198569e2c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -207,7 +207,8 @@ void AdvertizeLocal(CNode *pnode) if (addrLocal.IsRoutable()) { LogPrintf("AdvertizeLocal: advertizing address %s\n", addrLocal.ToString()); - pnode->PushAddress(addrLocal); + FastRandomContext insecure_rand; + pnode->PushAddress(addrLocal, insecure_rand); } } } diff --git a/src/net.h b/src/net.h index d042f11ea..cb86fdc85 100644 --- a/src/net.h +++ b/src/net.h @@ -394,14 +394,14 @@ class CNode addrKnown.insert(addr.GetKey()); } - void PushAddress(const CAddress& addr) + void PushAddress(const CAddress& addr, FastRandomContext &insecure_rand) { // Known checking here is only to save space from duplicates. // SendMessages will filter it again for knowns that were added // after addresses were pushed. if (addr.IsValid() && !addrKnown.contains(addr.GetKey())) { if (vAddrToSend.size() >= MAX_ADDR_TO_SEND) { - vAddrToSend[insecure_rand() % vAddrToSend.size()] = addr; + vAddrToSend[insecure_rand.rand32() % vAddrToSend.size()] = addr; } else { vAddrToSend.push_back(addr); } diff --git a/src/netbase.cpp b/src/netbase.cpp index fe4113399..4b75301c2 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -581,8 +581,8 @@ static bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDe // do socks negotiation if (proxy.randomize_credentials) { ProxyCredentials random_auth; - random_auth.username = strprintf("%i", insecure_rand()); - random_auth.password = strprintf("%i", insecure_rand()); + static std::atomic_int counter; + random_auth.username = random_auth.password = strprintf("%i", counter++); if (!Socks5(strDest, (unsigned short)port, &random_auth, hSocket)) return false; } else { diff --git a/src/random.cpp b/src/random.cpp index 6c4d1bf13..542fc57a0 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -66,23 +66,21 @@ uint256 GetRandHash() return hash; } -uint32_t insecure_rand_Rz = 11; -uint32_t insecure_rand_Rw = 11; -void seed_insecure_rand(bool fDeterministic) +FastRandomContext::FastRandomContext(bool fDeterministic) { // The seed values have some unlikely fixed points which we avoid. if (fDeterministic) { - insecure_rand_Rz = insecure_rand_Rw = 11; + Rz = Rw = 11; } else { uint32_t tmp; do { GetRandBytes((unsigned char*)&tmp, 4); } while (tmp == 0 || tmp == 0x9068ffffU); - insecure_rand_Rz = tmp; + Rz = tmp; do { GetRandBytes((unsigned char*)&tmp, 4); } while (tmp == 0 || tmp == 0x464fffffU); - insecure_rand_Rw = tmp; + Rw = tmp; } } diff --git a/src/random.h b/src/random.h index 38b66bf0f..0a7852237 100644 --- a/src/random.h +++ b/src/random.h @@ -50,25 +50,26 @@ void MappedShuffle(RandomAccessIterator first, } /** - * Seed insecure_rand using the random pool. - * @param Deterministic Use a deterministic seed + * Fast randomness source. This is seeded once with secure random data, but + * is completely deterministic and insecure after that. + * This class is not thread-safe. */ -void seed_insecure_rand(bool fDeterministic = false); +class FastRandomContext { +public: + explicit FastRandomContext(bool fDeterministic=false); -/** - * MWC RNG of George Marsaglia - * This is intended to be fast. It has a period of 2^59.3, though the - * least significant 16 bits only have a period of about 2^30.1. - * - * @return random value - */ -extern uint32_t insecure_rand_Rz; -extern uint32_t insecure_rand_Rw; -static inline uint32_t insecure_rand(void) -{ - insecure_rand_Rz = 36969 * (insecure_rand_Rz & 65535) + (insecure_rand_Rz >> 16); - insecure_rand_Rw = 18000 * (insecure_rand_Rw & 65535) + (insecure_rand_Rw >> 16); - return (insecure_rand_Rw << 16) + insecure_rand_Rz; -} + uint32_t rand32() { + Rz = 36969 * (Rz & 65535) + (Rz >> 16); + Rw = 18000 * (Rw & 65535) + (Rw >> 16); + return (Rw << 16) + Rz; + } + + bool randbool() { + return rand32() & 1; + } + + uint32_t Rz; + uint32_t Rw; +}; #endif // BITCOIN_RANDOM_H diff --git a/src/support/cleanse.cpp b/src/support/cleanse.cpp index 7a4da12b4..9fa2fc182 100644 --- a/src/support/cleanse.cpp +++ b/src/support/cleanse.cpp @@ -5,9 +5,34 @@ #include "cleanse.h" -#include +#include + +#if defined(_MSC_VER) +#include // For SecureZeroMemory. +#endif void memory_cleanse(void *ptr, size_t len) { - OPENSSL_cleanse(ptr, len); +#if defined(_MSC_VER) + /* SecureZeroMemory is guaranteed not to be optimized out by MSVC. */ + SecureZeroMemory(ptr, len); +#else + std::memset(ptr, 0, len); + + /* In order to prevent the compiler from optimizing out the memset, this uses an + * unremovable (see https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile ) + * asm block that the compiler must assume could access arbitary memory, including + * the zero bytes written by std::memset. + * + * Quoting Adam Langley in commit ad1907fe73334d6c696c8539646c21b11178f20f + * in BoringSSL (ISC License): + * As best as we can tell, this is sufficient to break any optimisations that + * might try to eliminate "superfluous" memsets. + * This method is used by memzero_explicit() in the Linux kernel, too. Its advantage is that it + * is pretty efficient because the compiler can still implement the memset() efficiently, + * just not remove it entirely. See "Dead Store Elimination (Still) Considered Harmful" by + * Yang et al. (USENIX Security 2017) for more background. + */ + __asm__ __volatile__("" : : "r"(ptr) : "memory"); +#endif } diff --git a/src/support/cleanse.h b/src/support/cleanse.h index c6fe12912..1b2bdc13e 100644 --- a/src/support/cleanse.h +++ b/src/support/cleanse.h @@ -8,6 +8,8 @@ #include +/** Secure overwrite a buffer (possibly containing secret data) with zero-bytes. The write + * operation will not be optimized out by the compiler. */ void memory_cleanse(void *ptr, size_t len); #endif // BITCOIN_SUPPORT_CLEANSE_H diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index 0aa7f2369..9268a7e36 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -25,7 +25,7 @@ class CAddrManTest : public CAddrMan void MakeDeterministic() { nKey.SetNull(); - seed_insecure_rand(true); + insecure_rand = FastRandomContext(true); } int RandomInt(int nMax) diff --git a/src/test/bignum.h b/src/test/bignum.h deleted file mode 100644 index 13e70133a..000000000 --- a/src/test/bignum.h +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2013 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or https://www.opensource.org/licenses/mit-license.php . - -#ifndef BITCOIN_TEST_BIGNUM_H -#define BITCOIN_TEST_BIGNUM_H - -#include -#include -#include -#include -#include -#include -#include - -#include - -class bignum_error : public std::runtime_error -{ -public: - explicit bignum_error(const std::string& str) : std::runtime_error(str) {} -}; - - -/** C++ wrapper for BIGNUM (OpenSSL bignum) */ -class CBigNum -{ - BIGNUM* bn; -public: - CBigNum() - { - bn = BN_new(); - assert(bn); - } - - CBigNum(const CBigNum& b) - { - bn = BN_new(); - assert(bn); - if (!BN_copy(bn, b.bn)) - { - BN_clear_free(bn); - throw bignum_error("CBigNum::CBigNum(const CBigNum&): BN_copy failed"); - } - } - - CBigNum& operator=(const CBigNum& b) - { - if (!BN_copy(bn, b.bn)) - throw bignum_error("CBigNum::operator=: BN_copy failed"); - return (*this); - } - - ~CBigNum() - { - BN_clear_free(bn); - } - - CBigNum(long long n) { bn = BN_new(); assert(bn); setint64(n); } - - explicit CBigNum(const std::vector& vch) - { - bn = BN_new(); - assert(bn); - setvch(vch); - } - - int getint() const - { - BN_ULONG n = BN_get_word(bn); - if (!BN_is_negative(bn)) - return (n > (BN_ULONG)std::numeric_limits::max() ? std::numeric_limits::max() : n); - else - return (n > (BN_ULONG)std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); - } - - void setint64(int64_t sn) - { - unsigned char pch[sizeof(sn) + 6]; - unsigned char* p = pch + 4; - bool fNegative; - uint64_t n; - - if (sn < (int64_t)0) - { - // Since the minimum signed integer cannot be represented as positive so long as its type is signed, - // and it's not well-defined what happens if you make it unsigned before negating it, - // we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate - n = -(sn + 1); - ++n; - fNegative = true; - } else { - n = sn; - fNegative = false; - } - - bool fLeadingZeroes = true; - for (int i = 0; i < 8; i++) - { - unsigned char c = (n >> 56) & 0xff; - n <<= 8; - if (fLeadingZeroes) - { - if (c == 0) - continue; - if (c & 0x80) - *p++ = (fNegative ? 0x80 : 0); - else if (fNegative) - c |= 0x80; - fLeadingZeroes = false; - } - *p++ = c; - } - unsigned int nSize = p - (pch + 4); - pch[0] = (nSize >> 24) & 0xff; - pch[1] = (nSize >> 16) & 0xff; - pch[2] = (nSize >> 8) & 0xff; - pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, bn); - } - - void setvch(const std::vector& vch) - { - std::vector vch2(vch.size() + 4); - unsigned int nSize = vch.size(); - // BIGNUM's byte stream format expects 4 bytes of - // big endian size data info at the front - vch2[0] = (nSize >> 24) & 0xff; - vch2[1] = (nSize >> 16) & 0xff; - vch2[2] = (nSize >> 8) & 0xff; - vch2[3] = (nSize >> 0) & 0xff; - // swap data to big endian - reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4); - BN_mpi2bn(&vch2[0], vch2.size(), bn); - } - - std::vector getvch() const - { - unsigned int nSize = BN_bn2mpi(bn, NULL); - if (nSize <= 4) - return std::vector(); - std::vector vch(nSize); - BN_bn2mpi(bn, &vch[0]); - vch.erase(vch.begin(), vch.begin() + 4); - reverse(vch.begin(), vch.end()); - return vch; - } - - friend inline const CBigNum operator+(const CBigNum& a, const CBigNum& b); - friend inline const CBigNum operator-(const CBigNum& a, const CBigNum& b); - friend inline const CBigNum operator-(const CBigNum& a); - friend inline bool operator==(const CBigNum& a, const CBigNum& b); - friend inline bool operator!=(const CBigNum& a, const CBigNum& b); - friend inline bool operator<=(const CBigNum& a, const CBigNum& b); - friend inline bool operator>=(const CBigNum& a, const CBigNum& b); - friend inline bool operator<(const CBigNum& a, const CBigNum& b); - friend inline bool operator>(const CBigNum& a, const CBigNum& b); -}; - - - -inline const CBigNum operator+(const CBigNum& a, const CBigNum& b) -{ - CBigNum r; - if (!BN_add(r.bn, a.bn, b.bn)) - throw bignum_error("CBigNum::operator+: BN_add failed"); - return r; -} - -inline const CBigNum operator-(const CBigNum& a, const CBigNum& b) -{ - CBigNum r; - if (!BN_sub(r.bn, a.bn, b.bn)) - throw bignum_error("CBigNum::operator-: BN_sub failed"); - return r; -} - -inline const CBigNum operator-(const CBigNum& a) -{ - CBigNum r(a); - BN_set_negative(r.bn, !BN_is_negative(r.bn)); - return r; -} - -inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) == 0); } -inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) != 0); } -inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) <= 0); } -inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) >= 0); } -inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) < 0); } -inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) > 0); } - -#endif // BITCOIN_TEST_BIGNUM_H diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 3932dafe0..383959b57 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -3,7 +3,7 @@ // file COPYING or https://www.opensource.org/licenses/mit-license.php . #include "coins.h" -#include "random.h" +#include "test_random.h" #include "script/standard.h" #include "uint256.h" #include "utilstrencodings.h" diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp index 9e3cf2d59..f79577f58 100644 --- a/src/test/crypto_tests.cpp +++ b/src/test/crypto_tests.cpp @@ -2,13 +2,14 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or https://www.opensource.org/licenses/mit-license.php . +#include "crypto/aes.h" #include "crypto/ripemd160.h" #include "crypto/sha1.h" #include "crypto/sha256.h" #include "crypto/sha512.h" #include "crypto/hmac_sha256.h" #include "crypto/hmac_sha512.h" -#include "random.h" +#include "test_random.h" #include "utilstrencodings.h" #include "test/test_bitcoin.h" @@ -63,6 +64,127 @@ void TestHMACSHA512(const std::string &hexkey, const std::string &hexin, const s TestVector(CHMAC_SHA512(&key[0], key.size()), ParseHex(hexin), ParseHex(hexout)); } +void TestAES128(const std::string &hexkey, const std::string &hexin, const std::string &hexout) +{ + std::vector key = ParseHex(hexkey); + std::vector in = ParseHex(hexin); + std::vector correctout = ParseHex(hexout); + std::vector buf, buf2; + + assert(key.size() == 16); + assert(in.size() == 16); + assert(correctout.size() == 16); + AES128Encrypt enc(&key[0]); + buf.resize(correctout.size()); + buf2.resize(correctout.size()); + enc.Encrypt(&buf[0], &in[0]); + BOOST_CHECK_EQUAL(HexStr(buf), HexStr(correctout)); + AES128Decrypt dec(&key[0]); + dec.Decrypt(&buf2[0], &buf[0]); + BOOST_CHECK_EQUAL(HexStr(buf2), HexStr(in)); +} + +void TestAES256(const std::string &hexkey, const std::string &hexin, const std::string &hexout) +{ + std::vector key = ParseHex(hexkey); + std::vector in = ParseHex(hexin); + std::vector correctout = ParseHex(hexout); + std::vector buf; + + assert(key.size() == 32); + assert(in.size() == 16); + assert(correctout.size() == 16); + AES256Encrypt enc(&key[0]); + buf.resize(correctout.size()); + enc.Encrypt(&buf[0], &in[0]); + BOOST_CHECK(buf == correctout); + AES256Decrypt dec(&key[0]); + dec.Decrypt(&buf[0], &buf[0]); + BOOST_CHECK(buf == in); +} + +void TestAES128CBC(const std::string &hexkey, const std::string &hexiv, bool pad, const std::string &hexin, const std::string &hexout) +{ + std::vector key = ParseHex(hexkey); + std::vector iv = ParseHex(hexiv); + std::vector in = ParseHex(hexin); + std::vector correctout = ParseHex(hexout); + std::vector realout(in.size() + AES_BLOCKSIZE); + + // Encrypt the plaintext and verify that it equals the cipher + AES128CBCEncrypt enc(&key[0], &iv[0], pad); + int size = enc.Encrypt(&in[0], in.size(), &realout[0]); + realout.resize(size); + BOOST_CHECK(realout.size() == correctout.size()); + BOOST_CHECK_MESSAGE(realout == correctout, HexStr(realout) + std::string(" != ") + hexout); + + // Decrypt the cipher and verify that it equals the plaintext + std::vector decrypted(correctout.size()); + AES128CBCDecrypt dec(&key[0], &iv[0], pad); + size = dec.Decrypt(&correctout[0], correctout.size(), &decrypted[0]); + decrypted.resize(size); + BOOST_CHECK(decrypted.size() == in.size()); + BOOST_CHECK_MESSAGE(decrypted == in, HexStr(decrypted) + std::string(" != ") + hexin); + + // Encrypt and re-decrypt substrings of the plaintext and verify that they equal each-other + for(std::vector::iterator i(in.begin()); i != in.end(); ++i) + { + std::vector sub(i, in.end()); + std::vector subout(sub.size() + AES_BLOCKSIZE); + int size = enc.Encrypt(&sub[0], sub.size(), &subout[0]); + if (size != 0) + { + subout.resize(size); + std::vector subdecrypted(subout.size()); + size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]); + subdecrypted.resize(size); + BOOST_CHECK(decrypted.size() == in.size()); + BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string(" != ") + HexStr(sub)); + } + } +} + +void TestAES256CBC(const std::string &hexkey, const std::string &hexiv, bool pad, const std::string &hexin, const std::string &hexout) +{ + std::vector key = ParseHex(hexkey); + std::vector iv = ParseHex(hexiv); + std::vector in = ParseHex(hexin); + std::vector correctout = ParseHex(hexout); + std::vector realout(in.size() + AES_BLOCKSIZE); + + // Encrypt the plaintext and verify that it equals the cipher + AES256CBCEncrypt enc(&key[0], &iv[0], pad); + int size = enc.Encrypt(&in[0], in.size(), &realout[0]); + realout.resize(size); + BOOST_CHECK(realout.size() == correctout.size()); + BOOST_CHECK_MESSAGE(realout == correctout, HexStr(realout) + std::string(" != ") + hexout); + + // Decrypt the cipher and verify that it equals the plaintext + std::vector decrypted(correctout.size()); + AES256CBCDecrypt dec(&key[0], &iv[0], pad); + size = dec.Decrypt(&correctout[0], correctout.size(), &decrypted[0]); + decrypted.resize(size); + BOOST_CHECK(decrypted.size() == in.size()); + BOOST_CHECK_MESSAGE(decrypted == in, HexStr(decrypted) + std::string(" != ") + hexin); + + // Encrypt and re-decrypt substrings of the plaintext and verify that they equal each-other + for(std::vector::iterator i(in.begin()); i != in.end(); ++i) + { + std::vector sub(i, in.end()); + std::vector subout(sub.size() + AES_BLOCKSIZE); + int size = enc.Encrypt(&sub[0], sub.size(), &subout[0]); + if (size != 0) + { + subout.resize(size); + std::vector subdecrypted(subout.size()); + size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]); + subdecrypted.resize(size); + BOOST_CHECK(decrypted.size() == in.size()); + BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string(" != ") + HexStr(sub)); + } + } +} + std::string LongTestString(void) { std::string ret; for (int i=0; i<200000; i++) { diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp index f5c80b4a7..8b921b729 100644 --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -8,7 +8,7 @@ #include "uint256.h" #include "arith_uint256.h" #include "version.h" -#include "random.h" +#include "test_random.h" #include "test/test_bitcoin.h" #include diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index 723fd3e62..d4af6a002 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -4,7 +4,7 @@ #include #include "prevector.h" -#include "random.h" +#include "test_random.h" #include "serialize.h" #include "streams.h" @@ -24,6 +24,7 @@ class prevector_tester { pretype pre_vector; typedef typename pretype::size_type Size; + FastRandomContext rand_cache; void test() { const pretype& const_pre_vector = pre_vector; @@ -149,6 +150,11 @@ class prevector_tester { pre_vector.shrink_to_fit(); test(); } + + prevector_tester() { + seed_insecure_rand(); + rand_cache = insecure_rand_ctx; + } }; BOOST_AUTO_TEST_CASE(PrevectorTestInt) diff --git a/src/test/sanity_tests.cpp b/src/test/sanity_tests.cpp index c29b173fa..41813fdd2 100644 --- a/src/test/sanity_tests.cpp +++ b/src/test/sanity_tests.cpp @@ -14,7 +14,7 @@ BOOST_AUTO_TEST_CASE(basic_sanity) { BOOST_CHECK_MESSAGE(glibc_sanity_test() == true, "libc sanity test"); BOOST_CHECK_MESSAGE(glibcxx_sanity_test() == true, "stdlib sanity test"); - BOOST_CHECK_MESSAGE(ECC_InitSanityCheck() == true, "openssl ECC test"); + BOOST_CHECK_MESSAGE(ECC_InitSanityCheck() == true, "ECC sanity test"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/scheduler_tests.cpp b/src/test/scheduler_tests.cpp index 26d705160..811003440 100644 --- a/src/test/scheduler_tests.cpp +++ b/src/test/scheduler_tests.cpp @@ -35,8 +35,6 @@ static void MicroSleep(uint64_t n) BOOST_AUTO_TEST_CASE(manythreads) { - seed_insecure_rand(false); - // Stress test: hundreds of microsecond-scheduled tasks, // serviced by 10 threads. // @@ -51,7 +49,7 @@ BOOST_AUTO_TEST_CASE(manythreads) boost::mutex counterMutex[10]; int counter[10] = { 0 }; - boost::random::mt19937 rng(insecure_rand()); + boost::random::mt19937 rng(42); boost::random::uniform_int_distribution<> zeroToNine(0, 9); boost::random::uniform_int_distribution<> randomMsec(-11, 1000); boost::random::uniform_int_distribution<> randomDelta(-1000, 1000); diff --git a/src/test/scriptnum10.h b/src/test/scriptnum10.h new file mode 100644 index 000000000..fc3d295ce --- /dev/null +++ b/src/test/scriptnum10.h @@ -0,0 +1,208 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_TEST_SCRIPTNUM10_H +#define BITCOIN_TEST_SCRIPTNUM10_H + +#include +#include +#include +#include +#include +#include +#include "assert.h" + +class scriptnum10_error : public std::runtime_error +{ +public: + explicit scriptnum10_error(const std::string& str) : std::runtime_error(str) {} +}; + +class CScriptNum10 +{ +/** + * The ScriptNum implementation from Bitcoin Core 0.10.0, for cross-comparison. + */ +public: + + explicit CScriptNum10(const int64_t& n) + { + m_value = n; + } + + static const size_t nDefaultMaxNumSize = 4; + + explicit CScriptNum10(const std::vector& vch, bool fRequireMinimal, + const size_t nMaxNumSize = nDefaultMaxNumSize) + { + if (vch.size() > nMaxNumSize) { + throw scriptnum10_error("script number overflow"); + } + if (fRequireMinimal && vch.size() > 0) { + // Check that the number is encoded with the minimum possible + // number of bytes. + // + // If the most-significant-byte - excluding the sign bit - is zero + // then we're not minimal. Note how this test also rejects the + // negative-zero encoding, 0x80. + if ((vch.back() & 0x7f) == 0) { + // One exception: if there's more than one byte and the most + // significant bit of the second-most-significant-byte is set + // it would conflict with the sign bit. An example of this case + // is +-255, which encode to 0xff00 and 0xff80 respectively. + // (big-endian). + if (vch.size() <= 1 || (vch[vch.size() - 2] & 0x80) == 0) { + throw scriptnum10_error("non-minimally encoded script number"); + } + } + } + m_value = set_vch(vch); + } + + inline bool operator==(const int64_t& rhs) const { return m_value == rhs; } + inline bool operator!=(const int64_t& rhs) const { return m_value != rhs; } + inline bool operator<=(const int64_t& rhs) const { return m_value <= rhs; } + inline bool operator< (const int64_t& rhs) const { return m_value < rhs; } + inline bool operator>=(const int64_t& rhs) const { return m_value >= rhs; } + inline bool operator> (const int64_t& rhs) const { return m_value > rhs; } + + inline bool operator==(const CScriptNum10& rhs) const { return operator==(rhs.m_value); } + inline bool operator!=(const CScriptNum10& rhs) const { return operator!=(rhs.m_value); } + inline bool operator<=(const CScriptNum10& rhs) const { return operator<=(rhs.m_value); } + inline bool operator< (const CScriptNum10& rhs) const { return operator< (rhs.m_value); } + inline bool operator>=(const CScriptNum10& rhs) const { return operator>=(rhs.m_value); } + inline bool operator> (const CScriptNum10& rhs) const { return operator> (rhs.m_value); } + + inline CScriptNum10 operator+( const int64_t& rhs) const + { + assert(rhs == 0 || (rhs > 0 && m_value <= std::numeric_limits::max() - rhs) || + (rhs < 0 && m_value >= std::numeric_limits::min() - rhs)); + return CScriptNum10(m_value + rhs); + } + + inline CScriptNum10 operator-( const int64_t& rhs) const + { + assert(rhs == 0 || (rhs > 0 && m_value >= std::numeric_limits::min() + rhs) || + (rhs < 0 && m_value <= std::numeric_limits::max() + rhs)); + return CScriptNum10(m_value - rhs); + } + + inline CScriptNum10 operator+( const CScriptNum10& rhs) const { return operator+(rhs.m_value); } + inline CScriptNum10 operator-( const CScriptNum10& rhs) const { return operator-(rhs.m_value); } + + inline CScriptNum10& operator+=( const CScriptNum10& rhs) { return operator+=(rhs.m_value); } + inline CScriptNum10& operator-=( const CScriptNum10& rhs) { return operator-=(rhs.m_value); } + + inline CScriptNum10 operator-() const + { + assert(m_value != std::numeric_limits::min()); + return CScriptNum10(-m_value); + } + + inline CScriptNum10& operator=( const int64_t& rhs) + { + m_value = rhs; + return *this; + } + + inline CScriptNum10& operator+=( const int64_t& rhs) + { + assert(rhs == 0 || (rhs > 0 && m_value <= std::numeric_limits::max() - rhs) || + (rhs < 0 && m_value >= std::numeric_limits::min() - rhs)); + m_value += rhs; + return *this; + } + + inline CScriptNum10& operator-=( const int64_t& rhs) + { + assert(rhs == 0 || (rhs > 0 && m_value >= std::numeric_limits::min() + rhs) || + (rhs < 0 && m_value <= std::numeric_limits::max() + rhs)); + m_value -= rhs; + return *this; + } + + int getint() const + { + if (m_value > std::numeric_limits::max()) + return std::numeric_limits::max(); + else if (m_value < std::numeric_limits::min()) + return std::numeric_limits::min(); + return m_value; + } + + std::vector getvch() const + { + return serialize(m_value); + } + + static std::vector serialize(const int64_t& value) + { + if(value == 0) + return std::vector(); + + // This could result in undefined behaviour in Bitcoin 0.10.0 and + // Zcash prior to https://github.com/zcash/zcash/pull/4454 . + // Since we only use this implementation for tests, we just assert + // that the tests are not triggering this case (which is tested + // separately for the real implementation). + assert(value != INT64_MIN); + + std::vector result; + const bool neg = value < 0; + uint64_t absvalue = neg ? -value : value; + + while(absvalue) + { + result.push_back(absvalue & 0xff); + absvalue >>= 8; + } + +// - If the most significant byte is >= 0x80 and the value is positive, push a +// new zero-byte to make the significant byte < 0x80 again. + +// - If the most significant byte is >= 0x80 and the value is negative, push a +// new 0x80 byte that will be popped off when converting to an integral. + +// - If the most significant byte is < 0x80 and the value is negative, add +// 0x80 to it, since it will be subtracted and interpreted as a negative when +// converting to an integral. + + if (result.back() & 0x80) + result.push_back(neg ? 0x80 : 0); + else if (neg) + result.back() |= 0x80; + + return result; + } + +private: + static int64_t set_vch(const std::vector& vch) + { + if (vch.empty()) + return 0; + + // This could result in undefined behaviour in Bitcoin 0.10.0 and + // Zcash prior to https://github.com/zcash/zcash/pull/4454 . + // Since we only use this implementation for tests, we just assert + // that the tests are not triggering this case (which is tested + // separately for the real implementation). + assert(vch.size() <= 8); + + int64_t result = 0; + for (size_t i = 0; i != vch.size(); ++i) + result |= static_cast(vch[i]) << 8*i; + + // If the input vector's most significant byte is 0x80, remove it from + // the result's msb and return a negative. + if (vch.back() & 0x80) + return -((int64_t)(result & ~(0x80ULL << (8 * (vch.size() - 1))))); + + return result; + } + + int64_t m_value; +}; + +#endif // BITCOIN_TEST_BIGNUM_H diff --git a/src/test/scriptnum_tests.cpp b/src/test/scriptnum_tests.cpp index 784ff7399..dcef1ce4c 100644 --- a/src/test/scriptnum_tests.cpp +++ b/src/test/scriptnum_tests.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or https://www.opensource.org/licenses/mit-license.php . -#include "bignum.h" +#include "scriptnum10.h" #include "script/script.h" #include "test/test_bitcoin.h" @@ -13,55 +13,68 @@ BOOST_FIXTURE_TEST_SUITE(scriptnum_tests, BasicTestingSetup) static const int64_t values[] = \ -{ 0, 1, CHAR_MIN, CHAR_MAX, UCHAR_MAX, SHRT_MIN, USHRT_MAX, INT_MIN, INT_MAX, UINT_MAX, LONG_MIN, LONG_MAX }; +{ 0, 1, CHAR_MIN, CHAR_MAX, UCHAR_MAX, SHRT_MIN, USHRT_MAX, INT_MIN, INT_MAX, UINT_MAX, INT64_MIN, INT64_MAX }; static const int64_t offsets[] = { 1, 0x79, 0x80, 0x81, 0xFF, 0x7FFF, 0x8000, 0xFFFF, 0x10000}; -static bool verify(const CBigNum& bignum, const CScriptNum& scriptnum) +static bool addition_in_range(int64_t a, int64_t b) { + // intentionally excludes cases where the result would be INT64_MIN + return b > 0 ? (a <= INT64_MAX - b) : (a > INT64_MIN - b); +} + +static bool subtraction_in_range(int64_t a, int64_t b) { + // intentionally excludes cases where the result would be INT64_MIN + return b >= 0 ? (a > INT64_MIN + b) : (a <= INT64_MAX + b); +} + +static bool value_in_range(int64_t a) { + return a != INT64_MIN; +} + +static bool verify(const CScriptNum10& bignum, const CScriptNum& scriptnum) { return bignum.getvch() == scriptnum.getvch() && bignum.getint() == scriptnum.getint(); } -static void CheckCreateVch(const int64_t& num) +static void CheckCreateVch(int64_t num) { - CBigNum bignum(num); + CScriptNum10 bignum(num); CScriptNum scriptnum(num); BOOST_CHECK(verify(bignum, scriptnum)); - CBigNum bignum2(bignum.getvch()); - CScriptNum scriptnum2(scriptnum.getvch(), false); + CScriptNum10 bignum2(bignum.getvch(), false); + std::vector scriptnum_vch = scriptnum.getvch(); + // The 9-byte case is exercised by the 'intmin' test. + BOOST_CHECK(scriptnum_vch.size() <= 8); + CScriptNum scriptnum2(scriptnum_vch, false); BOOST_CHECK(verify(bignum2, scriptnum2)); - CBigNum bignum3(scriptnum2.getvch()); + CScriptNum10 bignum3(scriptnum2.getvch(), false); CScriptNum scriptnum3(bignum2.getvch(), false); BOOST_CHECK(verify(bignum3, scriptnum3)); } -static void CheckCreateInt(const int64_t& num) +static void CheckCreateInt(int64_t num) { - CBigNum bignum(num); + CScriptNum10 bignum(num); CScriptNum scriptnum(num); BOOST_CHECK(verify(bignum, scriptnum)); - BOOST_CHECK(verify(bignum.getint(), CScriptNum(scriptnum.getint()))); - BOOST_CHECK(verify(scriptnum.getint(), CScriptNum(bignum.getint()))); - BOOST_CHECK(verify(CBigNum(scriptnum.getint()).getint(), CScriptNum(CScriptNum(bignum.getint()).getint()))); + BOOST_CHECK(verify(CScriptNum10(bignum.getint()), CScriptNum(scriptnum.getint()))); + BOOST_CHECK(verify(CScriptNum10(scriptnum.getint()), CScriptNum(bignum.getint()))); + BOOST_CHECK(verify(CScriptNum10(CScriptNum10(scriptnum.getint()).getint()), CScriptNum(CScriptNum(bignum.getint()).getint()))); } - -static void CheckAdd(const int64_t& num1, const int64_t& num2) +static void CheckAdd(int64_t num1, int64_t num2) { - const CBigNum bignum1(num1); - const CBigNum bignum2(num2); + const CScriptNum10 bignum1(num1); + const CScriptNum10 bignum2(num2); const CScriptNum scriptnum1(num1); const CScriptNum scriptnum2(num2); - CBigNum bignum3(num1); - CBigNum bignum4(num1); + CScriptNum10 bignum3(num1); + CScriptNum10 bignum4(num1); CScriptNum scriptnum3(num1); CScriptNum scriptnum4(num1); - // int64_t overflow is undefined. - bool invalid = (((num2 > 0) && (num1 > (std::numeric_limits::max() - num2))) || - ((num2 < 0) && (num1 < (std::numeric_limits::min() - num2)))); - if (!invalid) + if (addition_in_range(num1, num2)) { BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + scriptnum2)); BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + num2)); @@ -69,91 +82,84 @@ static void CheckAdd(const int64_t& num1, const int64_t& num2) } } -static void CheckNegate(const int64_t& num) +static void CheckNegate(int64_t num) { - const CBigNum bignum(num); + const CScriptNum10 bignum(num); const CScriptNum scriptnum(num); - // -INT64_MIN is undefined - if (num != std::numeric_limits::min()) - BOOST_CHECK(verify(-bignum, -scriptnum)); + BOOST_CHECK(verify(-bignum, -scriptnum)); } -static void CheckSubtract(const int64_t& num1, const int64_t& num2) +static void CheckSubtract(int64_t num1, int64_t num2) { - const CBigNum bignum1(num1); - const CBigNum bignum2(num2); + const CScriptNum10 bignum1(num1); + const CScriptNum10 bignum2(num2); const CScriptNum scriptnum1(num1); const CScriptNum scriptnum2(num2); bool invalid = false; - // int64_t overflow is undefined. - invalid = ((num2 > 0 && num1 < std::numeric_limits::min() + num2) || - (num2 < 0 && num1 > std::numeric_limits::max() + num2)); - if (!invalid) + if (subtraction_in_range(num1, num2)) { BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - scriptnum2)); BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - num2)); } - invalid = ((num1 > 0 && num2 < std::numeric_limits::min() + num1) || - (num1 < 0 && num2 > std::numeric_limits::max() + num1)); - if (!invalid) + if (subtraction_in_range(num2, num1)) { BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - scriptnum1)); BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - num1)); } } -static void CheckCompare(const int64_t& num1, const int64_t& num2) +static void CheckCompare(int64_t num1, int64_t num2) { - const CBigNum bignum1(num1); - const CBigNum bignum2(num2); + const CScriptNum10 bignum1(num1); + const CScriptNum10 bignum2(num2); const CScriptNum scriptnum1(num1); const CScriptNum scriptnum2(num2); BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == scriptnum1)); - BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != scriptnum1)); - BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < scriptnum1)); - BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > scriptnum1)); - BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= scriptnum1)); - BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= scriptnum1)); + BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != scriptnum1)); + BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < scriptnum1)); + BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > scriptnum1)); + BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= scriptnum1)); + BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= scriptnum1)); BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == num1)); - BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != num1)); - BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < num1)); - BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > num1)); - BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= num1)); - BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= num1)); - - BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == scriptnum2)); - BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != scriptnum2)); - BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < scriptnum2)); - BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > scriptnum2)); - BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= scriptnum2)); - BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= scriptnum2)); - - BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == num2)); - BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != num2)); - BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < num2)); - BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > num2)); - BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= num2)); - BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= num2)); + BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != num1)); + BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < num1)); + BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > num1)); + BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= num1)); + BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= num1)); + + BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == scriptnum2)); + BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != scriptnum2)); + BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < scriptnum2)); + BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > scriptnum2)); + BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= scriptnum2)); + BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= scriptnum2)); + + BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == num2)); + BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != num2)); + BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < num2)); + BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > num2)); + BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= num2)); + BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= num2)); } -static void RunCreate(const int64_t& num) +static void RunCreate(int64_t num) { CheckCreateInt(num); CScriptNum scriptnum(num); if (scriptnum.getvch().size() <= CScriptNum::nDefaultMaxNumSize) - CheckCreateVch(num); - else { - BOOST_CHECK_THROW (CheckCreateVch(num), scriptnum_error); + CheckCreateVch(num); + } else { + BOOST_CHECK_THROW(CheckCreateVch(num), scriptnum10_error); } } -static void RunOperators(const int64_t& num1, const int64_t& num2) +static void RunOperators(int64_t num1, int64_t num2) { CheckAdd(num1, num2); CheckSubtract(num1, num2); @@ -163,35 +169,56 @@ static void RunOperators(const int64_t& num1, const int64_t& num2) BOOST_AUTO_TEST_CASE(creation) { - for(size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i) + for (size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i) { - for(size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j) + for (size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j) { - RunCreate(values[i]); - RunCreate(values[i] + offsets[j]); - RunCreate(values[i] - offsets[j]); + if (value_in_range(values[i])) { + RunCreate(values[i]); + } + if (addition_in_range(values[i], offsets[j])) { + RunCreate(values[i] + offsets[j]); + } + if (subtraction_in_range(values[i], offsets[j])) { + RunCreate(values[i] - offsets[j]); + } } } } BOOST_AUTO_TEST_CASE(operators) { - for(size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i) + for (size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i) { - for(size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j) + for (size_t j = 0; j < sizeof(values) / sizeof(values[0]); ++j) { - RunOperators(values[i], values[i]); - RunOperators(values[i], -values[i]); - RunOperators(values[i], values[j]); - RunOperators(values[i], -values[j]); - RunOperators(values[i] + values[j], values[j]); - RunOperators(values[i] + values[j], -values[j]); - RunOperators(values[i] - values[j], values[j]); - RunOperators(values[i] - values[j], -values[j]); - RunOperators(values[i] + values[j], values[i] + values[j]); - RunOperators(values[i] + values[j], values[i] - values[j]); - RunOperators(values[i] - values[j], values[i] + values[j]); - RunOperators(values[i] - values[j], values[i] - values[j]); + if (value_in_range(values[i])) + { + RunOperators(values[i], values[i]); + RunOperators(values[i], -values[i]); + } + if (value_in_range(values[i]) && value_in_range(values[j])) + { + RunOperators(values[i], values[j]); + RunOperators(values[i], -values[j]); + } + if (addition_in_range(values[i], values[j]) && value_in_range(values[j])) + { + RunOperators(values[i] + values[j], values[j]); + RunOperators(values[i] + values[j], -values[j]); + RunOperators(values[i] + values[j], values[i] + values[j]); + } + if (subtraction_in_range(values[i], values[j]) && value_in_range(values[j])) + { + RunOperators(values[i] - values[j], values[j]); + RunOperators(values[i] - values[j], -values[j]); + RunOperators(values[i] - values[j], values[i] - values[j]); + } + if (addition_in_range(values[i], values[j]) && subtraction_in_range(values[i], values[j])) + { + RunOperators(values[i] + values[j], values[i] - values[j]); + RunOperators(values[i] - values[j], values[i] + values[j]); + } } } } diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp index fc91ea3e0..3677ddb3d 100644 --- a/src/test/sighash_tests.cpp +++ b/src/test/sighash_tests.cpp @@ -6,7 +6,7 @@ #include "consensus/validation.h" #include "data/sighash.json.h" #include "main.h" -#include "random.h" +#include "test_random.h" #include "script/interpreter.h" #include "script/script.h" #include "serialize.h" diff --git a/src/test/skiplist_tests.cpp b/src/test/skiplist_tests.cpp index 023a7cebb..c2a1e3bc8 100644 --- a/src/test/skiplist_tests.cpp +++ b/src/test/skiplist_tests.cpp @@ -3,7 +3,7 @@ // file COPYING or https://www.opensource.org/licenses/mit-license.php . #include "main.h" -#include "random.h" +#include "test_random.h" #include "util.h" #include "test/test_bitcoin.h" diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 02b6f8d33..6078c909a 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -31,6 +31,7 @@ CClientUIInterface uiInterface; // Declared but not defined in ui_interface.h CWallet* pwalletMain; ZCJoinSplit *pzcashParams; +FastRandomContext insecure_rand_ctx(true); extern bool fPrintToConsole; extern void noui_connect(); diff --git a/src/test/test_random.h b/src/test/test_random.h new file mode 100644 index 000000000..e61b92b7b --- /dev/null +++ b/src/test/test_random.h @@ -0,0 +1,23 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_TEST_RANDOM_H +#define BITCOIN_TEST_RANDOM_H + +#include "random.h" + +extern FastRandomContext insecure_rand_ctx; + +static inline void seed_insecure_rand(bool fDeterministic = false) +{ + insecure_rand_ctx = FastRandomContext(fDeterministic); +} + +static inline uint32_t insecure_rand(void) +{ + return insecure_rand_ctx.rand32(); +} + +#endif diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 24a096b1e..a42a0631d 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -6,7 +6,7 @@ #include "clientversion.h" #include "primitives/transaction.h" -#include "random.h" +#include "test_random.h" #include "sync.h" #include "utilstrencodings.h" #include "utilmoneystr.h" diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 3c48422dc..6e7438c97 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -483,7 +483,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const if (nCheckFrequency == 0) return; - if (insecure_rand() >= nCheckFrequency) + if (GetRand(std::numeric_limits::max()) >= nCheckFrequency) return; LogPrint("mempool", "Checking mempool with %u transactions and %u inputs\n", (unsigned int)mapTx.size(), (unsigned int)mapNextTx.size()); diff --git a/src/txmempool.h b/src/txmempool.h index 024ec019c..cdbda5d72 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -12,6 +12,7 @@ #include "coins.h" #include "primitives/transaction.h" #include "sync.h" +#include "random.h" #include "addressindex.h" #include "spentindex.h" diff --git a/src/util.cpp b/src/util.cpp index 336f2f0c4..012c753c9 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -82,8 +82,6 @@ #include #include #include -#include -#include // Work around clang compilation problem in Boost 1.46: // /usr/include/boost/program_options/detail/config_file.hpp:163:17: error: call to function 'to_internal' that is neither visible in the template definition nor found by argument-dependent lookup @@ -113,47 +111,6 @@ bool fLogIPs = DEFAULT_LOGIPS; std::atomic fReopenDebugLog(false); CTranslationInterface translationInterface; -/** Init OpenSSL library multithreading support */ -static CCriticalSection** ppmutexOpenSSL; -void locking_callback(int mode, int i, const char* file, int line) NO_THREAD_SAFETY_ANALYSIS -{ - if (mode & CRYPTO_LOCK) { - ENTER_CRITICAL_SECTION(*ppmutexOpenSSL[i]); - } else { - LEAVE_CRITICAL_SECTION(*ppmutexOpenSSL[i]); - } -} - -// Init -static class CInit -{ -public: - CInit() - { - // Init OpenSSL library multithreading support - ppmutexOpenSSL = (CCriticalSection**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(CCriticalSection*)); - for (int i = 0; i < CRYPTO_num_locks(); i++) - ppmutexOpenSSL[i] = new CCriticalSection(); - CRYPTO_set_locking_callback(locking_callback); - - // OpenSSL can optionally load a config file which lists optional loadable modules and engines. - // We don't use them so we don't require the config. However some of our libs may call functions - // which attempt to load the config file, possibly resulting in an exit() or crash if it is missing - // or corrupt. Explicitly tell OpenSSL not to try to load the file. The result for our libs will be - // that the config appears to have been loaded and there are no modules/engines available. - OPENSSL_no_config(); - } - ~CInit() - { - // Shutdown OpenSSL library multithreading support - CRYPTO_set_locking_callback(NULL); - for (int i = 0; i < CRYPTO_num_locks(); i++) - delete ppmutexOpenSSL[i]; - OPENSSL_free(ppmutexOpenSSL); - } -} -instance_of_cinit; - /** * LogPrintf() has been broken a couple of times now * by well-meaning people adding mutexes in the most straightforward way. @@ -919,9 +876,7 @@ std::string LicenseInfo() "\n" + FormatParagraph(_("This is experimental software.")) + "\n" + "\n" + - FormatParagraph(_("Distributed under the MIT software license, see the accompanying file COPYING or .")) + "\n" + - "\n" + - FormatParagraph(_("This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit and cryptographic software written by Eric Young.")) + + FormatParagraph(_("Distributed under the MIT software license, see the accompanying file COPYING or .")) + "\n"; } diff --git a/src/wallet/crypter.cpp b/src/wallet/crypter.cpp index 0c39825bc..59a5f4a92 100644 --- a/src/wallet/crypter.cpp +++ b/src/wallet/crypter.cpp @@ -4,6 +4,8 @@ #include "crypter.h" +#include "crypto/aes.h" +#include "crypto/sha512.h" #include "script/script.h" #include "script/standard.h" #include "streams.h" @@ -12,8 +14,33 @@ #include #include #include -#include -#include + +int CCrypter::BytesToKeySHA512AES(const std::vector& chSalt, const SecureString& strKeyData, int count, unsigned char *key,unsigned char *iv) const +{ + // This mimics the behavior of openssl's EVP_BytesToKey with an aes256cbc + // cipher and sha512 message digest. Because sha512's output size (64b) is + // greater than the aes256 block size (16b) + aes256 key size (32b), + // there's no need to process more than once (D_0). + + if(!count || !key || !iv) + return 0; + + unsigned char buf[CSHA512::OUTPUT_SIZE]; + CSHA512 di; + + di.Write((const unsigned char*)strKeyData.c_str(), strKeyData.size()); + if(chSalt.size()) + di.Write(&chSalt[0], chSalt.size()); + di.Finalize(buf); + + for(int i = 0; i != count - 1; i++) + di.Reset().Write(buf, sizeof(buf)).Finalize(buf); + + memcpy(key, buf, WALLET_CRYPTO_KEY_SIZE); + memcpy(iv, buf + WALLET_CRYPTO_KEY_SIZE, WALLET_CRYPTO_IV_SIZE); + memory_cleanse(buf, sizeof(buf)); + return WALLET_CRYPTO_KEY_SIZE; +} bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod) { @@ -22,13 +49,12 @@ bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::v int i = 0; if (nDerivationMethod == 0) - i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha512(), &chSalt[0], - (unsigned char *)&strKeyData[0], strKeyData.size(), nRounds, chKey, chIV); + i = BytesToKeySHA512AES(chSalt, strKeyData, nRounds, vchKey.data(), vchIV.data()); if (i != (int)WALLET_CRYPTO_KEY_SIZE) { - memory_cleanse(chKey, sizeof(chKey)); - memory_cleanse(chIV, sizeof(chIV)); + memory_cleanse(vchKey.data(), vchKey.size()); + memory_cleanse(vchIV.data(), vchIV.size()); return false; } @@ -38,65 +64,50 @@ bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::v bool CCrypter::SetKey(const CKeyingMaterial& chNewKey, const std::vector& chNewIV) { - if (chNewKey.size() != WALLET_CRYPTO_KEY_SIZE || chNewIV.size() != WALLET_CRYPTO_KEY_SIZE) + if (chNewKey.size() != WALLET_CRYPTO_KEY_SIZE || chNewIV.size() != WALLET_CRYPTO_IV_SIZE) return false; - memcpy(&chKey[0], &chNewKey[0], sizeof chKey); - memcpy(&chIV[0], &chNewIV[0], sizeof chIV); + memcpy(vchKey.data(), chNewKey.data(), chNewKey.size()); + memcpy(vchIV.data(), chNewIV.data(), chNewIV.size()); fKeySet = true; return true; } -bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector &vchCiphertext) +bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector &vchCiphertext) const { if (!fKeySet) return false; // max ciphertext len for a n bytes of plaintext is - // n + AES_BLOCK_SIZE - 1 bytes - int nLen = vchPlaintext.size(); - int nCLen = nLen + AES_BLOCK_SIZE, nFLen = 0; - vchCiphertext = std::vector (nCLen); - - bool fOk = true; + // n + AES_BLOCKSIZE bytes + vchCiphertext.resize(vchPlaintext.size() + AES_BLOCKSIZE); - EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); - assert(ctx); - if (fOk) fOk = EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV) != 0; - if (fOk) fOk = EVP_EncryptUpdate(ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen) != 0; - if (fOk) fOk = EVP_EncryptFinal_ex(ctx, (&vchCiphertext[0]) + nCLen, &nFLen) != 0; - EVP_CIPHER_CTX_free(ctx); - - if (!fOk) return false; + AES256CBCEncrypt enc(vchKey.data(), vchIV.data(), true); + size_t nLen = enc.Encrypt(&vchPlaintext[0], vchPlaintext.size(), &vchCiphertext[0]); + if(nLen < vchPlaintext.size()) + return false; + vchCiphertext.resize(nLen); - vchCiphertext.resize(nCLen + nFLen); return true; } -bool CCrypter::Decrypt(const std::vector& vchCiphertext, CKeyingMaterial& vchPlaintext) +bool CCrypter::Decrypt(const std::vector& vchCiphertext, CKeyingMaterial& vchPlaintext) const { if (!fKeySet) return false; // plaintext will always be equal to or lesser than length of ciphertext int nLen = vchCiphertext.size(); - int nPLen = nLen, nFLen = 0; - vchPlaintext = CKeyingMaterial(nPLen); + vchPlaintext.resize(nLen); - bool fOk = true; - - EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); - assert(ctx); - if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV) != 0; - if (fOk) fOk = EVP_DecryptUpdate(ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen) != 0; - if (fOk) fOk = EVP_DecryptFinal_ex(ctx, (&vchPlaintext[0]) + nPLen, &nFLen) != 0; - EVP_CIPHER_CTX_free(ctx); - - if (!fOk) return false; + AES256CBCDecrypt dec(vchKey.data(), vchIV.data(), true); + nLen = dec.Decrypt(&vchCiphertext[0], vchCiphertext.size(), &vchPlaintext[0]); + if(nLen == 0) + return false; + vchPlaintext.resize(nLen); - vchPlaintext.resize(nPLen + nFLen); return true; } @@ -104,8 +115,8 @@ bool CCrypter::Decrypt(const std::vector& vchCiphertext, CKeyingM static bool EncryptSecret(const CKeyingMaterial& vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256& nIV, std::vector &vchCiphertext) { CCrypter cKeyCrypter; - std::vector chIV(WALLET_CRYPTO_KEY_SIZE); - memcpy(&chIV[0], &nIV, WALLET_CRYPTO_KEY_SIZE); + std::vector chIV(WALLET_CRYPTO_IV_SIZE); + memcpy(&chIV[0], &nIV, WALLET_CRYPTO_IV_SIZE); if (!cKeyCrypter.SetKey(vMasterKey, chIV)) return false; return cKeyCrypter.Encrypt(*((const CKeyingMaterial*)&vchPlaintext), vchCiphertext); @@ -114,8 +125,8 @@ static bool EncryptSecret(const CKeyingMaterial& vMasterKey, const CKeyingMateri static bool DecryptSecret(const CKeyingMaterial& vMasterKey, const std::vector& vchCiphertext, const uint256& nIV, CKeyingMaterial& vchPlaintext) { CCrypter cKeyCrypter; - std::vector chIV(WALLET_CRYPTO_KEY_SIZE); - memcpy(&chIV[0], &nIV, WALLET_CRYPTO_KEY_SIZE); + std::vector chIV(WALLET_CRYPTO_IV_SIZE); + memcpy(&chIV[0], &nIV, WALLET_CRYPTO_IV_SIZE); if (!cKeyCrypter.SetKey(vMasterKey, chIV)) return false; return cKeyCrypter.Decrypt(vchCiphertext, *((CKeyingMaterial*)&vchPlaintext)); diff --git a/src/wallet/crypter.h b/src/wallet/crypter.h index 84a644f96..5c30ee8f3 100644 --- a/src/wallet/crypter.h +++ b/src/wallet/crypter.h @@ -15,6 +15,7 @@ class uint256; const unsigned int WALLET_CRYPTO_KEY_SIZE = 32; const unsigned int WALLET_CRYPTO_SALT_SIZE = 8; +const unsigned int WALLET_CRYPTO_IV_SIZE = 16; /** * Private key encryption is done based on a CMasterKey, @@ -80,44 +81,45 @@ class CSecureDataStream : public CBaseDataStream CBaseDataStream(vchIn, nTypeIn, nVersionIn) { } }; +namespace wallet_crypto +{ + class TestCrypter; +} + /** Encryption/decryption context with key information */ class CCrypter { +friend class wallet_crypto::TestCrypter; // for test access to chKey/chIV private: - unsigned char chKey[WALLET_CRYPTO_KEY_SIZE]; - unsigned char chIV[WALLET_CRYPTO_KEY_SIZE]; + std::vector> vchKey; + std::vector> vchIV; bool fKeySet; + int BytesToKeySHA512AES(const std::vector& chSalt, const SecureString& strKeyData, int count, unsigned char *key,unsigned char *iv) const; + public: bool SetKeyFromPassphrase(const SecureString &strKeyData, const std::vector& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod); - bool Encrypt(const CKeyingMaterial& vchPlaintext, std::vector &vchCiphertext); - bool Decrypt(const std::vector& vchCiphertext, CKeyingMaterial& vchPlaintext); + bool Encrypt(const CKeyingMaterial& vchPlaintext, std::vector &vchCiphertext) const; + bool Decrypt(const std::vector& vchCiphertext, CKeyingMaterial& vchPlaintext) const; bool SetKey(const CKeyingMaterial& chNewKey, const std::vector& chNewIV); void CleanKey() { - memory_cleanse(chKey, sizeof(chKey)); - memory_cleanse(chIV, sizeof(chIV)); + memory_cleanse(vchKey.data(), vchKey.size()); + memory_cleanse(vchIV.data(), vchIV.size()); fKeySet = false; } CCrypter() { fKeySet = false; - - // Try to keep the key data out of swap (and be a bit over-careful to keep the IV that we don't even use out of swap) - // Note that this does nothing about suspend-to-disk (which will put all our key data on disk) - // Note as well that at no point in this program is any attempt made to prevent stealing of keys by reading the memory of the running process. - LockedPageManager::Instance().LockRange(&chKey[0], sizeof chKey); - LockedPageManager::Instance().LockRange(&chIV[0], sizeof chIV); + vchKey.resize(WALLET_CRYPTO_KEY_SIZE); + vchIV.resize(WALLET_CRYPTO_IV_SIZE); } ~CCrypter() { CleanKey(); - - LockedPageManager::Instance().UnlockRange(&chKey[0], sizeof chKey); - LockedPageManager::Instance().UnlockRange(&chIV[0], sizeof chIV); } }; diff --git a/src/wallet/db.h b/src/wallet/db.h index 1ae5a03b5..2c38e0bf8 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -17,6 +17,7 @@ #include #include +#include #include @@ -125,21 +126,23 @@ class CDB Dbt datValue; datValue.set_flags(DB_DBT_MALLOC); int ret = pdb->get(activeTxn, &datKey, &datValue, 0); - memset(datKey.get_data(), 0, datKey.get_size()); - if (datValue.get_data() == NULL) - return false; - - // Unserialize value - try { - CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK, CLIENT_VERSION); - ssValue >> value; - } catch (const std::exception&) { - return false; + memory_cleanse(datKey.get_data(), datKey.get_size()); + if (datValue.get_data() != NULL) { + BOOST_SCOPE_EXIT_TPL(&datValue) { + // Clear and free memory + memory_cleanse(datValue.get_data(), datValue.get_size()); + free(datValue.get_data()); + } BOOST_SCOPE_EXIT_END + + + // Unserialize value + try { + CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK, CLIENT_VERSION); + ssValue >> value; + } catch (const std::exception&) { + return false; + } } - - // Clear and free memory - memset(datValue.get_data(), 0, datValue.get_size()); - free(datValue.get_data()); return (ret == 0); } @@ -167,8 +170,8 @@ class CDB int ret = pdb->put(activeTxn, &datKey, &datValue, (fOverwrite ? 0 : DB_NOOVERWRITE)); // Clear memory in case it was a private key - memset(datKey.get_data(), 0, datKey.get_size()); - memset(datValue.get_data(), 0, datValue.get_size()); + memory_cleanse(datKey.get_data(), datKey.get_size()); + memory_cleanse(datValue.get_data(), datValue.get_size()); return (ret == 0); } @@ -190,7 +193,7 @@ class CDB int ret = pdb->del(activeTxn, &datKey, 0); // Clear memory - memset(datKey.get_data(), 0, datKey.get_size()); + memory_cleanse(datKey.get_data(), datKey.get_size()); return (ret == 0 || ret == DB_NOTFOUND); } @@ -210,7 +213,7 @@ class CDB int ret = pdb->exists(activeTxn, &datKey, 0); // Clear memory - memset(datKey.get_data(), 0, datKey.get_size()); + memory_cleanse(datKey.get_data(), datKey.get_size()); return (ret == 0); } @@ -255,8 +258,8 @@ class CDB ssValue.write((char*)datValue.get_data(), datValue.get_size()); // Clear and free memory - memset(datKey.get_data(), 0, datKey.get_size()); - memset(datValue.get_data(), 0, datValue.get_size()); + memory_cleanse(datKey.get_data(), datKey.get_size()); + memory_cleanse(datValue.get_data(), datValue.get_size()); free(datKey.get_data()); free(datValue.get_data()); return 0; diff --git a/src/wallet/test/crypto_tests.cpp b/src/wallet/test/crypto_tests.cpp new file mode 100644 index 000000000..7a7a45479 --- /dev/null +++ b/src/wallet/test/crypto_tests.cpp @@ -0,0 +1,129 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "test/test_random.h" +#include "utilstrencodings.h" +#include "test/test_bitcoin.h" +#include "wallet/crypter.h" + +#include + +#include + +BOOST_FIXTURE_TEST_SUITE(wallet_crypto, BasicTestingSetup) + +class TestCrypter +{ +public: +static void TestPassphraseSingle(const std::vector& vchSalt, const SecureString& passphrase, uint32_t rounds, + const std::vector& correctKey = std::vector(), + const std::vector& correctIV=std::vector()) +{ + CCrypter crypt; + crypt.SetKeyFromPassphrase(passphrase, vchSalt, rounds, 0); + + if(!correctKey.empty()) + BOOST_CHECK_MESSAGE(memcmp(crypt.vchKey.data(), correctKey.data(), crypt.vchKey.size()) == 0, \ + HexStr(crypt.vchKey.begin(), crypt.vchKey.end()) + std::string(" != ") + HexStr(correctKey.begin(), correctKey.end())); + if(!correctIV.empty()) + BOOST_CHECK_MESSAGE(memcmp(crypt.vchIV.data(), correctIV.data(), crypt.vchIV.size()) == 0, + HexStr(crypt.vchIV.begin(), crypt.vchIV.end()) + std::string(" != ") + HexStr(correctIV.begin(), correctIV.end())); +} + +static void TestPassphrase(const std::vector& vchSalt, const SecureString& passphrase, uint32_t rounds, + const std::vector& correctKey = std::vector(), + const std::vector& correctIV=std::vector()) +{ + TestPassphraseSingle(vchSalt, passphrase, rounds, correctKey, correctIV); + for(SecureString::const_iterator i(passphrase.begin()); i != passphrase.end(); ++i) + TestPassphraseSingle(vchSalt, SecureString(i, passphrase.end()), rounds); +} + +static void TestDecrypt(const CCrypter& crypt, const std::vector& vchCiphertext, \ + const std::vector& vchPlaintext = std::vector()) +{ + CKeyingMaterial vchDecrypted; + crypt.Decrypt(vchCiphertext, vchDecrypted); + + if (vchPlaintext.size()) + BOOST_CHECK(CKeyingMaterial(vchPlaintext.begin(), vchPlaintext.end()) == vchDecrypted); +} + +static void TestEncryptSingle(const CCrypter& crypt, const CKeyingMaterial& vchPlaintext, + const std::vector& vchCiphertextCorrect = std::vector()) +{ + std::vector vchCiphertext; + crypt.Encrypt(vchPlaintext, vchCiphertext); + + if (!vchCiphertextCorrect.empty()) + BOOST_CHECK(vchCiphertext == vchCiphertextCorrect); + + const std::vector vchPlaintext2(vchPlaintext.begin(), vchPlaintext.end()); + + TestDecrypt(crypt, vchCiphertext, vchPlaintext2); +} + +static void TestEncrypt(const CCrypter& crypt, const std::vector& vchPlaintextIn, \ + const std::vector& vchCiphertextCorrect = std::vector()) +{ + TestEncryptSingle(crypt, CKeyingMaterial(vchPlaintextIn.begin(), vchPlaintextIn.end()), vchCiphertextCorrect); + for(std::vector::const_iterator i(vchPlaintextIn.begin()); i != vchPlaintextIn.end(); ++i) + TestEncryptSingle(crypt, CKeyingMaterial(i, vchPlaintextIn.end())); +} + +}; + +BOOST_AUTO_TEST_CASE(passphrase) { + // These are expensive. + + TestCrypter::TestPassphrase(ParseHex("0000deadbeef0000"), "test", 25000, \ + ParseHex("fc7aba077ad5f4c3a0988d8daa4810d0d4a0e3bcb53af662998898f33df0556a"), \ + ParseHex("cf2f2691526dd1aa220896fb8bf7c369")); + + std::string hash(GetRandHash().ToString()); + std::vector vchSalt(8); + GetRandBytes(&vchSalt[0], vchSalt.size()); + uint32_t rounds = insecure_rand(); + if (rounds > 30000) + rounds = 30000; + TestCrypter::TestPassphrase(vchSalt, SecureString(hash.begin(), hash.end()), rounds); +} + +BOOST_AUTO_TEST_CASE(encrypt) { + std::vector vchSalt = ParseHex("0000deadbeef0000"); + BOOST_CHECK(vchSalt.size() == WALLET_CRYPTO_SALT_SIZE); + CCrypter crypt; + crypt.SetKeyFromPassphrase("passphrase", vchSalt, 25000, 0); + TestCrypter::TestEncrypt(crypt, ParseHex("22bcade09ac03ff6386914359cfe885cfeb5f77ff0d670f102f619687453b29d")); + + for (int i = 0; i != 100; i++) + { + uint256 hash(GetRandHash()); + TestCrypter::TestEncrypt(crypt, std::vector(hash.begin(), hash.end())); + } + +} + +BOOST_AUTO_TEST_CASE(decrypt) { + std::vector vchSalt = ParseHex("0000deadbeef0000"); + BOOST_CHECK(vchSalt.size() == WALLET_CRYPTO_SALT_SIZE); + CCrypter crypt; + crypt.SetKeyFromPassphrase("passphrase", vchSalt, 25000, 0); + + // Some corner cases the came up while testing + TestCrypter::TestDecrypt(crypt,ParseHex("795643ce39d736088367822cdc50535ec6f103715e3e48f4f3b1a60a08ef59ca")); + TestCrypter::TestDecrypt(crypt,ParseHex("de096f4a8f9bd97db012aa9d90d74de8cdea779c3ee8bc7633d8b5d6da703486")); + TestCrypter::TestDecrypt(crypt,ParseHex("32d0a8974e3afd9c6c3ebf4d66aa4e6419f8c173de25947f98cf8b7ace49449c")); + TestCrypter::TestDecrypt(crypt,ParseHex("e7c055cca2faa78cb9ac22c9357a90b4778ded9b2cc220a14cea49f931e596ea")); + TestCrypter::TestDecrypt(crypt,ParseHex("b88efddd668a6801d19516d6830da4ae9811988ccbaf40df8fbb72f3f4d335fd")); + TestCrypter::TestDecrypt(crypt,ParseHex("8cae76aa6a43694e961ebcb28c8ca8f8540b84153d72865e8561ddd93fa7bfa9")); + + for (int i = 0; i != 100; i++) + { + uint256 hash(GetRandHash()); + TestCrypter::TestDecrypt(crypt, std::vector(hash.begin(), hash.end())); + } +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1390a2c44..74f170e52 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3120,7 +3120,7 @@ static void ApproximateBestSubset(vector Date: Sun, 14 Jul 2024 13:10:11 +0000 Subject: [PATCH 013/162] Fix 'founders_reward_test' errors --- src/Makefile.gtest.include | 30 ++++---- src/chainparams.cpp | 103 +--------------------------- src/gtest/test_deprecation.cpp | 2 +- src/gtest/test_foundersreward.cpp | 109 ++++++++++++++++++------------ 4 files changed, 84 insertions(+), 160 deletions(-) diff --git a/src/Makefile.gtest.include b/src/Makefile.gtest.include index bfb855da9..2abcc2f87 100644 --- a/src/Makefile.gtest.include +++ b/src/Makefile.gtest.include @@ -5,13 +5,13 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or https://www.opensource.org/licenses/mit-license.php . -TESTS += zcash-gtest -noinst_PROGRAMS += zcash-gtest +TESTS += bitcoinz-gtest +noinst_PROGRAMS += bitcoinz-gtest # tool for generating our public parameters. # test_checktransaction.cpp MUST be before # any test that calls SelectParams(). -zcash_gtest_SOURCES = \ +bitcoinz_gtest_SOURCES = \ gtest/main.cpp \ gtest/utils.cpp \ gtest/test_checktransaction.cpp \ @@ -21,10 +21,10 @@ zcash_gtest_SOURCES = \ # These tests are order-dependent, because they # depend on global state (see #1539) if ENABLE_WALLET -zcash_gtest_SOURCES += \ +bitcoinz_gtest_SOURCES += \ wallet/gtest/test_wallet_zkeys.cpp endif -zcash_gtest_SOURCES += \ +bitcoinz_gtest_SOURCES += \ gtest/test_tautology.cpp \ gtest/test_deprecation.cpp \ gtest/test_equihash.cpp \ @@ -51,15 +51,15 @@ zcash_gtest_SOURCES += \ gtest/test_checkblock.cpp \ gtest/test_zip32.cpp if ENABLE_WALLET -zcash_gtest_SOURCES += \ +bitcoinz_gtest_SOURCES += \ wallet/gtest/test_paymentdisclosure.cpp \ wallet/gtest/test_wallet.cpp endif -zcash_gtest_CPPFLAGS = $(AM_CPPFLAGS) -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DSTATIC $(BITCOIN_INCLUDES) -zcash_gtest_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +bitcoinz_gtest_CPPFLAGS = $(AM_CPPFLAGS) -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DSTATIC $(BITCOIN_INCLUDES) +bitcoinz_gtest_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -zcash_gtest_LDADD = \ +bitcoinz_gtest_LDADD = \ -lgtest -lgmock \ $(LIBBITCOIN_SERVER) \ $(LIBBITCOIN_CLI) \ @@ -74,7 +74,7 @@ zcash_gtest_LDADD = \ $(LIBMEMENV) \ $(LIBSECP256K1) -zcash_gtest_LDADD += \ +bitcoinz_gtest_LDADD += \ $(LIBZCASH_CONSENSUS) \ $(BOOST_LIBS) \ $(BOOST_UNIT_TEST_FRAMEWORK_LIB) \ @@ -88,10 +88,10 @@ zcash_gtest_LDADD += \ $(LIBZCASH_LIBS) -zcash_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static +bitcoinz_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static -zcash-gtest_check: zcash-gtest FORCE - ./zcash-gtest +bitcoinz-gtest_check: bitcoinz-gtest FORCE + ./bitcoinz-gtest -zcash-gtest-expected-failures: zcash-gtest FORCE - ./zcash-gtest --gtest_filter=*DISABLED_* --gtest_also_run_disabled_tests +bitcoinz-gtest-expected-failures: bitcoinz-gtest FORCE + ./bitcoinz-gtest --gtest_filter=*DISABLED_* --gtest_also_run_disabled_tests diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 47a17a07b..8fe6fa3f5 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -677,109 +677,10 @@ class CRegTestParams : public CChainParams { // Founders reward script expects a vector of 2-of-3 multisig addresses vCommunityFeeAddress = { - "t2FpKCWt95LAPVRed61YbBny9yz5nqexLGN", - "t2RqJNenxiDjC5NiVo84xgfHcYuwsPcpCie", - "t2MsHkAug2oEiqj4L5ZGZH1vHmdogTSb9km", - "t2EwBFfC96DCiCAcJuEqGUbUes8rTNmaD6Q", - "t2JqYXRoTsKb9r1rTLLwDs5jMXzsRBV317k", - "t2RocidGU4ReKPK2uTPYfNFgeZEWDCd3jsj", - "t2Mu8ToNiVow92PfETBk5Z6HWuAEG7RVXVD", - "t2MSLT1n4eQ87QC2FAxMvuTZ84zDzEj7FhQ", - "t2JZNFrWv1c4RqkCmDN9iRkPsG8xAZFdyGS", - "t2AyjEVUCf5jthGHZjwfbztDBHQbztkJB5v", - "t2Gs6dTYCzaFdHSeT91zaFLKmYzyqYY3NnP", - "t2FXfNK7iQhTdMFcGUyrizqXQE5qbmPK6zc", - "t2UqLwQ85pR1fdFMoUzXadXRB97JxP6vTWY", - "t2BocGBq7iBXQP8UQiousNVwU8M6AqUtaRx", - "t2VGGdXhspjF3iQvbWZW2zPNSDRSYauBcM3", - "t2HTNHicoeEXxsX1wVhsqsX3LgzRq2pYgWH", - "t2UiVSyM1vuvs6xP3157ytuYMKN6MuqmgJE", - "t2UmPyNoWSVUgyPzEXzFGN5GS96jMH2kreW", - "t2MQWZJHxZF5zSw6LbZ3S7jqoLX1y6SWLHQ", - "t2VUR1c1aFaTUo93uhi7rfFVRRZaT1aQYbv", - "t2NgLU6QCJhCKgBsR5uX6R4ds82jymzMoMJ", - "t2RorFwMUEb7NamvXFi3jCXitAdRoQtU1Hs", - "t2FFtmwePBnYaRVRVg1wsoBPxDzGMLrz3Jv", - "t2GH3734fKEhPo3NvvAZQazsFf3V51oR4c2", - "t2Ev3twAmUmono3gM2Q6RsfhRiryy7TnX5E", - "t2EmhhAjh6cLpyw6Yc9QEXvsjm7qdKpgFQP", - "t2Gy5N7DYbEZmiHqm3m8Re25a8Bxu7e36ju", - "t2LVSaxizciFWfc5gr1xccHXT115RSnQ13r", - "t28zy3Qiq3FtMeB2PCEysF7R5TgW5UfZN1N", - "t2FcN7o26gRCc8ZuSZcc7X7APPRqWQ5a3W2", - "t27QTHP9qoi5HkiTqx4JV86MGG37aikK51s", - "t2CwQ6H9GPT77nqRwkHCuVcyGvtbhxWHfAk", - "t2HLUDaoimaaSpQhHnvbqpKg6Fi37rAo6cx", - "t2Ebuq1FX7Qzi3ur1FnwsDMvfNBFjqVqDGX", - "t2Bca3HbSbwgQp1ZhzheNvGfpwBoU6Syt8G", - "t2EurfAqyJMsCyx6ujYecQSxrPPY7xxTqcB", - "t2R1kJGeNhLpKx1dKNCnBUq1BkxBVJjQdcp", - "t2M3x9koBJWJS1F9bGtWXTsVfr5pesWSTbR", - "t2La4mEMruVTtBqhndS7zRvmi2WsqWUjPQz", - "t29GwTHLXxYgF5k7SSj7XFaHB7JsocM9bDU", - "t2Awpdv7yG2QFeHeq17J1qCSXRw1AM3mfmz", - "t2BfotpLdNhhewRp9nXpBBYViBaq4y1Lnj5", - "t2F4CH89prySyGZHUiPYJUjnZk9UPXgLBbf", - "t2DNx1KzP8a2S3kZgAPngso9ptva5gE7Jbn", - "t2Eb7orwhjGcu4wYwHBzN5BoXzroPGq3CoM", - "t2BXYmM21WCdHiC1KiwQVHxaTvLQJpqXTvH", - "t27Y6774dwAcCFvYrhDKTXgaxtUewAdZdtz", - "t2JvmRjZnViBZXJJBekDygdvGTCRNWgFEK2", - "t2PL5W7qy1DKNRPWECbaZ6gV9GEzMn8h97Z", - "t2S1JaefdSNwaUexdr6ZtNJhqZS8uDGSNFg", - "t2BTunj4VB44Q22crWpT1ykoBvNGFKMnD7N", - "t2G7DkSoEUJGaEBH6erKsXemoHFqqTRaSiZ", - "t2Ldg8Bc6AWDuESqPgUoumWfCYw3zqKF8s9", - "t2Ft4QMMiJfKXVbhyGBrkwjnfn5ua73VuLo", - "t26xLxd4Fabbotkc9gfFwpCVHoZG1W9rmN7", - "t2DyghJMpK6rRKPEAL3DBKmCntUcj8bUiHg", - "t2RSYhCsgw2AdBiUUyXBCkFf2xE9ddwyESD", - "t26fv5NLiFYXMmfQnvqcJXcYnt5NY41eqrv", - "t2Ppht55eXKC1BX7pfusJxZqbHnkp9oWbBW", - "t2P4AWJ5C4ySU3KzfehAeppH2BV4Y87w34z", - "t28zjDUH2Gkvt8Ytb8UrW7L6G5U1QMwJFM3", - "t2JXDd9pumryTAXqDD98vDLS2ZLSQCNQrYZ", - "t2BNuNGnGq49MZzr7SH8WtEE7sSwZ9n3bsz", - "t2QumKdHZhkFD6ntrzJ9zJAga2QemEgqc9r", - "t2UKz2L7V3C6GTeBPDXmQnwMyqKEbgMpuXg", - "t2CyVugoafiDYpeSNd9DGZEng6Bpr4tqa3d", - "t2GR9eEen8KUDjhQG1opC1aFt27zxdtufnF", - "t2JKYuSRNupdHdTR91tqR4xsaU6friVJJgv", - "t2D2yMZEM3K8ap6iLo3FX2g1Ch9coPSVq2R", - "t2SeFu34eiE2rCPFpxrN8im6ZvcwMpdKnit", - "t2KH46EXQy5wnZHDGVDA7Q13FdRkdQ3LUou", - "t2UsTpuVqP6ZubtN8tQGPnh7Cqjjf1hoefd", - "t2Dd119xiqDbF9QzWwYfnYWUPfqgnL1CNFu", - "t29PjecMhv6EygD8W6smcMHAB8MSHQY3YnQ", - "t2BDZpxgcMRzqgKbDBiXRXrvL3VwD7G8cLc", - "t2MwiKqfCMdy7o96bXvbZ5aGCrRmVfVWVfA", - "t2Vhkny4jNjy6ZD53jeQzsdgZiZyejwRsgY", - "t2K3ouBrLAbYwZv6beoHjzfsE1AbYVa6PuE", - "t2DskMSpWs8i9vK2PhNpi9Mu2qJSvEDi8UZ", - "t2JB2Uz3eVWrxFhas1B1cSXLP22JHbRNYtL", - "t2ArYKW1L8hRoCDK9odNmD4piRwFheErWL1", - "t2K1zKGHrkibiFoYJ5GtfHe5xJecJPEvFwQ", - "t2VnABknMprtMk8y5AdDCBr2R9QZnMhfqSm", - "t2FbjEsP9eeQr5PmP7yC3fopPTuYS9E9VgN", - "t2Sn2XUPZEnFcggB77jvxBqX6LcjdCzcJUs", - "t2SEK3Tw5FYYUaeZcF5QemfeG3tiorrxNKp", - "t2D78THpHVodnhiREjF22A3KRznor5pPnR1", - "t2GyqFdkf6FoQTShEhLGsNrTxAWqmeq4pui", - "t2HnNgFLznEqaokYq8PBV44uzRwAmJXQeKd", - "t2PpHVStdHvWkzXsyuyPYQQq96ZRQu7ALpE", - "t2FHbHM9rKKHZe74HRBNozwNdRsExug8tCw", - "t29tM6DkMPSVp9R3g7UjZjvsobKhsbsRqFL", - "t2K2KixLVJo19phPJMv9ApSiFmxQCSQUvc9", - "t2AWJcGVUMWFC8A9KC3PL7qoCb1vxSzxbJP", - "t26p8FyjHmhqZ6duzhRFLCQcExh1TuCD1sC", - "t27x5n41uRNF3tJkb3Lg1CMomUjTNZwtUfm", - "t2VhRQJ9xeVkVVk7ic21CtDePKmHnrDyF8Z", - "t27hL1iAsTHBPWrdc1qYGSSTc3pTyBqohd4", - "t2RqLYWG8Eo4hopDsn1m8GUoAWtjZQEPE9s", "t2V1osVDkcwYFL4PF9qG8t9Ez1XRVMAkAb6" }; - vCommunityFeeStartHeight = 200; - vCommunityFeeLastHeight = 1400000; + vCommunityFeeStartHeight = 0; + vCommunityFeeLastHeight = 150; assert(vCommunityFeeAddress.size() <= GetLastCommunityFeeBlockHeight()); } diff --git a/src/gtest/test_deprecation.cpp b/src/gtest/test_deprecation.cpp index fb18d94f0..0db535f15 100644 --- a/src/gtest/test_deprecation.cpp +++ b/src/gtest/test_deprecation.cpp @@ -152,7 +152,7 @@ TEST_F(DeprecationTest, AlertNotify) { // -alertnotify restricts the message to safe characters. auto expectedMsg = strprintf( - "This version will be deprecated at block height %d, and will automatically shut down. You should upgrade to the latest version of Zcash.", + "This version will be deprecated at block height %d, and will automatically shut down. You should upgrade to the latest version of BitcoinZ.", DEPRECATION_HEIGHT); // Windows built-in echo semantics are different than posixy shells. Quotes and diff --git a/src/gtest/test_foundersreward.cpp b/src/gtest/test_foundersreward.cpp index e97055093..97491ba3f 100644 --- a/src/gtest/test_foundersreward.cpp +++ b/src/gtest/test_foundersreward.cpp @@ -16,7 +16,7 @@ #include "utiltest.h" // To run tests: -// ./zcash-gtest --gtest_filter="founders_reward_test.*" +// ./bitcoinz-gtest --gtest_filter="founders_reward_test.*" // // Enable this test to generate and print 48 testnet 2-of-3 multisig addresses. @@ -83,21 +83,17 @@ TEST(founders_reward_test, create_testnet_2of3multisig) { } #endif -static int GetLastCommunityFeeHeight(const Consensus::Params& params) { - int blossomActivationHeight = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight; - bool blossom = blossomActivationHeight != Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; - return Params().GetLastCommunityFeeBlockHeight(); -} - -// Utility method to check the number of unique addresses from height 1 to maxHeight +// Utility method to check the number of unique addresses from 1 to maxHeight void checkNumberOfUniqueAddresses(int nUnique) { - int maxHeight = Params().GetLastCommunityFeeBlockHeight(); + CChainParams params = Params(); + + int maxHeight = params.GetLastCommunityFeeBlockHeight(); + std::set addresses; for (int i = 1; i <= maxHeight; i++) { - addresses.insert(Params().GetCommunityFeeAddressAtHeight(i)); + addresses.insert(params.GetCommunityFeeAddressAtHeight(i)); } - //EXPECT_EQ(addresses.size(), nUnique); - ASSERT_TRUE(addresses.size() == nUnique); + EXPECT_EQ(addresses.size(), nUnique); } @@ -107,16 +103,17 @@ TEST(founders_reward_test, general) { CChainParams params = Params(); // Fourth testnet reward: - // address = t2ENg7hHVqqs9JwU5cgjvSbxnT2a9USNfhy - // script.ToString() = OP_HASH160 55d64928e69829d9376c776550b6cc710d427153 OP_EQUAL - // HexStr(script) = a91455d64928e69829d9376c776550b6cc710d42715387 - EXPECT_EQ(HexStr(params.GetCommunityFeeScriptAtHeight(1)), "a914ef775f1f997f122a062fff1a2d7443abd1f9c64287"); - EXPECT_EQ(params.GetCommunityFeeAddressAtHeight(1), "t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi"); - EXPECT_EQ(HexStr(params.GetCommunityFeeScriptAtHeight(53126)), "a914ac67f4c072668138d88a86ff21b27207b283212f87"); - EXPECT_EQ(params.GetCommunityFeeAddressAtHeight(53126), "t2NGQjYMQhFndDHguvUw4wZdNdsssA6K7x2"); - EXPECT_EQ(HexStr(params.GetCommunityFeeScriptAtHeight(53127)), "a91455d64928e69829d9376c776550b6cc710d42715387"); - EXPECT_EQ(params.GetCommunityFeeAddressAtHeight(53127), "t2ENg7hHVqqs9JwU5cgjvSbxnT2a9USNfhy"); - + // address = t2EwBFfC96DCiCAcJuEqGUbUes8rTNmaD6Q + // script.ToString() = OP_HASH160 5bfbeb4df59710514b7004041e75ad287dad9bc8 OP_EQUAL + // HexStr(script) = a9145bfbeb4df59710514b7004041e75ad287dad9bc887 + EXPECT_EQ(HexStr(params.GetCommunityFeeScriptAtHeight(1)), "a91465a7c41acd34d55e7001a02d68c39f5470ae38cf87"); + EXPECT_EQ(params.GetCommunityFeeAddressAtHeight(1), "t2FpKCWt95LAPVRed61YbBny9yz5nqexLGN"); + EXPECT_EQ(HexStr(params.GetCommunityFeeScriptAtHeight(53126)), "a9145bfbeb4df59710514b7004041e75ad287dad9bc887"); + EXPECT_EQ(params.GetCommunityFeeAddressAtHeight(53126), "t2EwBFfC96DCiCAcJuEqGUbUes8rTNmaD6Q"); + EXPECT_EQ(HexStr(params.GetCommunityFeeScriptAtHeight(53127)), "a9145bfbeb4df59710514b7004041e75ad287dad9bc887"); + EXPECT_EQ(params.GetCommunityFeeAddressAtHeight(53127), "t2EwBFfC96DCiCAcJuEqGUbUes8rTNmaD6Q"); + + int minHeight = params.GetCommunityFeeStartHeight(); int maxHeight = params.GetLastCommunityFeeBlockHeight(); // If the block height parameter is out of bounds, there is an assert. @@ -131,19 +128,17 @@ TEST(founders_reward_test, regtest_get_last_block_blossom) { auto params = RegtestActivateBlossom(false, blossomActivationHeight); int lastFRHeight = Params().GetLastCommunityFeeBlockHeight(); EXPECT_EQ(0, params.Halving(lastFRHeight)); - EXPECT_EQ(1, params.Halving(lastFRHeight + 1)); RegtestDeactivateBlossom(); } TEST(founders_reward_test, mainnet_get_last_block) { SelectParams(CBaseChainParams::MAIN); auto params = Params().GetConsensus(); - int lastFRHeight = GetLastCommunityFeeHeight(params); - EXPECT_EQ(0, params.Halving(lastFRHeight)); - EXPECT_EQ(1, params.Halving(lastFRHeight + 1)); + int lastFRHeight = Params().GetLastCommunityFeeBlockHeight(); + EXPECT_EQ(1, params.Halving(lastFRHeight)); } -#define NUM_MAINNET_FOUNDER_ADDRESSES 48 +#define NUM_MAINNET_FOUNDER_ADDRESSES 100 TEST(founders_reward_test, mainnet) { SelectParams(CBaseChainParams::MAIN); @@ -151,7 +146,7 @@ TEST(founders_reward_test, mainnet) { } -#define NUM_TESTNET_FOUNDER_ADDRESSES 48 +#define NUM_TESTNET_FOUNDER_ADDRESSES 100 TEST(founders_reward_test, testnet) { SelectParams(CBaseChainParams::TESTNET); @@ -168,53 +163,81 @@ TEST(founders_reward_test, regtest) { -// Test that 10% community fee is fully rewarded after the first halving and slow start shift. -// On Mainnet, this would be 2,100,000 ZEC after 850,000 blocks (840,000 + 10,000). +// Test that 5% community fee is fully rewarded in a defined period. +// On Mainnet: nHeight > 328500 && nHeight <= 1400000 (494687187.5 BTCZ) TEST(founders_reward_test, slow_start_subsidy) { SelectParams(CBaseChainParams::MAIN); CChainParams params = Params(); + int minHeight = params.GetCommunityFeeStartHeight(); int maxHeight = params.GetLastCommunityFeeBlockHeight(); + CAmount totalSubsidy = 0; for (int nHeight = 1; nHeight <= maxHeight; nHeight++) { - CAmount nSubsidy = GetBlockSubsidy(nHeight, params.GetConsensus()) / 5; - totalSubsidy += nSubsidy; + CAmount nSubsidy = GetBlockSubsidy(nHeight, params.GetConsensus()) * 0.05; + if (nHeight > minHeight) { + totalSubsidy += nSubsidy; + } } - ASSERT_TRUE(totalSubsidy == MAX_MONEY/10.0); + EXPECT_EQ(totalSubsidy, 49468718750000000); } -// For use with mainnet and testnet which each have 48 addresses. +// For use with mainnet and testnet which each have 100 addresses. // Verify the number of rewards each individual address receives. -void verifyNumberOfRewards() { +// Since on the main network vCommunityFeeStartHeight does not start from 0, +// the first 22 elements of vCommunityFeeAddress are skipped. +void verifyNumberOfRewards(bool fMainNet) { CChainParams params = Params(); + + int minHeight = params.GetCommunityFeeStartHeight(); int maxHeight = params.GetLastCommunityFeeBlockHeight(); + std::map ms; for (int nHeight = 1; nHeight <= maxHeight; nHeight++) { std::string addr = params.GetCommunityFeeAddressAtHeight(nHeight); if (ms.count(addr) == 0) { ms[addr] = 0; } - ms[addr] = ms[addr] + GetBlockSubsidy(nHeight, params.GetConsensus()) / 5; + if (nHeight > minHeight) { + ms[addr] = ms[addr] + GetBlockSubsidy(nHeight, params.GetConsensus()) * 0.05; + } + } + + if (fMainNet) { + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(0)], 0 * 625 * COIN); + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(1)], 0 * 625 * COIN); + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(22)], 0 * 625 * COIN); + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(23)], 7523 * 625 * COIN); + } else { + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(0)], 12500 * 625 * COIN); + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(1)], 14001 * 625 * COIN); + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(22)], 14001 * 625 * COIN); + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(23)], 14001 * 625 * COIN); } - EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(0)], 1960039937500); - EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(1)], 4394460062500); - for (int i = 2; i <= 46; i++) { - EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(i)], 17709 * COIN * 2.5); + for (int i = 24; i <= 58; i++) { + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(i)], 14001 * 625 * COIN); } - EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(47)], 17677 * COIN * 2.5); + + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(59)], 8731875 * COIN); + + for (int i = 60; i <= 98; i++) { + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(i)], 14001 * 312.5 * COIN); + } + + EXPECT_EQ(ms[params.GetCommunityFeeAddressAtIndex(99)], 13902 * 312.5 * COIN); } // Verify the number of rewards going to each mainnet address TEST(founders_reward_test, per_address_reward_mainnet) { SelectParams(CBaseChainParams::MAIN); - verifyNumberOfRewards(); + verifyNumberOfRewards(true); } // Verify the number of rewards going to each testnet address TEST(founders_reward_test, per_address_reward_testnet) { SelectParams(CBaseChainParams::TESTNET); - verifyNumberOfRewards(); + verifyNumberOfRewards(false); } From 50a5b1bf9c37860d6f4ad4bf9263a9511a5aef26 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Sun, 14 Jul 2024 13:27:56 +0000 Subject: [PATCH 014/162] Remove config option -disabledeprecation --- src/deprecation.cpp | 5 ----- src/gtest/test_deprecation.cpp | 16 ---------------- 2 files changed, 21 deletions(-) diff --git a/src/deprecation.cpp b/src/deprecation.cpp index 168969ff3..8f8cfc9b0 100644 --- a/src/deprecation.cpp +++ b/src/deprecation.cpp @@ -20,7 +20,6 @@ void EnforceNodeDeprecation(int nHeight, bool forceLogging, bool fThread) { if (networkID != "main") return; int blocksToDeprecation = DEPRECATION_HEIGHT - nHeight; - bool disableDeprecation = (GetArg("-disabledeprecation", "") == CLIENT_VERSION_STR); if (blocksToDeprecation <= 0) { // In order to ensure we only log once per process when deprecation is // disabled (to avoid log spam), we only need to log in two cases: @@ -32,10 +31,6 @@ void EnforceNodeDeprecation(int nHeight, bool forceLogging, bool fThread) { auto msg = strprintf(_("This version has been deprecated as of block height %d."), DEPRECATION_HEIGHT) + " " + _("You should upgrade to the latest version of BitcoinZ."); - if (!disableDeprecation) { - msg += " " + strprintf(_("To disable deprecation for this version, set %s%s."), - "-disabledeprecation=", CLIENT_VERSION_STR); - } LogPrintf("*** %s\n", msg); CAlert::Notify(msg, fThread); uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); diff --git a/src/gtest/test_deprecation.cpp b/src/gtest/test_deprecation.cpp index 0db535f15..5d5edf280 100644 --- a/src/gtest/test_deprecation.cpp +++ b/src/gtest/test_deprecation.cpp @@ -122,22 +122,6 @@ TEST_F(DeprecationTest, DeprecatedNodeIgnoredOnTestnet) { EXPECT_FALSE(ShutdownRequested()); } -TEST_F(DeprecationTest, DeprecatedNodeShutsDownIfOldVersionDisabled) { - EXPECT_FALSE(ShutdownRequested()); - mapArgs["-disabledeprecation"] = "1.0.0"; - EXPECT_CALL(mock_, ThreadSafeMessageBox(::testing::_, "", CClientUIInterface::MSG_ERROR)); - EnforceNodeDeprecation(DEPRECATION_HEIGHT); - EXPECT_TRUE(ShutdownRequested()); -} - -TEST_F(DeprecationTest, DeprecatedNodeKeepsRunningIfCurrentVersionDisabled) { - EXPECT_FALSE(ShutdownRequested()); - mapArgs["-disabledeprecation"] = CLIENT_VERSION_STR; - EXPECT_CALL(mock_, ThreadSafeMessageBox(::testing::_, "", CClientUIInterface::MSG_ERROR)); - EnforceNodeDeprecation(DEPRECATION_HEIGHT); - EXPECT_FALSE(ShutdownRequested()); -} - TEST_F(DeprecationTest, AlertNotify) { boost::filesystem::path temp = GetTempPath() / boost::filesystem::unique_path("alertnotify-%%%%.txt"); From 5425a4e3856195681491f70f0821a70f4f272838 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Sun, 14 Jul 2024 13:59:27 +0000 Subject: [PATCH 015/162] Fix 'checktransaction_tests' errors --- src/gtest/test_checktransaction.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gtest/test_checktransaction.cpp b/src/gtest/test_checktransaction.cpp index 69e8748a6..57f355b2c 100644 --- a/src/gtest/test_checktransaction.cpp +++ b/src/gtest/test_checktransaction.cpp @@ -505,7 +505,7 @@ TEST(checktransaction_tests, bad_txns_invalid_joinsplit_signature) { MockCValidationState state; // during initial block download, DoS ban score should be zero, else 100 EXPECT_CALL(state, DoS(0, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1); - ContextualCheckTransaction(tx, state, chainparams, 0, 100, [](const CChainParams&) { return false; });; + ContextualCheckTransaction(tx, state, chainparams, 0, 100, [](const CChainParams&) { return true; }); EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1); ContextualCheckTransaction(tx, state, chainparams, 0, 100, [](const CChainParams&) { return false; }); } @@ -542,7 +542,7 @@ TEST(checktransaction_tests, non_canonical_ed25519_signature) { MockCValidationState state; // during initial block download, DoS ban score should be zero, else 100 EXPECT_CALL(state, DoS(0, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1); - ContextualCheckTransaction(tx, state, chainparams, 0, 100, [](const CChainParams&) { return false; });; + ContextualCheckTransaction(tx, state, chainparams, 0, 100, [](const CChainParams&) { return true; }); EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1); ContextualCheckTransaction(tx, state, chainparams, 0, 100, [](const CChainParams&) { return false; }); } From 72e1f9be11223cdae7c21e8003571c036ca621ac Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Mon, 15 Jul 2024 09:40:33 +0000 Subject: [PATCH 016/162] build: set minimum supported macOS to 10.14 --- contrib/gitian-descriptors/gitian-osx.yml | 10 +++--- depends/Makefile | 2 +- depends/README.md | 2 +- depends/hosts/darwin.mk | 40 +++++++++++++++++++---- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml index 794a82af8..65533d060 100644 --- a/contrib/gitian-descriptors/gitian-osx.yml +++ b/contrib/gitian-descriptors/gitian-osx.yml @@ -24,10 +24,10 @@ remotes: - "url": "https://github.com/bitcoin/bitcoin.git" "dir": "bitcoin" files: -- "MacOSX10.9.sdk.tar.gz" +- "Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz" script: | WRAP_DIR=$HOME/wrapped - HOSTS="x86_64-apple-darwin11" + HOSTS="x86_64-apple-darwin18" CONFIGFLAGS="--enable-reduce-exports --disable-bench GENISOIMAGE=$WRAP_DIR/genisoimage" FAKETIME_HOST_PROGS="" FAKETIME_PROGS="ar ranlib date dmg genisoimage" @@ -48,7 +48,7 @@ script: | function create_global_faketime_wrappers { for prog in ${FAKETIME_PROGS}; do - echo '#!/bin/bash' > ${WRAP_DIR}/${prog} + echo '#!/usr/bin/env bash' > ${WRAP_DIR}/${prog} echo "REAL=\`which -a ${prog} | grep -v ${WRAP_DIR}/${prog} | head -1\`" >> ${WRAP_DIR}/${prog} echo 'export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${prog} echo "export FAKETIME=\"$1\"" >> ${WRAP_DIR}/${prog} @@ -60,7 +60,7 @@ script: | function create_per-host_faketime_wrappers { for i in $HOSTS; do for prog in ${FAKETIME_HOST_PROGS}; do - echo '#!/bin/bash' > ${WRAP_DIR}/${i}-${prog} + echo '#!/usr/bin/env bash' > ${WRAP_DIR}/${i}-${prog} echo "REAL=\`which -a ${i}-${prog} | grep -v ${WRAP_DIR}/${i}-${prog} | head -1\`" >> ${WRAP_DIR}/${i}-${prog} echo 'export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${i}-${prog} echo "export FAKETIME=\"$1\"" >> ${WRAP_DIR}/${i}-${prog} @@ -80,7 +80,7 @@ script: | BASEPREFIX=`pwd`/depends mkdir -p ${BASEPREFIX}/SDKs - tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/MacOSX10.9.sdk.tar.gz + tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz # Build dependencies for each host for i in $HOSTS; do diff --git a/depends/Makefile b/depends/Makefile index ec5b77b92..6d50950d3 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -148,7 +148,7 @@ install: check-packages $(host_prefix)/share/config.site download-one: check-sources $(all_sources) download-osx: - @$(MAKE) -s HOST=x86_64-apple-darwin11 download-one + @$(MAKE) -s HOST=x86_64-apple-darwin18 download-one download-linux: @$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one download-win: diff --git a/depends/README.md b/depends/README.md index 41898de1a..a143ff5f5 100644 --- a/depends/README.md +++ b/depends/README.md @@ -22,7 +22,7 @@ Common `host-platform-triplets` for cross compilation are: - `i686-w64-mingw32` for Win32 - `x86_64-w64-mingw32` for Win64 -- `x86_64-apple-darwin11` for MacOSX +- `x86_64-apple-darwin18` for MacOSX - `arm-linux-gnueabihf` for Linux ARM No other options are needed, the paths are automatically configured. diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk index 939988197..259ff2864 100644 --- a/depends/hosts/darwin.mk +++ b/depends/hosts/darwin.mk @@ -1,17 +1,43 @@ -OSX_MIN_VERSION=10.8 -OSX_SDK_VERSION=10.11 -OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk -LD64_VERSION=253.9 -darwin_CC=clang -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -darwin_CXX=clang++ -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -stdlib=libc++ +OSX_MIN_VERSION=10.14 +XCODE_VERSION=11.3.1 +XCODE_BUILD_ID=11C505 +LD64_VERSION=530 + +OSX_SDK=$(SDK_PATH)/Xcode-$(XCODE_VERSION)-$(XCODE_BUILD_ID)-extracted-SDK-with-libcxx-headers + +# Flag explanations: +# +# -mlinker-version +# +# Ensures that modern linker features are enabled. See here for more +# details: https://github.com/bitcoin/bitcoin/pull/19407. +# +# -B$(build_prefix)/bin +# +# Explicitly point to our binaries (e.g. cctools) so that they are +# ensured to be found and preferred over other possibilities. +# +# -nostdinc++ -isystem $(OSX_SDK)/usr/include/c++/v1 +# +# Forces clang to use the libc++ headers from our SDK and completely +# forget about the libc++ headers from the standard directories +# +# TODO: Once we start requiring a clang version that has the +# -stdlib++-isystem flag first introduced here: +# https://reviews.llvm.org/D64089, we should use that instead. Read the +# differential summary there for more details. +# +darwin_CC=clang -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -B$(build_prefix)/bin +darwin_CXX=clang++ -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -stdlib=libc++ -mlinker-version=$(LD64_VERSION) -B$(build_prefix)/bin -nostdinc++ -isystem $(OSX_SDK)/usr/include/c++/v1 darwin_CFLAGS=-pipe darwin_CXXFLAGS=$(darwin_CFLAGS) -darwin_release_CFLAGS=-O1 +darwin_release_CFLAGS=-O2 darwin_release_CXXFLAGS=$(darwin_release_CFLAGS) darwin_debug_CFLAGS=-O1 darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS) +darwin_native_binutils=native_cctools darwin_native_toolchain=native_cctools From dc7728503f933e3851cc4bae5812d38ab5491db8 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Mon, 15 Jul 2024 09:42:00 +0000 Subject: [PATCH 017/162] Require and build with C++17 --- build-aux/m4/ax_cxx_compile_stdcxx.m4 | 455 ++++++++++++++++++++++++-- configure.ac | 4 +- depends/packages/bdb.mk | 2 +- depends/packages/boost.mk | 2 +- depends/packages/googletest.mk | 2 +- depends/packages/zeromq.mk | 2 +- src/leveldb/build_detect_platform | 15 +- src/random.h | 1 + 8 files changed, 429 insertions(+), 54 deletions(-) diff --git a/build-aux/m4/ax_cxx_compile_stdcxx.m4 b/build-aux/m4/ax_cxx_compile_stdcxx.m4 index f147cee3b..43087b2e6 100644 --- a/build-aux/m4/ax_cxx_compile_stdcxx.m4 +++ b/build-aux/m4/ax_cxx_compile_stdcxx.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html +# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html # =========================================================================== # # SYNOPSIS @@ -33,21 +33,23 @@ # 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 # # 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 4 +#serial 11 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], [], - [$1], [14], [], - [$1], [17], [m4_fatal([support for C++17 not yet implemented in AX_CXX_COMPILE_STDCXX])], + 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"], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], @@ -57,26 +59,13 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl [$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])]) - m4_if([$4], [], [ax_cxx_compile_cxx$1_try_default=true], - [$4], [default], [ax_cxx_compile_cxx$1_try_default=true], - [$4], [nodefault], [ax_cxx_compile_cxx$1_try_default=false], - [m4_fatal([invalid fourth argument `$4' to AX_CXX_COMPILE_STDCXX])]) AC_LANG_PUSH([C++])dnl ac_success=no - m4_if([$4], [nodefault], [], [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 switch in -std=gnu++$1 -std=gnu++0x; do + 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, @@ -102,22 +91,27 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl 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 switch in -std=c++$1 -std=c++0x +std=c++$1 "-h std=c++$1"; 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" + 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 - ac_success=yes + done + if test x$ac_success = xyes; then break fi done @@ -154,6 +148,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ) +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 Tests for new features in C++11 @@ -191,11 +190,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -524,7 +525,7 @@ namespace cxx14 } - namespace test_digit_seperators + namespace test_digit_separators { constexpr auto ten_million = 100'000'000; @@ -566,3 +567,385 @@ 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 + +]]) diff --git a/configure.ac b/configure.ac index df7035a5c..50842f7aa 100644 --- a/configure.ac +++ b/configure.ac @@ -61,8 +61,8 @@ case $host in lt_cv_deplibs_check_method="pass_all" ;; esac -dnl Require C++11 compiler (no GNU extensions) -AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory], [nodefault]) +dnl Require C++17 compiler (no GNU extensions) +AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory]) dnl Check if -latomic is required for CHECK_ATOMIC diff --git a/depends/packages/bdb.mk b/depends/packages/bdb.mk index bb9074823..24b572026 100644 --- a/depends/packages/bdb.mk +++ b/depends/packages/bdb.mk @@ -11,7 +11,7 @@ $(package)_config_opts_mingw32=--enable-mingw $(package)_config_opts_linux=--with-pic $(package)_config_opts_freebsd=--with-pic $(package)_config_opts_aarch64=--disable-atomicsupport -$(package)_cxxflags=-std=c++11 +$(package)_cxxflags=-std=c++17 endef define $(package)_preprocess_cmds diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 1258e6edd..b341699b4 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -21,7 +21,7 @@ $(package)_archiver_$(host_os)=$($(package)_ar) $(package)_toolset_darwin=darwin $(package)_archiver_darwin=$($(package)_libtool) $(package)_config_libraries=chrono,filesystem,program_options,system,thread,test -$(package)_cxxflags=-std=c++11 -fvisibility=hidden +$(package)_cxxflags=-std=c++17 -fvisibility=hidden $(package)_cxxflags_linux=-fPIC $(package)_cxxflags_freebsd=-fPIC endef diff --git a/depends/packages/googletest.mk b/depends/packages/googletest.mk index 3e4a72fca..f0fff1ce1 100644 --- a/depends/packages/googletest.mk +++ b/depends/packages/googletest.mk @@ -6,7 +6,7 @@ $(package)_download_file=release-$($(package)_version).tar.gz $(package)_sha256_hash=58a6f4277ca2bc8565222b3bbd58a177609e9c488e8a72649359ba51450db7d8 define $(package)_set_vars -$(package)_cxxflags+=-std=c++11 +$(package)_cxxflags+=-std=c++17 $(package)_cxxflags_linux=-fPIC $(package)_cxxflags_freebsd=-fPIC endef diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index fee9e6e26..af4243162 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -8,7 +8,7 @@ define $(package)_set_vars $(package)_config_opts=--without-documentation --disable-shared --disable-curve $(package)_config_opts_linux=--with-pic $(package)_config_opts_freebsd=--with-pic - $(package)_cxxflags=-std=c++11 + $(package)_cxxflags=-std=c++17 endef define $(package)_config_cmds diff --git a/src/leveldb/build_detect_platform b/src/leveldb/build_detect_platform index a1101c1bd..be6c13848 100755 --- a/src/leveldb/build_detect_platform +++ b/src/leveldb/build_detect_platform @@ -56,7 +56,7 @@ fi COMMON_FLAGS= CROSS_COMPILE= PLATFORM_CCFLAGS= -PLATFORM_CXXFLAGS= +PLATFORM_CXXFLAGS="-std=c++17" PLATFORM_LDFLAGS= PLATFORM_LIBS= PLATFORM_SHARED_EXT="so" @@ -191,18 +191,9 @@ if [ "$CROSS_COMPILE" = "true" ]; then else CXXOUTPUT="${TMPDIR}/leveldb_build_detect_platform-cxx.$$" - # If -std=c++0x works, use as fallback for when memory barriers + # As -std=c++17 works, use as fallback for when memory barriers # are not available. - $CXX $CXXFLAGS -std=c++0x -x c++ - -o $CXXOUTPUT 2>/dev/null < - int main() {} -EOF - if [ "$?" = 0 ]; then - COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT" - PLATFORM_CXXFLAGS="-std=c++0x" - else - COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX" - fi + COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT" # Test whether tcmalloc is available $CXX $CXXFLAGS -x c++ - -o $CXXOUTPUT -ltcmalloc 2>/dev/null < +#include #include /** From 4f7a1d8ee4409102884a662383014cb6f3751211 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Mon, 15 Jul 2024 11:46:27 +0000 Subject: [PATCH 018/162] Remove '#include ' --- src/alert.cpp | 1 - src/bloom.cpp | 2 -- src/checkpoints.cpp | 2 -- src/checkqueue.h | 1 - src/coins.h | 1 - src/core_write.cpp | 1 - src/gtest/test_joinsplit.cpp | 1 - src/gtest/test_merkletree.cpp | 2 -- src/httpserver.cpp | 1 - src/keystore.cpp | 2 -- src/memusage.h | 1 - src/net.h | 1 - src/rpc/net.cpp | 2 -- src/rpc/server.cpp | 1 - src/script/sign.cpp | 2 -- src/script/standard.cpp | 2 -- src/sync.cpp | 1 - src/test/DoS_tests.cpp | 1 - src/test/accounting_tests.cpp | 1 - src/test/alert_tests.cpp | 1 - src/test/base58_tests.cpp | 1 - src/test/getarg_tests.cpp | 1 - src/test/multisig_tests.cpp | 1 - src/test/script_tests.cpp | 1 - src/test/sigopcount_tests.cpp | 1 - src/timedata.cpp | 2 -- src/torcontrol.cpp | 1 - src/util.cpp | 1 - src/wallet/crypter.cpp | 1 - src/wallet/test/wallet_tests.cpp | 1 - src/wallet/wallet_ismine.cpp | 2 -- src/wallet/walletdb.cpp | 1 - src/zcash/IncrementalMerkleTree.cpp | 2 -- src/zcash/JoinSplit.cpp | 1 - 34 files changed, 44 deletions(-) diff --git a/src/alert.cpp b/src/alert.cpp index bec18e559..2b7c2c1a4 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -18,7 +18,6 @@ #include #include -#include #include using namespace std; diff --git a/src/bloom.cpp b/src/bloom.cpp index ab4210601..1de10526f 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -14,8 +14,6 @@ #include #include -#include - #define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455 #define LN2 0.6931471805599453094172321214581765680755001343602552 diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 3cb619db6..91d6ba052 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -10,8 +10,6 @@ #include -#include - namespace Checkpoints { /** diff --git a/src/checkqueue.h b/src/checkqueue.h index 861d263bb..e700c1774 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/src/coins.h b/src/coins.h index b908d3b00..08efd020d 100644 --- a/src/coins.h +++ b/src/coins.h @@ -15,7 +15,6 @@ #include #include -#include #include #include "zcash/IncrementalMerkleTree.hpp" diff --git a/src/core_write.cpp b/src/core_write.cpp index f93fbac8c..a94e64658 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -16,7 +16,6 @@ #include "utilstrencodings.h" #include -#include using namespace std; diff --git a/src/gtest/test_joinsplit.cpp b/src/gtest/test_joinsplit.cpp index 546ae6aa6..43330baa5 100644 --- a/src/gtest/test_joinsplit.cpp +++ b/src/gtest/test_joinsplit.cpp @@ -2,7 +2,6 @@ #include "utilstrencodings.h" -#include #include #include "zcash/prf.h" diff --git a/src/gtest/test_merkletree.cpp b/src/gtest/test_merkletree.cpp index a7b7c5287..e4ad20dfc 100644 --- a/src/gtest/test_merkletree.cpp +++ b/src/gtest/test_merkletree.cpp @@ -26,8 +26,6 @@ #include "zcash/IncrementalMerkleTree.hpp" #include "zcash/util.h" -#include - #include "json_test_vectors.h" using namespace std; diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 81103fb01..bf13c0aab 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -36,7 +36,6 @@ #endif #include // for to_lower() -#include #include /** HTTP request work item */ diff --git a/src/keystore.cpp b/src/keystore.cpp index 8829f7c8a..1b73c86d0 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -9,8 +9,6 @@ #include "pubkey.h" #include "util.h" -#include - bool CKeyStore::AddKey(const CKey &key) { return AddKeyPubKey(key, key.GetPubKey()); } diff --git a/src/memusage.h b/src/memusage.h index e3e60d0a0..f4b81dfee 100644 --- a/src/memusage.h +++ b/src/memusage.h @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/src/net.h b/src/net.h index cb86fdc85..c67ae15c7 100644 --- a/src/net.h +++ b/src/net.h @@ -27,7 +27,6 @@ #endif #include -#include #include class CAddrMan; diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 079b8ed4b..c5677f5c7 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -15,8 +15,6 @@ #include "version.h" #include "deprecation.h" -#include - #include using namespace std; diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 91b181bbe..86051a0b6 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/src/script/sign.cpp b/src/script/sign.cpp index c2b871db0..587beb6d4 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -11,8 +11,6 @@ #include "script/standard.h" #include "uint256.h" -#include - using namespace std; typedef std::vector valtype; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index fe9c49e6f..09e6a8fa0 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -10,8 +10,6 @@ #include "util.h" #include "utilstrencodings.h" -#include - using namespace std; typedef vector valtype; diff --git a/src/sync.cpp b/src/sync.cpp index dd231ef61..e261f2286 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -9,7 +9,6 @@ #include -#include #include #ifdef DEBUG_LOCKCONTENTION diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp index 742b87a61..c3a05866e 100644 --- a/src/test/DoS_tests.cpp +++ b/src/test/DoS_tests.cpp @@ -23,7 +23,6 @@ #include // for 'map_list_of()' #include -#include #include #include diff --git a/src/test/accounting_tests.cpp b/src/test/accounting_tests.cpp index 8538479cc..16ae93425 100644 --- a/src/test/accounting_tests.cpp +++ b/src/test/accounting_tests.cpp @@ -9,7 +9,6 @@ #include -#include #include extern CWallet* pwalletMain; diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index 0c84c5d7e..3c7f7db20 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include "key.h" diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp index f7a6c9e39..49031fa82 100644 --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -18,7 +18,6 @@ #include -#include #include diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp index 99ec100f9..0cc68547a 100644 --- a/src/test/getarg_tests.cpp +++ b/src/test/getarg_tests.cpp @@ -9,7 +9,6 @@ #include #include -#include #include BOOST_FIXTURE_TEST_SUITE(getarg_tests, BasicTestingSetup) diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp index 116c1ce4f..781160de8 100644 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -17,7 +17,6 @@ #include "wallet/wallet_ismine.h" #endif -#include #include #include diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 147c135c1..6baa2ce75 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include diff --git a/src/test/sigopcount_tests.cpp b/src/test/sigopcount_tests.cpp index 3fd68f28d..b4c6aee80 100644 --- a/src/test/sigopcount_tests.cpp +++ b/src/test/sigopcount_tests.cpp @@ -11,7 +11,6 @@ #include -#include #include using namespace std; diff --git a/src/timedata.cpp b/src/timedata.cpp index f281e5222..aa1ce4158 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -11,8 +11,6 @@ #include "utilstrencodings.h" #include "warnings.h" -#include - using namespace std; static CCriticalSection cs_nTimeOffset; diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index a5c98a87d..fa497faca 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/src/util.cpp b/src/util.cpp index 012c753c9..254bf1ad0 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -78,7 +78,6 @@ #include // for startswith() and endswith() #include #include -#include #include #include #include diff --git a/src/wallet/crypter.cpp b/src/wallet/crypter.cpp index 59a5f4a92..69680f2f6 100644 --- a/src/wallet/crypter.cpp +++ b/src/wallet/crypter.cpp @@ -13,7 +13,6 @@ #include #include -#include int CCrypter::BytesToKeySHA512AES(const std::vector& chSalt, const SecureString& strKeyData, int count, unsigned char *key,unsigned char *iv) const { diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index bed4d53d6..495bbfc3c 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -11,7 +11,6 @@ #include "test/test_bitcoin.h" -#include #include // how many times to run all the tests to have a chance to catch errors that only show up with particular random shuffles diff --git a/src/wallet/wallet_ismine.cpp b/src/wallet/wallet_ismine.cpp index bbb93032e..b2f5d13c7 100644 --- a/src/wallet/wallet_ismine.cpp +++ b/src/wallet/wallet_ismine.cpp @@ -11,8 +11,6 @@ #include "script/standard.h" #include "script/sign.h" -#include - using namespace std; typedef vector valtype; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 491d925c4..0a90ea6a6 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -17,7 +17,6 @@ #include "zcash/Proof.hpp" #include -#include #include #include diff --git a/src/zcash/IncrementalMerkleTree.cpp b/src/zcash/IncrementalMerkleTree.cpp index e23cc93c6..288afe657 100644 --- a/src/zcash/IncrementalMerkleTree.cpp +++ b/src/zcash/IncrementalMerkleTree.cpp @@ -1,7 +1,5 @@ #include -#include - #include "zcash/IncrementalMerkleTree.hpp" #include "crypto/sha256.h" #include "zcash/util.h" diff --git a/src/zcash/JoinSplit.cpp b/src/zcash/JoinSplit.cpp index 92217bdd5..e48a7ec72 100644 --- a/src/zcash/JoinSplit.cpp +++ b/src/zcash/JoinSplit.cpp @@ -6,7 +6,6 @@ #include -#include #include #include #include From 4b7285f06d63c771f8d8f83dd3adbbe87fd926b1 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Mon, 15 Jul 2024 11:49:37 +0000 Subject: [PATCH 019/162] Introduce 'src/reverse_iterator.h' --- src/Makefile.am | 1 + src/reverse_iterator.h | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/reverse_iterator.h diff --git a/src/Makefile.am b/src/Makefile.am index f683f6c69..9e56ed9d8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -167,6 +167,7 @@ BITCOIN_CORE_H = \ protocol.h \ pubkey.h \ random.h \ + reverse_iterator.h \ reverselock.h \ rpc/client.h \ rpc/protocol.h \ diff --git a/src/reverse_iterator.h b/src/reverse_iterator.h new file mode 100644 index 000000000..21b56c660 --- /dev/null +++ b/src/reverse_iterator.h @@ -0,0 +1,39 @@ +// Taken from https://gist.github.com/arvidsson/7231973 + +#ifndef BITCOIN_REVERSE_ITERATOR_H +#define BITCOIN_REVERSE_ITERATOR_H + +/** + * Template used for reverse iteration in range-based for loops. + * + * std::vector v = {1, 2, 3, 4, 5}; + * for (auto x : reverse_iterate(v)) + * std::cout << x << " "; + */ + +template +class reverse_range +{ + T &x; + +public: + explicit reverse_range(T &x) : x(x) {} + + auto begin() const -> decltype(this->x.rbegin()) + { + return x.rbegin(); + } + + auto end() const -> decltype(this->x.rend()) + { + return x.rend(); + } +}; + +template +reverse_range reverse_iterate(T &x) +{ + return reverse_range(x); +} + +#endif // BITCOIN_REVERSE_ITERATOR_H From c65e9da18f6a0ae73d52c2c4f1b9246097199dbd Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Mon, 15 Jul 2024 11:55:35 +0000 Subject: [PATCH 020/162] Remove BOOST_REVERSE_FOREACH --- src/chainparams.cpp | 3 ++- src/checkpoints.cpp | 3 ++- src/main.cpp | 3 ++- src/prevector.h | 2 +- src/test/prevector_tests.cpp | 5 +++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 8fe6fa3f5..a20eb30a7 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -7,6 +7,7 @@ #include "key_io.h" #include "main.h" #include "crypto/equihash.h" +#include "reverse_iterator.h" #include "util.h" #include "utilstrencodings.h" @@ -834,7 +835,7 @@ bool checkEHParamaters(int solSize, int height, const CChainParams& params) { } int CChainParams::GetFutureBlockTimeWindow(int height) const { - BOOST_REVERSE_FOREACH(const MapFutureBlockTimeWindows::value_type& i, futureBlockTimeWindows) + for (const MapFutureBlockTimeWindows::value_type& i : reverse_iterate(futureBlockTimeWindows)) { if (i.first <= height) { return i.second * 60; diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 91d6ba052..a616b958f 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -6,6 +6,7 @@ #include "chainparams.h" #include "main.h" +#include "reverse_iterator.h" #include "uint256.h" #include @@ -66,7 +67,7 @@ namespace Checkpoints { { const MapCheckpoints& checkpoints = data.mapCheckpoints; - BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints) + for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints)) { const uint256& hash = i.second; BlockMap::const_iterator t = mapBlockIndex.find(hash); diff --git a/src/main.cpp b/src/main.cpp index 62a9563d6..fa020e142 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ #include "metrics.h" #include "net.h" #include "pow.h" +#include "reverse_iterator.h" #include "txmempool.h" #include "ui_interface.h" #include "undo.h" @@ -3427,7 +3428,7 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c nHeight = nTargetHeight; // Connect new blocks. - BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) { + for (CBlockIndex *pindexConnect : reverse_iterate(vpindexToConnect)) { if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : NULL)) { if (state.IsInvalid()) { // The block violates a consensus rule. diff --git a/src/prevector.h b/src/prevector.h index aad4c2717..7f34bcee9 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -129,7 +129,7 @@ class prevector { typedef const T* pointer; typedef const T& reference; typedef std::bidirectional_iterator_tag iterator_category; - const_reverse_iterator(T* ptr_) : ptr(ptr_) {} + const_reverse_iterator(const T* ptr_) : ptr(ptr_) {} const_reverse_iterator(reverse_iterator x) : ptr(&(*x)) {} const T& operator*() const { return *ptr; } const T* operator->() const { return ptr; } diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index d4af6a002..c255b0992 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -6,6 +6,7 @@ #include "prevector.h" #include "test_random.h" +#include "reverse_iterator.h" #include "serialize.h" #include "streams.h" @@ -43,13 +44,13 @@ class prevector_tester { for (const T& v : pre_vector) { BOOST_CHECK(v == real_vector[pos++]); } - BOOST_REVERSE_FOREACH(const T& v, pre_vector) { + for (const T& v : reverse_iterate(pre_vector)) { BOOST_CHECK(v == real_vector[--pos]); } for (const T& v : const_pre_vector) { BOOST_CHECK(v == real_vector[pos++]); } - BOOST_REVERSE_FOREACH(const T& v, const_pre_vector) { + for (const T& v : reverse_iterate(const_pre_vector)) { BOOST_CHECK(v == real_vector[--pos]); } CDataStream ss1(SER_DISK, 0); From 2d2f518c8e7cc127368b82ced9649bbf8a7c8f86 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Mon, 15 Jul 2024 12:04:31 +0000 Subject: [PATCH 021/162] Add destination wrapper functions --- src/chainparams.cpp | 2 +- src/rpc/misc.cpp | 4 ++-- src/script/standard.cpp | 8 ++++++++ src/script/standard.h | 6 ++++++ src/test/rpc_wallet_tests.cpp | 6 +++--- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index a20eb30a7..a680fd0e3 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -777,7 +777,7 @@ CScript CChainParams::GetCommunityFeeScriptAtHeight(int nHeight) const { CTxDestination address = DecodeDestination(GetCommunityFeeAddressAtHeight(nHeight).c_str()); assert(IsValidDestination(address)); - assert(boost::get(&address) != nullptr); + assert(IsScriptDestination(address)); CScriptID scriptID = boost::get(address); // address is a boost variant CScript script = CScript() << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL; return script; diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index b074ac13f..1ddce5948 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -501,13 +501,13 @@ static bool getIndexKey( if (!IsValidDestination(dest)) { return false; } - if (dest.type() == typeid(CKeyID)) { + if (IsKeyDestination(dest)) { auto x = boost::get(&dest); memcpy(&hashBytes, x->begin(), 20); type = CScript::P2PKH; return true; } - if (dest.type() == typeid(CScriptID)) { + if (IsScriptDestination(dest)) { auto x = boost::get(&dest); memcpy(&hashBytes, x->begin(), 20); type = CScript::P2SH; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 09e6a8fa0..e2ef3d62e 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -324,6 +324,14 @@ bool IsValidDestination(const CTxDestination& dest) { return dest.which() != 0; } +bool IsKeyDestination(const CTxDestination& dest) { + return dest.which() == 1; +} + +bool IsScriptDestination(const CTxDestination& dest) { + return dest.which() == 2; +} + // insightexplorer CTxDestination DestFromAddressHash(int scriptType, uint160& addressHash) { diff --git a/src/script/standard.h b/src/script/standard.h index b339e64cc..67b8e10db 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -85,6 +85,12 @@ typedef boost::variant CTxDestination; /** Check whether a CTxDestination is a CNoDestination. */ bool IsValidDestination(const CTxDestination& dest); +/** Check whether a CTxDestination is a CKeyID. */ +bool IsKeyDestination(const CTxDestination& dest); + +/** Check whether a CTxDestination is a CScriptID. */ +bool IsScriptDestination(const CTxDestination& dest); + const char* GetTxnOutputType(txnouttype t); bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector >& vSolutionsRet); diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp index fcaadf4b8..a113f61a3 100644 --- a/src/test/rpc_wallet_tests.cpp +++ b/src/test/rpc_wallet_tests.cpp @@ -72,15 +72,15 @@ BOOST_AUTO_TEST_CASE(rpc_addmultisig) CTxDestination address; BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(1, address1Hex), false)); address = DecodeDestination(v.get_str()); - BOOST_CHECK(IsValidDestination(address) && boost::get(&address) != nullptr); + BOOST_CHECK(IsValidDestination(address) && IsScriptDestination(address)); BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(1, address1Hex, address2Hex), false)); address = DecodeDestination(v.get_str()); - BOOST_CHECK(IsValidDestination(address) && boost::get(&address) != nullptr); + BOOST_CHECK(IsValidDestination(address) && IsScriptDestination(address)); BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(2, address1Hex, address2Hex), false)); address = DecodeDestination(v.get_str()); - BOOST_CHECK(IsValidDestination(address) && boost::get(&address) != nullptr); + BOOST_CHECK(IsValidDestination(address) && IsScriptDestination(address)); BOOST_CHECK_THROW(addmultisig(createArgs(0), false), runtime_error); BOOST_CHECK_THROW(addmultisig(createArgs(1), false), runtime_error); From 5dbc0500d5644d7a91289e753902f5987c0ed148 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Mon, 15 Jul 2024 12:12:05 +0000 Subject: [PATCH 022/162] Drop boost::this_thread::interruption_point and boost::thread_interrupted in main thread --- src/bitcoin-cli.cpp | 3 --- src/bitcoin-tx.cpp | 4 ---- src/main.cpp | 2 -- 3 files changed, 9 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 4336da3e9..446364b5f 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -328,9 +328,6 @@ int CommandLineRPC(int argc, char *argv[]) } } while (fWait); } - catch (const boost::thread_interrupted&) { - throw; - } catch (const std::exception& e) { strPrint = std::string("error: ") + e.what(); nRet = EXIT_FAILURE; diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 9885f3102..264dd6ffa 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -654,10 +654,6 @@ static int CommandLineRawTx(int argc, char* argv[]) OutputTx(tx); } - - catch (const boost::thread_interrupted&) { - throw; - } catch (const std::exception& e) { strPrint = std::string("error: ") + e.what(); nRet = EXIT_FAILURE; diff --git a/src/main.cpp b/src/main.cpp index fa020e142..0d7a99830 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4418,8 +4418,6 @@ bool static LoadBlockIndexDB() if (!pblocktree->LoadBlockIndexGuts(InsertBlockIndex)) return false; - boost::this_thread::interruption_point(); - // Calculate nChainWork vector > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); From c41bab1a6ff4652a785b4bb778ab2a7bb7c9849a Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Mon, 15 Jul 2024 12:24:02 +0000 Subject: [PATCH 023/162] Replace boost::signals2 with std::function --- src/bitcoin-cli.cpp | 2 ++ src/bitcoin-tx.cpp | 2 ++ src/bitcoind.cpp | 2 ++ src/consensus/params.h | 1 + src/dbwrapper.cpp | 2 ++ src/gtest/main.cpp | 2 ++ src/miner.h | 1 + src/noui.cpp | 2 ++ src/test/test_bitcoin.cpp | 2 ++ src/util.cpp | 1 - src/util.h | 20 ++++++-------------- src/zcash/Proof.hpp | 2 ++ 12 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 446364b5f..032e25f8d 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -19,6 +19,8 @@ #include +const std::function G_TRANSLATION_FUN = nullptr; + static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900; static const int CONTINUE_EXECUTION=-1; diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 264dd6ffa..754496c0e 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -26,6 +26,8 @@ static bool fCreateBlank; static std::map registers; static const int CONTINUE_EXECUTION=-1; +const std::function G_TRANSLATION_FUN = nullptr; + // // This function returns either one of EXIT_ codes when it's expected to stop the process or // CONTINUE_EXECUTION when it's expected to continue further. diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index c89256da0..7598e068e 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -19,6 +19,8 @@ #include +const std::function G_TRANSLATION_FUN = nullptr; + /* Introduction text for doxygen: */ /*! \mainpage Developer documentation diff --git a/src/consensus/params.h b/src/consensus/params.h index 32371051e..7c130ef57 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -9,6 +9,7 @@ #include "uint256.h" #include +#include namespace Consensus { diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index 494ab98ce..ab1202990 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -14,6 +14,8 @@ #include #include +#include + static leveldb::Options GetOptions(size_t nCacheSize) { leveldb::Options options; diff --git a/src/gtest/main.cpp b/src/gtest/main.cpp index 6c8fd0c2b..c954af80b 100644 --- a/src/gtest/main.cpp +++ b/src/gtest/main.cpp @@ -7,6 +7,8 @@ #include "librustzcash.h" +const std::function G_TRANSLATION_FUN = nullptr; + struct ECCryptoClosure { ECCVerifyHandle handle; diff --git a/src/miner.h b/src/miner.h index e71685898..64bedc296 100644 --- a/src/miner.h +++ b/src/miner.h @@ -9,6 +9,7 @@ #include "primitives/block.h" #include +#include #include class CBlockIndex; diff --git a/src/noui.cpp b/src/noui.cpp index a5ecd9f27..83ca8b4a6 100644 --- a/src/noui.cpp +++ b/src/noui.cpp @@ -12,6 +12,8 @@ #include #include +#include + static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style) { bool fSecure = style & CClientUIInterface::SECURE; diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 6078c909a..c4e18ee81 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -28,6 +28,8 @@ #include "librustzcash.h" +const std::function G_TRANSLATION_FUN = nullptr; + CClientUIInterface uiInterface; // Declared but not defined in ui_interface.h CWallet* pwalletMain; ZCJoinSplit *pzcashParams; diff --git a/src/util.cpp b/src/util.cpp index 254bf1ad0..a0e7b8581 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -108,7 +108,6 @@ bool fLogTimestamps = DEFAULT_LOGTIMESTAMPS; bool fLogTimeMicros = DEFAULT_LOGTIMEMICROS; bool fLogIPs = DEFAULT_LOGIPS; std::atomic fReopenDebugLog(false); -CTranslationInterface translationInterface; /** * LogPrintf() has been broken a couple of times now diff --git a/src/util.h b/src/util.h index 80c047ba4..4ae1cee59 100644 --- a/src/util.h +++ b/src/util.h @@ -26,21 +26,12 @@ #include #include -#include #include static const bool DEFAULT_LOGTIMEMICROS = false; static const bool DEFAULT_LOGIPS = false; static const bool DEFAULT_LOGTIMESTAMPS = true; -/** Signals for translation. */ -class CTranslationInterface -{ -public: - /** Translate a message to the native language of the user. */ - boost::signals2::signal Translate; -}; - extern std::map mapArgs; extern std::map > mapMultiArgs; extern bool fDebug; @@ -51,18 +42,19 @@ extern bool fServer; extern bool fLogTimestamps; extern bool fLogIPs; extern std::atomic fReopenDebugLog; -extern CTranslationInterface translationInterface; [[noreturn]] extern void new_handler_terminate(); +/** Translate a message to the native language of the user. */ +const extern std::function G_TRANSLATION_FUN; + /** - * Translation function: Call Translate signal on UI interface, which returns a boost::optional result. - * If no translation slot is registered, nothing is returned, and simply return the input. + * Translation function. + * If no translation function is set, simply return the input. */ inline std::string _(const char* psz) { - boost::optional rv = translationInterface.Translate(psz); - return rv ? (*rv) : psz; + return G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz; } void SetupEnvironment(); diff --git a/src/zcash/Proof.hpp b/src/zcash/Proof.hpp index 7c9b7f7f5..2b2cfb291 100644 --- a/src/zcash/Proof.hpp +++ b/src/zcash/Proof.hpp @@ -4,6 +4,8 @@ #include "serialize.h" #include "uint256.h" +#include + namespace libzcash { const unsigned char G1_PREFIX_MASK = 0x02; From 5f171cdab1a321ce20b4b9be6bfe28e66b7bf3d7 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Mon, 15 Jul 2024 12:53:18 +0000 Subject: [PATCH 024/162] Use wchar_t API explicitly on Windows --- src/util.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index a0e7b8581..5c3a93dbd 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -756,14 +756,14 @@ boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate) { namespace fs = boost::filesystem; - char pszPath[MAX_PATH] = ""; + WCHAR pszPath[MAX_PATH] = L""; - if(SHGetSpecialFolderPathA(NULL, pszPath, nFolder, fCreate)) + if(SHGetSpecialFolderPathW(nullptr, pszPath, nFolder, fCreate)) { return fs::path(pszPath); } - LogPrintf("SHGetSpecialFolderPathA() failed, could not obtain requested path.\n"); + LogPrintf("SHGetSpecialFolderPathW() failed, could not obtain requested path.\n"); return fs::path(""); } #endif From a4842fdb954ceb07df33881a102604f4a87b9fb4 Mon Sep 17 00:00:00 2001 From: MarkLTZ Date: Mon, 15 Jul 2024 14:29:13 +0000 Subject: [PATCH 025/162] Replace boost::variant and boost::optional with standard library --- src/chain.h | 27 ++--- src/chainparams.cpp | 8 +- src/consensus/params.h | 8 +- src/consensus/upgrades.cpp | 12 +- src/consensus/upgrades.h | 10 +- src/crypto/equihash.cpp | 9 +- src/gtest/test_joinsplit.cpp | 2 - src/gtest/test_keys.cpp | 16 +-- src/gtest/test_noteencryption.cpp | 15 +-- src/gtest/test_pow.cpp | 2 +- src/gtest/test_sapling_note.cpp | 2 +- src/gtest/test_upgrades.cpp | 50 ++++----- src/gtest/test_validation.cpp | 4 +- src/gtest/test_zip32.cpp | 2 +- src/init.cpp | 4 +- src/key_io.cpp | 19 ++-- src/keystore.h | 1 - src/main.cpp | 31 +++--- src/main.h | 3 +- src/miner.cpp | 6 +- src/miner.h | 1 - src/net.cpp | 2 +- src/pow.cpp | 4 +- src/primitives/transaction.cpp | 4 +- src/primitives/transaction.h | 7 +- src/rpc/blockchain.cpp | 9 +- src/rpc/misc.cpp | 17 +-- src/rpc/rawtransaction.cpp | 3 +- src/script/standard.cpp | 10 +- src/script/standard.h | 6 +- src/serialize.h | 13 +-- src/test/key_tests.cpp | 17 +-- src/test/rpc_wallet_tests.cpp | 60 +++++----- src/test/serialize_tests.cpp | 10 +- src/transaction_builder.cpp | 31 +++--- src/transaction_builder.h | 12 +- src/util.h | 1 + src/utiltest.cpp | 2 +- src/validationinterface.cpp | 2 +- src/validationinterface.h | 6 +- src/wallet/asyncrpcoperation_common.cpp | 4 +- src/wallet/asyncrpcoperation_common.h | 6 +- .../asyncrpcoperation_mergetoaddress.cpp | 45 ++++---- src/wallet/asyncrpcoperation_mergetoaddress.h | 9 +- .../asyncrpcoperation_saplingmigration.cpp | 12 +- src/wallet/asyncrpcoperation_sendmany.cpp | 51 ++++----- src/wallet/asyncrpcoperation_sendmany.h | 9 +- .../asyncrpcoperation_shieldcoinbase.cpp | 8 +- src/wallet/asyncrpcoperation_shieldcoinbase.h | 2 +- src/wallet/gtest/test_wallet.cpp | 70 ++++++------ src/wallet/gtest/test_wallet_zkeys.cpp | 6 +- src/wallet/paymentdisclosuredb.h | 2 - src/wallet/rpcdump.cpp | 24 ++-- src/wallet/rpcwallet.cpp | 54 ++++----- src/wallet/wallet.cpp | 103 +++++++++--------- src/wallet/wallet.h | 55 +++++----- src/zcash/Address.cpp | 6 +- src/zcash/Address.hpp | 10 +- src/zcash/IncrementalMerkleTree.cpp | 16 +-- src/zcash/IncrementalMerkleTree.hpp | 10 +- src/zcash/JoinSplit.cpp | 1 - src/zcash/JoinSplit.hpp | 3 +- src/zcash/Note.cpp | 58 +++++----- src/zcash/Note.hpp | 16 +-- src/zcash/NoteEncryption.cpp | 24 ++-- src/zcash/NoteEncryption.hpp | 11 +- src/zcash/Proof.hpp | 2 +- src/zcash/address/sapling.cpp | 6 +- src/zcash/address/sapling.hpp | 4 +- src/zcash/address/zip32.cpp | 10 +- src/zcash/address/zip32.h | 6 +- src/zcbenchmarks.cpp | 6 +- 72 files changed, 562 insertions(+), 535 deletions(-) diff --git a/src/chain.h b/src/chain.h index 7512b06b4..df3550c67 100644 --- a/src/chain.h +++ b/src/chain.h @@ -12,6 +12,7 @@ #include "tinyformat.h" #include "uint256.h" +#include #include static const int SPROUT_VALUE_VERSION = 1001400; @@ -202,7 +203,7 @@ class CBlockIndex //! Branch ID corresponding to the consensus rules used to validate this block. //! Only cached if block validity is BLOCK_VALID_CONSENSUS. //! Persisted at each activation height, memory-only for intervening blocks. - boost::optional nCachedBranchId; + std::optional nCachedBranchId; //! The anchor for the tree state up to the start of this block uint256 hashSproutAnchor; @@ -211,22 +212,22 @@ class CBlockIndex uint256 hashFinalSproutRoot; //! Change in value held by the Sprout circuit over this block. - //! Will be boost::none for older blocks on old nodes until a reindex has taken place. - boost::optional nSproutValue; + //! Will be std::nullopt for older blocks on old nodes until a reindex has taken place. + std::optional nSproutValue; //! (memory only) Total value held by the Sprout circuit up to and including this block. - //! Will be boost::none for on old nodes until a reindex has taken place. - //! Will be boost::none if nChainTx is zero. - boost::optional nChainSproutValue; + //! Will be std::nullopt for on old nodes until a reindex has taken place. + //! Will be std::nullopt if nChainTx is zero. + std::optional nChainSproutValue; //! Change in value held by the Sapling circuit over this block. - //! Not a boost::optional because this was added before Sapling activated, so we can + //! Not a std::optional because this was added before Sapling activated, so we can //! rely on the invariant that every block before this was added had nSaplingValue = 0. CAmount nSaplingValue; //! (memory only) Total value held by the Sapling circuit up to and including this block. - //! Will be boost::none if nChainTx is zero. - boost::optional nChainSaplingValue; + //! Will be std::nullopt if nChainTx is zero. + std::optional nChainSaplingValue; //! block header int nVersion; @@ -253,14 +254,14 @@ class CBlockIndex nTx = 0; nChainTx = 0; nStatus = 0; - nCachedBranchId = boost::none; + nCachedBranchId = std::nullopt; hashSproutAnchor = uint256(); hashFinalSproutRoot = uint256(); nSequenceId = 0; - nSproutValue = boost::none; - nChainSproutValue = boost::none; + nSproutValue = std::nullopt; + nChainSproutValue = std::nullopt; nSaplingValue = 0; - nChainSaplingValue = boost::none; + nChainSaplingValue = std::nullopt; nVersion = 0; hashMerkleRoot = uint256(); diff --git a/src/chainparams.cpp b/src/chainparams.cpp index a680fd0e3..92e94e176 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -13,6 +13,8 @@ #include "utilstrencodings.h" #include +#include +#include #include @@ -96,7 +98,7 @@ class CMainParams : public CChainParams { consensus.nPreBlossomPowTargetSpacing = Consensus::PRE_BLOSSOM_POW_TARGET_SPACING; consensus.nPostBlossomPowTargetSpacing = Consensus::POST_BLOSSOM_POW_TARGET_SPACING; //consensus.nPowTargetSpacing = 2.5 * 60; - consensus.nPowAllowMinDifficultyBlocksAfterHeight = boost::none; + consensus.nPowAllowMinDifficultyBlocksAfterHeight = std::nullopt; consensus.vUpgrades[Consensus::BASE_SPROUT].nProtocolVersion = 170002; consensus.vUpgrades[Consensus::BASE_SPROUT].nActivationHeight = Consensus::NetworkUpgrade::ALWAYS_ACTIVE; @@ -357,7 +359,7 @@ class CTestNetParams : public CChainParams { consensus.nPreBlossomPowTargetSpacing = Consensus::PRE_BLOSSOM_POW_TARGET_SPACING; consensus.nPostBlossomPowTargetSpacing = Consensus::POST_BLOSSOM_POW_TARGET_SPACING; //consensus.nPowTargetSpacing = 2.5 * 60; - consensus.nPowAllowMinDifficultyBlocksAfterHeight = boost::none; + consensus.nPowAllowMinDifficultyBlocksAfterHeight = std::nullopt; consensus.vUpgrades[Consensus::BASE_SPROUT].nProtocolVersion = 170002; consensus.vUpgrades[Consensus::BASE_SPROUT].nActivationHeight = Consensus::NetworkUpgrade::ALWAYS_ACTIVE; @@ -778,7 +780,7 @@ CScript CChainParams::GetCommunityFeeScriptAtHeight(int nHeight) const { CTxDestination address = DecodeDestination(GetCommunityFeeAddressAtHeight(nHeight).c_str()); assert(IsValidDestination(address)); assert(IsScriptDestination(address)); - CScriptID scriptID = boost::get(address); // address is a boost variant + CScriptID scriptID = std::get(address); CScript script = CScript() << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL; return script; } diff --git a/src/consensus/params.h b/src/consensus/params.h index 7c130ef57..d6d26678a 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -8,8 +8,8 @@ #include "uint256.h" -#include -#include +#include +#include namespace Consensus { @@ -71,7 +71,7 @@ struct NetworkUpgrade { * scrutiny than regular releases. nMinimumChainWork MUST be set to at least the chain * work of this block, otherwise this detection will have false positives. */ - boost::optional hashActivationBlock; + std::optional hashActivationBlock; }; /** ZIP208 block target interval in seconds. */ @@ -129,7 +129,7 @@ struct Params { unsigned int nEquihashN = 144; unsigned int nEquihashK = 5; uint256 powLimit; - boost::optional nPowAllowMinDifficultyBlocksAfterHeight; + std::optional nPowAllowMinDifficultyBlocksAfterHeight; int64_t nPowAveragingWindow; int64_t nPowMaxAdjustDown; int64_t nPowMaxAdjustUp; diff --git a/src/consensus/upgrades.cpp b/src/consensus/upgrades.cpp index 9e11e14a8..d171a534a 100644 --- a/src/consensus/upgrades.cpp +++ b/src/consensus/upgrades.cpp @@ -121,9 +121,9 @@ bool IsActivationHeightForAnyUpgrade( return false; } -boost::optional NextEpoch(int nHeight, const Consensus::Params& params) { +std::optional NextEpoch(int nHeight, const Consensus::Params& params) { if (nHeight < 0) { - return boost::none; + return std::nullopt; } // Sprout is never pending @@ -133,16 +133,16 @@ boost::optional NextEpoch(int nHeight, const Consensus::Params& params) { } } - return boost::none; + return std::nullopt; } -boost::optional NextActivationHeight( +std::optional NextActivationHeight( int nHeight, const Consensus::Params& params) { auto idx = NextEpoch(nHeight, params); if (idx) { - return params.vUpgrades[idx.get()].nActivationHeight; + return params.vUpgrades[idx.value()].nActivationHeight; } - return boost::none; + return std::nullopt; } diff --git a/src/consensus/upgrades.h b/src/consensus/upgrades.h index d5bb70b6f..d6e981a0e 100644 --- a/src/consensus/upgrades.h +++ b/src/consensus/upgrades.h @@ -7,7 +7,7 @@ #include "consensus/params.h" -#include +#include enum UpgradeState { UPGRADE_DISABLED, @@ -77,15 +77,15 @@ bool IsActivationHeightForAnyUpgrade( /** * Returns the index of the next upgrade after the given block height, or - * boost::none if there are no more known upgrades. + * std::nullopt if there are no more known upgrades. */ -boost::optional NextEpoch(int nHeight, const Consensus::Params& params); +std::optional NextEpoch(int nHeight, const Consensus::Params& params); /** * Returns the activation height for the next upgrade after the given block height, - * or boost::none if there are no more known upgrades. + * or std::nullopt if there are no more known upgrades. */ -boost::optional NextActivationHeight( +std::optional NextActivationHeight( int nHeight, const Consensus::Params& params); diff --git a/src/crypto/equihash.cpp b/src/crypto/equihash.cpp index 863c4f673..5a4111838 100644 --- a/src/crypto/equihash.cpp +++ b/src/crypto/equihash.cpp @@ -22,10 +22,9 @@ #include #include +#include #include -#include - static EhSolverCancelledException solver_cancelled; template @@ -639,7 +638,7 @@ bool Equihash::OptimisedSolve(const eh_HashState& base_state, size_t hashLen; size_t lenIndices; unsigned char tmpHash[HashOutput]; - std::vector>>> X; + std::vector>>> X; X.reserve(K+1); // 3) Repeat steps 1 and 2 for each partial index @@ -657,7 +656,7 @@ bool Equihash::OptimisedSolve(const eh_HashState& base_state, N/8, HashLength, CollisionBitLength, newIndex); if (cancelled(PartialGeneration)) throw solver_cancelled; } - boost::optional>> ic = icv; + std::optional>> ic = icv; // 2a) For each pair of lists: hashLen = HashLength; @@ -682,7 +681,7 @@ bool Equihash::OptimisedSolve(const eh_HashState& base_state, if (ic->size() == 0) goto invalidsolution; - X[r] = boost::none; + X[r] = std::nullopt; hashLen -= CollisionByteLength; lenIndices *= 2; rti = lti; diff --git a/src/gtest/test_joinsplit.cpp b/src/gtest/test_joinsplit.cpp index 43330baa5..7aaf1d36f 100644 --- a/src/gtest/test_joinsplit.cpp +++ b/src/gtest/test_joinsplit.cpp @@ -2,8 +2,6 @@ #include "utilstrencodings.h" -#include - #include "zcash/prf.h" #include "util.h" #include "streams.h" diff --git a/src/gtest/test_keys.cpp b/src/gtest/test_keys.cpp index a74ef066d..8caebdd92 100644 --- a/src/gtest/test_keys.cpp +++ b/src/gtest/test_keys.cpp @@ -4,6 +4,8 @@ #include "utiltest.h" +#include + #include TEST(Keys, EncodeAndDecodeSapling) @@ -23,9 +25,9 @@ TEST(Keys, EncodeAndDecodeSapling) auto spendingkey2 = DecodeSpendingKey(sk_string); EXPECT_TRUE(IsValidSpendingKey(spendingkey2)); - ASSERT_TRUE(boost::get(&spendingkey2) != nullptr); - auto sk2 = boost::get(spendingkey2); - EXPECT_EQ(sk, sk2); + ASSERT_TRUE(std::get_if(&spendingkey2) != nullptr); + auto sk2 = std::get(spendingkey2); + EXPECT_EQ(sk, sk2); } { auto extfvk = sk.ToXFVK(); @@ -37,8 +39,8 @@ TEST(Keys, EncodeAndDecodeSapling) auto viewingkey2 = DecodeViewingKey(vk_string); EXPECT_TRUE(IsValidViewingKey(viewingkey2)); - ASSERT_TRUE(boost::get(&viewingkey2) != nullptr); - auto extfvk2 = boost::get(viewingkey2); + ASSERT_TRUE(std::get_if(&viewingkey2) != nullptr); + auto extfvk2 = std::get(viewingkey2); EXPECT_EQ(extfvk, extfvk2); } { @@ -52,8 +54,8 @@ TEST(Keys, EncodeAndDecodeSapling) auto paymentaddr2 = DecodePaymentAddress(addr_string); EXPECT_TRUE(IsValidPaymentAddress(paymentaddr2)); - ASSERT_TRUE(boost::get(&paymentaddr2) != nullptr); - auto addr2 = boost::get(paymentaddr2); + ASSERT_TRUE(std::get_if(&paymentaddr2) != nullptr); + auto addr2 = std::get(paymentaddr2); EXPECT_EQ(addr, addr2); } } diff --git a/src/gtest/test_noteencryption.cpp b/src/gtest/test_noteencryption.cpp index 0ed6999f8..63423b827 100644 --- a/src/gtest/test_noteencryption.cpp +++ b/src/gtest/test_noteencryption.cpp @@ -2,6 +2,7 @@ #include "sodium.h" #include +#include #include #include "zcash/Note.hpp" @@ -39,7 +40,7 @@ TEST(noteencryption, NotePlaintext) if (!cmu_opt) { FAIL(); } - uint256 cmu = cmu_opt.get(); + uint256 cmu = cmu_opt.value(); SaplingNotePlaintext pt(note, memo); auto res = pt.encrypt(addr.pk_d); @@ -47,7 +48,7 @@ TEST(noteencryption, NotePlaintext) FAIL(); } - auto enc = res.get(); + auto enc = res.value(); auto ct = enc.first; auto encryptor = enc.second; @@ -73,7 +74,7 @@ TEST(noteencryption, NotePlaintext) FAIL(); } - auto bar = foo.get(); + auto bar = foo.value(); ASSERT_TRUE(bar.value() == pt.value()); ASSERT_TRUE(bar.memo() == pt.memo()); @@ -86,7 +87,7 @@ TEST(noteencryption, NotePlaintext) FAIL(); } - auto new_note = foobar.get(); + auto new_note = foobar.value(); ASSERT_TRUE(note.value() == new_note.value()); ASSERT_TRUE(note.d == new_note.d); @@ -121,7 +122,7 @@ TEST(noteencryption, NotePlaintext) FAIL(); } - auto decrypted_out_ct_unwrapped = decrypted_out_ct.get(); + auto decrypted_out_ct_unwrapped = decrypted_out_ct.value(); ASSERT_TRUE(decrypted_out_ct_unwrapped.pk_d == out_pt.pk_d); ASSERT_TRUE(decrypted_out_ct_unwrapped.esk == out_pt.esk); @@ -150,7 +151,7 @@ TEST(noteencryption, NotePlaintext) FAIL(); } - bar = foo.get(); + bar = foo.value(); ASSERT_TRUE(bar.value() == pt.value()); ASSERT_TRUE(bar.memo() == pt.memo()); @@ -183,7 +184,7 @@ TEST(noteencryption, SaplingApi) } // Invalid diversifier - ASSERT_EQ(boost::none, SaplingNoteEncryption::FromDiversifier({1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})); + ASSERT_EQ(std::nullopt, SaplingNoteEncryption::FromDiversifier({1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})); // Encrypt to pk_1 auto enc = *SaplingNoteEncryption::FromDiversifier(pk_1.d); diff --git a/src/gtest/test_pow.cpp b/src/gtest/test_pow.cpp index ad1dbca4b..fc0517043 100644 --- a/src/gtest/test_pow.cpp +++ b/src/gtest/test_pow.cpp @@ -93,7 +93,7 @@ TEST(PoW, MinDifficultyRules) { std::vector blocks(lastBlk+1); for (int i = 0; i <= lastBlk; i++) { blocks[i].pprev = i ? &blocks[i - 1] : nullptr; - blocks[i].nHeight = params.nPowAllowMinDifficultyBlocksAfterHeight.get() + i; + blocks[i].nHeight = params.nPowAllowMinDifficultyBlocksAfterHeight.value() + i; blocks[i].nTime = i ? blocks[i - 1].nTime + params.PoWTargetSpacing(i) : 1269211443; blocks[i].nBits = 0x1e7fffff; /* target 0x007fffff000... */ blocks[i].nChainWork = i ? blocks[i - 1].nChainWork + GetBlockProof(blocks[i - 1]) : arith_uint256(0); diff --git a/src/gtest/test_sapling_note.cpp b/src/gtest/test_sapling_note.cpp index 3e336ec7e..9f3979a86 100644 --- a/src/gtest/test_sapling_note.cpp +++ b/src/gtest/test_sapling_note.cpp @@ -45,7 +45,7 @@ TEST(SaplingNote, TestVectors) // Test commitment SaplingNote note = SaplingNote(diversifier, pk_d, v, r); - ASSERT_EQ(note.cm().get(), cm); + ASSERT_EQ(note.cm().value(), cm); // Test nullifier SaplingSpendingKey spendingKey(sk); diff --git a/src/gtest/test_upgrades.cpp b/src/gtest/test_upgrades.cpp index 54fa48832..9fe3e6f49 100644 --- a/src/gtest/test_upgrades.cpp +++ b/src/gtest/test_upgrades.cpp @@ -3,7 +3,7 @@ #include "chainparams.h" #include "consensus/upgrades.h" -#include +#include class UpgradesTest : public ::testing::Test { protected: @@ -148,28 +148,28 @@ TEST_F(UpgradesTest, NextEpoch) { const Consensus::Params& params = Params().GetConsensus(); // Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT - EXPECT_EQ(NextEpoch(-1, params), boost::none); - EXPECT_EQ(NextEpoch(0, params), boost::none); - EXPECT_EQ(NextEpoch(1, params), boost::none); - EXPECT_EQ(NextEpoch(1000000, params), boost::none); + EXPECT_EQ(NextEpoch(-1, params), std::nullopt); + EXPECT_EQ(NextEpoch(0, params), std::nullopt); + EXPECT_EQ(NextEpoch(1, params), std::nullopt); + EXPECT_EQ(NextEpoch(1000000, params), std::nullopt); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); - EXPECT_EQ(NextEpoch(-1, params), boost::none); - EXPECT_EQ(NextEpoch(0, params), boost::none); - EXPECT_EQ(NextEpoch(1, params), boost::none); - EXPECT_EQ(NextEpoch(1000000, params), boost::none); + EXPECT_EQ(NextEpoch(-1, params), std::nullopt); + EXPECT_EQ(NextEpoch(0, params), std::nullopt); + EXPECT_EQ(NextEpoch(1, params), std::nullopt); + EXPECT_EQ(NextEpoch(1000000, params), std::nullopt); int nActivationHeight = 100; UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, nActivationHeight); - EXPECT_EQ(NextEpoch(-1, params), boost::none); + EXPECT_EQ(NextEpoch(-1, params), std::nullopt); EXPECT_EQ(NextEpoch(0, params), static_cast(Consensus::UPGRADE_TESTDUMMY)); EXPECT_EQ(NextEpoch(1, params), static_cast(Consensus::UPGRADE_TESTDUMMY)); EXPECT_EQ(NextEpoch(nActivationHeight - 1, params), static_cast(Consensus::UPGRADE_TESTDUMMY)); - EXPECT_EQ(NextEpoch(nActivationHeight, params), boost::none); - EXPECT_EQ(NextEpoch(nActivationHeight + 1, params), boost::none); - EXPECT_EQ(NextEpoch(1000000, params), boost::none); + EXPECT_EQ(NextEpoch(nActivationHeight, params), std::nullopt); + EXPECT_EQ(NextEpoch(nActivationHeight + 1, params), std::nullopt); + EXPECT_EQ(NextEpoch(1000000, params), std::nullopt); } TEST_F(UpgradesTest, NextActivationHeight) { @@ -177,26 +177,26 @@ TEST_F(UpgradesTest, NextActivationHeight) { const Consensus::Params& params = Params().GetConsensus(); // Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT - EXPECT_EQ(NextActivationHeight(-1, params), boost::none); - EXPECT_EQ(NextActivationHeight(0, params), boost::none); - EXPECT_EQ(NextActivationHeight(1, params), boost::none); - EXPECT_EQ(NextActivationHeight(1000000, params), boost::none); + EXPECT_EQ(NextActivationHeight(-1, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(0, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(1, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(1000000, params), std::nullopt); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); - EXPECT_EQ(NextActivationHeight(-1, params), boost::none); - EXPECT_EQ(NextActivationHeight(0, params), boost::none); - EXPECT_EQ(NextActivationHeight(1, params), boost::none); - EXPECT_EQ(NextActivationHeight(1000000, params), boost::none); + EXPECT_EQ(NextActivationHeight(-1, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(0, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(1, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(1000000, params), std::nullopt); int nActivationHeight = 100; UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, nActivationHeight); - EXPECT_EQ(NextActivationHeight(-1, params), boost::none); + EXPECT_EQ(NextActivationHeight(-1, params), std::nullopt); EXPECT_EQ(NextActivationHeight(0, params), nActivationHeight); EXPECT_EQ(NextActivationHeight(1, params), nActivationHeight); EXPECT_EQ(NextActivationHeight(nActivationHeight - 1, params), nActivationHeight); - EXPECT_EQ(NextActivationHeight(nActivationHeight, params), boost::none); - EXPECT_EQ(NextActivationHeight(nActivationHeight + 1, params), boost::none); - EXPECT_EQ(NextActivationHeight(1000000, params), boost::none); + EXPECT_EQ(NextActivationHeight(nActivationHeight, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(nActivationHeight + 1, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(1000000, params), std::nullopt); } diff --git a/src/gtest/test_validation.cpp b/src/gtest/test_validation.cpp index 43c42741d..dd7357122 100644 --- a/src/gtest/test_validation.cpp +++ b/src/gtest/test_validation.cpp @@ -5,6 +5,8 @@ #include "main.h" #include "utiltest.h" +#include + extern ZCJoinSplit* params; extern bool ReceivedBlockTransactions( @@ -14,7 +16,7 @@ extern bool ReceivedBlockTransactions( CBlockIndex *pindexNew, const CDiskBlockPos& pos); -void ExpectOptionalAmount(CAmount expected, boost::optional actual) { +void ExpectOptionalAmount(CAmount expected, std::optional actual) { EXPECT_TRUE((bool)actual); if (actual) { EXPECT_EQ(expected, *actual); diff --git a/src/gtest/test_zip32.cpp b/src/gtest/test_zip32.cpp index e7715fd03..c8ee5a335 100644 --- a/src/gtest/test_zip32.cpp +++ b/src/gtest/test_zip32.cpp @@ -109,7 +109,7 @@ TEST(ZIP32, TestVectors) { auto maybe_m_1_2hv_3 = m_1_2hv.Derive(3); EXPECT_TRUE(maybe_m_1_2hv_3); - auto m_1_2hv_3 = maybe_m_1_2hv_3.get(); + auto m_1_2hv_3 = maybe_m_1_2hv_3.value(); EXPECT_EQ(m_1_2hv_3.depth, 3); EXPECT_EQ(m_1_2hv_3.parentFVKTag, 0x7583c148); EXPECT_EQ(m_1_2hv_3.childIndex, 3); diff --git a/src/init.cpp b/src/init.cpp index 89c1fa1cd..ccafb46ec 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1080,7 +1080,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (mapArgs.count("-migrationdestaddress")) { std::string migrationDestAddress = mapArgs["-migrationdestaddress"]; libzcash::PaymentAddress address = DecodePaymentAddress(migrationDestAddress); - if (boost::get(&address) == nullptr) { + if (std::get_if(&address) == nullptr) { return InitError(_("-migrationdestaddress must be a valid Sapling address.")); } } @@ -1778,7 +1778,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (pwalletMain) { // Address has already been validated CTxDestination addr = DecodeDestination(mapArgs["-mineraddress"]); - CKeyID keyID = boost::get(addr); + CKeyID keyID = std::get(addr); minerAddressInLocalWallet = pwalletMain->HaveKey(keyID); } if (GetBoolArg("-minetolocalwallet", true) && !minerAddressInLocalWallet) { diff --git a/src/key_io.cpp b/src/key_io.cpp index 4f41c16b8..21e769efb 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -10,16 +10,13 @@ #include