Skip to content

bip93: Check share sets in codex32_interpolate and add invalid set vectors - #5

Draft
BenWestgate wants to merge 5 commits into
bip93-generalize-hrpfrom
claude/project-thread-7ewdqc
Draft

BenWestgate wants to merge 5 commits into
bip93-generalize-hrpfrom
claude/project-thread-7ewdqc

Conversation

@BenWestgate

@BenWestgate BenWestgate commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Requested by Ben · project thread

Add invalid share set test vectors to BIP93 for bitcoin#2320, as discussed in stutxo/codex32_lean#1, and make the reference code reject them.

  • codex32_decode(s) applies the string rules for any HRP and returns the HRP and data part, or None.
  • codex32_interpolate(strings, x) takes codex32 strings and a target index character, decodes each string, checks the set with codex32_check_set, and returns a string. It raises an error for an invalid string or set.

Each vector set is made of valid strings but is not a valid set of shares:

  • share C of test vector 2 with a different HRP, threshold or identifier, or with share A's index, paired with share A
  • shares a and c of test vector 3, fewer than its threshold

codex32_recover raises an error for all of them. Without the check, interpolation returns a valid secret for the identifier set and the test vector 3 pair.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DNycZ6NQBfYLvTVtgeZWxK

List valid codex32 strings that do not form a valid set of shares:
Test vector 2's share C with a different human-readable part,
threshold or identifier, or with share A's index, paired with share A,
and two shares of Test vector 3 (fewer than its threshold).
codex32_recover returns a valid codex32 secret for the
different-identifier set and the Test vector 3 pair, so only the set
checks catch them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DNycZ6NQBfYLvTVtgeZWxK
@BenWestgate BenWestgate self-assigned this Oct 19, 2026
@BenWestgate

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T03:50:36.832828Z 8ff1eb8 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 8ff1eb8ef8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bip-0093.mediawiki Outdated

The shares of Test vector 3 with indexes <code>a</code> and <code>c</code> do not form a valid set, because there are fewer of them than the threshold.

Given the set with different identifiers, or these two shares of Test vector 3, <code>codex32_recover</code> returns a valid codex32 secret.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This PR needs to include a set-validation helper so these can actually fail.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Added codex32_check_set(strings, x) in 64510b1. It takes strings so the HRP check works, and it returns false for every set here with target s.


Generated by Claude Code

Add codex32_check_set, which takes valid codex32 strings and a target
share index and checks the conditions on the inputs to
codex32_interpolate. It takes strings because the data-part
representation omits the human-readable part. Point the MUST-check
sentence at it, and note that it rejects each invalid share set vector.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DNycZ6NQBfYLvTVtgeZWxK
@BenWestgate BenWestgate changed the title bip93: Add invalid share set test vectors bip93: Add share set check and invalid share set vectors Oct 20, 2026
Make codex32_interpolate take codex32 strings and a target index
character, check the set with codex32_check_set, and return a string.
Strings keep the human-readable part, which the data-part
representation dropped. codex32_recover now raises an error for every
invalid share set vector, so the MUST-check sentence goes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DNycZ6NQBfYLvTVtgeZWxK
@BenWestgate BenWestgate changed the title bip93: Add share set check and invalid share set vectors bip93: Check share sets in codex32_interpolate and add invalid set vectors Oct 20, 2026
Add a generic codex32_decode that applies the string rules for any
human-readable part: case, character set, HRP length, checksum,
minimum length and header. codex32_interpolate now decodes each input
before checking the set, so strings with bad checksums are rejected,
and codex32_check_set also requires the target to be one bech32
character.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DNycZ6NQBfYLvTVtgeZWxK
Return the interpolated string in uppercase when every input is
uppercase, and in lowercase otherwise, so Test vector 2's uppercase
shares give its uppercase derived share and secret.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DNycZ6NQBfYLvTVtgeZWxK
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