Add Kurihara n-of-m threshold XOR mnemonic backup (core + tests + docs) - #366
Open
CaverneCrypto wants to merge 1 commit into
Open
Add Kurihara n-of-m threshold XOR mnemonic backup (core + tests + docs)#366CaverneCrypto wants to merge 1 commit into
CaverneCrypto wants to merge 1 commit into
Conversation
Adds the pure, GUI-less core of an n-of-m threshold backup for BIP39 mnemonics. Any n of m shares reconstruct the seed; strictly fewer than n reveal nothing (perfect, information-theoretic confidentiality up to the threshold). Each share is exactly the size of the secret and re-encodes to a valid BIP39 mnemonic. - src/kurihara.py: scheme (split / reconstruct / regenerate lost share) via Gaussian elimination over GF(2). The arithmetic core has no external dependency (embit imported lazily for the BIP39 glue; rng injectable). - test/tests/test_kurihara.py: 15 unit tests (every coalition reconstructs, sub-threshold rejected, lost-share regeneration is bit-identical, BIP39 round-trip, deterministic known-answer vector). - docs/threshold-backup.md + mkdocs nav entry. Underlying scheme: Kurihara, Kiyomoto, Fukushima, Tanaka, ISC 2008 (https://eprint.iacr.org/2008/409). BIP39 adaptation, derivation, security verification and templates: https://doi.org/10.5281/zenodo.20734041 (CC BY 4.0). GUI/app wiring is intended as a follow-up PR so the security-critical math can be reviewed in isolation first. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for specter-diy-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an
n-of-mthreshold backup for BIP39 mnemonics, based on the ideal threshold XOR secret-sharing scheme of Kurihara et al. (ISC 2008). A seed is split intomshares such that anynreconstruct it, while anyn − 1reveal nothing (perfect, information-theoretic confidentiality up to the threshold). Reconstruction reduces to XORs of hex strings — no finite-field arithmetic — so it is also a pen-and-paper procedure. Each share is exactly the size of the secret and re-encodes to a valid BIP39 mnemonic (plausible deniability).There is currently no share-based backup in Specter-DIY (no SeedXOR / Shamir / SLIP-39); this fills that gap.
Scope of this PR
Audited arithmetic core + unit tests + docs only — no on-device GUI yet. Wiring it into an app/menu is intended as a follow-up PR, so the security-critical math can be reviewed in isolation first.
src/kurihara.py— the scheme: split / reconstruct / regenerate a lost share, via Gaussian elimination over GF(2) (coefficient rows as column-index sets, no big-int bitmasks → MicroPython-friendly). The arithmetic core has no external dependency;embitis imported lazily only for the BIP39 glue, and the randomness source is injectable (defaults torng.get_random_bytes).test/tests/test_kurihara.py— 15 unit tests: everyn-coalition reconstructs; every(n − 1)-coalition is rejected; lost-share regeneration is bit-for-bit identical and usable; each share encodes to a valid mnemonic and the secret round-trips through the mnemonics; a deterministic known-answer vector guards the construction.docs/threshold-backup.md(+ mkdocs nav entry).Profiles
Testing
All 15 tests pass. They are written for the simulator suite (
make test) and also run under the project's native CPython harness (realembit).make testwill exercise them in CI.References
🤖 Generated with Claude Code