1716 Commits

Author SHA1 Message Date
Russell O'Connor
f20dcbbad1 Correct typo. 2021-08-20 11:11:26 -04:00
Russell O'Connor
16a3cc07e8 Generate ecmult_static_pre_g.h
This header contains a static array that replaces the ecmult_context pre_g and pre_g_128 tables.
The gen_ecmult_static_pre_g program generates this header file.
2021-08-20 11:11:26 -04:00
Russell O'Connor
8de2d86a06 Bump memory limits in advance of making the ecmult context static. 2021-08-20 11:11:26 -04:00
Jonas Nick
d7ec49a689
Merge bitcoin-core/secp256k1#969: ci: Fixes after Debian release
5d5c74a057f3951677691113747952f4cbdde86b tests: Rewrite code to circument potential bug in clang (Tim Ruffing)
3d2f492ceb76eea93d3a9f85f80baec7b5842160 ci: Install libasan6 (instead of 5) after Debian upgrade (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 5d5c74a057f3951677691113747952f4cbdde86b

Tree-SHA512: 540ede482214bf9feaa607de52a69f6d34169dd98fb14bd3d003f4c8f722c1eebed56eb9d933e742f36d8886c25bfa9fa0ebbed5b0c3b161f04dc26180f5d214
2021-08-20 14:17:16 +00:00
Tim Ruffing
5d5c74a057 tests: Rewrite code to circument potential bug in clang
clang 7 to 11 (and maybe earlier versions) warn about recid being
potentially unitiliazed in "CHECK(recid >= 0 [...]", which was mitigated
in commit 3d2cf6c5bd35b0d72716b47bdd7e3892388aafc4 by initializing recid
to make clang happy but VG_UNDEF'ing the variable after initializiation
in order to ensure valgrind's memcheck analysis will still be sound and
complain if recid is not actually written to when creating a signature.

However, it turns out that at least for binaries produced by clang 11
(but not clang 7), valgrind complains about a branch on unitialized data
in the recid variable in that line before *and* after the aforementioned
commit. While the complaint after the commit could be spurious (clang
knows that recid is initialized, so it's fine to access it even though
the access is stupid), the complaint before the commit indicates a real
problem: it might be the case that clang is performing a wrong
optimization that leads to a situation where recid is really not
guaranteed to be initialized when it's accessed. As a result, clang
warns about this and generates code that just accesses the variable.

I'm not going to bother with this further because this is fixed in
clang 12 and the problem is just in our test code, not in the tested
code.

This commit rewrites the code in a way that groups the signing together
with the CHECK such that it's very easy to figure out for clang that
recid will be initialized properly. This seems to circument the issue.
2021-08-19 13:41:40 +02:00
Tim Ruffing
3d2f492ceb ci: Install libasan6 (instead of 5) after Debian upgrade 2021-08-19 12:11:11 +02:00
Jonas Nick
9447642140
Merge elementsproject/secp256k1-zkp#142: musig: fix session_init argument NULL check
9124ce0d9cd76312ac74207cb4733c04a82738b3 musig: fix session_init argument NULL check (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 9124ce0d9cd76312ac74207cb4733c04a82738b3

Tree-SHA512: 15b6e4012a2444803563151a37e3340e3aa59729ccafebfd80aac17b93f5429dc2b3c99e37119bfd68523f1e58ffd3efca67922d6cb4a2bbb7c8679de9f36097
2021-08-18 18:01:43 +00:00
Jonas Nick
9124ce0d9c musig: fix session_init argument NULL check 2021-08-18 14:02:29 +00:00
Jonas Nick
881b15cb43
Merge elementsproject/secp256k1-zkp#139: musig: use tagged hash for the list of pubkeys to aggregate
8f093be374da794b835302bfb81a72e2bdd51d26 musig: use tagged hash for the list of pubkeys to aggregate (Jonas Nick)
a6a768a4bf3a243609e508c492307cb0fe754bda musig: make key agg test vector more precise (Jonas Nick)

Pull request description:

Top commit has no ACKs.

Tree-SHA512: 5369dc5b4039dd4cda2c50282db2882c088b96e1daa5801240f92be1832ed8f29317fdbfc3cab211707155c284a68dc593967f3141703e2544f6b8dc1553e44d
2021-08-02 11:34:07 +00:00
Andrew Poelstra
90580edcc9
Merge pull request #140 from apoelstra/2021-07--resync
Upstream PRs 879, 959, 955, 944, 951, 960, 844, 963, 965
2021-07-28 21:58:53 +00:00
Andrew Poelstra
6ad66de680 rangeproof: add an (unnecessary) variable initialization to shut up CI 2021-07-27 18:15:58 +00:00
Andrew Poelstra
2979e4d9d4 Merge commits '8ae56e33 75ce488c 4866178d 446d28d9 253f90cd ec3aaa50 0440945f 7688a4f1 be8d9c26 ' into temp-merge-965 2021-07-27 18:12:45 +00:00
Jonas Nick
8f093be374 musig: use tagged hash for the list of pubkeys to aggregate
This is done to use tagged hashing consistently. Changes the musig test vectors.
2021-07-27 11:37:10 +00:00
Jonas Nick
a6a768a4bf musig: make key agg test vector more precise 2021-07-27 10:06:22 +00:00
Jonas Nick
5d2df05419
Merge elementsproject/secp256k1-zkp#120: Add MuSig Key Aggregation spec
fc26ca8ddef0629c7df190f1cc92157fce64e370 musig: remove unnecessary constant time normalize in combine (Jonas Nick)
48f63efe683bf5539324a52fa43f4a2a32285a91 musig: remove unnecessary branch in pubkey_tweak_add (Jonas Nick)
5860b5e0fe78b2bd34c1defb6ce3ad879029463e musig: do not also require schnorrsig module config flag (Jonas Nick)
f27fd1d5e754fc9b919d9c9f6e47a6eb8c9e2af7 musig: improve test coverage of pubkey_combine (Jonas Nick)
56014e8ca01e88e0fbf2f125363c4e7cc48039df musig: change pubkey_combine arg to array of pointers to pks (Jonas Nick)
08fa02d579154e26097fd582a409b814ef3dedba musig: add key aggregation spec draft (Jonas Nick)
4a9b059b16d7925a03bd0d695efa1637ad7e9826 musig: rename Musig coefficient to KeyAgg coefficient (Jonas Nick)
4bc46d836e7877715db54ee039ade407ee44ea45 musig: optimize key aggregation using const 1 for 2nd key (Jonas Nick)
2310849f50fa71f10ebd2f44669330f7ce76fc94 musig: compute musig coefficient by hashing key instead of index (Jonas Nick)
9683c8a7eb6cefa070cd1a931d8dee714496ee82 musig: add static test vectors for key aggregation (Jonas Nick)
9b3d7bf53617c962cd291039d5ce97088c4513cc extrakeys: add xonly_sort function (Jonas Nick)
f31affd8a613ebbdb07050a90ff1ccb2b1f0a1fd extrakeys: add hsort, in-place, iterative heapsort (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK fc26ca8ddef0629c7df190f1cc92157fce64e370

Tree-SHA512: fa29fe259d0e98d634782c0fb36308716dc3ffa6e35fe47b87fc25b2e5dd0a9859a72da0b9d669f03d379bc3ed972c5961995762b2f7e4ac16b9c6b5d8c4721d
2021-07-18 17:56:28 +00:00
Jonas Nick
fc26ca8dde musig: remove unnecessary constant time normalize in combine 2021-07-14 19:59:38 +00:00
Jonas Nick
48f63efe68 musig: remove unnecessary branch in pubkey_tweak_add 2021-07-14 19:59:38 +00:00
Jonas Nick
5860b5e0fe musig: do not also require schnorrsig module config flag
Also add musig to build options output.
2021-07-14 19:59:38 +00:00
Jonas Nick
f27fd1d5e7 musig: improve test coverage of pubkey_combine 2021-07-14 19:59:38 +00:00
Jonas Nick
56014e8ca0 musig: change pubkey_combine arg to array of pointers to pks
... instead of taking an array of pubkeys directly
2021-07-14 19:59:38 +00:00
Jonas Nick
08fa02d579 musig: add key aggregation spec draft 2021-07-14 19:59:38 +00:00
Jonas Nick
4a9b059b16 musig: rename Musig coefficient to KeyAgg coefficient
This is done to be consistent with the MuSig2 paper
2021-07-14 19:59:19 +00:00
Jonas Nick
4bc46d836e musig: optimize key aggregation using const 1 for 2nd key 2021-07-14 19:58:54 +00:00
Jonas Nick
2310849f50 musig: compute musig coefficient by hashing key instead of index 2021-07-14 19:41:38 +00:00
Jonas Nick
9683c8a7eb musig: add static test vectors for key aggregation 2021-07-14 19:41:38 +00:00
Jonas Nick
9b3d7bf536 extrakeys: add xonly_sort function 2021-07-14 19:41:38 +00:00
Jonas Nick
f31affd8a6 extrakeys: add hsort, in-place, iterative heapsort 2021-07-14 19:29:30 +00:00
Tim Ruffing
be8d9c262f
Merge bitcoin-core/secp256k1#965: gen_context: Don't use any ASM
aeece4459977b69962bcd1e1ee8845c18c74ff8f gen_context: Don't use any ASM (Tim Ruffing)

Pull request description:

  See https://github.com/bitcoin/bitcoin/issues/22441 , we need to wait for the testing results there.

ACKs for top commit:
  sipa:
    utACK aeece4459977b69962bcd1e1ee8845c18c74ff8f
  jonasnick:
    ACK aeece4459977b69962bcd1e1ee8845c18c74ff8f

Tree-SHA512: 52ff90f3dedda90124140de1c2c1c065a2f9374930d6b988d35c37f5eeae97f7d557b7ab0cf99d22add5a76ff8a3e06226572e43949e12d1048cb323d1b3d92b
2021-07-14 18:57:40 +02:00
Jonas Nick
d9560e0af7
Merge elementsproject/secp256k1-zkp#136: Eliminate a wrong -Wmaybe-uninitialized warning in GCC
cc0b279568d6edaa0b966b4333a0008f4ef63efa Eliminate a wrong -Wmaybe-uninitialized warning in GCC (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK cc0b279568d6edaa0b966b4333a0008f4ef63efa

Tree-SHA512: ee9ae840ba7df471f566fc9b4d5bdf04e1d0759bd6fec1d1144e0e7b3f12603865371d238f8a2ee4648db88224e5ea582ab837c2cbc041d2582141736ebe5fd0
2021-07-14 13:57:13 +00:00
Tim Ruffing
aeece44599 gen_context: Don't use any ASM 2021-07-14 11:15:36 +02:00
Jonas Nick
6db00f5b2e
Merge elementsproject/secp256k1-zkp#132: Upstream PRs 831, 907, 903, 889, 918, 906, 928, 922, 933, Merge bitcoin-core/secp256k1#936: Fix gen_context/ASM build on ARM, 925, 937, 926, Merge bitcoin-core/secp256k1#940: contrib: Explain explicit header guards, 850, 930, 941, 846, 947, 662, 950
f09497ea3e07d7a730a6ff3479dca18b848ef729 CI: tweak cirrus.yml to prevent OOM and timeout w sanitizer/valgrind (Jonas Nick)
7226cf215aaca80fcddcc5242c8ea11d2b35c85b ecdsa_adaptor: fix too small buffer in tests (Jonas Nick)
b053e853d4f556499decb5c50af473f91996f46e ecdsa_adaptor: fix test case with invalid signature (Jonas Nick)
d27e459861026ddaa376c9cb2acf93ad3c668ee3 Revert "Remove unused Jacobi symbol support" (Jonas Nick)
c58c4ea4707ec5934e49890db881914df3a341b4 ci: Add ppc64le build (Tim Ruffing)
8f879c2887e166da2ec959ce78078f7b84ebfdf9 Fix array size in bench_ecmult (Jonas Nick)
2fe1b50df16c9f41ea77b151634d734b930eeddd Add ecmult_gen, ecmult_const and ecmult to benchmark (Jonas Nick)
593e6bad9c5cda05dd72a5bd8266c4880113b4af Clean up ecmult_bench to make space for more benchmarks (Jonas Nick)
a35fdd3478f7556dfb9b83f32aaa319ccadff9a9 ci: Run PRs on merge result even for i686 (Tim Ruffing)
02dcea1ad9441f857c7768e2b7d304bb19fd2a0c ci: Make test iterations configurable and tweak for sanitizer builds (Tim Ruffing)
489ff5c20a1457d0e7d765c8f05856c50c4777a8 tests: Treat empty SECP2561_TEST_ITERS as if it was unset (Tim Ruffing)
fcfcb97e74b55a107290d44c81c049d6168e954f ci: Simplify to use generic wrapper for QEMU, Valgrind, etc (Tim Ruffing)
de4157f13acc43d521e3133ff1d2e7d67484f0ac ci: Run ASan/LSan and reorganize sanitizer and Valgrind jobs (Tim Ruffing)
09b3bb8648fec903e4ac2ec1d047503d5f0f48d7 Clean up git tree (Tim Ruffing)
8bbad7a18e5dc5054b27ae44ea0c8dffe050f6bf Add asm build to ARM32 CI (Pieter Wuille)
7d65ed5214273275841f5aa272ad561df7ea7f21 Add ARM32/ARM64 CI (Pieter Wuille)
6eceec6d566898a5c157630e47f95b260767026b add `secp256k1_xonly_pubkey_cmp` method (Andrew Poelstra)
0d9561ae879848191a14bcc67db87cbfd44fb69a add `secp256k1_ec_pubkey_cmp` method (Andrew Poelstra)
22a9ea154a280987be7cf8322156c8738c41c3c5 contrib: Explain explicit header guards (Tim Ruffing)
0881633dfd0c530a915cf63be295f00841c94cc4 secp256k1.h: clarify that by default arguments must be != NULL (Jonas Nick)
14c9739a1fb485bb56dbe3447132a37bcbef4e22 tests: Improve secp256k1_ge_set_all_gej_var for some infinity inputs (Tim Ruffing)
4a19668c37bc77d0165f4a1c0e626e321e9c4a09 tests: Test secp256k1_ge_set_all_gej_var for all infinity inputs (Tim Ruffing)
45b6468d7e3ed9849ed474c71e9a9479de1a77db Have secp256k1_ge_set_all_gej_var initialize all fields. Previous behaviour would not initialize r->y values in the case where infinity is passed in. Furthermore, the previous behaviour wouldn't initialize anything in the case where all inputs were infinity. (Russell O'Connor)
31c0f6de413e521731ad0e63424431b3dd49cec8 Have secp256k1_gej_double_var initialize all fields. Previous behaviour would not initialize r->x and r->y values in the case where infinity is passed in. (Russell O'Connor)
dd6c3de322740a3054cf6a1994a38dc8f201b473 Have secp256k1_ge_set_gej_var initialize all fields. Previous behaviour would not initialize r->x and r->y values in the case where infinity is passed in. (Russell O'Connor)
3c90bdda95aa4e79ff33bfbbbe91872417650ae9 change local lib headers to be relative for those pointing at "include/" dir (William Bright)
c8483520c9077905a1dc8b9adb88b6ea2a3bd9ef Makefile.am: Don't pass a variable twice (Tim Ruffing)
2161f31785e66e4e46471208610b5e3e98331849 Makefile.am: Honor config when building gen_context (Tim Ruffing)
99f47c20ec41279075d6b3ae64c9c1a84b40a6f8 gen_context: Don't use external ASM because it complicates the build (Tim Ruffing)
99e2d5be0dba938b7701d157cba86252db9eb61c Avoids a missing brace warning in schnorrsig/tests_impl.h on old compilers. (Gregory Maxwell)
ed5a199bed65bf084f34ce18d35807d31a1c75bb tests: fopen /dev/urandom in binary mode (Tim Ruffing)
4dc37bf81b55b9a3ffcf09f7a212436d25844710 Add mingw32-w64/wine CI build (Pieter Wuille)
ae9e648526ceaf7cd97ba4dfe3c105db8e226c35 Define SECP256K1_BUILD in secp256k1.c directly. (Gregory Maxwell)
be0609fd54af95a15b76cea150e6907d581318dd Add unit tests for edge cases with delta=1/2 variant of divsteps (Pieter Wuille)
cd393ce2283e0e7234ea39a15c4931715f4dde1e Optimization: only do 59 hddivsteps per iteration instead of 62 (Pieter Wuille)
277b224b6aba942efbac4a6aae1054035a68d8dd Use modified divsteps with initial delta=1/2 for constant-time (Pieter Wuille)
376ca366db0469f39b93af0af762090986ea75f2 Fix typo in explanation (Pieter Wuille)
07067967ee9dcc4af10fd3a565ffb846a2593e92 add ECMULT_GEN_PREC_BITS to basic_config.h (Aaron Voisine)
a3aa2628c7b675814157556d774872755c9f1aba gen_context: Don't include basic-config.h (Tim Ruffing)
99a1cfec1740a914aa416a87fd0acbde5426b969 print warnings for conditional-uninitialized (PiRK)
3d2cf6c5bd35b0d72716b47bdd7e3892388aafc4 initialize variable in tests (PiRK)
23c3fb629b905deebc4bcc9914bcfff7b9aedacd Make argument of fe_normalizes_to_zero{_var} const (Pieter Wuille)
4504472269df06b8765b134d41f86619cdcdf8f6 changed import to use brackets <> for openssl as they are not local to the project (William Bright)
24ad04fc064e71abdf973e061c30eb1f3f78db39 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS (Pieter Wuille)
ebc1af700f9ec6e96586152b7090a2a6494308c3 Optimization: track f,g limb count and pass to new variable-time update_fg_var (Peter Dettman)
b306935ac12bb24fd931d735b4dfc07f707e7447 Optimization: use formulas instead of lookup tables for cancelling g bits (Peter Dettman)
9164a1b6582e2fc833c760a3403d26b9b0b3b7b3 Optimization: special-case zero modulus limbs in modinv64 (Pieter Wuille)
1f233b3fa05eb29a744487e0682d925055fb0d4c Remove num/gmp support (Pieter Wuille)
20448b8d09a492afcfcae7721033c13a44a776fd Remove unused Jacobi symbol support (Pieter Wuille)
5437e7bdfbffddf69fdf7b4af7e997c78f5dafbf Remove unused scalar_sqr (Pieter Wuille)
aa9cc5218001f14f4312bde1058417d4b755fd11 Improve field/scalar inverse tests (Pieter Wuille)
1e0e885c8ac814c3621d9e43e66d60f25e324e8e Make field/scalar code use the new modinv modules for inverses (Pieter Wuille)
436281afdcb68991395f97338197d208212965e2 Move secp256k1_fe_inverse{_var} to per-impl files (Pieter Wuille)
aa404d53bef21d252a23171381d4bfda6e7e25c6 Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files (Pieter Wuille)
08d54964e51f318ef0cc4ef09d64cfa5ec143c5c Improve bounds checks in modinv modules (Pieter Wuille)
151aac00d31ba5e94800376f6fda4193071168af Add tests for modinv modules (Pieter Wuille)
d8a92fcc4c65cf189ec7bd5298dad8479347c442 Add extensive comments on the safegcd algorithm and implementation (Pieter Wuille)
8e415acba25830da9c23a4dd5531ebfc6b65aae7 Add safegcd based modular inverse modules (Peter Dettman)
de0a643c3dc2c40a447e670cfa1c1683c79c9297 Add secp256k1_ctz{32,64}_var functions (Pieter Wuille)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK f09497ea3e07d7a730a6ff3479dca18b848ef729

Tree-SHA512: 6cf3e96c5974e9aa17bd649fa7fdd738090ec3ab8c99e144fec397c086a24adc2ace9a5218a3c527989fc07e1d5c669027e4c895caf92d22771c8414b2a9bf35
2021-07-13 22:22:27 +00:00
Tim Ruffing
cc0b279568 Eliminate a wrong -Wmaybe-uninitialized warning in GCC 2021-07-13 17:30:05 +02:00
Jonas Nick
f09497ea3e CI: tweak cirrus.yml to prevent OOM and timeout w sanitizer/valgrind 2021-07-13 14:09:58 +00:00
Jonas Nick
7226cf215a ecdsa_adaptor: fix too small buffer in tests
Also add a specific test that fails adaptor sig deserialization because with the
correct size buffer that's not guaranteed anymore with the existing test.
2021-07-13 14:09:58 +00:00
Jonas Nick
b053e853d4 ecdsa_adaptor: fix test case with invalid signature
Previously the ECDSA signature had an overflowing s value, which after the sync
with upstream results in a failing VERIFY_CHECK in the inversion function.
However, normally parsed signatures shouldn't contain overflowing s values.
2021-07-13 14:09:58 +00:00
Jonas Nick
91b64770c3
Merge elementsproject/secp256k1-zkp#135: sync-upstream: fix "end" parameter for specifying range
907633e2e9abec15be48256f00c2f4c76855a9f6 sync-upstream: fix "end" parameter for specifying range (Tim Ruffing)
394f49fd1a6e88d2a5f9a6c80da897ec389fc59c sync-upstream: quote variables (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    utACK 907633e2e9abec15be48256f00c2f4c76855a9f6

Tree-SHA512: ba7834bf7fce403de29027e8df9387bbc6df5ba62eaacc31547bff0587962620475940b253966d0af0a3a4b3b12b4f72b64c8832aeffc638a308405a3945b6c2
2021-07-12 18:18:42 +00:00
Tim Ruffing
907633e2e9 sync-upstream: fix "end" parameter for specifying range 2021-07-12 18:24:04 +02:00
Tim Ruffing
394f49fd1a sync-upstream: quote variables 2021-07-12 18:23:18 +02:00
Jonas Nick
1bb5db3d60
Merge elementsproject/secp256k1-zkp#134: sync-upstream: parse merge commits w/ and w/o repo identifier
9321d42f7510e08e0e9f3c0a19fd55cfb7d07775 sync-upstream: parse merge commits w/ and w/o repo identifier (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 9321d42f7510e08e0e9f3c0a19fd55cfb7d07775

Tree-SHA512: 89347703b56199327813b9ac72d2e4b9620d852fb4059855f87a245f60f72605acf57ba07d073affe7eb0c4e7e97814f410679f4ed1e067939fab50c18a1eeee
2021-07-12 14:04:55 +00:00
Tim Ruffing
9321d42f75 sync-upstream: parse merge commits w/ and w/o repo identifier 2021-07-12 15:21:38 +02:00
Jonas Nick
7688a4f13a
Merge bitcoin-core/secp256k1#963: "Schnorrsig API overhaul" fixups
90e83449b2c2e4046af755e35fdeee579a468f31 ci: Add C++ test (Tim Ruffing)
f698caaff6a263390d7ded5be4751dbc1c862b1e Use unsigned char consistently for byte arrays (Tim Ruffing)
b5b8e7b7190aed619a1fa83bf1794fddef90346d Don't declare constants twice (Tim Ruffing)
769528f30714a1e5503a7abefad25fd89f0ef237 Don't use string literals for char arrays without NUL termination (Tim Ruffing)
2cc3cfa58382582fc26eb91e3243153e1d06ce77 Fix -Wmissing-braces warning in clang (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 90e83449b2c2e4046af755e35fdeee579a468f31

Tree-SHA512: c26ba3db7514399c502f6c5c6f6ce6703459d83d831765042e331b051aeee282641197c3ae881c614f51ca714a818c5528410d288aadbd3e92361c1e9c129afe
2021-07-05 20:59:43 +00:00
Tim Ruffing
90e83449b2 ci: Add C++ test 2021-07-05 13:57:40 +02:00
Elichai Turkel
adec5a1638 Add missing null check for ctx and input keys in the public API 2021-07-04 12:47:46 +03:00
Elichai Turkel
f4edfc7581 Improve consistency for NULL arguments in the public interface 2021-07-04 12:47:45 +03:00
Tim Ruffing
f698caaff6 Use unsigned char consistently for byte arrays
C++ does not allow initialization with string literals but we do it in other
places and -fpermissive will convince g++ to compile.
2021-07-04 11:37:06 +02:00
Tim Ruffing
b5b8e7b719 Don't declare constants twice
This is forbidden in C++.
2021-07-04 11:35:52 +02:00
Tim Ruffing
769528f307 Don't use string literals for char arrays without NUL termination
unsigned char foo[4] = "abcd" is not valid C++ because the string
literal "abcd" does not fit into foo due to the terminating NUL
character. This is valid in C, it will just omit the NUL character.

Fixes #962.
2021-07-04 10:40:30 +02:00
Tim Ruffing
2cc3cfa583 Fix -Wmissing-braces warning in clang 2021-07-04 02:01:44 +02:00
Tim Ruffing
0440945fb5
Merge #844: schnorrsig API overhaul
5f6ceafcfa46a69e901bed87e2c5f323b03b1e8c schnorrsig: allow setting MSGLEN != 32 in benchmark (Jonas Nick)
fdd06b7967196a3b34f73a5b19632637b4bde90a schnorrsig: add tests for sign_custom and varlen msg verification (Jonas Nick)
d8d806aaf386c7ead9431649f899ff82b0185aae schnorrsig: add extra parameter struct for sign_custom (Jonas Nick)
a0c3fc177f7f435e593962504182c3861c47d1be schnorrsig: allow signing and verification of variable length msgs (Jonas Nick)
5a8e4991ad443cc0cc613d80380a2db802a4cbce Add secp256k1_tagged_sha256 as defined in BIP-340 (Jonas Nick)
b6c0b72fb06e3c31121f1ef4403d2a229a31ec1c schnorrsig: remove noncefp args from sign; add sign_custom function (Jonas Nick)
442cee5bafbd7419acadf203ca11569e371f1f85 schnorrsig: add algolen argument to nonce_function_hardened (Jonas Nick)
df3bfa12c3b728241d3e61d13f8c976719a3de41 schnorrsig: clarify result of calling nonce_function_bip340 without data (Jonas Nick)
99e8614812bf23798a48c53649957e26e5b12f4a README: mention schnorrsig module (Jonas Nick)

Pull request description:

  This is a work in progress because I wanted to put this up for discussion before writing tests. It addresses the TODOs that didn't make it in the schnorrsig PR and changes the APIs of `schnorrsig_sign`, `schnorrsig_verify` and `hardened_nonce_function`.

  - Ideally, the new `aux_rand32` argument for `sign` would be const, but didn't find a solution I was happy with.
  - Support for variable length message signing and verification supports the [suggested BIP amendment](https://github.com/sipa/bips/issues/207#issuecomment-673681901) for such messages.
  - ~~`sign_custom` with its opaque config object allows adding more arguments later without having to change the API again. Perhaps there are other sensible customization options, but I'm thinking of [sign-to-contract/covert-channel](https://github.com/bitcoin-core/secp256k1/pull/590) in particular. It would require adding the fields `unsigned char *s2c_data32` and `secp256k1_s2c_opening *s2c_opening` to the config struct. The former is the data to commit to and the latter is written to by `sign_custom`.~~ (EDIT: see below)

ACKs for top commit:
  ariard:
    utACK 5f6ceaf
  LLFourn:
    utACK 5f6ceafcfa46a69e901bed87e2c5f323b03b1e8c

Tree-SHA512: cf1716dddf4f29bcacf542ed22622a817d0ec9c20d0592333cb7e6105902c77d819952e776b9407fae1333cbd03d63fded492d3a5df7769dcc5b450d91bb4761
2021-07-03 11:45:30 +02:00
Tim Ruffing
ec3aaa5014
Merge #960: tests_exhaustive: check the result of secp256k1_ecdsa_sign
a1ee83c6546c65d8f5b32acc4a0e1740858ee7d6 tests_exhaustive: check the result of secp256k1_ecdsa_sign (Nicolas Iooss)

Pull request description:

  Hello,

  In `test_exhaustive_sign`, if `secp256k1_ecdsa_sign` fails, the signature which is then loaded by `secp256k1_ecdsa_signature_load` is garbage. Exit early with an error when this occurs.

  By the way, I am wondering whether attribute `SECP256K1_WARN_UNUSED_RESULT` should be added to function `secp256k1_ecdsa_sign`: as (according to the documentation of this function) the nonce generation function may fail, it seems to be a good idea to force callers to check the value returned by this function. What do you think about this?

ACKs for top commit:
  sipa:
    ACK a1ee83c6546c65d8f5b32acc4a0e1740858ee7d6
  real-or-random:
    utACK a1ee83c6546c65d8f5b32acc4a0e1740858ee7d6

Tree-SHA512: d8c186afecbd95522e909c269255e8879695bf9df2de91f0f9303e575e18f03cafc66683d863e6cf9892fe61b668eab00d586861c39013292b71484a962f846d
2021-07-03 11:21:18 +02:00