Commit Graph

10 Commits

Author SHA1 Message Date
MarcoFalke
fa67b6752d refactor: Use array initialization for unterminated strings
The previous code is correct and harmless to initialize an array with a
non-terminated character sequence using a string literal.

However, it requires exactly specifying the array size, which can be
cumbersome.

Also, GCC-15 may issue the -Wunterminated-string-initialization warning.
[1]

Fix both issues by using array initialization. This refactoring commit
does not change behavior.

[1] Example warning:

src/modules/schnorrsig/main_impl.h:48:46: error: initializer-string for array of 'unsigned char' is too long [-Werror=unterminated-string-initialization]
   48 | static const unsigned char bip340_algo[13] = "BIP0340/nonce";
      |                                              ^~~~~~~~~~~~~~~
2024-08-15 17:58:14 +02:00
Sebastian Falbesoner
e73f6f8fd9 tests: refactor: drop secp256k1_ prefix from testrand.h functions
The rename was done with the following command:

$ sed -i 's/secp256k1_testrand/testrand/g' $(git grep -l secp256k1_testrand)
2024-05-27 03:29:36 +02:00
Sebastian Falbesoner
0ee7453a99 tests: refactor: add testutil_ prefix to testutil.h functions 2024-05-27 03:29:32 +02:00
Sebastian Falbesoner
59db007f0f tests: refactor: rename random_group_element_... -> random_ge_...
The rename was done with the following command:

$ sed -i 's/random_group_element_/random_ge_/g' $(git grep -l random_group_element_)
2024-05-27 03:09:04 +02:00
Sebastian Falbesoner
e7bdddd9c9 refactor: rename check_fe_equal -> fe_equal
As this function doesn't do any checking, it's better to rename it,
so that it's less likely to miss the needed `CHECK`.
2024-02-01 15:34:40 +01:00
Pieter Wuille
04af0ba162 Replace ge_equals_ge[,j] calls with group.h equality calls 2023-12-01 16:10:20 -05:00
Sebastian Falbesoner
cf25c86d05 introduce and use SECP256K1_{FE,GE,GEJ}_VERIFY macros
By providing an uppercase variant of these verification functions, it is
better visible that it is test code and surrounding `#ifdef VERIFY`
blocks can be removed (if there is no other code around that could
remain in production mode), as they don't serve their purpose any more.

At some places intentional blank lines are inserted for grouping and
better readadbility.
2023-12-01 00:54:58 +01: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
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