Skip to content

Commit

Permalink
Merge remote-tracking branch 'navcoin/master' into btc-master
Browse files Browse the repository at this point in the history
 Conflicts:
	ci/test/04_install.sh
	src/Makefile.am
	src/key_io.h
	src/test/blsct/bech32_mod_tests.cpp
	src/test/coins_tests.cpp
  • Loading branch information
mxaddict committed Jan 10, 2024
2 parents 0e0289a + eddf587 commit 6bcf134
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 62 deletions.
28 changes: 28 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ AC_ARG_ENABLE([lto],
[enable_lto=$enableval],
[enable_lto=no])

AC_ARG_ENABLE([build-libblsct-only],
[AS_HELP_STRING([--enable-build-libblsct-only],
[build libblsct.a only and do not build others (default is to build everything)])],
[enable_build_libblsct_only=$enableval],
[enable_build_libblsct_only=no])

AC_LANG_PUSH([C++])

dnl Check for a flag to turn compiler warnings into errors. This is helpful for checks which may
Expand Down Expand Up @@ -1294,6 +1300,26 @@ if test "$enable_fuzz" = "yes"; then
AX_CHECK_PREPROC_FLAG([-DABORT_ON_FAILED_ASSUME], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DABORT_ON_FAILED_ASSUME"], [], [$CXXFLAG_WERROR])
fi

if test "$enable_build_libblsct_only" = "yes"; then
AC_MSG_WARN([enable-build-libblsct-only will disable all other targets overriding enable-fuzz])
build_bitcoin_utils=no
build_bitcoin_cli=no
build_bitcoin_tx=no
build_bitcoin_util=no
build_bitcoin_chainstate=no
build_bitcoin_wallet=no
build_bitcoind=no
build_bitcoin_libs=no
use_bench=no
use_tests=no
use_external_signer=no
use_upnp=no
use_natpmp=no
use_zmq=no
enable_fuzz=no
enable_fuzz_binary=no
fi

if test "$enable_fuzz_binary" = "yes"; then
AC_MSG_CHECKING([whether main function is needed for fuzz binary])
AX_CHECK_LINK_FLAG(
Expand Down Expand Up @@ -1769,6 +1795,7 @@ AM_CONDITIONAL([USE_ASM], [test "$use_asm" = "yes"])
AM_CONDITIONAL([WORDS_BIGENDIAN], [test "$ac_cv_c_bigendian" = "yes"])
AM_CONDITIONAL([USE_NATPMP], [test "$use_natpmp" = "yes"])
AM_CONDITIONAL([USE_UPNP], [test "$use_upnp" = "yes"])
AM_CONDITIONAL([BUILD_LIBBLSCT_ONLY], [test "$enable_build_libblsct_only" = "yes"])

dnl for minisketch
AM_CONDITIONAL([ENABLE_CLMUL], [test "$enable_clmul" = "yes"])
Expand Down Expand Up @@ -1917,6 +1944,7 @@ echo " debug enabled = $enable_debug"
echo " gprof enabled = $enable_gprof"
echo " werror = $enable_werror"
echo " LTO = $enable_lto"
echo " libblsct only = $enable_build_libblsct_only"
echo
echo " target os = $host_os"
echo " build os = $build_os"
Expand Down
163 changes: 108 additions & 55 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ noinst_LTLIBRARIES += $(LIBBITCOIN_CRYPTO)
$(LIBSECP256K1): $(wildcard secp256k1/src/*.h) $(wildcard secp256k1/src/*.c) $(wildcard secp256k1/include/*)
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)

LIBBLS_A = bls/lib/libbls384_256.a
$(LIBBLS):
$(AM_V_at) \
ARCH='$(firstword $(subst -, ,$(HOST)))' \
Expand All @@ -85,8 +86,9 @@ $(LIBBLS):
AR='$(AR)' \
RANLIB='$(RANLIB)' \
$(MAKE) $(AM_MAKEFLAGS) BLS_ETH=1 -C bls lib/libbls384_256.a
$(RANLIB) bls/lib/libbls384_256.a
$(RANLIB) $(LIBBLS_A)

LIBMCL_A = bls/mcl/lib/libmcl.a
$(LIBMCL):
$(AM_V_at) \
MCL_USE_LLVM=0 \
Expand All @@ -99,7 +101,7 @@ $(LIBMCL):
AR='$(AR)' \
RANLIB='$(RANLIB)' \
$(MAKE) $(AM_MAKEFLAGS) -C bls/mcl lib/libmcl.a
$(RANLIB) bls/mcl/lib/libmcl.a
$(RANLIB) $(LIBMCL_A)

# Make is not made aware of per-object dependencies to avoid limiting building parallelization
# But to build the less dependent modules first, we manually select their order here:
Expand Down Expand Up @@ -144,28 +146,15 @@ if BUILD_BITCOIN_CHAINSTATE
bin_PROGRAMS += navcoin-chainstate
endif

.PHONY: FORCE check-symbols check-security
# navcoin core #
BITCOIN_CORE_H = \
addresstype.h \
addrdb.h \
addrman.h \
addrman_impl.h \
attributes.h \
banman.h \
base58.h \
bech32.h \
bech32_mod.h \
bip324.h \
blockencodings.h \
blockfilter.h \
BLSCT_H = \
blsct/arith/mcl/mcl.h \
blsct/arith/mcl/mcl_g1point.h \
blsct/arith/mcl/mcl_init.h \
blsct/arith/mcl/mcl_scalar.h \
blsct/arith/mcl/mcl_util.h \
blsct/arith/elements.h \
blsct/arith/endianness.h \
blsct/bech32_mod.h \
blsct/building_block/fiat_shamir.h \
blsct/building_block/generator_deriver.h \
blsct/building_block/g_h_gi_hi_zero_verifier.h \
Expand Down Expand Up @@ -207,7 +196,61 @@ BITCOIN_CORE_H = \
blsct/wallet/keyring.h \
blsct/wallet/txfactory.h \
blsct/wallet/txfactory_global.h \
blsct/wallet/verification.h \
blsct/wallet/verification.h

BLSCT_CPP = \
blsct/arith/mcl/mcl_g1point.cpp \
blsct/arith/mcl/mcl_scalar.cpp \
blsct/arith/elements.cpp \
blsct/building_block/generator_deriver.cpp \
blsct/building_block/g_h_gi_hi_zero_verifier.cpp \
blsct/building_block/imp_inner_prod_arg.cpp \
blsct/building_block/lazy_point.cpp \
blsct/building_block/lazy_points.cpp \
blsct/building_block/weighted_inner_prod_arg.cpp \
blsct/common.cpp \
blsct/double_public_key.cpp \
blsct/eip_2333/bls12_381_keygen.cpp \
blsct/private_key.cpp \
blsct/public_key.cpp \
blsct/public_keys.cpp \
blsct/range_proof/bulletproofs/amount_recovery_request.cpp \
blsct/range_proof/bulletproofs/amount_recovery_result.cpp \
blsct/range_proof/bulletproofs/range_proof_logic.cpp \
blsct/range_proof/bulletproofs/range_proof.cpp \
blsct/range_proof/bulletproofs/range_proof_with_transcript.cpp \
blsct/range_proof/bulletproofs_plus/amount_recovery_request.cpp \
blsct/range_proof/bulletproofs_plus/amount_recovery_result.cpp \
blsct/range_proof/bulletproofs_plus/range_proof_logic.cpp \
blsct/range_proof/bulletproofs_plus/range_proof.cpp \
blsct/range_proof/bulletproofs_plus/range_proof_with_transcript.cpp \
blsct/range_proof/bulletproofs_plus/util.cpp \
blsct/range_proof/common.cpp \
blsct/range_proof/generators.cpp \
blsct/range_proof/msg_amt_cipher.cpp \
blsct/range_proof/proof_base.cpp \
blsct/set_mem_proof/set_mem_proof.cpp \
blsct/set_mem_proof/set_mem_proof_setup.cpp \
blsct/set_mem_proof/set_mem_proof_prover.cpp \
blsct/wallet/verification.cpp \
blsct/signature.cpp


.PHONY: FORCE check-symbols check-security
# navcoin core #
BITCOIN_CORE_H = \
addrdb.h \
addresstype.h \
addrman.h \
addrman_impl.h \
attributes.h \
banman.h \
base58.h \
bech32.h \
bech32_mod.h \
bip324.h \
blockencodings.h \
blockfilter.h \
dandelion.h \
chain.h \
chainparams.h \
Expand Down Expand Up @@ -447,7 +490,8 @@ BITCOIN_CORE_H = \
zmq/zmqnotificationinterface.h \
zmq/zmqpublishnotifier.h \
zmq/zmqrpc.h \
zmq/zmqutil.h
zmq/zmqutil.h \
$(BLSCT_H)


obj/build.h: FORCE
Expand All @@ -466,41 +510,6 @@ libbitcoin_node_a_SOURCES = \
bip324.cpp \
blockencodings.cpp \
blockfilter.cpp \
blsct/arith/mcl/mcl_g1point.cpp \
blsct/arith/mcl/mcl_scalar.cpp \
blsct/arith/elements.cpp \
blsct/building_block/generator_deriver.cpp \
blsct/building_block/g_h_gi_hi_zero_verifier.cpp \
blsct/building_block/imp_inner_prod_arg.cpp \
blsct/building_block/lazy_point.cpp \
blsct/building_block/lazy_points.cpp \
blsct/building_block/weighted_inner_prod_arg.cpp \
blsct/common.cpp \
blsct/double_public_key.cpp \
blsct/eip_2333/bls12_381_keygen.cpp \
blsct/private_key.cpp \
blsct/public_key.cpp \
blsct/public_keys.cpp \
blsct/range_proof/bulletproofs/amount_recovery_request.cpp \
blsct/range_proof/bulletproofs/amount_recovery_result.cpp \
blsct/range_proof/bulletproofs/range_proof_logic.cpp \
blsct/range_proof/bulletproofs/range_proof.cpp \
blsct/range_proof/bulletproofs/range_proof_with_transcript.cpp \
blsct/range_proof/bulletproofs_plus/amount_recovery_request.cpp \
blsct/range_proof/bulletproofs_plus/amount_recovery_result.cpp \
blsct/range_proof/bulletproofs_plus/range_proof_logic.cpp \
blsct/range_proof/bulletproofs_plus/range_proof.cpp \
blsct/range_proof/bulletproofs_plus/range_proof_with_transcript.cpp \
blsct/range_proof/bulletproofs_plus/util.cpp \
blsct/range_proof/common.cpp \
blsct/range_proof/generators.cpp \
blsct/range_proof/msg_amt_cipher.cpp \
blsct/range_proof/proof_base.cpp \
blsct/set_mem_proof/set_mem_proof.cpp \
blsct/set_mem_proof/set_mem_proof_setup.cpp \
blsct/set_mem_proof/set_mem_proof_prover.cpp \
blsct/wallet/verification.cpp \
blsct/signature.cpp \
chain.cpp \
chainparams.cpp \
consensus/tx_verify.cpp \
Expand Down Expand Up @@ -585,6 +594,7 @@ libbitcoin_node_a_SOURCES = \
validation.cpp \
validationinterface.cpp \
versionbits.cpp \
$(BLSCT_CPP) \
$(BITCOIN_CORE_H)

if ENABLE_WALLET
Expand Down Expand Up @@ -841,8 +851,8 @@ libbitcoin_common_a_SOURCES = \
bech32.cpp \
blsct/arith/mcl/mcl_g1point.cpp \
blsct/arith/mcl/mcl_scalar.cpp \
bech32_mod.cpp \
blsct/arith/elements.cpp \
blsct/bech32_mod.cpp \
blsct/building_block/generator_deriver.cpp \
blsct/building_block/g_h_gi_hi_zero_verifier.cpp \
blsct/building_block/imp_inner_prod_arg.cpp \
Expand Down Expand Up @@ -1310,9 +1320,52 @@ CLEANFILES += wallet/*.gcda wallet/*.gcno
CLEANFILES += wallet/test/*.gcda wallet/test/*.gcno
CLEANFILES += zmq/*.gcda zmq/*.gcno
CLEANFILES += obj/build.h
CLEANFILES += $(LIBBLS_A)
CLEANFILES += $(LIBMCL_A)

EXTRA_DIST = $(CTAES_DIST)

# blsct library #
if BUILD_LIBBLSCT_ONLY
LIBBLSCT_A = libblsct.a
noinst_LIBRARIES = $(LIBBLSCT_A)
libblsct_a_SOURCES = \
crypto/sha256_arm_shani.cpp \
crypto/sha256_avx2.cpp \
crypto/sha256_sse4.cpp \
crypto/sha256_sse41.cpp \
crypto/sha256_x86_shani.cpp \
crypto/sha256.cpp \
blsct/external_api/blsct.cpp \
$(BLSCT_CPP)
libblsct_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libblsct_a_CPPFLAGS = $(AM_CPPFLAGS) $(BLS_INCLUDES) $(BOOST_CPPFLAGS)

if ENABLE_SSE41
libblsct_a_CXXFLAGS += $(SSE41_CXXFLAGS)
libblsct_a_CPPFLAGS += -DENABLE_SSE41
endif

if ENABLE_AVX2
libblsct_a_CXXFLAGS += $(AVX2_CXXFLAGS)
libblsct_a_CPPFLAGS += -DENABLE_AVX2
endif

if ENABLE_X86_SHANI
libblsct_a_CXXFLAGS += $(X86_SHANI_CXXFLAGS)
libblsct_a_CPPFLAGS += -DENABLE_X86_SHANI
endif

if ENABLE_ARM_SHANI
libblsct_a_CXXFLAGS += $(ARM_SHANI_CXXFLAGS)
libblsct_a_CPPFLAGS += -DENABLE_ARM_SHANI
endif

$(LIBBLSCT_A): $(LIBBLS) $(LIBMCL)

CLEANFILES += $(LIBBLSCT_A) blsct/include/libblsct_a-blsct.o
endif
#

config/bitcoin-config.h: config/stamp-h1
@$(MAKE) -C $(top_builddir) $(subdir)/$(@)
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ BITCOIN_TESTS =\
test/base58_tests.cpp \
test/base64_tests.cpp \
test/bech32_tests.cpp \
test/bech32_mod_tests.cpp \
test/bip32_tests.cpp \
test/blockchain_tests.cpp \
test/blockencodings_tests.cpp \
Expand All @@ -90,6 +89,7 @@ BITCOIN_TESTS =\
test/blsct/arith/mcl/mcl_g1point_tests.cpp \
test/blsct/arith/mcl/mcl_integration_tests.cpp \
test/blsct/arith/mcl/mcl_scalar_tests.cpp \
test/blsct/bech32_mod_tests.cpp \
test/blsct/building_block/generator_deriver_tests.cpp \
test/blsct/building_block/imp_inner_prod_arg_tests.cpp \
test/blsct/building_block/lazy_points_tests.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/bench/bech32_mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <bench/bench.h>

#include <bech32_mod.h>
#include <blsct/bech32_mod.h>
#include <util/strencodings.h>

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion src/bech32_mod.cpp → src/blsct/bech32_mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <blsct/double_public_key.h>
#include <bech32_mod.h>
#include <blsct/bech32_mod.h>
#include <util/vector.h>

#include <array>
Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions src/blsct/external_api/blsct.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <blsct/external_api/blsct.h>
#include <blsct/arith/mcl/mcl.h>
#include <blsct/arith/mcl/mcl_init.h>
#include <iostream>

extern "C" {

void BlsctInit() {
MclInit for_side_effect_only;
}

void BlsctTest() {

Mcl::Scalar a(1);
Mcl::Scalar b(2);

auto c = a + b;

auto s = c.GetString();

std::cout << "The answer is " << s << std::endl;
}

} // extern "C"
6 changes: 6 additions & 0 deletions src/blsct/external_api/blsct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extern "C" {

void BlsctInit();
void BlsctTest();

} // extern "C"
2 changes: 1 addition & 1 deletion src/key_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include <base58.h>
#include <bech32.h>
#include <bech32_mod.h>
#include <blsct/arith/mcl/mcl.h>
#include <blsct/bech32_mod.h>
#include <blsct/double_public_key.h>
#include <key_io.h>
#include <net.h>
Expand Down
2 changes: 1 addition & 1 deletion src/key_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define BITCOIN_KEY_IO_H

#include <addresstype.h>
#include <bech32_mod.h>
#include <blsct/bech32_mod.h>
#include <blsct/double_public_key.h>
#include <chainparams.h>
#include <key.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <bech32_mod.h>
#include <blsct/bech32_mod.h>
#include <blsct/double_public_key.h>
#include <random.h>
#include <test/util/str.h>
Expand Down
Loading

0 comments on commit 6bcf134

Please sign in to comment.