Registry / auth-security / shamir-mnemonic

shamir-mnemonic

JSON →
library0.3.0pypypi✓ verified 85d ago

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
INSTALL
IMPORT
SIG · SHAMIR-MNEMONIC
S
shamir-mnemonic
auth-securitypythonv0.3.0
Install
1.6s avg
Import
56ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.060s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.052s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

generate_mnemonics
from shamir_mnemonic import generate_mnemonics
from shamir_mnemonic import generate_mnemonic
Function is plural 'generate_mnemonics' (returns list), not singular.
combine_mnemonics
from shamir_mnemonic import combine_mnemonics
from shamir_mnemonic import combine
Function is 'combine_mnemonics', not 'combine'.
MnemonicError
from shamir_mnemonic import MnemonicError
Exception raised for invalid mnemonics.

Basic split and combine using SLIP-39 with 1 group, 2-of-3 threshold.

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'
Debug
Known issues
gotchaThe `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.
affects: all
gotchaThe `entropy` must be exactly 128, 256, or 512 bits (16, 32, or 64 bytes).
fix
Ensure entropy length is one of the valid lengths.
affects: all
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.
affects: all
gotchaThe 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.
affects: all
Errors
Common errors & fixes
shamir_mnemonic.mnemonic.MnemonicWordError: Invalid mnemonic word
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.
shamir_mnemonic.mnemonic.MnemonicError: Invalid mnemonic length
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).
shamir_mnemonic.mnemonic.MnemonicError: Invalid checksum
A mnemonic has an invalid checksum, often due to typo or truncation.
fix
Double-check the mnemonic and re-enter it correctly.
Upgrade
Version history
0.3.0latest on PyPI · released May 16, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources
shamir-mnemonic — pip install shamir-mnemonic · libregistry