Commit Graph

1263 Commits

Author SHA1 Message Date
Tim Ruffing e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge 2021-01-30 19:38:24 +01:00
Jonas Nick f8c0b57e6b
Merge #864: Add support for Cirrus CI
cc2a5451dc ci: Refactor Nix shell files (Jonas Nick)
2480e55c8f ci: Remove support for Travis CI (Tim Ruffing)
2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS (Tim Ruffing)
8c02e465c5 ci: Add support for Cirrus CI (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    ACK cc2a5451dc. Tested by introducing bugs: #883, #884, #885, #886, #887.
  jonasnick:
    ACK cc2a5451dc

Tree-SHA512: c9e8a891c9bda48b3fc307c2a85d2e4aa180531d084edd778d41c034769661627538ab397efac3abfc1a71c2f0730a45350dd212d499fe475c90a2a1b3c61ac8
2021-01-30 10:07:58 +00:00
Jonas Nick cc2a5451dc ci: Refactor Nix shell files 2021-01-29 22:26:02 +01:00
Tim Ruffing 2480e55c8f ci: Remove support for Travis CI
So long, and thanks for all fish!
2021-01-29 21:54:07 +01:00
Tim Ruffing 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 2021-01-29 21:54:07 +01:00
Tim Ruffing 8c02e465c5 ci: Add support for Cirrus CI 2021-01-29 21:54:07 +01:00
Tim Ruffing 659d0d4798
Merge #880: Add parens around ROUND_TO_ALIGN's parameter.
b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. (Russell O'Connor)

Pull request description:

  This makes the macro robust against a hypothetical `ROUND_TO_ALIGN(foo ? sizeA : size B)` invocation.

  See also <https://wiki.sei.cmu.edu/confluence/display/c/PRE01-C.+Use+parentheses+within+macros+around+parameter+names>.

ACKs for top commit:
  sipa:
    ACK b6f649889a. This is the way.
  jonasnick:
    utACK b6f649889a
  real-or-random:
    utACK b6f649889a

Tree-SHA512: 6a2685f959e8ae472259e5ea75fe12e8e6213f56f5aec7603a896c294e6a8833caae25c412607d9c9a3125370a7765a3e506127b101a1b87203f95e326f6c6c6
2021-01-26 09:39:00 +01:00
Russell O'Connor b6f649889a Add parens around ROUND_TO_ALIGN's parameter.
This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation.
2021-01-25 11:43:45 -05:00
Jonas Nick a4abaab793
Merge #877: Add missing secp256k1_ge_set_gej_var decl.
482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. (Russell O'Connor)

Pull request description:

ACKs for top commit:
  sipa:
    utACK 482e4a9cfc
  real-or-random:
    utACK 482e4a9cfc
  jonasnick:
    ACK 482e4a9cfc

Tree-SHA512: 02195390fb79f08bcfd655dc56115ea37df42c1ad8f1123b26e7426e387d9658a3bb18fe9951140fc4dd78ce222b84d8b75ce77aec884675e0c26a2005dd2ddc
2021-01-25 14:00:47 +00:00
Jonas Nick 5671e5f3fd
Merge #874: Remove underscores from header defs.
fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. (Russell O'Connor)

Pull request description:

ACKs for top commit:
  real-or-random:
    utACK fb390c5299
  jonasnick:
    ACK fb390c5299

Tree-SHA512: f49da79c0a90d1e82494821e7cf6f61c66bc377a3f37b2d4787ef19d2126e000627bfe4a76aa1c5bfffeb1382054aa824a7e9ab5d73c19d876b0828722c73854
2021-01-25 13:57:43 +00:00
Jonas Nick db726782fa
Merge #878: Remove unused secp256k1_fe_inv_all_var
75d2ae149e Remove unused secp256k1_fe_inv_all_var (Pieter Wuille)

Pull request description:

ACKs for top commit:
  practicalswift:
    cr ACK 75d2ae149ef37d3aa42fdefd1529aad89859816c: patch looks correct
  real-or-random:
    utACK 75d2ae149e
  jonasnick:
    utACK 75d2ae149e

Tree-SHA512: 6f548a436c6dcb275493e73e6afa23fd1b79392cc3071878f98735732ac9c93971e5c92736c3fe50eaae90a200e1a435e9be9f14d1a69251c83876a6e3c46d41
2021-01-25 13:40:00 +00:00
Jonas Nick b732701faa
Merge #875: Avoid casting (void**) values.
2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. (Russell O'Connor)

Pull request description:

ACKs for top commit:
  sipa:
    utACK 2730618604
  real-or-random:
    utACK 2730618604
  jonasnick:
    utACK 2730618604

Tree-SHA512: bdc1e9eefa10f79b744ef6ae83f379faff7bce9fb428c3bcfcc3f6e4e252e5c6543efbe0f84760709850948cbc8a432772c76a6c5f6b8cd18cb2d862b324912d
2021-01-25 13:36:01 +00:00
Pieter Wuille 75d2ae149e Remove unused secp256k1_fe_inv_all_var 2021-01-23 20:16:51 -08:00
Russell O'Connor 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2021-01-23 19:12:19 -05:00
Russell O'Connor 2730618604 Avoid casting (void**) values.
Replaced with an expression that only casts (void*) values.
2021-01-23 15:22:54 -05:00
Russell O'Connor fb390c5299 Remove underscores from header defs.
This makes them consistent with other files and avoids reserved identifiers.
2021-01-23 14:48:35 -05:00
Tim Ruffing f2d9aeae6d
Merge #862: Autoconf improvements
3c15130709 Improve CC_FOR_BUILD detection (Tim Ruffing)
47802a4762 Restructure and tidy configure.ac (Tim Ruffing)
252c19dfc6 Ask brew for valgrind include path (Tim Ruffing)

Pull request description:

  See individual commit messages. These are improvements in preparation of the switch to Cirrus CI. (Maybe I'll just open a PR on top of this one.)

  The first commit made the difference between successful build https://cirrus-ci.com/task/6740575057608704 and unsuccessful build https://cirrus-ci.com/task/4909571074424832.

  I've tested the second commit without cross-compilation and with cross-compilation for android (https://github.com/bitcoin-core/secp256k1/issues/621#issuecomment-495703399)

  When working on the autoconf stuff, I noticed two things that I just want to write down here:
   - At some point we should update [build-aux/m4/ax_prog_cc_for_build.m4](https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html). This is outdated, and [there have been a lot of fixes](https://github.com/autoconf-archive/autoconf-archive/pull/207) But the latest version is [broken](https://lists.gnu.org/archive/html/autoconf-archive-maintainers/2020-06/msg00002.html), so now is probably not the time.
   - The latest autoconf 2.70 deprecates `AC_PROG_CC_C89`. It's not needed anymore because `AC_PROG_CC` cares about testing for version support. This makes autoconf 2.70 output a warning that we should probably just ignore. We don't want to force users onto 2.70...

ACKs for top commit:
  sipa:
    utACK 3c15130709
  jonasnick:
    utACK 3c15130 makes sense (with my very basic understanding of autoconf)

Tree-SHA512: 595b9de316374c2213f1340cddaa22eb3190b01fa99aa6ae26e77804df41e7ecf96a09e03c28e8f8b9fd04e211e4ee2f78f1e5a7995143c84f99d2e16d4f0260
2021-01-12 15:38:52 +01:00
Tim Ruffing 328aaef22a
Merge #845: Extract the secret key from a keypair
33cb3c2b1f Add secret key extraction from keypair to constant time tests (Elichai Turkel)
36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests (Elichai Turkel)
fc96aa73f5 Add a function to extract the secretkey from a keypair (Elichai Turkel)

Pull request description:

  With schnorrsig if you need to tweak the secret key (for BIP32) you must use the keypair API to get compatible secret/public keys which you do by calling `secp256k1_keypair_xonly_tweak_add()`, but after that there's no currently a way to extract the secret key back for storage.
  so I added a `secp256k1_keypair_seckey` function to extract the key

ACKs for top commit:
  jonasnick:
    ACK 33cb3c2b1f
  real-or-random:
    ACK 33cb3c2b1f code inspection, tests pass

Tree-SHA512: 11212db38c8b87a87e2dc35c4d6993716867b45215b94b20522b1b3164ca63d4c6bf5192a6bff0e9267b333779cc8164844c56669a94e9be72df9ef025ffcfd4
2021-01-12 10:56:14 +01:00
Tim Ruffing 3c15130709 Improve CC_FOR_BUILD detection
This commits simply uses CC as CC_FOR_BUILD and the same for
corresponding flags if we're not cross-compiling. This has a number of
benefits in this common case:
 - It avoids strange cases where very old compilers are used (#768).
 - Flags are consistently set for CC and CC_FOR_BUILD.
 - ./configure is faster.
 - You get compiler x consistently if you set CC=x; we got this wrong
   in CI in the past.

./configure warns if a _FOR_BUILD variable is set but ignored because
we're not cross-compiling.

The change exposed that //-style comments are used in gen_context.c,
which is also fixed by this commit.

This commit also reorganizes code in configure.ac to have a cleaner
separation of sections.
2021-01-08 16:09:04 +01:00
Tim Ruffing 47802a4762 Restructure and tidy configure.ac
No behavioral changes.
2021-01-08 15:29:40 +01:00
Tim Ruffing 252c19dfc6 Ask brew for valgrind include path
Valgrind is typically installed using brew on macOS. This commit
makes ./configure detect this case set the appropriate include
directory (in the same way as we already do for openssl and gmp).
2021-01-08 14:24:34 +01:00
Tim Ruffing 8c727b9087
Merge #860: fixed trivial typo
b7bc3a4aaa fixed typo (Ferdinando M. Ametrano)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK b7bc3a4aaa
  elichai:
    ACK b7bc3a4aaa

Tree-SHA512: 6c1889f095607a2f293ffe00359c03e63cfca572b0a17388b83ece54f24ec61ac12d6eb967a47d2dccd54de991383923a07c5cced320c0a96a36a28674cf739c
2021-01-08 14:16:38 +01:00
Ferdinando M. Ametrano b7bc3a4aaa
fixed typo 2020-12-22 22:31:29 +01:00
Elichai Turkel 33cb3c2b1f
Add secret key extraction from keypair to constant time tests 2020-12-19 11:01:36 +02:00
Elichai Turkel 36d9dc1e8e
Add seckey extraction from keypair to the extrakeys tests 2020-12-19 11:00:25 +02:00
Elichai Turkel fc96aa73f5
Add a function to extract the secretkey from a keypair 2020-12-19 11:00:25 +02:00
Jonas Nick 98dac87839
Merge #858: Fix insecure links
07aa4c70ff Fix insecure links (Dimitris Apostolou)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 07aa4c70ff. Verified all the modified links.
  jonasnick:
    ACK 07aa4c70ff

Tree-SHA512: d1240aab5e40a204c75fca1049b99af9890684df7dbce4167b1904f73424c8a4f84ed85a8cc315501f1b7cf1674d744232b9f2126dff31e3d47e4f3fc65764d4
2020-12-18 18:33:03 +00:00
Dimitris Apostolou 07aa4c70ff
Fix insecure links 2020-12-18 00:24:22 +02:00
Tim Ruffing b61f9da54e
Merge #857: docs: fix simple typo, dependecy -> dependency
18aadf9d28 docs: fix simple typo, dependecy -> dependency (Tim Gates)

Pull request description:

  There is a small typo in src/group_impl.h.

  Should read `dependency` rather than `dependecy`.

ACKs for top commit:
  real-or-random:
    ACK 18aadf9d28

Tree-SHA512: 3529f43bcc87ea8940ecf5af765951f61d97d1efa86fd8abc29e32b600fd449165a94a2fa525bc6b3d9a7d8aa6e691cc4d42033537b196ba166a867e6db7f397
2020-12-09 18:05:58 +01:00
Tim Gates 18aadf9d28
docs: fix simple typo, dependecy -> dependency
There is a small typo in src/group_impl.h.

Should read `dependency` rather than `dependecy`.
2020-12-08 21:45:13 +11:00
Jonas Nick 2d9e7175c6
Merge #852: Add sage script for generating scalar_split_lambda constants
329a2e0a3f sage: Add script for generating scalar_split_lambda constants (Tim Ruffing)
f554dfc708 sage: Reorganize files (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 329a2e0a3f

Tree-SHA512: d41fe5eba332f48af0b800778aa076925c4e8e95ec21c4371a500ddd6088b6d52961bdb93f7ce2b127e18095667dbb966a0d14191177f0d0e78dfaf55271d5e2
2020-12-07 21:49:32 +00:00
Tim Ruffing dc6e5c3a5c
Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation
6e85d675aa Rename tweak to tweak32 in public API (Jonas Nick)
f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation (Jonas Nick)

Pull request description:

  This fixes #307 if there's nothing else that's confusing.

ACKs for top commit:
  real-or-random:
    ACK 6e85d675aa I inspected the diff

Tree-SHA512: 1b0dc9dfffd497058dc39c962a512ed6d7f89218020fef9d2c03aaae1aefbf272b918c4fe6503434b62547714855fe1b8b89f2366f3ae6cde16143207c9e6b86
2020-12-07 22:10:47 +01:00
Jonas Nick 6e85d675aa Rename tweak to tweak32 in public API 2020-12-04 14:16:43 +00:00
Jonas Nick f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 2020-12-04 14:12:38 +00:00
Tim Ruffing 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 2020-12-03 11:56:09 +01:00
Jonas Nick 8f0c6f1545
Merge #851: make test count iteration configurable by environment variable
f4fa8d226a forbid a test iteration of 0 or less (Andrew Poelstra)
0ce4554881 make test count iteration configurable by environment variable (Andrew Poelstra)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK f4fa8d226a
  real-or-random:
    ACK f4fa8d226a

Tree-SHA512: 087771402c8e9536c07446baa7d02da5104d2b691f40c1dd04737329534422d895d3b692f485990d5791af8ccc124305b4f8b19be75e27b6b04cfb2337b28beb
2020-12-01 08:31:13 +00:00
Andrew Poelstra f4fa8d226a forbid a test iteration of 0 or less 2020-11-30 18:12:31 +00:00
Tim Ruffing f554dfc708 sage: Reorganize files
* Move curve parameters to separate file
 * Rename main prover script for clarity
2020-11-25 13:50:40 +01:00
Jonas Nick 3a106966aa
Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9)
13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) (Frédéric Chapoton)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 13c88efed0

Tree-SHA512: 6b8a32c35554b7e881841c17fe21323035014d25003f14e399f03ec017ea1bae1c68eee18a4d0315fc0f3b40d8252b5c8790f6c355d7d074a8ebc5e1ca832795
2020-11-23 20:15:25 +00:00
Frédéric Chapoton 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9)
Co-authored-by: Tim Ruffing <crypto@timruffing.de>
2020-11-23 15:56:22 +01:00
Andrew Poelstra 0ce4554881 make test count iteration configurable by environment variable 2020-11-23 01:05:31 +00:00
Pieter Wuille 9e5939d284
Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t
1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler (Tim Ruffing)
e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t (Tim Ruffing)

Pull request description:

  As identified in #829 and #833. Fixes #829.

  Since we touch this anyway, this commit additionally makes the
  identifiers in the benchmark files a little bit more consistent.

  This is necessary before we can merge #833. I preferred a separate PR because it makes it easier to see the results of Travis in #833.

ACKs for top commit:
  sipa:
    utACK 1f4dd03838
  jonasnick:
    ACK 1f4dd03838

Tree-SHA512: c0ec92798f3c94f3ef6ac69b3f0f39a39257a32be9d9a068832cece1ebe64c89848b70e44652fc397004b8b240883ac4bc0c8f95abbe4ba4b028de120e6734bf
2020-11-04 15:29:25 -08:00
Jonas Nick d0a83f7328
Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small
29a299e373 Run the undefined behaviour sanitizer on Travis (Fabien)
7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small (Fabien)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 29a299e373. Reviewed the code changes and verified that building with these sanitizer flags catches the existing error, as well as a signed integer overflow if introduced.
  real-or-random:
    ACK 29a299e373 code inspection
  jonasnick:
    utACK 29a299e373

Tree-SHA512: 4d788f12f3d7b48018e884910adb9b530a05d88f504de83dadeab8a22d75da83c05a1518f7317de5f536c4dd243ea7b347b1eaddb2ca1d804c663e41b85db69d
2020-11-04 14:53:04 +00:00
Jonas Nick 903b16aa6c
Merge #840: Return NULL early in context_preallocated_create if flags invalid
ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    ACK ebfa2058e9
  jonasnick:
    ACK ebfa2058e9

Tree-SHA512: 61310539046e015e5c9e6b5702ac7b542fda854a23915ef5dd549361c8ec6e70aa6d509e02b30fd859b24dfaf2250721bb55270767323d6e94854067b7d7e9a6
2020-10-30 17:48:46 +00:00
Tim Ruffing 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler 2020-10-27 20:18:18 +01:00
Tim Ruffing 3967d96bf1
Merge #838: Make autotools check for all the used openssl functions
3734b68200 Configure echo if openssl tests are enabled (Elichai Turkel)
e6692778d3 Modify bitcoin_secp.m4's openssl check to call all the functions that we use in the tests/benchmarks. That way linking will fail if those symbols are missing (Elichai Turkel)

Pull request description:

  I added all the openssl functions that we call in `tests.c` and in `bench_verify.c` to the m4 check, that way if any of them are missing it won't enable openssl.
  I also modified it a little to prevent a segmentation fault when running that program (not that it really matters for autotools)

  This should fix #836

ACKs for top commit:
  sipa:
    ACK 3734b68200
  real-or-random:
    ACK 3734b68200

Tree-SHA512: c82aa96a4176061284dfa5fdb87ca874a25aa2e11f75c4ec6d1edebcc8a19e2bc940990f8a5cfa64776fd295b6fd3a140fa2afede29326564504bc8d1a3a6b69
2020-10-27 20:15:33 +01:00
Elichai Turkel 3734b68200
Configure echo if openssl tests are enabled 2020-10-27 16:11:27 +02:00
Tim Ruffing ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid
If the user passes invalid flags to _context_create, and the default
illegal callback does not abort the program (which is possible), then we
work with the result of malloc(0), which may be undefined behavior. This
violates the promise that a library function won't crash after the
illegal callback has been called.

This commit fixes this issue by returning NULL early in _context_create
in that case.
2020-10-27 15:03:21 +01:00
Jonas Nick 6f54e69f03
Merge #841: Avoids a potentially shortening size_t to int cast in strauss_wnaf_
8893f42438 Avoids a potentially shortening size_t to int cast in strauss_wnaf_ (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 8893f42438. `np` and `no` shouldn't ever take on negative values.
  jonasnick:
    ACK 8893f42438
  elichai:
    ACK 8893f42438

Tree-SHA512: 431a6b88c8db8c8883b35c9bc03c90e37ecd0b06c7ee01c5d83cca4a7f6fc1f3cfbbaa871a4a23374ce4cc5bcfb9502c7f2e2540f9f9db9535e47e48827b6af6
2020-10-27 13:24:33 +00:00
Fabien 29a299e373 Run the undefined behaviour sanitizer on Travis
Run UBSAN with both GCC and Clang, on Linux and macOS.
The `halt_on_error=1` option is required to make the build fail if the
sanitizer finds an issue.
2020-10-27 08:45:21 +01:00