Skip to content

Commit 01dddb4

Browse files
committed
Squashed 'src/secp256k1/' changes from 44c2452fd3..e46f81abd6
e46f81abd6 ElligatorSwift d556a9d9aa Add benchmark for key generation 855c8e667d Add x-only ecmult_const version for x=n/d 223ccb76d1 doc: Describe Jacobi calculation in safegcd_implementation.md a72e280efe Native jacobi symbol algorithm 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: e46f81abd67e6d2d4d2399814b8c9fc982218aac
1 parent c41bfd1 commit 01dddb4

Some content is hidden

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

41 files changed

+1750
-111
lines changed

.cirrus.yml

+68-12
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
@@ -67,11 +68,11 @@ task:
6768
<< : *LINUX_CONTAINER
6869
matrix: &ENV_MATRIX
6970
- env: {WIDEMUL: int64, RECOVERY: yes}
70-
- env: {WIDEMUL: int64, ECDH: yes, SCHNORRSIG: yes}
71+
- env: {WIDEMUL: int64, ECDH: yes, SCHNORRSIG: yes, ELLSWIFT: yes}
7172
- env: {WIDEMUL: int128}
72-
- env: {WIDEMUL: int128, RECOVERY: yes, SCHNORRSIG: yes}
73+
- env: {WIDEMUL: int128, RECOVERY: yes, SCHNORRSIG: yes, ELLSWIFT: yes}
7374
- env: {WIDEMUL: int128, ECDH: yes, SCHNORRSIG: yes}
74-
- env: {WIDEMUL: int128, ASM: x86_64}
75+
- env: {WIDEMUL: int128, ASM: x86_64 , ELLSWIFT: yes}
7576
- env: { RECOVERY: yes, SCHNORRSIG: yes}
7677
- env: {BUILD: distcheck, WITH_VALGRIND: no, CTIMETEST: no, BENCH: no}
7778
- env: {CPPFLAGS: -DDETERMINISTIC}
@@ -178,6 +179,7 @@ task:
178179
ECDH: yes
179180
RECOVERY: yes
180181
SCHNORRSIG: yes
182+
ELLSWIFT: yes
181183
CTIMETEST: no
182184
<< : *MERGE_BASE
183185
test_script:
@@ -197,6 +199,7 @@ task:
197199
ECDH: yes
198200
RECOVERY: yes
199201
SCHNORRSIG: yes
202+
ELLSWIFT: yes
200203
CTIMETEST: no
201204
matrix:
202205
- env: {}
@@ -217,6 +220,7 @@ task:
217220
ECDH: yes
218221
RECOVERY: yes
219222
SCHNORRSIG: yes
223+
ELLSWIFT: yes
220224
CTIMETEST: no
221225
<< : *MERGE_BASE
222226
test_script:
@@ -234,24 +238,67 @@ task:
234238
ECDH: yes
235239
RECOVERY: yes
236240
SCHNORRSIG: yes
241+
ELLSWIFT: yes
237242
CTIMETEST: no
238243
<< : *MERGE_BASE
239244
test_script:
240245
- ./ci/cirrus.sh
241246
<< : *CAT_LOGS
242247

243248
task:
244-
name: "x86_64 (mingw32-w64): Windows (Debian stable, Wine)"
245249
<< : *LINUX_CONTAINER
246250
env:
247-
WRAPPER_CMD: wine64-stable
248-
SECP256K1_TEST_ITERS: 16
249-
HOST: x86_64-w64-mingw32
251+
WRAPPER_CMD: wine
252+
WITH_VALGRIND: no
253+
ECDH: yes
254+
RECOVERY: yes
255+
SCHNORRSIG: yes
256+
CTIMETEST: no
257+
matrix:
258+
- name: "x86_64 (mingw32-w64): Windows (Debian stable, Wine)"
259+
env:
260+
HOST: x86_64-w64-mingw32
261+
- name: "i686 (mingw32-w64): Windows (Debian stable, Wine)"
262+
env:
263+
HOST: i686-w64-mingw32
264+
<< : *MERGE_BASE
265+
test_script:
266+
- ./ci/cirrus.sh
267+
<< : *CAT_LOGS
268+
269+
task:
270+
<< : *LINUX_CONTAINER
271+
env:
272+
WRAPPER_CMD: wine
273+
WERROR_CFLAGS: -WX
250274
WITH_VALGRIND: no
251275
ECDH: yes
252276
RECOVERY: yes
277+
EXPERIMENTAL: yes
253278
SCHNORRSIG: yes
279+
ELLSWIFT: yes
280+
ELLSWIFT: yes
254281
CTIMETEST: no
282+
# Set non-essential options that affect the CLI messages here.
283+
# (They depend on the user's taste, so we don't want to set them automatically in configure.ac.)
284+
CFLAGS: -nologo -diagnostics:caret
285+
LDFLAGS: -XCClinker -nologo -XCClinker -diagnostics:caret
286+
# Use a MinGW-w64 host to tell ./configure we're building for Windows.
287+
# This will detect some MinGW-w64 tools but then make will need only
288+
# the MSVC tools CC, AR and NM as specified below.
289+
matrix:
290+
- name: "x86_64 (MSVC): Windows (Debian stable, Wine)"
291+
env:
292+
HOST: x86_64-w64-mingw32
293+
CC: /opt/msvc/bin/x64/cl
294+
AR: /opt/msvc/bin/x64/lib
295+
NM: /opt/msvc/bin/x64/dumpbin -symbols -headers
296+
- name: "i686 (MSVC): Windows (Debian stable, Wine)"
297+
env:
298+
HOST: i686-w64-mingw32
299+
CC: /opt/msvc/bin/x86/cl
300+
AR: /opt/msvc/bin/x86/lib
301+
NM: /opt/msvc/bin/x86/dumpbin -symbols -headers
255302
<< : *MERGE_BASE
256303
test_script:
257304
- ./ci/cirrus.sh
@@ -264,6 +311,7 @@ task:
264311
ECDH: yes
265312
RECOVERY: yes
266313
SCHNORRSIG: yes
314+
ELLSWIFT: yes
267315
CTIMETEST: no
268316
matrix:
269317
- name: "Valgrind (memcheck)"
@@ -302,22 +350,30 @@ task:
302350
<< : *CAT_LOGS
303351

304352
task:
305-
name: "C++ -fpermissive"
353+
name: "C++ -fpermissive (entire project)"
306354
<< : *LINUX_CONTAINER
307355
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
356+
CC: g++
357+
CFLAGS: -fpermissive -g
358+
CPPFLAGS: -DSECP256K1_CPLUSPLUS_TEST_OVERRIDE
312359
WERROR_CFLAGS:
313360
ECDH: yes
314361
RECOVERY: yes
315362
SCHNORRSIG: yes
363+
ELLSWIFT: yes
316364
<< : *MERGE_BASE
317365
test_script:
318366
- ./ci/cirrus.sh
319367
<< : *CAT_LOGS
320368

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

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

+14
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@ 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

1019
$CC -v || true
1120
valgrind --version || true
21+
$WRAPPER_CMD --version || true
1222

1323
./autogen.sh
1424

@@ -18,6 +28,7 @@ valgrind --version || true
1828
--with-ecmult-window="$ECMULTWINDOW" \
1929
--with-ecmult-gen-precision="$ECMULTGENPRECISION" \
2030
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
31+
--enable-module-ellswift="$ELLSWIFT" \
2132
--enable-module-schnorrsig="$SCHNORRSIG" \
2233
--enable-examples="$EXAMPLES" \
2334
--with-valgrind="$WITH_VALGRIND" \
@@ -63,6 +74,9 @@ then
6374
make precomp
6475
fi
6576

77+
# Shutdown wineserver again
78+
wineserver -k || true
79+
6680
# Check that no repo files have been modified by the build.
6781
# (This fails for example if the precomp files need to be updated in the repo.)
6882
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)