tests: Check that every hashed value uses the ctx-provided SHA256 #1982

pull mllwchrry wants to merge 1 commits into bitcoin-core:master from mllwchrry:generalize-transform-probe changing 4 files +107 −16
  1. mllwchrry commented at 10:43 AM on October 26, 2026: contributor

    The ctx-provided SHA256 compression tests check that the probe was called and the output differs. For functions that hash several values, this passes as soon as any one of them goes through the caller's ctx, so it can't detect another value silently using the default compression.

    This PR lets DEFINE_SHA256_TRANSFORM_PROBE perturb a single chosen block (_target) and count blocks (_blocks). A target of 0 keeps the previous behavior, so existing tests are unchanged. For multi-hash functions, the tests now perturb only the last block and pin the number of blocks: if any value bypassed the ctx, fewer blocks would be hashed and the output would not change.

    Also, optional inputs (aux_rand32, the musig nonce inputs) are now passed so that all hashing paths run.

    The idea comes from @apoelstra in https://github.com/BlockstreamResearch/secp256k1-zkp/pull/374#issuecomment-5777732309.

    silentpayments is not covered here: its ctx test is being added in #1940, which is still open. sender_create_outputs (input hash and output tweak) is a good candidate for a follow-up once it's merged.

  2. tests: Check that every hashed value uses the ctx-provided SHA256
    A plain "output differs" check passes as soon as any one of several
    hashed values goes through the caller's ctx. Let the transform probe
    perturb a single chosen block (target 0 keeps the old behavior) and,
    for functions that hash several values, perturb only the last block
    while pinning the number of blocks: if any value bypassed the ctx,
    fewer blocks would be hashed and the output would not change.
    b9aebbc568
  3. theStack added the label assurance on Oct 28, 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 07:15 UTC

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