Skip to content

Commit 2d46a89

Browse files
committed
Squashed 'src/secp256k1/' changes from 2f2ccc46954..0cdc758a563
0cdc758a563 Merge bitcoin-core/secp256k1#1631: release: prepare for 0.6.0 39d5dfd542a release: prepare for 0.6.0 df2eceb2790 build: add ellswift.md and musig.md to release tarball a306bb7e903 tools: fix check-abi.sh after cmake out locations were changed 145868a84d2 Do not export `secp256k1_musig_nonce_gen_internal` b161bffb8bf Merge bitcoin-core/secp256k1#1579: Clear sensitive memory without getting optimized out (revival of bitcoin#636) a38d879a1a6 Merge bitcoin-core/secp256k1#1628: Name public API structs 7d48f5ed02e Merge bitcoin-core/secp256k1#1581: test, ci: Lower default iteration count to 16 694342fdb71 Name public API structs 0f73caf7c62 test, ci: Lower default iteration count to 16 9a8db52f4e9 Merge bitcoin-core/secp256k1#1582: cmake, test: Add `secp256k1_` prefix to test names 765ef53335a Clear _gej instances after point multiplication to avoid potential leaks 349e6ab916b Introduce separate _clear functions for hash module 99cc9fd6d01 Don't rely on memset to set signed integers to 0 97c57f42ba8 Implement various _clear() functions with secp256k1_memclear() 9bb368d1466 Use secp256k1_memclear() to clear stack memory instead of memset() e3497bbf001 Separate between clearing memory and setting to zero in tests d79a6ccd43a Separate secp256k1_fe_set_int( . , 0 ) from secp256k1_fe_clear() 1c081262227 Add secp256k1_memclear() for clearing secret data 1464f15c812 Merge bitcoin-core/secp256k1#1625: util: Remove unused (u)int64_t formatting macros 980c08df80a util: Remove unused (u)int64_t formatting macros 9b7c59cbb90 Merge bitcoin-core/secp256k1#1624: ci: Update macOS image 096e3e23f63 ci: Update macOS image e7d384488e8 Don't clear secrets in pippenger implementation 68b55209f1b Merge bitcoin-core/secp256k1#1619: musig: ctimetests: fix _declassify range for generated nonce points f0868a9b3d8 Merge bitcoin-core/secp256k1#1595: build: 45839th attempt to fix symbol visibility on Windows 1fae76f50c0 Merge bitcoin-core/secp256k1#1620: Remove unused scratch space from API 8be3839fb2e Remove unused scratch space from API 57eda3ba300 musig: ctimetests: fix _declassify range for generated nonce points 87384f5c0f2 cmake, test: Add `secp256k1_` prefix to test names e59158b6eb7 Merge bitcoin-core/secp256k1#1553: cmake: Set top-level target output locations 18f9b967c25 Merge bitcoin-core/secp256k1#1616: examples: do not retry generating seckey randomness in musig 5bab8f6d3c4 examples: make key generation doc consistent e8908221a45 examples: do not retry generating seckey randomness in musig 70b6be1834e extrakeys: improve doc of keypair_create (don't suggest retry) 01b5893389e Merge bitcoin-core/secp256k1#1599: bitcoin#1570 improve examples: remove key generation loop cd4f84f3ba8 Improve examples/documentation: remove key generation loops a88aa935063 Merge bitcoin-core/secp256k1#1603: f can never equal -m 3660fe5e2a9 Merge bitcoin-core/secp256k1#1479: Add module "musig" that implements MuSig2 multi-signatures (BIP 327) 168c92011f5 build: allow enabling the musig module in cmake f411841a46b Add module "musig" that implements MuSig2 multi-signatures (BIP 327) 0be79660f38 util: add constant-time is_zero_array function c8fbdb1b972 group: add ge_to_bytes_ext and ge_from_bytes_ext ef7ff03407f f can never equal -m c232486d84e Revert "cmake: Set `ENVIRONMENT` property for examples on Windows" 26e4a7c2146 cmake: Set top-level target output locations 4c57c7a5a95 Merge bitcoin-core/secp256k1#1554: cmake: Clean up testing code 447334cb06d include: Avoid visibility("default") on Windows 472faaa8ee6 Merge bitcoin-core/secp256k1#1604: doc: fix typos in `secp256k1_ecdsa_{recoverable_,}signature` API description 292310fbb24 doc: fix typos in `secp256k1_ecdsa_{recoverable_,}signature` API description 85e224dd97f group: add ge_to_bytes and ge_from_bytes 7c987ec89e6 cmake: Call `enable_testing()` unconditionally 6aa576515ef cmake: Delete `CTest` module git-subtree-dir: src/secp256k1 git-subtree-split: 0cdc758a56360bf58a851fe91085a327ec97685a
1 parent 6115628 commit 2d46a89

Some content is hidden

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

58 files changed

+4749
-297
lines changed

.cirrus.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ env:
2222
RECOVERY: no
2323
EXTRAKEYS: no
2424
SCHNORRSIG: no
25+
MUSIG: no
2526
ELLSWIFT: no
2627
### test options
27-
SECP256K1_TEST_ITERS:
28+
SECP256K1_TEST_ITERS: 64
2829
BENCH: yes
2930
SECP256K1_BENCH_ITERS: 2
3031
CTIMETESTS: yes
@@ -69,6 +70,7 @@ task:
6970
RECOVERY: yes
7071
EXTRAKEYS: yes
7172
SCHNORRSIG: yes
73+
MUSIG: yes
7274
ELLSWIFT: yes
7375
matrix:
7476
# Currently only gcc-snapshot, the other compilers are tested on GHA with QEMU
@@ -86,6 +88,7 @@ task:
8688
RECOVERY: yes
8789
EXTRAKEYS: yes
8890
SCHNORRSIG: yes
91+
MUSIG: yes
8992
ELLSWIFT: yes
9093
WRAPPER_CMD: 'valgrind --error-exitcode=42'
9194
SECP256K1_TEST_ITERS: 2

.github/workflows/ci.yml

+31-20
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ env:
3333
RECOVERY: 'no'
3434
EXTRAKEYS: 'no'
3535
SCHNORRSIG: 'no'
36+
MUSIG: 'no'
3637
ELLSWIFT: 'no'
3738
### test options
38-
SECP256K1_TEST_ITERS:
39+
SECP256K1_TEST_ITERS: 64
3940
BENCH: 'yes'
4041
SECP256K1_BENCH_ITERS: 2
4142
CTIMETESTS: 'yes'
@@ -72,18 +73,18 @@ jobs:
7273
matrix:
7374
configuration:
7475
- env_vars: { WIDEMUL: 'int64', RECOVERY: 'yes' }
75-
- env_vars: { WIDEMUL: 'int64', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
76+
- env_vars: { WIDEMUL: 'int64', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes' }
7677
- env_vars: { WIDEMUL: 'int128' }
7778
- env_vars: { WIDEMUL: 'int128_struct', ELLSWIFT: 'yes' }
78-
- env_vars: { WIDEMUL: 'int128', RECOVERY: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
79-
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes' }
79+
- env_vars: { WIDEMUL: 'int128', RECOVERY: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes' }
80+
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes' }
8081
- env_vars: { WIDEMUL: 'int128', ASM: 'x86_64', ELLSWIFT: 'yes' }
81-
- env_vars: { RECOVERY: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes' }
82-
- env_vars: { CTIMETESTS: 'no', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', CPPFLAGS: '-DVERIFY' }
82+
- env_vars: { RECOVERY: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes' }
83+
- env_vars: { CTIMETESTS: 'no', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', CPPFLAGS: '-DVERIFY' }
8384
- env_vars: { BUILD: 'distcheck', WITH_VALGRIND: 'no', CTIMETESTS: 'no', BENCH: 'no' }
8485
- env_vars: { CPPFLAGS: '-DDETERMINISTIC' }
8586
- env_vars: { CFLAGS: '-O0', CTIMETESTS: 'no' }
86-
- env_vars: { CFLAGS: '-O1', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
87+
- env_vars: { CFLAGS: '-O1', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes' }
8788
- env_vars: { ECMULTGENKB: 2, ECMULTWINDOW: 2 }
8889
- env_vars: { ECMULTGENKB: 86, ECMULTWINDOW: 4 }
8990
cc:
@@ -142,6 +143,7 @@ jobs:
142143
RECOVERY: 'yes'
143144
EXTRAKEYS: 'yes'
144145
SCHNORRSIG: 'yes'
146+
MUSIG: 'yes'
145147
ELLSWIFT: 'yes'
146148
CC: ${{ matrix.cc }}
147149

@@ -187,6 +189,7 @@ jobs:
187189
RECOVERY: 'yes'
188190
EXTRAKEYS: 'yes'
189191
SCHNORRSIG: 'yes'
192+
MUSIG: 'yes'
190193
ELLSWIFT: 'yes'
191194
CTIMETESTS: 'no'
192195

@@ -239,6 +242,7 @@ jobs:
239242
RECOVERY: 'yes'
240243
EXTRAKEYS: 'yes'
241244
SCHNORRSIG: 'yes'
245+
MUSIG: 'yes'
242246
ELLSWIFT: 'yes'
243247
CTIMETESTS: 'no'
244248

@@ -285,6 +289,7 @@ jobs:
285289
RECOVERY: 'yes'
286290
EXTRAKEYS: 'yes'
287291
SCHNORRSIG: 'yes'
292+
MUSIG: 'yes'
288293
ELLSWIFT: 'yes'
289294
CTIMETESTS: 'no'
290295

@@ -341,6 +346,7 @@ jobs:
341346
RECOVERY: 'yes'
342347
EXTRAKEYS: 'yes'
343348
SCHNORRSIG: 'yes'
349+
MUSIG: 'yes'
344350
ELLSWIFT: 'yes'
345351
CTIMETESTS: 'no'
346352

@@ -394,6 +400,7 @@ jobs:
394400
RECOVERY: 'yes'
395401
EXTRAKEYS: 'yes'
396402
SCHNORRSIG: 'yes'
403+
MUSIG: 'yes'
397404
ELLSWIFT: 'yes'
398405
CTIMETESTS: 'no'
399406
SECP256K1_TEST_ITERS: 2
@@ -446,6 +453,7 @@ jobs:
446453
RECOVERY: 'yes'
447454
EXTRAKEYS: 'yes'
448455
SCHNORRSIG: 'yes'
456+
MUSIG: 'yes'
449457
ELLSWIFT: 'yes'
450458
CTIMETESTS: 'no'
451459
CFLAGS: '-fsanitize=undefined,address -g'
@@ -511,6 +519,7 @@ jobs:
511519
RECOVERY: 'yes'
512520
EXTRAKEYS: 'yes'
513521
SCHNORRSIG: 'yes'
522+
MUSIG: 'yes'
514523
ELLSWIFT: 'yes'
515524
CC: 'clang'
516525
SECP256K1_TEST_ITERS: 32
@@ -558,6 +567,7 @@ jobs:
558567
RECOVERY: 'yes'
559568
EXTRAKEYS: 'yes'
560569
SCHNORRSIG: 'yes'
570+
MUSIG: 'yes'
561571
ELLSWIFT: 'yes'
562572
CTIMETESTS: 'no'
563573

@@ -602,9 +612,9 @@ jobs:
602612
if: ${{ always() }}
603613

604614
x86_64-macos-native:
605-
name: "x86_64: macOS Monterey, Valgrind"
615+
name: "x86_64: macOS Ventura, Valgrind"
606616
# See: https://github.com/actions/runner-images#available-images.
607-
runs-on: macos-12
617+
runs-on: macos-13
608618

609619
env:
610620
CC: 'clang'
@@ -615,15 +625,15 @@ jobs:
615625
fail-fast: false
616626
matrix:
617627
env_vars:
618-
- { WIDEMUL: 'int64', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
628+
- { WIDEMUL: 'int64', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes' }
619629
- { WIDEMUL: 'int128_struct', ECMULTGENKB: 2, ECMULTWINDOW: 4 }
620-
- { WIDEMUL: 'int128', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
630+
- { WIDEMUL: 'int128', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes' }
621631
- { WIDEMUL: 'int128', RECOVERY: 'yes' }
622-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
623-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc' }
624-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
625-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
626-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CPPFLAGS: '-DVERIFY', CTIMETESTS: 'no' }
632+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes' }
633+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc' }
634+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
635+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
636+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', MUSIG: 'yes', ELLSWIFT: 'yes', CPPFLAGS: '-DVERIFY', CTIMETESTS: 'no' }
627637
- BUILD: 'distcheck'
628638

629639
steps:
@@ -751,14 +761,14 @@ jobs:
751761
# Use the bash shell included with Git for Windows.
752762
shell: bash
753763
run: |
754-
cd build/src/RelWithDebInfo && file *tests.exe bench*.exe libsecp256k1-*.dll || true
764+
cd build/bin/RelWithDebInfo && file *tests.exe bench*.exe libsecp256k1-*.dll || true
755765
756766
- name: Check
757767
run: |
758768
ctest -C RelWithDebInfo --test-dir build -j ([int]$env:NUMBER_OF_PROCESSORS + 1)
759-
build\src\RelWithDebInfo\bench_ecmult.exe
760-
build\src\RelWithDebInfo\bench_internal.exe
761-
build\src\RelWithDebInfo\bench.exe
769+
build\bin\RelWithDebInfo\bench_ecmult.exe
770+
build\bin\RelWithDebInfo\bench_internal.exe
771+
build\bin\RelWithDebInfo\bench.exe
762772
763773
win64-native-headers:
764774
name: "x64 (MSVC): C++ (public headers)"
@@ -790,6 +800,7 @@ jobs:
790800
RECOVERY: 'yes'
791801
EXTRAKEYS: 'yes'
792802
SCHNORRSIG: 'yes'
803+
MUSIG: 'yes'
793804
ELLSWIFT: 'yes'
794805

795806
steps:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ecdh_example
1111
ecdsa_example
1212
schnorr_example
1313
ellswift_example
14+
musig_example
1415
*.exe
1516
*.so
1617
*.a

CHANGELOG.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,26 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## [0.6.0] - 2024-11-04
9+
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+
- New CMake variable `SECP256K1_APPEND_LDFLAGS` for appending linker flags to the build command.
16+
17+
#### Changed
18+
- API functions now use a significantly more robust method to clear secrets from the stack before returning. However, secret clearing remains a best-effort security measure and cannot guarantee complete removal.
19+
- Any type `secp256k1_foo` can now be forward-declared using `typedef struct secp256k1_foo secp256k1_foo;` (or also `struct secp256k1_foo;` in C++).
20+
- Organized CMake build artifacts into dedicated directories (`bin/` for executables, `lib/` for libraries) to improve build output structure and Windows shared library compatibility.
21+
22+
#### Removed
23+
- Removed the `secp256k1_scratch_space` struct and its associated functions `secp256k1_scratch_space_create` and `secp256k1_scratch_space_destroy` because the scratch space was unused in the API.
24+
25+
#### ABI Compatibility
26+
The symbols `secp256k1_scratch_space_create` and `secp256k1_scratch_space_destroy` were removed.
27+
Otherwise, the library maintains backward compatibility with versions 0.3.x through 0.5.x.
928

1029
## [0.5.1] - 2024-08-01
1130

@@ -143,7 +162,7 @@ This version was in fact never released.
143162
The number was given by the build system since the introduction of autotools in Jan 2014 (ea0fe5a5bf0c04f9cc955b2966b614f5f378c6f6).
144163
Therefore, this version number does not uniquely identify a set of source files.
145164

146-
[unreleased]: https://github.com/bitcoin-core/secp256k1/compare/v0.5.1...HEAD
165+
[0.6.0]: https://github.com/bitcoin-core/secp256k1/compare/v0.5.1...v0.6.0
147166
[0.5.1]: https://github.com/bitcoin-core/secp256k1/compare/v0.5.0...v0.5.1
148167
[0.5.0]: https://github.com/bitcoin-core/secp256k1/compare/v0.4.1...v0.5.0
149168
[0.4.1]: https://github.com/bitcoin-core/secp256k1/compare/v0.4.0...v0.4.1

CMakeLists.txt

+34-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
cmake_minimum_required(VERSION 3.16)
22

3+
#=============================
4+
# Project / Package metadata
5+
#=============================
36
project(libsecp256k1
47
# The package (a.k.a. release) version is based on semantic versioning 2.0.0 of
58
# the API. All changes in experimental modules are treated as
69
# backwards-compatible and therefore at most increase the minor version.
7-
VERSION 0.5.2
10+
VERSION 0.6.0
811
DESCRIPTION "Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1."
912
HOMEPAGE_URL "https://github.com/bitcoin-core/secp256k1"
1013
LANGUAGES C
1114
)
15+
enable_testing()
16+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
1217

1318
if(CMAKE_VERSION VERSION_LESS 3.21)
1419
# Emulates CMake 3.21+ behavior.
@@ -26,15 +31,19 @@ endif()
2631
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
2732
# All changes in experimental modules are treated as if they don't affect the
2833
# interface and therefore only increase the revision.
29-
set(${PROJECT_NAME}_LIB_VERSION_CURRENT 4)
30-
set(${PROJECT_NAME}_LIB_VERSION_REVISION 2)
31-
set(${PROJECT_NAME}_LIB_VERSION_AGE 2)
34+
set(${PROJECT_NAME}_LIB_VERSION_CURRENT 5)
35+
set(${PROJECT_NAME}_LIB_VERSION_REVISION 0)
36+
set(${PROJECT_NAME}_LIB_VERSION_AGE 0)
3237

38+
#=============================
39+
# Language setup
40+
#=============================
3341
set(CMAKE_C_STANDARD 90)
3442
set(CMAKE_C_EXTENSIONS OFF)
3543

36-
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
37-
44+
#=============================
45+
# Configurable options
46+
#=============================
3847
option(BUILD_SHARED_LIBS "Build shared libraries." ON)
3948
option(SECP256K1_DISABLE_SHARED "Disable shared library. Overrides BUILD_SHARED_LIBS." OFF)
4049
if(SECP256K1_DISABLE_SHARED)
@@ -51,6 +60,7 @@ option(SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON)
5160
option(SECP256K1_ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." OFF)
5261
option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON)
5362
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON)
63+
option(SECP256K1_ENABLE_MODULE_MUSIG "Enable musig module." ON)
5464
option(SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON)
5565

5666
# Processing must be done in a topological sorting of the dependency graph
@@ -59,6 +69,14 @@ if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
5969
add_compile_definitions(ENABLE_MODULE_ELLSWIFT=1)
6070
endif()
6171

72+
if(SECP256K1_ENABLE_MODULE_MUSIG)
73+
if(DEFINED SECP256K1_ENABLE_MODULE_SCHNORRSIG AND NOT SECP256K1_ENABLE_MODULE_SCHNORRSIG)
74+
message(FATAL_ERROR "Module dependency error: You have disabled the schnorrsig module explicitly, but it is required by the musig module.")
75+
endif()
76+
set(SECP256K1_ENABLE_MODULE_SCHNORRSIG ON)
77+
add_compile_definitions(ENABLE_MODULE_MUSIG=1)
78+
endif()
79+
6280
if(SECP256K1_ENABLE_MODULE_SCHNORRSIG)
6381
if(DEFINED SECP256K1_ENABLE_MODULE_EXTRAKEYS AND NOT SECP256K1_ENABLE_MODULE_EXTRAKEYS)
6482
message(FATAL_ERROR "Module dependency error: You have disabled the extrakeys module explicitly, but it is required by the schnorrsig module.")
@@ -262,13 +280,6 @@ if(SECP256K1_BUILD_CTIME_TESTS)
262280
unset(msan_enabled)
263281
endif()
264282

265-
include(CTest)
266-
# We do not use CTest's BUILD_TESTING because a single toggle for all tests is too coarse for our needs.
267-
mark_as_advanced(BUILD_TESTING)
268-
if(SECP256K1_BUILD_BENCHMARK OR SECP256K1_BUILD_TESTS OR SECP256K1_BUILD_EXHAUSTIVE_TESTS OR SECP256K1_BUILD_CTIME_TESTS OR SECP256K1_BUILD_EXAMPLES)
269-
enable_testing()
270-
endif()
271-
272283
set(SECP256K1_APPEND_CFLAGS "" CACHE STRING "Compiler flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.")
273284
if(SECP256K1_APPEND_CFLAGS)
274285
# Appending to this low-level rule variable is the only way to
@@ -284,6 +295,15 @@ if(SECP256K1_APPEND_LDFLAGS)
284295
string(APPEND CMAKE_C_LINK_EXECUTABLE " ${SECP256K1_APPEND_LDFLAGS}")
285296
endif()
286297

298+
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
299+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
300+
endif()
301+
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
302+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
303+
endif()
304+
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
305+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
306+
endif()
287307
add_subdirectory(src)
288308
if(SECP256K1_BUILD_EXAMPLES)
289309
add_subdirectory(examples)
@@ -305,6 +325,7 @@ message(" ECDH ................................ ${SECP256K1_ENABLE_MODULE_ECDH}
305325
message(" ECDSA pubkey recovery ............... ${SECP256K1_ENABLE_MODULE_RECOVERY}")
306326
message(" extrakeys ........................... ${SECP256K1_ENABLE_MODULE_EXTRAKEYS}")
307327
message(" schnorrsig .......................... ${SECP256K1_ENABLE_MODULE_SCHNORRSIG}")
328+
message(" musig ............................... ${SECP256K1_ENABLE_MODULE_MUSIG}")
308329
message(" ElligatorSwift ...................... ${SECP256K1_ENABLE_MODULE_ELLSWIFT}")
309330
message("Parameters:")
310331
message(" ecmult window size .................. ${SECP256K1_ECMULT_WINDOW_SIZE}")

Makefile.am

+16
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,17 @@ ellswift_example_LDFLAGS += -lbcrypt
195195
endif
196196
TESTS += ellswift_example
197197
endif
198+
if ENABLE_MODULE_MUSIG
199+
noinst_PROGRAMS += musig_example
200+
musig_example_SOURCES = examples/musig.c
201+
musig_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
202+
musig_example_LDADD = libsecp256k1.la
203+
musig_example_LDFLAGS = -static
204+
if BUILD_WINDOWS
205+
musig_example_LDFLAGS += -lbcrypt
206+
endif
207+
TESTS += musig_example
208+
endif
198209
endif
199210

200211
### Precomputed tables
@@ -254,6 +265,7 @@ maintainer-clean-local: clean-testvectors
254265
### Additional files to distribute
255266
EXTRA_DIST = autogen.sh CHANGELOG.md SECURITY.md
256267
EXTRA_DIST += doc/release-process.md doc/safegcd_implementation.md
268+
EXTRA_DIST += doc/ellswift.md doc/musig.md
257269
EXTRA_DIST += examples/EXAMPLES_COPYING
258270
EXTRA_DIST += sage/gen_exhaustive_groups.sage
259271
EXTRA_DIST += sage/gen_split_lambda_constants.sage
@@ -281,6 +293,10 @@ if ENABLE_MODULE_SCHNORRSIG
281293
include src/modules/schnorrsig/Makefile.am.include
282294
endif
283295

296+
if ENABLE_MODULE_MUSIG
297+
include src/modules/musig/Makefile.am.include
298+
endif
299+
284300
if ENABLE_MODULE_ELLSWIFT
285301
include src/modules/ellswift/Makefile.am.include
286302
endif

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Features:
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).
2323
* Optional module for ElligatorSwift key exchange according to [BIP-324](https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki).
24+
* Optional module for MuSig2 Schnorr multi-signatures according to [BIP-327](https://github.com/bitcoin/bips/blob/master/bip-0327.mediawiki).
2425

2526
Implementation details
2627
----------------------

0 commit comments

Comments
 (0)