Skip to content

Commit 92cddab

Browse files
committed
Squashed 'src/secp256k1/' changes from 44c2452fd3..fad8b11539
fad8b11539 Add ellswift testing to CI ea2da437fb Add ElligatorSwift ctime tests dd5b2884dd Add tests for ElligatorSwift a6379f4091 Add ElligatorSwift benchmarks bc604c165d Add ellswift module implementing ElligatorSwift f616ed2cc2 Add functions to test if X coordinate is valid c4c1ba575c Add benchmark for key generation 96f32b18e4 Add x-only ecmult_const version for x=n/d cd142afa59 doc: Describe Jacobi calculation in safegcd_implementation.md ca417ae597 Native jacobi symbol algorithm c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: fad8b11539e8bc22d2d941f5e2a2194b06be6157
1 parent c41bfd1 commit 92cddab

Some content is hidden

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

44 files changed

+2022
-119
lines changed

.cirrus.yml

+67-13
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ env:
1818
ECDH: no
1919
RECOVERY: no
2020
SCHNORRSIG: no
21+
ELLSWIFT: no
2122
### test options
2223
SECP256K1_TEST_ITERS:
2324
BENCH: yes
@@ -36,7 +37,6 @@ cat_logs_snippet: &CAT_LOGS
3637
- cat valgrind_ctime_test.log || true
3738
cat_bench_log_script:
3839
- cat bench.log || true
39-
on_failure:
4040
cat_config_log_script:
4141
- cat config.log || true
4242
cat_test_env_script:
@@ -67,11 +67,11 @@ task:
6767
<< : *LINUX_CONTAINER
6868
matrix: &ENV_MATRIX
6969
- env: {WIDEMUL: int64, RECOVERY: yes}
70-
- env: {WIDEMUL: int64, ECDH: yes, SCHNORRSIG: yes}
70+
- env: {WIDEMUL: int64, ECDH: yes, SCHNORRSIG: yes, ELLSWIFT: yes}
7171
- env: {WIDEMUL: int128}
72-
- env: {WIDEMUL: int128, RECOVERY: yes, SCHNORRSIG: yes}
72+
- env: {WIDEMUL: int128, RECOVERY: yes, SCHNORRSIG: yes, ELLSWIFT: yes}
7373
- env: {WIDEMUL: int128, ECDH: yes, SCHNORRSIG: yes}
74-
- env: {WIDEMUL: int128, ASM: x86_64}
74+
- env: {WIDEMUL: int128, ASM: x86_64 , ELLSWIFT: yes}
7575
- env: { RECOVERY: yes, SCHNORRSIG: yes}
7676
- env: {BUILD: distcheck, WITH_VALGRIND: no, CTIMETEST: no, BENCH: no}
7777
- env: {CPPFLAGS: -DDETERMINISTIC}
@@ -178,6 +178,7 @@ task:
178178
ECDH: yes
179179
RECOVERY: yes
180180
SCHNORRSIG: yes
181+
ELLSWIFT: yes
181182
CTIMETEST: no
182183
<< : *MERGE_BASE
183184
test_script:
@@ -197,6 +198,7 @@ task:
197198
ECDH: yes
198199
RECOVERY: yes
199200
SCHNORRSIG: yes
201+
ELLSWIFT: yes
200202
CTIMETEST: no
201203
matrix:
202204
- env: {}
@@ -217,6 +219,7 @@ task:
217219
ECDH: yes
218220
RECOVERY: yes
219221
SCHNORRSIG: yes
222+
ELLSWIFT: yes
220223
CTIMETEST: no
221224
<< : *MERGE_BASE
222225
test_script:
@@ -234,24 +237,66 @@ task:
234237
ECDH: yes
235238
RECOVERY: yes
236239
SCHNORRSIG: yes
240+
ELLSWIFT: yes
237241
CTIMETEST: no
238242
<< : *MERGE_BASE
239243
test_script:
240244
- ./ci/cirrus.sh
241245
<< : *CAT_LOGS
242246

243247
task:
244-
name: "x86_64 (mingw32-w64): Windows (Debian stable, Wine)"
245248
<< : *LINUX_CONTAINER
246249
env:
247-
WRAPPER_CMD: wine64-stable
248-
SECP256K1_TEST_ITERS: 16
249-
HOST: x86_64-w64-mingw32
250+
WRAPPER_CMD: wine
251+
WITH_VALGRIND: no
252+
ECDH: yes
253+
RECOVERY: yes
254+
SCHNORRSIG: yes
255+
CTIMETEST: no
256+
matrix:
257+
- name: "x86_64 (mingw32-w64): Windows (Debian stable, Wine)"
258+
env:
259+
HOST: x86_64-w64-mingw32
260+
- name: "i686 (mingw32-w64): Windows (Debian stable, Wine)"
261+
env:
262+
HOST: i686-w64-mingw32
263+
<< : *MERGE_BASE
264+
test_script:
265+
- ./ci/cirrus.sh
266+
<< : *CAT_LOGS
267+
268+
task:
269+
<< : *LINUX_CONTAINER
270+
env:
271+
WRAPPER_CMD: wine
272+
WERROR_CFLAGS: -WX
250273
WITH_VALGRIND: no
251274
ECDH: yes
252275
RECOVERY: yes
276+
EXPERIMENTAL: yes
253277
SCHNORRSIG: yes
278+
ELLSWIFT: yes
254279
CTIMETEST: no
280+
# Set non-essential options that affect the CLI messages here.
281+
# (They depend on the user's taste, so we don't want to set them automatically in configure.ac.)
282+
CFLAGS: -nologo -diagnostics:caret
283+
LDFLAGS: -XCClinker -nologo -XCClinker -diagnostics:caret
284+
# Use a MinGW-w64 host to tell ./configure we're building for Windows.
285+
# This will detect some MinGW-w64 tools but then make will need only
286+
# the MSVC tools CC, AR and NM as specified below.
287+
matrix:
288+
- name: "x86_64 (MSVC): Windows (Debian stable, Wine)"
289+
env:
290+
HOST: x86_64-w64-mingw32
291+
CC: /opt/msvc/bin/x64/cl
292+
AR: /opt/msvc/bin/x64/lib
293+
NM: /opt/msvc/bin/x64/dumpbin -symbols -headers
294+
- name: "i686 (MSVC): Windows (Debian stable, Wine)"
295+
env:
296+
HOST: i686-w64-mingw32
297+
CC: /opt/msvc/bin/x86/cl
298+
AR: /opt/msvc/bin/x86/lib
299+
NM: /opt/msvc/bin/x86/dumpbin -symbols -headers
255300
<< : *MERGE_BASE
256301
test_script:
257302
- ./ci/cirrus.sh
@@ -264,6 +309,7 @@ task:
264309
ECDH: yes
265310
RECOVERY: yes
266311
SCHNORRSIG: yes
312+
ELLSWIFT: yes
267313
CTIMETEST: no
268314
matrix:
269315
- name: "Valgrind (memcheck)"
@@ -302,22 +348,30 @@ task:
302348
<< : *CAT_LOGS
303349

304350
task:
305-
name: "C++ -fpermissive"
351+
name: "C++ -fpermissive (entire project)"
306352
<< : *LINUX_CONTAINER
307353
env:
308-
# ./configure correctly errors out when given CC=g++.
309-
# We hack around this by passing CC=g++ only to make.
310-
CC: gcc
311-
MAKEFLAGS: -j4 CC=g++ CFLAGS=-fpermissive\ -g
354+
CC: g++
355+
CFLAGS: -fpermissive -g
356+
CPPFLAGS: -DSECP256K1_CPLUSPLUS_TEST_OVERRIDE
312357
WERROR_CFLAGS:
313358
ECDH: yes
314359
RECOVERY: yes
315360
SCHNORRSIG: yes
361+
ELLSWIFT: yes
316362
<< : *MERGE_BASE
317363
test_script:
318364
- ./ci/cirrus.sh
319365
<< : *CAT_LOGS
320366

367+
task:
368+
name: "C++ (public headers)"
369+
<< : *LINUX_CONTAINER
370+
test_script:
371+
- g++ -Werror include/*.h
372+
- clang -Werror -x c++-header include/*.h
373+
- /opt/msvc/bin/x64/cl.exe -c -WX -TP include/*.h
374+
321375
task:
322376
name: "sage prover"
323377
<< : *LINUX_CONTAINER

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ schnorr_example
1313
*.so
1414
*.a
1515
*.csv
16-
!.gitignore
1716
*.log
1817
*.trs
1918

@@ -34,8 +33,6 @@ libtool
3433
*.lo
3534
*.o
3635
*~
37-
*.log
38-
*.trs
3936

4037
coverage/
4138
coverage.html

Makefile.am

+6-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ noinst_HEADERS += src/hash_impl.h
5858
noinst_HEADERS += src/field.h
5959
noinst_HEADERS += src/field_impl.h
6060
noinst_HEADERS += src/bench.h
61-
noinst_HEADERS += src/basic-config.h
6261
noinst_HEADERS += contrib/lax_der_parsing.h
6362
noinst_HEADERS += contrib/lax_der_parsing.c
6463
noinst_HEADERS += contrib/lax_der_privatekey_parsing.h
@@ -87,7 +86,7 @@ endif
8786
endif
8887

8988
libsecp256k1_la_SOURCES = src/secp256k1.c
90-
libsecp256k1_la_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES)
89+
libsecp256k1_la_CPPFLAGS = $(SECP_INCLUDES)
9190
libsecp256k1_la_LIBADD = $(SECP_LIBS) $(COMMON_LIB) $(PRECOMPUTED_LIB)
9291
libsecp256k1_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_CURRENT):$(LIB_VERSION_REVISION):$(LIB_VERSION_AGE)
9392

@@ -112,7 +111,7 @@ TESTS =
112111
if USE_TESTS
113112
noinst_PROGRAMS += tests
114113
tests_SOURCES = src/tests.c
115-
tests_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
114+
tests_CPPFLAGS = $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
116115
if VALGRIND_ENABLED
117116
tests_CPPFLAGS += -DVALGRIND
118117
noinst_PROGRAMS += valgrind_ctime_test
@@ -228,3 +227,7 @@ endif
228227
if ENABLE_MODULE_SCHNORRSIG
229228
include src/modules/schnorrsig/Makefile.am.include
230229
endif
230+
231+
if ENABLE_MODULE_ELLSWIFT
232+
include src/modules/ellswift/Makefile.am.include
233+
endif

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ libsecp256k1
22
============
33

44
[![Build Status](https://api.cirrus-ci.com/github/bitcoin-core/secp256k1.svg?branch=master)](https://cirrus-ci.com/github/bitcoin-core/secp256k1)
5+
![Dependencies: None](https://img.shields.io/badge/dependencies-none-success)
6+
[![irc.libera.chat #secp256k1](https://img.shields.io/badge/irc.libera.chat-%23secp256k1-success)](https://web.libera.chat/#secp256k1)
57

68
Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1.
79

@@ -15,6 +17,7 @@ Features:
1517
* Derandomized ECDSA (via RFC6979 or with a caller provided function.)
1618
* Very efficient implementation.
1719
* Suitable for embedded systems.
20+
* No runtime dependencies.
1821
* Optional module for public key recovery.
1922
* Optional module for ECDH key exchange.
2023
* Optional module for Schnorr signatures according to [BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki).
@@ -72,11 +75,12 @@ To compile optional modules (such as Schnorr signatures), you need to run `./con
7275

7376
Usage examples
7477
-----------
75-
Usage examples can be found in the [examples](examples) directory. To compile them you need to configure with `--enable-examples`.
78+
Usage examples can be found in the [examples](examples) directory. To compile them you need to configure with `--enable-examples`.
7679
* [ECDSA example](examples/ecdsa.c)
7780
* [Schnorr signatures example](examples/schnorr.c)
7881
* [Deriving a shared secret (ECDH) example](examples/ecdh.c)
79-
To compile the Schnorr signature and ECDH examples, you also need to configure with `--enable-module-schnorrsig` and `--enable-module-ecdh`.
82+
83+
To compile the Schnorr signature and ECDH examples, you also need to configure with `--enable-module-schnorrsig` and `--enable-module-ecdh`.
8084

8185
Test coverage
8286
-----------

build-aux/m4/bitcoin_secp.m4

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ AC_MSG_RESULT([$has_64bit_asm])
1010
])
1111

1212
AC_DEFUN([SECP_VALGRIND_CHECK],[
13+
AC_MSG_CHECKING([for valgrind support])
1314
if test x"$has_valgrind" != x"yes"; then
1415
CPPFLAGS_TEMP="$CPPFLAGS"
1516
CPPFLAGS="$VALGRIND_CPPFLAGS $CPPFLAGS"
@@ -21,6 +22,7 @@ if test x"$has_valgrind" != x"yes"; then
2122
#endif
2223
]])], [has_valgrind=yes; AC_DEFINE(HAVE_VALGRIND,1,[Define this symbol if valgrind is installed, and it supports the host platform])])
2324
fi
25+
AC_MSG_RESULT($has_valgrind)
2426
])
2527

2628
dnl SECP_TRY_APPEND_CFLAGS(flags, VAR)

ci/cirrus.sh

+23-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,27 @@ set -x
55

66
export LC_ALL=C
77

8+
# Start persistent wineserver if necessary.
9+
# This speeds up jobs with many invocations of wine (e.g., ./configure with MSVC) tremendously.
10+
case "$WRAPPER_CMD" in
11+
*wine*)
12+
# This is apparently only reliable when we run a dummy command such as "hh.exe" afterwards.
13+
wineserver -p && wine hh.exe
14+
;;
15+
esac
16+
817
env >> test_env.log
918

10-
$CC -v || true
11-
valgrind --version || true
19+
if [ -n "$CC" ]; then
20+
# The MSVC compiler "cl" doesn't understand "-v"
21+
$CC -v || true
22+
fi
23+
if [ "$WITH_VALGRIND" = "yes" ]; then
24+
valgrind --version
25+
fi
26+
if [ -n "$WRAPPER_CMD" ]; then
27+
$WRAPPER_CMD --version
28+
fi
1229

1330
./autogen.sh
1431

@@ -18,6 +35,7 @@ valgrind --version || true
1835
--with-ecmult-window="$ECMULTWINDOW" \
1936
--with-ecmult-gen-precision="$ECMULTGENPRECISION" \
2037
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
38+
--enable-module-ellswift="$ELLSWIFT" \
2139
--enable-module-schnorrsig="$SCHNORRSIG" \
2240
--enable-examples="$EXAMPLES" \
2341
--with-valgrind="$WITH_VALGRIND" \
@@ -63,6 +81,9 @@ then
6381
make precomp
6482
fi
6583

84+
# Shutdown wineserver again
85+
wineserver -k || true
86+
6687
# Check that no repo files have been modified by the build.
6788
# (This fails for example if the precomp files need to be updated in the repo.)
6889
git diff --exit-code

ci/linux-debian.Dockerfile

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
FROM debian:stable
22

3-
RUN dpkg --add-architecture i386
4-
RUN dpkg --add-architecture s390x
5-
RUN dpkg --add-architecture armhf
6-
RUN dpkg --add-architecture arm64
7-
RUN dpkg --add-architecture ppc64el
8-
RUN apt-get update
3+
RUN dpkg --add-architecture i386 && \
4+
dpkg --add-architecture s390x && \
5+
dpkg --add-architecture armhf && \
6+
dpkg --add-architecture arm64 && \
7+
dpkg --add-architecture ppc64el
98

109
# dkpg-dev: to make pkg-config work in cross-builds
1110
# llvm: for llvm-symbolizer, which is used by clang's UBSan for symbolized stack traces
12-
RUN apt-get install --no-install-recommends --no-upgrade -y \
11+
RUN apt-get update && apt-get install --no-install-recommends -y \
1312
git ca-certificates \
1413
make automake libtool pkg-config dpkg-dev valgrind qemu-user \
1514
gcc clang llvm libc6-dbg \
@@ -19,8 +18,20 @@ RUN apt-get install --no-install-recommends --no-upgrade -y \
1918
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross libc6-dbg:armhf \
2019
gcc-aarch64-linux-gnu libc6-dev-arm64-cross libc6-dbg:arm64 \
2120
gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross libc6-dbg:ppc64el \
22-
wine gcc-mingw-w64-x86-64 \
21+
gcc-mingw-w64-x86-64-win32 wine64 wine \
22+
gcc-mingw-w64-i686-win32 wine32 \
2323
sagemath
2424

25-
# Run a dummy command in wine to make it set up configuration
26-
RUN wine64-stable xcopy || true
25+
WORKDIR /root
26+
# The "wine" package provides a convience wrapper that we need
27+
RUN apt-get update && apt-get install --no-install-recommends -y \
28+
git ca-certificates wine64 wine python3-simplejson python3-six msitools winbind procps && \
29+
git clone https://github.com/mstorsjo/msvc-wine && \
30+
mkdir /opt/msvc && \
31+
python3 msvc-wine/vsdownload.py --accept-license --dest /opt/msvc Microsoft.VisualStudio.Workload.VCTools && \
32+
msvc-wine/install.sh /opt/msvc
33+
34+
# Initialize the wine environment. Wait until the wineserver process has
35+
# exited before closing the session, to avoid corrupting the wine prefix.
36+
RUN wine64 wineboot --init && \
37+
while (ps -A | grep wineserver) > /dev/null; do sleep 1; done

0 commit comments

Comments
 (0)