Skip to content

Add Kurihara n-of-m threshold XOR mnemonic backup (core + tests + docs) - #366

Open
CaverneCrypto wants to merge 1 commit into
cryptoadvance:masterfrom
CaverneCrypto:feature/kurihara-threshold-backup
Open

Add Kurihara n-of-m threshold XOR mnemonic backup (core + tests + docs)#366
CaverneCrypto wants to merge 1 commit into
cryptoadvance:masterfrom
CaverneCrypto:feature/kurihara-threshold-backup

Conversation

@CaverneCrypto

Copy link
Copy Markdown

Summary

Adds an n-of-m threshold backup for BIP39 mnemonics, based on the ideal threshold XOR secret-sharing scheme of Kurihara et al. (ISC 2008). A seed is split into m shares such that any n reconstruct it, while any n − 1 reveal 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; embit is imported lazily only for the BIP39 glue, and the randomness source is injectable (defaults to rng.get_random_bytes).
  • test/tests/test_kurihara.py — 15 unit tests: every n-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

Profile L (bits) Words Tolerates
2-of-3 128 12 1 loss
3-of-5 256 24 2 losses

Testing

All 15 tests pass. They are written for the simulator suite (make test) and also run under the project's native CPython harness (real embit). make test will exercise them in CI.

References

  • Whitepaper (the BIP39 adaptation, pen-and-paper derivation, security-property verification and ready-to-print templates this module implements): CaverneCrypto, Bitcoin Mnemonic Backup via Threshold XOR (n-of-m): A pen-and-paper adaptation of the Kurihara scheme to BIP39, 2026 — https://doi.org/10.5281/zenodo.20734041 (CC BY 4.0)
  • Underlying scheme: J. Kurihara, S. Kiyomoto, K. Fukushima, T. Tanaka, A New (k, n)-Threshold Secret Sharing Scheme and Its Extension, ISC 2008 — https://eprint.iacr.org/2008/409

🤖 Generated with Claude Code

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>
@netlify

netlify Bot commented Jun 17, 2026

Copy link
Copy Markdown

Deploy Preview for specter-diy-docs ready!

Name Link
🔨 Latest commit 0b101bb
🔍 Latest deploy log https://app.netlify.com/projects/specter-diy-docs/deploys/6a32b053d2a84f00085dfa5f
😎 Deploy Preview https://deploy-preview-366--specter-diy-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

1 participant