2097 Commits

Author SHA1 Message Date
Tim Ruffing
afd7eb4a55
Merge bitcoin-core/secp256k1#1371: Add exhaustive tests for ellswift (with create+decode roundtrip)
2792119278bcb2a0befce3fbc64c83578df54953 Add exhaustive test for ellswift (create+decode roundtrip) (Sebastian Falbesoner)

Pull request description:

  This PR adds the basic structure for ellswift exhaustive tests. Right now only a `secp256k1_ellswift_create` + `secp256k1_ellswift_decode` indirect roundtrip (exhaustive loop scalar -> ellswift pubkey -> decoded pubkey -> decoded group element, compared with exhaustive precomputed group element) is included.

  The exhaustive tests passes locally with all currently supported orders (n=13 [default] and n=199). Note that for n=7, the test is skipped, as the used curve in this case is even-ordered and ellswift only supports odd-ordered curves.

ACKs for top commit:
  sipa:
    utACK 2792119278bcb2a0befce3fbc64c83578df54953
  real-or-random:
    utACK 2792119278bcb2a0befce3fbc64c83578df54953

Tree-SHA512: c51d3d99e9839793b3c15d75b9a29f01080db160ab8819973abd877288f9f0af972ea4264290220ab1cd035fdebcfac7767436aa39154d924ef0bf6a5733a55d
2023-07-05 23:19:31 +02:00
Sebastian Falbesoner
2792119278 Add exhaustive test for ellswift (create+decode roundtrip)
Co-authored-by: Pieter Wuille <pieter@wuille.net>
Co-authored-by: Tim Ruffing <crypto@timruffing.de>
2023-07-05 18:24:37 +02:00
Tim Ruffing
332af315fc
Merge bitcoin-core/secp256k1#1344: group: save normalize_weak calls in secp256k1_ge_is_valid_var/secp256k1_gej_eq_x_var
07c0e8b82e2cea87f85263512945fed7adffea18 group: remove unneeded normalize_weak in `secp256k1_gej_eq_x_var` (Sebastian Falbesoner)
efa76c4bf7cab1c22aa476cd2730e891450ad4a0 group: remove unneeded normalize_weak in `secp256k1_ge_is_valid_var` (Sebastian Falbesoner)

Pull request description:

  This PR removes unneeded normalize_weak calls in two group element functions:
  * `secp256k1_ge_is_valid_var`: After calculating the right-hand side of the elliptic curve equation (x^3 + 7), the field element `x3` has a magnitude of 2 (1 as result of `secp256k1_fe_mul`, then increased by 1 due to `secp256k1_fe_add_int`). This is fine for `secp256k1_fe_equal_var`, as the second parameter only requires the magnitude to not exceed 31, and the normalize_weak call is hence not needed and can be dropped. Note that the interface description for `secp256k1_fe_equal` (which also applies to `secp256k1_fe_equal_var`) once stated that _both_ parameters need to have magnitude 1, but that was corrected in commit 7d7d43c6dd2741853de4631881d77ae38a14cd23.

  * `secp256k1_gej_eq_x_var`: By requiring that the input group element's X coordinate (`a->x`) has a magnitude of <= 31, the normalize_weak call and also the field element variable `r2` are not needed anymore and hence can be dropped.

ACKs for top commit:
  sipa:
    utACK 07c0e8b82e2cea87f85263512945fed7adffea18
  jonasnick:
    ACK 07c0e8b82e2cea87f85263512945fed7adffea18

Tree-SHA512: 9037e4af881ce7bf3347414d6da06b99e3d318733ba4f70e8b24d2320c2f26d022144e17bd6b95c1a4ef1be3825a4464e56ce2d2b3ae7bbced04257048832b7f
2023-07-04 14:21:46 +02:00
Tim Ruffing
9e6d1b0e9b
Merge bitcoin-core/secp256k1#1367: build: Improvements to symbol visibility logic on Windows (attempt 3)
c6cd2b15a007ad0a2d5c4656ae641ba442d8b2fe ci: Add task for static library on Windows + CMake (Hennadii Stepanov)
020bf69a44ba700624d09de0c18ceb867369d24e build: Add extensive docs on visibility issues (Tim Ruffing)
0196e8ade16e2b2d8efadac01d8520205553ee39 build: Introduce `SECP256k1_DLL_EXPORT` macro (Hennadii Stepanov)
9f1b1904a358e4ce7248c6542e8c7ac143ba0e3f refactor: Replace `SECP256K1_API_VAR` with `SECP256K1_API` (Hennadii Stepanov)
ae9db95ceaa2605138fac9c237c640acea3f3bd6 build: Introduce `SECP256K1_STATIC` macro for Windows users (Hennadii Stepanov)

Pull request description:

  Previous attempts:
  - https://github.com/bitcoin-core/secp256k1/pull/1346
  - https://github.com/bitcoin-core/secp256k1/pull/1362

  The result is as follows:
  1. Simple, concise and extensively documented code.
  2. Explicitly documented use cases with no ambiguities.
  3. No workarounds for linker warnings.
  4. Solves one item in https://github.com/bitcoin-core/secp256k1/issues/1235.

ACKs for top commit:
  real-or-random:
    utACK c6cd2b15a007ad0a2d5c4656ae641ba442d8b2fe

Tree-SHA512: d58694452d630aefbd047916033249891bc726b7475433aaaa7c3ea2a07ded8f185a598385b67c2ee3440ec5904ff9d9452c97b0961d84dcb2eb2cf46caa171e
2023-07-03 18:53:38 +02:00
Tim Ruffing
0aacf64352
Merge bitcoin-core/secp256k1#1370: Corrected some typos
b6b9834e8da7f3fd91b95f750a4ee7a10bf67435 small fixes (Alejandro)

Pull request description:

  Corrected some typos

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

Tree-SHA512: c40c22c66f1067ecca351f08cca07a78b00bb98af2f6cfb08c25d0b1db6845e0e32ace1954c386db7020cf9fc7ae973ff15bd6d9c0144f3d21ea28c15741050f
2023-07-03 18:50:45 +02:00
Alejandro
b6b9834e8d small fixes
restoring wycheproof files

restoring wycheproof files2
2023-07-03 17:05:55 +02:00
Sebastian Falbesoner
07c0e8b82e group: remove unneeded normalize_weak in secp256k1_gej_eq_x_var
By requiring that the input group element's X coordinate (`a->x`) has a
magnitude of <= 31, the normalize_weak call and also the field element
variable `r2` are not needed anymore and hence can be dropped.
2023-07-03 16:54:19 +02:00
Tim Ruffing
3fc1de5c55
Merge bitcoin-core/secp256k1#1364: Avoid -Wmaybe-uninitialized when compiling with gcc -O1
5b9f37f136620b9c61cd66439904b2db266fba70 ci: Add `CFLAGS: -O1` to task matrix (Hennadii Stepanov)
a6ca76cdf2a3d0aef091e3d26d7c6c8ee9c88e72 Avoid `-Wmaybe-uninitialized` when compiling with `gcc -O1` (Hennadii Stepanov)

Pull request description:

  Fixes https://github.com/bitcoin-core/secp256k1/issues/1361.

  CI tasks have been adjusted to catch similar issues in the future.

ACKs for top commit:
  real-or-random:
    utACK 5b9f37f136620b9c61cd66439904b2db266fba70
  jonasnick:
    tACK 5b9f37f136620b9c61cd66439904b2db266fba70

Tree-SHA512: 8aa5ec22ed88579ecd37681df68d64f8bab93cd14bdbf432a3af41cadc7ab3eba86c33c179db15bf3a3c798c33064bd845ebdedb02ee617ef634e98c596838c2
2023-07-03 15:32:17 +02:00
Jonas Nick
fb758fe8d6
Merge bitcoin-core/secp256k1#1323: tweak_add: fix API doc for tweak=0
05873bb6b1041227f413626717b7af69fb6176ef tweak_add: fix API doc for tweak=0 (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 05873bb6b1041227f413626717b7af69fb6176ef

Tree-SHA512: ef587a680c3355c6328dd61e0f5fcac80ea995f6045b4392fe35f3ee1c04ee1bd941662c120758ad641588670c1f0f53bfb17a802821f54100f1385b8bb7375a
2023-07-03 13:11:20 +00:00
Hennadii Stepanov
c6cd2b15a0
ci: Add task for static library on Windows + CMake 2023-07-03 13:57:31 +01:00
Tim Ruffing
020bf69a44
build: Add extensive docs on visibility issues 2023-07-03 13:57:17 +01:00
Hennadii Stepanov
0196e8ade1
build: Introduce SECP256k1_DLL_EXPORT macro
This change provides a way to build a shared library that is not tired
to the Libtool-specific `DLL_EXPORT` macro.
2023-07-03 13:57:17 +01:00
Hennadii Stepanov
9f1b1904a3
refactor: Replace SECP256K1_API_VAR with SECP256K1_API 2023-07-03 13:57:16 +01:00
Hennadii Stepanov
ae9db95cea
build: Introduce SECP256K1_STATIC macro for Windows users
It is a non-Libtool-specific way to explicitly specify the user's
intention to consume a static `libseck256k1`.

This change allows to get rid of MSVC linker warnings LNK4217 and
LNK4286. Also, it makes possible to merge the `SECP256K1_API` and
`SECP256K1_API_VAR` into one.
2023-07-03 13:57:11 +01:00
Tim Ruffing
7966aee31d
Merge bitcoin-core/secp256k1#1369: ci: Print commit in Windows container
a7bec34231b991ad0e1f686f6505a81749a2a8c7 ci: Print commit in Windows container (Hennadii Stepanov)

Pull request description:

  This PR is a follow-up to https://github.com/bitcoin-core/secp256k1/pull/1368 and adds the same functionality to Windows containers that is already available in Linux containers.

  See: https://github.com/bitcoin-core/secp256k1/pull/1368#discussion_r1250454050.

ACKs for top commit:
  real-or-random:
    ACK a7bec34231b991ad0e1f686f6505a81749a2a8c7 seems to work: https://cirrus-ci.com/task/4919320090771456?logs=git_show#L2

Tree-SHA512: 0998e0f7231e3057a7e358a27b34071c73ca556973da20494db84fc67f2a72ad2fe582e59647a425ee41e7d9103a0a22fb3cdf0ace6fe0aed1d21f2f75c8ec53
2023-07-03 14:55:19 +02:00
Hennadii Stepanov
a7bec34231
ci: Print commit in Windows container
This change adds the same functionality to Windows containers that is
already available in Linux containers.
2023-07-03 09:31:49 +01:00
Jonas Nick
249c81eaa3
Merge bitcoin-core/secp256k1#1368: ci: Drop manual checkout of merge commit
98579e297b19bbb23c924f21942eccdbd618de67 ci: Drop manual checkout of merge commit (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 98579e297b19bbb23c924f21942eccdbd618de67

Tree-SHA512: fe5305322e6fa616af4664db7c151acdfb8119feb0255a65190b9c185ae5383eab37debe76085dfc8137c691e0ff55cb20d9e51993f6cc871bc6c5c945ed66bf
2023-07-02 18:23:54 +00:00
Tim Ruffing
98579e297b ci: Drop manual checkout of merge commit
This is no longer necessary as of
https://github.com/cirruslabs/cirrus-ci-docs/issues/791#issuecomment-1615691585 .
2023-07-01 13:01:57 +02:00
Hennadii Stepanov
5b9f37f136
ci: Add CFLAGS: -O1 to task matrix 2023-06-28 07:46:40 +01:00
Hennadii Stepanov
a6ca76cdf2
Avoid -Wmaybe-uninitialized when compiling with gcc -O1 2023-06-28 07:45:57 +01:00
Tim Ruffing
0fa84f869d
Merge bitcoin-core/secp256k1#1358: tests: introduce helper for non-zero random_fe_test() results
5a95a268b944ffe64b7857e58f5b3b44aba514da tests: introduce helper for non-zero `random_fe_test` results (Sebastian Falbesoner)
304421d57b66670428de656ae6b3272c1ab6fde5 tests: refactor: remove duplicate function `random_field_element_test` (Sebastian Falbesoner)

Pull request description:

  There are several instances in the tests where random non-zero field elements are generated by calling `random_fe_test` in a do/while-loop with is-zero condition. This PR deduplicates all these by introducing a `random_fe_non_zero_test` helper. Note that some instances checked the is-zero condition via `secp256k1_fe_normalizes_to_zero_var`, which is unnecessary, as the result of `random_field_element_test` is already normalized (so strictly speaking, this is not a pure refactor, and there could be tiny run-time improvements, though I doubt that's measurable).

  Additionally, the first commit removes the function `random_field_element_test` as it is logically a duplicate of `random_fe_test`.

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

Tree-SHA512: 920404f38ebe8b84bfd52f3354dc17ae6a0fd6355f99b78c9aeb53bf21f7eca5fd4518edc8a422d84f430ae95864661b497de42a3ab7fa9c49515a1df2f1d466
2023-06-27 12:16:50 +02:00
Sebastian Falbesoner
5a95a268b9 tests: introduce helper for non-zero random_fe_test results
There are several instances in the tests where random non-zero field
elements are generated by calling `random_fe_test` in a do/while-loop.
This commit deduplicates all these by introducing a
`random_fe_non_zero_test` helper. Note that some instances checked the
is-zero condition via `secp256k1_fe_normalizes_to_zero_var`, which is
unnecessary, as the result of `random_fe_test` is already normalized (so
strictly speaking, this is not a pure refactor).
2023-06-27 10:31:24 +02:00
Sebastian Falbesoner
304421d57b tests: refactor: remove duplicate function random_field_element_test
There is a function `random_fe_test` which does exactly the
same, so use that instead. Note that it's also moved up before the
`random_group_element_test` function, in order to avoid needing a forward
declaration.
2023-06-27 10:31:22 +02:00
Tim Ruffing
3aef6ab8e1
Merge bitcoin-core/secp256k1#1345: field: Static-assert that int args affecting magnitude are constant
be8ff3a02aeff87c60d49883a1b2afa8b2999bbe field: Static-assert that int args affecting magnitude are constant (Tim Ruffing)

Pull request description:

  See #1001.

  Try to revert the lines in `tests.c` to see the error message in action.

ACKs for top commit:
  sipa:
    ACK be8ff3a02aeff87c60d49883a1b2afa8b2999bbe. Verified by introducing some non-constant expressions and seeing compilation fail.
  theStack:
    ACK be8ff3a02aeff87c60d49883a1b2afa8b2999bbe

Tree-SHA512: 8befec6ee64959cdc7f3e29b4b622410794cfaf69e9df8df17600390a93bc787dba5cf86239de6eb2e99c038b9aca5461e4b3c82f0e0c4cf066ad7c689941b19
2023-06-27 09:39:10 +02:00
Tim Ruffing
4494a369b6
Merge bitcoin-core/secp256k1#1357: tests: refactor: take use of secp256k1_ge_x_on_curve_var
7d8d5c86df8b27b45e80ed50341dd0ce64546c0f tests: refactor: take use of `secp256k1_ge_x_on_curve_var` (Sebastian Falbesoner)

Pull request description:

  The recently merged ellswift PR (#1129) introduced a helper `secp256k1_ge_x_on_curve_var` to check if a given X coordinate is on the curve (i.e. the expression x^3 + 7 is square, see commit 79e5b2a8b80f507e2c9936ff1c4e2fb39bc66a4e). This can be used for code deduplication in the `ecmult_const_mult_xonly` test.

  (Found this instance via `$ git grep add_int.*SECP256K1_B`, I think it's the only one where the helper can be used.)

ACKs for top commit:
  sipa:
    utACK 7d8d5c86df8b27b45e80ed50341dd0ce64546c0f
  real-or-random:
    utACK 7d8d5c86df8b27b45e80ed50341dd0ce64546c0f

Tree-SHA512: aebff9b5ef2f6f6664ce89e4e1272cb55b6aac81cfb379652c4b7ab30dd1d7fd82a2c3b47c7b7429755ba28f011a3a9e2e6d3aa5c77d3b105d159104c24b89f3
2023-06-27 09:37:49 +02:00
Tim Ruffing
799f4eec27
Merge bitcoin-core/secp256k1#1356: ci: Adjust Docker image to Debian 12 "bookworm"
c862a9fb49e885dcafb42d4e21e05a244248aab0 ci: Adjust Docker image to Debian 12 "bookworm" (Hennadii Stepanov)
a1782098a9f0174aa7b7da431bf77c009dfeef51 ci: Force DWARF v4 for Clang when Valgrind tests are expected (Hennadii Stepanov)
8a7273465b3b17d6dedc67c7aac32a89a0a4dacf Help the compiler prove that a loop is entered (Tim Ruffing)

Pull request description:

  Since the [release](https://www.debian.org/News/2023/20230610.html) of Debian 12 "bookworm", it has become the "stable" one that our `ci/linux-debian.Dockerfile` relies on.

  Last time the Docker image was built basing on Debian Bullseye.

  Changes in packages are significant, for instance:
  - `gcc` 10.2. --> 12.2
  - `clang` 11.0 --> 14.0
  - `wine` 5.0 --> 8.0

  which requires certain adjustments provided in this PR.

  The first commit has been cherry-picked from https://github.com/bitcoin-core/secp256k1/pull/1313.

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

Tree-SHA512: 2a62a8865f904a460274f1f3ec02d2b0b72c84b25722a383c6455cfe672c1d93382941a5027e8dceb2c0f5fe0f0efd49a0ed6b72303982f9e32991f1535538eb
2023-06-27 09:33:42 +02:00
Hennadii Stepanov
c862a9fb49
ci: Adjust Docker image to Debian 12 "bookworm" 2023-06-26 10:24:15 +01:00
Hennadii Stepanov
a1782098a9
ci: Force DWARF v4 for Clang when Valgrind tests are expected 2023-06-26 10:03:19 +01:00
Sebastian Falbesoner
7d8d5c86df tests: refactor: take use of secp256k1_ge_x_on_curve_var
The recently merged ellswift PR (#1129) introduced a helper
`secp256k1_ge_x_on_curve_var` to check if a given X coordinate is
valid (i.e. the expression x^3 + 7 is square, see commit
79e5b2a8b80f507e2c9936ff1c4e2fb39bc66a4e). This can be used for code
deduplication in the `ecmult_const_mult_xonly` test.
2023-06-25 22:26:20 +02:00
Tim Ruffing
8a7273465b
Help the compiler prove that a loop is entered 2023-06-25 19:07:16 +01:00
Tim Ruffing
fd491ea1bb
Merge bitcoin-core/secp256k1#1355: Fix a typo in the error message
67887ae65cf11d02c7055709082acd0e5d86db9b Fix a typo in the error message (Hennadii Stepanov)

Pull request description:

  The code has been copy-pasted from the `precompute_ecmult_gen.c` source file.

ACKs for top commit:
  real-or-random:
    ACK 67887ae65cf11d02c7055709082acd0e5d86db9b

Tree-SHA512: d6874949310197e5d2d6c43f5a7c2165b4ee0f6cbe3cc1491d0f97163fa5329ebeab2b2adf10246c87382016fbe738c69dfd3f2253e93c906bf404cbf439b12a
2023-06-25 09:52:04 +02:00
Tim Ruffing
ac43613d25
Merge bitcoin-core/secp256k1#1354: Add ellswift to CHANGELOG
7c7467ab7f935f6b982064c8c48772a433da1f8f Refer to ellswift.md in API docs (Pieter Wuille)
c32ffd8d8c833a964ee7fbb294640764ad25de5d Add ellswift to CHANGELOG (Pieter Wuille)

Pull request description:

  A follow-up with a CHANGELOG entry for #1129.

ACKs for top commit:
  real-or-random:
    ACK 7c7467ab7f935f6b982064c8c48772a433da1f8f
  theStack:
    ACK 7c7467ab7f935f6b982064c8c48772a433da1f8f

Tree-SHA512: 4f066e4b8d5e130f2b5bea0ed4c634e9426bc576342aad6c306e0805a8354e27a5e679b15ec869d4e7d36eb5d53174e46b3bf5e15d19a7e165afc82e46ddfcf5
2023-06-25 09:49:40 +02:00
Hennadii Stepanov
67887ae65c
Fix a typo in the error message
The code has been copy-pasted from the `precompute_ecmult_gen.c` source
file.
2023-06-24 20:18:45 +01:00
Tim Ruffing
926dd3e962
Merge bitcoin-core/secp256k1#1295: abi: Use dllexport for mingw builds
bc7c8db179a56cf7273f3c4c0decd10543a10521 abi: Use dllexport for mingw builds (Cory Fields)

Pull request description:

  Addresses the first part of #1181. See the discussion there for more context and history.

  After this, all that remains is a (platform-independent) exports checker for c-i. Or perhaps a linker script or .def file could be tricked into testing as a side-effect.

  This should fix mingw exports, specifically hiding the following:
  `secp256k1_pre_g_128`
  `secp256k1_pre_g`
  `secp256k1_ecmult_gen_prec_table`

  This changes our visibility macros to look more like [gcc's recommendation](https://gcc.gnu.org/wiki/Visibility#How_to_use_the_new_C.2B-.2B-_visibility_support).

  Edit:
  Note that we could further complicate this by supporting `__attribute__ ((dllexport))` as well, though I didn't bother as I'm not sure what compiler combo would accept that but not the bare dllexport syntax.

  Edit2:
  As the title implies, this affects this ABI and could affect downstream libs/apps in unintended ways (though it's hard to imagine any real downside). Though because it's win32 only, I'm imagining very little real-world impact at all.

ACKs for top commit:
  hebasto:
    re-ACK bc7c8db179a56cf7273f3c4c0decd10543a10521, only a comment has been adjusted since my recent [review](https://github.com/bitcoin-core/secp256k1/pull/1295#pullrequestreview-1414928537),
  real-or-random:
    utACK bc7c8db179a56cf7273f3c4c0decd10543a10521

Tree-SHA512: 378e15556da49494f551bdf4f7b41304db9d03a435f21fcc947c9520aa43e3c655cfe216fba57a5179a871c975c806460eef7c33b105f2726e1de0937ff2444e
2023-06-24 10:37:55 +02:00
Tim Ruffing
10836832e7
Merge bitcoin-core/secp256k1#1336: Use __shiftright128 intrinsic in secp256k1_u128_rshift on MSVC
5b7bf2e9d4ee02cbec1105ad6e890c34a4da1beb Use `__shiftright128` intrinsic in `secp256k1_u128_rshift` on MSVC (Hennadii Stepanov)

Pull request description:

  Closes https://github.com/bitcoin-core/secp256k1/issues/1324.

  As the `__shiftright128` [docs](https://learn.microsoft.com/en-us/cpp/intrinsics/shiftright128) state:
  > The `Shift` value is always modulo 64...

  it is not applicable for the `n >= 64` branch.

ACKs for top commit:
  sipa:
    utACK 5b7bf2e9d4ee02cbec1105ad6e890c34a4da1beb
  real-or-random:
    ACK 5b7bf2e9d4ee02cbec1105ad6e890c34a4da1beb tested with MSVC x64

Tree-SHA512: bc4c245a9da83c783a0479e751a4bc2ec77a34b99189fcc4431033a5420c93b610f3b960d3f23c15bce2eb010beba665b3e84d468b3fdab3d5846d4f27016898
2023-06-24 10:16:02 +02:00
Pieter Wuille
7c7467ab7f Refer to ellswift.md in API docs 2023-06-23 16:05:24 -04:00
Pieter Wuille
c32ffd8d8c Add ellswift to CHANGELOG 2023-06-21 13:04:42 -04:00
Tim Ruffing
3c1a0fd37f
Merge bitcoin-core/secp256k1#1347: field: Document return value of fe_sqrt()
57791374579595bbc5d8d2e55f7fa0bc40d861a4 field: Document return value of fe_sqrt() (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 57791374579595bbc5d8d2e55f7fa0bc40d861a4
  theStack:
    ACK 57791374579595bbc5d8d2e55f7fa0bc40d861a4

Tree-SHA512: 706f8c6a26bf85f6c23af3bb053173b2cdee6838dd930cb2b1e2f851f47cfebafccecbd7d84b8152f2fea12f0676c1ddd700bb32beebec3f3e0f4300e878d0f5
2023-06-21 17:43:01 +02:00
Jonas Nick
705ce7ed8c
Merge bitcoin-core/secp256k1#1129: ElligatorSwift + integrated x-only DH
90e360acc2511f313964e394005bafb377b4f191 Add doc/ellswift.md with ElligatorSwift explanation (Pieter Wuille)
4f091847c20c9e9dd3cece2e8b62549278e5028b Add ellswift testing to CI (Pieter Wuille)
1bcea8c57f3f232c8e91d9eb3aad522766d13026 Add benchmarks for ellswift module (Pieter Wuille)
2d1d41acf85a385be6c436307eb826122c21846f Add ctime tests for ellswift module (Pieter Wuille)
df633cdeba133a9468c43f055122b07bf102dd2d Add _prefix and _bip324 ellswift_xdh hash functions (Pieter Wuille)
9695deb351e7742f78dc4ed72dea6655dcf6bb0e Add tests for ellswift module (Pieter Wuille)
c47917bbd62c488fb168431169c1ffe780562da1 Add ellswift module implementing ElligatorSwift (Pieter Wuille)
79e5b2a8b80f507e2c9936ff1c4e2fb39bc66a4e Add functions to test if X coordinate is valid (Pieter Wuille)
a597a5a9cedc27eb6a1190b1959cb9fe0d26a7dc Add benchmark for key generation (Pieter Wuille)

Pull request description:

ACKs for top commit:
  Davidson-Souza:
    tACK 90e360a. Full testing backlog:
  real-or-random:
    ACK 90e360acc2511f313964e394005bafb377b4f191
  jonasnick:
    ACK 90e360acc2511f313964e394005bafb377b4f191

Tree-SHA512: cf59044c1b064f9a3fd57fd1c4c6ab154305ee6ad67a604bc254ddd6b8ee78626250d325174e10d2f2b19264ab0d58013508dc763aa07f5a1e6417e03551a378
2023-06-21 14:34:39 +00:00
Tim Ruffing
0702ecb061
Merge bitcoin-core/secp256k1#1338: Drop no longer needed #include "../include/secp256k1.h"
e449af6872445d33a0796224fcb733be6476ad36 Drop no longer needed `#include "../include/secp256k1.h"` (Hennadii Stepanov)

Pull request description:

  The removed header includes have not been needed since https://github.com/bitcoin-core/secp256k1/pull/1231.

  Test suggestions:
  1. Using Autottols-based build system:
  ```
  ./autogen.sh
  ./configure
  make clean-precomp
  make
  ```
  2. Using CMake-based build system:
  ```
  cmake -B build -DCMAKE_C_INCLUDE_WHAT_YOU_USE="include-what-you-use"
  cmake --build build --target secp256k1_precomputed
  ```

ACKs for top commit:
  sipa:
    utACK e449af6872445d33a0796224fcb733be6476ad36
  real-or-random:
    utACK e449af6872445d33a0796224fcb733be6476ad36

Tree-SHA512: 5aed7a88e1e03fcc2306c43817712c0652ecf6145679dd17f4719376818d372f619e4180bdaee548f2e82aaccbe6a2ff4c37203121d939af545128c8c48b933e
2023-06-21 09:55:02 +02:00
Tim Ruffing
5779137457 field: Document return value of fe_sqrt()
Co-authored-by: Jonas Nick <jonasd.nick@gmail.com>
2023-06-21 00:18:24 +02:00
Pieter Wuille
90e360acc2 Add doc/ellswift.md with ElligatorSwift explanation 2023-06-20 11:31:58 -04:00
Pieter Wuille
4f091847c2 Add ellswift testing to CI 2023-06-20 11:31:58 -04:00
Pieter Wuille
1bcea8c57f Add benchmarks for ellswift module 2023-06-20 11:31:58 -04:00
Pieter Wuille
2d1d41acf8 Add ctime tests for ellswift module 2023-06-20 11:31:58 -04:00
Pieter Wuille
df633cdeba Add _prefix and _bip324 ellswift_xdh hash functions 2023-06-20 11:31:58 -04:00
Pieter Wuille
9695deb351 Add tests for ellswift module
These include both test vectors taken from BIP324, as randomized unit tests.
2023-06-20 11:31:58 -04:00
Pieter Wuille
c47917bbd6 Add ellswift module implementing ElligatorSwift
The scheme implemented is described below, and largely follows the paper
"SwiftEC: Shallue–van de Woestijne Indifferentiable Function To Elliptic Curves",
by Chavez-Saab, Rodriguez-Henriquez, and Tibouchi
(https://eprint.iacr.org/2022/759).

A new 64-byte public key format is introduced, with the property that *every*
64-byte array is an encoding for a non-infinite curve point. Each curve point
has roughly 2^256 distinct encodings. This permits disguising public keys as
uniformly random bytes.

The new API functions:
* secp256k1_ellswift_encode: convert a normal public key to an ellswift 64-byte
  public key, using additional entropy to pick among the many possible
  encodings.
* secp256k1_ellswift_decode: convert an ellswift 64-byte public key to a normal
  public key.
* secp256k1_ellswift_create: a faster and safer equivalent to calling
  secp256k1_ec_pubkey_create + secp256k1_ellswift_encode.
* secp256k1_ellswift_xdh: x-only ECDH directly on ellswift 64-byte public keys,
  where the key encodings are fed to the hash function.

The scheme itself is documented in secp256k1_ellswift.h.
2023-06-20 11:31:58 -04:00
Pieter Wuille
79e5b2a8b8 Add functions to test if X coordinate is valid 2023-06-20 11:05:32 -04:00
Pieter Wuille
a597a5a9ce Add benchmark for key generation 2023-06-20 10:57:19 -04:00