Skip to content

Commit 236630b

Browse files
committed
tests: Drop historical CRC padding tie-break test
The legacy padding check is gone, so nothing should model the padding written before the all-ones XOR. test_cli_tie_breaks_follow_hamming_crc_then_fingerprint already covers the Hamming, CRC, fingerprint order. Drop the API doc line about historical padding for the same reason. pytest on a squash of this branch: 912 passed, also with -O. Ruff check and format: passed. Claude-Session: https://claude.ai/code/session_019DuBKzoVE7oBFRnzoGH2ps
1 parent 91fcf6d commit 236630b

2 files changed

Lines changed: 2 additions & 24 deletions

File tree

‎docs/developer/api.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,7 @@ Without it, a 24-byte seed extended with zero bits to 64 bytes would keep valid
566566
padding, since both sizes use CRC3. With it, the extended padding never
567567
matches, because the 320 added bits are not a multiple of CRC3's period of 7.
568568
CRC1 stays without an XOR because an XOR there would give every all-zero
569-
28-byte seed valid padding. Correction tie-breaks consider only the current
570-
generation CRC padding. Historical padding formats receive no special preference.
569+
28-byte seed valid padding.
571570

572571
The polynomials appear in the [Koopman CRC catalogue](https://users.ece.cmu.edu/~koopman/crc/index.html),
573572
including its [CRC-3](https://users.ece.cmu.edu/~koopman/crc/crc3.html) and

‎tests/test_crc.py‎

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
from data.bip93_vectors import VECTOR_2, VECTOR_4
77

88
import codex32
9-
from codex32 import CorrectionCandidate, MasterSeed, Share, parse_codex32
9+
from codex32 import MasterSeed, Share, parse_codex32
1010
from codex32.checksums import _CRC, _crc_pad
11-
from codex32.correction import _best
1211
from codex32.gf32 import _multiply as _gf32_multiply
1312
from codex32.profiles.ms32 import SEED_BYTE_LENGTHS, _has_generation_padding, _payload_padding
1413

@@ -60,26 +59,6 @@ def test_parsed_master_seed_validity_is_independent_of_crc() -> None:
6059
assert generated.payload_symbols in {secret.payload_symbols for secret in parsed}
6160

6261

63-
def test_tie_break_prefers_only_current_crc_padding() -> None:
64-
parsed = [parse_codex32(VECTOR_4[f"secret_s_alternate_{padding}"]) for padding in range(16)]
65-
assert all(isinstance(secret, MasterSeed) for secret in parsed)
66-
current = next(secret for secret in parsed if _has_generation_padding(secret))
67-
previous = parsed[8] # Pad suffix produced before the final XOR was added.
68-
other = parsed[0]
69-
assert current not in (previous, other)
70-
71-
def candidates(*secrets: MasterSeed) -> list[CorrectionCandidate]:
72-
return [CorrectionCandidate(s, (), 1, 0, 0, _has_generation_padding(s)) for s in secrets]
73-
74-
assert tuple(item.artifact for item in _best(candidates(other, previous, current))) == (current,)
75-
# Without a current CRC match, neither historical nor arbitrary padding wins.
76-
tied = tuple(item.artifact for item in _best(candidates(other, previous)))
77-
assert tied == tuple(sorted((other, previous), key=lambda secret: secret.text.lower()))
78-
# The wallet hint can decide the tie without being overridden by historical padding.
79-
hinted = _best(candidates(other, previous), fingerprint_match=lambda item: item.artifact == other)
80-
assert tuple(item.artifact for item in hinted) == (other,)
81-
82-
8362
def test_padding_acceptance_is_balanced_for_every_nonzero_lagrange_weight() -> None:
8463
"""A free GF(32) symbol leaves each permitted padding suffix equally likely."""
8564
for padding_bits in range(1, 5):

0 commit comments

Comments
 (0)