Move SHA256 self-test into hash module and remove selftest.h #1987

pull amartya1523 wants to merge 2 commits into bitcoin-core:master from amartya1523:selftest-into-hash changing 4 files +29 −45
  1. amartya1523 commented at 4:28 PM on November 3, 2026: none

    This addresses the "Reorganize self-test" item in #1835.

    The SHA256 check used by secp256k1_selftest and secp256k1_context_set_sha256_compression only exercises the hash module, so the first commit moves it next to secp256k1_sha256_smoke_test and renames it to secp256k1_sha256_selftest. No functional change.

    After that, selftest.h only held a one-line wrapper, so the second commit removes the file and has secp256k1_selftest call the hash self-test directly. A comment there explains why it always uses the built-in implementation: the API function is meant to catch a broken build of the library (e.g. wrong endianness), and a compression override is already checked when it is set on a context.

    I kept the move and the removal as separate commits so the first one is easy to review as a pure move.

  2. hash: Move SHA256 self-test into hash module
    secp256k1_selftest_sha256 only exercises the hash module and is also
    used to validate a caller-supplied compression function in
    secp256k1_context_set_sha256_compression. Move it next to
    secp256k1_sha256_smoke_test and rename it to secp256k1_sha256_selftest
    to match the naming of the module it lives in.
    
    No functional change.
    2728b61a66
  3. selftest: Remove module and test built-in SHA256 directly
    After moving the SHA256 check into the hash module, selftest.h only had
    a one-line wrapper left. Drop it and call secp256k1_sha256_selftest
    from secp256k1_selftest directly, with a comment explaining why it
    always uses the built-in implementation: the API function is meant to
    catch a broken build of the library (e.g., wrong endianness), and a
    compression override is already checked when it is set on a context.
    507d8b4b33
  4. amartya1523 closed this on Nov 3, 2026


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: 2026-11-12 08:15 UTC

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