Skip to content

Commit 7b49f22

Browse files
committed
Squashed 'src/secp256k1/' changes from 7a49cac..8225239
8225239 Merge dogecoin#433: Make the libcrypto detection fail the newer API. 12de863 Make the libcrypto detection fail the newer API. 2928420 Merge dogecoin#427: Remove Schnorr from travis as well 8eecc4a Remove Schnorr from travis as well a8abae7 Merge dogecoin#310: Add exhaustive test for group functions on a low-order subgroup b4ceedf Add exhaustive test for verification 83836a9 Add exhaustive tests for group arithmetic, signing, and ecmult on a small group 20b8877 Add exhaustive test for group functions on a low-order subgroup 80773a6 Merge dogecoin#425: Remove Schnorr experiment e06e878 Remove Schnorr experiment 04c8ef3 Merge dogecoin#407: Modify parameter order of internal functions to match API parameter order 6e06696 Merge dogecoin#411: Remove guarantees about memcmp-ability 40c8d7e Merge dogecoin#421: Update scalar_4x64_impl.h a922365 Merge dogecoin#422: Restructure nonce clearing 3769783 Restructure nonce clearing 0f9e69d Restructure nonce clearing 9d67afa Update scalar_4x64_impl.h 7d15cd7 Merge dogecoin#413: fix auto-enabled static precompuatation 00c5d2e fix auto-enabled static precompuatation 91219a1 Remove guarantees about memcmp-ability 353c1bf Fix secp256k1_ge_set_table_gej_var parameter order 541b783 Fix secp256k1_ge_set_all_gej_var parameter order 7d893f4 Fix secp256k1_fe_inv_all_var parameter order git-subtree-dir: src/secp256k1 git-subtree-split: 8225239f490f79842a5a3b82ad6cc8aa11d5208e
1 parent b213535 commit 7b49f22

33 files changed

+676
-937
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ bench_schnorr_verify
66
bench_recover
77
bench_internal
88
tests
9+
exhaustive_tests
910
gen_context
1011
*.exe
1112
*.so

.travis.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cache:
1111
- src/java/guava/
1212
env:
1313
global:
14-
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no schnorr=no RECOVERY=no EXPERIMENTAL=no
14+
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no RECOVERY=no EXPERIMENTAL=no
1515
- GUAVA_URL=https://search.maven.org/remotecontent?filepath=com/google/guava/guava/18.0/guava-18.0.jar GUAVA_JAR=src/java/guava/guava-18.0.jar
1616
matrix:
1717
- SCALAR=32bit RECOVERY=yes
@@ -22,15 +22,14 @@ env:
2222
- FIELD=64bit ENDOMORPHISM=yes ECDH=yes EXPERIMENTAL=yes
2323
- FIELD=64bit ASM=x86_64
2424
- FIELD=64bit ENDOMORPHISM=yes ASM=x86_64
25-
- FIELD=32bit SCHNORR=yes EXPERIMENTAL=yes
2625
- FIELD=32bit ENDOMORPHISM=yes
2726
- BIGNUM=no
28-
- BIGNUM=no ENDOMORPHISM=yes SCHNORR=yes RECOVERY=yes EXPERIMENTAL=yes
27+
- BIGNUM=no ENDOMORPHISM=yes RECOVERY=yes EXPERIMENTAL=yes
2928
- BIGNUM=no STATICPRECOMPUTATION=no
3029
- BUILD=distcheck
3130
- EXTRAFLAGS=CPPFLAGS=-DDETERMINISTIC
3231
- EXTRAFLAGS=CFLAGS=-O0
33-
- BUILD=check-java ECDH=yes SCHNORR=yes EXPERIMENTAL=yes
32+
- BUILD=check-java ECDH=yes EXPERIMENTAL=yes
3433
matrix:
3534
fast_finish: true
3635
include:
@@ -66,5 +65,5 @@ before_script: ./autogen.sh
6665
script:
6766
- if [ -n "$HOST" ]; then export USE_HOST="--host=$HOST"; fi
6867
- if [ "x$HOST" = "xi686-linux-gnu" ]; then export CC="$CC -m32"; fi
69-
- ./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
68+
- ./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-recovery=$RECOVERY $EXTRAFLAGS $USE_HOST && make -j2 $BUILD
7069
os: linux

Makefile.am

+13-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ noinst_HEADERS =
1212
noinst_HEADERS += src/scalar.h
1313
noinst_HEADERS += src/scalar_4x64.h
1414
noinst_HEADERS += src/scalar_8x32.h
15+
noinst_HEADERS += src/scalar_low.h
1516
noinst_HEADERS += src/scalar_impl.h
1617
noinst_HEADERS += src/scalar_4x64_impl.h
1718
noinst_HEADERS += src/scalar_8x32_impl.h
19+
noinst_HEADERS += src/scalar_low_impl.h
1820
noinst_HEADERS += src/group.h
1921
noinst_HEADERS += src/group_impl.h
2022
noinst_HEADERS += src/num_gmp.h
@@ -87,13 +89,23 @@ bench_internal_LDADD = $(SECP_LIBS) $(COMMON_LIB)
8789
bench_internal_CPPFLAGS = -DSECP256K1_BUILD $(SECP_INCLUDES)
8890
endif
8991

92+
TESTS =
9093
if USE_TESTS
9194
noinst_PROGRAMS += tests
9295
tests_SOURCES = src/tests.c
9396
tests_CPPFLAGS = -DSECP256K1_BUILD -DVERIFY -I$(top_srcdir)/src -I$(top_srcdir)/include $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
9497
tests_LDADD = $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB)
9598
tests_LDFLAGS = -static
96-
TESTS = tests
99+
TESTS += tests
100+
endif
101+
102+
if USE_EXHAUSTIVE_TESTS
103+
noinst_PROGRAMS += exhaustive_tests
104+
exhaustive_tests_SOURCES = src/tests_exhaustive.c
105+
exhaustive_tests_CPPFLAGS = -DSECP256K1_BUILD -DVERIFY -I$(top_srcdir)/src $(SECP_INCLUDES)
106+
exhaustive_tests_LDADD = $(SECP_LIBS)
107+
exhaustive_tests_LDFLAGS = -static
108+
TESTS += exhaustive_tests
97109
endif
98110

99111
JAVAROOT=src/java
@@ -154,10 +166,6 @@ if ENABLE_MODULE_ECDH
154166
include src/modules/ecdh/Makefile.am.include
155167
endif
156168

157-
if ENABLE_MODULE_SCHNORR
158-
include src/modules/schnorr/Makefile.am.include
159-
endif
160-
161169
if ENABLE_MODULE_RECOVERY
162170
include src/modules/recovery/Makefile.am.include
163171
endif

build-aux/m4/bitcoin_secp.m4

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ if test x"$has_libcrypto" = x"yes" && test x"$has_openssl_ec" = x; then
4646
ECDSA_sign(0, NULL, 0, NULL, NULL, eckey);
4747
ECDSA_verify(0, NULL, 0, NULL, 0, eckey);
4848
EC_KEY_free(eckey);
49+
ECDSA_SIG *sig_openssl;
50+
sig_openssl = ECDSA_SIG_new();
51+
(void)sig_openssl->r;
52+
ECDSA_SIG_free(sig_openssl);
4953
]])],[has_openssl_ec=yes],[has_openssl_ec=no])
5054
AC_MSG_RESULT([$has_openssl_ec])
5155
fi

configure.ac

+9-21
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ AC_ARG_ENABLE(experimental,
104104
[use_experimental=$enableval],
105105
[use_experimental=no])
106106

107+
AC_ARG_ENABLE(exhaustive_tests,
108+
AS_HELP_STRING([--enable-exhaustive-tests],[compile exhaustive tests (default is yes)]),
109+
[use_exhaustive_tests=$enableval],
110+
[use_exhaustive_tests=yes])
111+
107112
AC_ARG_ENABLE(endomorphism,
108113
AS_HELP_STRING([--enable-endomorphism],[enable endomorphism (default is no)]),
109114
[use_endomorphism=$enableval],
@@ -119,11 +124,6 @@ AC_ARG_ENABLE(module_ecdh,
119124
[enable_module_ecdh=$enableval],
120125
[enable_module_ecdh=no])
121126

122-
AC_ARG_ENABLE(module_schnorr,
123-
AS_HELP_STRING([--enable-module-schnorr],[enable Schnorr signature module (experimental)]),
124-
[enable_module_schnorr=$enableval],
125-
[enable_module_schnorr=no])
126-
127127
AC_ARG_ENABLE(module_recovery,
128128
AS_HELP_STRING([--enable-module-recovery],[enable ECDSA pubkey recovery module (default is no)]),
129129
[enable_module_recovery=$enableval],
@@ -381,9 +381,6 @@ fi
381381
if test x"$use_jni" != x"no"; then
382382
AX_JNI_INCLUDE_DIR
383383
have_jni_dependencies=yes
384-
if test x"$enable_module_schnorr" = x"no"; then
385-
have_jni_dependencies=no
386-
fi
387384
if test x"$enable_module_ecdh" = x"no"; then
388385
have_jni_dependencies=no
389386
fi
@@ -392,7 +389,7 @@ if test x"$use_jni" != x"no"; then
392389
fi
393390
if test "x$have_jni_dependencies" = "xno"; then
394391
if test x"$use_jni" = x"yes"; then
395-
AC_MSG_ERROR([jni support explicitly requested but headers/dependencies were not found. Enable ECDH and Schnorr and try again.])
392+
AC_MSG_ERROR([jni support explicitly requested but headers/dependencies were not found. Enable ECDH and try again.])
396393
fi
397394
AC_MSG_WARN([jni headers/dependencies not found. jni support disabled])
398395
use_jni=no
@@ -413,18 +410,14 @@ if test x"$use_endomorphism" = x"yes"; then
413410
AC_DEFINE(USE_ENDOMORPHISM, 1, [Define this symbol to use endomorphism optimization])
414411
fi
415412

416-
if test x"$use_ecmult_static_precomputation" = x"yes"; then
413+
if test x"$set_precomp" = x"yes"; then
417414
AC_DEFINE(USE_ECMULT_STATIC_PRECOMPUTATION, 1, [Define this symbol to use a statically generated ecmult table])
418415
fi
419416

420417
if test x"$enable_module_ecdh" = x"yes"; then
421418
AC_DEFINE(ENABLE_MODULE_ECDH, 1, [Define this symbol to enable the ECDH module])
422419
fi
423420

424-
if test x"$enable_module_schnorr" = x"yes"; then
425-
AC_DEFINE(ENABLE_MODULE_SCHNORR, 1, [Define this symbol to enable the Schnorr signature module])
426-
fi
427-
428421
if test x"$enable_module_recovery" = x"yes"; then
429422
AC_DEFINE(ENABLE_MODULE_RECOVERY, 1, [Define this symbol to enable the ECDSA pubkey recovery module])
430423
fi
@@ -442,7 +435,6 @@ AC_MSG_NOTICE([Using bignum implementation: $set_bignum])
442435
AC_MSG_NOTICE([Using scalar implementation: $set_scalar])
443436
AC_MSG_NOTICE([Using endomorphism optimizations: $use_endomorphism])
444437
AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh])
445-
AC_MSG_NOTICE([Building Schnorr signatures module: $enable_module_schnorr])
446438
AC_MSG_NOTICE([Building ECDSA pubkey recovery module: $enable_module_recovery])
447439
AC_MSG_NOTICE([Using jni: $use_jni])
448440

@@ -451,12 +443,8 @@ if test x"$enable_experimental" = x"yes"; then
451443
AC_MSG_NOTICE([WARNING: experimental build])
452444
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
453445
AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh])
454-
AC_MSG_NOTICE([Building Schnorr signatures module: $enable_module_schnorr])
455446
AC_MSG_NOTICE([******])
456447
else
457-
if test x"$enable_module_schnorr" = x"yes"; then
458-
AC_MSG_ERROR([Schnorr signature module is experimental. Use --enable-experimental to allow.])
459-
fi
460448
if test x"$enable_module_ecdh" = x"yes"; then
461449
AC_MSG_ERROR([ECDH module is experimental. Use --enable-experimental to allow.])
462450
fi
@@ -473,10 +461,10 @@ AC_SUBST(SECP_LIBS)
473461
AC_SUBST(SECP_TEST_LIBS)
474462
AC_SUBST(SECP_TEST_INCLUDES)
475463
AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"])
464+
AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$use_exhaustive_tests" != x"no"])
476465
AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
477-
AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$use_ecmult_static_precomputation" = x"yes"])
466+
AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$set_precomp" = x"yes"])
478467
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
479-
AM_CONDITIONAL([ENABLE_MODULE_SCHNORR], [test x"$enable_module_schnorr" = x"yes"])
480468
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
481469
AM_CONDITIONAL([USE_JNI], [test x"$use_jni" == x"yes"])
482470
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$use_external_asm" = x"yes"])

include/secp256k1.h

+4-10
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@ typedef struct secp256k1_context_struct secp256k1_context;
4747
* The exact representation of data inside is implementation defined and not
4848
* guaranteed to be portable between different platforms or versions. It is
4949
* however guaranteed to be 64 bytes in size, and can be safely copied/moved.
50-
* If you need to convert to a format suitable for storage or transmission, use
51-
* secp256k1_ec_pubkey_serialize and secp256k1_ec_pubkey_parse.
52-
*
53-
* Furthermore, it is guaranteed that identical public keys (ignoring
54-
* compression) will have identical representation, so they can be memcmp'ed.
50+
* If you need to convert to a format suitable for storage, transmission, or
51+
* comparison, use secp256k1_ec_pubkey_serialize and secp256k1_ec_pubkey_parse.
5552
*/
5653
typedef struct {
5754
unsigned char data[64];
@@ -62,12 +59,9 @@ typedef struct {
6259
* The exact representation of data inside is implementation defined and not
6360
* guaranteed to be portable between different platforms or versions. It is
6461
* however guaranteed to be 64 bytes in size, and can be safely copied/moved.
65-
* If you need to convert to a format suitable for storage or transmission, use
66-
* the secp256k1_ecdsa_signature_serialize_* and
62+
* If you need to convert to a format suitable for storage, transmission, or
63+
* comparison, use the secp256k1_ecdsa_signature_serialize_* and
6764
* secp256k1_ecdsa_signature_serialize_* functions.
68-
*
69-
* Furthermore, it is guaranteed to identical signatures will have identical
70-
* representation, so they can be memcmp'ed.
7165
*/
7266
typedef struct {
7367
unsigned char data[64];

0 commit comments

Comments
 (0)