← Back to Pull requests

Judge a key BIP341's H by the bytes it holds (closes #464) #483

Closed
unknown closed this pull request without merging on Nov 27, 2026 13:40 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 10:36 UTC
Author

What this changes

_is_unspendable answered key.pub_key[1:33] == _UNSPENDABLE_X, which read a bytes subclass through its own __getitem__. A key whose [1:33] answered H's x coordinate was taken for BIP341's H, so tr() and rawtr() of a key the wallet can sign for listed no key path. A __getitem__ that raised made spending_paths raise from this line.

The slice is now taken from _plain(key.pub_key), the copy the module already reads a key's bytes through. A changelog entry is in changelog/next/.

Closes #464

How it was verified

A test in tests/descriptors/spending_paths_test.py builds an x-only KeyExpression of 1G's even SEC from a subclass whose slices answer H's x, and from one whose slices raise. For each, TrDescriptor and RawTrDescriptor give one key path, the same paths as the plain key. A control shows the overrides answer.

| Check | Result |
| --- | --- |
| The new test on main 38dae92 | 2 failed: no path for the lying key, RuntimeError from _is_unspendable for the raising one |
| Same, on this branch | 2 passed |
| uv run pytest | 8981 passed, 1792 skipped; coverage 100.00% |
| uv run --locked --only-group lint pre-commit run --all-files --show-diff-on-failure | exit 0 |
| uv run --locked --no-default-groups --group docs sphinx-build -n -W -b html docs/source docs/build/html | exit 0 |
| tests/descriptors/spending_paths_test.py on CPython 3.11 | 138 passed |

Checks

  • uv run pre-commit run --all-files is clean (ruff, mypy strict,

  • markdownlint, the copyright notice, uv.lock)
  • uv run pytest passes

  • I have read and understood every line of this change, and can

  • answer a review of it without the model

    Anything the reviewer should know

    The changelog file is named for pull request 483, the number I expect; if it gets another I will rename it in a second commit. I wrote this with AI assistance (Grok Bot). I have read the change and can answer for it.

    Diff: 246 lines (+184 / -62) across 3 files Reviewer: fametrano Review duration: 4503m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 246 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.330
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #483"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.9% (MEDIUM) · Higher = larger blast radius
    38.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.4% · Safe to merge
    15.4%