**Motivations:** - Implement BIP39 mnemonic import for identity creation - Add password-based key protection for enhanced security - Improve pairing workflow with QR code and URL display - Migrate hash cache from LocalStorage to IndexedDB for better scalability - Update signet-dashboard and mempool components **Root causes:** - N/A (feature implementations) **Correctifs:** - N/A (no bug fixes in this commit) **Evolutions:** - BIP39 mnemonic import: Support for 12/24 word English mnemonics with BIP32 derivation path m/44'/0'/0'/0/0 - Key protection: Password-based encryption of private keys at rest with unlock/lock functionality - Pairing workflow: QR code and URL display for device pairing, form-based word exchange between devices - IndexedDB migration: Hash cache moved from LocalStorage to IndexedDB to avoid size limitations - Global action bar: URL parameter support for navigation - Pairing connection: Enhanced pairing status management **Pages affectées:** - userwallet/src/utils/identity.ts - userwallet/src/utils/keyProtection.ts - userwallet/src/utils/sessionUnlockedKey.ts - userwallet/src/utils/indexedDbStorage.ts - userwallet/src/utils/cache.ts - userwallet/src/utils/pairing.ts - userwallet/src/components/UnlockScreen.tsx - userwallet/src/components/PairingDisplayScreen.tsx - userwallet/src/components/PairingSetupBlock.tsx - userwallet/src/components/GlobalActionBar.tsx - userwallet/src/components/HomeScreen.tsx - userwallet/src/components/ImportIdentityScreen.tsx - userwallet/src/components/DataExportImportScreen.tsx - userwallet/src/hooks/useIdentity.ts - userwallet/src/hooks/usePairingConnected.ts - userwallet/src/services/syncService.ts - userwallet/src/services/pairingConfirm.ts - userwallet/src/App.tsx - userwallet/package.json - userwallet/docs/specs.md - userwallet/docs/storage.md - userwallet/docs/synthese.md - signet-dashboard/public/*.html - signet-dashboard/public/app.js - signet-dashboard/public/styles.css - mempool (submodule updates) - hash_list.txt, hash_list_cache.txt, utxo_list.txt, utxo_list_cache.txt, fees_list.txt - features/*.md (documentation files)
47 lines
2.2 KiB
Markdown
47 lines
2.2 KiB
Markdown
# UserWallet – Import BIP39 mnemonic
|
||
|
||
**Author:** Équipe 4NK
|
||
**Date:** 2026-01-26
|
||
|
||
## Objectif
|
||
|
||
Permettre l’import d’une identité à partir d’une phrase BIP39 (12 ou 24 mots anglais) en plus de la clé privée hex brute, en dérivant la clé via BIP32.
|
||
|
||
## Impacts
|
||
|
||
- **Fonctionnels** : L’écran « Importer une identité » accepte soit 64 caractères hex (clé brute), soit une phrase BIP39 valide (12 ou 24 mots, anglais). La clé est dérivée avec le chemin m/44'/0'/0'/0/0.
|
||
- **Techniques** : Dépendances `@scure/bip39` et `@scure/bip32`. Nouvelle fonction `privateKeyFromMnemonic` dans `identity.ts`, extension de `importIdentity`.
|
||
|
||
## Modifications
|
||
|
||
### identity.ts
|
||
|
||
- Import de `validateMnemonic`, `mnemonicToSeedSync` (@scure/bip39), wordlist anglaise, `HDKey` (@scure/bip32), `bytesToHex` (@noble/hashes).
|
||
- `privateKeyFromMnemonic(mnemonic)` : `mnemonicToSeedSync` → `HDKey.fromMasterSeed` → `derive("m/44'/0'/0'/0/0")` → `bytesToHex(privateKey)`.
|
||
- `importIdentity` : si l’entrée est 64 hex → comportement actuel (clé brute). Sinon, normalisation (espaces, lowercase), vérification 12/24 mots et `validateMnemonic`, puis `privateKeyFromMnemonic`. Création de l’identité comme avant.
|
||
|
||
### ImportIdentityScreen
|
||
|
||
- Placeholder et label mis à jour (BIP39, 12/24 mots).
|
||
- Hint : « Clé hex brute ou phrase BIP39 (anglais). Passphrase BIP39 non supportée. Dérivation m/44'/0'/0'/0/0. » + `aria-describedby` / `id` pour l’accessibilité.
|
||
|
||
### Documentation
|
||
|
||
- `userwallet/docs/synthese.md` : identité – import BIP39 et chemin de dérivation indiqués ; passphrase non supportée.
|
||
|
||
## Limitations
|
||
|
||
- **Passphrase BIP39** : non supportée (toujours `''`).
|
||
- **Wordlist** : anglais uniquement.
|
||
- **Chemin** : fixe m/44'/0'/0'/0/0 (pas de paramétrage).
|
||
|
||
## Modalités de déploiement
|
||
|
||
- `npm install` (nouvelles deps), rebuild frontend, déploiement des assets.
|
||
|
||
## Modalités d’analyse
|
||
|
||
- Importer une phrase BIP39 valide (12 ou 24 mots) et vérifier que l’identité est créée et que la clé publique correspond à une dérivation m/44'/0'/0'/0/0.
|
||
- Importer une clé hex brute : vérifier qu’aucune régression.
|
||
- Entrée invalide (mots incorrects, mauvais nombre) : message d’erreur, pas d’identité créée.
|