Skip to content

Commit 91ee21c

Browse files
committed
Squashed 'src/secp256k1/' changes from 71ed475..991d637
991d637 Pedersen commitments, borromean ring signatures, and ZK range proofs. 6ab73e4 Add 64-bit integer utilities bd2895f Merge pull request #371 e5a9047 [Trivial] Remove double semicolons c18b869 Merge pull request #360 3026daa Merge pull request #302 03d4611 Add sage verification script for the group laws a965937 Merge pull request #361 83221ec Add experimental features to configure 5d4c5a3 Prevent damage_array in the signature test from going out of bounds. 419bf7f Merge pull request #356 6c527ec Merge pull request #357 445f7f1 Fix for Windows compile issue 03d84a4 Benchmark against OpenSSL verification 2bfb82b Merge pull request #351 06aeea5 Turn secp256k1_ec_pubkey_serialize outlen to in/out 970164d Merge pull request #348 6466625 Improvements for coordinate decompression e2100ad Merge pull request #347 8e48787 Change secp256k1_ec_pubkey_combine's count argument to size_t. c69dea0 Clear output in more cases for pubkey_combine, adds tests. 269d422 Comment copyediting. b4d17da Merge pull request #344 4709265 Merge pull request #345 26abce7 Adds 32 static test vectors for scalar mul, sqr, inv. 5b71a3f Better error case handling for pubkey_create & pubkey_serialize, more tests. 3b7bc69 Merge pull request #343 eed87af Change contrib/laxder from headers-only to files compilable as standalone C d7eb1ae Merge pull request #342 7914a6e Make lax_der_privatekey_parsing.h not depend on internal code 73f64ff Merge pull request #339 9234391 Overhaul flags handling 1a36898 Make flags more explicit, add runtime checks. 1a3e03a Merge pull request #340 96be204 Add additional tests for eckey and arg-checks. bb5aa4d Make the tweak function zeroize-output-on-fail behavior consistent. 4a243da Move secp256k1_ec_privkey_import/export to contrib. 1b3efc1 Move secp256k1_ecdsa_sig_recover into the recovery module. e3cd679 Eliminate all side-effects from VERIFY_CHECK() usage. b30fc85 Avoid nonce_function_rfc6979 algo16 argument emulation. 70d4640 Make secp256k1_ec_pubkey_create skip processing invalid secret keys. 6c476a8 Minor comment improvements. 131afe5 Merge pull request #334 0c6ab2f Introduce explicit lower-S normalization fea19e7 Add contrib/lax_der_parsing.h 3bb9c44 Rewrite ECDSA signature parsing code fa57f1b Use secp256k1_rand_int and secp256k1_rand_bits more 49b3749 Add new tests for the extra testrand functions f684d7d Faster secp256k1_rand_int implementation 251b1a6 Improve testrand: add extra random functions 31994c8 Merge pull request #338 f79aa88 Bugfix: swap arguments to noncefp c98df26 Merge pull request #319 67f7da4 Extensive interface and operations tests for secp256k1_ec_pubkey_parse. ee2cb40 Add ARG_CHECKs to secp256k1_ec_pubkey_parse/secp256k1_ec_pubkey_serialize 7450ef1 Merge pull request #328 68a3c76 Merge pull request #329 98135ee Merge pull request #332 37100d7 improve ECDH header-doc b13d749 Fix couple of typos in API comments 7c823e3 travis: fixup module configs cc3141a Merge pull request #325 ee58fae Merge pull request #326 213aa67 Do not force benchmarks to be statically linked. 338fc8b Add API exports to secp256k1_nonce_function_default and secp256k1_nonce_function_rfc6979. 52fd03f Merge pull request #320 9f6993f Remove some dead code. 357f8cd Merge pull request #314 118cd82 Use explicit symbol visibility. 4e64608 Include public module headers when compiling modules. 1f41437 Merge pull request #316 fe0d463 Merge pull request #317 cfe0ed9 Fix miscellaneous style nits that irritate overactive static analysis. 2b199de Use the explicit NULL macro for pointer comparisons. 9e90516 Merge pull request #294 dd891e0 Get rid of _t as it is POSIX reserved 201819b Merge pull request #313 912f203 Eliminate a few unbraced statements that crept into the code. eeab823 Merge pull request #299 486b9bb Use a flags bitfield for compressed option to secp256k1_ec_pubkey_serialize and secp256k1_ec_privkey_export 05732c5 Callback data: Accept pointers to either const or non-const data 1973c73 Bugfix: Reinitialise buffer lengths that have been used as outputs 788038d Use size_t for lengths (at least in external API) c9d7c2a secp256k1_context_set_{error,illegal}_callback: Restore default handler by passing NULL as function argument 9aac008 secp256k1_context_destroy: Allow NULL argument as a no-op 64b730b secp256k1_context_create: Use unsigned type for flags bitfield cb04ab5 Merge pull request #309 a551669 Merge pull request #295 81e45ff Update group_impl.h 85e3a2c Merge pull request #112 b2eb63b Merge pull request #293 dc0ce9f [API BREAK] Change argument order to out/outin/in 6d947ca Merge pull request #298 c822693 Merge pull request #301 6d04350 Merge pull request #303 7ab311c Merge pull request #304 5fb3229 Fixes a bug where bench_sign would fail due to passing in too small a buffer. 263dcbc remove unused assignment b183b41 bugfix: "ARG_CHECK(ctx != NULL)" makes no sense 6da1446 build: fix parallel build 5eb4356 Merge pull request #291 c996d53 Print success 9f443be Move pubkey recovery code to separate module d49abbd Separate ECDSA recovery tests 439d34a Separate recoverable and normal signatures a7b046e Merge pull request #289 f66907f Improve/reformat API documentation secp256k1.h 2f77487 Add context building benchmarks cc623d5 Merge pull request #287 de7e398 small typo fix 2b4cf41 Use pkg-config always when possible, with failover to manual checks for libcrypto REVERT: 71ed475 Pedersen commitments, borromean ring signatures, and ZK range proofs. REVERT: afd1379 Add 64-bit integer utilities git-subtree-dir: src/secp256k1 git-subtree-split: 991d637d80377f09d574afb8482c45ed628f17a3
1 parent a671356 commit 91ee21c

Some content is hidden

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

76 files changed

+6146
-2110
lines changed

.travis.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,24 @@ compiler:
88
- gcc
99
env:
1010
global:
11-
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no schnorr=NO
11+
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no schnorr=no RECOVERY=no EXPERIMENTAL=no
1212
matrix:
13-
- SCALAR=32bit
14-
- SCALAR=32bit FIELD=32bit ECDH=yes
13+
- SCALAR=32bit RECOVERY=yes
14+
- SCALAR=32bit FIELD=32bit ECDH=yes EXPERIMENTAL=yes
1515
- SCALAR=64bit
16-
- FIELD=64bit
16+
- FIELD=64bit RECOVERY=yes
1717
- FIELD=64bit ENDOMORPHISM=yes
18-
- FIELD=64bit ENDOMORPHISM=yes ECDH=yes
18+
- FIELD=64bit ENDOMORPHISM=yes ECDH=yes EXPERIMENTAL=yes
1919
- FIELD=64bit ASM=x86_64
2020
- FIELD=64bit ENDOMORPHISM=yes ASM=x86_64
21-
- FIELD=32bit SCHNORR=yes
21+
- FIELD=32bit SCHNORR=yes EXPERIMENTAL=yes
2222
- FIELD=32bit ENDOMORPHISM=yes
2323
- BIGNUM=no
24-
- BIGNUM=no ENDOMORPHISM=yes SCHNORR=yes
24+
- BIGNUM=no ENDOMORPHISM=yes SCHNORR=yes RECOVERY=yes EXPERIMENTAL=yes
2525
- BIGNUM=no STATICPRECOMPUTATION=no
2626
- BUILD=distcheck
27-
- EXTRAFLAGS=CFLAGS=-DDETERMINISTIC
27+
- EXTRAFLAGS=CPPFLAGS=-DDETERMINISTIC
28+
- EXTRAFLAGS=CFLAGS=-O0
2829
matrix:
2930
fast_finish: true
3031
include:
@@ -58,5 +59,5 @@ before_script: ./autogen.sh
5859
script:
5960
- if [ -n "$HOST" ]; then export USE_HOST="--host=$HOST"; fi
6061
- if [ "x$HOST" = "xi686-linux-gnu" ]; then export CC="$CC -m32"; fi
61-
- ./configure --enable-endomorphism=$ENDOMORPHISM --with-field=$FIELD --with-bignum=$BIGNUM --with-scalar=$SCALAR --enable-ecmult-static-precomputation=$STATICPRECOMPUTATION --enable-module-ecdh=$ECDH --enable-module-schnorr=$SCHNORR $EXTRAFLAGS $USE_HOST && make -j2 $BUILD
62+
- ./configure --enable-experimental=$EXPERIMENTAL --enable-endomorphism=$ENDOMORPHISM --with-field=$FIELD --with-bignum=$BIGNUM --with-scalar=$SCALAR --enable-ecmult-static-precomputation=$STATICPRECOMPUTATION --enable-module-ecdh=$ECDH --enable-module-schnorr=$SCHNORR --enable-module-recovery=$RECOVERY $EXTRAFLAGS $USE_HOST && make -j2 $BUILD
6263
os: linux

Makefile.am

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ noinst_HEADERS += src/hash_impl.h
4040
noinst_HEADERS += src/field.h
4141
noinst_HEADERS += src/field_impl.h
4242
noinst_HEADERS += src/bench.h
43+
noinst_HEADERS += contrib/lax_der_parsing.h
44+
noinst_HEADERS += contrib/lax_der_parsing.c
45+
noinst_HEADERS += contrib/lax_der_privatekey_parsing.h
46+
noinst_HEADERS += contrib/lax_der_privatekey_parsing.c
4347

4448
pkgconfigdir = $(libdir)/pkgconfig
4549
pkgconfig_DATA = libsecp256k1.pc
@@ -51,33 +55,27 @@ libsecp256k1_la_LIBADD = $(SECP_LIBS)
5155

5256
noinst_PROGRAMS =
5357
if USE_BENCHMARK
54-
noinst_PROGRAMS += bench_verify bench_recover bench_sign bench_internal
58+
noinst_PROGRAMS += bench_verify bench_sign bench_internal
5559
bench_verify_SOURCES = src/bench_verify.c
56-
bench_verify_LDADD = libsecp256k1.la $(SECP_LIBS)
57-
bench_verify_LDFLAGS = -static
58-
bench_recover_SOURCES = src/bench_recover.c
59-
bench_recover_LDADD = libsecp256k1.la $(SECP_LIBS)
60-
bench_recover_LDFLAGS = -static
60+
bench_verify_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS)
6161
bench_sign_SOURCES = src/bench_sign.c
62-
bench_sign_LDADD = libsecp256k1.la $(SECP_LIBS)
63-
bench_sign_LDFLAGS = -static
62+
bench_sign_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS)
6463
bench_internal_SOURCES = src/bench_internal.c
6564
bench_internal_LDADD = $(SECP_LIBS)
66-
bench_internal_LDFLAGS = -static
6765
bench_internal_CPPFLAGS = $(SECP_INCLUDES)
6866
endif
6967

7068
if USE_TESTS
7169
noinst_PROGRAMS += tests
7270
tests_SOURCES = src/tests.c
73-
tests_CPPFLAGS = -DVERIFY -I$(top_srcdir)/src $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
71+
tests_CPPFLAGS = -DVERIFY -I$(top_srcdir)/src -I$(top_srcdir)/include $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
7472
tests_LDADD = $(SECP_LIBS) $(SECP_TEST_LIBS)
7573
tests_LDFLAGS = -static
7674
TESTS = tests
7775
endif
7876

7977
if USE_ECMULT_STATIC_PRECOMPUTATION
80-
CPPFLAGS_FOR_BUILD +=-I$(top_srcdir)/
78+
CPPFLAGS_FOR_BUILD +=-I$(top_srcdir)
8179
CFLAGS_FOR_BUILD += -Wall -Wextra -Wno-unused-function
8280

8381
gen_context_OBJECTS = gen_context.o
@@ -90,6 +88,7 @@ $(gen_context_BIN): $(gen_context_OBJECTS)
9088

9189
$(libsecp256k1_la_OBJECTS): src/ecmult_static_context.h
9290
$(tests_OBJECTS): src/ecmult_static_context.h
91+
$(bench_internal_OBJECTS): src/ecmult_static_context.h
9392

9493
src/ecmult_static_context.h: $(gen_context_BIN)
9594
./$(gen_context_BIN)
@@ -107,6 +106,10 @@ if ENABLE_MODULE_SCHNORR
107106
include src/modules/schnorr/Makefile.am.include
108107
endif
109108

109+
if ENABLE_MODULE_RECOVERY
110+
include src/modules/recovery/Makefile.am.include
111+
endif
112+
110113
if ENABLE_MODULE_RANGEPROOF
111114
include src/modules/rangeproof/Makefile.am.include
112115
endif

build-aux/m4/bitcoin_secp.m4

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ AC_MSG_RESULT([$has_64bit_asm])
1616

1717
dnl
1818
AC_DEFUN([SECP_OPENSSL_CHECK],[
19-
if test x"$use_pkgconfig" = x"yes"; then
20-
: #NOP
19+
has_libcrypto=no
2120
m4_ifdef([PKG_CHECK_MODULES],[
2221
PKG_CHECK_MODULES([CRYPTO], [libcrypto], [has_libcrypto=yes],[has_libcrypto=no])
2322
if test x"$has_libcrypto" = x"yes"; then
@@ -27,11 +26,16 @@ if test x"$use_pkgconfig" = x"yes"; then
2726
LIBS="$TEMP_LIBS"
2827
fi
2928
])
30-
else
31-
AC_CHECK_HEADER(openssl/crypto.h,[AC_CHECK_LIB(crypto, main,[has_libcrypto=yes; CRYPTO_LIBS=-lcrypto; AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed])]
32-
)])
33-
LIBS=
34-
fi
29+
if test x$has_libcrypto = xno; then
30+
AC_CHECK_HEADER(openssl/crypto.h,[
31+
AC_CHECK_LIB(crypto, main,[
32+
has_libcrypto=yes
33+
CRYPTO_LIBS=-lcrypto
34+
AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed])
35+
])
36+
])
37+
LIBS=
38+
fi
3539
if test x"$has_libcrypto" = x"yes" && test x"$has_openssl_ec" = x; then
3640
AC_MSG_CHECKING(for EC functions in libcrypto)
3741
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[

configure.ac

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ if test x"$ac_cv_prog_cc_c89" = x"no"; then
3030
AC_MSG_ERROR([c89 compiler support required])
3131
fi
3232

33-
case $host in
34-
*mingw*)
35-
use_pkgconfig=no
36-
;;
37-
*)
38-
use_pkgconfig=yes
39-
;;
40-
esac
41-
4233
case $host_os in
4334
*darwin*)
4435
if test x$cross_compiling != xyes; then
@@ -83,6 +74,14 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
8374
CFLAGS="$saved_CFLAGS"
8475
])
8576

77+
saved_CFLAGS="$CFLAGS"
78+
CFLAGS="$CFLAGS -fvisibility=hidden"
79+
AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
80+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
81+
[ AC_MSG_RESULT([yes]) ],
82+
[ AC_MSG_RESULT([no])
83+
CFLAGS="$saved_CFLAGS"
84+
])
8685

8786
AC_ARG_ENABLE(benchmark,
8887
AS_HELP_STRING([--enable-benchmark],[compile benchmark (default is no)]),
@@ -94,26 +93,36 @@ AC_ARG_ENABLE(tests,
9493
[use_tests=$enableval],
9594
[use_tests=yes])
9695

96+
AC_ARG_ENABLE(experimental,
97+
AS_HELP_STRING([--enable-experimental],[allow experimental configure options (default is no)]),
98+
[use_experimental=$enableval],
99+
[use_experimental=no])
100+
97101
AC_ARG_ENABLE(endomorphism,
98102
AS_HELP_STRING([--enable-endomorphism],[enable endomorphism (default is no)]),
99103
[use_endomorphism=$enableval],
100104
[use_endomorphism=no])
101-
105+
102106
AC_ARG_ENABLE(ecmult_static_precomputation,
103107
AS_HELP_STRING([--enable-ecmult-static-precomputation],[enable precomputed ecmult table for signing (default is yes)]),
104108
[use_ecmult_static_precomputation=$enableval],
105109
[use_ecmult_static_precomputation=yes])
106110

107111
AC_ARG_ENABLE(module_ecdh,
108-
AS_HELP_STRING([--enable-module-ecdh],[enable ECDH shared secret computation (default is no)]),
112+
AS_HELP_STRING([--enable-module-ecdh],[enable ECDH shared secret computation (experimental)]),
109113
[enable_module_ecdh=$enableval],
110114
[enable_module_ecdh=no])
111115

112116
AC_ARG_ENABLE(module_schnorr,
113-
AS_HELP_STRING([--enable-module-schnorr],[enable Schnorr signature module (default is no)]),
117+
AS_HELP_STRING([--enable-module-schnorr],[enable Schnorr signature module (experimental)]),
114118
[enable_module_schnorr=$enableval],
115119
[enable_module_schnorr=no])
116120

121+
AC_ARG_ENABLE(module_recovery,
122+
AS_HELP_STRING([--enable-module-recovery],[enable ECDSA pubkey recovery module (default is no)]),
123+
[enable_module_recovery=$enableval],
124+
[enable_module_recovery=no])
125+
117126
AC_ARG_ENABLE(module_rangeproof,
118127
AS_HELP_STRING([--enable-module-rangeproof],[enable Pedersen / zero-knowledge range proofs module (default is no)]),
119128
[enable_module_rangeproof=$enableval],
@@ -347,6 +356,10 @@ if test x"$enable_module_schnorr" = x"yes"; then
347356
AC_DEFINE(ENABLE_MODULE_SCHNORR, 1, [Define this symbol to enable the Schnorr signature module])
348357
fi
349358

359+
if test x"$enable_module_recovery" = x"yes"; then
360+
AC_DEFINE(ENABLE_MODULE_RECOVERY, 1, [Define this symbol to enable the ECDSA pubkey recovery module])
361+
fi
362+
350363
if test x"$enable_module_rangeproof" = x"yes"; then
351364
AC_DEFINE(ENABLE_MODULE_RANGEPROOF, 1, [Define this symbol to enable the Pedersen / zero knowledge range proof module])
352365
fi
@@ -358,10 +371,27 @@ AC_MSG_NOTICE([Using field implementation: $set_field])
358371
AC_MSG_NOTICE([Using bignum implementation: $set_bignum])
359372
AC_MSG_NOTICE([Using scalar implementation: $set_scalar])
360373
AC_MSG_NOTICE([Using endomorphism optimizations: $use_endomorphism])
361-
362-
AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh])
363-
AC_MSG_NOTICE([Building Schnorr signatures module: $enable_module_schnorr])
364-
AC_MSG_NOTICE([Building range proof module: $enable_module_rangeproof])
374+
AC_MSG_NOTICE([Building ECDSA pubkey recovery module: $enable_module_recovery])
375+
376+
if test x"$enable_experimental" = x"yes"; then
377+
AC_MSG_NOTICE([******])
378+
AC_MSG_NOTICE([WARNING: experimental build])
379+
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
380+
AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh])
381+
AC_MSG_NOTICE([Building Schnorr signatures module: $enable_module_schnorr])
382+
AC_MSG_NOTICE([Building range proof module: $enable_module_rangeproof])
383+
AC_MSG_NOTICE([******])
384+
else
385+
if test x"$enable_module_schnorr" = x"yes"; then
386+
AC_MSG_ERROR([Schnorr signature module is experimental. Use --enable-experimental to allow.])
387+
fi
388+
if test x"$enable_module_ecdh" = x"yes"; then
389+
AC_MSG_ERROR([ECDH module is experimental. Use --enable-experimental to allow.])
390+
fi
391+
if test x"$enable_module_rangeproof" = x"yes"; then
392+
AC_MSG_ERROR([Range proof module is experimental. Use --enable-experimental to allow.])
393+
fi
394+
fi
365395

366396
AC_CONFIG_HEADERS([src/libsecp256k1-config.h])
367397
AC_CONFIG_FILES([Makefile libsecp256k1.pc])
@@ -374,6 +404,7 @@ AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
374404
AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$use_ecmult_static_precomputation" = x"yes"])
375405
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
376406
AM_CONDITIONAL([ENABLE_MODULE_SCHNORR], [test x"$enable_module_schnorr" = x"yes"])
407+
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
377408
AM_CONDITIONAL([ENABLE_MODULE_RANGEPROOF], [test x"$enable_module_rangeproof" = x"yes"])
378409

379410
dnl make sure nothing new is exported so that we don't break the cache

0 commit comments

Comments
 (0)