Description
src/ctime_tests.c covers secp256k1_schnorrsig_sign32 and secp256k1_schnorrsig_sign_custom entry points under Valgrind/CHECKMEM.
sign_custom accepts optional extraparams (including a custom nonce function) and variable-length messages before calling the shared internal signer. Functional tests cover it, but previously it was not tested under the constant-time CHECKMEM harness.
This PR adds coverage for:
secp256k1_schnorrsig_sign_custom(..., NULL)(default nonce path, NULL extraparams).- Default BIP340 nonce with non-NULL
extraparams.ndata(auxiliary randomness). - The actual custom callback dispatch path via a distinct custom callback function (
nonce_function_custom) delegating tosecp256k1_nonce_function_bip340. - Variable-length message handling (
sizeof(msg) - 1) in the custom callback case. - Secret-tainted key, keypair, message, and auxiliary data under CHECKMEM.
Coverage gap (why)
Planted local-only synthetic mutations (e.g. secret-dependent branch in custom nonce callback, secret-dependent branch on non-NULL auxiliary data) were not detected by the existing ctime suite, but were detected after these test additions. A constant-work control mutation remained clean.
This is a test-coverage improvement. No production cryptographic code is modified. This PR does not claim a real production vulnerability in unmodified libsecp256k1.
Change
src/ctime_tests.conly- No mutation code
- No new dependencies
Build / test
cmake -B build \
-DSECP256K1_VALGRIND=ON \
-DSECP256K1_BUILD_CTIME_TESTS=ON \
-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON \
-DSECP256K1_ENABLE_MODULE_EXTRAKEYS=ON \
-DSECP256K1_ENABLE_MODULE_ECDH=ON \
-DSECP256K1_ENABLE_MODULE_RECOVERY=ON \
-DSECP256K1_ENABLE_MODULE_ELLSWIFT=ON \
-DSECP256K1_ENABLE_MODULE_MUSIG=ON
cmake --build build --target ctime_tests
valgrind --error-exitcode=42 ./build/bin/ctime_tests
Clean upstream + this test: pass (repeated).
Synthetic mutations were local-only and are not included in this branch.