From 529b54d9224e680197e6052b505d2a66398e0d36 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Fri, 14 Apr 2023 07:11:46 +0200 Subject: [PATCH 1/6] autotools: Move Wycheproof header from EXTRA_DIST to noinst_HEADERS --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 36e26e3e8a47f..23555e344f83f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,6 +65,7 @@ noinst_HEADERS += src/hash_impl.h noinst_HEADERS += src/field.h noinst_HEADERS += src/field_impl.h noinst_HEADERS += src/bench.h +noinst_HEADERS += src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h noinst_HEADERS += contrib/lax_der_parsing.h noinst_HEADERS += contrib/lax_der_parsing.c noinst_HEADERS += contrib/lax_der_privatekey_parsing.h @@ -249,7 +250,6 @@ include src/modules/schnorrsig/Makefile.am.include endif EXTRA_DIST += src/wycheproof/WYCHEPROOF_COPYING -EXTRA_DIST += src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h EXTRA_DIST += src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json EXTRA_DIST += tools/tests_wycheproof_generate.py From 08f4b1632d0ad976fe00ee606f3a95894555a2e1 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Fri, 14 Apr 2023 07:22:01 +0200 Subject: [PATCH 2/6] autotools: Move code around to tidy Makefile --- Makefile.am | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Makefile.am b/Makefile.am index 23555e344f83f..20024e474e79b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -223,6 +223,20 @@ maintainer-clean-local: clean-precomp clean-precomp: rm -f $(PRECOMP) +### Pregenerated test vectors +TESTVECTORS = src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h + +src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h: + python3 tools/tests_wycheproof_generate.py src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json > $@ + +testvectors: $(TESTVECTORS) + +maintainer-clean-testvectors: clean-testvectors + +clean-testvectors: + rm -f $(TESTVECTORS) + +### Additional files to distribute EXTRA_DIST = autogen.sh CHANGELOG.md SECURITY.md EXTRA_DIST += doc/release-process.md doc/safegcd_implementation.md EXTRA_DIST += examples/EXAMPLES_COPYING @@ -232,6 +246,9 @@ EXTRA_DIST += sage/group_prover.sage EXTRA_DIST += sage/prove_group_implementations.sage EXTRA_DIST += sage/secp256k1_params.sage EXTRA_DIST += sage/weierstrass_prover.sage +EXTRA_DIST += src/wycheproof/WYCHEPROOF_COPYING +EXTRA_DIST += src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json +EXTRA_DIST += tools/tests_wycheproof_generate.py if ENABLE_MODULE_ECDH include src/modules/ecdh/Makefile.am.include @@ -248,19 +265,3 @@ endif if ENABLE_MODULE_SCHNORRSIG include src/modules/schnorrsig/Makefile.am.include endif - -EXTRA_DIST += src/wycheproof/WYCHEPROOF_COPYING -EXTRA_DIST += src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json -EXTRA_DIST += tools/tests_wycheproof_generate.py - -TESTVECTORS = src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h - -src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h: - python3 tools/tests_wycheproof_generate.py src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json > $@ - -testvectors: $(TESTVECTORS) - -maintainer-clean-testvectors: clean-testvectors - -clean-testvectors: - rm -f $(TESTVECTORS) From e1b9ce881159e8e2572467f1426f200e987a4d44 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Fri, 14 Apr 2023 07:37:10 +0200 Subject: [PATCH 3/6] autotools: Use same conventions for all pregenerated files --- Makefile.am | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 20024e474e79b..f745013c933fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -203,7 +203,7 @@ precompute_ecmult_gen_LDADD = $(COMMON_LIB) # otherwise make's decision whether to rebuild them (even in the first # build by a normal user) depends on mtimes, and thus is very fragile. # This means that rebuilds of the prebuilt files always need to be -# forced by deleting them, e.g., by invoking `make clean-precomp`. +# forced by deleting them. src/precomputed_ecmult.c: $(MAKE) $(AM_MAKEFLAGS) precompute_ecmult$(EXEEXT) ./precompute_ecmult$(EXEEXT) @@ -224,6 +224,7 @@ clean-precomp: rm -f $(PRECOMP) ### Pregenerated test vectors +### (see the comments in the previous section for detailed rationale) TESTVECTORS = src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h: @@ -231,7 +232,9 @@ src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h: testvectors: $(TESTVECTORS) -maintainer-clean-testvectors: clean-testvectors +BUILT_SOURCES += $(TESTVECTORS) + +maintainer-clean-local: clean-testvectors clean-testvectors: rm -f $(TESTVECTORS) From 8764034ed55bffc8a26fbe377ac505359f8828e9 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Fri, 14 Apr 2023 07:45:49 +0200 Subject: [PATCH 4/6] autotools: Make all "pregenerated" targets .PHONY This follows the automake conventions more, see: https://www.gnu.org/software/automake/manual/html_node/Clean.html --- Makefile.am | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index f745013c933fc..6e2aa7fe01b7f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,3 @@ -.PHONY: clean-precomp precomp - ACLOCAL_AMFLAGS = -I build-aux/m4 # AM_CFLAGS will be automatically prepended to CFLAGS by Automake when compiling some foo @@ -218,10 +216,10 @@ precomp: $(PRECOMP) # e.g., after `make maintainer-clean`). BUILT_SOURCES = $(PRECOMP) -maintainer-clean-local: clean-precomp - +.PHONY: clean-precomp clean-precomp: rm -f $(PRECOMP) +maintainer-clean-local: clean-precomp ### Pregenerated test vectors ### (see the comments in the previous section for detailed rationale) @@ -234,10 +232,10 @@ testvectors: $(TESTVECTORS) BUILT_SOURCES += $(TESTVECTORS) -maintainer-clean-local: clean-testvectors - +.PHONY: clean-testvectors clean-testvectors: rm -f $(TESTVECTORS) +maintainer-clean-local: clean-testvectors ### Additional files to distribute EXTRA_DIST = autogen.sh CHANGELOG.md SECURITY.md From 2418d3260ac51ba0f148fb20e19c8f41bba8a135 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Fri, 14 Apr 2023 07:54:24 +0200 Subject: [PATCH 5/6] autotools: Create src/wycheproof dir before creating file in it This directory may not exist in a VPATH build, see https://github.com/bitcoin/bitcoin/pull/27445#issuecomment-1502994264 . --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 6e2aa7fe01b7f..047b2f2178368 100644 --- a/Makefile.am +++ b/Makefile.am @@ -226,6 +226,7 @@ maintainer-clean-local: clean-precomp TESTVECTORS = src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h: + mkdir -p $(@D) python3 tools/tests_wycheproof_generate.py src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json > $@ testvectors: $(TESTVECTORS) From 7e977b3c5071fc17575ff88ebbc9db7b17c70497 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Tue, 25 Apr 2023 11:44:25 +0100 Subject: [PATCH 6/6] autotools: Take VPATH builds into account when generating testvectors --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 047b2f2178368..29b8a69cfba1b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -227,7 +227,7 @@ TESTVECTORS = src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h: mkdir -p $(@D) - python3 tools/tests_wycheproof_generate.py src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json > $@ + python3 $(top_srcdir)/tools/tests_wycheproof_generate.py $(top_srcdir)/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json > $@ testvectors: $(TESTVECTORS)