Shamir Mnemonic
raw JSON → 0.3.0 verified Mon Apr 27 auth: no python
Implementation of SLIP-39 Shamir Secret Sharing mnemonics for splitting and recovering BIP-39 seed phrases. Current version 0.3.0, requires Python >=3.6, <4.0. Low release cadence.
pip install shamir-mnemonic Common errors
error shamir_mnemonic.mnemonic.MnemonicWordError: Invalid mnemonic word ↓
cause A mnemonic share contains an invalid word not in the SLIP-39 wordlist.
fix
Verify each share against the official SLIP-39 wordlist or regenerate shares.
error shamir_mnemonic.mnemonic.MnemonicError: Invalid mnemonic length ↓
cause The mnemonic string length does not match expected format (33 or 20 words).
fix
Ensure each mnemonic is exactly 33 words (standard) or 20 words (for shorter secrets).
error shamir_mnemonic.mnemonic.MnemonicError: Invalid checksum ↓
cause A mnemonic has an invalid checksum, often due to typo or truncation.
fix
Double-check the mnemonic and re-enter it correctly.
Warnings
gotcha The `passphrase` parameter is part of the secret and must be the same for splitting and combining. It is not a password but an additional entropy. ↓
fix Always store and reuse the same passphrase or use empty string.
gotcha The `entropy` must be exactly 128, 256, or 512 bits (16, 32, or 64 bytes). ↓
fix Ensure entropy length is one of the valid lengths.
gotcha `generate_mnemonics` returns a list of mnemonics, not a single mnemonic. Ensure you handle the list correctly. ↓
fix Use mnemonics[0] if you need one, or iterate.
gotcha The library uses SLIP-39, not the older BIP-39 style mnemonic format. Shares look different (they include a prefix like 'acid...'). ↓
fix Do not mix with BIP-39 mnemonic functions.
Imports
- generate_mnemonics wrong
from shamir_mnemonic import generate_mnemoniccorrectfrom shamir_mnemonic import generate_mnemonics - combine_mnemonics wrong
from shamir_mnemonic import combinecorrectfrom shamir_mnemonic import combine_mnemonics - MnemonicError
from shamir_mnemonic import MnemonicError
Quickstart
from shamir_mnemonic import generate_mnemonics, combine_mnemonics
# Split a BIP-39 seed phrase into 3 shares, requiring 2 to recover
mnemonics = generate_mnemonics(
group_threshold=1,
groups=[(2, 3)],
passphrase='',
entropy=b'\x00' * 16 # replace with actual 128-bit entropy
)
print(mnemonics) # list of 3 mnemonic strings
# Recover from 2 shares
recovered = combine_mnemonics(mnemonics[:2])
print(recovered) # dict with 'group', 'passphrase', 'entropy', 'share'