Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 49e2686

Browse files
committedApr 5, 2024
Squashed 'src/secp256k1/' changes from efe85c70a2..0ced4b26ef
0ced4b26ef ci: enable silentpayments module 6acaa0f546 tests: add BIP-352 test vectors 7ef44c148a silentpayments: add routine for tx output scanning (for receiver) 6dc5d6a20f silentpayments: add routine for creating labelled spend pubkeys (for addresses) e8bcabf3c3 silentpayments: add label tweak calculation routine ce450075fe silentpayments: add public tweak data creation routine cb30aabcee silentpayments: add sender routine 601c4b30e1 silentpayments: implement output pubkey creation 90d2faf2a3 silentpayments: add shared secret creation routine 298c2c2b91 silentpayments: add sortable recipient struct 7866b0e961 doc: add module description for secp256k1-silentpayments 022bb60db9 build: add skeleton for new silentpayments (BIP352) module afdeabf8d9 add secp256k1_ec_pubkey_sort 0653a25d50 Merge bitcoin-core/secp256k1#1486: ci: Update cache action 94a14d5290 ci: Update cache action 2483627299 Merge bitcoin-core/secp256k1#1483: cmake: Recommend native CMake commands in README 5ad3aa3dcd Merge bitcoin-core/secp256k1#1484: tests: Drop redundant _scalar_check_overflow calls 51df2d9ab3 tests: Drop redundant _scalar_check_overflow calls 3777e3f36a cmake: Recommend native CMake commands in README e4af41c61b Merge bitcoin-core/secp256k1#1249: cmake: Add `SECP256K1_LATE_CFLAGS` configure option 3bf4d68fc0 Merge bitcoin-core/secp256k1#1482: build: Clean up handling of module dependencies e6822678ea build: Error if required module explicitly off 89ec583ccf build: Clean up handling of module dependencies 44378867a0 Merge bitcoin-core/secp256k1#1468: v0.4.1 release aftermath a9db9f2d75 Merge bitcoin-core/secp256k1#1480: Get rid of untested sizeof(secp256k1_ge_storage) == 64 code path 74b7c3b53e Merge bitcoin-core/secp256k1#1476: include: make docs more consistent b37fdb28ce check-abi: Minor UI improvements ad5f589a94 check-abi: Default to HEAD for new version 9fb7e2f156 release process: Style and formatting nits ba5d72d626 assumptions: Use new STATIC_ASSERT macro e53c2d9ffc Require that sizeof(secp256k1_ge_storage) == 64 d0ba2abbff util: Add STATIC_ASSERT macro da7bc1b803 include: in doc, remove article in front of "pointer" aa3dd5280b include: make doc about ctx more consistent e3f690015a include: remove obvious "cannot be NULL" doc d373bf6d08 Merge bitcoin-core/secp256k1#1474: tests: restore scalar_mul test 79e094517c Merge bitcoin-core/secp256k1#1473: Fix typos 3dbfb48946 tests: restore scalar_mul test d77170a88d Fix typos e7053d065b release process: Add email step 429d21dc79 release process: Run sanity checks on release PR 42f8c51402 cmake: Add `SECP256K1_LATE_CFLAGS` configure option git-subtree-dir: src/secp256k1 git-subtree-split: 0ced4b26efef88f2a926fe83cbbfc768104d44c1
1 parent 29fde02 commit 49e2686

36 files changed

+5897
-228
lines changed
 

‎.cirrus.yml

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ env:
2222
RECOVERY: no
2323
SCHNORRSIG: no
2424
ELLSWIFT: no
25+
SILENTPAYMENTS: no
2526
### test options
2627
SECP256K1_TEST_ITERS:
2728
BENCH: yes
@@ -68,6 +69,7 @@ task:
6869
RECOVERY: yes
6970
SCHNORRSIG: yes
7071
ELLSWIFT: yes
72+
SILENTPAYMENTS: yes
7173
matrix:
7274
# Currently only gcc-snapshot, the other compilers are tested on GHA with QEMU
7375
- env: { CC: 'gcc-snapshot' }
@@ -84,6 +86,7 @@ task:
8486
RECOVERY: yes
8587
SCHNORRSIG: yes
8688
ELLSWIFT: yes
89+
SILENTPAYMENTS: yes
8790
WRAPPER_CMD: 'valgrind --error-exitcode=42'
8891
SECP256K1_TEST_ITERS: 2
8992
matrix:

‎.github/actions/install-homebrew-valgrind/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ runs:
1616
cat valgrind_fingerprint
1717
shell: bash
1818
19-
- uses: actions/cache@v3
19+
- uses: actions/cache@v4
2020
id: cache
2121
with:
2222
path: ${{ env.CI_HOMEBREW_CELLAR_VALGRIND }}

‎.github/workflows/ci.yml

+21-10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ env:
3333
RECOVERY: 'no'
3434
SCHNORRSIG: 'no'
3535
ELLSWIFT: 'no'
36+
SILENTPAYMENTS: 'no'
3637
### test options
3738
SECP256K1_TEST_ITERS:
3839
BENCH: 'yes'
@@ -71,18 +72,18 @@ jobs:
7172
matrix:
7273
configuration:
7374
- env_vars: { WIDEMUL: 'int64', RECOVERY: 'yes' }
74-
- env_vars: { WIDEMUL: 'int64', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
75+
- env_vars: { WIDEMUL: 'int64', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes' }
7576
- env_vars: { WIDEMUL: 'int128' }
7677
- env_vars: { WIDEMUL: 'int128_struct', ELLSWIFT: 'yes' }
7778
- env_vars: { WIDEMUL: 'int128', RECOVERY: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
78-
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes' }
79+
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', SILENTPAYMENTS: 'yes' }
7980
- env_vars: { WIDEMUL: 'int128', ASM: 'x86_64', ELLSWIFT: 'yes' }
8081
- env_vars: { RECOVERY: 'yes', SCHNORRSIG: 'yes' }
81-
- env_vars: { CTIMETESTS: 'no', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', CPPFLAGS: '-DVERIFY' }
82+
- env_vars: { CTIMETESTS: 'no', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', SILENTPAYMENTS: 'yes', CPPFLAGS: '-DVERIFY' }
8283
- env_vars: { BUILD: 'distcheck', WITH_VALGRIND: 'no', CTIMETESTS: 'no', BENCH: 'no' }
8384
- env_vars: { CPPFLAGS: '-DDETERMINISTIC' }
8485
- env_vars: { CFLAGS: '-O0', CTIMETESTS: 'no' }
85-
- env_vars: { CFLAGS: '-O1', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
86+
- env_vars: { CFLAGS: '-O1', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes' }
8687
- env_vars: { ECMULTGENPRECISION: 2, ECMULTWINDOW: 2 }
8788
- env_vars: { ECMULTGENPRECISION: 8, ECMULTWINDOW: 4 }
8889
cc:
@@ -141,6 +142,7 @@ jobs:
141142
RECOVERY: 'yes'
142143
SCHNORRSIG: 'yes'
143144
ELLSWIFT: 'yes'
145+
SILENTPAYMENTS: 'yes'
144146
CC: ${{ matrix.cc }}
145147

146148
steps:
@@ -185,6 +187,7 @@ jobs:
185187
RECOVERY: 'yes'
186188
SCHNORRSIG: 'yes'
187189
ELLSWIFT: 'yes'
190+
SILENTPAYMENTS: 'yes'
188191
CTIMETESTS: 'no'
189192

190193
steps:
@@ -236,6 +239,7 @@ jobs:
236239
RECOVERY: 'yes'
237240
SCHNORRSIG: 'yes'
238241
ELLSWIFT: 'yes'
242+
SILENTPAYMENTS: 'yes'
239243
CTIMETESTS: 'no'
240244

241245
steps:
@@ -281,6 +285,7 @@ jobs:
281285
RECOVERY: 'yes'
282286
SCHNORRSIG: 'yes'
283287
ELLSWIFT: 'yes'
288+
SILENTPAYMENTS: 'yes'
284289
CTIMETESTS: 'no'
285290

286291
strategy:
@@ -336,6 +341,7 @@ jobs:
336341
RECOVERY: 'yes'
337342
SCHNORRSIG: 'yes'
338343
ELLSWIFT: 'yes'
344+
SILENTPAYMENTS: 'yes'
339345
CTIMETESTS: 'no'
340346

341347
steps:
@@ -388,6 +394,7 @@ jobs:
388394
RECOVERY: 'yes'
389395
SCHNORRSIG: 'yes'
390396
ELLSWIFT: 'yes'
397+
SILENTPAYMENTS: 'yes'
391398
CTIMETESTS: 'no'
392399
SECP256K1_TEST_ITERS: 2
393400

@@ -439,6 +446,7 @@ jobs:
439446
RECOVERY: 'yes'
440447
SCHNORRSIG: 'yes'
441448
ELLSWIFT: 'yes'
449+
SILENTPAYMENTS: 'yes'
442450
CTIMETESTS: 'no'
443451
CFLAGS: '-fsanitize=undefined,address -g'
444452
UBSAN_OPTIONS: 'print_stacktrace=1:halt_on_error=1'
@@ -496,6 +504,7 @@ jobs:
496504
RECOVERY: 'yes'
497505
SCHNORRSIG: 'yes'
498506
ELLSWIFT: 'yes'
507+
SILENTPAYMENTS: 'yes'
499508
CTIMETESTS: 'yes'
500509
CC: 'clang'
501510
SECP256K1_TEST_ITERS: 32
@@ -543,6 +552,7 @@ jobs:
543552
RECOVERY: 'yes'
544553
SCHNORRSIG: 'yes'
545554
ELLSWIFT: 'yes'
555+
SILENTPAYMENTS: 'yes'
546556
CTIMETESTS: 'no'
547557

548558
strategy:
@@ -599,14 +609,14 @@ jobs:
599609
fail-fast: false
600610
matrix:
601611
env_vars:
602-
- { WIDEMUL: 'int64', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
612+
- { WIDEMUL: 'int64', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes' }
603613
- { WIDEMUL: 'int128_struct', ECMULTGENPRECISION: 2, ECMULTWINDOW: 4 }
604-
- { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
614+
- { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes' }
605615
- { WIDEMUL: 'int128', RECOVERY: 'yes' }
606-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
607-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc' }
608-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
609-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
616+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes' }
617+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes', CC: 'gcc' }
618+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
619+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes', CC: 'gcc', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
610620
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CPPFLAGS: '-DVERIFY', CTIMETESTS: 'no' }
611621
- BUILD: 'distcheck'
612622

@@ -718,6 +728,7 @@ jobs:
718728
RECOVERY: 'yes'
719729
SCHNORRSIG: 'yes'
720730
ELLSWIFT: 'yes'
731+
SILENTPAYMENTS: 'yes'
721732

722733
steps:
723734
- name: Checkout

‎CMakeLists.txt

+35-10
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,45 @@ endif()
5151

5252
option(SECP256K1_INSTALL "Enable installation." ${PROJECT_IS_TOP_LEVEL})
5353

54+
## Modules
55+
56+
# We declare all options before processing them, to make sure we can express
57+
# dependendencies while processing.
5458
option(SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON)
55-
if(SECP256K1_ENABLE_MODULE_ECDH)
56-
add_compile_definitions(ENABLE_MODULE_ECDH=1)
59+
option(SECP256K1_ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." OFF)
60+
option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON)
61+
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON)
62+
option(SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON)
63+
option(SECP256K1_ENABLE_MODULE_SILENTPAYMENTS "Enable Silent Payments module." OFF)
64+
65+
# Processing must be done in a topological sorting of the dependency graph
66+
# (dependent module first).
67+
if(SECP256K1_ENABLE_MODULE_SILENTPAYMENTS)
68+
add_compile_definitions(ENABLE_MODULE_SILENTPAYMENTS=1)
5769
endif()
5870

59-
option(SECP256K1_ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." OFF)
60-
if(SECP256K1_ENABLE_MODULE_RECOVERY)
61-
add_compile_definitions(ENABLE_MODULE_RECOVERY=1)
71+
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
72+
add_compile_definitions(ENABLE_MODULE_ELLSWIFT=1)
6273
endif()
6374

64-
option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON)
65-
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON)
6675
if(SECP256K1_ENABLE_MODULE_SCHNORRSIG)
76+
if(DEFINED SECP256K1_ENABLE_MODULE_EXTRAKEYS AND NOT SECP256K1_ENABLE_MODULE_EXTRAKEYS)
77+
message(FATAL_ERROR "Module dependency error: You have disabled the extrakeys module explicitly, but it is required by the schnorrsig module.")
78+
endif()
6779
set(SECP256K1_ENABLE_MODULE_EXTRAKEYS ON)
6880
add_compile_definitions(ENABLE_MODULE_SCHNORRSIG=1)
6981
endif()
82+
7083
if(SECP256K1_ENABLE_MODULE_EXTRAKEYS)
7184
add_compile_definitions(ENABLE_MODULE_EXTRAKEYS=1)
7285
endif()
7386

74-
option(SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON)
75-
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
76-
add_compile_definitions(ENABLE_MODULE_ELLSWIFT=1)
87+
if(SECP256K1_ENABLE_MODULE_RECOVERY)
88+
add_compile_definitions(ENABLE_MODULE_RECOVERY=1)
89+
endif()
90+
91+
if(SECP256K1_ENABLE_MODULE_ECDH)
92+
add_compile_definitions(ENABLE_MODULE_ECDH=1)
7793
endif()
7894

7995
option(SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS "Enable external default callback functions." OFF)
@@ -254,9 +270,14 @@ if(SECP256K1_BUILD_BENCHMARK OR SECP256K1_BUILD_TESTS OR SECP256K1_BUILD_EXHAUST
254270
enable_testing()
255271
endif()
256272

273+
set(SECP256K1_LATE_CFLAGS "" CACHE STRING "Compiler flags that are added to the command line after all other flags added by the build system.")
274+
include(AllTargetsCompileOptions)
275+
257276
add_subdirectory(src)
277+
all_targets_compile_options(src "${SECP256K1_LATE_CFLAGS}")
258278
if(SECP256K1_BUILD_EXAMPLES)
259279
add_subdirectory(examples)
280+
all_targets_compile_options(examples "${SECP256K1_LATE_CFLAGS}")
260281
endif()
261282

262283
message("\n")
@@ -276,6 +297,7 @@ message(" ECDSA pubkey recovery ............... ${SECP256K1_ENABLE_MODULE_RECOV
276297
message(" extrakeys ........................... ${SECP256K1_ENABLE_MODULE_EXTRAKEYS}")
277298
message(" schnorrsig .......................... ${SECP256K1_ENABLE_MODULE_SCHNORRSIG}")
278299
message(" ElligatorSwift ...................... ${SECP256K1_ENABLE_MODULE_ELLSWIFT}")
300+
message(" Silent Payments ..................... ${SECP256K1_ENABLE_MODULE_SILENTPAYMENTS}")
279301
message("Parameters:")
280302
message(" ecmult window size .................. ${SECP256K1_ECMULT_WINDOW_SIZE}")
281303
message(" ecmult gen precision bits ........... ${SECP256K1_ECMULT_GEN_PREC_BITS}")
@@ -330,6 +352,9 @@ else()
330352
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
331353
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
332354
endif()
355+
if(SECP256K1_LATE_CFLAGS)
356+
message("SECP256K1_LATE_CFLAGS ................. ${SECP256K1_LATE_CFLAGS}")
357+
endif()
333358
message("\n")
334359
if(SECP256K1_EXPERIMENTAL)
335360
message(

‎CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The Contributor Workflow & Peer Review in libsecp256k1 are similar to Bitcoin Co
4444

4545
In addition, libsecp256k1 tries to maintain the following coding conventions:
4646

47-
* No runtime heap allocation (e.g., no `malloc`) unless explicitly requested by the caller (via `secp256k1_context_create` or `secp256k1_scratch_space_create`, for example). Morever, it should be possible to use the library without any heap allocations.
47+
* No runtime heap allocation (e.g., no `malloc`) unless explicitly requested by the caller (via `secp256k1_context_create` or `secp256k1_scratch_space_create`, for example). Moreover, it should be possible to use the library without any heap allocations.
4848
* The tests should cover all lines and branches of the library (see [Test coverage](#coverage)).
4949
* Operations involving secret data should be tested for being constant time with respect to the secrets (see [src/ctime_tests.c](src/ctime_tests.c)).
5050
* Local variables containing secret data should be cleared explicitly to try to delete secrets from memory.

‎Makefile.am

+6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ noinst_HEADERS += src/field.h
6464
noinst_HEADERS += src/field_impl.h
6565
noinst_HEADERS += src/bench.h
6666
noinst_HEADERS += src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h
67+
noinst_HEADERS += src/hsort.h
68+
noinst_HEADERS += src/hsort_impl.h
6769
noinst_HEADERS += contrib/lax_der_parsing.h
6870
noinst_HEADERS += contrib/lax_der_parsing.c
6971
noinst_HEADERS += contrib/lax_der_privatekey_parsing.h
@@ -271,3 +273,7 @@ endif
271273
if ENABLE_MODULE_ELLSWIFT
272274
include src/modules/ellswift/Makefile.am.include
273275
endif
276+
277+
if ENABLE_MODULE_SILENTPAYMENTS
278+
include src/modules/silentpayments/Makefile.am.include
279+
endif

‎README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ To maintain a pristine source tree, CMake encourages to perform an out-of-source
7979

8080
$ mkdir build && cd build
8181
$ cmake ..
82-
$ make
83-
$ make check # run the test suite
84-
$ sudo make install # optional
82+
$ cmake --build .
83+
$ ctest # run the test suite
84+
$ sudo cmake --build . --target install # optional
8585

8686
To compile optional modules (such as Schnorr signatures), you need to run `cmake` with additional flags (such as `-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON`). Run `cmake .. -LH` to see the full list of available flags.
8787

‎ci/ci.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ print_environment() {
1313
# does not rely on bash.
1414
for var in WERROR_CFLAGS MAKEFLAGS BUILD \
1515
ECMULTWINDOW ECMULTGENPRECISION ASM WIDEMUL WITH_VALGRIND EXTRAFLAGS \
16-
EXPERIMENTAL ECDH RECOVERY SCHNORRSIG ELLSWIFT \
16+
EXPERIMENTAL ECDH RECOVERY SCHNORRSIG ELLSWIFT SILENTPAYMENTS \
1717
SECP256K1_TEST_ITERS BENCH SECP256K1_BENCH_ITERS CTIMETESTS\
1818
EXAMPLES \
1919
HOST WRAPPER_CMD \
@@ -76,6 +76,7 @@ esac
7676
--with-ecmult-gen-precision="$ECMULTGENPRECISION" \
7777
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
7878
--enable-module-ellswift="$ELLSWIFT" \
79+
--enable-module-silentpayments="$SILENTPAYMENTS" \
7980
--enable-module-schnorrsig="$SCHNORRSIG" \
8081
--enable-examples="$EXAMPLES" \
8182
--enable-ctime-tests="$CTIMETESTS" \

‎cmake/AllTargetsCompileOptions.cmake

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Add compile options to all targets added in the subdirectory.
2+
function(all_targets_compile_options dir options)
3+
get_directory_property(targets DIRECTORY ${dir} BUILDSYSTEM_TARGETS)
4+
separate_arguments(options)
5+
set(compiled_target_types STATIC_LIBRARY SHARED_LIBRARY OBJECT_LIBRARY EXECUTABLE)
6+
foreach(target ${targets})
7+
get_target_property(type ${target} TYPE)
8+
if(type IN_LIST compiled_target_types)
9+
target_compile_options(${target} PRIVATE ${options})
10+
endif()
11+
endforeach()
12+
endfunction()

‎configure.ac

+24-11
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ AC_ARG_ENABLE(module_ellswift,
188188
AS_HELP_STRING([--enable-module-ellswift],[enable ElligatorSwift module [default=yes]]), [],
189189
[SECP_SET_DEFAULT([enable_module_ellswift], [yes], [yes])])
190190

191+
AC_ARG_ENABLE(module_silentpayments,
192+
AS_HELP_STRING([--enable-module-silentpayments],[enable Silent Payments module [default=no]]), [],
193+
[SECP_SET_DEFAULT([enable_module_silentpayments], [no], [yes])])
194+
191195
AC_ARG_ENABLE(external_default_callbacks,
192196
AS_HELP_STRING([--enable-external-default-callbacks],[enable external default callback functions [default=no]]), [],
193197
[SECP_SET_DEFAULT([enable_external_default_callbacks], [no], [no])])
@@ -387,29 +391,36 @@ SECP_CFLAGS="$SECP_CFLAGS $WERROR_CFLAGS"
387391
### Handle module options
388392
###
389393

390-
if test x"$enable_module_ecdh" = x"yes"; then
391-
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_ECDH=1"
394+
# Processing must be done in a reverse topological sorting of the dependency graph
395+
# (dependent module first).
396+
if test x"$enable_module_silentpayments" = x"yes"; then
397+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_SILENTPAYMENTS=1"
392398
fi
393399

394-
if test x"$enable_module_recovery" = x"yes"; then
395-
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_RECOVERY=1"
400+
if test x"$enable_module_ellswift" = x"yes"; then
401+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_ELLSWIFT=1"
396402
fi
397403

398404
if test x"$enable_module_schnorrsig" = x"yes"; then
399-
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_SCHNORRSIG=1"
405+
if test x"$enable_module_extrakeys" = x"no"; then
406+
AC_MSG_ERROR([Module dependency error: You have disabled the extrakeys module explicitly, but it is required by the schnorrsig module.])
407+
fi
400408
enable_module_extrakeys=yes
409+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_SCHNORRSIG=1"
401410
fi
402411

403-
if test x"$enable_module_ellswift" = x"yes"; then
404-
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_ELLSWIFT=1"
405-
fi
406-
407-
# Test if extrakeys is set after the schnorrsig module to allow the schnorrsig
408-
# module to set enable_module_extrakeys=yes
409412
if test x"$enable_module_extrakeys" = x"yes"; then
410413
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_EXTRAKEYS=1"
411414
fi
412415

416+
if test x"$enable_module_recovery" = x"yes"; then
417+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_RECOVERY=1"
418+
fi
419+
420+
if test x"$enable_module_ecdh" = x"yes"; then
421+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_ECDH=1"
422+
fi
423+
413424
if test x"$enable_external_default_callbacks" = x"yes"; then
414425
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DUSE_EXTERNAL_DEFAULT_CALLBACKS=1"
415426
fi
@@ -447,6 +458,7 @@ AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"ye
447458
AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"yes"])
448459
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
449460
AM_CONDITIONAL([ENABLE_MODULE_ELLSWIFT], [test x"$enable_module_ellswift" = x"yes"])
461+
AM_CONDITIONAL([ENABLE_MODULE_SILENTPAYMENTS], [test x"$enable_module_silentpayments" = x"yes"])
450462
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$enable_external_asm" = x"yes"])
451463
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm32"])
452464
AM_CONDITIONAL([BUILD_WINDOWS], [test "$build_windows" = "yes"])
@@ -469,6 +481,7 @@ echo " module recovery = $enable_module_recovery"
469481
echo " module extrakeys = $enable_module_extrakeys"
470482
echo " module schnorrsig = $enable_module_schnorrsig"
471483
echo " module ellswift = $enable_module_ellswift"
484+
echo " module silentpayments = $enable_module_silentpayments"
472485
echo
473486
echo " asm = $set_asm"
474487
echo " ecmult window size = $set_ecmult_window"

0 commit comments

Comments
 (0)
Please sign in to comment.