Skip to content

Commit 7becbb1

Browse files
committed
secp256k1-zkp-sys: vendor to jonasnick/secp256k1-zkp#musig2
1 parent f101a0d commit 7becbb1

Some content is hidden

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

78 files changed

+6321
-3113
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# This file was automatically created by ./vendor-libsecp.sh
2-
f3708a1ecb445b1b05a0f8fcd1da6a88f83d89c4
2+
044e0c563e74aa563fc69b6a61ecf9d6355fb028

secp256k1-zkp-sys/depend/secp256k1/.cirrus.yml

+151-50
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
env:
22
WIDEMUL: auto
3-
BIGNUM: auto
43
STATICPRECOMPUTATION: yes
54
ECMULTGENPRECISION: auto
65
ASM: no
76
BUILD: check
87
WITH_VALGRIND: yes
9-
RUN_VALGRIND: no
108
EXTRAFLAGS:
119
HOST:
1210
ECDH: no
@@ -21,7 +19,8 @@ env:
2119
EXPERIMENTAL: no
2220
CTIMETEST: yes
2321
BENCH: yes
24-
ITERS: 2
22+
TEST_ITERS:
23+
BENCH_ITERS: 2
2524
MAKEFLAGS: -j2
2625

2726
cat_logs_snippet: &CAT_LOGS
@@ -65,47 +64,13 @@ task:
6564
- env: {WIDEMUL: int128, RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
6665
- env: {WIDEMUL: int128, ECDH: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes, ECDSA_S2C: yes, RANGEPROOF: yes, WHITELIST: yes, GENERATOR: yes, MUSIG: yes, ECDSAADAPTOR: yes}
6766
- env: {WIDEMUL: int128, ASM: x86_64}
68-
- env: {BIGNUM: no}
69-
- env: {BIGNUM: no, RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes, ECDSA_S2C: yes, RANGEPROOF: yes, WHITELIST: yes, GENERATOR: yes, MUSIG: yes, ECDSAADAPTOR: yes}
70-
- env: {BIGNUM: no, STATICPRECOMPUTATION: no}
67+
- env: { RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes, ECDSA_S2C: yes, RANGEPROOF: yes, WHITELIST: yes, GENERATOR: yes, MUSIG: yes, ECDSAADAPTOR: yes}
68+
- env: { STATICPRECOMPUTATION: no}
7169
- env: {BUILD: distcheck, WITH_VALGRIND: no, CTIMETEST: no, BENCH: no}
7270
- env: {CPPFLAGS: -DDETERMINISTIC}
7371
- env: {CFLAGS: -O0, CTIMETEST: no}
74-
- env:
75-
CFLAGS: "-fsanitize=undefined -fno-omit-frame-pointer"
76-
LDFLAGS: "-fsanitize=undefined -fno-omit-frame-pointer"
77-
UBSAN_OPTIONS: "print_stacktrace=1:halt_on_error=1"
78-
BIGNUM: no
79-
ASM: x86_64
80-
ECDH: yes
81-
RECOVERY: yes
82-
EXPERIMENTAL: yes
83-
SCHNORRSIG: yes
84-
ECDSA_S2C: yes
85-
RANGEPROOF: yes
86-
WHITELIST: yes
87-
GENERATOR: yes
88-
MUSIG: yes
89-
ECDSAADAPTOR: yes
90-
CTIMETEST: no
9172
- env: { ECMULTGENPRECISION: 2 }
9273
- env: { ECMULTGENPRECISION: 8 }
93-
- env:
94-
RUN_VALGRIND: yes
95-
BIGNUM: no
96-
ASM: x86_64
97-
ECDH: yes
98-
RECOVERY: yes
99-
EXPERIMENTAL: yes
100-
SCHNORRSIG: yes
101-
ECDSA_S2C: yes
102-
RANGEPROOF: yes
103-
WHITELIST: yes
104-
GENERATOR: yes
105-
MUSIG: yes
106-
ECDSAADAPTOR: yes
107-
EXTRAFLAGS: "--disable-openssl-tests"
108-
BUILD:
10974
matrix:
11075
- env:
11176
CC: gcc
@@ -139,11 +104,6 @@ task:
139104
CC: i686-linux-gnu-gcc
140105
- env:
141106
CC: clang --target=i686-pc-linux-gnu -isystem /usr/i686-linux-gnu/include
142-
matrix:
143-
- env:
144-
BIGNUM: gmp
145-
- env:
146-
BIGNUM: no
147107
<< : *MERGE_BASE
148108
test_script:
149109
- ./ci/cirrus.sh
@@ -153,8 +113,8 @@ task:
153113
name: "x86_64: macOS Catalina"
154114
macos_instance:
155115
image: catalina-base
156-
# As of d4ca81f48e tasks with valgrind enabled take about 60 minutes
157-
timeout_in: 90m
116+
# tasks with valgrind enabled take about 90 minutes
117+
timeout_in: 120m
158118
env:
159119
HOMEBREW_NO_AUTO_UPDATE: 1
160120
HOMEBREW_NO_INSTALL_CLEANUP: 1
@@ -204,7 +164,7 @@ task:
204164
# If we haven't restored from cached (and just run brew install), this is a no-op.
205165
- brew link valgrind
206166
brew_script:
207-
- brew install automake libtool gmp gcc@9
167+
- brew install automake libtool gcc@9
208168
<< : *MERGE_BASE
209169
test_script:
210170
- ./ci/cirrus.sh
@@ -217,11 +177,10 @@ task:
217177
cpu: 1
218178
memory: 1G
219179
env:
220-
QEMU_CMD: qemu-s390x
180+
WRAPPER_CMD: qemu-s390x
181+
TEST_ITERS: 16
221182
HOST: s390x-linux-gnu
222-
BUILD:
223183
WITH_VALGRIND: no
224-
BIGNUM: no
225184
ECDH: yes
226185
RECOVERY: yes
227186
EXPERIMENTAL: yes
@@ -239,3 +198,145 @@ task:
239198
- rm /etc/ld.so.cache
240199
- ./ci/cirrus.sh
241200
<< : *CAT_LOGS
201+
202+
task:
203+
name: "ARM32: Linux (Debian stable, QEMU)"
204+
container:
205+
dockerfile: ci/linux-debian.Dockerfile
206+
cpu: 1
207+
memory: 1G
208+
env:
209+
WRAPPER_CMD: qemu-arm
210+
TEST_ITERS: 16
211+
HOST: arm-linux-gnueabihf
212+
WITH_VALGRIND: no
213+
ECDH: yes
214+
RECOVERY: yes
215+
EXPERIMENTAL: yes
216+
SCHNORRSIG: yes
217+
CTIMETEST: no
218+
matrix:
219+
- env: {}
220+
- env: {ASM: arm}
221+
<< : *MERGE_BASE
222+
test_script:
223+
- ./ci/cirrus.sh
224+
<< : *CAT_LOGS
225+
226+
task:
227+
name: "ARM64: Linux (Debian stable, QEMU)"
228+
container:
229+
dockerfile: ci/linux-debian.Dockerfile
230+
cpu: 1
231+
memory: 1G
232+
env:
233+
WRAPPER_CMD: qemu-aarch64
234+
TEST_ITERS: 16
235+
HOST: aarch64-linux-gnu
236+
WITH_VALGRIND: no
237+
ECDH: yes
238+
RECOVERY: yes
239+
EXPERIMENTAL: yes
240+
SCHNORRSIG: yes
241+
CTIMETEST: no
242+
<< : *MERGE_BASE
243+
test_script:
244+
- ./ci/cirrus.sh
245+
<< : *CAT_LOGS
246+
247+
task:
248+
name: "ppc64le: Linux (Debian stable, QEMU)"
249+
container:
250+
dockerfile: ci/linux-debian.Dockerfile
251+
cpu: 1
252+
memory: 1G
253+
env:
254+
WRAPPER_CMD: qemu-ppc64le
255+
TEST_ITERS: 16
256+
HOST: powerpc64le-linux-gnu
257+
WITH_VALGRIND: no
258+
ECDH: yes
259+
RECOVERY: yes
260+
EXPERIMENTAL: yes
261+
SCHNORRSIG: yes
262+
CTIMETEST: no
263+
<< : *MERGE_BASE
264+
test_script:
265+
- ./ci/cirrus.sh
266+
<< : *CAT_LOGS
267+
268+
task:
269+
name: "x86_64 (mingw32-w64): Windows (Debian stable, Wine)"
270+
container:
271+
dockerfile: ci/linux-debian.Dockerfile
272+
cpu: 1
273+
memory: 1G
274+
env:
275+
WRAPPER_CMD: wine64-stable
276+
TEST_ITERS: 16
277+
HOST: x86_64-w64-mingw32
278+
WITH_VALGRIND: no
279+
ECDH: yes
280+
RECOVERY: yes
281+
EXPERIMENTAL: yes
282+
SCHNORRSIG: yes
283+
CTIMETEST: no
284+
<< : *MERGE_BASE
285+
test_script:
286+
- ./ci/cirrus.sh
287+
<< : *CAT_LOGS
288+
289+
# Sanitizers
290+
task:
291+
timeout_in: 120m
292+
container:
293+
dockerfile: ci/linux-debian.Dockerfile
294+
cpu: 1
295+
memory: 2G
296+
env:
297+
ECDH: yes
298+
RECOVERY: yes
299+
EXPERIMENTAL: yes
300+
SCHNORRSIG: yes
301+
ECDSA_S2C: yes
302+
RANGEPROOF: yes
303+
WHITELIST: yes
304+
GENERATOR: yes
305+
MUSIG: yes
306+
ECDSAADAPTOR: yes
307+
CTIMETEST: no
308+
EXTRAFLAGS: "--disable-openssl-tests"
309+
matrix:
310+
- name: "Valgrind (memcheck)"
311+
env:
312+
# The `--error-exitcode` is required to make the test fail if valgrind found errors, otherwise it'll return 0 (https://www.valgrind.org/docs/manual/manual-core.html)
313+
WRAPPER_CMD: "valgrind --error-exitcode=42"
314+
TEST_ITERS: 8
315+
- name: "UBSan, ASan, LSan"
316+
env:
317+
CFLAGS: "-fsanitize=undefined,address"
318+
CFLAGS_FOR_BUILD: "-fsanitize=undefined,address"
319+
UBSAN_OPTIONS: "print_stacktrace=1:halt_on_error=1"
320+
ASAN_OPTIONS: "strict_string_checks=1:detect_stack_use_after_return=1:detect_leaks=1"
321+
LSAN_OPTIONS: "use_unaligned=1"
322+
TEST_ITERS: 32
323+
# Try to cover many configurations with just a tiny matrix.
324+
matrix:
325+
- env:
326+
ASM: auto
327+
STATICPRECOMPUTATION: yes
328+
- env:
329+
ASM: no
330+
STATICPRECOMPUTATION: no
331+
ECMULTGENPRECISION: 2
332+
matrix:
333+
- env:
334+
CC: clang
335+
- env:
336+
HOST: i686-linux-gnu
337+
CC: i686-linux-gnu-gcc
338+
<< : *MERGE_BASE
339+
test_script:
340+
- ./ci/cirrus.sh
341+
<< : *CAT_LOGS
342+

secp256k1-zkp-sys/depend/secp256k1/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ libtool
3535
*~
3636
*.log
3737
*.trs
38+
39+
coverage/
40+
coverage.html
41+
coverage.*.html
42+
*.gcda
43+
*.gcno
44+
*.gcov
45+
3846
src/libsecp256k1-config.h
3947
src/libsecp256k1-config.h.in
4048
src/ecmult_static_context.h

secp256k1-zkp-sys/depend/secp256k1/Makefile.am

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ noinst_HEADERS += src/scalar_8x32_impl.h
1414
noinst_HEADERS += src/scalar_low_impl.h
1515
noinst_HEADERS += src/group.h
1616
noinst_HEADERS += src/group_impl.h
17-
noinst_HEADERS += src/num_gmp.h
18-
noinst_HEADERS += src/num_gmp_impl.h
1917
noinst_HEADERS += src/eccommit.h
2018
noinst_HEADERS += src/eccommit_impl.h
2119
noinst_HEADERS += src/ecdsa.h
@@ -28,14 +26,16 @@ noinst_HEADERS += src/ecmult_const.h
2826
noinst_HEADERS += src/ecmult_const_impl.h
2927
noinst_HEADERS += src/ecmult_gen.h
3028
noinst_HEADERS += src/ecmult_gen_impl.h
31-
noinst_HEADERS += src/num.h
32-
noinst_HEADERS += src/num_impl.h
3329
noinst_HEADERS += src/field_10x26.h
3430
noinst_HEADERS += src/field_10x26_impl.h
3531
noinst_HEADERS += src/field_5x52.h
3632
noinst_HEADERS += src/field_5x52_impl.h
3733
noinst_HEADERS += src/field_5x52_int128_impl.h
3834
noinst_HEADERS += src/field_5x52_asm_impl.h
35+
noinst_HEADERS += src/modinv32.h
36+
noinst_HEADERS += src/modinv32_impl.h
37+
noinst_HEADERS += src/modinv64.h
38+
noinst_HEADERS += src/modinv64_impl.h
3939
noinst_HEADERS += src/assumptions.h
4040
noinst_HEADERS += src/util.h
4141
noinst_HEADERS += src/scratch.h
@@ -70,7 +70,7 @@ endif
7070
endif
7171

7272
librustsecp256k1zkp_v0_4_0_la_SOURCES = src/secp256k1.c
73-
librustsecp256k1zkp_v0_4_0_la_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES)
73+
librustsecp256k1zkp_v0_4_0_la_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES)
7474
librustsecp256k1zkp_v0_4_0_la_LIBADD = $(SECP_LIBS) $(COMMON_LIB)
7575

7676
if VALGRIND_ENABLED
@@ -83,27 +83,27 @@ noinst_PROGRAMS += bench_verify bench_sign bench_internal bench_ecmult
8383
bench_verify_SOURCES = src/bench_verify.c
8484
bench_verify_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB)
8585
# SECP_TEST_INCLUDES are only used here for CRYPTO_CPPFLAGS
86-
bench_verify_CPPFLAGS = -DSECP256K1_BUILD $(SECP_TEST_INCLUDES)
86+
bench_verify_CPPFLAGS = $(SECP_TEST_INCLUDES)
8787
bench_sign_SOURCES = src/bench_sign.c
8888
bench_sign_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB)
8989
bench_internal_SOURCES = src/bench_internal.c
9090
bench_internal_LDADD = $(SECP_LIBS) $(COMMON_LIB)
91-
bench_internal_CPPFLAGS = -DSECP256K1_BUILD $(SECP_INCLUDES)
91+
bench_internal_CPPFLAGS = $(SECP_INCLUDES)
9292
bench_ecmult_SOURCES = src/bench_ecmult.c
9393
bench_ecmult_LDADD = $(SECP_LIBS) $(COMMON_LIB)
94-
bench_ecmult_CPPFLAGS = -DSECP256K1_BUILD $(SECP_INCLUDES)
94+
bench_ecmult_CPPFLAGS = $(SECP_INCLUDES)
9595
endif
9696

9797
TESTS =
9898
if USE_TESTS
9999
noinst_PROGRAMS += tests
100100
tests_SOURCES = src/tests.c
101-
tests_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/src -I$(top_srcdir)/include $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
101+
tests_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
102102
if VALGRIND_ENABLED
103103
tests_CPPFLAGS += -DVALGRIND
104104
noinst_PROGRAMS += valgrind_ctime_test
105105
valgrind_ctime_test_SOURCES = src/valgrind_ctime_test.c
106-
valgrind_ctime_test_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_LIBS) $(COMMON_LIB)
106+
valgrind_ctime_test_LDADD = libsecp256k1.la $(SECP_LIBS) $(COMMON_LIB)
107107
endif
108108
if !ENABLE_COVERAGE
109109
tests_CPPFLAGS += -DVERIFY
@@ -116,7 +116,7 @@ endif
116116
if USE_EXHAUSTIVE_TESTS
117117
noinst_PROGRAMS += exhaustive_tests
118118
exhaustive_tests_SOURCES = src/tests_exhaustive.c
119-
exhaustive_tests_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/src $(SECP_INCLUDES)
119+
exhaustive_tests_CPPFLAGS = -I$(top_srcdir)/src $(SECP_INCLUDES)
120120
if !ENABLE_COVERAGE
121121
exhaustive_tests_CPPFLAGS += -DVERIFY
122122
endif
@@ -131,7 +131,7 @@ CPPFLAGS_FOR_BUILD +=-I$(top_srcdir) -I$(builddir)/src
131131
gen_context_OBJECTS = gen_context.o
132132
gen_context_BIN = gen_context$(BUILD_EXEEXT)
133133
gen_%.o: src/gen_%.c src/libsecp256k1-config.h
134-
$(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -c $< -o $@
134+
$(CC_FOR_BUILD) $(DEFS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -c $< -o $@
135135

136136
$(gen_context_BIN): $(gen_context_OBJECTS)
137137
$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $^ -o $@

secp256k1-zkp-sys/depend/secp256k1/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ Implementation details
3535
* Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1).
3636
* Using 5 52-bit limbs (including hand-optimized assembly for x86_64, by Diederik Huys).
3737
* Using 10 26-bit limbs (including hand-optimized assembly for 32-bit ARM, by Wladimir J. van der Laan).
38-
* Field inverses and square roots using a sliding window over blocks of 1s (by Peter Dettman).
3938
* Scalar operations
4039
* Optimized implementation without data-dependent branches of arithmetic modulo the curve's order.
4140
* Using 4 64-bit limbs (relying on __int128 support in the compiler).
4241
* Using 8 32-bit limbs.
42+
* Modular inverses (both field elements and scalars) based on [safegcd](https://gcd.cr.yp.to/index.html) with some modifications, and a variable-time variant (by Peter Dettman).
4343
* Group operations
4444
* Point addition formula specifically simplified for the curve equation (y^2 = x^3 + 7).
4545
* Use addition between points in Jacobian and affine coordinates where possible.
@@ -97,7 +97,8 @@ To create a report, `gcovr` is recommended, as it includes branch coverage repor
9797

9898
To create a HTML report with coloured and annotated source code:
9999

100-
$ gcovr --exclude 'src/bench*' --html --html-details -o coverage.html
100+
$ mkdir -p coverage
101+
$ gcovr --exclude 'src/bench*' --html --html-details -o coverage/coverage.html
101102

102103
Reporting a vulnerability
103104
------------

0 commit comments

Comments
 (0)