Skip to content

Sort silent payment codes sharing a scan key before assigning k - #50

Closed
macgyver13 wants to merge 1 commit into
sparrowwallet:masterfrom
macgyver13:bip375-sort-same-scan-key
Closed

macgyver13 wants to merge 1 commit into
sparrowwallet:masterfrom
macgyver13:bip375-sort-same-scan-key

Conversation

@macgyver13

Copy link
Copy Markdown

When a transaction has two or more silent payment outputs sharing a scan key, Sparrow and SeedSigner assigned k in different orders and derived different output addresses.

@notTanveer discovered this issue when testing Sparrow and SeedSigner - Thank you for sharing!

BIP375 Text:

If there are multiple silent payment codes with the same scan key, sort the codes lexicographically in ascending order to determine the ordering of the k value. If there are multiple silent payment codes with both the same scan and spend keys, sort the subgroup by output index in ascending order.

Test testBip375ThreeOutputsSameScanKey clones "can finalize: three sp outputs (same scan key) - output 0 uses label=1, outputs 1 and 2 uses label=2 (same spend key)" from BIP375 v1.1.1 test vectors proposed in BIPs PR 2207. Note that v1.1.1 is still proposed, waiting for BIP authors to confirm spec interpretation is accurate.

Happy to address any requested changes or close this PR in favor of your solution.

@craigraw

Copy link
Copy Markdown
Collaborator

Thanks for this - I've made the change separately in 59f43e3, using serialize() which avoids touching SilentPaymentAddress. The test is the same though.

@craigraw craigraw closed this Aug 28, 2026
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.

2 participants