Skip to content

Fix embedded mnemonic share index bits#56

Open
Randy-sin wants to merge 1 commit into
bitaps-com:masterfrom
Randy-sin:codex/fix-embedded-mnemonic-index-bits
Open

Fix embedded mnemonic share index bits#56
Randy-sin wants to merge 1 commit into
bitaps-com:masterfrom
Randy-sin:codex/fix-embedded-mnemonic-index-bits

Conversation

@Randy-sin
Copy link
Copy Markdown

Fixes #55

This keeps embedded share indexes within the checksum bit width that can actually be stored by the mnemonic.

Changes:

  • Validate splitMnemonic(..., { embeddedIndex: true }) so total shares cannot exceed the mnemonic checksum capacity.
  • Use Math.ceil(Math.log2(total + 1)) instead of Math.ceil(Math.log2(total)) + 1 for the share-index mask width.
  • Add regression coverage for a 12-word mnemonic split into 15 shares, ensuring embedded indexes stay in 1..15 and combining still restores the original mnemonic.
  • Add a rejection test for trying to embed 16 shares into a 12-word mnemonic.

Validation:

  • npm test (85 passing)
  • npm run build

Note: I kept the patch intentionally small because this touches wallet recovery behavior.

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.

Bug: indexBits=8 default causes silent wallet loss for 12-word mnemonics

1 participant