[WIP] Fix assumption on int size in ecmult_wnaf function #1770

pull Copilot wants to merge 1 commits into bitcoin-core:master from bitcoin-core:copilot/fix-ecmult-wnaf-int-bits changing 0 files +0 −0
  1. Copilot commented at 10:23 am on November 7, 2025: none

    Thanks for assigning this issue to me. I’m starting to work on it and will keep this PR’s description up to date as I form a plan and make progress.


    This section details on the original issue you should resolve

    <issue_title>_ecmult_wnaf relies on int having at least 32 value bits</issue_title> <issue_description>The current secp256k1_ecmult_wnaf needs the unstated and unchecked assumption that int has at least 32 value bits when it VERIFY_CHECKs that w <= 31. In practice, we call it only with WINDOW_A == 5 and WINDOW_G == ECMULT_WINDOW_SIZE where the latter is configurable in the range 2..24.

    A consequence of this “bug” is that the code fails on a 16-bit platform if you set ECMULT_WINDOW_SIZE > 16. I don’t think we need to support this, but code without unchecked assumptions is bad. So I suggest that we rewrite the function to use int32_t instead of int even if we don’t use my macro approach. (We can keep the “bit position” arguments and variables int.)

    Alternatively, we could add the assumption that INT_MAX >= INT32_MAX but this forbids 16-bit platforms, and the code seems to work on them in principle; see #792 (comment).

    Originally posted by @real-or-random in #1761#pullrequestreview-3432695127 </issue_description>

    <agent_instructions>Use the suggestion to use int32_t instead of int. Keep the “bit positions” variables and arguments int.</agent_instructions>

    Comments on the Issue (you are @copilot in this section)

    • Fixes bitcoin-core/secp256k1#1769

    ✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

  2. Initial plan 4bfe72b826
  3. Copilot assigned Copilot on Nov 7, 2025
  4. Copilot assigned real-or-random on Nov 7, 2025
  5. real-or-random commented at 4:27 pm on November 10, 2025: contributor
    @copilot Are you still alive?
  6. real-or-random closed this on Nov 11, 2025

  7. real-or-random commented at 9:03 pm on November 11, 2025: contributor
    This was a GitHub Actions permissions issue: https://github.com/orgs/community/discussions/179396

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-11-27 05:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me