Skip to content

Commit 9f5afc1

Browse files
sipaFabcien
authored andcommitted
[SECP256K1] Remove num/gmp support
Summary: ``` The whole "num" API and its libgmp-based implementation are now unused. Remove them. ``` Partial backport of [[bitcoin-core/secp256k1#831 | secp256k1#831]]: bitcoin-core/secp256k1@1f233b3 Depends on D9407. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D9408
1 parent c39b913 commit 9f5afc1

25 files changed

+5
-1032
lines changed

.cirrus.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
env:
22
WIDEMUL: auto
3-
BIGNUM: gmp
43
STATICPRECOMPUTATION: yes
54
ECMULTGENPRECISION: auto
65
ASM: no
@@ -49,9 +48,8 @@ task:
4948
- env: {WIDEMUL: int128, RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
5049
- env: {WIDEMUL: int128, ECDH: yes, EXPERIMENTAL: yes, MULTISET: yes, SCHNORRSIG: yes}
5150
- env: {WIDEMUL: int128, ASM: x86_64}
52-
- env: {BIGNUM: no}
53-
- env: {BIGNUM: no, RECOVERY: yes, EXPERIMENTAL: yes, MULTISET: yes, SCHNORRSIG: yes}
54-
- env: {BIGNUM: no, STATICPRECOMPUTATION: no}
51+
- env: { RECOVERY: yes, EXPERIMENTAL: yes, MULTISET: yes, SCHNORRSIG: yes}
52+
- env: { STATICPRECOMPUTATION: no}
5553
- env: {AUTOTOOLS_TARGET: distcheck, CMAKE_TARGET: install, WITH_VALGRIND: no, CTIMETEST: no, BENCH: no}
5654
- env: {AUTOTOOLS_EXTRA_FLAGS: CPPFLAGS=-DDETERMINISTIC, CMAKE_EXTRA_FLAGS: -DCMAKE_C_FLAGS=-DDETERMINISTIC}
5755
- env: {AUTOTOOLS_EXTRA_FLAGS: CFLAGS=-O0, CMAKE_EXTRA_FLAGS: -DCMAKE_BUILD_TYPE=Debug, CTIMETEST: no}
@@ -63,7 +61,6 @@ task:
6361
CFLAGS: "-fsanitize=undefined -fno-omit-frame-pointer"
6462
LDFLAGS: "-fsanitize=undefined -fno-omit-frame-pointer"
6563
UBSAN_OPTIONS: "print_stacktrace=1:halt_on_error=1"
66-
BIGNUM: no
6764
ASM: x86_64
6865
ECDH: yes
6966
RECOVERY: yes
@@ -75,7 +72,6 @@ task:
7572
- env: { ECMULTGENPRECISION: 8 }
7673
- env:
7774
RUN_VALGRIND: yes
78-
BIGNUM: no
7975
ASM: x86_64
8076
ECDH: yes
8177
RECOVERY: yes
@@ -113,11 +109,6 @@ task:
113109
CC: i686-linux-gnu-gcc
114110
- env:
115111
CC: clang --target=i686-pc-linux-gnu -isystem /usr/i686-linux-gnu/include
116-
matrix:
117-
- env:
118-
BIGNUM: gmp
119-
- env:
120-
BIGNUM: no
121112
test_script:
122113
- ./ci/build_autotools.sh
123114
- ./ci/build_cmake.sh
@@ -177,7 +168,7 @@ task:
177168
# If we haven't restored from cached (and just run brew install), this is a no-op.
178169
- brew link valgrind
179170
brew_script:
180-
- brew install automake cmake gcc@9 gmp libtool ninja
171+
- brew install automake cmake gcc@9 libtool ninja
181172
test_script:
182173
- ./ci/build_autotools.sh
183174
- ./ci/build_cmake.sh
@@ -193,7 +184,6 @@ task:
193184
QEMU_CMD: qemu-s390x
194185
HOST: s390x-linux-gnu
195186
WITH_VALGRIND: no
196-
BIGNUM: no
197187
ECDH: yes
198188
RECOVERY: yes
199189
EXPERIMENTAL: yes

CMakeLists.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,6 @@ set(SECP256K1_PUBLIC_HEADERS
7373
include/secp256k1_preallocated.h
7474
)
7575

76-
option(SECP256K1_ENABLE_BIGNUM "Use the GMP bignum implementation" OFF)
77-
if(SECP256K1_ENABLE_BIGNUM)
78-
# We need to link in GMP
79-
find_package(GMP REQUIRED)
80-
target_link_libraries(secp256k1 GMP::gmp)
81-
set(USE_NUM_GMP 1)
82-
set(USE_FIELD_INV_NUM 1)
83-
set(USE_SCALAR_INV_NUM 1)
84-
else()
85-
set(USE_NUM_NONE 1)
86-
set(USE_FIELD_INV_BUILTIN 1)
87-
set(USE_SCALAR_INV_BUILTIN 1)
88-
endif()
89-
9076
# Guess the target architecture, within the ones with supported ASM.
9177
# First check if the CMAKE_C_COMPILER_TARGET is set (should be when
9278
# cross compiling), then CMAKE_SYSTEM_PROCESSOR as a fallback if meaningful

Makefile.am

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ noinst_HEADERS += src/scalar_8x32_impl.h
1818
noinst_HEADERS += src/scalar_low_impl.h
1919
noinst_HEADERS += src/group.h
2020
noinst_HEADERS += src/group_impl.h
21-
noinst_HEADERS += src/num_gmp.h
22-
noinst_HEADERS += src/num_gmp_impl.h
2321
noinst_HEADERS += src/ecdsa.h
2422
noinst_HEADERS += src/ecdsa_impl.h
2523
noinst_HEADERS += src/eckey.h
@@ -30,8 +28,6 @@ noinst_HEADERS += src/ecmult_const.h
3028
noinst_HEADERS += src/ecmult_const_impl.h
3129
noinst_HEADERS += src/ecmult_gen.h
3230
noinst_HEADERS += src/ecmult_gen_impl.h
33-
noinst_HEADERS += src/num.h
34-
noinst_HEADERS += src/num_impl.h
3531
noinst_HEADERS += src/field_10x26.h
3632
noinst_HEADERS += src/field_10x26_impl.h
3733
noinst_HEADERS += src/field_5x52.h

build-aux/m4/bitcoin_secp.m4

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,6 @@ if test x"$has_libcrypto" = x"yes" && test x"$has_openssl_ec" = x; then
7575
fi
7676
])
7777

78-
dnl
79-
AC_DEFUN([SECP_GMP_CHECK],[
80-
if test x"$has_gmp" != x"yes"; then
81-
CPPFLAGS_TEMP="$CPPFLAGS"
82-
CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
83-
LIBS_TEMP="$LIBS"
84-
LIBS="$GMP_LIBS $LIBS"
85-
AC_CHECK_HEADER(gmp.h,[AC_CHECK_LIB(gmp, __gmpz_init,[has_gmp=yes; GMP_LIBS="$GMP_LIBS -lgmp"; AC_DEFINE(HAVE_LIBGMP,1,[Define this symbol if libgmp is installed])])])
86-
CPPFLAGS="$CPPFLAGS_TEMP"
87-
LIBS="$LIBS_TEMP"
88-
fi
89-
])
90-
9178
AC_DEFUN([SECP_VALGRIND_CHECK],[
9279
if test x"$has_valgrind" != x"yes"; then
9380
CPPFLAGS_TEMP="$CPPFLAGS"

ci/build_autotools.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ pushd buildautotools
3434
../configure \
3535
--enable-experimental=$EXPERIMENTAL \
3636
--with-test-override-wide-multiply=$WIDEMUL \
37-
--with-bignum=$BIGNUM \
3837
--with-asm=$ASM \
3938
--enable-ecmult-static-precomputation=$STATICPRECOMPUTATION \
4039
--with-ecmult-gen-precision=$ECMULTGENPRECISION \

ci/build_cmake.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ ${CMAKE_COMMAND} -GNinja .. \
4545
-DSECP256K1_ENABLE_MODULE_EXTRAKEYS=$SCHNORRSIG \
4646
-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=$SCHNORRSIG \
4747
-DSECP256K1_ENABLE_JNI=$JNI \
48-
-DSECP256K1_ENABLE_BIGNUM=$BIGNUM \
4948
-DSECP256K1_USE_ASM=$ASM \
5049
-DSECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY=$WIDEMUL \
5150
$ECMULT_GEN_PRECISION_ARG \

ci/linux-debian.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN apt-get update
88
# dkpg-dev: to make pkg-config work in cross-builds
99
RUN apt-get install --no-install-recommends --no-upgrade -y \
1010
automake default-jdk dpkg-dev libssl-dev libtool make ninja-build pkg-config python3 qemu-user valgrind \
11-
gcc clang libc6-dbg libgmp-dev \
12-
gcc-i686-linux-gnu libc6-dev-i386-cross libc6-dbg:i386 libgmp-dev:i386 \
11+
gcc clang libc6-dbg \
12+
gcc-i686-linux-gnu libc6-dev-i386-cross libc6-dbg:i386 \
1313
gcc-s390x-linux-gnu libc6-dev-s390x-cross libc6-dbg:s390x
1414
RUN apt-get install -t buster-backports --no-install-recommends --no-upgrade -y cmake

cmake/modules/FindGMP.cmake

Lines changed: 0 additions & 92 deletions
This file was deleted.

configure.ac

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,12 @@ case $host_os in
4848
# in expected paths because they may conflict with system files. Ask
4949
# Homebrew where each one is located, then adjust paths accordingly.
5050
openssl_prefix=`$BREW --prefix openssl 2>/dev/null`
51-
gmp_prefix=`$BREW --prefix gmp 2>/dev/null`
5251
valgrind_prefix=`$BREW --prefix valgrind 2>/dev/null`
5352
if test x$openssl_prefix != x; then
5453
PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
5554
export PKG_CONFIG_PATH
5655
CRYPTO_CPPFLAGS="-I$openssl_prefix/include"
5756
fi
58-
if test x$gmp_prefix != x; then
59-
GMP_CPPFLAGS="-I$gmp_prefix/include"
60-
GMP_LIBS="-L$gmp_prefix/lib"
61-
fi
6257
if test x$valgrind_prefix != x; then
6358
VALGRIND_CPPFLAGS="-I$valgrind_prefix/include"
6459
fi
@@ -179,9 +174,6 @@ AC_ARG_ENABLE(jni,
179174
[use_jni=$enableval],
180175
[use_jni=no])
181176

182-
AC_ARG_WITH([bignum], [AS_HELP_STRING([--with-bignum=gmp|no|auto],
183-
[bignum implementation to use [default=auto]])],[req_bignum=$withval], [req_bignum=auto])
184-
185177
AC_ARG_WITH([asm], [AS_HELP_STRING([--with-asm=x86_64|arm|no|auto],
186178
[assembly optimizations to use (experimental: arm) [default=auto]])],[req_asm=$withval], [req_asm=auto])
187179

@@ -260,32 +252,6 @@ else
260252
esac
261253
fi
262254

263-
if test x"$req_bignum" = x"auto"; then
264-
SECP_GMP_CHECK
265-
if test x"$has_gmp" = x"yes"; then
266-
set_bignum=gmp
267-
fi
268-
269-
if test x"$set_bignum" = x; then
270-
set_bignum=no
271-
fi
272-
else
273-
set_bignum=$req_bignum
274-
case $set_bignum in
275-
gmp)
276-
SECP_GMP_CHECK
277-
if test x"$has_gmp" != x"yes"; then
278-
AC_MSG_ERROR([gmp bignum explicitly requested but libgmp not available])
279-
fi
280-
;;
281-
no)
282-
;;
283-
*)
284-
AC_MSG_ERROR([invalid bignum implementation selection])
285-
;;
286-
esac
287-
fi
288-
289255
# Select assembly optimization
290256
use_external_asm=no
291257

@@ -323,24 +289,6 @@ auto)
323289
;;
324290
esac
325291

326-
# Select bignum implementation
327-
case $set_bignum in
328-
gmp)
329-
AC_DEFINE(HAVE_LIBGMP, 1, [Define this symbol if libgmp is installed])
330-
AC_DEFINE(USE_NUM_GMP, 1, [Define this symbol to use the gmp implementation for num])
331-
AC_DEFINE(USE_FIELD_INV_NUM, 1, [Define this symbol to use the num-based field inverse implementation])
332-
AC_DEFINE(USE_SCALAR_INV_NUM, 1, [Define this symbol to use the num-based scalar inverse implementation])
333-
;;
334-
no)
335-
AC_DEFINE(USE_NUM_NONE, 1, [Define this symbol to use no num implementation])
336-
AC_DEFINE(USE_FIELD_INV_BUILTIN, 1, [Define this symbol to use the native field inverse implementation])
337-
AC_DEFINE(USE_SCALAR_INV_BUILTIN, 1, [Define this symbol to use the native scalar inverse implementation])
338-
;;
339-
*)
340-
AC_MSG_ERROR([invalid bignum implementation])
341-
;;
342-
esac
343-
344292
# Set ecmult window size
345293
if test x"$req_ecmult_window" = x"auto"; then
346294
set_ecmult_window=15
@@ -428,11 +376,6 @@ if test x"$use_jni" != x"no"; then
428376
fi
429377
fi
430378

431-
if test x"$set_bignum" = x"gmp"; then
432-
SECP_LIBS="$SECP_LIBS $GMP_LIBS"
433-
SECP_INCLUDES="$SECP_INCLUDES $GMP_CPPFLAGS"
434-
fi
435-
436379
if test x"$enable_valgrind" = x"yes"; then
437380
SECP_INCLUDES="$SECP_INCLUDES $VALGRIND_CPPFLAGS"
438381
fi
@@ -627,7 +570,6 @@ echo " module extrakeys = $enable_module_extrakeys"
627570
echo " module schnorrsig = $enable_module_schnorrsig"
628571
echo
629572
echo " asm = $set_asm"
630-
echo " bignum = $set_bignum"
631573
echo " ecmult window size = $set_ecmult_window"
632574
echo " ecmult gen prec. bits = $set_ecmult_gen_precision"
633575
# Hide test-only options unless they're used.

src/basic-config.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,10 @@
1313
#undef USE_ECMULT_STATIC_PRECOMPUTATION
1414
#undef USE_EXTERNAL_ASM
1515
#undef USE_EXTERNAL_DEFAULT_CALLBACKS
16-
#undef USE_FIELD_INV_BUILTIN
17-
#undef USE_FIELD_INV_NUM
18-
#undef USE_NUM_GMP
19-
#undef USE_NUM_NONE
20-
#undef USE_SCALAR_INV_BUILTIN
21-
#undef USE_SCALAR_INV_NUM
2216
#undef USE_FORCE_WIDEMUL_INT64
2317
#undef USE_FORCE_WIDEMUL_INT128
2418
#undef ECMULT_WINDOW_SIZE
2519

26-
#define USE_NUM_NONE 1
27-
#define USE_FIELD_INV_BUILTIN 1
28-
#define USE_SCALAR_INV_BUILTIN 1
2920
#define USE_WIDEMUL_64 1
3021
#define ECMULT_WINDOW_SIZE 15
3122

0 commit comments

Comments
 (0)