Commit Graph

2666 Commits

Author SHA1 Message Date
Hennadii Stepanov
d1478763a5 build: Drop no longer needed -fvisibility=hidden compiler option 2025-03-11 21:59:35 +00:00
Hennadii Stepanov
8ed1d83d92 ci: Run tools/symbol-check.py 2025-03-11 21:59:35 +00:00
Hennadii Stepanov
41d32ab2de test: Add tools/symbol-check.py
Co-authored-by: Tim Ruffing <crypto@timruffing.de>
2025-03-11 21:58:55 +00:00
Hennadii Stepanov
88548058b3 Introduce SECP256K1_LOCAL_VAR macro
This change makes the `-fvisibility=hidden` compiler option unnecessary.
2025-03-11 21:58:55 +00:00
merge-script
03bbe8c615 Merge bitcoin-core/secp256k1#1655: gha: Print all *.log files, in a separate action
59860bcc24 gha: Print all *.log files, in a separate action (Tim Ruffing)

Pull request description:

  Before this commit, we didn't print *_example.log files and
  test_suite.log.

  Printing is now handled in a separate action, which avoids code
  duplication and makes the ci.yml file more readable. This changes the
  folding/grouping of the log output in the GitHub Actions CI, but I
  think the new variant is as good as the old one.

  Furthermore, the condition for printing the logs is changed from
  "always()" to "!cancelled()". This ensures that logs will still be
  printed if previous steps such as the CI script failed, but that they
  won't be printed if the entire run is cancelled (e.g., by clicking a
  button in the UI or through a force-push to the PR). This is in line
  with a recommendation in the GHA docs:
  https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#always

ACKs for top commit:
  hebasto:
    ACK 59860bcc24.
  sipa:
    ACK 59860bcc24

Tree-SHA512: ca11f5e5f01660964276b9c2e11c22caeed8492e9c7ffaa2078aaaa733005c63242fc93a1056124fb8f1f83019d46818c12b10142fb10f43270a8562fd10885a
2025-03-11 22:08:45 +01:00
Tim Ruffing
59860bcc24 gha: Print all *.log files, in a separate action
Before this commit, we didn't print *_example.log files and
test_suite.log.

Printing is now handled in a separate action, which avoids code
duplication and makes the ci.yml file more readable. This changes the
folding/grouping of the log output in the GitHub Actions CI, but I
think the new variant is as good as the old one.

Furthermore, the condition for printing the logs is changed from
"always()" to "!cancelled()". This ensures that logs will still be
printed if previous steps such as the CI script failed, but that they
won't be printed if the entire run is cancelled (e.g., by clicking a
button in the UI or through a force-push to the PR). This is in line
with a recommendation in the GHA docs:
https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#always
2025-03-10 21:09:07 +01:00
merge-script
4ba1ba2af9 Merge bitcoin-core/secp256k1#1647: cmake: Adjust diagnostic flags for clang-cl
4c50d73dd9 ci: Add new "Windows (clang-cl)" job (Hennadii Stepanov)
84c0bd1f72 cmake: Adjust diagnostic flags for clang-cl (Hennadii Stepanov)

Pull request description:

  When building with `clang-cl` on Windows, the output is cluttered with warning messages because compiler diagnostic flags are not applied correctly:
  ```
  > cmake -B build -G Ninja -DCMAKE_C_COMPILER="C:\Users\hebasto\Downloads\clang+llvm-18.1.8-x86_64-pc-windows-msvc\bin\clang-cl.exe"
  > cmake --build build
  [1/16] Building C object src\CMakeFiles\bench.dir\bench.c.obj
  In file included from C:\Users\hebasto\secp256k1\src\bench.c:11:
  C:\Users\hebasto\secp256k1\src\util.h(34,13): warning: unused function 'print_buf_plain' [-Wunused-function]
     34 | static void print_buf_plain(const unsigned char *buf, size_t len) {
        |             ^~~~~~~~~~~~~~~
  1 warning generated.
  [2/16] Building C object src\CMakeFiles\secp256k1_precomputed.dir\precomputed_ecmult_gen.c.obj
  In file included from C:\Users\hebasto\secp256k1\src\precomputed_ecmult_gen.c:3:
  In file included from C:\Users\hebasto\secp256k1\src\group.h:10:
  In file included from C:\Users\hebasto\secp256k1\src\field.h:10:
  C:\Users\hebasto\secp256k1\src\util.h(34,13): warning: unused function 'print_buf_plain' [-Wunused-function]
     34 | static void print_buf_plain(const unsigned char *buf, size_t len) {
        |             ^~~~~~~~~~~~~~~
  ```

  This PR resolves this issue.

  ---

  **Additional note for reviewers:** The VS builtin clang can also be used assuming that the following VS components are installed:

  ![photo_2024-12-12_12-38-17](https://github.com/user-attachments/assets/c69bafcc-3aa2-4a72-a162-071c593d1c4a)

  The user can generate a build system on Windows as follows:
  - Using the default "Visual Studio" generator:
  ```
  cmake -B build -T ClangCL
  ```
  - Using the "Ninja" generator:
  ```
  cmake -B build -G Ninja -DCMAKE_C_COMPILER=clang-cl
  ```

  ---

  Required for downstream projects which aim to build with `clang-cl` (see https://github.com/bitcoin/bitcoin/issues/31456).

ACKs for top commit:
  real-or-random:
    utACK 4c50d73dd9

Tree-SHA512: 439eb53afd7be65d538cd569f3d095f58325bd26ffc5014ca5f94320689a45b20c9a5a963170578214a20fd3233ec15ef6ab75ab96ce3a4314c282b1b6229ca1
2025-03-10 17:54:36 +01:00
Jonas Nick
abd25054a1 Merge bitcoin-core/secp256k1#1656: musig: Fix clearing of pubnonces
961ec25a83 musig: Fix clearing of pubnonces (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 961ec25a83
  jonasnick:
    ACK 961ec25a83

Tree-SHA512: 7840318773987e6a94b0ce81068843a53e990f06d09a6f8fd47c76863b77b6c4de00a6fe3d8465118981d7e51ed0d229057147d200f3a70e55e007463689eeeb
2025-03-10 15:15:03 +00:00
Tim Ruffing
961ec25a83 musig: Fix clearing of pubnonces
Fixes a silent merge conflict between #1614 and #1579.
2025-03-10 15:10:29 +01:00
merge-script
3186082387 Merge bitcoin-core/secp256k1#1614: Add _ge_set_all_gej and use it in musig for own public nonces
64228a648f musig: Use _ge_set_all_gej for own public nonces (Tim Ruffing)
300aab1c05 tests: Improve _ge_set_all_gej(_var) tests (Tim Ruffing)
365f274ce3 group: Simplify secp256k1_ge_set_all_gej (Tim Ruffing)
d3082ddead group: Add constant-time secp256k1_ge_set_all_gej (Tim Ruffing)

Pull request description:

  As suggested in https://github.com/bitcoin-core/secp256k1/pull/1479#discussion_r1781469191

ACKs for top commit:
  theStack:
    re-ACK 64228a648f
  sipa:
    ACK 64228a648f

Tree-SHA512: f62a95e44dc09bb55a64da0640ad323e7ef5acc262d3c2aea6787eae0918769ea97da466b7d602e59693e4fb85c5ec9a67fdfba8b890624467855b6d1e1596c0
2025-03-10 14:44:37 +01:00
merge-script
6c2a39dafb Merge bitcoin-core/secp256k1#1639: Make static context const
432ac57705 Make static context const (Daniel Pfeifer)

Pull request description:

  Fixes #1637

ACKs for top commit:
  real-or-random:
    ACK 432ac57705

Tree-SHA512: 64e91a02fff8fd31bd6da3a37f25f572877343fb8081693c42a0517fae5cbc3951f38ec372d0a1fd91388596b6d85531d3f154a49208b43b0f56a4c72951c42b
2025-02-25 10:54:23 +01:00
Sebastian Falbesoner
37d2c60bec Remove deprecated _ec_privkey_{negate,tweak_add,tweak_mul} aliases
These function aliases have been described as DEPRECATED in the public
API docs already many years ago (see #701, commit 41fc7856), and in
addition explicit deprecation warnings are shown by the compiler at
least since the first official release 0.2.0 (see PR #1089, commit
fc94a2da), so it should be fine to just remove them by now.

Co-authored-by: Tim Ruffing <crypto@timruffing.de>
2025-02-25 04:17:45 +01:00
Daniel Pfeifer
432ac57705 Make static context const 2025-02-24 17:25:27 +01:00
merge-script
1b1fc09341 Merge bitcoin-core/secp256k1#1642: Verify compressed argument in secp256k1_eckey_pubkey_serialize
1823594761 Verify `compressed` argument in `secp256k1_eckey_pubkey_serialize` (Sebastian Falbesoner)

Pull request description:

  Due to similarity to the public API function `secp256k1_ec_pubkey_serialize`, public API flags like `SECP256K1_EC_COMPRESSED` are sometimes mistakingly passed to `secp256k1_eckey_pubkey_serialize` in newly proposed code (this is currently the case for several modules in secp256k1-zkp, see https://github.com/BlockstreamResearch/secp256k1-zkp/pull/300), which is currently not detected. To avoid this in the future, a VERIFY_CHECK is added to check that the `compressed` argument is either 0 or 1.

ACKs for top commit:
  real-or-random:
    utACK 1823594761
  stratospher:
    ACK 1823594. Got tests failures when passing public API flags to `secp256k1_eckey_pubkey_serialize`.

Tree-SHA512: ca542afc87f33e436ba33dc55b285dfe3759007c446ef94503bc1044c7a0a7f7b2208ae82e2c9743fc5fa38cf386127f3fbfa02d2c242f28fab3041ee46f153b
2025-02-24 15:24:38 +01:00
merge-script
c0d9480fbb Merge bitcoin-core/secp256k1#1654: use EXIT_ constants over magic numbers for indicating program execution status
13d389629a CONTRIBUTING: mention that `EXIT_` codes should be used (Sebastian Falbesoner)
c855581728 test, bench, precompute_ecmult: use `EXIT_...` constants for `main` return values (Sebastian Falbesoner)
965393fcea examples: use `EXIT_...` constants for `main` return values (Sebastian Falbesoner)

Pull request description:

  This simple PR addresses #1609 for all example and internal binaries. Alternative to #1618, which is stale (the author confirmed to me that they are not working on that PR anymore). The last commits adds a suggestion to CONTRIBUTING.md, not sure though if we want to go that far.

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

Tree-SHA512: 513eba4b712ba3d5f23a5fdc51cb27c5347b29bcaba39501345913c220be6f093a41186911032d2ddc898b848de84f05f374b3554ffcf92610728b2a23c0bb36
2025-02-24 10:15:27 +01:00
Sebastian Falbesoner
13d389629a CONTRIBUTING: mention that EXIT_ codes should be used 2025-02-14 18:03:55 +01:00
Sebastian Falbesoner
c855581728 test, bench, precompute_ecmult: use EXIT_... constants for main return values 2025-02-14 18:03:36 +01:00
Sebastian Falbesoner
965393fcea examples: use EXIT_... constants for main return values
Fixes issue #1609.
2025-02-14 13:43:10 +01:00
Jonas Nick
2e3bf13653 Merge bitcoin-core/secp256k1#1646: README: add instructions for verifying GPG signatures
b682dbcf84 README: add instructions for verifying GPG signatures (James O'Beirne)

Pull request description:

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

Tree-SHA512: 77ec0014e1a98e13ef38537177ea10175f064e7314e41474cd13a9c95c734ae1cca09effa2e2184a8c1495f3621e418d0df098fde4890d972d914cd7e80aa2d7
2025-02-10 13:23:28 +00:00
James O'Beirne
b682dbcf84 README: add instructions for verifying GPG signatures 2025-02-06 08:20:03 -05:00
Jonas Nick
00774d0723 Merge bitcoin-core/secp256k1#1650: schnorrsig: clear out masked secret key in BIP-340 nonce function
a82287fb85 schnorrsig: clear out masked secret key in BIP-340 nonce function (Sebastian Falbesoner)

Pull request description:

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

Tree-SHA512: 0e77ddc299e204edae238759e549d4e8314abb730a654580a109ec05daf53a625be1cc37664a9e00fd41cf34a94abede96b547e661cdf18c40c50141e7b4ee0e
2025-01-29 14:03:58 +00:00
Sebastian Falbesoner
a82287fb85 schnorrsig: clear out masked secret key in BIP-340 nonce function 2025-01-29 04:05:02 +01:00
Hennadii Stepanov
4c50d73dd9 ci: Add new "Windows (clang-cl)" job 2024-12-13 09:35:55 +00:00
Hennadii Stepanov
84c0bd1f72 cmake: Adjust diagnostic flags for clang-cl 2024-12-13 09:19:40 +00:00
merge-script
f79f46c703 Merge bitcoin-core/secp256k1#1641: doc: Improve cmake instructions in README
2ac9f558c4 doc: Improve cmake instructions in README (Fabian Jahr)

Pull request description:

  Minor improvement suggestion for the readme. I find this alternative way of using cmake a bit more comfortable because I don't like to change the directory.

  It's just a suggestion based on personal preference, if this is too minor of an improvement feel free to close.

ACKs for top commit:
  hebasto:
    ACK 2ac9f558c4.
  real-or-random:
    utACK 2ac9f558c4

Tree-SHA512: 5f7bc8b5ff91fb7a115a0e57224c66b018cfc824784e0def1064d07f9be66efe55e1a71e034f6a3d6489e063995c1ae17a9e91c990a0944d600cc957c038909d
2024-12-09 09:23:53 +01:00
Fabian Jahr
2ac9f558c4 doc: Improve cmake instructions in README 2024-12-06 19:45:22 +01:00
Sebastian Falbesoner
1823594761 Verify compressed argument in secp256k1_eckey_pubkey_serialize
Due to similarity to the public API function `secp256k1_ec_pubkey_serialize`,
public API flags like `SECP256K1_EC_COMPRESSED` are sometimes mistakingly
passed to newly proposed code (this is currently the case for several modules in
secp256k1-zkp, see https://github.com/BlockstreamResearch/secp256k1-zkp/pull/300).
which is currently not detected. To avoid this in the future, a VERIFY_CHECK
is added to check that the `compressed` argument is either 0 or 1.
2024-12-02 18:20:18 +01:00
merge-script
8deef00b33 Merge bitcoin-core/secp256k1#1634: Fix some misspellings
39705450eb Fix some misspellings (Nicolas Iooss)

Pull request description:

  Hello,

  Some files contained English misspellings or math issues (`lamba` instead of `lambda`), mainly in comments. Fixing them helps readability.

  By the way, the misspellings found in the Wycheproof test vector file were also reported upstream: https://github.com/C2SP/wycheproof/issues/124

ACKs for top commit:
  real-or-random:
    utACK 39705450eb

Tree-SHA512: 36327e8bb58ef3c0408cf4966bb33f51c84b1614809d8711d86eaf3d4e5336ae8c663593cb5f0e9c56adbb2d7f2ca62a9b84cae1b76b9811c110f87f1defa624
2024-11-05 19:36:44 +01:00
Nicolas Iooss
39705450eb Fix some misspellings
Some files contained English misspellings or math issues (`lamba`
instead of `lambda`).
2024-11-05 19:29:03 +01:00
Jonas Nick
ec329c2501 Merge bitcoin-core/secp256k1#1633: release cleanup: bump version after 0.6.0
c97059f594 release cleanup: bump version after 0.6.0 (Jonas Nick)

Pull request description:

ACKs for top commit:
  sipa:
    utACK c97059f594
  hebasto:
    ACK c97059f594.
  real-or-random:
    utACK c97059f594

Tree-SHA512: 2fccf8b4647f04397066410f7daf565a015aa7f1e20c9aa7151af3c47e7140dedf3032f5e79909b2705bb09f27af30d41485a7cbf0675725f7cf221c6c537d9b
2024-11-04 17:46:17 +00:00
Jonas Nick
c97059f594 release cleanup: bump version after 0.6.0 2024-11-04 17:17:39 +00:00
Jonas Nick
0cdc758a56 Merge bitcoin-core/secp256k1#1631: release: prepare for 0.6.0
39d5dfd542 release: prepare for 0.6.0 (Jonas Nick)
df2eceb279 build: add ellswift.md and musig.md to release tarball (Jonas Nick)
a306bb7e90 tools: fix check-abi.sh after cmake out locations were changed (Jonas Nick)
145868a84d Do not export `secp256k1_musig_nonce_gen_internal` (Hennadii Stepanov)

Pull request description:

ACKs for top commit:
  sipa:
    utACK 39d5dfd542
  real-or-random:
    ACK 39d5dfd542 mod the CI results

Tree-SHA512: 9b4623ca03aafcd1e04b0809382faeb3b427d3d07062f065177c7608e4feb30abd52cb10fa8c06b7ae17a82b32455e995b6bd39e3ef6239d5fc65c78873385b0
v0.6.0
2024-11-04 17:13:32 +00:00
Jonas Nick
39d5dfd542 release: prepare for 0.6.0 2024-11-04 16:11:46 +00:00
Jonas Nick
df2eceb279 build: add ellswift.md and musig.md to release tarball 2024-11-04 15:59:41 +00:00
Jonas Nick
a306bb7e90 tools: fix check-abi.sh after cmake out locations were changed 2024-11-04 15:59:41 +00:00
Hennadii Stepanov
145868a84d Do not export secp256k1_musig_nonce_gen_internal 2024-11-04 15:59:41 +00:00
merge-script
b161bffb8b Merge bitcoin-core/secp256k1#1579: Clear sensitive memory without getting optimized out (revival of #636)
765ef53335 Clear _gej instances after point multiplication to avoid potential leaks (Sebastian Falbesoner)
349e6ab916 Introduce separate _clear functions for hash module (Tim Ruffing)
99cc9fd6d0 Don't rely on memset to set signed integers to 0 (Tim Ruffing)
97c57f42ba Implement various _clear() functions with secp256k1_memclear() (Tim Ruffing)
9bb368d146 Use secp256k1_memclear() to clear stack memory instead of memset() (Tim Ruffing)
e3497bbf00 Separate between clearing memory and setting to zero in tests (Tim Ruffing)
d79a6ccd43 Separate secp256k1_fe_set_int( . , 0 ) from secp256k1_fe_clear() (Tim Ruffing)
1c08126222 Add secp256k1_memclear() for clearing secret data (Tim Ruffing)
e7d384488e Don't clear secrets in pippenger implementation (Tim Ruffing)

Pull request description:

  This PR picks up #636 (which in turn picked up #448, so this is take number three) and is essentially a rebase on master.

  Some changes to the original PR:
  * the clearing function now has the `secp256k1_` prefix again, since the related helper `_memczero` got it as well (see PR #835 / commit e89278f211)
  * the original commit b17a7df814 ("Make _set_fe_int( . , 0 ) set magnitude to 0") is not needed anymore, since it was already applied in PR #943 (commit d49011f54c)
  * clearing of stack memory with `secp256k1_memclear` is now also done on modules that have been newly introduced since then, i.e. schnorr and ellswift (of course, there is still no guarantee that all places where clearing is necessary are covered)

  So far I haven't looked at any disassembly and possible performance implications yet (there were some concerns expressed in https://github.com/bitcoin-core/secp256k1/pull/636#issuecomment-620118629), happy to go deeper there if this gets Concept ACKed.

  The proposed method of using a memory barrier to prevent optimizating away the memset is still used in BoringSSL (where it was originally picked up from) and in the Linux Kernel, see e.g. 5af122c3df/crypto/mem.c (L335) and d456068672/include/linux/string.h (L348) / d456068672/include/linux/compiler.h (L102)

  Fixes #185.

ACKs for top commit:
  sipa:
    reACK 765ef53335
  real-or-random:
    ACK 765ef53335

Tree-SHA512: 5a034d5ad14178c06928022459f3d4f0877d06f576b24ab07b86b3608b0b3e9273217b8309a1db606f024f3032731f13013114b1e0828964b578814d1efb2959
2024-11-04 16:34:52 +01:00
Tim Ruffing
64228a648f musig: Use _ge_set_all_gej for own public nonces 2024-11-01 23:33:53 +01:00
Tim Ruffing
300aab1c05 tests: Improve _ge_set_all_gej(_var) tests 2024-11-01 23:31:47 +01:00
Tim Ruffing
365f274ce3 group: Simplify secp256k1_ge_set_all_gej
No semantic changes.
2024-11-01 23:31:47 +01:00
Tim Ruffing
d3082ddead group: Add constant-time secp256k1_ge_set_all_gej
This is a dump mechanical translation of secp256k1_ge_set_all_gej_var
that assumes that inputs are not infinity.
2024-11-01 23:31:47 +01:00
merge-script
a38d879a1a Merge bitcoin-core/secp256k1#1628: Name public API structs
694342fdb7 Name public API structs (Ava Chow)

Pull request description:

  Closes #1627

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

Tree-SHA512: 4e03d97e7c072fc7ddefe3f679878aa8a806f3f557a736c9a1b9137972798c953cb21b91491d65f7ba5d75d7119e3224ce60309a0ff93fcf9a64b57b4a426655
2024-11-01 17:12:04 +01:00
merge-script
7d48f5ed02 Merge bitcoin-core/secp256k1#1581: test, ci: Lower default iteration count to 16
0f73caf7c6 test, ci: Lower default iteration count to 16 (Hennadii Stepanov)

Pull request description:

  The number of test iterations in the CI remains the same.

  Resolves https://github.com/bitcoin-core/secp256k1/issues/1561.

  ```
  $ ./build/src/tests
  test count = 16
  random seed = 59ea2b21267ec0ef0b4d13821292489f
  random run = 2936c044f82c7598a866869b9d954d42
  no problems found
  ```

ACKs for top commit:
  sipa:
    utACK 0f73caf7c6
  jonasnick:
    ACK 0f73caf7c6

Tree-SHA512: 84b265dc5d2780b3ea0a38f50ac8871d850ef2c97f33a0a5816baf20ac71c01db8b85696b343b089d7116d9cdb9450a6ca668229d95e54a39920d0e91a3127b3
2024-11-01 16:44:40 +01:00
Ava Chow
694342fdb7 Name public API structs 2024-10-31 13:55:52 -04:00
Hennadii Stepanov
0f73caf7c6 test, ci: Lower default iteration count to 16
The number of test iterations in the CI remains unchanged.

Additionally, the minimum iteration counts to enable the
`test_ecmult_constants_2bit` test is adjusted from 35 to 16, so it is
run by default.
2024-10-30 14:30:55 +00:00
merge-script
9a8db52f4e Merge bitcoin-core/secp256k1#1582: cmake, test: Add secp256k1_ prefix to test names
87384f5c0f cmake, test: Add `secp256k1_` prefix to test names (Hennadii Stepanov)

Pull request description:

  This PR improves regex matching options when using `ctest` in downstream projects, such as Bitcoin Core.

  For instance, a downstream project users can filter their tests like that:
  ```
  ctest --tests-regex "secp256k1"
  ```
  or
  ```
  ctest --exclude-regex "secp256k1"
  ```

  A `ctest` log with this PR:
  ```
  $ ctest --test-dir build -j 16
  Internal ctest changing into directory: /home/hebasto/git/secp256k1/secp256k1/build
  Test project /home/hebasto/git/secp256k1/secp256k1/build
      Start 1: secp256k1_noverify_tests
      Start 2: secp256k1_tests
      Start 3: secp256k1_exhaustive_tests
      Start 4: secp256k1_ecdsa_example
      Start 5: secp256k1_ecdh_example
      Start 6: secp256k1_schnorr_example
      Start 7: secp256k1_ellswift_example
      Start 8: secp256k1_musig_example
  1/8 Test #4: secp256k1_ecdsa_example ..........   Passed    0.00 sec
  2/8 Test #5: secp256k1_ecdh_example ...........   Passed    0.00 sec
  3/8 Test #6: secp256k1_schnorr_example ........   Passed    0.00 sec
  4/8 Test #7: secp256k1_ellswift_example .......   Passed    0.00 sec
  5/8 Test #8: secp256k1_musig_example ..........   Passed    0.00 sec
  6/8 Test #3: secp256k1_exhaustive_tests .......   Passed    6.19 sec
  7/8 Test #1: secp256k1_noverify_tests .........   Passed   38.83 sec
  8/8 Test #2: secp256k1_tests ..................   Passed   91.66 sec

  100% tests passed, 0 tests failed out of 8

  Total Test time (real) =  91.67 sec
  ```

ACKs for top commit:
  theuni:
    utACK 87384f5c0f
  real-or-random:
    utACK 87384f5c0f

Tree-SHA512: d8e46558cf58c9c660544b7bdfed24c991eb3e120b6511aa3968f509190130e498749a3c4dbabc87a7f22f0aa0056c6bcd3fc6c44f5eb131588945d593546840
2024-10-29 18:10:50 +01:00
Sebastian Falbesoner
765ef53335 Clear _gej instances after point multiplication to avoid potential leaks
Quoting sipa (see https://github.com/bitcoin-core/secp256k1/pull/1479#discussion_r1790079414):
"When performing an EC multiplication A = aG for secret a, the resulting
 _affine_ coordinates of A are presumed to not leak information about a (ECDLP),
  but the same is not necessarily true for the Jacobian coordinates that come
  out of our multiplication algorithm."

For the ECDH point multiplication result, the result in Jacobi coordinates should be
cleared not only to avoid leaking the scalar, but even more so as it's a representation
of the resulting shared secret.
2024-10-25 18:44:48 +02:00
Tim Ruffing
349e6ab916 Introduce separate _clear functions for hash module
This gives the caller more control about whether the state should
be cleaned (= should be considered secret). Moreover, it gives the
caller the possibility to clean a hash struct without finalizing it.
2024-10-25 18:44:48 +02:00
Tim Ruffing
99cc9fd6d0 Don't rely on memset to set signed integers to 0 2024-10-25 18:44:48 +02:00
Tim Ruffing
97c57f42ba Implement various _clear() functions with secp256k1_memclear() 2024-10-25 18:44:48 +02:00