Skip to content

fix: generate correct BIP39 entropy size in Mnemonic::new()#1034

Open
shivv23 wants to merge 2 commits into
bitcoindevkit:masterfrom
shivv23:pr-1-mnemonic-entropy-fix
Open

fix: generate correct BIP39 entropy size in Mnemonic::new()#1034
shivv23 wants to merge 2 commits into
bitcoindevkit:masterfrom
shivv23:pr-1-mnemonic-entropy-fix

Conversation

@shivv23

@shivv23 shivv23 commented Jun 18, 2026

Copy link
Copy Markdown

Description

Mnemonic::new() was always generating 32 bytes of entropy regardless of the requested word count, with an explicit TODO expressing uncertainty about the approach.

Changes

  • Generate entropy of the correct size based on word count (16 bytes for 12-words, 24 for 18-words, 32 for 24-words)
  • Replace the redundant generate_with_entropy → o_string() → parse_in() round-trip with a direct rom_entropy() call
  • Remove unused imports (GeneratableKey, GeneratedKey, BareCtx)

Testing

  • Added est_mnemonic_generation_word_count to verify generated mnemonics have the correct word count

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant