Skip to content

fix(receive): Enforce BIP-352 K_MAX per-group recipient limit in scan_txouts - #75

Merged
nymius merged 1 commit into
bitcoindevkit:masterfrom
MusabYK:add-k_max-cap
Sep 3, 2026
Merged

fix(receive): Enforce BIP-352 K_MAX per-group recipient limit in scan_txouts#75
nymius merged 1 commit into
bitcoindevkit:masterfrom
MusabYK:add-k_max-cap

Conversation

@MusabYK

@MusabYK MusabYK commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #67 by adding const K_MAX: u32 = 2323 to silentpayments::receive, and a threshold check to the matched_tweaks counter loop in scan_txouts. Also added a ScanLimitExceeded(u32) variant to SpReceiveError returning an explicit error

Notes to the reviewers

I replaced check_cases(27) with a dedicated
maximum_per_group_recipient_limit_k_max_is_exceeded() test function that explicitly matches and asserts SpReceiveError::ScanLimitExceeded(K_MAX) on test vector 27, preserving check_cases for standard test vectors. i think modifying it with hardcoded branch conditions for test 27 makes the general test runner dirty.

All Submissions:

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

Comment thread silentpayments/tests/functional_tests/bip352_vectors/receive.rs Outdated
@MusabYK
MusabYK force-pushed the add-k_max-cap branch 2 times, most recently from e319f66 to 345a109 Compare September 2, 2026 19:13

@nymius nymius left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you squash both commits together? Also, in general, I prefer commit messages that explain the what and why of the code, rather than short descriptions.

@MusabYK

MusabYK commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Hi @nymius I squashed both commits together and updated the commit message to include the full context. Thanks for the feedback

@nymius nymius left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One last request, can you wrap the commit message to less than 72 characters?

@MusabYK

MusabYK commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

One last request, can you wrap the commit message to less than 72 characters?

Done!

@nymius nymius left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ACK 1598b06

@nymius
nymius merged commit d257a22 into bitcoindevkit:master Sep 3, 2026
@nymius

nymius commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

If you want to work in a follow up: I prefer these slow tests to only execute on CI, and ignore them in just pre-push.

@MusabYK

MusabYK commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Makes sense. I'll look into it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Add a K_max cap to scan_txouts to mitigate unbounded per-transaction scan cost

2 participants