Skip to content

Commit 395e115

Browse files
committed
Squashed 'src/secp256k1/' changes from be8d9c2..af4047cf8
af4047cf8 Add ellsq testing to CI 1ab129a5c Elligator Squared module 13fe9daa9 Native jacobi symbol algorithm 2a3a97c Merge bitcoin-core/secp256k1#976: `secp256k1_schnorrsig_sign_internal` should be static aa5d34a Merge bitcoin-core/secp256k1#783: Make the public API docs more consistent and explicit 7271387 Add missing static to secp256k1_schnorrsig_sign_internal 9a5a87e Merge bitcoin-core/secp256k1#956: Replace ecmult_context with a generated static array. 20abd52 Add tests for pre_g tables. 6815761 Remove ecmult_context. f20dcbb Correct typo. 16a3cc0 Generate ecmult_static_pre_g.h 8de2d86 Bump memory limits in advance of making the ecmult context static. d7ec49a Merge bitcoin-core/secp256k1#969: ci: Fixes after Debian release 5d5c74a tests: Rewrite code to circument potential bug in clang 3d2f492 ci: Install libasan6 (instead of 5) after Debian upgrade adec5a1 Add missing null check for ctx and input keys in the public API f4edfc7 Improve consistency for NULL arguments in the public interface git-subtree-dir: src/secp256k1 git-subtree-split: af4047cf871df2875e492c27885fcaca2cbc760e
1 parent c020cba commit 395e115

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

+18261
-623
lines changed

.cirrus.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ env:
1818
ECDH: no
1919
RECOVERY: no
2020
SCHNORRSIG: no
21+
ELLSQ: no
2122
### test options
2223
TEST_ITERS:
2324
BENCH: yes
@@ -60,12 +61,12 @@ task:
6061
memory: 1G
6162
matrix: &ENV_MATRIX
6263
- env: {WIDEMUL: int64, RECOVERY: yes}
63-
- env: {WIDEMUL: int64, ECDH: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
64+
- env: {WIDEMUL: int64, ECDH: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes, ELLSQ: yes}
6465
- env: {WIDEMUL: int128}
65-
- env: {WIDEMUL: int128, RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
66+
- env: {WIDEMUL: int128, RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes, ELLSQ: yes}
6667
- env: {WIDEMUL: int128, ECDH: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
6768
- env: {WIDEMUL: int128, ASM: x86_64}
68-
- env: { RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
69+
- env: { RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes, ELLSQ: yes}
6970
- env: { STATICPRECOMPUTATION: no}
7071
- env: {BUILD: distcheck, WITH_VALGRIND: no, CTIMETEST: no, BENCH: no}
7172
- env: {CPPFLAGS: -DDETERMINISTIC}
@@ -91,6 +92,7 @@ task:
9192
env:
9293
HOST: i686-linux-gnu
9394
ECDH: yes
95+
ELLSQ: yes
9496
RECOVERY: yes
9597
EXPERIMENTAL: yes
9698
SCHNORRSIG: yes
@@ -175,6 +177,7 @@ task:
175177
HOST: s390x-linux-gnu
176178
WITH_VALGRIND: no
177179
ECDH: yes
180+
ELLSQ: yes
178181
RECOVERY: yes
179182
EXPERIMENTAL: yes
180183
SCHNORRSIG: yes
@@ -198,6 +201,7 @@ task:
198201
HOST: arm-linux-gnueabihf
199202
WITH_VALGRIND: no
200203
ECDH: yes
204+
ELLSQ: tes
201205
RECOVERY: yes
202206
EXPERIMENTAL: yes
203207
SCHNORRSIG: yes
@@ -222,6 +226,7 @@ task:
222226
HOST: aarch64-linux-gnu
223227
WITH_VALGRIND: no
224228
ECDH: yes
229+
ELLSQ: yes
225230
RECOVERY: yes
226231
EXPERIMENTAL: yes
227232
SCHNORRSIG: yes
@@ -243,6 +248,7 @@ task:
243248
HOST: powerpc64le-linux-gnu
244249
WITH_VALGRIND: no
245250
ECDH: yes
251+
ELLSQ: yes
246252
RECOVERY: yes
247253
EXPERIMENTAL: yes
248254
SCHNORRSIG: yes
@@ -264,6 +270,7 @@ task:
264270
HOST: x86_64-w64-mingw32
265271
WITH_VALGRIND: no
266272
ECDH: yes
273+
ELLSQ: yes
267274
RECOVERY: yes
268275
EXPERIMENTAL: yes
269276
SCHNORRSIG: yes
@@ -278,9 +285,10 @@ task:
278285
container:
279286
dockerfile: ci/linux-debian.Dockerfile
280287
cpu: 1
281-
memory: 1G
288+
memory: 2G
282289
env:
283290
ECDH: yes
291+
ELLSQ: yes
284292
RECOVERY: yes
285293
EXPERIMENTAL: yes
286294
SCHNORRSIG: yes
@@ -334,6 +342,7 @@ task:
334342
WERROR_CFLAGS:
335343
EXPERIMENTAL: yes
336344
ECDH: yes
345+
ELLSQ: yes
337346
RECOVERY: yes
338347
SCHNORRSIG: yes
339348
<< : *MERGE_BASE

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/ecmult_static_pre_g.h linguist-generated

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ bench_internal
99
tests
1010
exhaustive_tests
1111
gen_context
12+
gen_ecmult_static_pre_g
1213
valgrind_ctime_test
1314
*.exe
1415
*.so

Makefile.am

+13-2
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,19 @@ exhaustive_tests_LDFLAGS = -static
127127
TESTS += exhaustive_tests
128128
endif
129129

130+
EXTRA_PROGRAMS = gen_ecmult_static_pre_g
131+
gen_ecmult_static_pre_g_SOURCES = src/gen_ecmult_static_pre_g.c
132+
# See Automake manual, Section "Errors with distclean"
133+
src/ecmult_static_pre_g.h:
134+
$(MAKE) $(AM_MAKEFLAGS) gen_ecmult_static_pre_g$(EXEEXT)
135+
./gen_ecmult_static_pre_g$(EXEEXT)
136+
130137
if USE_ECMULT_STATIC_PRECOMPUTATION
131138
CPPFLAGS_FOR_BUILD +=-I$(top_srcdir) -I$(builddir)/src
132139

133140
gen_context_OBJECTS = gen_context.o
134141
gen_context_BIN = gen_context$(BUILD_EXEEXT)
135-
gen_%.o: src/gen_%.c src/libsecp256k1-config.h
142+
$(gen_context_OBJECTS): src/gen_context.c src/libsecp256k1-config.h
136143
$(CC_FOR_BUILD) $(DEFS) $(CPPFLAGS_FOR_BUILD) $(SECP_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -c $< -o $@
137144

138145
$(gen_context_BIN): $(gen_context_OBJECTS)
@@ -149,7 +156,7 @@ src/ecmult_static_context.h: $(gen_context_BIN)
149156
CLEANFILES = $(gen_context_BIN) src/ecmult_static_context.h
150157
endif
151158

152-
EXTRA_DIST = autogen.sh src/gen_context.c src/basic-config.h
159+
EXTRA_DIST = autogen.sh src/gen_context.c src/ecmult_static_pre_g.h src/basic-config.h
153160

154161
if ENABLE_MODULE_ECDH
155162
include src/modules/ecdh/Makefile.am.include
@@ -166,3 +173,7 @@ endif
166173
if ENABLE_MODULE_SCHNORRSIG
167174
include src/modules/schnorrsig/Makefile.am.include
168175
endif
176+
177+
if ENABLE_MODULE_ELLSQ
178+
include src/modules/ellsq/Makefile.am.include
179+
endif

ci/cirrus.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ valgrind --version || true
1616
--enable-experimental="$EXPERIMENTAL" \
1717
--with-test-override-wide-multiply="$WIDEMUL" --with-asm="$ASM" \
1818
--enable-ecmult-static-precomputation="$STATICPRECOMPUTATION" --with-ecmult-gen-precision="$ECMULTGENPRECISION" \
19-
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
19+
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" --enable-module-ellsq="$ELLSQ" \
2020
--enable-module-schnorrsig="$SCHNORRSIG" \
2121
--with-valgrind="$WITH_VALGRIND" \
2222
--host="$HOST" $EXTRAFLAGS
@@ -60,6 +60,10 @@ then
6060
then
6161
$EXEC ./bench_ecdh >> bench.log 2>&1
6262
fi
63+
if [ "$ELLSQ" = "yes" ]
64+
then
65+
$EXEC ./bench_ellsq >> bench.log 2>&1
66+
fi
6367
if [ "$SCHNORRSIG" = "yes" ]
6468
then
6569
$EXEC ./bench_schnorrsig >> bench.log 2>&1

ci/linux-debian.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN apt-get install --no-install-recommends --no-upgrade -y \
1414
make automake libtool pkg-config dpkg-dev valgrind qemu-user \
1515
gcc clang llvm libc6-dbg \
1616
g++ \
17-
gcc-i686-linux-gnu libc6-dev-i386-cross libc6-dbg:i386 libubsan1:i386 libasan5:i386 \
17+
gcc-i686-linux-gnu libc6-dev-i386-cross libc6-dbg:i386 libubsan1:i386 libasan6:i386 \
1818
gcc-s390x-linux-gnu libc6-dev-s390x-cross libc6-dbg:s390x \
1919
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross libc6-dbg:armhf \
2020
gcc-aarch64-linux-gnu libc6-dev-arm64-cross libc6-dbg:arm64 \

configure.ac

+17
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ AC_ARG_ENABLE(module_schnorrsig,
161161
[enable_module_schnorrsig=$enableval],
162162
[enable_module_schnorrsig=no])
163163

164+
AC_ARG_ENABLE(module_ellsq,
165+
AS_HELP_STRING([--enable-module-ellsq],[enable Elligator^2 module (experimental)]),
166+
[enable_module_ellsq=$enableval],
167+
[enable_module_ellsq=no])
168+
164169
AC_ARG_ENABLE(external_default_callbacks,
165170
AS_HELP_STRING([--enable-external-default-callbacks],[enable external default callback functions [default=no]]),
166171
[use_external_default_callbacks=$enableval],
@@ -177,6 +182,8 @@ AC_ARG_WITH([ecmult-window], [AS_HELP_STRING([--with-ecmult-window=SIZE|auto],
177182
[window size for ecmult precomputation for verification, specified as integer in range [2..24].]
178183
[Larger values result in possibly better performance at the cost of an exponentially larger precomputed table.]
179184
[The table will store 2^(SIZE-1) * 64 bytes of data but can be larger in memory due to platform-specific padding and alignment.]
185+
[A window size larger than 15 will require you delete the prebuilt ecmult_static_pre_g.h file so that it can be rebuilt.]
186+
[For very large window sizes, use "make -j 1" to reduce memory use during compilation.]
180187
["auto" is a reasonable setting for desktop machines (currently 15). [default=auto]]
181188
)],
182189
[req_ecmult_window=$withval], [req_ecmult_window=auto])
@@ -454,6 +461,10 @@ if test x"$enable_module_extrakeys" = x"yes"; then
454461
AC_DEFINE(ENABLE_MODULE_EXTRAKEYS, 1, [Define this symbol to enable the extrakeys module])
455462
fi
456463

464+
if test x"$enable_module_ellsq" = x"yes"; then
465+
AC_DEFINE(ENABLE_MODULE_ELLSQ, 1, [Define this symbol to enable the Elligator^2 module])
466+
fi
467+
457468
if test x"$use_external_default_callbacks" = x"yes"; then
458469
AC_DEFINE(USE_EXTERNAL_DEFAULT_CALLBACKS, 1, [Define this symbol if an external implementation of the default callbacks is used])
459470
fi
@@ -468,6 +479,7 @@ if test x"$enable_experimental" = x"yes"; then
468479
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
469480
AC_MSG_NOTICE([Building extrakeys module: $enable_module_extrakeys])
470481
AC_MSG_NOTICE([Building schnorrsig module: $enable_module_schnorrsig])
482+
AC_MSG_NOTICE([Building Elligator^2 module: $enable_module_ellsq])
471483
AC_MSG_NOTICE([******])
472484
else
473485
if test x"$enable_module_extrakeys" = x"yes"; then
@@ -476,6 +488,9 @@ else
476488
if test x"$enable_module_schnorrsig" = x"yes"; then
477489
AC_MSG_ERROR([schnorrsig module is experimental. Use --enable-experimental to allow.])
478490
fi
491+
if test x"$enable_module_ellsq" = x"yes"; then
492+
AC_MSG_ERROR([Elligator^2 module is experimental. Use --enable-experimental to allow.])
493+
fi
479494
if test x"$set_asm" = x"arm"; then
480495
AC_MSG_ERROR([ARM assembly optimization is experimental. Use --enable-experimental to allow.])
481496
fi
@@ -501,6 +516,7 @@ AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
501516
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
502517
AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"yes"])
503518
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
519+
AM_CONDITIONAL([ENABLE_MODULE_ELLSQ], [test x"$enable_module_ellsq" = x"yes"])
504520
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$use_external_asm" = x"yes"])
505521
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"])
506522

@@ -523,6 +539,7 @@ echo " module ecdh = $enable_module_ecdh"
523539
echo " module recovery = $enable_module_recovery"
524540
echo " module extrakeys = $enable_module_extrakeys"
525541
echo " module schnorrsig = $enable_module_schnorrsig"
542+
echo " module ellsq = $enable_module_ellsq"
526543
echo
527544
echo " asm = $set_asm"
528545
echo " ecmult window size = $set_ecmult_window"

0 commit comments

Comments
 (0)