2748 Commits

Author SHA1 Message Date
Tim Ruffing
0eea7d97ab Use relative #include paths in tests (as in upstream) 2023-04-21 11:51:04 +02:00
Tim Ruffing
c690d6df70 Use relative #include paths in benchmarks (as in upstream) 2023-04-21 11:50:46 +02:00
Tim Ruffing
c565827c1a Use relative #include paths in ctime_test (as in upstream) 2023-04-21 11:50:34 +02:00
Tim Ruffing
4eca406f4c Use relative #include paths in library (as in upstream) 2023-04-21 11:50:24 +02:00
Tim Ruffing
68b16a1662 bench: Make sys/time.h a system include 2023-04-21 11:18:36 +02:00
Hennadii Stepanov
162608cc98
cmake: Emulate PROJECT_IS_TOP_LEVEL for CMake<3.21 2023-04-20 23:12:28 +01:00
Pieter Wuille
69e1ec0331 Get rid of secp256k1_fe_const_b 2023-04-20 16:07:56 -04:00
Jonas Nick
bf7bf8a64f
norm arg: split norm_arg_zero into prove_edge and verify_zero_len
One function tests prover edge cases, the other tests verifier edge cases.
2023-04-20 19:05:22 +00:00
Jonas Nick
a70c4d4a8a
norm arg: add test vector for |n| = 0 2023-04-20 19:03:27 +00:00
Jonas Nick
f5e4b16f0f
norm arg: add test vector for sign bit malleability
R is point at infinity but sign is != 0
2023-04-20 19:02:51 +00:00
Jonas Nick
c0de361fc5
norm arg: allow X and R to be the point at infinity
Add test vector
2023-04-20 19:02:41 +00:00
Jonas Nick
f22834f202
norm arg: add verify vector for n = [0], l = [0] 2023-04-20 19:00:14 +00:00
Jonas Nick
d8e7f3763b
musig: move ge_{serialize,parse}_ext to module-independent file 2023-04-20 18:56:11 +00:00
Jonas Nick
050d9b2912
Merge elementsproject/secp256k1-zkp#226: bppp: align terminology with paper
2c63d17c1e3b89950af9b6e51b14f025a2251c95 bppp: align terminology with paper (gamma) (Jonas Nick)
dbf2e4d3e1dda55a1a33dd4d86918a3c2281d8dc bppp: align terminology with paper (mu, rho) (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    utACK  2c63d17c1e3b89950af9b6e51b14f025a2251c95

Tree-SHA512: 494db14717acf95de74ca14cdbd4908b31a2e81562ca18b8e3ddd795d40f60cd8ea8d7472c348da108db7d314d510f7366dc594809cf29c0c044c701c56119cc
2023-04-20 18:54:16 +00:00
Tim Ruffing
ce5ba9e24d gitignore: Add CMakeUserPresets.json
This file is specifically intended for *local* CMake templates
(as opposed to CMakePresets.json).
2023-04-20 19:23:12 +02:00
Tim Ruffing
0a446a312f cmake: Add dev-mode CMake preset
To use, invoke `cmake` with argument `--preset dev-mode`.

Solves one item in #1235.

One disadvantage over `./configure --enable-dev-mode` is that CMake
does not provide a way to "hide" presets from users. That is,
`cmake --list-presets` will list dev-mode, and it will also appear
in `cmake-gui`, even though it's not selectable there due to bug
https://gitlab.kitware.com/cmake/cmake/-/issues/23341. (So in our
case, that's probably rather a feature than a bug.)

We curently use version 3 presets which require CMake 3.21+.
Unfortunately, CMake versions before 3.19 may ignore the `--preset`
argument silently. So if the preset is not picked up, make sure you
have a recent enough CMake version.

More unfortunately, we can't even spell this warning out in
CMakePresets.json because CMake does not support officially support
comments in JSON, see
 - https://gitlab.kitware.com/cmake/cmake/-/issues/21858
 - https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5853 .
We could use a hack hinted at in
https://gitlab.kitware.com/cmake/cmake/-/issues/21858#note_908543
but that's risky, because it could simply break for future versions,
and we probably want to use presets not only for dev mode.
2023-04-20 19:22:43 +02:00
Tim Ruffing
a6f4bcf6e1
Merge bitcoin-core/secp256k1#1231: Move SECP256K1_INLINE macro definition out from include/secp256k1.h
8e142ca4102ade1b90dcb06d6c78405ef3220599 Move `SECP256K1_INLINE` macro definition out from `include/secp256k1.h` (Hennadii Stepanov)
77445898a5852ecd38ab95cfb329333a82673115 Remove `SECP256K1_INLINE` usage from examples (Hennadii Stepanov)

Pull request description:

  From [IRC](https://gnusha.org/secp256k1/2023-01-31.log):
  > 06:29 \< hebasto\> What are reasons to define the `SECP256K1_INLINE` macro in user's `include/secp256k1.h` header, while it is used internally only?
  > 06:32 \< hebasto\> I mean, any other (or a new dedicated) header in `src` looks more appropriate, no?
  > 06:35 \< sipa\> I think it may just predate any "utility" internal headers.
  > 06:42 \< sipa\> I think it makes sense to move it to util.h

  Pros:
  - it is a step in direction to better organized headers (in context of #924, #1039)

  Cons:
  - code duplication for `SECP256K1_GNUC_PREREQ` macro

ACKs for top commit:
  sipa:
    utACK 8e142ca4102ade1b90dcb06d6c78405ef3220599
  real-or-random:
    utACK 8e142ca410

Tree-SHA512: 180e0ba7c2ef242b765f20698b67d06c492b7b70866c21db27c18d8b2e85c3e11f86c6cb99ffa88bbd23891ce3ee8a24bc528f2c91167ec2fddc167463f78eac
2023-04-20 18:18:11 +02:00
Hennadii Stepanov
a273d74b2e
cmake: Improve version comparison 2023-04-20 17:03:42 +01:00
Hennadii Stepanov
6a58b483ef
cmake: Use if(... IN_LIST ...) command
Available in CMake 3.3+.
2023-04-20 17:00:11 +01:00
Hennadii Stepanov
2445808c02
cmake: Use dedicated GENERATOR_IS_MULTI_CONFIG property
Available in CMake 3.9+.
2023-04-20 17:00:10 +01:00
Hennadii Stepanov
9f8703ef17
cmake: Use dedicated CMAKE_HOST_APPLE variable 2023-04-20 17:00:10 +01:00
Hennadii Stepanov
8c2017035a
cmake: Use recommended add_compile_definitions command
Available in CMake 3.12+.
2023-04-20 17:00:10 +01:00
Hennadii Stepanov
04d4cc071a
cmake: Add DESCRIPTION and HOMEPAGE_URL options to project command
`DESCRIPTION` is available in CMake 3.9+.
`HOMEPAGE_URL` is available in CMake 3.12+.
2023-04-20 17:00:10 +01:00
Hennadii Stepanov
8a8b6536ef
cmake: Use SameMinorVersion compatibility mode
Available in CMake 3.11+.
2023-04-20 17:00:03 +01:00
Tim Ruffing
5b0444a3b5
Merge bitcoin-core/secp256k1#1263: cmake: Make installation optional
47ac3d63cd5e00a2d50cb489461c8bc349d37912 cmake: Make installation optional (Anna “CyberTailor”)

Pull request description:

  Useful for embedding secp256k1 in a subproject.

ACKs for top commit:
  theuni:
    ACK 47ac3d63cd5e00a2d50cb489461c8bc349d37912.
  real-or-random:
    utACK 47ac3d63cd5e00a2d50cb489461c8bc349d37912
  hebasto:
    ACK 47ac3d63cd5e00a2d50cb489461c8bc349d37912, tested on Ubuntu 23.04.

Tree-SHA512: 12ac0ba9dc38adf45684055386280b669384b5a4e528a3f6f4470fd0b7f57d64dfed6a8bb9f0a84cacfcb72f509534d71676c5ba37b27297b1a96676eea44e6e
2023-04-20 17:44:44 +02:00
Anna “CyberTailor”
47ac3d63cd
cmake: Make installation optional
Useful for embedding secp256k1 in a subproject.
2023-04-20 19:20:33 +05:00
Tim Ruffing
2e035af251
Merge bitcoin-core/secp256k1#1273: build: Make SECP_VALGRIND_CHECK preserve CPPFLAGS
1ecb94ebe9800900c7dd3a4f9883c600e25eecf7 build: Make `SECP_VALGRIND_CHECK` preserve `CPPFLAGS` (Hennadii Stepanov)

Pull request description:

  It was overlooked in #862 and #1027.

ACKs for top commit:
  real-or-random:
    utACK 1ecb94ebe9800900c7dd3a4f9883c600e25eecf7

Tree-SHA512: 263fc600ce9743e4aad767150f706bf7d4325dabb9c363ed57f08fe38faea94d7d1999804947cffeacbe698bb6d959ee6de3f6e50400050a390ecc0db957e426
2023-04-20 10:34:04 +02:00
Tim Ruffing
5be353d658
Merge bitcoin-core/secp256k1#1279: tests: lint wycheproof's python script
35ada3b954ccc6c54628fb3bcc0365d176297019 tests: lint wycheproof's python script (RandomLattice)

Pull request description:

  This PR lints tests_wycheproof_generate.py according to bitcoin's python linting scripts. This is a follow-up to PR #1245.

ACKs for top commit:
  sipa:
    utACK 35ada3b954ccc6c54628fb3bcc0365d176297019
  real-or-random:
    utACK 35ada3b954ccc6c54628fb3bcc0365d176297019

Tree-SHA512: ea405060d2e73ff3543626687de5bc5282be923b914bd5c8c53e65df8dca9bea0000c416603095efff29bc7ae43c2081454c4e506db0f6805443d023fbffaf4c
2023-04-19 16:28:39 +02:00
Tim Ruffing
08f4b1632d autotools: Move code around to tidy Makefile 2023-04-19 15:55:25 +02:00
Jonas Nick
2c63d17c1e
bppp: align terminology with paper (gamma)
e -> gamma
2023-04-19 12:37:47 +00:00
Jonas Nick
dbf2e4d3e1
bppp: align terminology with paper (mu, rho)
q-> mu, r -> rho
2023-04-19 12:37:29 +00:00
Tim Ruffing
04bf3f6778
Merge bitcoin-core/secp256k1#1230: Build: allow static or shared but not both
ef49a11d29601e09e94134975c968e92c0214102 build: allow static or shared but not both (Cory Fields)
36b0adf1b90139a41fdcb94390d0bb06e9224795 build: remove warning until it's reproducible (Cory Fields)

Pull request description:

  Continuing from here: https://github.com/bitcoin-core/secp256k1/issues/1224#issuecomment-1460438227

  Unfortunately it wasn't really possible to keep a clean diff here because of the nature of the change. I suggest reviewing the lib creation stuff in its entirety, sorry about that :\

  Rather than allowing for shared and static libs to be built at the same time like autotools, this PR switches to the CMake convention of allowing only 1.

  A new `BUILD_SHARED_LIBS` option is added to match CMake convention, as well as a `SECP256K1_DISABLE_SHARED` option which overrides it. That way even projects which have `BUILD_SHARED_LIBS=1` can opt-into a static libsecp in particular.

  Details:

  Two object libraries are created: `secp256k1_asm` and `secp256k1_precomputed_objs`. Some tests/benchmarks use the object libraries directly, some link against the real lib: `secp256k1`.

  Because the objs don't know what they're going to be linked into, they need to be told how to deal with PIC.

  The `DEFINE_SYMBOL` property sets the `DLL_EXPORT` define as necessary (when building a shared lib)

ACKs for top commit:
  hebasto:
    re-ACK ef49a11d29601e09e94134975c968e92c0214102, only [suggested](https://github.com/bitcoin-core/secp256k1/pull/1230#pullrequestreview-1388191165) changes since my recent [review](https://github.com/bitcoin-core/secp256k1/pull/1230#pullrequestreview-1352125381).
  real-or-random:
    ACK ef49a11d29601e09e94134975c968e92c0214102

Tree-SHA512: 8870de305176fdb677caff0fdfc6f8c59c0e906489cb72bc9980e551002812685e59e20d731f2a82e33628bdfbb7261eafd6f228038cad3ec83bd74335959600
2023-04-18 12:54:03 +02:00
Tim Ruffing
9ce9984f32
Merge bitcoin-core/secp256k1#1265: Remove bits argument from secp256k1_wnaf_const{_xonly}
a575339c0282ba49a4f46c9c660a4cc3b6bfc703 Remove bits argument from secp256k1_wnaf_const (always 256) (Pieter Wuille)

Pull request description:

  There is little reason for having the number of bits in the scalar as a parameter, as I don't think there are any (current) use cases for non-256-bit scalars.

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

Tree-SHA512: 994b1f19b4c513f6d070ed259a5d6f221a0c2450271ec824c5eba1cd0ecace276de391c170285bfeae96aaf8f1e0f7fe6260966ded0336c75c522ab6c56d182c
2023-04-18 12:25:09 +02:00
Jonas Nick
566faa17d3
Merge bitcoin-core/secp256k1#1267: doc: clarify process for patch releases
1b6fb5593c3b0dad8f8ad17ddd29ca30ebd00af3 doc: clarify process for patch releases (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 1b6fb5593c3b0dad8f8ad17ddd29ca30ebd00af3

Tree-SHA512: 5c1da34c920f66327b91c1fd11ad2eccbb55c5befdb3ba59138faf921ce83d0e7c62de84f2431b0a63433f1edc0f7f0f025a852a76dd3638e3fd583ca13b83e4
2023-04-18 08:19:51 +00:00
Cory Fields
ef49a11d29 build: allow static or shared but not both 2023-04-17 16:25:27 +00:00
Tim Ruffing
f4dd0419aa
Merge ElementsProject/secp256k1-zkp#225: sync-upstream: Use --autostash to handle uncommitted changes
13c438cdeed358a20b1f0324ee36a6cadfaf0016 sync-upstream: Use --autostash to handle uncommitted changes (Tim Ruffing)

Pull request description:

  This makes it possible to use sync-upstream with uncommitted changes. (This is in particular helpful when working on the script itself.)

  Without this commit, git pull will fail due to the uncommitted changes.

ACKs for top commit:
  apoelstra:
    utACK 13c438cdeed358a20b1f0324ee36a6cadfaf0016

Tree-SHA512: c3a2fce68382bf4e769c64bbdc5666a8f4d9cf6f387e7d8af408e9c3e07b4a875205b7cdae9f647b7127128c13ee58effc0045ac5faf5fba2851b38af40439e8
2023-04-17 11:49:56 +02:00
RandomLattice
35ada3b954 tests: lint wycheproof's python script
This PR lints tests_wycheproof_generate.py according to pylint.
This is a follow-up to PR #1245.

Co-authored-by: Sean Andersen <6730974+andozw@users.noreply.github.com>
2023-04-14 18:59:35 +02:00
Tim Ruffing
4258c54f4e
Merge bitcoin-core/secp256k1#1276: autotools: Don't regenerate Wycheproof header automatically
06c67dea9f6d46d3e24e810900fbb03045eae641 autotools: Don't regenerate Wycheproof header automatically (Tim Ruffing)

Pull request description:

  This is a hot fix for https://github.com/bitcoin/bitcoin/pull/27445 .

  ---

  Pregenerated files that we distribute should not have dependencies in Makefile.am. For rationale, see the comments about the precomputed table files.

  See also https://github.com/bitcoin/bitcoin/pull/27445#issuecomment-1502994264 .

ACKs for top commit:
  hebasto:
    ACK 06c67dea9f6d46d3e24e810900fbb03045eae641
  RandomLattice:
    ACK 06c67dea9f

Tree-SHA512: fa7f44eaa1c7e42ecba5829ac1b8ae8b5826d1a1551e01c3caf37af780bd5c102c8f54e88520723937f7016d93c67b62a334c7a28b96c4f422a38fcf8e6a1984
2023-04-14 13:46:48 +02:00
Tim Ruffing
529b54d922 autotools: Move Wycheproof header from EXTRA_DIST to noinst_HEADERS 2023-04-14 08:00:10 +02:00
Tim Ruffing
06c67dea9f autotools: Don't regenerate Wycheproof header automatically
Pregenerated files that we distribute should not have dependencies
in Makefile.am. For rationale, see the comments about the precomputed
table files.

See also https://github.com/bitcoin/bitcoin/pull/27445#issuecomment-1502994264 .
2023-04-14 07:59:57 +02:00
Hennadii Stepanov
dc0657c762
build: Fix C4005 "macro redefinition" MSVC warnings in examples 2023-04-13 12:23:30 +01:00
Hennadii Stepanov
1ecb94ebe9
build: Make SECP_VALGRIND_CHECK preserve CPPFLAGS 2023-04-11 18:59:12 +01:00
Tim Ruffing
13c438cdee sync-upstream: Use --autostash to handle uncommitted changes
This makes it possible to use sync-upstream with uncommitted changes. (This
is in particular helpful when working on the script itself.)

Without this commit, git pull will fail due to the uncommitted changes.
2023-04-11 12:25:51 +02:00
Jonas Nick
6ec1ff6040
Merge elementsproject/secp256k1-zkp#224: Backport of "ct: Use volatile "trick" in all fe/scalar cmov implementations"
96f48538503ff40bf0017652c4b4f3a42cd3fa94 ct: Use volatile "trick" in all fe/scalar cmov implementations (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 96f48538503ff40bf0017652c4b4f3a42cd3fa94

Tree-SHA512: b3524a817ad8787a19dd28fc38523ab0ee2ddb72c5d88dfef566a9baa849b8d6a12df93030ecf97251e078128ec8203478bf98f3e8d9b28cc595ea5e8579c762
2023-04-11 10:15:01 +00:00
Tim Ruffing
96f4853850 ct: Use volatile "trick" in all fe/scalar cmov implementations
Apparently clang 15 is able to compile our cmov code into a branch,
at least for fe_cmov and fe_storage_cmov. This commit makes the
condition volatile in all cmov implementations (except ge but that
one only calls into the fe impls).

This is just a quick fix. We should still look into other methods,
e.g., asm and #457. We should also consider not caring about
constant-time in scalar_low_impl.h

We should also consider testing on very new compilers in nightly CI,
see https://github.com/bitcoin-core/secp256k1/pull/864#issuecomment-769211867
2023-04-11 12:06:09 +02:00
Jonas Nick
3bab71cf05
Merge bitcoin-core/secp256k1#1268: release cleanup: bump version after 0.3.1
656c6ea8d8ec5b4f1fa91bc7f0a0ecd10c5cf5a0 release cleanup: bump version after 0.3.1 (Jonas Nick)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 656c6ea8d8ec5b4f1fa91bc7f0a0ecd10c5cf5a0
  real-or-random:
    ACK 656c6ea8d8ec5b4f1fa91bc7f0a0ecd10c5cf5a0

Tree-SHA512: da24326ed5feaa6a432522bddd64e6c129455cfe55a9e2decfce8c6039f4ce1a1da64233d17200f45d2c142f5414505b9a9b2ef5d136e047c1dd6cfdde1b560d
2023-04-10 20:05:59 +00:00
Jonas Nick
656c6ea8d8
release cleanup: bump version after 0.3.1 2023-04-10 19:50:27 +00:00
Jonas Nick
346a053d4c
Merge bitcoin-core/secp256k1#1269: changelog: Fix link
6a37b2a5ea9075c5dff14b3067c61114a334a2ba changelog: Fix link (Tim Ruffing)

Pull request description:

Top commit has no ACKs.

Tree-SHA512: 70d50c8fe958a197eb527e51c6f8120609e3166d93bfc1bbec75a3cb565c406d5ba0e6d088a724dcfda422b6594abf53f507211946a0533515df371d5d2a91bf
2023-04-10 19:31:28 +00:00
Tim Ruffing
6a37b2a5ea changelog: Fix link 2023-04-10 20:52:11 +02:00
Jonas Nick
ec98fcedd5
Merge bitcoin-core/secp256k1#1266: release: Prepare for 0.3.1
898e1c676e177af73b2c7b540cc93e72a2790fa2 release: Prepare for 0.3.1 (Tim Ruffing)
1d9a13fc2640b9bf870cba65dc69c504c1c9468d changelog: Remove inconsistent newlines (Tim Ruffing)
0e091669a13190289ed9dcc2ea9b8c330412cbc7 changelog: Catch up in preparation of 0.3.1 (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 898e1c676e177af73b2c7b540cc93e72a2790fa2
  jonasnick:
    ACK 898e1c676e177af73b2c7b540cc93e72a2790fa2

Tree-SHA512: 941b1524f8b34ca803a2ede55a7baf54d2faa69a4c5e47254297e96cc4ac2121094ed90e7cd64a708f3e9af830b0de0ef3c755dfee1b01ce958cc998fc1a1311
2023-04-10 17:28:39 +00:00