1673 Commits

Author SHA1 Message Date
Tim Ruffing
53796d2b24 contexts: Rename static context 2022-12-05 11:26:44 +01:00
Tim Ruffing
72fedf8a6c docs: Improve docs for static context 2022-12-05 11:26:39 +01:00
Tim Ruffing
316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 2022-12-05 11:26:02 +01:00
Tim Ruffing
1a553ee8be docs: Change signature "validation" to "verification" 2022-11-25 23:26:15 +01:00
Tim Ruffing
ee7341fbac docs: Never require a verification context 2022-11-25 23:26:15 +01:00
Tim Ruffing
2286f80902
Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default
41e8704b484652cf5bbb2b7ecc27feedc3cf0ae1 build: Enable some modules by default (Tim Ruffing)

Pull request description:

  This has been discussed in https://github.com/bitcoin-core/secp256k1/issues/817#issuecomment-693198323 and I agree with the arguments brought up there.

  Alternatively, we could not enable them and add a discussion to the readme why we discourage people from using the modules. I believe enabling ECDH is not very controversial. But what about recovery? Do we want to leave it off and instead give a reason?

ACKs for top commit:
  sipa:
    ACK 41e8704b484652cf5bbb2b7ecc27feedc3cf0ae1
  jonasnick:
    ACK 41e8704b484652cf5bbb2b7ecc27feedc3cf0ae1

Tree-SHA512: 1dd21037043f2b2c94a92cd2f31e69b505ba5b43119897bc0934966d9ccd84fc4fc20e7509af634f1c3a096710db1a2253090f5f1f107b9d258945a5546e9ba4
2022-11-22 12:53:48 +01:00
Tim Ruffing
e40fd277b7
Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic
99bd3355994a436e25d148c68e097cca11f3c63e Make int128 overflow test use secp256k1_[ui]128_mul (Pieter Wuille)
3afce0af7c00eb4c5ca6d303e36a48c91a800459 Avoid signed overflow in MSVC AMR64 secp256k1_mul128 (Pieter Wuille)
9b5f589d30c3a86df686aadcde63eaa54eeafe71 Heuristically decide whether to use int128_struct (Pieter Wuille)
63ff064d2f7e67bb8ce3431ca5d7f8f056ba6bbd int128: Add test override for testing __(u)mulh on MSVC X64 (Tim Ruffing)
f2b7e88768f86b2fd506be4a8970ba6d1423d0a5 Add int128 randomized tests (Pieter Wuille)

Pull request description:

  This is a follow-up to #1000:
  * Add randomized unit tests for int128 logic.
  * Add CI for the `_(u)mulh` code path (on non-ARM64 MSVC).
  * Add heuristic logic to enable int128_struct based arithmetic on 64-bit MSVC, or systems with pointers wider than 32 bits.
  * Fix signed overflow in ARM64 MSVC code.

ACKs for top commit:
  roconnor-blockstream:
    utACK 99bd335
  real-or-random:
    ACK 99bd3355994a436e25d148c68e097cca11f3c63e tested this also on MSVC locally with the override, including all the benchmark binaries
  jonasnick:
    utACK 99bd3355994a436e25d148c68e097cca11f3c63e

Tree-SHA512: 5ea897362293b45a86650593e1fdc8c4004a1d9452eed2fa070d22dffc7ed7ca1ec50a4df61e3a33dbe35e08132ad9686286ac44af6742b32b82f11c9d3341c6
2022-11-18 16:51:07 -05:00
Pieter Wuille
99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul 2022-11-17 12:22:29 -05:00
Pieter Wuille
3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 2022-11-17 09:44:10 -05:00
Pieter Wuille
9b5f589d30 Heuristically decide whether to use int128_struct 2022-11-17 09:28:30 -05:00
Tim Ruffing
63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64
Also add a corresponding CI job
2022-11-17 09:28:30 -05:00
Pieter Wuille
f2b7e88768 Add int128 randomized tests 2022-11-17 09:28:30 -05:00
Jonas Nick
6138d73be4
Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs
00a42b91b3477f63d6f9b6fe0df02bda8b09cddd Add MSan CI job (Pieter Wuille)

Pull request description:

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

Tree-SHA512: 0b9ced572430e917041c916d8cda5c94996899a6e0a8c5a13f73f2c99b58b0098f7562cd758b48f18bec8c7095fab37980aa6dc2b139b2d1c293c965ea603686
2022-11-17 11:06:56 +00:00
Tim Ruffing
ddf2b2910e
Merge bitcoin-core/secp256k1#1000: Synthetic int128 type.
a340d9500a9c45e5c261174f48b3eb18b3b3647d ci: add int128_struct tests (Jonas Nick)
dceaa1f57963d1a88b24974eab4b49baac6d04cd int128: Tidy #includes of int128.h and int128_impl.h (Tim Ruffing)
2914bccbc0913806ee64425a27d38cdc27b288e8 Simulated int128 type. (Russell O'Connor)

Pull request description:

  Abstracts the int128 type and provides an native version, if available, or a implements it using a pair of int64_t's.

  This is activated by setting the configuration flag `--with-test-override-wide-multiply=int128_struct`.

  The primary purpose of this PR is to take advantage of MSVC's [umulh](https://docs.microsoft.com/en-us/cpp/intrinsics/umulh?view=msvc-170) intrinsic that we can use to simulate an int128 type which MSVC does not have (AFAIU). This PR lays out the groundwork for this level of MSVC support, but doesn't include the configuration logic to enable it yet.

  For completeness, and implementation of `umulh` and `mulh` are also provided for compilers that support neither the intrinsic nor the int128 type (such as CompCert?).  This also opens up the possibility of removing the 32-bit field and scalar implementations should that ever be desired.

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

Tree-SHA512: b4f2853fa3ab60ce9d77b4eaee1fd20c4b612850e19fcb3179d7e36986f420c6c4589ff72f0cf844f989584ace49a1cd23cca3f4e405dabefc8da647a0df679d
2022-11-16 14:37:01 -05:00
Tim Ruffing
86e3b38a4a
Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file
6a965b6b98bc08646c87bcfc826181e317079a9e Remove usage of CHECK from non-test file (Tobin C. Harding)

Pull request description:

  Currently CHECK is used only in test and bench mark files except for one usage in `ecmult_impl.h`.

  We would like to move the definition of CHECK out of `util.h` so that `util.h` no longer has a hard dependency on `stdio.h`.

  Done as part of an effort to allow secp256k1 to be compiled to WASM as part of `rust-secp256k1`.

  ### Note to reviewers

  Please review carefully, I don't actually know if this patch is correct. Done while working on #1095. I'm happy to make any changes both in concept and execution - I'm super rusty at C programming.

  cc real-or-random

ACKs for top commit:
  sipa:
    utACK 6a965b6b98bc08646c87bcfc826181e317079a9e
  real-or-random:
    utACK 6a965b6b98bc08646c87bcfc826181e317079a9e

Tree-SHA512: 6bfb456bdb92a831acd3bc202607e80f6d0a194d6b2cf745c8eceb12ba675d03a319d6d105332b0cbca474e443969295e5a8e938635453e21e057d0ee597440b
2022-11-16 14:22:06 -05:00
Pieter Wuille
00a42b91b3 Add MSan CI job 2022-11-16 13:36:56 -05:00
Tim Ruffing
44916ae915
Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI
4e54c03153a307af5cc80c7671ac7eef28138326 ci: print env to allow reproducing the job outside of CI (Jonas Nick)

Pull request description:

  Example output:

  ```
  WERROR_CFLAGS="-Werror -pedantic-errors"  MAKEFLAGS="-j4"  BUILD="check"  ECMULTWINDOW="auto"  ECMULTGENPRECISION="auto"  ASM="no"  WIDEMUL="int64"  WITH_VALGRIND="no"  EXTRAFLAGS=""  EXPERIMENTAL="no"  ECDH="no"  RECOVERY="yes"  SCHNORRSIG="no"  SECP256K1_TEST_ITERS=""  BENCH="yes"  SECP256K1_BENCH_ITERS="2"  CTIMETEST="yes"  EXAMPLES="yes"  WRAPPER_CMD=""  CC="gcc"  AR=""  NM=""  HOST=""  ./ci/cirrus.sh
  ```

ACKs for top commit:
  sipa:
    ACK 4e54c03153a307af5cc80c7671ac7eef28138326
  real-or-random:
    ACK 4e54c03153

Tree-SHA512: b74a8724e72b3de7884e4d93fe933dc5043aec37020672b7997a8faebda3b0cbbba1bca69c344109729261ab4a94e76f4eca0d8773dc101a443fdf9e0d7d54f5
2022-11-14 18:01:49 -05:00
Jonas Nick
c2ee9175e9
Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error
49ae843592650ca02b33c188cf2aff7aa78985d3 ci: mostly prevent "-v/--version: not found" irrelevant error (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 49ae843592650ca02b33c188cf2aff7aa78985d3

Tree-SHA512: 2e048b037826dff372e26103f198e0d490494e7909d17d8632b51f6d9e0629b51bcd0b55b65b2c21d63d522394ccfed481ce126cea165c087df670556bc8ccf6
2022-11-08 13:26:06 +00:00
Jonas Nick
e13fae487e
Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log
5c9f1a5c3774192f77c97474431bb70a124c7b0c ci: always cat all logs_snippets (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 5c9f1a5c3774192f77c97474431bb70a124c7b0c

Tree-SHA512: fc715c5fc4006d80a4b0c2faa8ef81ed23c4479614945ffa7c96665a3acc38fe956dd6d148bcf97043232ceee055b724ea9490e4ac4142a210e4488fed8dd299
2022-11-08 13:24:29 +00:00
Jonas Nick
a340d9500a ci: add int128_struct tests 2022-11-07 16:55:43 -05:00
Tim Ruffing
dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h
After this commit, int128.h and int128_impl.h are included as follows:
 - .c files which use int128 include int128_impl.h (after util.h)
 - .h files which use int128 include int128.h (after util.h)

This list is exhaustive. util.h needs to included first because it sets
up necessary #defines.
2022-11-07 16:38:30 -05:00
Russell O'Connor
2914bccbc0 Simulated int128 type. 2022-11-07 16:37:24 -05:00
Tobin C. Harding
6a965b6b98 Remove usage of CHECK from non-test file
Currently CHECK is used only in test and bench mark files except for one
usage in `ecmult_impl.h`.

We would like to move the definition of CHECK out of `util.h` so that
`util.h` no longer has a hard dependency on `stdio.h`.

Done in preparation for moving the definition of `CHECK` as part of an
effort to allow secp256k1 to be compiled to WASM as part of
`rust-secp256k1`.
2022-11-08 07:29:52 +11:00
Jonas Nick
5c9f1a5c37
ci: always cat all logs_snippets 2022-11-07 20:12:33 +00:00
Jonas Nick
49ae843592
ci: mostly prevent "-v/--version: not found" irrelevant error
$CC, $WRAPPER_CMD and valgrind are not necessarily defined
2022-11-02 17:13:21 +00:00
Jonas Nick
4e54c03153
ci: print env to allow reproducing the job outside of CI 2022-11-02 15:57:14 +00:00
Jonas Nick
a43e982bca
Merge bitcoin-core/secp256k1#1144: Cleanup .gitignore file
f5039cb66c9f49d1c78fa59c0e83d0d122292697 Cleanup `.gitignore` file (Hennadii Stepanov)
798727ae1edc1b07257f7a884f8e57021063a089 Revert "Add test logs to gitignore" (Hennadii Stepanov)

Pull request description:

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

Tree-SHA512: 3586329e77958a9bfa06dd84e5b121cd456e93332670d5afc1a6691e165cdfa5a6fd6a61f82be12ec33f2a58b26a13adfedeb177ae1056202e53a530949fc549
2022-11-01 16:32:30 +00:00
Hennadii Stepanov
f5039cb66c
Cleanup .gitignore file
The removed line was introduced for `obj/.gitignore` file. Since the
`obj` directory has been removed, it is not longer required.
2022-10-28 16:30:20 +01:00
Hennadii Stepanov
798727ae1e
Revert "Add test logs to gitignore"
This reverts commit bceefd6547635132ba17f022a52db18f17e00df6.
2022-10-28 16:10:46 +01:00
Tim Ruffing
41e8704b48 build: Enable some modules by default
We don't enable the ECDSA recovery module, because we don't recommend
ECDSA recovery for new protocols. In particular, the recovery API is
prone to misuse: It invites the caller to forget to check the public
key (and the verification function always returns 1).

In general, we also don't recommend ordinary ECDSA for new protocols.
But disabling the ECDSA functions is not possible because they're not
in a module, and let's be honest: disabling ECDSA would mean to ignore
reality blatantly.
2022-08-03 17:09:54 +02:00
Tim Ruffing
694ce8fb2d
Merge bitcoin-core/secp256k1#1131: readme: Misc improvements
88b00897e7ee8dc9bed878082b2277f12136c154 readme: Fix line break (Tim Ruffing)
78f5296da400db8e1034750d79d8cf6d2fd9b045 readme: Sell "no runtime dependencies" (Tim Ruffing)
ef48f088ad95862b6c52781f7ca71cf8535a9b91 readme: Add IRC channel (Tim Ruffing)

Pull request description:

ACKs for top commit:
  apoelstra:
    utACK 88b00897e7ee8dc9bed878082b2277f12136c154
  sipa:
    ACK 88b00897e7ee8dc9bed878082b2277f12136c154

Tree-SHA512: 174f1596406f98a19059a18cd4fb993102e5ffb8ec29fcc6d03e27f135fcb526b37204b64055b5e4f0a273daab05d395cf335f26241cf3a29a060041c9ef109b
2022-08-02 17:33:21 +02:00
Tim Ruffing
88b00897e7 readme: Fix line break 2022-08-02 10:41:15 +02:00
Tim Ruffing
78f5296da4 readme: Sell "no runtime dependencies" 2022-08-02 10:41:15 +02:00
Tim Ruffing
ef48f088ad readme: Add IRC channel 2022-08-02 10:41:15 +02:00
Tim Ruffing
9f8a13dc8e
Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge)
cabe085bb4371cc61286023ac9f6a8ce3138d7ea configure: Remove pkgconfig macros again (reintroduced by mismerge) (Tim Ruffing)

Pull request description:

  We had removed `PKG_PROG_PKG_CONFIG` in 21b2ebaf74222017f85123deb6f30a33c7678513
  (#1090). But then then the not rebased (!) merge of 2be6ba0fedd0d2d62ba6f346d7ced7abde0d66e4
  (#1084) brought that macro back at another location, without git
  complaining about a conflict.

  Fixes #1127.

ACKs for top commit:
  fanquake:
    ACK cabe085bb4371cc61286023ac9f6a8ce3138d7ea
  hebasto:
    ACK cabe085bb4371cc61286023ac9f6a8ce3138d7ea
  jonasnick:
    ACK cabe085bb4371cc61286023ac9f6a8ce3138d7ea

Tree-SHA512: ba497503db3a11e631b15c4fe875e62d892971c2c708d90b2f6be684e85d164043ea97c13af0452831eef41f3cf8230cd8a9eafa332dc5b5ae18e118b87c3828
2022-07-21 12:06:35 +02:00
Tim Ruffing
cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge)
We had removed `PKG_PROG_PKG_CONFIG` in 21b2ebaf74222017f85123deb6f30a33c7678513
(#1090). But then then the not rebased (!) merge of 2be6ba0fedd0d2d62ba6f346d7ced7abde0d66e4
(#1084) brought that macro back at another location, without git
complaining about a conflict.

Fixes #1127.
2022-07-21 11:10:05 +02:00
Jonas Nick
3efeb9da21
Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values
c27ae451440bdaf68bf8aaa60edb1f4b4614d492 config: Remove basic-config.h (Tim Ruffing)
da6514a04a0761f973bb7591a7b41fb235747a3d config: Introduce DEBUG_CONFIG macro for debug output of config (Tim Ruffing)
d0cf55e13a7f0914759fe4f3afd003ff37868269 config: Set preprocessor defaults for ECMULT_* config values (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    ACK c27ae451440bdaf68bf8aaa60edb1f4b4614d492
  hebasto:
    ACK c27ae451440bdaf68bf8aaa60edb1f4b4614d492, I have reviewed the code and it looks correct.
  jonasnick:
    ACK c27ae451440bdaf68bf8aaa60edb1f4b4614d492

Tree-SHA512: 56b0f384bd9f42cf7c903bec08f4807db1415ddf9a06676dfe1e638e4d02431c522ef0422585e85429074e0dbb51da4f400cf53e8f883d6e07122731c57be1e3
2022-07-11 12:14:25 +00:00
Jonas Nick
6a873cc4a9
Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4
17065f48ae261c6949dab74a7c197ac13b52eb1b tests: Randomize the context with probability 15/16 instead of 1/4 (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 17065f48ae261c6949dab74a7c197ac13b52eb1b
  jonasnick:
    ACK 17065f48ae261c6949dab74a7c197ac13b52eb1b

Tree-SHA512: 3b7005770007b922a294be610f23da60b0dde74dfd7585d64a2cb04eaa6ec879de8d21a0ade31c1857019a8dd97260fa3aa167ae16fc55027ef280a3e3feaa6d
2022-07-11 11:21:57 +00:00
Tim Ruffing
17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 2022-07-08 18:45:32 +02:00
Tim Ruffing
c27ae45144 config: Remove basic-config.h
It's unused and thus potentially confusing.
2022-07-07 20:32:18 +02:00
Tim Ruffing
da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 2022-07-07 20:32:08 +02:00
Tim Ruffing
63a3565e97
Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available
55f8bc99dce8846e0da99b92e52353c8cf893287 ecmult_gen: Improve comments about projective blinding (Tim Ruffing)
7a869558004b70803717d8169dd8b090e04df4af ecmult_gen: Simplify code (no observable change) (Tim Ruffing)
4cc0b1b669392d38770f74cb3fb5c801c82f67a0 ecmult_gen: Skip RNG when creating blinding if no seed is available (Tim Ruffing)

Pull request description:

  Running the RNG is pointless if no seed is available because the key
  will be fixed. The computation just wastes time.

  Previously, users could avoid this computation at least by asking for
  a context without signing capabilities. But since 3b0c218 we always
  build an ecmult_gen context, ignoring the context flags. Moreover,
  users could never avoid this pointless computation when asking for
  the creation of a signing context.

  This fixes one item in #1065.

ACKs for top commit:
  sipa:
    ACK 55f8bc99dce8846e0da99b92e52353c8cf893287
  apoelstra:
    ACK 55f8bc99dce8846e0da99b92e52353c8cf893287

Tree-SHA512: 5ccba56041f94fa8f40a8a56ce505369ff2e0ed20cd7f0bfc3fdfffa5fa7bf826a93602b9b2455a352865a9548ab4928e858c19bb5af7ec221594a3bf25c4f3d
2022-07-07 20:08:17 +02:00
Tim Ruffing
d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values
This simplifies manual builds and solves one item in #929.
2022-07-06 15:07:57 +02:00
Tim Ruffing
55f8bc99dc ecmult_gen: Improve comments about projective blinding
Whenever I read this code, I first think that rescaling ctx->initial is
a dead store because we overwrite it later with gb. But that's wrong.
The rescaling blinds the computation of gb and affects its result.
2022-07-05 19:28:09 +02:00
Tim Ruffing
7a86955800 ecmult_gen: Simplify code (no observable change) 2022-07-05 19:28:09 +02:00
Tim Ruffing
4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available
Running the RNG is pointless if no seed is available because the key
will be fixed. The computation just wastes time.

Previously, users could avoid this computation at least by asking for
a context without signing capabilities. But since 3b0c218 we always
build an ecmult_gen context, ignoring the context flags. Moreover,
users could never avoid this pointless computation when asking for
the creation of a signing context.
2022-07-05 19:27:47 +02:00
Tim Ruffing
af65d30cc8
Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments
40a3473a9d44dc409412e94f70ad0f09bd9da3ac build: Fix #include "..." paths to get rid of further -I arguments (Tim Ruffing)

Pull request description:

  This simplifies building without a build system.

  This is in line with #925; the paths fixed here were either forgotten
  there or only introduced later. This commit also makes the Makefile
  stricter so that further "wrong" #include paths will lead to build
  errors even in autotools builds.

  This belongs to #929.

ACKs for top commit:
  hebasto:
    ACK 40a3473a9d44dc409412e94f70ad0f09bd9da3ac

Tree-SHA512: 6f4d825ea3cf86b13f294e2ec19fafc29660fa99450e6b579157d7a6e9bdb3404d761edf89c1135fa89b984d6431a527beeb97031dc90f2fae9761528f4d06d1
2022-07-01 22:13:32 +02:00
Tim Ruffing
40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments
This simplifies building without a build system.

This is in line with #925; the paths fixed here were either forgotten
there or only introduced later. This commit also makes the Makefile
stricter so that further "wrong" #include paths will lead to build
errors even in autotools builds.

This belongs to #929.

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2022-07-01 15:03:35 +02:00
Tim Ruffing
43756da819
Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h
069aba812542642986786f348a08af697b7e53c7 Fix sepc256k1 -> secp256k1 typo in group.h (henopied)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 069aba812542642986786f348a08af697b7e53c7

Tree-SHA512: 0fcb7d042f201737870da99f5425c8449e9ec3f5f8e9bbe5eb719e46cdf230db057509fb9102d4ce50a94d616015233c29249665c754e726899174fea3ea9f40
2022-06-30 12:17:51 +02:00
henopied
069aba8125
Fix sepc256k1 -> secp256k1 typo in group.h 2022-06-29 20:08:47 -05:00