Description
src/ctime_tests.c covers secp256k1_schnorrsig_sign32 and secp256k1_schnorrsig_sign_custom entry points under Valgrind/CHECKMEM.
secp256k1_schnorrsig_sign_custom accepts optional extraparams, including a custom nonce function, before calling the shared internal signer. Functional tests cover this API, but previously it was not exercised under the constant-time CHECKMEM harness.
This PR adds coverage for:
secp256k1_schnorrsig_sign_custom(..., NULL)using the default nonce path with NULL extraparams.- The default BIP340 nonce function with non-NULL
extraparams.ndata. - The custom nonce callback dispatch path via a distinct
nonce_function_customcallback that delegates tosecp256k1_nonce_function_bip340. - Secret key material and keypair state under CHECKMEM for these signing paths.
Message and auxiliary data are not treated as secret inputs in these tests.
Coverage gap
The existing constant-time test suite exercised secp256k1_schnorrsig_sign32, but did not exercise the public secp256k1_schnorrsig_sign_custom entry point and its custom nonce callback dispatch path under CHECKMEM.
Local synthetic mutations were used during development to verify that the added coverage reaches these paths. These mutations are not included in this branch.
This is a test-coverage improvement. No production cryptographic code is modified, and this PR does not claim a production vulnerability in unmodified libsecp256k1.
Change
src/ctime_tests.conly- No production code changes
- 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
cmake --build build --parallel
ctest --test-dir build --output-on-failure
valgrind --error-exitcode=42 ./build/bin/ctime_tests
Local validation after addressing review feedback:
- 207/207 CTest tests passed.
ctime_testspassed under Valgrind.- Valgrind reported
ERROR SUMMARY: 0 errors. - Valgrind process exited with code 0.