Skip to content

Prevent ambiguous mnemonic panics and preserve language roundtrip through serde - #108

Open
tnull wants to merge 2 commits into
rust-bitcoin:masterfrom
tnull:2026-08-fix-chinese-mnemonic-roundtrips
Open

Prevent ambiguous mnemonic panics and preserve language roundtrip through serde#108
tnull wants to merge 2 commits into
rust-bitcoin:masterfrom
tnull:2026-08-fix-chinese-mnemonic-roundtrips

Conversation

@tnull

@tnull tnull commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Fixes #106.

Prevent ambiguous mnemonic entropy panics 

Valid Chinese mnemonics can use words shared by the Simplified and
Traditional lists. Entropy recovery redetects their language and unwraps
the ambiguity error, causing a panic for otherwise valid values.

Recover entropy directly from the stored, validated word indices.
Preserve mnemonic language through serde 

Serde currently stores only the displayed phrase. A phrase shared by the
Simplified and Traditional Chinese lists cannot be auto-detected during
deserialization, so a valid serialized mnemonic cannot be restored.

Add a versioned language tag for ambiguous phrases while retaining the
legacy string representation and reader behavior elsewhere.

tnull added 2 commits August 20, 2026 12:19
Valid Chinese mnemonics can use words shared by the Simplified and
Traditional lists. Entropy recovery redetects their language and unwraps
the ambiguity error, causing a panic for otherwise valid values.

Recover entropy directly from the stored, validated word indices.

Co-Authored-By: HAL 9000
Serde currently stores only the displayed phrase. A phrase shared by the
Simplified and Traditional Chinese lists cannot be auto-detected during
deserialization, so a valid serialized mnemonic cannot be restored.

Add a versioned language tag for ambiguous phrases while retaining the
legacy string representation and reader behavior elsewhere.

Co-Authored-By: HAL 9000
@tnull
tnull requested a review from elsirion August 20, 2026 10:22
@tnull
tnull requested a review from stevenroose August 20, 2026 10:41
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.

to_entropy_array can panic for a valid mnemonic when language detection is ambiguous

1 participant