tests: cover rejection of invalid plain seckey alongside a valid one #1931

pull brunoerg wants to merge 1 commits into bitcoin-core:master from brunoerg:silentpayments-mixed-seckey-test changing 1 files +17 −0
  1. brunoerg commented at 1:54 PM on September 7, 2026: contributor

    The existing silentpayment sender tests only pass a single invalid plain seckey, which parses to a zero scalar and is therefore also rejected by the later zero-sum check. Add a test with a valid key followed by an invalid one so that the early return in the seckey loop itself is exercised.

    It kills the following mutant, the only one remaining within 229 ones :) - https://secp256k1.space/src/modules/silentpayments/main_impl.h

    diff --git a/src/modules/silentpayments/main_impl.h b/src/modules/silentpayments/main_impl.h
    index 415f2d2..489ec91 100644
    --- a/src/modules/silentpayments/main_impl.h
    +++ b/src/modules/silentpayments/main_impl.h
    @@ -237,7 +237,7 @@ int secp256k1_silentpayments_sender_create_outputs(
         for (i = 0; i < n_seckeys; i++) {
             ret = secp256k1_scalar_set_b32_seckey(&addend, seckeys[i]);
             secp256k1_declassify(ctx, &ret, sizeof(ret));
    -        if (!ret) {
    +        if (1==0) {
                 secp256k1_scalar_clear(&addend);
                 secp256k1_scalar_clear(&seckey_sum_scalar);
                 return 0;
    
  2. real-or-random added the label assurance on Sep 7, 2026
  3. real-or-random added the label tweak/refactor on Sep 7, 2026
  4. real-or-random approved
  5. real-or-random commented at 8:05 PM on September 7, 2026: contributor

    utACK ec43762c2a99a874154df45112af7d66ce430cd4

    If you want to improve this further, you could also swap the order of the two keys.

  6. theStack commented at 3:58 PM on September 8, 2026: contributor

    ACK modulo commit subject typo (s/silentpaymets/silentpayments/)

  7. brunoerg commented at 5:28 PM on September 8, 2026: contributor

    I'm going to fix the typo and also add a test case that swap the order of the two keys.

  8. tests: silentpayments: cover rejection of invalid plain seckey alongside a valid one
    The existing sender tests only pass a single invalid plain seckey, which
    parses to a zero scalar and is therefore also rejected by the later
    zero-sum check. Add tests with a valid key and an invalid one so that
    the early return in the seckey loop itself is exercised. The invalid key
    is placed at both the first and the last index, so that skipping the
    check for either position would be caught.
    05f9289984
  9. brunoerg force-pushed on Sep 8, 2026
  10. brunoerg commented at 5:39 PM on September 8, 2026: contributor

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-09-09 02:15 UTC

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