Skip to content

Commit 4654cc3

Browse files
committed
Update secp256k1 subtree to latest master
2 parents 71c51c1 + 53eec53 commit 4654cc3

27 files changed

+358
-269
lines changed

src/secp256k1/.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 }}

src/secp256k1/.github/actions/run-in-docker-action/action.yml

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

39+
- # Workaround for https://github.com/google/sanitizers/issues/1614 .
40+
# The underlying issue has been fixed in clang 18.1.3.
41+
run: sudo sysctl -w vm.mmap_rnd_bits=28
42+
shell: bash
43+
3944
- # Tell Docker to pass environment variables in `env` into the container.
4045
run: >
4146
docker run \

src/secp256k1/CMakeLists.txt

+30-11
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,40 @@ endif()
5151

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

54-
option(SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON)
55-
if(SECP256K1_ENABLE_MODULE_ECDH)
56-
add_compile_definitions(ENABLE_MODULE_ECDH=1)
57-
endif()
54+
## Modules
5855

56+
# We declare all options before processing them, to make sure we can express
57+
# dependendencies while processing.
58+
option(SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON)
5959
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)
62-
endif()
63-
6460
option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON)
6561
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON)
62+
option(SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON)
63+
64+
# Processing must be done in a topological sorting of the dependency graph
65+
# (dependent module first).
66+
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
67+
add_compile_definitions(ENABLE_MODULE_ELLSWIFT=1)
68+
endif()
69+
6670
if(SECP256K1_ENABLE_MODULE_SCHNORRSIG)
71+
if(DEFINED SECP256K1_ENABLE_MODULE_EXTRAKEYS AND NOT SECP256K1_ENABLE_MODULE_EXTRAKEYS)
72+
message(FATAL_ERROR "Module dependency error: You have disabled the extrakeys module explicitly, but it is required by the schnorrsig module.")
73+
endif()
6774
set(SECP256K1_ENABLE_MODULE_EXTRAKEYS ON)
6875
add_compile_definitions(ENABLE_MODULE_SCHNORRSIG=1)
6976
endif()
77+
7078
if(SECP256K1_ENABLE_MODULE_EXTRAKEYS)
7179
add_compile_definitions(ENABLE_MODULE_EXTRAKEYS=1)
7280
endif()
7381

74-
option(SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON)
75-
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
76-
add_compile_definitions(ENABLE_MODULE_ELLSWIFT=1)
82+
if(SECP256K1_ENABLE_MODULE_RECOVERY)
83+
add_compile_definitions(ENABLE_MODULE_RECOVERY=1)
84+
endif()
85+
86+
if(SECP256K1_ENABLE_MODULE_ECDH)
87+
add_compile_definitions(ENABLE_MODULE_ECDH=1)
7788
endif()
7889

7990
option(SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS "Enable external default callback functions." OFF)
@@ -254,9 +265,14 @@ if(SECP256K1_BUILD_BENCHMARK OR SECP256K1_BUILD_TESTS OR SECP256K1_BUILD_EXHAUST
254265
enable_testing()
255266
endif()
256267

268+
set(SECP256K1_LATE_CFLAGS "" CACHE STRING "Compiler flags that are added to the command line after all other flags added by the build system.")
269+
include(AllTargetsCompileOptions)
270+
257271
add_subdirectory(src)
272+
all_targets_compile_options(src "${SECP256K1_LATE_CFLAGS}")
258273
if(SECP256K1_BUILD_EXAMPLES)
259274
add_subdirectory(examples)
275+
all_targets_compile_options(examples "${SECP256K1_LATE_CFLAGS}")
260276
endif()
261277

262278
message("\n")
@@ -330,6 +346,9 @@ else()
330346
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
331347
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
332348
endif()
349+
if(SECP256K1_LATE_CFLAGS)
350+
message("SECP256K1_LATE_CFLAGS ................. ${SECP256K1_LATE_CFLAGS}")
351+
endif()
333352
message("\n")
334353
if(SECP256K1_EXPERIMENTAL)
335354
message(

src/secp256k1/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.

src/secp256k1/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

src/secp256k1/ci/ci.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ print_environment() {
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
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()

src/secp256k1/configure.ac

+16-13
Original file line numberDiff line numberDiff line change
@@ -387,29 +387,32 @@ SECP_CFLAGS="$SECP_CFLAGS $WERROR_CFLAGS"
387387
### Handle module options
388388
###
389389

390-
if test x"$enable_module_ecdh" = x"yes"; then
391-
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_ECDH=1"
392-
fi
393-
394-
if test x"$enable_module_recovery" = x"yes"; then
395-
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_RECOVERY=1"
390+
# Processing must be done in a reverse topological sorting of the dependency graph
391+
# (dependent module first).
392+
if test x"$enable_module_ellswift" = x"yes"; then
393+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_ELLSWIFT=1"
396394
fi
397395

398396
if test x"$enable_module_schnorrsig" = x"yes"; then
399-
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_SCHNORRSIG=1"
397+
if test x"$enable_module_extrakeys" = x"no"; then
398+
AC_MSG_ERROR([Module dependency error: You have disabled the extrakeys module explicitly, but it is required by the schnorrsig module.])
399+
fi
400400
enable_module_extrakeys=yes
401+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_SCHNORRSIG=1"
401402
fi
402403

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
409404
if test x"$enable_module_extrakeys" = x"yes"; then
410405
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_EXTRAKEYS=1"
411406
fi
412407

408+
if test x"$enable_module_recovery" = x"yes"; then
409+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_RECOVERY=1"
410+
fi
411+
412+
if test x"$enable_module_ecdh" = x"yes"; then
413+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_ECDH=1"
414+
fi
415+
413416
if test x"$enable_external_default_callbacks" = x"yes"; then
414417
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DUSE_EXTERNAL_DEFAULT_CALLBACKS=1"
415418
fi

src/secp256k1/contrib/lax_der_parsing.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ extern "C" {
6767
*
6868
* Returns: 1 when the signature could be parsed, 0 otherwise.
6969
* Args: ctx: a secp256k1 context object
70-
* Out: sig: a pointer to a signature object
71-
* In: input: a pointer to the signature to be parsed
70+
* Out: sig: pointer to a signature object
71+
* In: input: pointer to the signature to be parsed
7272
* inputlen: the length of the array pointed to be input
7373
*
7474
* This function will accept any valid DER encoded signature, even if the

src/secp256k1/doc/release-process.md

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Release Process
1+
# Release process
22

33
This document outlines the process for releasing versions of the form `$MAJOR.$MINOR.$PATCH`.
44

@@ -14,31 +14,30 @@ This process also assumes that there will be no minor releases for old major rel
1414

1515
We aim to cut a regular release every 3-4 months, approximately twice as frequent as major Bitcoin Core releases. Every second release should be published one month before the feature freeze of the next major Bitcoin Core release, allowing sufficient time to update the library in Core.
1616

17-
## Sanity Checks
18-
Perform these checks before creating a release:
17+
## Sanity checks
18+
Perform these checks when reviewing the release PR (see below):
1919

2020
1. Ensure `make distcheck` doesn't fail.
21-
```shell
22-
./autogen.sh && ./configure --enable-dev-mode && make distcheck
23-
```
21+
```shell
22+
./autogen.sh && ./configure --enable-dev-mode && make distcheck
23+
```
2424
2. Check installation with autotools:
25-
```shell
26-
dir=$(mktemp -d)
27-
./autogen.sh && ./configure --prefix=$dir && make clean && make install && ls -RlAh $dir
28-
gcc -o ecdsa examples/ecdsa.c $(PKG_CONFIG_PATH=$dir/lib/pkgconfig pkg-config --cflags --libs libsecp256k1) -Wl,-rpath,"$dir/lib" && ./ecdsa
29-
```
25+
```shell
26+
dir=$(mktemp -d)
27+
./autogen.sh && ./configure --prefix=$dir && make clean && make install && ls -RlAh $dir
28+
gcc -o ecdsa examples/ecdsa.c $(PKG_CONFIG_PATH=$dir/lib/pkgconfig pkg-config --cflags --libs libsecp256k1) -Wl,-rpath,"$dir/lib" && ./ecdsa
29+
```
3030
3. Check installation with CMake:
31-
```shell
32-
dir=$(mktemp -d)
33-
build=$(mktemp -d)
34-
cmake -B $build -DCMAKE_INSTALL_PREFIX=$dir && cmake --build $build --target install && ls -RlAh $dir
35-
gcc -o ecdsa examples/ecdsa.c -I $dir/include -L $dir/lib*/ -l secp256k1 -Wl,-rpath,"$dir/lib",-rpath,"$dir/lib64" && ./ecdsa
36-
```
37-
4. Use the [`check-abi.sh`](/tools/check-abi.sh) tool to ensure there are no unexpected ABI incompatibilities and that the version number and release notes accurately reflect all potential ABI changes. To run this tool, the `abi-dumper` and `abi-compliance-checker` packages are required.
38-
39-
```shell
40-
tools/check-abi.sh
41-
```
31+
```shell
32+
dir=$(mktemp -d)
33+
build=$(mktemp -d)
34+
cmake -B $build -DCMAKE_INSTALL_PREFIX=$dir && cmake --build $build --target install && ls -RlAh $dir
35+
gcc -o ecdsa examples/ecdsa.c -I $dir/include -L $dir/lib*/ -l secp256k1 -Wl,-rpath,"$dir/lib",-rpath,"$dir/lib64" && ./ecdsa
36+
```
37+
4. Use the [`check-abi.sh`](/tools/check-abi.sh) tool to verify that there are no unexpected ABI incompatibilities and that the version number and the release notes accurately reflect all potential ABI changes. To run this tool, the `abi-dumper` and `abi-compliance-checker` packages are required.
38+
```shell
39+
tools/check-abi.sh
40+
```
4241

4342
## Regular release
4443

@@ -47,47 +46,48 @@ tools/check-abi.sh
4746
* adding a section for the release (make sure that the version number is a link to a diff between the previous and new version),
4847
* removing the `[Unreleased]` section header, and
4948
* including an entry for `### ABI Compatibility` if it doesn't exist,
50-
* sets `_PKG_VERSION_IS_RELEASE` to `true` in `configure.ac`, and
51-
* if this is not a patch release
52-
* updates `_PKG_VERSION_*` and `_LIB_VERSION_*` in `configure.ac` and
49+
* sets `_PKG_VERSION_IS_RELEASE` to `true` in `configure.ac`, and,
50+
* if this is not a patch release,
51+
* updates `_PKG_VERSION_*` and `_LIB_VERSION_*` in `configure.ac`, and
5352
* updates `project(libsecp256k1 VERSION ...)` and `${PROJECT_NAME}_LIB_VERSION_*` in `CMakeLists.txt`.
54-
2. After the PR is merged, tag the commit and push it:
53+
2. Perform the [sanity checks](#sanity-checks) on the PR branch.
54+
3. After the PR is merged, tag the commit, and push the tag:
5555
```
5656
RELEASE_COMMIT=<merge commit of step 1>
5757
git tag -s v$MAJOR.$MINOR.$PATCH -m "libsecp256k1 $MAJOR.$MINOR.$PATCH" $RELEASE_COMMIT
5858
git push [email protected]:bitcoin-core/secp256k1.git v$MAJOR.$MINOR.$PATCH
5959
```
60-
3. Open a PR to the master branch with a commit (using message `"release cleanup: bump version after $MAJOR.$MINOR.$PATCH"`, for example) that
60+
4. Open a PR to the master branch with a commit (using message `"release cleanup: bump version after $MAJOR.$MINOR.$PATCH"`, for example) that
6161
* sets `_PKG_VERSION_IS_RELEASE` to `false` and increments `_PKG_VERSION_PATCH` and `_LIB_VERSION_REVISION` in `configure.ac`,
6262
* increments the `$PATCH` component of `project(libsecp256k1 VERSION ...)` and `${PROJECT_NAME}_LIB_VERSION_REVISION` in `CMakeLists.txt`, and
6363
* adds an `[Unreleased]` section header to the [CHANGELOG.md](../CHANGELOG.md).
6464

6565
If other maintainers are not present to approve the PR, it can be merged without ACKs.
66-
4. Create a new GitHub release with a link to the corresponding entry in [CHANGELOG.md](../CHANGELOG.md).
66+
5. Create a new GitHub release with a link to the corresponding entry in [CHANGELOG.md](../CHANGELOG.md).
67+
6. Send an announcement email to the bitcoin-dev mailing list.
6768

6869
## Maintenance release
6970

70-
Note that bugfixes only need to be backported to releases for which no compatible release without the bug exists.
71+
Note that bug fixes need to be backported only to releases for which no compatible release without the bug exists.
7172

7273
1. If there's no maintenance branch `$MAJOR.$MINOR`, create one:
7374
```
7475
git checkout -b $MAJOR.$MINOR v$MAJOR.$MINOR.$((PATCH - 1))
7576
git push [email protected]:bitcoin-core/secp256k1.git $MAJOR.$MINOR
7677
```
7778
2. Open a pull request to the `$MAJOR.$MINOR` branch that
78-
* includes the bugfixes,
79+
* includes the bug fixes,
7980
* finalizes the release notes similar to a regular release,
8081
* increments `_PKG_VERSION_PATCH` and `_LIB_VERSION_REVISION` in `configure.ac`
8182
and the `$PATCH` component of `project(libsecp256k1 VERSION ...)` and `${PROJECT_NAME}_LIB_VERSION_REVISION` in `CMakeLists.txt`
8283
(with commit message `"release: bump versions for $MAJOR.$MINOR.$PATCH"`, for example).
83-
3. After the PRs are merged, update the release branch and tag the commit:
84+
3. Perform the [sanity checks](#sanity-checks) on the PR branch.
85+
4. After the PRs are merged, update the release branch, tag the commit, and push the tag:
8486
```
8587
git checkout $MAJOR.$MINOR && git pull
8688
git tag -s v$MAJOR.$MINOR.$PATCH -m "libsecp256k1 $MAJOR.$MINOR.$PATCH"
87-
```
88-
4. Push tag:
89-
```
9089
git push [email protected]:bitcoin-core/secp256k1.git v$MAJOR.$MINOR.$PATCH
9190
```
92-
5. Create a new GitHub release with a link to the corresponding entry in [CHANGELOG.md](../CHANGELOG.md).
93-
6. Open PR to the master branch that includes a commit (with commit message `"release notes: add $MAJOR.$MINOR.$PATCH"`, for example) that adds release notes to [CHANGELOG.md](../CHANGELOG.md).
91+
6. Create a new GitHub release with a link to the corresponding entry in [CHANGELOG.md](../CHANGELOG.md).
92+
7. Send an announcement email to the bitcoin-dev mailing list.
93+
8. Open PR to the master branch that includes a commit (with commit message `"release notes: add $MAJOR.$MINOR.$PATCH"`, for example) that adds release notes to [CHANGELOG.md](../CHANGELOG.md).

0 commit comments

Comments
 (0)