Skip to content

Commit 61f942a

Browse files
committed
Squashed 'src/secp256k1/' changes from 21ffe4b22a..19262492ef
19262492ef Add doc/ellswift.md with ElligatorSwift explanation f3b0b08a19 Add ellswift testing to CI 7d852dd6a5 Add ElligatorSwift ctime tests f3a25cd7bc Add tests for ElligatorSwift 30b99876a4 Add ElligatorSwift benchmarks d2d47485a5 Add ellswift module implementing ElligatorSwift 4116a67dea Add functions to test if X coordinate is valid a5eb1a0fe9 Add benchmark for key generation 2e5a8dffed Add x-only ecmult_const version for x=n/d e65551e389 doc: Describe Jacobi calculation in safegcd_implementation.md bb146e5096 Native jacobi symbol algorithm 62eb12379c Make secp256k1_modinv64_det_check_pow2 support abs val 3a58861f0e Make secp256k1_i128_check_pow2 support -(2^n) 01b819a8c7 Merge bitcoin-core/secp256k1#1158: Add a secp256k1_i128_to_u64 function. eacad90f69 Merge bitcoin-core/secp256k1#1171: Change ARG_CHECK_NO_RETURN to ARG_CHECK_VOID which returns (void) 3f57b9f774 Merge bitcoin-core/secp256k1#1177: Some improvements to the changelog c30b889f17 Clarify that the ABI-incompatible versions are earlier 881fc33d0c Consistency in naming of modules 665ba77e79 Merge bitcoin-core/secp256k1#1178: Drop `src/libsecp256k1-config.h` 75d7b7f5ba Merge bitcoin-core/secp256k1#1154: ci: set -u in cirrus.sh to treat unset variables as an error 7a74688201 ci: add missing CFLAGS & CPPFLAGS variable to print_environment c2e0fdadeb ci: set -u in cirrus.sh to treat unset variables as an error 9c5a4d21bb Do not define unused `HAVE_VALGRIND` macro ad8647f548 Drop no longer relevant files from `.gitignore` b627ba7050 Remove dependency on `src/libsecp256k1-config.h` 9ecf8149a1 Reduce font size in changelog 2dc133a67f Add more changelog entries ac233e181a Add links to diffs to changelog cee8223ef6 Mention semantic versioning in changelog 9a8d65f07f Merge bitcoin-core/secp256k1#1174: release cleanup: bump version after 0.2.0 02ebc290f7 release cleanup: bump version after 0.2.0 b6b360efaf doc: improve message of cleanup commit a49e0940ad docs: Fix typo 2551cdac90 tests: Fix code formatting c635c1bfd5 Change ARG_CHECK_NO_RETURN to ARG_CHECK_VOID which returns (void) cf66f2357c refactor: Add helper function secp256k1_context_is_proper() d216475205 test secp256k1_i128_to_i64 4bc429019d Add a secp256k1_i128_to_u64 function. git-subtree-dir: src/secp256k1 git-subtree-split: 19262492ef5268ff1d76ba45cd1b8b2eaf6d40cd
1 parent 9d47e7b commit 61f942a

Some content is hidden

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

45 files changed

+2492
-200
lines changed

.cirrus.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
env:
22
### compiler options
33
HOST:
4+
WRAPPER_CMD:
45
# Specific warnings can be disabled with -Wno-error=foo.
56
# -pedantic-errors is not equivalent to -Werror=pedantic and thus not implied by -Werror according to the GCC manual.
67
WERROR_CFLAGS: -Werror -pedantic-errors
@@ -18,6 +19,7 @@ env:
1819
ECDH: no
1920
RECOVERY: no
2021
SCHNORRSIG: no
22+
ELLSWIFT: no
2123
### test options
2224
SECP256K1_TEST_ITERS:
2325
BENCH: yes
@@ -71,12 +73,12 @@ task:
7173
<< : *LINUX_CONTAINER
7274
matrix: &ENV_MATRIX
7375
- env: {WIDEMUL: int64, RECOVERY: yes}
74-
- env: {WIDEMUL: int64, ECDH: yes, SCHNORRSIG: yes}
76+
- env: {WIDEMUL: int64, ECDH: yes, SCHNORRSIG: yes, ELLSWIFT: yes}
7577
- env: {WIDEMUL: int128}
76-
- env: {WIDEMUL: int128_struct}
77-
- env: {WIDEMUL: int128, RECOVERY: yes, SCHNORRSIG: yes}
78+
- env: {WIDEMUL: int128_struct, ELLSWIFT: yes}
79+
- env: {WIDEMUL: int128, RECOVERY: yes, SCHNORRSIG: yes, ELLSWIFT: yes}
7880
- env: {WIDEMUL: int128, ECDH: yes, SCHNORRSIG: yes}
79-
- env: {WIDEMUL: int128, ASM: x86_64}
81+
- env: {WIDEMUL: int128, ASM: x86_64 , ELLSWIFT: yes}
8082
- env: { RECOVERY: yes, SCHNORRSIG: yes}
8183
- env: {BUILD: distcheck, WITH_VALGRIND: no, CTIMETEST: no, BENCH: no}
8284
- env: {CPPFLAGS: -DDETERMINISTIC}
@@ -150,6 +152,7 @@ task:
150152
ECDH: yes
151153
RECOVERY: yes
152154
SCHNORRSIG: yes
155+
ELLSWIFT: yes
153156
CTIMETEST: no
154157
<< : *MERGE_BASE
155158
test_script:
@@ -169,6 +172,7 @@ task:
169172
ECDH: yes
170173
RECOVERY: yes
171174
SCHNORRSIG: yes
175+
ELLSWIFT: yes
172176
CTIMETEST: no
173177
matrix:
174178
- env: {}
@@ -189,6 +193,7 @@ task:
189193
ECDH: yes
190194
RECOVERY: yes
191195
SCHNORRSIG: yes
196+
ELLSWIFT: yes
192197
CTIMETEST: no
193198
<< : *MERGE_BASE
194199
test_script:
@@ -206,6 +211,7 @@ task:
206211
ECDH: yes
207212
RECOVERY: yes
208213
SCHNORRSIG: yes
214+
ELLSWIFT: yes
209215
CTIMETEST: no
210216
<< : *MERGE_BASE
211217
test_script:
@@ -243,6 +249,7 @@ task:
243249
RECOVERY: yes
244250
EXPERIMENTAL: yes
245251
SCHNORRSIG: yes
252+
ELLSWIFT: yes
246253
CTIMETEST: no
247254
# Use a MinGW-w64 host to tell ./configure we're building for Windows.
248255
# This will detect some MinGW-w64 tools but then make will need only
@@ -282,6 +289,7 @@ task:
282289
ECDH: yes
283290
RECOVERY: yes
284291
SCHNORRSIG: yes
292+
ELLSWIFT: yes
285293
CTIMETEST: no
286294
matrix:
287295
- name: "Valgrind (memcheck)"
@@ -356,6 +364,7 @@ task:
356364
ECDH: yes
357365
RECOVERY: yes
358366
SCHNORRSIG: yes
367+
ELLSWIFT: yes
359368
<< : *MERGE_BASE
360369
test_script:
361370
- ./ci/cirrus.sh

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ coverage.*.html
4242
*.gcno
4343
*.gcov
4444

45-
src/libsecp256k1-config.h
46-
src/libsecp256k1-config.h.in
4745
build-aux/ar-lib
4846
build-aux/config.guess
4947
build-aux/config.sub
@@ -58,5 +56,4 @@ build-aux/m4/ltversion.m4
5856
build-aux/missing
5957
build-aux/compile
6058
build-aux/test-driver
61-
src/stamp-h1
6259
libsecp256k1.pc

CHANGELOG.md

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
11
# Changelog
22

3-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
47

58
## [Unreleased]
69

710
## [0.2.0] - 2022-12-12
811

9-
### Added
12+
#### Added
13+
- Added usage examples for common use cases in a new `examples/` directory.
1014
- Added `secp256k1_selftest`, to be used in conjunction with `secp256k1_context_static`.
15+
- Added support for 128-bit wide multiplication on MSVC for x86_64 and arm64, giving roughly a 20% speedup on those platforms.
1116

12-
### Changed
13-
- Enabled modules schnorrsig, extrakeys and ECDH by default in `./configure`.
17+
#### Changed
18+
- Enabled modules `schnorrsig`, `extrakeys` and `ecdh` by default in `./configure`.
19+
- The `secp256k1_nonce_function_rfc6979` nonce function, used by default by `secp256k1_ecdsa_sign`, now reduces the message hash modulo the group order to match the specification. This only affects improper use of ECDSA signing API.
1420

15-
### Deprecated
21+
#### Deprecated
1622
- Deprecated context flags `SECP256K1_CONTEXT_VERIFY` and `SECP256K1_CONTEXT_SIGN`. Use `SECP256K1_CONTEXT_NONE` instead.
1723
- Renamed `secp256k1_context_no_precomp` to `secp256k1_context_static`.
24+
- Module `schnorrsig`: renamed `secp256k1_schnorrsig_sign` to `secp256k1_schnorrsig_sign32`.
1825

19-
### ABI Compatibility
26+
#### ABI Compatibility
2027

2128
Since this is the first release, we do not compare application binary interfaces.
22-
However, there are unreleased versions of libsecp256k1 that are *not* ABI compatible with this version.
29+
However, there are earlier unreleased versions of libsecp256k1 that are *not* ABI compatible with this version.
2330

2431
## [0.1.0] - 2013-03-05 to 2021-12-25
2532

2633
This version was in fact never released.
2734
The number was given by the build system since the introduction of autotools in Jan 2014 (ea0fe5a5bf0c04f9cc955b2966b614f5f378c6f6).
2835
Therefore, this version number does not uniquely identify a set of source files.
36+
37+
[unreleased]: https://github.com/bitcoin-core/secp256k1/compare/v0.2.0...HEAD
38+
[0.2.0]: https://github.com/bitcoin-core/secp256k1/compare/423b6d19d373f1224fd671a982584d7e7900bc93..v0.2.0
39+
[0.1.0]: https://github.com/bitcoin-core/secp256k1/commit/423b6d19d373f1224fd671a982584d7e7900bc93

Makefile.am

+15-11
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ noinst_HEADERS += examples/random.h
7373
PRECOMPUTED_LIB = libsecp256k1_precomputed.la
7474
noinst_LTLIBRARIES = $(PRECOMPUTED_LIB)
7575
libsecp256k1_precomputed_la_SOURCES = src/precomputed_ecmult.c src/precomputed_ecmult_gen.c
76-
libsecp256k1_precomputed_la_CPPFLAGS = $(SECP_INCLUDES)
76+
libsecp256k1_precomputed_la_CPPFLAGS = $(SECP_INCLUDES) $(SECP_CONFIG_DEFINES)
7777

7878
if USE_EXTERNAL_ASM
7979
COMMON_LIB = libsecp256k1_common.la
@@ -92,7 +92,7 @@ endif
9292
endif
9393

9494
libsecp256k1_la_SOURCES = src/secp256k1.c
95-
libsecp256k1_la_CPPFLAGS = $(SECP_INCLUDES)
95+
libsecp256k1_la_CPPFLAGS = $(SECP_INCLUDES) $(SECP_CONFIG_DEFINES)
9696
libsecp256k1_la_LIBADD = $(SECP_LIBS) $(COMMON_LIB) $(PRECOMPUTED_LIB)
9797
libsecp256k1_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_CURRENT):$(LIB_VERSION_REVISION):$(LIB_VERSION_AGE)
9898

@@ -107,17 +107,17 @@ bench_SOURCES = src/bench.c
107107
bench_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB)
108108
bench_internal_SOURCES = src/bench_internal.c
109109
bench_internal_LDADD = $(SECP_LIBS) $(COMMON_LIB) $(PRECOMPUTED_LIB)
110-
bench_internal_CPPFLAGS = $(SECP_INCLUDES)
110+
bench_internal_CPPFLAGS = $(SECP_INCLUDES) $(SECP_CONFIG_DEFINES)
111111
bench_ecmult_SOURCES = src/bench_ecmult.c
112112
bench_ecmult_LDADD = $(SECP_LIBS) $(COMMON_LIB) $(PRECOMPUTED_LIB)
113-
bench_ecmult_CPPFLAGS = $(SECP_INCLUDES)
113+
bench_ecmult_CPPFLAGS = $(SECP_INCLUDES) $(SECP_CONFIG_DEFINES)
114114
endif
115115

116116
TESTS =
117117
if USE_TESTS
118118
noinst_PROGRAMS += tests
119119
tests_SOURCES = src/tests.c
120-
tests_CPPFLAGS = $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
120+
tests_CPPFLAGS = $(SECP_INCLUDES) $(SECP_TEST_INCLUDES) $(SECP_CONFIG_DEFINES)
121121
if VALGRIND_ENABLED
122122
tests_CPPFLAGS += -DVALGRIND
123123
noinst_PROGRAMS += valgrind_ctime_test
@@ -135,7 +135,7 @@ endif
135135
if USE_EXHAUSTIVE_TESTS
136136
noinst_PROGRAMS += exhaustive_tests
137137
exhaustive_tests_SOURCES = src/tests_exhaustive.c
138-
exhaustive_tests_CPPFLAGS = $(SECP_INCLUDES)
138+
exhaustive_tests_CPPFLAGS = $(SECP_INCLUDES) $(SECP_CONFIG_DEFINES)
139139
if !ENABLE_COVERAGE
140140
exhaustive_tests_CPPFLAGS += -DVERIFY
141141
endif
@@ -148,7 +148,7 @@ endif
148148
if USE_EXAMPLES
149149
noinst_PROGRAMS += ecdsa_example
150150
ecdsa_example_SOURCES = examples/ecdsa.c
151-
ecdsa_example_CPPFLAGS = -I$(top_srcdir)/include
151+
ecdsa_example_CPPFLAGS = -I$(top_srcdir)/include $(SECP_CONFIG_DEFINES)
152152
ecdsa_example_LDADD = libsecp256k1.la
153153
ecdsa_example_LDFLAGS = -static
154154
if BUILD_WINDOWS
@@ -158,7 +158,7 @@ TESTS += ecdsa_example
158158
if ENABLE_MODULE_ECDH
159159
noinst_PROGRAMS += ecdh_example
160160
ecdh_example_SOURCES = examples/ecdh.c
161-
ecdh_example_CPPFLAGS = -I$(top_srcdir)/include
161+
ecdh_example_CPPFLAGS = -I$(top_srcdir)/include $(SECP_CONFIG_DEFINES)
162162
ecdh_example_LDADD = libsecp256k1.la
163163
ecdh_example_LDFLAGS = -static
164164
if BUILD_WINDOWS
@@ -169,7 +169,7 @@ endif
169169
if ENABLE_MODULE_SCHNORRSIG
170170
noinst_PROGRAMS += schnorr_example
171171
schnorr_example_SOURCES = examples/schnorr.c
172-
schnorr_example_CPPFLAGS = -I$(top_srcdir)/include
172+
schnorr_example_CPPFLAGS = -I$(top_srcdir)/include $(SECP_CONFIG_DEFINES)
173173
schnorr_example_LDADD = libsecp256k1.la
174174
schnorr_example_LDFLAGS = -static
175175
if BUILD_WINDOWS
@@ -184,11 +184,11 @@ EXTRA_PROGRAMS = precompute_ecmult precompute_ecmult_gen
184184
CLEANFILES = $(EXTRA_PROGRAMS)
185185

186186
precompute_ecmult_SOURCES = src/precompute_ecmult.c
187-
precompute_ecmult_CPPFLAGS = $(SECP_INCLUDES)
187+
precompute_ecmult_CPPFLAGS = $(SECP_INCLUDES) $(SECP_CONFIG_DEFINES)
188188
precompute_ecmult_LDADD = $(SECP_LIBS) $(COMMON_LIB)
189189

190190
precompute_ecmult_gen_SOURCES = src/precompute_ecmult_gen.c
191-
precompute_ecmult_gen_CPPFLAGS = $(SECP_INCLUDES)
191+
precompute_ecmult_gen_CPPFLAGS = $(SECP_INCLUDES) $(SECP_CONFIG_DEFINES)
192192
precompute_ecmult_gen_LDADD = $(SECP_LIBS) $(COMMON_LIB)
193193

194194
# See Automake manual, Section "Errors with distclean".
@@ -241,3 +241,7 @@ endif
241241
if ENABLE_MODULE_SCHNORRSIG
242242
include src/modules/schnorrsig/Makefile.am.include
243243
endif
244+
245+
if ENABLE_MODULE_ELLSWIFT
246+
include src/modules/ellswift/Makefile.am.include
247+
endif

build-aux/m4/bitcoin_secp.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if test x"$has_valgrind" != x"yes"; then
2020
#if defined(NVALGRIND)
2121
# error "Valgrind does not support this platform."
2222
#endif
23-
]])], [has_valgrind=yes; AC_DEFINE(HAVE_VALGRIND,1,[Define this symbol if valgrind is installed, and it supports the host platform])])
23+
]])], [has_valgrind=yes])
2424
fi
2525
AC_MSG_RESULT($has_valgrind)
2626
])

ci/cirrus.sh

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/sh
22

3-
set -e
4-
set -x
3+
set -eux
54

65
export LC_ALL=C
76

@@ -11,14 +10,20 @@ print_environment() {
1110
set +x
1211
# There are many ways to print variable names and their content. This one
1312
# does not rely on bash.
14-
for i in WERROR_CFLAGS MAKEFLAGS BUILD \
13+
for var in WERROR_CFLAGS MAKEFLAGS BUILD \
1514
ECMULTWINDOW ECMULTGENPRECISION ASM WIDEMUL WITH_VALGRIND EXTRAFLAGS \
1615
EXPERIMENTAL ECDH RECOVERY SCHNORRSIG \
1716
SECP256K1_TEST_ITERS BENCH SECP256K1_BENCH_ITERS CTIMETEST\
1817
EXAMPLES \
19-
WRAPPER_CMD CC AR NM HOST
18+
HOST WRAPPER_CMD \
19+
CC CFLAGS CPPFLAGS AR NM
2020
do
21-
eval 'printf "%s %s " "$i=\"${'"$i"'}\""'
21+
eval "isset=\${$var+x}"
22+
if [ -n "$isset" ]; then
23+
eval "val=\${$var}"
24+
# shellcheck disable=SC2154
25+
printf '%s="%s" ' "$var" "$val"
26+
fi
2227
done
2328
echo "$0"
2429
set -x
@@ -36,7 +41,7 @@ esac
3641

3742
env >> test_env.log
3843

39-
if [ -n "$CC" ]; then
44+
if [ -n "${CC+x}" ]; then
4045
# The MSVC compiler "cl" doesn't understand "-v"
4146
$CC -v || true
4247
fi
@@ -55,6 +60,7 @@ fi
5560
--with-ecmult-window="$ECMULTWINDOW" \
5661
--with-ecmult-gen-precision="$ECMULTGENPRECISION" \
5762
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
63+
--enable-module-ellswift="$ELLSWIFT" \
5864
--enable-module-schnorrsig="$SCHNORRSIG" \
5965
--enable-examples="$EXAMPLES" \
6066
--with-valgrind="$WITH_VALGRIND" \

0 commit comments

Comments
 (0)