Skip to content

Commit 17fc46c

Browse files
authored
Merge branch 'bitcoin-core:master' into simd
2 parents 72c5cf1 + b9313c6 commit 17fc46c

File tree

8 files changed

+92
-53
lines changed

8 files changed

+92
-53
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,11 @@ jobs:
652652
653653
- name: Symbol check
654654
if: ${{ matrix.configuration.symbol_check }}
655+
shell: bash
655656
run: |
656657
py -3 --version
657658
py -3 -m pip install lief
658-
py -3 .\tools\symbol-check.py build\bin\RelWithDebInfo\libsecp256k1-5.dll
659+
py -3 ./tools/symbol-check.py build/bin/RelWithDebInfo/libsecp256k1-*.dll
659660
660661
- name: Check
661662
run: |

CHANGELOG.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.7.0] - 2025-07-21
11+
12+
#### Added
13+
- CMake: Added `secp256k1_objs` interface library to allow parent projects to embed libsecp256k1 object files into their own static libraries.
14+
- build: Added `SECP256K1_NO_API_VISIBILITY_ATTRIBUTES` preprocessor flag (CMake option: `SECP256K1_ENABLE_API_VISIBILITY_ATTRIBUTES`) that disables explicit "visibility" attributes for API symbols. Defining this macro enables the user to control the visibility of the API symbols via `-fvisibility=<value>` when building libsecp256k1. (All non-API declarations will always have hidden visibility, even with `SECP256K1_ENABLE_API_VISIBILITY_ATTRIBUTES` defined.) For instance, `-fvisibility=hidden` can be useful even for the API symbols, e.g., when building a static libsecp256k1 which is linked into a shared library, and the latter should not re-export the libsecp256k1 API.
15+
16+
#### Changed
17+
- The pointers `secp256k1_context_static` and `secp256k1_context_no_precomp` to the constant context objects are now `const`.
18+
- Removed `SECP256K1_WARN_UNUSED_RESULT` attribute (defined as `__attribute__ ((__warn_unused_result__))`) from several API functions that always return 1. Compilers will no longer warn if the return value is unused.
19+
- CMake: Building with CMake is no longer considered experimental.
20+
- CMake: The minimum required CMake version was increased to 3.22.
21+
- CMake: Shared libraries built with CMake on FreeBSD now create the full versioned filename and symlink chain, matching the behavior of autotools builds.
22+
1023
#### Removed
1124
- Removed previously deprecated function aliases `secp256k1_ec_privkey_negate`, `secp256k1_ec_privkey_tweak_add` and
1225
`secp256k1_ec_privkey_tweak_mul`. Use `secp256k1_ec_seckey_negate`, `secp256k1_ec_seckey_tweak_add` and
1326
`secp256k1_ec_seckey_tweak_mul` instead.
1427

28+
#### ABI Compatibility
29+
The symbols `secp256k1_ec_privkey_negate`, `secp256k1_ec_privkey_tweak_add`, and `secp256k1_ec_privkey_tweak_mul` were removed.
30+
The pointers `secp256k1_context_static` and `secp256k1_context_no_precomp` have been made `const`.
31+
Otherwise, the library maintains backward compatibility with version 0.6.0.
32+
1533
## [0.6.0] - 2024-11-04
1634

1735
#### Added
@@ -169,7 +187,8 @@ This version was in fact never released.
169187
The number was given by the build system since the introduction of autotools in Jan 2014 (ea0fe5a5bf0c04f9cc955b2966b614f5f378c6f6).
170188
Therefore, this version number does not uniquely identify a set of source files.
171189

172-
[unreleased]: https://github.com/bitcoin-core/secp256k1/compare/v0.6.0...HEAD
190+
[unreleased]: https://github.com/bitcoin-core/secp256k1/compare/v0.7.0...HEAD
191+
[0.7.0]: https://github.com/bitcoin-core/secp256k1/compare/v0.6.0...v0.7.0
173192
[0.6.0]: https://github.com/bitcoin-core/secp256k1/compare/v0.5.1...v0.6.0
174193
[0.5.1]: https://github.com/bitcoin-core/secp256k1/compare/v0.5.0...v0.5.1
175194
[0.5.0]: https://github.com/bitcoin-core/secp256k1/compare/v0.4.1...v0.5.0

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ project(libsecp256k1
77
# The package (a.k.a. release) version is based on semantic versioning 2.0.0 of
88
# the API. All changes in experimental modules are treated as
99
# backwards-compatible and therefore at most increase the minor version.
10-
VERSION 0.6.1
10+
VERSION 0.7.1
1111
DESCRIPTION "Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1."
1212
HOMEPAGE_URL "https://github.com/bitcoin-core/secp256k1"
1313
LANGUAGES C
@@ -21,7 +21,7 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
2121
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
2222
# All changes in experimental modules are treated as if they don't affect the
2323
# interface and therefore only increase the revision.
24-
set(${PROJECT_NAME}_LIB_VERSION_CURRENT 5)
24+
set(${PROJECT_NAME}_LIB_VERSION_CURRENT 6)
2525
set(${PROJECT_NAME}_LIB_VERSION_REVISION 1)
2626
set(${PROJECT_NAME}_LIB_VERSION_AGE 0)
2727

@@ -42,6 +42,8 @@ endif()
4242

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

45+
option(SECP256K1_ENABLE_API_VISIBILITY_ATTRIBUTES "Enable visibility attributes in the API." ON)
46+
4547
## Modules
4648

4749
# We declare all options before processing them, to make sure we can express
@@ -312,6 +314,7 @@ else()
312314
set(cross_status "FALSE")
313315
endif()
314316
message("Cross compiling ....................... ${cross_status}")
317+
message("API visibility attributes ............. ${SECP256K1_ENABLE_API_VISIBILITY_ATTRIBUTES}")
315318
message("Valgrind .............................. ${SECP256K1_VALGRIND}")
316319
get_directory_property(definitions COMPILE_DEFINITIONS)
317320
string(REPLACE ";" " " definitions "${definitions}")

ci/ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ then
113113
case "$HOST" in
114114
*mingw*)
115115
ls -l .libs
116-
python3 ./tools/symbol-check.py .libs/libsecp256k1-5.dll
116+
python3 ./tools/symbol-check.py .libs/libsecp256k1-*.dll
117117
;;
118118
*)
119119
python3 ./tools/symbol-check.py .libs/libsecp256k1.so

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ AC_PREREQ([2.60])
44
# the API. All changes in experimental modules are treated as
55
# backwards-compatible and therefore at most increase the minor version.
66
define(_PKG_VERSION_MAJOR, 0)
7-
define(_PKG_VERSION_MINOR, 6)
7+
define(_PKG_VERSION_MINOR, 7)
88
define(_PKG_VERSION_PATCH, 1)
99
define(_PKG_VERSION_IS_RELEASE, false)
1010

@@ -13,7 +13,7 @@ define(_PKG_VERSION_IS_RELEASE, false)
1313
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
1414
# All changes in experimental modules are treated as if they don't affect the
1515
# interface and therefore only increase the revision.
16-
define(_LIB_VERSION_CURRENT, 5)
16+
define(_LIB_VERSION_CURRENT, 6)
1717
define(_LIB_VERSION_REVISION, 1)
1818
define(_LIB_VERSION_AGE, 0)
1919

include/secp256k1.h

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -121,45 +121,57 @@ typedef int (*secp256k1_nonce_function)(
121121
#endif
122122

123123
/* Symbol visibility. */
124-
#if defined(_WIN32)
125-
/* GCC for Windows (e.g., MinGW) accepts the __declspec syntax
126-
* for MSVC compatibility. A __declspec declaration implies (but is not
127-
* exactly equivalent to) __attribute__ ((visibility("default"))), and so we
128-
* actually want __declspec even on GCC, see "Microsoft Windows Function
129-
* Attributes" in the GCC manual and the recommendations in
130-
* https://gcc.gnu.org/wiki/Visibility. */
131-
# if defined(SECP256K1_BUILD)
132-
# if defined(DLL_EXPORT) || defined(SECP256K1_DLL_EXPORT)
133-
/* Building libsecp256k1 as a DLL.
134-
* 1. If using Libtool, it defines DLL_EXPORT automatically.
135-
* 2. In other cases, SECP256K1_DLL_EXPORT must be defined. */
136-
# define SECP256K1_API extern __declspec (dllexport)
137-
# else
138-
/* Building libsecp256k1 as a static library on Windows.
139-
* No declspec is needed, and so we would want the non-Windows-specific
140-
* logic below take care of this case. However, this may result in setting
141-
* __attribute__ ((visibility("default"))), which is supposed to be a noop
142-
* on Windows but may trigger warnings when compiling with -flto due to a
143-
* bug in GCC, see
144-
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116478 . */
145-
# define SECP256K1_API extern
146-
# endif
147-
/* The user must define SECP256K1_STATIC when consuming libsecp256k1 as a static
148-
* library on Windows. */
149-
# elif !defined(SECP256K1_STATIC)
150-
/* Consuming libsecp256k1 as a DLL. */
151-
# define SECP256K1_API extern __declspec (dllimport)
152-
# endif
124+
#if !defined(SECP256K1_API) && defined(SECP256K1_NO_API_VISIBILITY_ATTRIBUTES)
125+
/* The user has requested that we don't specify visibility attributes in
126+
* the public API.
127+
*
128+
* Since all our non-API declarations use the static qualifier, this means
129+
* that the user can use -fvisibility=<value> to set the visibility of the
130+
* API symbols. For instance, -fvisibility=hidden can be useful *even for
131+
* the API symbols*, e.g., when building a static library which is linked
132+
* into a shared library, and the latter should not re-export the
133+
* libsecp256k1 API.
134+
*
135+
* While visibility is a concept that applies only to shared libraries,
136+
* setting visibility will still make a difference when building a static
137+
* library: the visibility settings will be stored in the static library,
138+
* solely for the potential case that the static library will be linked into
139+
* a shared library. In that case, the stored visibility settings will
140+
* resurface and be honored for the shared library. */
141+
# define SECP256K1_API extern
153142
#endif
154-
#ifndef SECP256K1_API
155-
/* All cases not captured by the Windows-specific logic. */
156-
# if defined(__GNUC__) && (__GNUC__ >= 4) && defined(SECP256K1_BUILD)
157-
/* Building libsecp256k1 using GCC or compatible. */
158-
# define SECP256K1_API extern __attribute__ ((visibility ("default")))
159-
# else
160-
/* Fall back to standard C's extern. */
161-
# define SECP256K1_API extern
162-
# endif
143+
#if !defined(SECP256K1_API)
144+
# if defined(SECP256K1_BUILD)
145+
/* On Windows, assume a shared library only if explicitly requested.
146+
* 1. If using Libtool, it defines DLL_EXPORT automatically.
147+
* 2. In other cases, SECP256K1_DLL_EXPORT must be defined. */
148+
# if defined(_WIN32) && (defined(SECP256K1_DLL_EXPORT) || defined(DLL_EXPORT))
149+
/* GCC for Windows (e.g., MinGW) accepts the __declspec syntax for
150+
* MSVC compatibility. A __declspec declaration implies (but is not
151+
* exactly equivalent to) __attribute__ ((visibility("default"))),
152+
* and so we actually want __declspec even on GCC, see "Microsoft
153+
* Windows Function Attributes" in the GCC manual and the
154+
* recommendations in https://gcc.gnu.org/wiki/Visibility . */
155+
# define SECP256K1_API extern __declspec(dllexport)
156+
/* Avoid __attribute__ ((visibility("default"))) on Windows to get rid
157+
* of warnings when compiling with -flto due to a bug in GCC, see
158+
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116478 . */
159+
# elif !defined(_WIN32) && defined (__GNUC__) && (__GNUC__ >= 4)
160+
# define SECP256K1_API extern __attribute__ ((visibility("default")))
161+
# else
162+
# define SECP256K1_API extern
163+
# endif
164+
# else
165+
/* On Windows, SECP256K1_STATIC must be defined when consuming
166+
* libsecp256k1 as a static library. Note that SECP256K1_STATIC is a
167+
* "consumer-only" macro, and it has no meaning when building
168+
* libsecp256k1. */
169+
# if defined(_WIN32) && !defined(SECP256K1_STATIC)
170+
# define SECP256K1_API extern __declspec(dllimport)
171+
# else
172+
# define SECP256K1_API extern
173+
# endif
174+
# endif
163175
#endif
164176

165177
/* Warning attributes

src/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ add_library(secp256k1_precomputed OBJECT EXCLUDE_FROM_ALL
5454
# from being exported.
5555
target_sources(secp256k1 PRIVATE secp256k1.c $<TARGET_OBJECTS:secp256k1_precomputed>)
5656

57+
if(NOT SECP256K1_ENABLE_API_VISIBILITY_ATTRIBUTES)
58+
target_compile_definitions(secp256k1 PRIVATE SECP256K1_NO_API_VISIBILITY_ATTRIBUTES)
59+
endif()
60+
5761
# Create a helper lib that parent projects can use to link secp256k1 into a
5862
# static lib.
5963
add_library(secp256k1_objs INTERFACE)
@@ -86,7 +90,8 @@ target_include_directories(secp256k1 INTERFACE
8690
$<BUILD_INTERFACE:$<$<NOT:$<BOOL:${PROJECT_IS_TOP_LEVEL}>>:${PROJECT_SOURCE_DIR}/include>>
8791
)
8892
set_target_properties(secp256k1_objs PROPERTIES
89-
INTERFACE_INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:secp256k1,INTERFACE_INCLUDE_DIRECTORIES>"
93+
INTERFACE_COMPILE_DEFINITIONS "$<TARGET_PROPERTY:secp256k1,INTERFACE_COMPILE_DEFINITIONS>"
94+
INTERFACE_INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:secp256k1,INTERFACE_INCLUDE_DIRECTORIES>"
9095
)
9196

9297
# This emulates Libtool to make sure Libtool and CMake agree on the ABI version,

src/modules/musig/tests_impl.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -910,12 +910,15 @@ static void musig_test_vectors_signverify(void) {
910910
* the signing key does not belong to any pubkey. */
911911
continue;
912912
}
913+
913914
expected = c->error != MUSIG_PUBKEY;
914915
CHECK(expected == musig_vectors_keyagg_and_tweak(&error, &keyagg_cache, NULL, vector->pubkeys, NULL, c->key_indices_len, c->key_indices, 0, NULL, NULL));
915916
CHECK(expected || c->error == error);
916917
if (!expected) {
917918
continue;
918919
}
920+
CHECK(secp256k1_ec_pubkey_parse(CTX, &pubkey, vector->pubkeys[0], sizeof(vector->pubkeys[0])));
921+
CHECK(secp256k1_keypair_create(CTX, &keypair, vector->sk));
919922

920923
expected = c->error != MUSIG_AGGNONCE;
921924
CHECK(expected == secp256k1_musig_aggnonce_parse(CTX, &aggnonce, vector->aggnonces[c->aggnonce_index]));
@@ -924,14 +927,10 @@ static void musig_test_vectors_signverify(void) {
924927
}
925928
CHECK(secp256k1_musig_nonce_process(CTX, &session, &aggnonce, vector->msgs[c->msg_index], &keyagg_cache));
926929

927-
CHECK(secp256k1_ec_pubkey_parse(CTX, &pubkey, vector->pubkeys[0], sizeof(vector->pubkeys[0])));
928-
musig_test_set_secnonce(&secnonce, vector->secnonces[c->secnonce_index], &pubkey);
929930
expected = c->error != MUSIG_SECNONCE;
930-
if (expected) {
931-
CHECK(secp256k1_musig_partial_sign(CTX, &partial_sig, &secnonce, &keypair, &keyagg_cache, &session));
932-
} else {
933-
CHECK_ILLEGAL(CTX, secp256k1_musig_partial_sign(CTX, &partial_sig, &secnonce, &keypair, &keyagg_cache, &session));
934-
}
931+
CHECK(!expected);
932+
musig_test_set_secnonce(&secnonce, vector->secnonces[c->secnonce_index], &pubkey);
933+
CHECK_ILLEGAL(CTX, secp256k1_musig_partial_sign(CTX, &partial_sig, &secnonce, &keypair, &keyagg_cache, &session));
935934
}
936935
for (i = 0; i < sizeof(vector->verify_fail_case)/sizeof(vector->verify_fail_case[0]); i++) {
937936
const struct musig_verify_fail_error_case *c = &vector->verify_fail_case[i];

0 commit comments

Comments
 (0)