Skip to content

Commit 9d91a9f

Browse files
committed
Update libsecp256k1
2 parents 77269e0 + a671356 commit 9d91a9f

62 files changed

Lines changed: 3834 additions & 2225 deletions

Some content is hidden

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

src/secp256k1/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ bench_inv
22
bench_ecdh
33
bench_sign
44
bench_verify
5+
bench_schnorr_verify
56
bench_recover
67
bench_internal
78
tests
9+
gen_context
810
*.exe
911
*.so
1012
*.a
@@ -29,6 +31,7 @@ build-aux/
2931
*~
3032
src/libsecp256k1-config.h
3133
src/libsecp256k1-config.h.in
34+
src/ecmult_static_context.h
3235
m4/libtool.m4
3336
m4/ltoptions.m4
3437
m4/ltsugar.m4

src/secp256k1/.travis.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@ compiler:
88
- gcc
99
env:
1010
global:
11-
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no ASM=no BUILD=check EXTRAFLAGS= HOST=
11+
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no schnorr=NO
1212
matrix:
1313
- SCALAR=32bit
14+
- SCALAR=32bit FIELD=32bit ECDH=yes
1415
- SCALAR=64bit
1516
- FIELD=64bit
1617
- FIELD=64bit ENDOMORPHISM=yes
18+
- FIELD=64bit ENDOMORPHISM=yes ECDH=yes
1719
- FIELD=64bit ASM=x86_64
1820
- FIELD=64bit ENDOMORPHISM=yes ASM=x86_64
19-
- FIELD=32bit
21+
- FIELD=32bit SCHNORR=yes
2022
- FIELD=32bit ENDOMORPHISM=yes
2123
- BIGNUM=no
22-
- BIGNUM=no ENDOMORPHISM=yes
24+
- BIGNUM=no ENDOMORPHISM=yes SCHNORR=yes
25+
- BIGNUM=no STATICPRECOMPUTATION=no
2326
- BUILD=distcheck
2427
- EXTRAFLAGS=CFLAGS=-DDETERMINISTIC
2528
matrix:
@@ -55,5 +58,5 @@ before_script: ./autogen.sh
5558
script:
5659
- if [ -n "$HOST" ]; then export USE_HOST="--host=$HOST"; fi
5760
- if [ "x$HOST" = "xi686-linux-gnu" ]; then export CC="$CC -m32"; fi
58-
- ./configure --enable-endomorphism=$ENDOMORPHISM --with-field=$FIELD --with-bignum=$BIGNUM --with-scalar=$SCALAR $EXTRAFLAGS $USE_HOST && make -j2 $BUILD
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
5962
os: linux

src/secp256k1/Makefile.am

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ noinst_HEADERS += src/group.h
1313
noinst_HEADERS += src/group_impl.h
1414
noinst_HEADERS += src/num_gmp.h
1515
noinst_HEADERS += src/num_gmp_impl.h
16-
noinst_HEADERS += src/ecdh.h
17-
noinst_HEADERS += src/ecdh_impl.h
1816
noinst_HEADERS += src/ecdsa.h
1917
noinst_HEADERS += src/ecdsa_impl.h
2018
noinst_HEADERS += src/eckey.h
2119
noinst_HEADERS += src/eckey_impl.h
2220
noinst_HEADERS += src/ecmult.h
2321
noinst_HEADERS += src/ecmult_impl.h
22+
noinst_HEADERS += src/ecmult_const.h
23+
noinst_HEADERS += src/ecmult_const_impl.h
2424
noinst_HEADERS += src/ecmult_gen.h
2525
noinst_HEADERS += src/ecmult_gen_impl.h
2626
noinst_HEADERS += src/num.h
@@ -40,56 +40,73 @@ 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 += src/borromean.h
44-
noinst_HEADERS += src/borromean_impl.h
45-
noinst_HEADERS += src/rangeproof.h
46-
noinst_HEADERS += src/rangeproof_impl.h
47-
noinst_HEADERS += src/schnorr.h
48-
noinst_HEADERS += src/schnorr_impl.h
4943

5044
pkgconfigdir = $(libdir)/pkgconfig
5145
pkgconfig_DATA = libsecp256k1.pc
5246

5347
libsecp256k1_la_SOURCES = src/secp256k1.c
54-
libsecp256k1_la_CPPFLAGS = -I$(top_srcdir)/include $(SECP_INCLUDES)
48+
libsecp256k1_la_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES)
5549
libsecp256k1_la_LIBADD = $(SECP_LIBS)
5650

5751

5852
noinst_PROGRAMS =
5953
if USE_BENCHMARK
60-
noinst_PROGRAMS += bench_verify bench_recover bench_sign bench_rangeproof bench_internal bench_ecdh bench_schnorr_verify
54+
noinst_PROGRAMS += bench_verify bench_recover bench_sign bench_internal
6155
bench_verify_SOURCES = src/bench_verify.c
6256
bench_verify_LDADD = libsecp256k1.la $(SECP_LIBS)
6357
bench_verify_LDFLAGS = -static
64-
bench_schnorr_verify_SOURCES = src/bench_schnorr_verify.c
65-
bench_schnorr_verify_LDADD = libsecp256k1.la $(SECP_LIBS)
66-
bench_schnorr_verify_LDFLAGS = -static
6758
bench_recover_SOURCES = src/bench_recover.c
6859
bench_recover_LDADD = libsecp256k1.la $(SECP_LIBS)
6960
bench_recover_LDFLAGS = -static
7061
bench_sign_SOURCES = src/bench_sign.c
7162
bench_sign_LDADD = libsecp256k1.la $(SECP_LIBS)
7263
bench_sign_LDFLAGS = -static
73-
bench_rangeproof_SOURCES = src/bench_rangeproof.c
74-
bench_rangeproof_LDADD = libsecp256k1.la $(SECP_LIBS)
75-
bench_rangeproof_LDFLAGS = -static
7664
bench_internal_SOURCES = src/bench_internal.c
7765
bench_internal_LDADD = $(SECP_LIBS)
7866
bench_internal_LDFLAGS = -static
7967
bench_internal_CPPFLAGS = $(SECP_INCLUDES)
80-
bench_ecdh_SOURCES = src/bench_ecdh.c
81-
bench_ecdh_LDADD = libsecp256k1.la $(SECP_LIBS)
82-
bench_ecdh_LDFLAGS = -static
83-
bench_ecdh_CPPFLAGS = $(SECP_INCLUDES)
8468
endif
8569

8670
if USE_TESTS
8771
noinst_PROGRAMS += tests
8872
tests_SOURCES = src/tests.c
89-
tests_CPPFLAGS = -DVERIFY $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
73+
tests_CPPFLAGS = -DVERIFY -I$(top_srcdir)/src $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
9074
tests_LDADD = $(SECP_LIBS) $(SECP_TEST_LIBS)
9175
tests_LDFLAGS = -static
9276
TESTS = tests
9377
endif
9478

95-
EXTRA_DIST = autogen.sh
79+
if USE_ECMULT_STATIC_PRECOMPUTATION
80+
CPPFLAGS_FOR_BUILD +=-I$(top_srcdir)/
81+
CFLAGS_FOR_BUILD += -Wall -Wextra -Wno-unused-function
82+
83+
gen_context_OBJECTS = gen_context.o
84+
gen_context_BIN = gen_context$(BUILD_EXEEXT)
85+
gen_%.o: src/gen_%.c
86+
$(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -c $< -o $@
87+
88+
$(gen_context_BIN): $(gen_context_OBJECTS)
89+
$(CC_FOR_BUILD) $^ -o $@
90+
91+
$(libsecp256k1_la_OBJECTS): src/ecmult_static_context.h
92+
$(tests_OBJECTS): src/ecmult_static_context.h
93+
94+
src/ecmult_static_context.h: $(gen_context_BIN)
95+
./$(gen_context_BIN)
96+
97+
CLEANFILES = $(gen_context_BIN) src/ecmult_static_context.h
98+
endif
99+
100+
EXTRA_DIST = autogen.sh src/gen_context.c src/basic-config.h
101+
102+
if ENABLE_MODULE_ECDH
103+
include src/modules/ecdh/Makefile.am.include
104+
endif
105+
106+
if ENABLE_MODULE_SCHNORR
107+
include src/modules/schnorr/Makefile.am.include
108+
endif
109+
110+
if ENABLE_MODULE_RANGEPROOF
111+
include src/modules/rangeproof/Makefile.am.include
112+
endif
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# ===========================================================================
2+
# http://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_PROG_CC_FOR_BUILD
8+
#
9+
# DESCRIPTION
10+
#
11+
# This macro searches for a C compiler that generates native executables,
12+
# that is a C compiler that surely is not a cross-compiler. This can be
13+
# useful if you have to generate source code at compile-time like for
14+
# example GCC does.
15+
#
16+
# The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything
17+
# needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD).
18+
# The value of these variables can be overridden by the user by specifying
19+
# a compiler with an environment variable (like you do for standard CC).
20+
#
21+
# It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object
22+
# file extensions for the build platform, and GCC_FOR_BUILD to `yes' if
23+
# the compiler we found is GCC. All these variables but GCC_FOR_BUILD are
24+
# substituted in the Makefile.
25+
#
26+
# LICENSE
27+
#
28+
# Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>
29+
#
30+
# Copying and distribution of this file, with or without modification, are
31+
# permitted in any medium without royalty provided the copyright notice
32+
# and this notice are preserved. This file is offered as-is, without any
33+
# warranty.
34+
35+
#serial 8
36+
37+
AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
38+
AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
39+
AC_REQUIRE([AC_PROG_CC])dnl
40+
AC_REQUIRE([AC_PROG_CPP])dnl
41+
AC_REQUIRE([AC_EXEEXT])dnl
42+
AC_REQUIRE([AC_CANONICAL_HOST])dnl
43+
44+
dnl Use the standard macros, but make them use other variable names
45+
dnl
46+
pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
47+
pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
48+
pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
49+
pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
50+
pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
51+
pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
52+
pushdef([ac_cv_objext], ac_cv_build_objext)dnl
53+
pushdef([ac_exeext], ac_build_exeext)dnl
54+
pushdef([ac_objext], ac_build_objext)dnl
55+
pushdef([CC], CC_FOR_BUILD)dnl
56+
pushdef([CPP], CPP_FOR_BUILD)dnl
57+
pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
58+
pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
59+
pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
60+
pushdef([host], build)dnl
61+
pushdef([host_alias], build_alias)dnl
62+
pushdef([host_cpu], build_cpu)dnl
63+
pushdef([host_vendor], build_vendor)dnl
64+
pushdef([host_os], build_os)dnl
65+
pushdef([ac_cv_host], ac_cv_build)dnl
66+
pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
67+
pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
68+
pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
69+
pushdef([ac_cv_host_os], ac_cv_build_os)dnl
70+
pushdef([ac_cpp], ac_build_cpp)dnl
71+
pushdef([ac_compile], ac_build_compile)dnl
72+
pushdef([ac_link], ac_build_link)dnl
73+
74+
save_cross_compiling=$cross_compiling
75+
save_ac_tool_prefix=$ac_tool_prefix
76+
cross_compiling=no
77+
ac_tool_prefix=
78+
79+
AC_PROG_CC
80+
AC_PROG_CPP
81+
AC_EXEEXT
82+
83+
ac_tool_prefix=$save_ac_tool_prefix
84+
cross_compiling=$save_cross_compiling
85+
86+
dnl Restore the old definitions
87+
dnl
88+
popdef([ac_link])dnl
89+
popdef([ac_compile])dnl
90+
popdef([ac_cpp])dnl
91+
popdef([ac_cv_host_os])dnl
92+
popdef([ac_cv_host_vendor])dnl
93+
popdef([ac_cv_host_cpu])dnl
94+
popdef([ac_cv_host_alias])dnl
95+
popdef([ac_cv_host])dnl
96+
popdef([host_os])dnl
97+
popdef([host_vendor])dnl
98+
popdef([host_cpu])dnl
99+
popdef([host_alias])dnl
100+
popdef([host])dnl
101+
popdef([LDFLAGS])dnl
102+
popdef([CPPFLAGS])dnl
103+
popdef([CFLAGS])dnl
104+
popdef([CPP])dnl
105+
popdef([CC])dnl
106+
popdef([ac_objext])dnl
107+
popdef([ac_exeext])dnl
108+
popdef([ac_cv_objext])dnl
109+
popdef([ac_cv_exeext])dnl
110+
popdef([ac_cv_prog_cc_g])dnl
111+
popdef([ac_cv_prog_cc_cross])dnl
112+
popdef([ac_cv_prog_cc_works])dnl
113+
popdef([ac_cv_prog_gcc])dnl
114+
popdef([ac_cv_prog_CPP])dnl
115+
116+
dnl Finally, set Makefile variables
117+
dnl
118+
BUILD_EXEEXT=$ac_build_exeext
119+
BUILD_OBJEXT=$ac_build_objext
120+
AC_SUBST(BUILD_EXEEXT)dnl
121+
AC_SUBST(BUILD_OBJEXT)dnl
122+
AC_SUBST([CFLAGS_FOR_BUILD])dnl
123+
AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
124+
AC_SUBST([LDFLAGS_FOR_BUILD])dnl
125+
])

0 commit comments

Comments
 (0)