Skip to content

Commit b525369

Browse files
committed
Squashed 'src/secp256k1/' changes from efe85c70a2e..093af5dc48e
093af5dc48e Merge 3b6c90a93fb55b2ea5fc629762bf4c3c569211cf into 05bfab69aef3622f77f754cfb01220108a109c91 05bfab69aef Merge bitcoin-core/secp256k1#1507: ci: Add workaround for ASLR bug in sanitizers a5e8ab24844 ci: Add sanitizer env variables to debug output 84a93de4d2b ci: Add workaround for ASLR bug in sanitizers 3b6c90a93fb fixup! improve nonce_gen doc 2512e4b9431 fixup! add musig module to change log 35dd4304c20 fixup! Add pubkey_sort to changelog 461970682f5 fixup! split counter mode from musig_nonce_gen dfd9849a193 fixup! rename pubkey_sort -> ec_pubkey_sort d3a8952d5e3 fixup! move extrakeys to main 468c5c41e4a fixup! move musig_ge_{to,from} to group.h 2a0d934540e fixup! use optimized tagged hashes 427e86b9edc Merge bitcoin-core/secp256k1#1490: tests: improve fe_sqr test (issue bitcoin#1472) 2028069df2e doc: clarify input requirements for secp256k1_fe_mul 11420a7a283 tests: improve fe_sqr test cdc9a6258e9 Merge bitcoin-core/secp256k1#1489: tests: add missing fe comparison checks for inverse field test cases d926510cf76 Merge bitcoin-core/secp256k1#1496: msan: notate variable assignments from assembly code 31ba4049442 msan: notate variable assignments from assembly code e7ea32e30a9 msan: Add SECP256K1_CHECKMEM_MSAN_DEFINE which applies to memory sanitizer and not valgrind e7bdddd9c9c refactor: rename `check_fe_equal` -> `fe_equal` 00111c9c563 tests: add missing fe comparison checks for inverse field test cases 0653a25d50f Merge bitcoin-core/secp256k1#1486: ci: Update cache action 94a14d5290e ci: Update cache action 24836272992 Merge bitcoin-core/secp256k1#1483: cmake: Recommend native CMake commands in README 5ad3aa3dcd2 Merge bitcoin-core/secp256k1#1484: tests: Drop redundant _scalar_check_overflow calls dd4932b67b5 build: allow enabling the musig module in cmake 6e104fbdbb0 Add module "musig" that implements MuSig2 multi-signatures (BIP 327) 0c7ca2732d8 group: add ge_to_bytes and ge_from_bytes 26dde295d0a extrakeys: add secp256k1_pubkey_sort 51df2d9ab3a tests: Drop redundant _scalar_check_overflow calls 3777e3f36a6 cmake: Recommend native CMake commands in README e4af41c61b0 Merge bitcoin-core/secp256k1#1249: cmake: Add `SECP256K1_LATE_CFLAGS` configure option 3bf4d68fc00 Merge bitcoin-core/secp256k1#1482: build: Clean up handling of module dependencies e6822678ea0 build: Error if required module explicitly off 89ec583ccf0 build: Clean up handling of module dependencies 44378867a01 Merge bitcoin-core/secp256k1#1468: v0.4.1 release aftermath a9db9f2d75a Merge bitcoin-core/secp256k1#1480: Get rid of untested sizeof(secp256k1_ge_storage) == 64 code path 74b7c3b53e1 Merge bitcoin-core/secp256k1#1476: include: make docs more consistent b37fdb28ce3 check-abi: Minor UI improvements ad5f589a94c check-abi: Default to HEAD for new version 9fb7e2f1568 release process: Style and formatting nits ba5d72d6265 assumptions: Use new STATIC_ASSERT macro e53c2d9ffc0 Require that sizeof(secp256k1_ge_storage) == 64 d0ba2abbff2 util: Add STATIC_ASSERT macro da7bc1b803b include: in doc, remove article in front of "pointer" aa3dd5280b4 include: make doc about ctx more consistent e3f690015a2 include: remove obvious "cannot be NULL" doc d373bf6d08c Merge bitcoin-core/secp256k1#1474: tests: restore scalar_mul test 79e094517c9 Merge bitcoin-core/secp256k1#1473: Fix typos 3dbfb48946b tests: restore scalar_mul test d77170a88d0 Fix typos e7053d065b9 release process: Add email step 429d21dc79e release process: Run sanity checks on release PR 42f8c514022 cmake: Add `SECP256K1_LATE_CFLAGS` configure option git-subtree-dir: src/secp256k1 git-subtree-split: 093af5dc48e57e31b5f451ef0b483d7605e6817c
1 parent 29fde02 commit b525369

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5062
-262
lines changed

.cirrus.yml

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ env:
2121
ECDH: no
2222
RECOVERY: no
2323
SCHNORRSIG: no
24+
MUSIG: no
2425
ELLSWIFT: no
2526
### test options
2627
SECP256K1_TEST_ITERS:
@@ -67,6 +68,7 @@ task:
6768
ECDH: yes
6869
RECOVERY: yes
6970
SCHNORRSIG: yes
71+
MUSIG: yes
7072
ELLSWIFT: yes
7173
matrix:
7274
# Currently only gcc-snapshot, the other compilers are tested on GHA with QEMU
@@ -83,6 +85,7 @@ task:
8385
ECDH: yes
8486
RECOVERY: yes
8587
SCHNORRSIG: yes
88+
MUSIG: yes
8689
ELLSWIFT: yes
8790
WRAPPER_CMD: 'valgrind --error-exitcode=42'
8891
SECP256K1_TEST_ITERS: 2

.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/actions/run-in-docker-action/action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ runs:
3636
load: true
3737
cache-from: type=gha
3838

39+
- # Workaround for https://github.com/google/sanitizers/issues/1614 .
40+
run: sudo sysctl -w vm.mmap_rnd_bits=28
41+
shell: bash
42+
3943
- # Tell Docker to pass environment variables in `env` into the container.
4044
run: >
4145
docker run \

.github/workflows/ci.yml

+24-13
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ env:
3232
ECDH: 'no'
3333
RECOVERY: 'no'
3434
SCHNORRSIG: 'no'
35+
MUSIG: 'no'
3536
ELLSWIFT: 'no'
3637
### test options
3738
SECP256K1_TEST_ITERS:
@@ -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', MUSIG: 'yes', ELLSWIFT: 'yes' }
7576
- env_vars: { WIDEMUL: 'int128' }
76-
- env_vars: { WIDEMUL: 'int128_struct', ELLSWIFT: 'yes' }
77-
- env_vars: { WIDEMUL: 'int128', RECOVERY: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
78-
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes' }
79-
- env_vars: { WIDEMUL: 'int128', ASM: 'x86_64', ELLSWIFT: 'yes' }
77+
- env_vars: { WIDEMUL: 'int128_struct', ELLSWIFT: 'yes' }
78+
- env_vars: { WIDEMUL: 'int128', RECOVERY: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes' }
79+
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes' }
80+
- env_vars: { WIDEMUL: 'int128', ASM: 'x86_64', ELLSWIFT: 'yes' }
8081
- env_vars: { RECOVERY: 'yes', SCHNORRSIG: 'yes' }
8182
- env_vars: { CTIMETESTS: 'no', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: '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', MUSIG: 'yes', ELLSWIFT: 'yes' }
8687
- env_vars: { ECMULTGENPRECISION: 2, ECMULTWINDOW: 2 }
8788
- env_vars: { ECMULTGENPRECISION: 8, ECMULTWINDOW: 4 }
8889
cc:
@@ -140,6 +141,7 @@ jobs:
140141
ECDH: 'yes'
141142
RECOVERY: 'yes'
142143
SCHNORRSIG: 'yes'
144+
MUSIG: 'yes'
143145
ELLSWIFT: 'yes'
144146
CC: ${{ matrix.cc }}
145147

@@ -184,6 +186,7 @@ jobs:
184186
ECDH: 'yes'
185187
RECOVERY: 'yes'
186188
SCHNORRSIG: 'yes'
189+
MUSIG: 'yes'
187190
ELLSWIFT: 'yes'
188191
CTIMETESTS: 'no'
189192

@@ -235,6 +238,7 @@ jobs:
235238
ECDH: 'yes'
236239
RECOVERY: 'yes'
237240
SCHNORRSIG: 'yes'
241+
MUSIG: 'yes'
238242
ELLSWIFT: 'yes'
239243
CTIMETESTS: 'no'
240244

@@ -280,6 +284,7 @@ jobs:
280284
ECDH: 'yes'
281285
RECOVERY: 'yes'
282286
SCHNORRSIG: 'yes'
287+
MUSIG: 'yes'
283288
ELLSWIFT: 'yes'
284289
CTIMETESTS: 'no'
285290

@@ -335,6 +340,7 @@ jobs:
335340
ECDH: 'yes'
336341
RECOVERY: 'yes'
337342
SCHNORRSIG: 'yes'
343+
MUSIG: 'yes'
338344
ELLSWIFT: 'yes'
339345
CTIMETESTS: 'no'
340346

@@ -387,6 +393,7 @@ jobs:
387393
ECDH: 'yes'
388394
RECOVERY: 'yes'
389395
SCHNORRSIG: 'yes'
396+
MUSIG: 'yes'
390397
ELLSWIFT: 'yes'
391398
CTIMETESTS: 'no'
392399
SECP256K1_TEST_ITERS: 2
@@ -438,6 +445,7 @@ jobs:
438445
ECDH: 'yes'
439446
RECOVERY: 'yes'
440447
SCHNORRSIG: 'yes'
448+
MUSIG: 'yes'
441449
ELLSWIFT: 'yes'
442450
CTIMETESTS: 'no'
443451
CFLAGS: '-fsanitize=undefined,address -g'
@@ -495,6 +503,7 @@ jobs:
495503
ECDH: 'yes'
496504
RECOVERY: 'yes'
497505
SCHNORRSIG: 'yes'
506+
MUSIG: 'yes'
498507
ELLSWIFT: 'yes'
499508
CTIMETESTS: 'yes'
500509
CC: 'clang'
@@ -542,6 +551,7 @@ jobs:
542551
ECDH: 'yes'
543552
RECOVERY: 'yes'
544553
SCHNORRSIG: 'yes'
554+
MUSIG: 'yes'
545555
ELLSWIFT: 'yes'
546556
CTIMETESTS: 'no'
547557

@@ -599,15 +609,15 @@ 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', MUSIG: 'yes', ELLSWIFT: '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', MUSIG: 'yes', ELLSWIFT: '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 }
610-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CPPFLAGS: '-DVERIFY', CTIMETESTS: 'no' }
616+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes' }
617+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc' }
618+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
619+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
620+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes', CPPFLAGS: '-DVERIFY', CTIMETESTS: 'no' }
611621
- BUILD: 'distcheck'
612622

613623
steps:
@@ -717,6 +727,7 @@ jobs:
717727
ECDH: 'yes'
718728
RECOVERY: 'yes'
719729
SCHNORRSIG: 'yes'
730+
MUSIG: 'yes'
720731
ELLSWIFT: 'yes'
721732

722733
steps:

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
#### Added
11+
- New module `musig` implements the MuSig2 multisignature scheme according to the [BIP 327 specification](https://github.com/bitcoin/bips/blob/master/bip-0327.mediawiki). See:
12+
- Header file `include/secp256k1_musig.h` which defines the new API.
13+
- Document `doc/musig.md` for further notes on API usage.
14+
- Usage example `examples/musig.c`.
15+
- Added `secp256k1_ec_pubkey_sort` which sorts an array of public keys (see `include/secp256k1.h`).
16+
1017
## [0.4.1] - 2023-12-21
1118

1219
#### Changed

CMakeLists.txt

+39-10
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,49 @@ 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_MUSIG "Enable musig module." ON)
63+
option(SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON)
64+
65+
# Processing must be done in a topological sorting of the dependency graph
66+
# (dependent module first).
67+
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
68+
add_compile_definitions(ENABLE_MODULE_ELLSWIFT=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_MUSIG)
72+
if(DEFINED SECP256K1_ENABLE_MODULE_SCHNORRSIG AND NOT SECP256K1_ENABLE_MODULE_SCHNORRSIG)
73+
message(FATAL_ERROR "Module dependency error: You have disabled the schnorrsig module explicitly, but it is required by the musig module.")
74+
endif()
75+
set(SECP256K1_ENABLE_MODULE_SCHNORRSIG ON)
76+
add_compile_definitions(ENABLE_MODULE_MUSIG=1)
6277
endif()
6378

64-
option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON)
65-
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON)
6679
if(SECP256K1_ENABLE_MODULE_SCHNORRSIG)
80+
if(DEFINED SECP256K1_ENABLE_MODULE_EXTRAKEYS AND NOT SECP256K1_ENABLE_MODULE_EXTRAKEYS)
81+
message(FATAL_ERROR "Module dependency error: You have disabled the extrakeys module explicitly, but it is required by the schnorrsig module.")
82+
endif()
6783
set(SECP256K1_ENABLE_MODULE_EXTRAKEYS ON)
6884
add_compile_definitions(ENABLE_MODULE_SCHNORRSIG=1)
6985
endif()
86+
7087
if(SECP256K1_ENABLE_MODULE_EXTRAKEYS)
7188
add_compile_definitions(ENABLE_MODULE_EXTRAKEYS=1)
7289
endif()
7390

74-
option(SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON)
75-
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
76-
add_compile_definitions(ENABLE_MODULE_ELLSWIFT=1)
91+
if(SECP256K1_ENABLE_MODULE_RECOVERY)
92+
add_compile_definitions(ENABLE_MODULE_RECOVERY=1)
93+
endif()
94+
95+
if(SECP256K1_ENABLE_MODULE_ECDH)
96+
add_compile_definitions(ENABLE_MODULE_ECDH=1)
7797
endif()
7898

7999
option(SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS "Enable external default callback functions." OFF)
@@ -254,9 +274,14 @@ if(SECP256K1_BUILD_BENCHMARK OR SECP256K1_BUILD_TESTS OR SECP256K1_BUILD_EXHAUST
254274
enable_testing()
255275
endif()
256276

277+
set(SECP256K1_LATE_CFLAGS "" CACHE STRING "Compiler flags that are added to the command line after all other flags added by the build system.")
278+
include(AllTargetsCompileOptions)
279+
257280
add_subdirectory(src)
281+
all_targets_compile_options(src "${SECP256K1_LATE_CFLAGS}")
258282
if(SECP256K1_BUILD_EXAMPLES)
259283
add_subdirectory(examples)
284+
all_targets_compile_options(examples "${SECP256K1_LATE_CFLAGS}")
260285
endif()
261286

262287
message("\n")
@@ -275,6 +300,7 @@ message(" ECDH ................................ ${SECP256K1_ENABLE_MODULE_ECDH}
275300
message(" ECDSA pubkey recovery ............... ${SECP256K1_ENABLE_MODULE_RECOVERY}")
276301
message(" extrakeys ........................... ${SECP256K1_ENABLE_MODULE_EXTRAKEYS}")
277302
message(" schnorrsig .......................... ${SECP256K1_ENABLE_MODULE_SCHNORRSIG}")
303+
message(" musig ............................... ${SECP256K1_ENABLE_MODULE_MUSIG}")
278304
message(" ElligatorSwift ...................... ${SECP256K1_ENABLE_MODULE_ELLSWIFT}")
279305
message("Parameters:")
280306
message(" ecmult window size .................. ${SECP256K1_ECMULT_WINDOW_SIZE}")
@@ -330,6 +356,9 @@ else()
330356
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
331357
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
332358
endif()
359+
if(SECP256K1_LATE_CFLAGS)
360+
message("SECP256K1_LATE_CFLAGS ................. ${SECP256K1_LATE_CFLAGS}")
361+
endif()
333362
message("\n")
334363
if(SECP256K1_EXPERIMENTAL)
335364
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

+17
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
@@ -182,6 +184,17 @@ schnorr_example_LDFLAGS += -lbcrypt
182184
endif
183185
TESTS += schnorr_example
184186
endif
187+
if ENABLE_MODULE_MUSIG
188+
noinst_PROGRAMS += musig_example
189+
musig_example_SOURCES = examples/musig.c
190+
musig_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
191+
musig_example_LDADD = libsecp256k1.la
192+
musig_example_LDFLAGS = -static
193+
if BUILD_WINDOWS
194+
musig_example_LDFLAGS += -lbcrypt
195+
endif
196+
TESTS += musig_example
197+
endif
185198
endif
186199

187200
### Precomputed tables
@@ -268,6 +281,10 @@ if ENABLE_MODULE_SCHNORRSIG
268281
include src/modules/schnorrsig/Makefile.am.include
269282
endif
270283

284+
if ENABLE_MODULE_MUSIG
285+
include src/modules/musig/Makefile.am.include
286+
endif
287+
271288
if ENABLE_MODULE_ELLSWIFT
272289
include src/modules/ellswift/Makefile.am.include
273290
endif

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Features:
2020
* Optional module for public key recovery.
2121
* Optional module for ECDH key exchange.
2222
* Optional module for Schnorr signatures according to [BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki).
23+
* Optional module for the MuSig2 multi-signature scheme according to [BIP-327](https://github.com/bitcoin/bips/blob/master/bip-0327.mediawiki).
2324

2425
Implementation details
2526
----------------------
@@ -79,9 +80,9 @@ To maintain a pristine source tree, CMake encourages to perform an out-of-source
7980

8081
$ mkdir build && cd build
8182
$ cmake ..
82-
$ make
83-
$ make check # run the test suite
84-
$ sudo make install # optional
83+
$ cmake --build .
84+
$ ctest # run the test suite
85+
$ sudo cmake --build . --target install # optional
8586

8687
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.
8788

ci/ci.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ 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 MUSIG ELLSWIFT \
1717
SECP256K1_TEST_ITERS BENCH SECP256K1_BENCH_ITERS CTIMETESTS\
1818
EXAMPLES \
1919
HOST WRAPPER_CMD \
20-
CC CFLAGS CPPFLAGS AR NM
20+
CC CFLAGS CPPFLAGS AR NM \
21+
UBSAN_OPTIONS ASAN_OPTIONS LSAN_OPTIONS
2122
do
2223
eval "isset=\${$var+x}"
2324
if [ -n "$isset" ]; then
@@ -77,6 +78,7 @@ esac
7778
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
7879
--enable-module-ellswift="$ELLSWIFT" \
7980
--enable-module-schnorrsig="$SCHNORRSIG" \
81+
--enable-module-musig="$MUSIG" \
8082
--enable-examples="$EXAMPLES" \
8183
--enable-ctime-tests="$CTIMETESTS" \
8284
--with-valgrind="$WITH_VALGRIND" \

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()

0 commit comments

Comments
 (0)