Skip to content

Fix cleartext confusion score#273

Draft
bigspider wants to merge 9 commits into
masterfrom
fix-cleartext-confusion-score
Draft

Fix cleartext confusion score#273
bigspider wants to merge 9 commits into
masterfrom
fix-cleartext-confusion-score

Conversation

@bigspider

Copy link
Copy Markdown
Contributor

No description provided.

bigspider added 9 commits June 9, 2026 19:16
key_derivation_orderings_count grouped occurrences by whole key expression, so
a musig(@i,@j,...) counted as one unit. That undercounts the derivation-ordering
ambiguity: the same cleartext also decodes to multi_a(...), where each musig
member is an individual plain key that can repeat across leaves (and the key
path) and be permuted. Count by individual key index instead, expanding every
musig group into its members.

We use a deliberate over-to keep things simple, and raise MAX_CONFUSION_SCORE
from the 3600 to 100000.
- Add a musig-key-path vector with three shared 2-of-2 fallback leaves: the
  case that motivated the formula change. Its score (5184) over-counts the 54
  actual decodings, so the round-trip test now asserts the decoder yields at
  most confusion_score variants rather than exactly that many; the test-vector
  schema docs are updated to call the score an upper bound.
- Pin confusion_score on the ~29 vectors that previously omitted it, widening
  coverage of the confusion-score function.
This is needed because of composability (some patterns might appear
inside other patterns). Instead, we capitalize the first character
of each cleartext entry if it's a lowercase letter, which looks
better in the UI of a hardware signer.

Modified decoding code (and the unambiguity guards) to always work
with lowercase text (this is a good tighter rule anyway).
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.

1 participant