Skip to content

Commit 42c7d35

Browse files
committed
Squashed 'src/secp256k1/' changes from b9313c6e1a..a44a339384
a44a339384 Merge bitcoin-core/secp256k1#1750: ci: Use clang-snapshot in "MSan" job 53585f93b7 ci: Use clang-snapshot in "MSan" job 6894c964f3 Fix Clang 21+ `-Wuninitialized-const-pointer` warning when using MSan 2b7337f63a Merge bitcoin-core/secp256k1#1756: ci: Fix image caching and apply other improvements f163c35897 ci: Set `DEBIAN_FRONTEND=noninteractive` 70ae177ca0 ci: Bump `docker/build-push-action` version b2a95a420f ci: Drop `tags` input for `docker/build-push-action` 122014edb3 ci: Add `scope` parameter to `cache-{to,from}` options baa265429f Merge bitcoin-core/secp256k1#1727: docs: Clarify that callback can be called more than once 4d90585fea docs: Improve API docs of _context_set_illegal_callback 895f53d1cf docs: Clarify that callback can be called more than once de6af6ae35 Merge bitcoin-core/secp256k1#1748: bench: improve context creation in ECDH benchmark 5817885153 Merge bitcoin-core/secp256k1#1749: build: Fix warnings in x86_64 assembly check ab560078aa build: Fix warnings in x86_64 assembly check 10dab907e7 Merge bitcoin-core/secp256k1#1741: doc: clarify API doc of `secp256k1_ecdsa_recover` return value dfe284ed2d bench: improve context creation in ECDH benchmark 7321bdf27b doc: clarify API doc of `secp256k1_ecdsa_recover` return value b475654302 Merge bitcoin-core/secp256k1#1745: test: introduce group order byte-array constant for deduplication 0c91c56041 test: introduce group order byte-array constant for deduplication 88be4e8d86 Merge bitcoin-core/secp256k1#1735: musig: Invalidate secnonce in secp256k1_musig_partial_sign 36e76952cb Merge bitcoin-core/secp256k1#1738: check-abi: remove support for obsolete CMake library output location (src/libsecp256k1.so) 399b582a5f Split memclear into two versions 4985ac0f89 Merge bitcoin-core/secp256k1#1737: doc: mention ctx requirement for `_ellswift_create` (not secp256k1_context_static) 7ebaa134a7 check-abi: remove support for obsolete CMake library output location (src/libsecp256k1.so) 806de38bfc doc: mention ctx requirement for `_ellswift_create` (not secp256k1_context_static) 03fb60ad2e Merge bitcoin-core/secp256k1#1681: doc: Recommend clang-cl when building on Windows d93380fb35 Merge bitcoin-core/secp256k1#1731: schnorrsig: Securely clear buf containing k or its negation 8113671f80 Merge bitcoin-core/secp256k1#1729: hash: Use size_t instead of int for RFC6979 outlen copy 325d65a8cf Rename and clear var containing k or -k 960ba5f9c6 Use size_t instead of int for RFC6979 outlen copy 737912430d ci: Add more tests for clang-cl 7379a5bed3 doc: Recommend clang-cl when building on Windows f36afb8b3d Merge bitcoin-core/secp256k1#1725: tests: refactor tagged hash verification 5153cf1c91 tests: refactor tagged hash tests d2dcf52091 Merge bitcoin-core/secp256k1#1726: docs: fix broken link to Tromer's cache.pdf paper 489a43d1bf docs: fix broken link to eprint cache.pdf paper d599714147 Merge bitcoin-core/secp256k1#1722: docs: Exclude modules' `bench_impl.h` headers from coverage report 0458def51e doc: Add `--gcov-ignore-parse-errors=all` option to `gcovr` invocations 1aecce5936 doc: Add `--merge-mode-functions=separate` option to `gcovr` invocations 106a7cbf41 doc: Exclude modules' `bench_impl.h` headers from coverage report a9e955d3ea autotools, docs: Adjust help string for `--enable-coverage` option e523e4f90e Merge bitcoin-core/secp256k1#1720: chore(ci): Fix typo in Dockerfile comment 24ba8ff168 chore(ci): Fix typo in Dockerfile comment 74b8068c5d Merge bitcoin-core/secp256k1#1717: test: update wycheproof test vectors c25c3c8a88 test: update wycheproof test vectors 20e3b44746 Merge bitcoin-core/secp256k1#1688: cmake: Avoid contaminating parent project's cache with `BUILD_SHARED_LIBS` 2c076d907a Merge bitcoin-core/secp256k1#1711: tests: update Wycheproof 7b07b22957 cmake: Avoid contaminating parent project's cache with BUILD_SHARED_LIBS 5433648ca0 Fix typos and spellings 9ea54c69b7 tests: update Wycheproof files git-subtree-dir: src/secp256k1 git-subtree-split: a44a339384e1e4b1c0ed7fa59e2857b057f075bf
1 parent 5600e6f commit 42c7d35

34 files changed

+206
-194
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ inputs:
44
dockerfile:
55
description: 'A Dockerfile that defines an image'
66
required: true
7-
tag:
8-
description: 'A tag of an image'
9-
required: true
7+
scope:
8+
description: 'A cached image scope'
9+
required: false
10+
default: ${{ runner.arch }}
1011
command:
1112
description: 'A command to run in a container'
1213
required: false
@@ -16,25 +17,23 @@ runs:
1617
steps:
1718
- uses: docker/setup-buildx-action@v3
1819

19-
- uses: docker/build-push-action@v5
20+
- uses: docker/build-push-action@v6
2021
id: main_builder
2122
continue-on-error: true
2223
with:
2324
context: .
2425
file: ${{ inputs.dockerfile }}
25-
tags: ${{ inputs.tag }}
2626
load: true
27-
cache-from: type=gha
27+
cache-from: type=gha,scope=${{ inputs.scope }}
2828

29-
- uses: docker/build-push-action@v5
29+
- uses: docker/build-push-action@v6
3030
id: retry_builder
3131
if: steps.main_builder.outcome == 'failure'
3232
with:
3333
context: .
3434
file: ${{ inputs.dockerfile }}
35-
tags: ${{ inputs.tag }}
3635
load: true
37-
cache-from: type=gha
36+
cache-from: type=gha,scope=${{ inputs.scope }}
3837

3938
- # Workaround for https://github.com/google/sanitizers/issues/1614 .
4039
# The underlying issue has been fixed in clang 18.1.3.
@@ -47,7 +46,8 @@ runs:
4746
$(echo '${{ toJSON(env) }}' | jq -r 'keys[] | "--env \(.) "') \
4847
--volume ${{ github.workspace }}:${{ github.workspace }} \
4948
--workdir ${{ github.workspace }} \
50-
${{ inputs.tag }} bash -c "
49+
$(docker images -q | head -n1) \
50+
bash -c "
5151
git config --global --add safe.directory ${{ github.workspace }}
5252
${{ inputs.command }}
5353
"

.github/workflows/ci.yml

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ jobs:
6767
network=host
6868
6969
- name: Build container
70-
uses: docker/build-push-action@v5
70+
uses: docker/build-push-action@v6
7171
with:
7272
file: ./ci/linux-debian.Dockerfile
73-
tags: ${{ matrix.arch }}-debian-image
74-
cache-from: type=gha
75-
cache-to: type=gha,mode=min
73+
cache-from: type=gha,scope=${{ runner.arch }}
74+
cache-to: type=gha,scope=${{ runner.arch }},mode=min
7675

7776
x86_64-debian:
7877
name: "x86_64: Linux (Debian stable)"
@@ -116,7 +115,6 @@ jobs:
116115
uses: ./.github/actions/run-in-docker-action
117116
with:
118117
dockerfile: ./ci/linux-debian.Dockerfile
119-
tag: x64-debian-image
120118

121119
- name: Print logs
122120
uses: ./.github/actions/print-logs
@@ -152,7 +150,6 @@ jobs:
152150
uses: ./.github/actions/run-in-docker-action
153151
with:
154152
dockerfile: ./ci/linux-debian.Dockerfile
155-
tag: x64-debian-image
156153

157154
- name: Print logs
158155
uses: ./.github/actions/print-logs
@@ -184,7 +181,6 @@ jobs:
184181
uses: ./.github/actions/run-in-docker-action
185182
with:
186183
dockerfile: ./ci/linux-debian.Dockerfile
187-
tag: x64-debian-image
188184

189185
- name: Print logs
190186
uses: ./.github/actions/print-logs
@@ -225,7 +221,6 @@ jobs:
225221
uses: ./.github/actions/run-in-docker-action
226222
with:
227223
dockerfile: ./ci/linux-debian.Dockerfile
228-
tag: x64-debian-image
229224

230225
- name: Print logs
231226
uses: ./.github/actions/print-logs
@@ -265,7 +260,6 @@ jobs:
265260
uses: ./.github/actions/run-in-docker-action
266261
with:
267262
dockerfile: ./ci/linux-debian.Dockerfile
268-
tag: arm64-debian-image
269263

270264
- name: Print logs
271265
uses: ./.github/actions/print-logs
@@ -297,7 +291,6 @@ jobs:
297291
uses: ./.github/actions/run-in-docker-action
298292
with:
299293
dockerfile: ./ci/linux-debian.Dockerfile
300-
tag: x64-debian-image
301294

302295
- name: Print logs
303296
uses: ./.github/actions/print-logs
@@ -313,28 +306,22 @@ jobs:
313306
fail-fast: false
314307
matrix:
315308
include:
316-
- docker_arch: x64
317-
runner: ubuntu-latest
309+
- runner: ubuntu-latest
318310
binary_arch: x64
319311
env_vars: { CC: 'clang', ASM: 'auto' }
320-
- docker_arch: x64
321-
runner: ubuntu-latest
312+
- runner: ubuntu-latest
322313
binary_arch: i686
323314
env_vars: { CC: 'i686-linux-gnu-gcc', HOST: 'i686-linux-gnu', ASM: 'auto' }
324-
- docker_arch: arm64
325-
runner: ubuntu-24.04-arm
315+
- runner: ubuntu-24.04-arm
326316
binary_arch: arm64
327317
env_vars: { CC: 'clang', ASM: 'auto' }
328-
- docker_arch: x64
329-
runner: ubuntu-latest
318+
- runner: ubuntu-latest
330319
binary_arch: x64
331320
env_vars: { CC: 'clang', ASM: 'no', ECMULTGENKB: 2, ECMULTWINDOW: 2 }
332-
- docker_arch: x64
333-
runner: ubuntu-latest
321+
- runner: ubuntu-latest
334322
binary_arch: i686
335323
env_vars: { CC: 'i686-linux-gnu-gcc', HOST: 'i686-linux-gnu', ASM: 'no', ECMULTGENKB: 2, ECMULTWINDOW: 2 }
336-
- docker_arch: arm64
337-
runner: ubuntu-24.04-arm
324+
- runner: ubuntu-24.04-arm
338325
binary_arch: arm64
339326
env_vars: { CC: 'clang', ASM: 'no', ECMULTGENKB: 2, ECMULTWINDOW: 2 }
340327

@@ -360,7 +347,6 @@ jobs:
360347
uses: ./.github/actions/run-in-docker-action
361348
with:
362349
dockerfile: ./ci/linux-debian.Dockerfile
363-
tag: ${{ matrix.docker_arch }}-debian-image
364350

365351
- name: Print logs
366352
uses: ./.github/actions/print-logs
@@ -404,7 +390,6 @@ jobs:
404390
uses: ./.github/actions/run-in-docker-action
405391
with:
406392
dockerfile: ./ci/linux-debian.Dockerfile
407-
tag: x64-debian-image
408393

409394
- name: Print logs
410395
uses: ./.github/actions/print-logs
@@ -432,6 +417,9 @@ jobs:
432417
# when ctime_tests when enabled.
433418
CFLAGS: '-fsanitize=memory -fsanitize-recover=memory -fsanitize-memory-param-retval -g'
434419
CTIMETESTS: 'no'
420+
cc:
421+
- 'clang'
422+
- 'clang-snapshot'
435423

436424
env:
437425
ECDH: 'yes'
@@ -440,7 +428,7 @@ jobs:
440428
SCHNORRSIG: 'yes'
441429
MUSIG: 'yes'
442430
ELLSWIFT: 'yes'
443-
CC: 'clang'
431+
CC: ${{ matrix.cc }}
444432
SECP256K1_TEST_ITERS: 32
445433
ASM: 'no'
446434
WITH_VALGRIND: 'no'
@@ -455,7 +443,6 @@ jobs:
455443
uses: ./.github/actions/run-in-docker-action
456444
with:
457445
dockerfile: ./ci/linux-debian.Dockerfile
458-
tag: x64-debian-image
459446

460447
- name: Print logs
461448
uses: ./.github/actions/print-logs
@@ -498,7 +485,6 @@ jobs:
498485
uses: ./.github/actions/run-in-docker-action
499486
with:
500487
dockerfile: ./ci/linux-debian.Dockerfile
501-
tag: x64-debian-image
502488

503489
- name: Print logs
504490
uses: ./.github/actions/print-logs
@@ -631,8 +617,16 @@ jobs:
631617
cpp_flags: '/DSECP256K1_MSVC_MULH_TEST_OVERRIDE'
632618
- job_name: 'x86 (MSVC): Windows (VS 2022)'
633619
cmake_options: '-A Win32'
634-
- job_name: 'x64 (MSVC): Windows (clang-cl)'
635-
cmake_options: '-T ClangCL'
620+
- job_name: 'x64 (clang-cl): Windows (VS 2022, shared)'
621+
cmake_options: '-T ClangCL -DBUILD_SHARED_LIBS=ON'
622+
symbol_check: 'true'
623+
- job_name: 'x64 (clang-cl): Windows (VS 2022, static)'
624+
cmake_options: '-T ClangCL -DBUILD_SHARED_LIBS=OFF'
625+
- job_name: 'x64 (clang-cl): Windows (VS 2022, int128_struct)'
626+
cmake_options: '-T ClangCL -DSECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY=int128_struct'
627+
- job_name: 'x64 (clang-cl): Windows (VS 2022, int128_struct with __(u)mulh)'
628+
cmake_options: '-T ClangCL -DSECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY=int128_struct'
629+
cpp_flags: '/DSECP256K1_MSVC_MULH_TEST_OVERRIDE'
636630

637631
steps:
638632
- name: Checkout
@@ -706,7 +700,6 @@ jobs:
706700
uses: ./.github/actions/run-in-docker-action
707701
with:
708702
dockerfile: ./ci/linux-debian.Dockerfile
709-
tag: x64-debian-image
710703

711704
- name: Print logs
712705
uses: ./.github/actions/print-logs
@@ -725,7 +718,6 @@ jobs:
725718
uses: ./.github/actions/run-in-docker-action
726719
with:
727720
dockerfile: ./ci/linux-debian.Dockerfile
728-
tag: x64-debian-image
729721
command: |
730722
g++ -Werror include/*.h
731723
clang -Werror -x c++-header include/*.h

CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ set(CMAKE_C_EXTENSIONS OFF)
3434
#=============================
3535
# Configurable options
3636
#=============================
37-
option(BUILD_SHARED_LIBS "Build shared libraries." ON)
38-
option(SECP256K1_DISABLE_SHARED "Disable shared library. Overrides BUILD_SHARED_LIBS." OFF)
39-
if(SECP256K1_DISABLE_SHARED)
40-
set(BUILD_SHARED_LIBS OFF)
37+
if(libsecp256k1_IS_TOP_LEVEL)
38+
option(BUILD_SHARED_LIBS "Build shared libraries." ON)
4139
endif()
4240

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

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ Run the tests:
9292

9393
To create a report, `gcovr` is recommended, as it includes branch coverage reporting:
9494

95-
$ gcovr --exclude 'src/bench*' --print-summary
95+
$ gcovr --gcov-ignore-parse-errors=all --merge-mode-functions=separate --exclude 'src/bench*' --exclude 'src/modules/.*/bench_impl.h' --print-summary
9696

9797
To create a HTML report with coloured and annotated source code:
9898

9999
$ mkdir -p coverage
100-
$ gcovr --exclude 'src/bench*' --html --html-details -o coverage/coverage.html
100+
$ gcovr --gcov-ignore-parse-errors=all --merge-mode-functions=separate --exclude 'src/bench*' --exclude 'src/modules/.*/bench_impl.h' --html --html-details -o coverage/coverage.html
101+
102+
On `gcovr` >=8.3, `--gcov-ignore-parse-errors=all` can be replaced with `--gcov-suspicious-hits-threshold=140737488355330`.
101103

102104
#### Exhaustive tests
103105

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,11 @@ To cross compile for Android with [NDK](https://developer.android.com/ndk/guides
135135
136136
### Building on Windows
137137
138-
To build on Windows with Visual Studio, a proper [generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators) must be specified for a new build tree.
139-
140-
The following example assumes using of Visual Studio 2022 and CMake v3.21+.
138+
The following example assumes Visual Studio 2022. Using clang-cl is recommended.
141139
142140
In "Developer Command Prompt for VS 2022":
143141
144-
>cmake -G "Visual Studio 17 2022" -A x64 -B build
142+
>cmake -B build -T ClangCL
145143
>cmake --build build --config RelWithDebInfo
146144
147145
Usage examples

build-aux/m4/bitcoin_secp.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ AC_DEFUN([SECP_X86_64_ASM_CHECK],[
33
AC_MSG_CHECKING(for x86_64 assembly availability)
44
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
55
#include <stdint.h>]],[[
6-
uint64_t a = 11, tmp;
6+
uint64_t a = 11, tmp = 0;
77
__asm__ __volatile__("movq \@S|@0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
88
]])], [has_x86_64_asm=yes], [has_x86_64_asm=no])
99
AC_MSG_RESULT([$has_x86_64_asm])

ci/linux-debian.Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ RUN dpkg --add-architecture i386 && \
1919
dpkg --add-architecture arm64 && \
2020
dpkg --add-architecture ppc64el
2121

22-
# dkpg-dev: to make pkg-config work in cross-builds
22+
# dpkg-dev: to make pkg-config work in cross-builds
2323
# llvm: for llvm-symbolizer, which is used by clang's UBSan for symbolized stack traces
24-
RUN apt-get update && apt-get install --no-install-recommends -y \
24+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
2525
git ca-certificates \
2626
make automake libtool pkg-config dpkg-dev valgrind qemu-user \
2727
gcc clang llvm libclang-rt-dev libc6-dbg \
@@ -34,14 +34,15 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
3434
gcc-mingw-w64-i686-win32 wine32 \
3535
python3-full && \
3636
if ! ( dpkg --print-architecture | grep --quiet "arm64" ) ; then \
37-
apt-get install --no-install-recommends -y \
37+
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
3838
gcc-aarch64-linux-gnu libc6-dev-arm64-cross libc6-dbg:arm64 ;\
3939
fi && \
4040
apt-get clean && rm -rf /var/lib/apt/lists/*
4141

4242
# Build and install gcc snapshot
4343
ARG GCC_SNAPSHOT_MAJOR=16
44-
RUN apt-get update && apt-get install --no-install-recommends -y wget libgmp-dev libmpfr-dev libmpc-dev flex && \
44+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
45+
wget libgmp-dev libmpfr-dev libmpc-dev flex && \
4546
mkdir gcc && cd gcc && \
4647
wget --progress=dot:giga --https-only --recursive --accept '*.tar.xz' --level 1 --no-directories "https://gcc.gnu.org/pub/gcc/snapshots/LATEST-${GCC_SNAPSHOT_MAJOR}" && \
4748
wget "https://gcc.gnu.org/pub/gcc/snapshots/LATEST-${GCC_SNAPSHOT_MAJOR}/sha512.sum" && \
@@ -62,15 +63,15 @@ RUN apt-get update && apt-get install --no-install-recommends -y wget libgmp-dev
6263
# Install clang snapshot, see https://apt.llvm.org/
6364
RUN \
6465
# Setup GPG keys of LLVM repository
65-
apt-get update && apt-get install --no-install-recommends -y wget && \
66+
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y wget && \
6667
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
6768
# Add repository for this Debian release
6869
. /etc/os-release && echo "deb http://apt.llvm.org/${VERSION_CODENAME} llvm-toolchain-${VERSION_CODENAME} main" >> /etc/apt/sources.list && \
6970
apt-get update && \
7071
# Determine the version number of the LLVM development branch
7172
LLVM_VERSION=$(apt-cache search --names-only '^clang-[0-9]+$' | sort -V | tail -1 | cut -f1 -d" " | cut -f2 -d"-" ) && \
7273
# Install
73-
apt-get install --no-install-recommends -y "clang-${LLVM_VERSION}" && \
74+
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y "clang-${LLVM_VERSION}" "libclang-rt-${LLVM_VERSION}-dev" && \
7475
# Create symlink
7576
ln -s "/usr/bin/clang-${LLVM_VERSION}" /usr/bin/clang-snapshot && \
7677
# Clean up

cmake/CheckX86_64Assembly.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ function(check_x86_64_assembly)
44
check_c_source_compiles("
55
#include <stdint.h>
66
7-
int main()
7+
int main(void)
88
{
9-
uint64_t a = 11, tmp;
9+
uint64_t a = 11, tmp = 0;
1010
__asm__ __volatile__(\"movq $0x100000000,%1; mulq %%rsi\" : \"+a\"(a) : \"S\"(tmp) : \"cc\", \"%rdx\");
11+
return 0;
1112
}
1213
" HAVE_X86_64_ASM)
1314
set(HAVE_X86_64_ASM ${HAVE_X86_64_ASM} PARENT_SCOPE)

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ AC_ARG_ENABLE(benchmark,
144144
[SECP_SET_DEFAULT([enable_benchmark], [yes], [yes])])
145145

146146
AC_ARG_ENABLE(coverage,
147-
AS_HELP_STRING([--enable-coverage],[enable compiler flags to support kcov coverage analysis [default=no]]), [],
147+
AS_HELP_STRING([--enable-coverage],[enable coverage analysis support [default=no]]), [],
148148
[SECP_SET_DEFAULT([enable_coverage], [no], [no])])
149149

150150
AC_ARG_ENABLE(tests,

0 commit comments

Comments
 (0)