Skip to content

bip93: Report an unused length instead of a failed checksum - #209

Draft
BenWestgate wants to merge 1 commit into
claude/project-thread-jhiarh-friendly-errorsfrom
claude/project-thread-jhiarh-length-first
Draft

BenWestgate wants to merge 1 commit into
claude/project-thread-jhiarh-friendly-errorsfrom
claude/project-thread-jhiarh-length-first

Conversation

@BenWestgate

Copy link
Copy Markdown
Owner

Before: parse_codex32 said "The checksum does not match." for a 47-character ms1 string. Only the CLI rewrote that to the length error, so GUIs and API callers never saw it.

After: when the checksum fails and the length is one the application never uses, the library raises the application's length error, for example "This input has 47 characters. A Bitcoin master-seed backup must have exactly 48, 54, 61, 67, 74, or 127 characters." A string with a valid length and a bad checksum still says the checksum does not match.

The checksum is still verified before any application rule accepts the input. The length only picks the reason for a rejection. Generic length errors (too short, the 94/95 gap, too long) already came first and are unchanged.

How: _decode_codex32 checks the profile text length when the checksum fails. The CLI's own rewrite in _parse is gone. api.md and three tests that pinned the old order are updated.

Stacked on #161. It changes which error a parse failure raises, so per project policy it needs a security review before it is marked ready.

Checks run locally: python -m pytest and python -O -m pytest (918 passed), ruff, ruff format, mypy.


Generated by Claude Code

When a string's checksum fails and its length is one its application
never uses, parse_codex32 now raises the application's length error
("This input has 47 characters. A Bitcoin master-seed backup must have
exactly 48, 54, 61, 67, 74, or 127 characters.") instead of "The
checksum does not match." A wrong length is the clearer reason, and
GUIs and API callers now get it too.

The checksum is still verified before any application rule accepts the
input; the length only picks the reason for a rejection. The CLI's own
rewrite of this message is gone.

Claude-Session: https://claude.ai/code/session_01Q1TNm1YeYW8K9W2eBvxmCD

This branch has not been deployed

No deployments
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