Repository navigation
checksums: XOR CRC2-CRC4 padding with all ones - #216
Open
BenWestgate wants to merge 1 commit into
Open
BenWestgate wants to merge 1 commit into
BenWestgate wants to merge 1 commit into
Conversation
Match the spare-bit CRC of the codex32 key-expressions draft. Without the XOR, a 24-byte seed extended with zero bits to 64 bytes keeps valid CRC3 padding; with it, that extension never matches, since 320 bits is not a multiple of CRC3's period of 7. CRC1 keeps no XOR, because one would give every all-zero 28-byte seed valid padding. Correction tie-breaks prefer the new padding, then the padding written before this change, then neither. BIP93 vectors 3 and 4 now generate their alternate 3 and 7 strings. pytest: 913 passed. Ruff check and format, mypy: passed. Claude-Session: https://claude.ai/code/session_019DuBKzoVE7oBFRnzoGH2ps
BenWestgate
marked this pull request as ready for review
November 6, 2026 19:11
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Owner
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: generated ms strings fill their spare bits with a CRC that starts from 1 and has no final XOR. A 24-byte seed extended with zero bits and read as a 64-byte seed keeps valid CRC3 padding, so the padding cannot tell the two apart.
After: CRC2 to CRC4 end with an all-ones XOR, matching the spare-bit CRC in the codex32 key-expressions draft. That extension never keeps valid padding, because the 320 added bits are not a multiple of CRC3's period of 7. CRC1 stays odd parity, because an XOR there would give every all-zero 28-byte seed valid padding.
Strings made before this change still parse, since padding is never enforced. When correction finds several equally good candidates, it now prefers the new padding, then the old no-XOR padding, then neither. The wallet fingerprint hint still comes after both.
How: the CRC2 to CRC4 constants in
checksums.pybecome0b11,0b111and0b1111._has_legacy_generation_paddinginprofiles/ms32.pyrecognises the old padding, andcorrection.pyuses it as a second hint in_bestand as a sort key.CorrectionCandidateis unchanged. The frozen-convention section indocs/developer/api.mdgives the new representative outputs and the reason for the XOR.BIP93 vectors 3 and 4 now generate their
secret_s_alternate_3andsecret_s_alternate_7strings, notsecret_s. The vector 3 test derives its shares from the officialsecret_s. A new test checks the tie-break order and fails without thecorrection.pychange. Strings from v0.4.0, which started the CRC from 0, get no preference.Validation:
python -O -m pytest -qgave 913 passed on this commit.python -m pytest -qgave 911 passed before the two vector-test updates, which then passed on rerun. Ruff check and format, andpython -m mypy src/codex32, passed.🤖 Generated with Claude Code
https://claude.ai/code/session_019DuBKzoVE7oBFRnzoGH2ps