Skip to content

S5: SLIP-39 RS1024 encoding + Share codec#112

Draft
SachinMeier wants to merge 2 commits into
sachin--slip39-4-cipherfrom
sachin--slip39-5-encoding-share
Draft

S5: SLIP-39 RS1024 encoding + Share codec#112
SachinMeier wants to merge 2 commits into
sachin--slip39-4-cipherfrom
sachin--slip39-5-encoding-share

Conversation

@SachinMeier

Copy link
Copy Markdown
Collaborator

Stack: S0 → S1 → S2 → S3 → S4 → S5 → S6 (spec §3.7, §3.8)

  • Bitcoinex.SLIP39.Encoding: RS1024 polymod (bech32-polymod style) with "shamir"/"shamir_extendable" customization, checksum create/verify, word↔index mapping
  • Bitcoinex.SLIP39.Share: bit-exact wire codec; decode validates length, RS1024 (ext bit peeked pre-verify), ≤8-bit zero padding, GT≤G; encode is total on valid structs
  • Official-vector coverage: full metadata asserts on 4 vectors (incl. 33-word/256-bit), byte-identical encode∘decode round-trip over every mnemonic in all 45 vectors, specific error atoms for invalid-checksum/padding/length/group-threshold vectors; RS1024 1–3-word mutation guarantee property

🤖 Generated with Claude Code

@SachinMeier SachinMeier force-pushed the sachin--slip39-5-encoding-share branch from 8ef8a67 to 53a206a Compare July 2, 2026 04:22
@SachinMeier SachinMeier force-pushed the sachin--slip39-4-cipher branch from b7440e5 to 9c16226 Compare July 2, 2026 04:22
@SachinMeier

Copy link
Copy Markdown
Collaborator Author

Independent adversarial review (subagent) complete: no High/Medium findings, no security issues. RS1024 cross-checked against an independent Python implementation (40/40 cases); official-vector bit-decodes independently reproduced for vectors 1, 20, 42, 45 (incl. both extendable ones); validation order matches the trezor reference; hand mutation tests all rejected correctly.

Addressed in the follow-up commit:

  • decoder-never-raises fuzz properties for Share.decode/1 (arbitrary strings + random valid-word sequences), matching the BIP-39 decoder fuzz
  • named assertion pinning the extendable-flag wire path (official vector 42)

Note: S6 (#113) adjusts the pad_bits > 8 error from :invalid_padding to :invalid_secret_length — official vector 40 names that case "invalid master secret length"; rationale in the S6 PR description.

SachinMeier and others added 2 commits July 1, 2026 21:26
Add Bitcoinex.SLIP39.Encoding (RS1024 polymod/checksum over GF(1024)
with shamir/shamir_extendable customization strings, plus 10-bit word
index <-> word conversion against the 1024-word SLIP-39 list) and
Bitcoinex.SLIP39.Share (bit-packed single-mnemonic codec: 15-bit
identifier, extendable flag, iteration exponent, group/member metadata
stored 1-based in the struct and minus-1 on the wire, zero left-padded
share value, 3-word RS1024 checksum).

decode/1 validates word membership, minimum 20-word length, RS1024
checksum (peeking the extendable bit to select the customization
string), padding (pad_bits <= 8 and all-zero), and group_threshold <=
group_count.

Tests cover the spec's unit enumeration plus official
trezor/python-shamir-mnemonic vectors (metadata decode for vectors
1/4/17/20 incl. a 33-word 256-bit share, byte-identical encode
round-trip across all 45 vectors, and specific error atoms for the
invalid-checksum/padding/length/group-threshold vectors), a StreamData
round-trip property over random valid shares, and an RS1024
checksum-guarantee property mutating 1-3 words.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- add decoder-never-raises fuzz properties for Share.decode/1 over
  arbitrary strings and random valid-word sequences (parity with the
  BIP-39 decoder fuzz)
- pin the extendable-flag wire path with a named assertion on official
  vector 42

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@SachinMeier SachinMeier force-pushed the sachin--slip39-4-cipher branch from 9c16226 to cad06d0 Compare July 2, 2026 04:27
@SachinMeier SachinMeier force-pushed the sachin--slip39-5-encoding-share branch from 53a206a to 5340708 Compare July 2, 2026 04:27
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