1444 Commits

Author SHA1 Message Date
Jonas Nick
c545fdc374
Merge bitcoin-core/secp256k1#1298: Remove randomness tests
6ec3731e8c53658fcf68634c81bb1e47cad791ad Simplify test PRNG implementation (Pieter Wuille)
fb5bfa4eed834dcd58109525408a2d88dabc48c5 Add static test vector for Xoshiro256++ (Tim Ruffing)
723e8ca8f7ee75126bac4240feeac825c23a0d44 Remove randomness tests (Pieter Wuille)

Pull request description:

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

Tree-SHA512: 4cbbb9c42e31f067b17dd9169ae5d5e68bce77d1253452db9df523d3be2b5d61002d5a4203e5a153f257ec63c5ff2113555743eeb402d4b6c573069ea494d407
2023-07-18 14:05:46 +00:00
Jonas Nick
6c54db1987
Merge commits '2286f809 751c4354 477f02c4 e3f84777 5c789dcd 8c949f56 21ffe4b2 ' into temp-merge-1055 2023-07-18 12:51:17 +00:00
Jonas Nick
e996d076da
Merge commits '44916ae9 86e3b38a ddf2b291 6138d73b e40fd277 ' into temp-merge-1156 2023-07-17 14:02:13 +00:00
Jonas Nick
64717a7b16
Merge commits '8b013fce 485f608f 44c2452f cd470333 accadc94 43756da8 af65d30c 63a3565e 6a873cc4 3efeb9da 9f8a13dc 694ce8fb a43e982b e13fae48 c2ee9175 ' into temp-merge-1146 2023-07-17 13:02:36 +00:00
Jonas Nick
9a981068ce
Merge commits '8b013fce 485f608f 44c2452f cd470333 accadc94 43756da8 ' into temp-merge-1115 2023-07-17 12:01:46 +00:00
Jonas Nick
c424e2fb43
ellswift: fix probabilistic test failure when swapping sides
When configured with `--disable-module-ecdh --enable-module-recovery`, then
`./tests  64 81af32fd7ab8c9cbc2e62a689f642106` fails with
```
src/modules/ellswift/tests_impl.h:396: test condition failed: secp256k1_memcmp_var(share32_bad, share32a, 32) != 0
```

This tests verifies that changing the `party` bit of the
`secp256k1_ellswift_xdh` function results in a different share. However, that's
not the case when the secret keys of both parties are the same and this is
actually what happens in the observed test failure. The keys can be equal in
this test case because they are created by the `random_scalar_order_test`
function whose output is not uniformly random (it's biased towards 0).

This commit restores the assummption that the secret keys differ.
2023-07-17 09:50:32 +00:00
Tim Ruffing
0f7657d59c
Merge bitcoin-core/secp256k1#1366: field: Use restrict consistently in fe_sqrt
b79ba8aa4c074b2cd09188f6f85ba68d6b80fe50 field: Use `restrict` consistently in fe_sqrt (Tim Ruffing)

Pull request description:

  That is, use it also in the definition and not only the declaration.

  I believe this was the intention of commit
  be82bd8e03, but it was omitted there.

  edit: Changed the description. I'm not entirely sure but after looking at the standard, I tend to think this is more than a cosmetic change, and only this change actually makes the parameters `restrict`. Anyway, I believe making them `restrict` was simply forgotten in be82bd8e0347e090037ff1d30a22a9d614db8c9f.

ACKs for top commit:
  sipa:
    utACK b79ba8aa4c074b2cd09188f6f85ba68d6b80fe50

Tree-SHA512: eecec7674d8cef7833d50f4041b87241ca8de4839aa8027df1c422b89f5a1bcef3916ac785057a596c459ce1aa9d41e5a21ecb6fed9c5d15a1d9f588c7ee208e
2023-07-12 01:14:22 +02:00
Tim Ruffing
cc55757552
Merge bitcoin-core/secp256k1#1340: clean up in-comment Sage code (refer to secp256k1_params.sage, update to Python3)
600c5adcd59240305e22918943f45dceeabb7e93 clean up in-comment Sage code (refer to secp256k1_params.sage, update to Python3) (Sebastian Falbesoner)

Pull request description:

  Some of the C source files contain contain in-comment Sage code calculating secp256k1 parameters that are already defined in the file secp256k1_params.sage.  Replace that by a corresponding load instruction and access the necessary variables. In ecdsa_impl.h, update the comment to use a one-line shell command calling sage to get the values.

  The remaining code (test `test_add_neg_y_diff_x` in tests.c) is updated to work with a current version based on Python3 (Sage 9.0+, see https://wiki.sagemath.org/Python3-Switch).

  The latter can be seen as a small follow-up to PR #849 (commit 13c88efed0005eb6745a222963ee74564054eafb).

ACKs for top commit:
  sipa:
    ACK 600c5adcd59240305e22918943f45dceeabb7e93
  real-or-random:
    ACK 600c5adcd59240305e22918943f45dceeabb7e93

Tree-SHA512: a9e52f6afbce65edd9ab14203612c3d423639f450fe8f0d269a3dda04bebefa95b607f7aa0faec864cb78b46d49f281632bb1277118749b7d8613e9f5dcc8f3d
2023-07-10 18:34:16 +02:00
Sebastian Falbesoner
600c5adcd5 clean up in-comment Sage code (refer to secp256k1_params.sage, update to Python3)
Some of the C source files contain contain in-comment Sage code
calculating secp256k1 parameters that are already defined in the file
secp256k1_params.sage.  Replace that by a corresponding load instruction
and access the necessary variables. In ecdsa_impl.h, update the comment
to use a one-line shell command calling sage to get the values.

The remaining code (test `test_add_neg_y_diff_x` in tests.c) is updated
to work with a current version based on Python3 (Sage 9.0+, see
https://wiki.sagemath.org/Python3-Switch).

The latter can be seen as a small follow-up to PR #849 (commit
13c88efed0005eb6745a222963ee74564054eafb).
2023-07-10 02:28:31 +02:00
Tim Ruffing
b79ba8aa4c field: Use restrict consistently in fe_sqrt
That is, use it also in the definition and not only the declaration.

I believe this was the intention of commit
be82bd8e0347e090037ff1d30a22a9d614db8c9f, but it was omitted there.
2023-07-06 16:44:52 +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
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
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
Hennadii Stepanov
a6ca76cdf2
Avoid -Wmaybe-uninitialized when compiling with gcc -O1 2023-06-28 07:45:57 +01: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
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
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
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
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
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
Tim Ruffing
30574f22ea
Merge bitcoin-core/secp256k1#1349: Normalize ge produced from secp256k1_pubkey_load
f1652528be5a287a3c33a4fae1e5763693333c2b Normalize ge produced from secp256k1_pubkey_load (stratospher)

Pull request description:

  The output `ge` in secp256k1_pubkey_load is normalized when `sizeof(secp256k1_ge_storage) = 64` but not when it's not 64. ARG_CHECK at the end of the function assumes normalization. So normalize ge in the other code path too.

  context: [#1129(comment)](https://github.com/bitcoin-core/secp256k1/pull/1129/files#r1196167066)

ACKs for top commit:
  sipa:
    utACK f1652528be5a287a3c33a4fae1e5763693333c2b
  real-or-random:
    ACK f1652528be5a287a3c33a4fae1e5763693333c2b tested by changing the two `== 64` checks to `== 65`

Tree-SHA512: 0de1caad85ccdb42053f8e09576135257c88fda88455ef25e7640049c05a1e03d1e9bae1cd132d2e6fc327fd79929257a8b21fe1cc41c82374b6cd88e6744aa3
2023-06-18 20:34:43 +02:00
stratospher
f1652528be Normalize ge produced from secp256k1_pubkey_load
The output ge is normalized when sizeof(secp256k1_ge_storage) = 64
but not when it's not 64. ARG_CHECK at the end of the function
assumes normalization. So normalize ge in the other code path too.
2023-06-17 10:26:19 +05:30
Sebastian Falbesoner
7067ee54b4 tests: add tests for secp256k1_{read,write}_be64
This can be reviewed with `--ignore-all-space` (or `-w`), to ignore
already existing code that was only indented.
2023-06-17 01:54:25 +02:00
Sebastian Falbesoner
740528caad scalar: use newly introduced secp256k1_{read,write}_be64 helpers (4x64 impl.) 2023-06-17 01:06:35 +02:00
Tim Ruffing
be8ff3a02a field: Static-assert that int args affecting magnitude are constant
See #1001.
2023-06-13 13:34:49 +02:00
Sebastian Falbesoner
efa76c4bf7 group: remove unneeded normalize_weak in 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 can
hence be dropped.
2023-06-12 23:57:15 +02:00
Sebastian Falbesoner
887183e7de scalar: use secp256k1_{read,write}_be32 helpers (4x64 impl.)
An alternative would be to introduce special helpers for reading/writing
uint64_t in big endian `secp256k1_{read,write}_be64`.
2023-06-10 19:50:54 +02:00
Sebastian Falbesoner
52b84238de scalar: use secp256k1_{read,write}_be32 helpers (8x32 impl.) 2023-06-10 19:21:38 +02:00
Hennadii Stepanov
e449af6872
Drop no longer needed #include "../include/secp256k1.h"
The removed header includes have not been needed since PR1231.
2023-06-06 09:07:36 +01:00
Hennadii Stepanov
747ada3587
test: Silent noisy clang warnings about Valgrind code on macOS x86_64 2023-06-04 18:25:39 +01:00
Hennadii Stepanov
5b7bf2e9d4
Use __shiftright128 intrinsic in secp256k1_u128_rshift on MSVC 2023-06-04 18:03:36 +01:00
Sebastian Falbesoner
605e07e365 fix input range comment for secp256k1_fe_add_int
This seems to be a typo that was introduced with commit
4371f98346b0a50c0a77e93948fe5e21d9346d06 (PR #1066).
2023-06-01 02:55:12 +02:00