bench: improve context creation in ECDH benchmark #1748

pull theStack wants to merge 1 commits into bitcoin-core:master from theStack:context_static-for-ecdh-benchmark changing 1 files +2 −5
  1. theStack commented at 9:34 pm on September 16, 2025: contributor

    Calling secp256k1_context_create with SECP256K1_FLAGS_TYPE_CONTEXT seems to be confusing and not strictly API-compliant, as the only allowed (non-deprecated) value is SECP256K1_CONTEXT_NONE, even if the former happens to map to the latter currently.

    Fix this by not dynamically creating a context in the first place and switch to using the static context, as it is sufficient for this benchmark and presumably matches what the “no capabilities” comment intended back then.

    Alternatives are:

    • keep the signing context and only fix the name, i.e. s/_FLAGS_TYPE_CONTEXT/_CONTEXT_NONE/
    • use secp256k1_context_static everywhere directly and get rid of the ctx field in the bench_ecdh_data struct (less flexible for future changes, deviates from other bench structures)

    Found while reviewing #1698, see #1698 (review).

  2. bench: improve context creation in ECDH benchmark
    Calling `secp256k1_context_create` with `SECP256K1_FLAGS_TYPE_CONTEXT`
    seems to be not strictly API-compliant, as the only allowed
    (non-deprecated) value is `SECP256K1_CONTEXT_NONE`, even if the
    former happens to map to the latter currently.
    
    Fix this by not dynamically creating a context in the first place and
    switch to using the static context, as it is sufficient for this
    benchmark and presumably matches what the "no capabilities" comment
    intended back then.
    dfe284ed2d
  3. stratospher commented at 3:45 pm on September 18, 2025: contributor
    ACK dfe284e. not sure whether the alternative is preferred though.
  4. real-or-random approved
  5. real-or-random commented at 4:02 pm on September 19, 2025: contributor
    utACK dfe284ed2d24ab44705ca5ecd8f3f7e1b8e4c278
  6. real-or-random added the label tweak/refactor on Sep 19, 2025
  7. sipa commented at 9:27 pm on September 19, 2025: contributor
    utACK dfe284ed2d24ab44705ca5ecd8f3f7e1b8e4c278
  8. furszy commented at 9:47 pm on September 21, 2025: member

    ACK dfe284ed2d24ab44705ca5ecd8f3f7e1b8e4c278

    If it wouldn’t be for the initial VERIFY_CHECK, the context could be null as it is not used internally.

  9. real-or-random merged this on Sep 22, 2025
  10. real-or-random closed this on Sep 22, 2025

  11. theStack deleted the branch on Sep 22, 2025

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-10-13 19:15 UTC

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