Skip to content

tests: silentpayments: cover rejection of invalid keypair alongside a valid one - #1937

Open
Yudis-bit wants to merge 1 commit into
bitcoin-core:masterfrom
Yudis-bit:test-silentpayments-invalid-keypair-alongside-valid
Open

Yudis-bit wants to merge 1 commit into
bitcoin-core:masterfrom
Yudis-bit:test-silentpayments-invalid-keypair-alongside-valid

Conversation

@Yudis-bit

@Yudis-bit Yudis-bit commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Add coverage for an invalid Taproot keypair passed alongside a valid one, following the plain secret key tests in #1931.

Both orderings are tested. The invalid-first case catches a missing early return in the keypair loop: the valid keypair leaves a nonzero sum, so the subsequent zero-sum check would not catch the failure.

@real-or-random

Copy link
Copy Markdown
Contributor

cc @brunoerg

@brunoerg

Copy link
Copy Markdown
Contributor

Concept ACK

I'm adding more mutation operators to my tool and nested early-return deletion is one of them, the following mutant isn't killed on master but killed with the test case added here (nice!):

diff --git a/src/modules/silentpayments/main_impl.h b/src/modules/silentpayments/main_impl.h
index e42dc1a..8d7be21 100644
--- a/src/modules/silentpayments/main_impl.h
+++ b/src/modules/silentpayments/main_impl.h
@@ -249,7 +249,6 @@ int secp256k1_silentpayments_sender_create_outputs(
         if (!ret) {
             secp256k1_scalar_clear(&addend);
             secp256k1_scalar_clear(&seckey_sum_scalar);
-            return 0;
         }
         if (secp256k1_fe_is_odd(&addend_point.y)) {
             secp256k1_scalar_negate(&addend, &addend);

Comment thread src/modules/silentpayments/tests_impl.h
Comment thread src/modules/silentpayments/tests_impl.h Outdated
Copilot AI lite review requested due to automatic review settings September 15, 2026 08:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No blocking issues were identified.

Pull request overview

Adds silent-payments sender test coverage for rejecting invalid Taproot keypairs mixed with valid keypairs.

Changes:

  • Tests both valid/invalid keypair orderings.
  • Verifies invalid keypairs trigger rejection.
File summaries
File Description
src/modules/silentpayments/tests_impl.h Adds mixed-validity Taproot keypair rejection tests.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@theStack

Copy link
Copy Markdown
Contributor

Concept ACK

@Yudis-bit: Could you squash the commits, please?

@Yudis-bit
Yudis-bit force-pushed the test-silentpayments-invalid-keypair-alongside-valid branch from ca6b4a2 to e5b4d58 Compare September 16, 2026 03:24
@Yudis-bit

Copy link
Copy Markdown
Contributor Author

Squashed into e5b4d58. No changes to the final diff.

@Yudis-bit

Copy link
Copy Markdown
Contributor Author

Rechecked e5b4d58: all 225 local tests pass. Removing the early return in the keypair loop passes the parent tests but fails the new invalid-first assertion. Ready for another look.

Comment thread src/modules/silentpayments/tests_impl.h Outdated
@Yudis-bit
Yudis-bit force-pushed the test-silentpayments-invalid-keypair-alongside-valid branch from e5b4d58 to d6ec1ab Compare October 2, 2026 00:15

@fametrano fametrano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK d6ec1ab

Confirmed by mutation: with the keypair loop's return 0; removed, the master tests and the (valid, invalid) ordering still pass, and the (invalid, valid) ordering fails. This matches the new comment.

@real-or-random

Copy link
Copy Markdown
Contributor

@brunoerg want to re-review this? :)

@brunoerg brunoerg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK d6ec1ab

but the PR description is not accurate, should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants