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 · 5 suggestions
Earlier concerns neither republished nor resolved: 1 minor finding. See the Run archive for their assessments.
Findings
[critical] · A stale script-check error can mark the next valid block invalid
After an invalid block fails checks on two workers, one worker can carry its error into the next block, which may then be permanently marked invalid and split the node from the honest chain.
Location: src/checkqueue.h:209 (head).
Details and suggested fix
In the batched queue, a worker's local_result is cleared only when it is swapped into an empty m_result. Successful checks and successful batch->Verify() calls do not reset it, and worker threads remain in one Loop(false) for the queue's lifetime.
If two workers fail checks for the same block, the worker whose error is not published can retain it after Complete() returns. This can happen with two failing scripts, including ordinary ECDSA failures, or with invalid Schnorr signatures in two workers' batches. On the next ConnectBlock, that worker can publish the stale error after its first chunk or during batch verification, including for a coinbase-only block. The next block is rejected as BLOCK_CONSENSUS; ConnectTip then calls InvalidBlockFound and marks the valid block BLOCK_FAILED_VALID. The node remains off the honest chain until reconsiderblock is run.
A P2P trigger requires one PoW-valid invalid block. A trusted RPC client can create the same state through getblocktemplate proposal mode, which skips the PoW check. Reset local_result after publishing or discarding it, and add a CCheckQueue test that fails on multiple threads before completing a valid round.
[major] · A worker can be counted twice before all batches finish verification
A worker that wakes again after being counted can let Complete() return before another worker reports a failing Schnorr batch, potentially allowing an invalid block to be accepted.
Location: src/checkqueue.h:138 (head).
Details and suggested fix
After a thread increments m_total_verified, it clears do_verify_batch and waits on a condition variable without a predicate. Nothing records that it has already been counted for the round. If it wakes while m_complete && nTodo == 0 && m_total_verified != nTotal, it takes the !do_verify_batch branch, verifies its now-empty batch, and increments the counter again.
The wakeup can be spurious or can come from Complete(), which sets m_complete under the lock and notifies workers after releasing it. The double count can make the master see m_total_verified == nTotal and return m_result while another worker is still in batch->Verify(). If that batch contains an invalid Schnorr signature, ConnectBlock can accept the invalid block. The late worker can then publish its failure into the next round's m_result. It also retains do_verify_batch == true, so it can spin through empty batches in the next block until the queue drains.
This requires an invalid block and an uncommon interleaving; its frequency is not established. Use a per-round generation number so each thread counts once per round and waits for the generation to change.
[major] · A public batch seed can let cancelling invalid signatures pass verification
Because the first signature is omitted from the coefficient transcript, invalid signatures can be constructed to pass verification when randomness is public or the batch is reset; Core's current wrapper recreates batches with fresh randomness, so no current Core path is affected.
Location: src/secp256k1/src/modules/schnorrsig/batch_add_impl.h:133 (head).
Details and suggested fix
secp256k1_batch_add_schnorrsig assigns the first term coefficient 1 without adding it to batch->sha256. Later coefficients therefore depend only on the seed and later inputs.
With a public seed, two individually invalid signatures can cancel. Starting from valid signatures 1 and 2, set s2' = s2 + d, compute a2 from the modified second signature, and set s1' = s1 − a2·d. The R values, keys, messages, and challenges remain unchanged, and s1' + a2·s2' = s1 + a2·s2, so secp256k1_batch_verify returns 1.
The seed is public when aux_rand16 is NULL, which the header describes as supplemental to security, and after secp256k1_batch_reset, which restores the bare tag midstate and drops the creation randomness. The tweak-check add path also skips its first input. BatchSchnorrVerifier currently seeds each batch with GetRandBytes and implements Reset() by destroying and recreating the batch, so no current Core path is exploitable. Switching to secp256k1_batch_reset, which the header recommends for reuse, would make this reachable from blocks.
Hash every input, including the first, into the coefficient transcript, and ensure reset cannot leave a state derived only from public data. Add a regression test with cancelling signatures.
[minor] · A scratch-allocation failure can make batch verification accept an invalid tweak check
In builds with 64-byte alignment, a capacity-1 batch can run out of Strauss scratch space, and release builds ignore that failure, accepting invalid tweak checks; Core's capacity-106 Schnorr-only wrapper is unaffected.
Location: src/secp256k1/src/modules/batch/main_impl.h:191 (head).
Details and suggested fix
secp256k1_batch_create sizes scratch as strauss_scratch_size(max_terms) + STRAUSS_SCRATCH_OBJECTS*16, but secp256k1_scratch_alloc rounds each of the five allocations up to ALIGNMENT, which is 64 on x86-64 GCC with AVX-512 enabled.
For a capacity-1 batch with the non-VERIFY 5x52 layout, the scratch holds 1452 + 80 = 1532 bytes, while the rounded allocations need 64 + 128 + 320 + 704 + 320 = 1536. The Strauss state allocation fails. secp256k1_ecmult_strauss_batch_internal has already set the result to infinity, then returns 0. secp256k1_batch_verify checks that return only with VERIFY_CHECK, which compiles out in release builds, and therefore reports success.
A capacity-1 tweak-check batch can then accept any invalid tweak check whose inputs parse; the module's own tweak API test creates such a batch. Core uses capacity 106 with even-length Schnorr-only batches, whose alignment slack fits within 80 bytes, so Core is unaffected. Treat strauss_ret == 0 as verification failure and size the slack for the rounded allocations.
[minor] · The reject reason for a failed Schnorr batch varies with -par
Single-threaded validation reports a different reject reason than the queued path, so feature_taproot.py fails on one-CPU hosts even though the block is correctly rejected.
Location: src/validation.cpp:2713 (head).
Details and suggested fix
With script 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 (-par=1, or the default on a one-core host), the sequential path returns block-batch-verify-failed and skips the Block validation error log. Before this change, both paths reported block-script-verify-flag-failed (Invalid Schnorr signature) with the input details.
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 sequential validation and the test fails even though the block is correctly rejected. Report the same reason in both paths, for example with strprintf("block-script-verify-flag-failed (%s)", ScriptErrorString(SCRIPT_ERR_BATCH_VALIDATION_FAILED)), and set the state rather than returning early so normal logging runs.
[minor] · The batch tweak check accepts parity values outside 0 and 1
A value such as tweaked_pk_parity = 2 can pass batch verification although the individual tweak check rejects it, contrary to the 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, which negates y whenever fe_is_odd(y) != odd. For values other than 0 or 1, that comparison is always true, so the root from fe_sqrt is always negated. For about half of x coordinates, this still produces the correct Q.
The batch can therefore accept parity 2. secp256k1_xonly_pubkey_tweak_add_check rejects the same input because it compares == tweaked_pk_parity exactly. The header promises that a parity that does not match secp256k1_xonly_pubkey_from_pubkey makes batch verification fail.
Core does not use this API, and BIP341 parity from control[0] & 1 is always 0 or 1, so no current caller is affected. Set batch->result = 0 when parity is neither 0 nor 1, and add out-of-range parity cases to the batch API tests.
[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) only defines a static wrapper; it does not register the test. tests_batch_add_schnorrsig lists only the randomizer and API tests, and nothing else calls the wrapper.
As a result, the randomized sign-and-batch-verify checks do not run. They cover bit flips in signatures and messages, overflowing and negated s, the empty message, and varying message lengths. A comment in schnorrsig/tests_impl.h names this as the batch counterpart of test_schnorrsig_sign_verify. Add CASE1(test_schnorrsig_sign_batch_verify) to the registry.
Optional improvements
[suggestion] · The batched check-queue protocol has no isolated test coverage
Existing check-queue tests use non-batched check types, leaving the completion barrier and cross-round result handoff untested in isolation.
Location: src/checkqueue.h:45 (head).
Details and suggested fix
Every CCheckQueue test, fuzz target, and benchmark (checkqueue_tests.cpp, fuzz/checkqueue.cpp, bench/checkqueue.cpp, and transaction_tests.cpp) instantiates a non-batched check type. None exercises the batched completion phase, per-thread Verify and Reset, the m_total_verified barrier, or result handoff between rounds in isolation.
The stale-result and double-count defects in this review are in that code. It is currently exercised only end-to-end through functional tests with one or two script threads. Add a batched fake check that returns valid or invalid SchnorrSignatureToVerify vectors. Run many rounds across many threads, including extra wakeups, and assert each round's result and that no failure leaks into the next round.
[suggestion] · Workers continue script checks after batch->Add fails
When a key fails to parse, the worker continues the rest of its chunk, unlike other failure paths in the queue; the extra work is bounded and occurs only for invalid blocks.
Location: src/checkqueue.h:217 (head).
Details and suggested fix
When batch->Add rejects an unparsable x-only key, the break leaves only the loop over that check's signatures. The outer for (T& check : vChecks) loop continues running the remaining script checks in the chunk, even though local_result already holds a failure.
The base loop and the script-failure branch above stop at the first failure. The extra work is bounded by the chunk size, at most 128 checks for the script queue, and happens only for invalid blocks. Check local_result after the signature loop and break from the outer loop as well.
[suggestion] · The BIP340-vector batch test does not mix invalid signatures with valid ones
Because Verify() clears the batch, each invalid vector is checked alone with coefficient 1, so the test never covers mixed batches.
Location: src/test/key_tests.cpp:453 (head).
Details and suggested fix
secp256k1_batch_verify clears the batch's terms after it runs. The valid-vector loop calls batch.Verify() after every Add. The invalid-vector loop calls batch.Verify() on the random valid subset before adding the invalid signature, so the invalid vector is always the only term, with coefficient 1.
This test never verifies a batch with more than one signature or mixes an invalid BIP340 edge-case vector with valid ones. The batchverify fuzz target mixes only bit-flipped signatures. Remove the intermediate Verify() so each invalid vector is checked with the random valid subset, and verify once after adding the valid vectors.
[suggestion] · The refactored ecmult tests no longer pass a NULL generator scalar
The helper discards its randomly chosen generator pointer, so the randomized tests lose coverage of NULL-generator branches.
Location: src/secp256k1/src/tests.c:5328 (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 that choice in g_scalar_ptr, but assigns it only to its own by-value g_scalar parameter. Both callers retain g_scalar_ptr = &g_scalar, so they always pass a non-NULL generator scalar.
The randomized tests no longer cover the NULL-generator branches of the multi-scalar multiplication functions, 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.
[suggestion] · Autotools skips the batch example when MuSig is disabled
The batch example is nested inside the MuSig conditional, so autotools builds without MuSig omit it even when batch and Schnorr are enabled, unlike CMake.
Location: src/secp256k1/Makefile.am:212 (head).
Details and suggested fix
The new Automake block for batch_example is inside if ENABLE_MODULE_MUSIG, although the example uses only the batch, Schnorr, and extrakeys APIs. An autotools build with examples, batch, and Schnorr enabled but MuSig disabled silently skips building and running batch_example. CMake gates the same example on SECP256K1_ENABLE_MODULE_BATCH AND SECP256K1_ENABLE_MODULE_SCHNORRSIG.
Bitcoin Core builds the subtree with CMake, so this affects only standalone autotools builds of the library. Move the block out of the MuSig conditional and gate it on batch and Schnorr, matching CMake.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [minor]: The batch example reports success after randomness generation fails (earlier report)