Skip to content

[Feature] Add Electrum Seed Support to Seed XOR Flow, builds on PR #738#884

Open
berlinxray wants to merge 2 commits intoSeedSigner:devfrom
berlinxray:electrum-seedxor
Open

[Feature] Add Electrum Seed Support to Seed XOR Flow, builds on PR #738#884
berlinxray wants to merge 2 commits intoSeedSigner:devfrom
berlinxray:electrum-seedxor

Conversation

@berlinxray
Copy link

@berlinxray berlinxray commented Mar 1, 2026

Based on: PR #738 (Seed XOR functionality)
Related: PR #513 / #571 (Electrum seed support), Issue #43 (SeedXOR)

Summary

Builds on PR #738 (Seed XOR Flow by @Advaitgaur004) to add Electrum native segwit seed support to the XOR split/combine workflow.

  • Electrum seeds can now be used as XOR shards alongside BIP-39 seeds
  • XOR recombination auto-detects when the result is an Electrum seed
  • The exact Electrum mnemonic is recovered after BIP-39 checksum recomputation
  • 13 new unit tests verify Electrum XOR roundtrip, type detection, and validator compatibility
  • All 27 XOR tests pass (14 existing + 13 new)

Note: This PR is focused exclusively on Seed XOR + Electrum support. The AES-256-CBC encrypted seed QR import feature is in a separate PR (#882).

Changes (13 files)

Core (src/seedsigner/helpers/mnemonic_generation.py)

  • Replaced entropy-based XOR (bip39.mnemonic_to_bytes) with word-index-based approach — Electrum seeds lack valid BIP-39 checksums, so direct entropy extraction fails. Word-index XOR operates on the raw 11-bit indices and reconstructs entropy bits afterwards.

Model (src/seedsigner/models/seed.py)

  • Seed._is_electrum_hmac() — HMAC-SHA512 prefix check for segwit ("100") only. The standard prefix ("01") is excluded to prevent false positives during 256-variant brute-force on 24-word seeds.
  • Seed.detect_mnemonic_type() — Checks all 16/256 last-word checksum variants for Electrum HMAC match
  • Seed.get_electrum_mnemonic() — Recovers the exact last word that makes the mnemonic a valid Electrum seed

Validator (src/seedsigner/helpers/seed_xor_validator.py)

  • Use ignore_checksum=True in inverse-shard detection so Electrum seeds don't trigger checksum errors

Controller (src/seedsigner/controller.py)

  • Added FLOW__REBUILD_SEEDXOR constant and XOR rebuild methods: validate_rebuild_seedxor_shard(), process_rebuild_seedxor_shard(), remove_rebuild_seedxor_shard(), clear_rebuild_seedxor_data()

Storage (src/seedsigner/models/seed_storage.py)

  • Added XOR rebuild state: rebuild_seedxor_shards, rebuild_seedxor_combined_seed, and management methods

Settings (src/seedsigner/models/settings_definition.py)

  • Added SETTING__SEED_XOR feature toggle (advanced, enabled by default)

GUI (src/seedsigner/gui/components.py)

  • Uncommented CLOSE icon constant used by Seed XOR views

Views (src/seedsigner/views/seed_views.py)

  • Complete Seed XOR rebuild flow: RebuildSeedXORLoadShardView, RebuildSeedXORManageView, RebuildSeedXORShowFingerprintView, RebuildSeedXORFinalizeView, RebuildSeedXORFinalizeOptionsView, and more
  • "Enter Electrum seed" button gated by SETTING__ELECTRUM_SEEDS
  • Auto-detects Electrum vs BIP-39 result, creates ElectrumSeed when appropriate
  • Warning screen when Electrum support is disabled but XOR result is Electrum

Scan Views (src/seedsigner/views/scan_views.py)

  • ScanSeedQRView accepts is_rebuild_seedxor_shard parameter to route scanned seeds into the XOR flow
  • Back button handling for scan screen

Tests

  • tests/test_seedxor.py: 14 tests for base XOR logic (combine, commutativity, identity, invalid words, mismatched lengths)
  • tests/test_seedxor_electrum.py: 13 tests (roundtrip, type detection, commutativity, validator acceptance, derivation path preservation)
  • tests/test_flow_seedxor.py: Integration tests for XOR rebuild UI workflow

Checklist

  • pytest passes
  • Tested on Raspberry Pi OS (manual build)
  • Tested on SeedSigner OS (Pi0)

Test plan

  • All 27 XOR tests pass (14 base + 13 Electrum)
  • Manual test: Split Electrum seed → enter shares → Rebuild Seed XOR → verify fingerprint matches
  • Manual test: Verify "Enter Electrum seed" button only appears when Electrum Seeds setting is enabled
  • Manual test: Verify warning screen when XOR result is Electrum but setting is disabled

@berlinxray berlinxray changed the title [Feature] Add Electrum Seed Support to Seed XOR Flow [Feature] Add Electrum Seed Support to Seed XOR Flow, builds on PR #738 Mar 1, 2026
berlinxray and others added 2 commits March 2, 2026 04:30
Implement the Seed XOR split/combine workflow, enabling users to
reconstruct a Bitcoin seed from multiple XOR shards. Based on PR SeedSigner#738
by @Advaitgaur004.

- Add complete XOR rebuild UI: load shards, manage, finalize
- Add word-index-based XOR combine in mnemonic_generation.py
- Add SeedXORValidator for shard validation and inverse detection
- Add FLOW__REBUILD_SEEDXOR controller methods and SeedStorage state
- Add SETTING__SEED_XOR feature toggle
- Add ScanSeedQRView support for XOR shard scanning
- Uncomment CLOSE icon constant used by XOR views
- Add 14 unit tests and flow integration tests

Co-Authored-By: Advaitgaur004 <advaitgaur004@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Enable Electrum native segwit seeds to participate in XOR split/combine
operations alongside standard BIP-39 seeds.

- Replace entropy-based XOR with word-index-based approach in
  combine_mnemonics_with_xor() to support Electrum seeds (which lack
  valid BIP-39 checksums)
- Add Seed.detect_mnemonic_type() to identify Electrum seeds after XOR
  recombination by checking all last-word checksum variants against
  HMAC-SHA512 prefix "100"
- Add Seed.get_electrum_mnemonic() to recover the exact Electrum last
  word after BIP-39 checksum recomputation
- Update RebuildSeedXORLoadShardView with Electrum seed entry option
  (gated by existing Electrum Seeds setting)
- Update RebuildSeedXORFinalizeView to detect result type and create
  ElectrumSeed when appropriate, with warning when Electrum disabled
- Fix SeedXORValidator to use ignore_checksum=True for Electrum
  seed compatibility in inverse-shard detection
- Add 13 unit tests for Electrum XOR roundtrip, type detection, and
  validator compatibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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