Provider refusals
write_verifier: Provider declined the request because of a cybersecurity restriction. Experiments remain incomplete; static verification can continue.
1 critical finding · 2 major findings · 4 minor findings · 3 suggestions
Findings
[critical] · A stale script-check failure can make the next valid block permanently invalid
After an invalid block, a worker can retain a script-check failure and report it for the next block, causing the node to mark that valid block permanently invalid.
Location: src/checkqueue.h:209 (head).
Details and suggested fix
In the batched queue, a worker clears local_result only when it swaps the value into an empty m_result. Successful checks and successful batch->Verify() calls do not reset it. If a failure arrives after another worker has already published a result, the first worker keeps its failure after Complete() returns. Worker threads reuse the same loop across queue rounds.
A block with invalid Schnorr signatures spread across chunks can cause multiple workers to fail during batch verification. On the next ConnectBlock, a worker can publish its stale failure while processing the first chunk or during batch verification; the latter also runs for a coinbase-only block. The next block is then rejected as BLOCK_CONSENSUS, and ConnectTip marks it BLOCK_FAILED_VALID. The node remains off the honest chain until an operator runs reconsiderblock.
A P2P trigger requires one proof-of-work-valid block with invalid Schnorr signatures. A trusted RPC client can also trigger the state through getblocktemplate proposal mode, which calls TestBlockValidity without checking proof of work.
Reset local_result after it has been published or discarded, for example immediately after the cleanup swap. Add a CCheckQueue test that uses a batched check type to fail on several threads, then completes a valid round.
[major] · A worker can be counted twice before every batch is verified
A worker woken again after being counted can increment the verification count twice, allowing Complete() to return before another worker reports a failing Schnorr batch.
Location: src/checkqueue.h:138 (head).
Details and suggested fix
After incrementing m_total_verified, a worker clears do_verify_batch and waits without a predicate. The queue does not record that the worker has already been counted for the round.
If the worker wakes while m_complete && nTodo == 0 && m_total_verified != nTotal, it can take the !do_verify_batch branch, verify its now-empty batch, and increment the counter again. The wakeup can be spurious, or it can follow Complete() setting m_complete and notifying workers. A double count can let the master return m_result while another worker is still in batch->Verify(). If that worker's batch contains an invalid Schnorr signature, ConnectBlock can accept the invalid block. The late failure can then be carried into the next round.
This requires both a block with invalid signatures and an uncommon timing interleaving; how often it occurs is not established. Give each round a generation number so each thread counts exactly once per generation and waits until the generation changes.
[major] · A public batch seed can let invalid Schnorr signatures cancel
Because the first signature is omitted from the coefficient transcript, a public seed, including one restored by secp256k1_batch_reset, can let crafted invalid signatures pass batch verification; Core's current path avoids these cases.
Location: src/secp256k1/src/modules/schnorrsig/batch_add_impl.h:133 (head).
Details and suggested fix
secp256k1_batch_add_schnorrsig assigns the first term a coefficient of 1 and does not add that signature to batch->sha256. Later coefficients therefore depend only on the seed and later inputs.
With a public seed, two individually invalid signatures can be made to cancel. Starting with valid signatures 1 and 2, set s2' = s2 + d, compute a2 for the modified second signature, then set s1' = s1 − a2·d. The points, keys, messages, and challenges remain unchanged, and s1' + a2·s2' still equals s1 + a2·s2. Thus secp256k1_batch_verify returns 1 even though neither signature is valid.
The seed is public when aux_rand16 is NULL, which the header permits, or after secp256k1_batch_reset, which restores the bare tag midstate and discards the creation randomness. The tweak-check add function skips its first input in the same way.
Core's BatchSchnorrVerifier currently avoids both cases: it seeds each batch with GetRandBytes, and its Reset() destroys and recreates the batch. This is not a direct bypass of Core block validation today, but it is a soundness failure in the vendored public API; using secp256k1_batch_reset, which the header recommends for reuse, would make it reachable from blocks.
Hash every input, including the first, into the coefficient transcript, as BIP340's batch construction does. Ensure reset cannot return to a state derived only from public data, and add a regression test with cancelling signatures.
[minor] · Schnorr batch failures have different reject reasons depending on -par
Single-threaded validation reports a different reject reason, causing feature_taproot.py to fail on one-CPU hosts even though the block is rejected.
Location: src/validation.cpp:2654 (head).
Details and suggested fix
With worker threads, a block that fails Schnorr batch verification is rejected with block-script-verify-flag-failed (Schnorr batch validation failed). With no worker threads, such as -par=1 or the default on a single-core host, the sequential path returns block-batch-verify-failed and skips the Block validation error log.
feature_taproot.py expects ERR_SCHNORR_SIG_BATCH in the submitblock response. The test framework sets par=min(2, os.cpu_count()), so a one-CPU runner uses -par=1 and the test fails despite the block being correctly rejected.
Use the same reject reason in both paths, and set the validation state instead of returning early so normal logging runs.
[minor] · The randomized sign-and-batch-verify test is not registered
test_schnorrsig_sign_batch_verify is defined but never added to the test registry, so its checks do not run.
Location: src/secp256k1/src/modules/schnorrsig/batch_add_tests_impl.h:240 (head).
Details and suggested fix
REPEAT_TEST(test_schnorrsig_sign_batch_verify) defines a static wrapper but does not register it. tests_batch_add_schnorrsig lists only the randomizer and API tests, and nothing else calls the wrapper.
As a result, the randomized checks for bit flips in signatures and messages, overflowing and negated s, empty messages, and varying message lengths do not run. A comment in schnorrsig/tests_impl.h identifies this as the batch counterpart of test_schnorrsig_sign_verify.
Add CASE1(test_schnorrsig_sign_batch_verify) to the registry.
[minor] · Batch tweak checks can accept a parity value outside 0 or 1
A non-bit tweaked_pk_parity can pass batch verification even though the individual tweak check rejects it, contrary to the documented API contract.
Location: src/secp256k1/src/modules/extrakeys/batch_add_impl.h:115 (head).
Details and suggested fix
secp256k1_batch_add_xonlypub_tweak_check passes tweaked_pk_parity directly to secp256k1_ge_set_xo_var. That helper compares fe_is_odd(y) != odd and negates y when they differ. For any value other than 0 or 1, the comparison is always true, so the root returned by fe_sqrt is always negated. For roughly half of x coordinates, this still produces the correct Q.
The batch can therefore accept, for example, parity 2, which secp256k1_xonly_pubkey_tweak_add_check rejects with its exact == tweaked_pk_parity comparison. This contradicts the header's promise that a parity mismatch makes batch verification fail.
Core does not currently use this API, and BIP341 parity derived from control[0] & 1 is always 0 or 1, so no current caller is affected. Set batch->result = 0 whenever the parity is not 0 or 1.
[minor] · The batch example reports success after randomness generation fails
Three helpers return 1 when fill_random fails, so main prints “ok” and continues with incomplete data.
Location: src/secp256k1/examples/batch.c:37 (head).
Details and suggested fix
create_keypair, generate_schnorrsigs, and generate_xonlypub_tweak_checks return 1 when fill_random fails, but main treats a nonzero return as success. After printing “Failed to generate randomness,” the example prints “ok” and continues with incomplete key, message, or tweak data instead of exiting with an error.
Return 0 from those failure branches.
Optional improvements
[suggestion] · The unit test never verifies an invalid signature in a multi-signature batch
Each invalid vector is checked alone because Verify() clears the batch, so this test does not exercise coefficient generation or mixing valid and invalid signatures.
Location: src/test/key_tests.cpp:449 (head).
Details and suggested fix
secp256k1_batch_verify clears the batch's terms after it runs. In the invalid-vector loop, the test calls batch.Verify() on the random valid subset before adding the invalid signature. The invalid signature is therefore always the only term, with coefficient 1. The valid-signature loop also verifies after every Add.
This unit test never verifies a batch containing more than one signature, so it does not exercise coefficient generation or a mix of valid and invalid signatures. Remove the intermediate Verify() so the invalid vector is checked with the random valid subset.
[suggestion] · Batch verification can fail open if Strauss scratch allocation fails
If allocation fails, the result remains infinity and release builds ignore the failure return, so verification accepts the batch; current batch sizing should prevent this path.
Location: src/secp256k1/src/modules/batch/main_impl.h:191 (head).
Details and suggested fix
secp256k1_ecmult_strauss_batch_internal sets r to infinity before allocating scratch state. If allocation fails, it returns 0 with r still at infinity. secp256k1_batch_verify checks strauss_ret only with VERIFY_CHECK, which compiles out in release builds, then treats infinity as success.
The allocation should succeed today because secp256k1_batch_create sizes scratch for capacity terms. However, that sizing reserves only 16 bytes of padding per object, while the existing ecmult tests size Strauss scratch with STRAUSS_SCRATCH_OBJECTS*ALIGNMENT. If the sizing assumption stops holding, verification would accept the batch instead of rejecting it.
Include strauss_ret in the result, for example with batch->result = batch->result && strauss_ret && mid_res;.
[suggestion] · The refactored ecmult tests no longer pass a NULL generator scalar
The helper's chosen pointer is discarded, so the randomized tests lose coverage of NULL-generator branches.
Location: src/secp256k1/src/tests.c:5251 (head).
Details and suggested fix
Before the refactor, test_ecmult_multi_random passed either &g_scalar or NULL to ecmult_multi, depending on g_nonzero || testrand_bits(1). The extracted helper still makes this choice in g_scalar_ptr, but assigns it only to its own by-value parameter with g_scalar = g_scalar_ptr;. Both callers keep g_scalar_ptr = &g_scalar, so they always pass a non-NULL generator scalar.
The multi-scalar multiplication functions' NULL-generator branches lose randomized coverage, and the new Strauss-internal test never covers them. Return the chosen pointer through a secp256k1_scalar ** out-parameter, or return an omit-G flag.