Skip to content

Commit 05145db

Browse files
sipajanus
authored andcommitted
Squashed 'src/secp256k1/' changes from bdf39000b9..4258c54f4e
4258c54f4e Merge bitcoin-core/secp256k1#1276: autotools: Don't regenerate Wycheproof header automatically 06c67dea9f autotools: Don't regenerate Wycheproof header automatically 3bab71cf05 Merge bitcoin-core/secp256k1#1268: release cleanup: bump version after 0.3.1 656c6ea8d8 release cleanup: bump version after 0.3.1 346a053d4c Merge bitcoin-core/secp256k1#1269: changelog: Fix link 6a37b2a5ea changelog: Fix link ec98fcedd5 Merge bitcoin-core/secp256k1#1266: release: Prepare for 0.3.1 898e1c676e release: Prepare for 0.3.1 1d9a13fc26 changelog: Remove inconsistent newlines 0e091669a1 changelog: Catch up in preparation of 0.3.1 7b7503dac5 Merge bitcoin-core/secp256k1#1245: tests: Add Wycheproof ECDSA vectors 145078c418 Merge bitcoin-core/secp256k1#1118: Add x-only ecmult_const version with x specified as n/d e5de454609 tests: Add Wycheproof ECDSA vectors 0f8642079b Add exhaustive tests for ecmult_const_xonly 4485926ace Add x-only ecmult_const version for x=n/d a0f4644f7e Merge bitcoin-core/secp256k1#1252: Make position of * in pointer declarations in include/ consistent 4e682626a3 Merge bitcoin-core/secp256k1#1226: Add CMake instructions to release process 2d51a454fc Merge bitcoin-core/secp256k1#1257: ct: Use volatile "trick" in all fe/scalar cmov implementations 4a496a36fb ct: Use volatile "trick" in all fe/scalar cmov implementations 3d1f430f9f Make position of * in pointer declarations in include/ consistent 2bca0a5cbf Merge bitcoin-core/secp256k1#1241: build: Improve `SECP_TRY_APPEND_DEFAULT_CFLAGS` macro afd8b23b27 Merge bitcoin-core/secp256k1#1244: Suppress `-Wunused-parameter` when building for coverage analysis 1d8f367515 Merge bitcoin-core/secp256k1#1250: No need to subtract 1 before doing a right shift 3e43041be6 No need to subtract 1 before doing a right shift 3addb4c1e8 build: Improve `SECP_TRY_APPEND_DEFAULT_CFLAGS` macro 0c07c82834 Add CMake instructions to release process 464a9115b4 Merge bitcoin-core/secp256k1#1242: Set ARM ASM symbol visibility to `hidden` f16a709fd6 Merge bitcoin-core/secp256k1#1247: Apply Checks only in VERIFY mode. 70be3cade5 Merge bitcoin-core/secp256k1#1246: Typo 4ebd82852d Apply Checks only in VERIFY mode. d1e7ca192d Typo 5bb03c2911 Replace `SECP256K1_ECMULT_TABLE_VERIFY` macro by a function 9c8c4f443c Merge bitcoin-core/secp256k1#1238: build: bump CMake minimum requirement to 3.13 0cf2fb91ef Merge bitcoin-core/secp256k1#1243: build: Ensure no optimization when building for coverage analysis fd2a408647 Set ARM ASM symbol visibility to `hidden` 4429a8c218 Suppress `-Wunused-parameter` when building for coverage analysis 8e79c7ed11 build: Ensure no optimization when building for coverage analysis 96dd062511 build: bump CMake minimum requirement to 3.13 427bc3cdcf Merge bitcoin-core/secp256k1#1236: Update comment for secp256k1_modinv32_inv256 647f0a5cb1 Update comment for secp256k1_modinv32_inv256 5658209459 Merge bitcoin-core/secp256k1#1228: release cleanup: bump version after 0.3.0 28e63f7ea7 release cleanup: bump version after 0.3.0 git-subtree-dir: src/secp256k1 git-subtree-split: 4258c54f4ebfc09390168e8a43306c46b315134b
1 parent e096f65 commit 05145db

29 files changed

+8745
-136
lines changed

CHANGELOG.md

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

88
## [Unreleased]
99

10+
## [0.3.1] - 2023-04-10
11+
We strongly recommend updating to 0.3.1 if you use or plan to use Clang >=14 to compile libsecp256k1, e.g., Xcode >=14 on macOS has Clang >=14. When in doubt, check the Clang version using `clang -v`.
12+
13+
#### Security
14+
- Fix "constant-timeness" issue with Clang >=14 that could leave applications using libsecp256k1 vulnerable to a timing side-channel attack. The fix avoids secret-dependent control flow and secret-dependent memory accesses in conditional moves of memory objects when libsecp256k1 is compiled with Clang >=14.
15+
16+
#### Added
17+
- Added tests against [Project Wycheproof's](https://github.com/google/wycheproof/) set of ECDSA test vectors (Bitcoin "low-S" variant), a fixed set of test cases designed to trigger various edge cases.
18+
19+
#### Changed
20+
- Increased minimum required CMake version to 3.13. CMake builds remain experimental.
21+
22+
#### ABI Compatibility
23+
The ABI is compatible with version 0.3.0.
24+
1025
## [0.3.0] - 2023-03-08
1126

1227
#### Added
@@ -25,7 +40,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2540
- Removed the configuration header `src/libsecp256k1-config.h`. We recommend passing flags to `./configure` or `cmake` to set configuration options (see `./configure --help` or `cmake -LH`). If you cannot or do not want to use one of the supported build systems, pass configuration flags such as `-DSECP256K1_ENABLE_MODULE_SCHNORRSIG` manually to the compiler (see the file `configure.ac` for supported flags).
2641

2742
#### ABI Compatibility
28-
2943
Due to changes in the API regarding `secp256k1_context_static` described above, the ABI is *not* compatible with previous versions.
3044

3145
## [0.2.0] - 2022-12-12
@@ -45,7 +59,6 @@ Due to changes in the API regarding `secp256k1_context_static` described above,
4559
- Module `schnorrsig`: renamed `secp256k1_schnorrsig_sign` to `secp256k1_schnorrsig_sign32`.
4660

4761
#### ABI Compatibility
48-
4962
Since this is the first release, we do not compare application binary interfaces.
5063
However, there are earlier unreleased versions of libsecp256k1 that are *not* ABI compatible with this version.
5164

@@ -55,7 +68,8 @@ This version was in fact never released.
5568
The number was given by the build system since the introduction of autotools in Jan 2014 (ea0fe5a5bf0c04f9cc955b2966b614f5f378c6f6).
5669
Therefore, this version number does not uniquely identify a set of source files.
5770

58-
[unreleased]: https://github.com/bitcoin-core/secp256k1/compare/v0.3.0...HEAD
71+
[unreleased]: https://github.com/bitcoin-core/secp256k1/compare/v0.3.1...HEAD
72+
[0.3.1]: https://github.com/bitcoin-core/secp256k1/compare/v0.3.0...v0.3.1
5973
[0.3.0]: https://github.com/bitcoin-core/secp256k1/compare/v0.2.0...v0.3.0
6074
[0.2.0]: https://github.com/bitcoin-core/secp256k1/compare/423b6d19d373f1224fd671a982584d7e7900bc93..v0.2.0
6175
[0.1.0]: https://github.com/bitcoin-core/secp256k1/commit/423b6d19d373f1224fd671a982584d7e7900bc93

CMakeLists.txt

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.1)
1+
cmake_minimum_required(VERSION 3.13)
22

33
if(CMAKE_VERSION VERSION_GREATER 3.14)
44
# MSVC runtime library flags are selected by the CMAKE_MSVC_RUNTIME_LIBRARY abstraction.
@@ -10,15 +10,15 @@ endif()
1010
# The package (a.k.a. release) version is based on semantic versioning 2.0.0 of
1111
# the API. All changes in experimental modules are treated as
1212
# backwards-compatible and therefore at most increase the minor version.
13-
project(libsecp256k1 VERSION 0.3.0 LANGUAGES C)
13+
project(libsecp256k1 VERSION 0.3.2 LANGUAGES C)
1414

1515
# The library version is based on libtool versioning of the ABI. The set of
1616
# rules for updating the version can be found here:
1717
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
1818
# All changes in experimental modules are treated as if they don't affect the
1919
# interface and therefore only increase the revision.
2020
set(${PROJECT_NAME}_LIB_VERSION_CURRENT 2)
21-
set(${PROJECT_NAME}_LIB_VERSION_REVISION 0)
21+
set(${PROJECT_NAME}_LIB_VERSION_REVISION 2)
2222
set(${PROJECT_NAME}_LIB_VERSION_AGE 0)
2323

2424
set(CMAKE_C_STANDARD 90)
@@ -147,7 +147,7 @@ else()
147147
endif()
148148

149149
# Define custom "Coverage" build type.
150-
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O0 -DCOVERAGE=1 --coverage -Wno-unused-parameter" CACHE STRING
150+
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O0 -DCOVERAGE=1 --coverage" CACHE STRING
151151
"Flags used by the C compiler during \"Coverage\" builds."
152152
FORCE
153153
)
@@ -203,11 +203,6 @@ else()
203203
try_add_compile_option(-Wundef)
204204
endif()
205205

206-
if(CMAKE_VERSION VERSION_GREATER 3.2)
207-
# Honor visibility properties for all target types.
208-
# See: https://cmake.org/cmake/help/latest/policy/CMP0063.html
209-
cmake_policy(SET CMP0063 NEW)
210-
endif()
211206
set(CMAKE_C_VISIBILITY_PRESET hidden)
212207

213208
# Ask CTest to create a "check" target (e.g., make check) as alias for the "test" target.

Makefile.am

+17
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,20 @@ if TARGET_LINUX
449449
$(AM_V_at) CC='$(CC)' CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_ELF
450450
$(AM_V_at) CC='$(CC)' CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_ELF
451451
endif
452+
453+
EXTRA_DIST += src/wycheproof/WYCHEPROOF_COPYING
454+
EXTRA_DIST += src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h
455+
EXTRA_DIST += src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json
456+
EXTRA_DIST += tools/tests_wycheproof_generate.py
457+
458+
TESTVECTORS = src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h
459+
460+
src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h:
461+
python3 tools/tests_wycheproof_generate.py src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json > $@
462+
463+
testvectors: $(TESTVECTORS)
464+
465+
maintainer-clean-testvectors: clean-testvectors
466+
467+
clean-testvectors:
468+
rm -f $(TESTVECTORS)

configure.ac

+24-12
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ AC_PREREQ([2.60])
55
# backwards-compatible and therefore at most increase the minor version.
66
define(_PKG_VERSION_MAJOR, 0)
77
define(_PKG_VERSION_MINOR, 3)
8-
define(_PKG_VERSION_PATCH, 0)
9-
define(_PKG_VERSION_IS_RELEASE, true)
8+
define(_PKG_VERSION_PATCH, 2)
9+
define(_PKG_VERSION_IS_RELEASE, false)
1010

1111
# The library version is based on libtool versioning of the ABI. The set of
1212
# rules for updating the version can be found here:
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.
1616
define(_LIB_VERSION_CURRENT, 2)
17-
define(_LIB_VERSION_REVISION, 0)
17+
define(_LIB_VERSION_REVISION, 2)
1818
define(_LIB_VERSION_AGE, 0)
1919

2020
AC_INIT([libsecp256k1],m4_join([.], _PKG_VERSION_MAJOR, _PKG_VERSION_MINOR, _PKG_VERSION_PATCH)m4_if(_PKG_VERSION_IS_RELEASE, [true], [], [-dev]),[https://github.com/bitcoin-core/secp256k1/issues],[libsecp256k1],[https://github.com/bitcoin-core/secp256k1])
@@ -659,11 +659,14 @@ AC_ARG_ENABLE([util-wallet],
659659
[build_BGL_wallet=$enableval],
660660
[build_BGL_wallet=$build_BGL_utils])
661661

662-
AC_ARG_ENABLE([util-util],
663-
[AS_HELP_STRING([--enable-util-util],
664-
[build BGL-util])],
665-
[build_BGL_util=$enableval],
666-
[build_BGL_util=$build_BGL_utils])
662+
if test "${CFLAGS+set}" = "set"; then
663+
CFLAGS_overridden=yes
664+
else
665+
CFLAGS_overridden=no
666+
fi
667+
AC_PROG_CC
668+
AM_PROG_AS
669+
AM_PROG_AR
667670

668671
AC_ARG_ENABLE([experimental-util-chainstate],
669672
[AS_HELP_STRING([--enable-experimental-util-chainstate],
@@ -860,11 +863,14 @@ esac
860863
AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [
861864
# GCC and compatible (incl. clang)
862865
if test "x$GCC" = "xyes"; then
863-
# Try to append -Werror=unknown-warning-option to CFLAGS temporarily. Otherwise clang will
864-
# not error out if it gets unknown warning flags and the checks here will always succeed
865-
# no matter if clang knows the flag or not.
866+
# Try to append -Werror to CFLAGS temporarily. Otherwise checks for some unsupported
867+
# flags will succeed.
868+
# Note that failure to append -Werror does not necessarily mean that -Werror is not
869+
# supported. The compiler may already be warning about something unrelated, for example
870+
# about some path issue. If that is the case, -Werror cannot be used because all
871+
# of those warnings would be turned into errors.
866872
SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS="$CFLAGS"
867-
SECP_TRY_APPEND_CFLAGS([-Werror=unknown-warning-option], CFLAGS)
873+
SECP_TRY_APPEND_CFLAGS([-Werror], CFLAGS)
868874
869875
SECP_TRY_APPEND_CFLAGS([-std=c89 -pedantic -Wno-long-long -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef], $1) # GCC >= 3.0, -Wlong-long is implied by -pedantic.
870876
SECP_TRY_APPEND_CFLAGS([-Wno-overlength-strings], $1) # GCC >= 4.2, -Woverlength-strings is implied by -pedantic.
@@ -1271,6 +1277,12 @@ fi
12711277
if test x"$enable_coverage" = x"yes"; then
12721278
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DCOVERAGE=1"
12731279
SECP_CFLAGS="-O0 --coverage $SECP_CFLAGS"
1280+
# If coverage is enabled, and the user has not overridden CFLAGS,
1281+
# override Autoconf's value "-g -O2" with "-g". Otherwise we'd end up
1282+
# with "-O0 --coverage -g -O2".
1283+
if test "$CFLAGS_overridden" = "no"; then
1284+
CFLAGS="-g"
1285+
fi
12741286
LDFLAGS="--coverage $LDFLAGS"
12751287
else
12761288
use_boost=yes

doc/release-process.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@ This process also assumes that there will be no minor releases for old major rel
1515
## Regular release
1616

1717
1. Open a PR to the master branch with a commit (using message `"release: prepare for $MAJOR.$MINOR.$PATCH"`, for example) that
18-
* finalizes the release notes in [CHANGELOG.md](../CHANGELOG.md) (make sure to include an entry for `### ABI Compatibility`) and
19-
* updates `_PKG_VERSION_*`, `_LIB_VERSION_*`, and sets `_PKG_VERSION_IS_RELEASE` to `true` in `configure.ac`.
18+
* finalizes the release notes in [CHANGELOG.md](../CHANGELOG.md) (make sure to include an entry for `### ABI Compatibility`),
19+
* updates `_PKG_VERSION_*` and `_LIB_VERSION_*` and sets `_PKG_VERSION_IS_RELEASE` to `true` in `configure.ac`, and
20+
* updates `project(libsecp256k1 VERSION ...)` and `${PROJECT_NAME}_LIB_VERSION_*` in `CMakeLists.txt`.
2021
2. After the PR is merged, tag the commit and push it:
2122
```
2223
RELEASE_COMMIT=<merge commit of step 1>
2324
git tag -s v$MAJOR.$MINOR.$PATCH -m "libsecp256k1 $MAJOR.$MINOR.$PATCH" $RELEASE_COMMIT
2425
git push [email protected]:bitcoin-core/secp256k1.git v$MAJOR.$MINOR.$PATCH
2526
```
26-
3. Open a PR to the master branch with a commit (using message `"release cleanup: bump version after $MAJOR.$MINOR.$PATCH"`, for example) that sets `_PKG_VERSION_IS_RELEASE` to `false` and `_PKG_VERSION_PATCH` to `$PATCH + 1` and increases `_LIB_VERSION_REVISION`. If other maintainers are not present to approve the PR, it can be merged without ACKs.
27+
3. Open a PR to the master branch with a commit (using message `"release cleanup: bump version after $MAJOR.$MINOR.$PATCH"`, for example) that
28+
* sets `_PKG_VERSION_IS_RELEASE` to `false` and increments `_PKG_VERSION_PATCH` and `_LIB_VERSION_REVISION` in `configure.ac`, and
29+
* increments the `$PATCH` component of `project(libsecp256k1 VERSION ...)` and `${PROJECT_NAME}_LIB_VERSION_REVISION` in `CMakeLists.txt`.
30+
31+
If other maintainers are not present to approve the PR, it can be merged without ACKs.
2732
4. Create a new GitHub release with a link to the corresponding entry in [CHANGELOG.md](../CHANGELOG.md).
2833

2934
## Maintenance release
@@ -38,7 +43,9 @@ Note that bugfixes only need to be backported to releases for which no compatibl
3843
2. Open a pull request to the `$MAJOR.$MINOR` branch that
3944
* includes the bugfixes,
4045
* finalizes the release notes,
41-
* bumps `_PKG_VERSION_PATCH` and `_LIB_VERSION_REVISION` in `configure.ac` (with commit message `"release: update PKG_ and LIB_VERSION for $MAJOR.$MINOR.$PATCH"`, for example).
46+
* increments `_PKG_VERSION_PATCH` and `_LIB_VERSION_REVISION` in `configure.ac`
47+
and the `$PATCH` component of `project(libsecp256k1 VERSION ...)` and `${PROJECT_NAME}_LIB_VERSION_REVISION` in `CMakeLists.txt`
48+
(with commit message `"release: bump versions for $MAJOR.$MINOR.$PATCH"`, for example).
4249
3. After the PRs are merged, update the release branch and tag the commit:
4350
```
4451
git checkout $MAJOR.$MINOR && git pull

src/int128_struct_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static SECP256K1_INLINE int secp256k1_i128_check_pow2(const secp256k1_int128 *r,
193193
VERIFY_CHECK(n < 127);
194194
VERIFY_CHECK(sign == 1 || sign == -1);
195195
return n >= 64 ? r->hi == (uint64_t)sign << (n - 64) && r->lo == 0
196-
: r->hi == (uint64_t)((sign - 1) >> 1) && r->lo == (uint64_t)sign << n;
196+
: r->hi == (uint64_t)(sign >> 1) && r->lo == (uint64_t)sign << n;
197197
}
198198

199199
#endif

src/secp256k1/ci/cirrus.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ fi
109109
# Rebuild precomputed files (if not cross-compiling).
110110
if [ -z "$HOST" ]
111111
then
112-
make clean-precomp
113-
make precomp
112+
make clean-precomp clean-testvectors
113+
make precomp testvectors
114114
fi
115115

116116
# Check that no repo files have been modified by the build.

0 commit comments

Comments
 (0)