Skip to content

Commit 21e2d65

Browse files
Merge #159: Sync Upstream
b7ebe64 Test APIs of funcs that need an ecmult_gen ctx with static ctx (Jonas Nick) e82144e Fixup skew before global Z fixup (Peter Dettman) 40b624c Add tests for _gej_cmov (Peter Dettman) 8c13a9b ECDH skews by 0 or 1 (Peter Dettman) 1515099 Simpler and faster ecdh skew fixup (Peter Dettman) 3d7cbaf tests: Fix test whose result is implementation-defined (Tim Ruffing) 77a1975 Use xoshiro256++ PRNG instead of RFC6979 in tests (Pieter Wuille) 5f2efe6 secp256k1_testrand_int(2**N) -> secp256k1_testrand_bits(N) (Pieter Wuille) 3ed0d02 doc: add CHANGELOG template (Jonas Nick) 6f42dc1 doc: add release_process.md (Jonas Nick) 0bd3e42 build: set library version to 0.0.0 explicitly (Jonas Nick) b4b02fd build: change libsecp version from 0.1 to 0.1.0-pre (Jonas Nick) 05e049b ecmult: move `_ecmult_odd_multiples_table_globalz_windowa` (siv2r) b4ac1a1 ci: Run valgrind/memcheck tasks with 2 CPUs (Tim Ruffing) e70acab ci: Use Cirrus "greedy" flag to use idle CPU time when available (Tim Ruffing) d07e301 ci: Update brew on macOS (Tim Ruffing) 22382f0 ci: Test different ecmult window sizes (Tim Ruffing) 26a022a ci: Remove STATICPRECOMPUTATION (Tim Ruffing) 10461d8 precompute_ecmult: Always compute all tables up to default WINDOW_G (Tim Ruffing) 1287786 doc: Add comment to top of field_10x26_impl.h (Elliott Jin) 58da5bd doc: Fix upper bounds + cleanup in field_5x52_impl.h comment (Elliott Jin) 22d25c8 Add another ecmult_multi test (Pieter Wuille) 515e795 Improve checks at top of _fe_negate methods (Peter Dettman) e05da9e Fix c++ build (Pieter Wuille) c45386d Cleanup preprocessor indentation in precompute{,d}_ecmult{,_gen} (Pieter Wuille) 19d96e1 Split off .c file from precomputed_ecmult.h (Pieter Wuille) 1a6691a Split off .c file from precomputed_ecmult_gen.h (Pieter Wuille) bb36331 Simplify precompute_ecmult_print_* (Pieter Wuille) 38cd84a Compute ecmult tables at runtime for tests_exhaustive (Pieter Wuille) e458ec2 Move ecmult table computation code to separate file (Pieter Wuille) fc1bf9f Split ecmult table computation and printing (Pieter Wuille) 31feab0 Rename function secp256k1_ecmult_gen_{create_prec -> compute}_table (Pieter Wuille) 725370c Rename ecmult_gen_prec -> ecmult_gen_compute_table (Pieter Wuille) 075252c Rename ecmult_static_pre_g -> precomputed_ecmult (Pieter Wuille) 7cf47f7 Rename ecmult_gen_static_prec_table -> precomputed_ecmult_gen (Pieter Wuille) f95b810 Rename gen_ecmult_static_pre_g -> precompute_ecmult (Pieter Wuille) bae7768 Rename gen_ecmult_gen_static_prec_table -> precompute_ecmult_gen (Pieter Wuille) 7dfcece build: Remove #undef hack for ASM in the precomputation programs (Tim Ruffing) bb36fe9 ci: Test `make precomp` (Tim Ruffing) d94a37a build: Remove CC_FOR_BUILD stuff (Tim Ruffing) ad63bb4 build: Prebuild and distribute ecmult_gen table (Tim Ruffing) ac49361 prealloc: Get rid of manual memory management for prealloc contexts (Tim Ruffing) 6573c08 ecmult_gen: Tidy precomputed file and save space (Tim Ruffing) 5eba83f ecmult_gen: Precompute tables for all values of ECMULT_GEN_PREC_BITS (Tim Ruffing) fdb33dd refactor: Make PREC_BITS a parameter of ecmult_gen_build_prec_table (Tim Ruffing) a4875e3 refactor: Move default callbacks to util.h (Tim Ruffing) 4c94c55 doc: Remove obsolete hint for valgrind stack size (Tim Ruffing) 5106226 exhaustive_tests: Fix with ecmult_gen table with custom generator (Tim Ruffing) e1a7653 refactor: Make generator a parameter of ecmult_gen_create_prec_table (Tim Ruffing) 9ad09f6 refactor: Rename program that generates static ecmult_gen table (Tim Ruffing) 8ae18f1 refactor: Rename file that contains static ecmult_gen table (Tim Ruffing) 00d2fa1 ecmult_gen: Make code consistent with comment (Tim Ruffing) 3b0c218 ecmult_gen: Simplify ecmult_gen context after making table static (Tim Ruffing) e43ba02 refactor: Decouple table generation and ecmult_gen context (Tim Ruffing) 22dc2c0 ecmult_gen: Move table creation to new file and force static prec (Tim Ruffing) 099bad9 Comment and check a parameter for inf in secp256k1_ecmult_const. (Russell O'Connor) 6c0be85 Verify that secp256k1_ge_set_gej_zinv does not operate on infinity. a->x and a->y should not be used if the infinity flag is set. (Russell O'Connor) 5eb519e ci: reduce TEST_ITERS in memcheck run (Pieter Wuille) e2cf773 Test ecmult functions for all i*2^j for j=0..255 and odd i=1..255. (Pieter Wuille) c0cd7de build: add -no-undefined to libtool LDFLAGS (fanquake) fe32a79 build: pass win32-dll to LT_INIT (fanquake) 7c7ce87 build: Add a check that Valgrind actually supports a host platform (Hennadii Stepanov) 592661c ci: move test environment variable declaration to .cirrus.yml (siv2r) dcbe84b bench: add --help option to bench. (siv2r) 2b7c749 build: replace backtick command substitution with $() (fanquake) 60bf889 ecmult: fix definition of STRAUSS_SCRATCH_OBJECTS (Jonas Nick) 214042a build: don't append valgrind CPPFLAGS if not installed (fanquake) 812ff5c doc: remove use of 0xa0 "no break space" (fanquake) dc9b685 doc: Minor fixes in safegcd_implementation.md (Elliott Jin) 2332975 Fix typos (Dimitris Apostolou) 72de135 ci: Enable -g if we set CFLAGS manually (Tim Ruffing) 16d1322 refactor: Use (int)&(int) in boolean context to avoid compiler warning (MarcoFalke) 3b157c4 doc: Suggest keys.openpgp.org as keyserver in SECURITY.md (Tim Ruffing) 73a7472 doc: Replace apoelstra's GPG key by jonasnick's GPG key (Tim Ruffing) af6abcb Make bench support selecting which benchmarks to run (Pieter Wuille) 9f56bdf Merge bench_schnorrsig into bench (Pieter Wuille) 3208557 Merge bench_recover into bench (Pieter Wuille) 855e18d Merge bench_ecdh into bench (Pieter Wuille) 2a7be67 Combine bench_sign and bench_verify into single bench (Pieter Wuille) 5324f89 Make aux_rnd32==NULL behave identical to 0x0000..00. (Pieter Wuille) 2888640 VERIFY_CHECK precondition for secp256k1_fe_set_int. (Russell O'Connor) d49011f Make _set_fe_int( . , 0 ) set magnitude to 0 (Tim Ruffing) 23e2f66 bench: don't return 1 in have_flag() if argc = 1 (Jonas Nick) 96b1ad2 bench_ecmult: improve clarity of output (Jonas Nick) b4b1306 create csv file from the benchmark output (siv2r) 26a255b Shared benchmark format for command line and CSV outputs (siv2r) 044d956 Fix G.y parity in sage code (Pieter Wuille) b53e0cd Avoid overly-wide multiplications (Peter Dettman) 9be7b0f Avoid computing out-of-bounds pointer. (Tim Ruffing) bc08599 Remove OpenSSL testing support (Pieter Wuille) db4667d Make aux_rand32 arg to secp256k1_schnorrsig_sign const (Pieter Wuille) 189f6bc Fix unused parameter warnings when building without VERIFY (Jonas Nick) d439937 tests: remove `secp256k1_fe_verify` from tests.c and modify `secp256k1_fe_from_storage` to call `secp256k1_fe_verify` (siv2r) Pull request description: [bitcoin-core/secp256k1#986]: tests: remove `secp256k1_fe_verify` from tests.c and modify `_fe_from_storage` to call `_fe_verify` [bitcoin-core/secp256k1#987]: Fix unused parameter warnings when building without VERIFY [bitcoin-core/secp256k1#966]: Make aux_rand32 arg to secp256k1_schnorrsig_sign const [bitcoin-core/secp256k1#983]: [RFC] Remove OpenSSL testing support [bitcoin-core/secp256k1#952]: Avoid computing out-of-bounds pointer. [bitcoin-core/secp256k1#810]: Avoid overly-wide multiplications in 5x52 field mul/sqr [bitcoin-core/secp256k1#996]: Fix G.y parity in sage code [bitcoin-core/secp256k1#989]: Shared benchmark format for command line and CSV outputs [bitcoin-core/secp256k1#999]: bench_ecmult: improve clarity of output [bitcoin-core/secp256k1#943]: VERIFY_CHECK precondition for secp256k1_fe_set_int. [bitcoin-core/secp256k1#1002]: Make aux_rnd32==NULL behave identical to 0x0000..00. [bitcoin-core/secp256k1#991]: Merge all "external" benchmarks into a single bench binary [bitcoin-core/secp256k1#1007]: doc: Replace apoelstra's GPG key by jonasnick's GPG key [bitcoin-core/secp256k1#1009]: refactor: Use (int)&(int) in boolean context to avoid compiler warning [bitcoin-core/secp256k1#1011]: ci: Enable -g if we set CFLAGS manually [bitcoin-core/secp256k1#1012]: Fix typos [bitcoin-core/secp256k1#1010]: doc: Minor fixes in safegcd_implementation.md [bitcoin-core/secp256k1#1020]: doc: remove use of <0xa0> "no break space" [bitcoin-core/secp256k1#1019]: build: don't append valgrind CPPFLAGS if not installed (macOS) [bitcoin-core/secp256k1#1004]: ecmult: fix definition of STRAUSS_SCRATCH_OBJECTS [bitcoin-core/secp256k1#1025]: build: replace backtick command substitution with $() [bitcoin-core/secp256k1#1008]: bench.c: add `--help` option and ci: move env variables [bitcoin-core/secp256k1#1027]: build: Add a check that Valgrind actually supports a host platform [bitcoin-core/secp256k1#1022]: build: Windows DLL additions [bitcoin-core/secp256k1#920]: Test all ecmult functions with many j*2^i combinations [bitcoin-core/secp256k1#942]: Verify that secp256k1_ge_set_gej_zinv does not operate on infinity. [bitcoin-core/secp256k1#988]: Make signing table fully static [bitcoin-core/secp256k1#1042]: Follow-ups to making all tables fully static [bitcoin-core/secp256k1#816]: Improve checks at top of _fe_negate methods [bitcoin-core/secp256k1#1044]: Add another ecmult_multi test [bitcoin-core/secp256k1#1030]: doc: Fix upper bounds + cleanup in field_5x52_impl.h comment [bitcoin-core/secp256k1#1047]: ci: Various improvements [bitcoin-core/secp256k1#1053]: ecmult: move `_ecmult_odd_multiples_table_globalz_windowa` [bitcoin-core/secp256k1#964]: Add release-process.md [bitcoin-core/secp256k1#1052]: Use xoshiro256++ instead of RFC6979 for tests [bitcoin-core/secp256k1#1054]: tests: Fix test whose result is implementation-defined [bitcoin-core/secp256k1#1029]: Simpler and faster ecdh skew fixup This PR can be recreated with `./contrib/sync-upstream.sh range a1102b1`. ACKs for top commit: apoelstra: utACK b7ebe64 real-or-random: ACK b7ebe64 diff looks good. tested on my machine, also on valgrind. Tree-SHA512: 8b01347bbb9ac35cb93df628eaaf2a997fc8182046588bccc48a0623e9595d40cad2d46102a9c62c819ff77069331f344361138fd8ad0afc81bba9c1690bb541
2 parents b220661 + b7ebe64 commit 21e2d65

Some content is hidden

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

69 files changed

+11649
-1928
lines changed

.cirrus.yml

+37-55
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ env:
44
# Specific warnings can be disabled with -Wno-error=foo.
55
# -pedantic-errors is not equivalent to -Werror=pedantic and thus not implied by -Werror according to the GCC manual.
66
WERROR_CFLAGS: -Werror -pedantic-errors
7-
MAKEFLAGS: -j2
7+
MAKEFLAGS: -j4
88
BUILD: check
99
### secp256k1 config
10-
STATICPRECOMPUTATION: yes
10+
ECMULTWINDOW: auto
1111
ECMULTGENPRECISION: auto
1212
ASM: no
1313
WIDEMUL: auto
@@ -24,9 +24,9 @@ env:
2424
MUSIG: no
2525
ECDSAADAPTOR: no
2626
### test options
27-
TEST_ITERS:
27+
SECP256K1_TEST_ITERS:
2828
BENCH: yes
29-
BENCH_ITERS: 2
29+
SECP256K1_BENCH_ITERS: 2
3030
CTIMETEST: yes
3131

3232
cat_logs_snippet: &CAT_LOGS
@@ -55,14 +55,19 @@ merge_base_script_snippet: &MERGE_BASE
5555
- git config --global user.name "ci"
5656
- git merge FETCH_HEAD # Merge base to detect silent merge conflicts
5757

58-
task:
59-
name: "x86_64: Linux (Debian stable)"
58+
linux_container_snippet: &LINUX_CONTAINER
6059
container:
6160
dockerfile: ci/linux-debian.Dockerfile
6261
# Reduce number of CPUs to be able to do more builds in parallel.
6362
cpu: 1
63+
# Gives us more CPUs for free if they're available.
64+
greedy: true
6465
# More than enough for our scripts.
6566
memory: 1G
67+
68+
task:
69+
name: "x86_64: Linux (Debian stable)"
70+
<< : *LINUX_CONTAINER
6671
matrix: &ENV_MATRIX
6772
- env: {WIDEMUL: int64, RECOVERY: yes}
6873
- env: {WIDEMUL: int64, ECDH: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes, ECDSA_S2C: yes, RANGEPROOF: yes, WHITELIST: yes, GENERATOR: yes, MUSIG: yes, ECDSAADAPTOR: yes}
@@ -71,12 +76,11 @@ task:
7176
- env: {WIDEMUL: int128, ECDH: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes, ECDSA_S2C: yes, RANGEPROOF: yes, WHITELIST: yes, GENERATOR: yes, MUSIG: yes, ECDSAADAPTOR: yes}
7277
- env: {WIDEMUL: int128, ASM: x86_64}
7378
- env: { RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes, ECDSA_S2C: yes, RANGEPROOF: yes, WHITELIST: yes, GENERATOR: yes, MUSIG: yes, ECDSAADAPTOR: yes}
74-
- env: { STATICPRECOMPUTATION: no}
7579
- env: {BUILD: distcheck, WITH_VALGRIND: no, CTIMETEST: no, BENCH: no}
7680
- env: {CPPFLAGS: -DDETERMINISTIC}
7781
- env: {CFLAGS: -O0, CTIMETEST: no}
78-
- env: { ECMULTGENPRECISION: 2 }
79-
- env: { ECMULTGENPRECISION: 8 }
82+
- env: { ECMULTGENPRECISION: 2, ECMULTWINDOW: 2 }
83+
- env: { ECMULTGENPRECISION: 8, ECMULTWINDOW: 4 }
8084
matrix:
8185
- env:
8286
CC: gcc
@@ -89,10 +93,7 @@ task:
8993

9094
task:
9195
name: "i686: Linux (Debian stable)"
92-
container:
93-
dockerfile: ci/linux-debian.Dockerfile
94-
cpu: 1
95-
memory: 1G
96+
<< : *LINUX_CONTAINER
9697
env:
9798
HOST: i686-linux-gnu
9899
ECDH: yes
@@ -147,8 +148,9 @@ task:
147148
## - rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
148149
##
149150
brew_valgrind_pre_script:
151+
- brew update
150152
- brew config
151-
- brew tap --shallow LouisBrunner/valgrind
153+
- brew tap LouisBrunner/valgrind
152154
# Fetch valgrind source but don't build it yet.
153155
- brew fetch --HEAD LouisBrunner/valgrind/valgrind
154156
brew_valgrind_cache:
@@ -178,13 +180,10 @@ task:
178180

179181
task:
180182
name: "s390x (big-endian): Linux (Debian stable, QEMU)"
181-
container:
182-
dockerfile: ci/linux-debian.Dockerfile
183-
cpu: 1
184-
memory: 1G
183+
<< : *LINUX_CONTAINER
185184
env:
186185
WRAPPER_CMD: qemu-s390x
187-
TEST_ITERS: 16
186+
SECP256K1_TEST_ITERS: 16
188187
HOST: s390x-linux-gnu
189188
WITH_VALGRIND: no
190189
ECDH: yes
@@ -207,13 +206,10 @@ task:
207206

208207
task:
209208
name: "ARM32: Linux (Debian stable, QEMU)"
210-
container:
211-
dockerfile: ci/linux-debian.Dockerfile
212-
cpu: 1
213-
memory: 1G
209+
<< : *LINUX_CONTAINER
214210
env:
215211
WRAPPER_CMD: qemu-arm
216-
TEST_ITERS: 16
212+
SECP256K1_TEST_ITERS: 16
217213
HOST: arm-linux-gnueabihf
218214
WITH_VALGRIND: no
219215
ECDH: yes
@@ -231,13 +227,10 @@ task:
231227

232228
task:
233229
name: "ARM64: Linux (Debian stable, QEMU)"
234-
container:
235-
dockerfile: ci/linux-debian.Dockerfile
236-
cpu: 1
237-
memory: 1G
230+
<< : *LINUX_CONTAINER
238231
env:
239232
WRAPPER_CMD: qemu-aarch64
240-
TEST_ITERS: 16
233+
SECP256K1_TEST_ITERS: 16
241234
HOST: aarch64-linux-gnu
242235
WITH_VALGRIND: no
243236
ECDH: yes
@@ -252,13 +245,10 @@ task:
252245

253246
task:
254247
name: "ppc64le: Linux (Debian stable, QEMU)"
255-
container:
256-
dockerfile: ci/linux-debian.Dockerfile
257-
cpu: 1
258-
memory: 1G
248+
<< : *LINUX_CONTAINER
259249
env:
260250
WRAPPER_CMD: qemu-ppc64le
261-
TEST_ITERS: 16
251+
SECP256K1_TEST_ITERS: 16
262252
HOST: powerpc64le-linux-gnu
263253
WITH_VALGRIND: no
264254
ECDH: yes
@@ -273,13 +263,10 @@ task:
273263

274264
task:
275265
name: "x86_64 (mingw32-w64): Windows (Debian stable, Wine)"
276-
container:
277-
dockerfile: ci/linux-debian.Dockerfile
278-
cpu: 1
279-
memory: 1G
266+
<< : *LINUX_CONTAINER
280267
env:
281268
WRAPPER_CMD: wine64-stable
282-
TEST_ITERS: 16
269+
SECP256K1_TEST_ITERS: 16
283270
HOST: x86_64-w64-mingw32
284271
WITH_VALGRIND: no
285272
ECDH: yes
@@ -295,10 +282,7 @@ task:
295282
# Sanitizers
296283
task:
297284
timeout_in: 120m
298-
container:
299-
dockerfile: ci/linux-debian.Dockerfile
300-
cpu: 1
301-
memory: 2G
285+
<< : *LINUX_CONTAINER
302286
env:
303287
ECDH: yes
304288
RECOVERY: yes
@@ -311,30 +295,31 @@ task:
311295
MUSIG: yes
312296
ECDSAADAPTOR: yes
313297
CTIMETEST: no
314-
EXTRAFLAGS: "--disable-openssl-tests"
315298
matrix:
316299
- name: "Valgrind (memcheck)"
300+
container:
301+
cpu: 2
317302
env:
318303
# 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)
319304
WRAPPER_CMD: "valgrind --error-exitcode=42"
320-
TEST_ITERS: 8
305+
SECP256K1_TEST_ITERS: 2
321306
- name: "UBSan, ASan, LSan"
307+
container:
308+
memory: 2G
322309
env:
323-
CFLAGS: "-fsanitize=undefined,address"
324-
CFLAGS_FOR_BUILD: "-fsanitize=undefined,address"
310+
CFLAGS: "-fsanitize=undefined,address -g"
325311
UBSAN_OPTIONS: "print_stacktrace=1:halt_on_error=1"
326312
ASAN_OPTIONS: "strict_string_checks=1:detect_stack_use_after_return=1:detect_leaks=1"
327313
LSAN_OPTIONS: "use_unaligned=1"
328-
TEST_ITERS: 32
314+
SECP256K1_TEST_ITERS: 32
329315
# Try to cover many configurations with just a tiny matrix.
330316
matrix:
331317
- env:
332318
ASM: auto
333-
STATICPRECOMPUTATION: yes
334319
- env:
335320
ASM: no
336-
STATICPRECOMPUTATION: no
337321
ECMULTGENPRECISION: 2
322+
ECMULTWINDOW: 2
338323
matrix:
339324
- env:
340325
CC: clang
@@ -348,15 +333,12 @@ task:
348333

349334
task:
350335
name: "C++ -fpermissive"
351-
container:
352-
dockerfile: ci/linux-debian.Dockerfile
353-
cpu: 1
354-
memory: 1G
336+
<< : *LINUX_CONTAINER
355337
env:
356338
# ./configure correctly errors out when given CC=g++.
357339
# We hack around this by passing CC=g++ only to make.
358340
CC: gcc
359-
MAKEFLAGS: -j2 CC=g++ CFLAGS=-fpermissive
341+
MAKEFLAGS: -j4 CC=g++ CFLAGS=-fpermissive\ -g
360342
WERROR_CFLAGS:
361343
EXPERIMENTAL: yes
362344
ECDH: yes

.gitattributes

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
src/ecmult_static_pre_g.h linguist-generated
1+
src/precomputed_ecmult.c linguist-generated
2+
src/precomputed_ecmult_gen.c linguist-generated

.gitignore

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
bench_inv
2-
bench_ecdh
1+
bench
32
bench_ecmult
43
bench_generator
54
bench_rangeproof
6-
bench_schnorrsig
7-
bench_sign
8-
bench_verify
9-
bench_recover
105
bench_internal
116
tests
127
exhaustive_tests
13-
gen_context
14-
gen_ecmult_static_pre_g
8+
precompute_ecmult_gen
9+
precompute_ecmult
1510
valgrind_ctime_test
1611
*.exe
1712
*.so
1813
*.a
14+
*.csv
1915
!.gitignore
2016

2117
Makefile
@@ -47,7 +43,6 @@ coverage.*.html
4743

4844
src/libsecp256k1-config.h
4945
src/libsecp256k1-config.h.in
50-
src/ecmult_static_context.h
5146
build-aux/config.guess
5247
build-aux/config.sub
5348
build-aux/depcomp

0 commit comments

Comments
 (0)