Aller au contenu

PD-242 — Décomposition des tâches

Date : 2026-02-19 Branche : feature/PD-242-recovery-envelope


Séquence d'implémentation

TASK-1 (dépendance) → TASK-2 (bip39) → TASK-3 (service) → TASK-4 (composants)
                              TASK-5 (create) → TASK-6 (restore) → TASK-7 (regenerate)
                                                                     TASK-8 (tests)

TASK-1 — Ajout dépendance @noble/bip39

Agent : Claude (orchestrateur) Fichiers : package.json Durée estimée : 5 min

Actions : 1. npm install @noble/bip39 2. Vérifier import dans Metro bundler 3. Vérifier import dans Jest

Critère de succès : Import fonctionne sans erreur.


TASK-2 — Module BIP-39 wrapper

Agent : Claude Fichiers : - src/crypto/bip39.ts (CREATE) - src/crypto/constants.ts (UPDATE)

Contract : CC-02

Interface cible :

export function generateMnemonic(): string[];
export function validateMnemonic(words: string[]): boolean;
export function mnemonicToSeed(words: string[], passphrase?: string): Uint8Array;
export function getWordlist(): readonly string[];

Invariants : INV-242-05


TASK-3 — RecoveryService principal

Agent : Claude Fichiers : src/services/recoveryService.ts (CREATE)

Contract : CC-03

Interface cible :

export interface RecoveryEnvelope {
  envelope: string;    // base64 (ciphertext)
  nonce: string;       // base64 (12 bytes)
  tag: string;         // base64 (16 bytes)
}

export function deriveRecoveryKey(mnemonic: string[], userId: string): Uint8Array;
export function createRecoveryEnvelope(kRecovery: Uint8Array, kMaster: Uint8Array): RecoveryEnvelope;
export function restoreFromEnvelope(kRecovery: Uint8Array, envelope: RecoveryEnvelope): Uint8Array;
export function computeVerificationHash(kRecovery: Uint8Array, userId: string): Uint8Array;
export function zeroizeRecoveryKey(kRecovery: Uint8Array): void;

Dépendances internes : - @noble/bip39 (TASK-2) - src/services/hkdf.ts (PD-97) - src/crypto/aes-gcm.ts (PD-97) - src/crypto/utils.ts (PD-97) - src/crypto/zeroize.ts (PD-97)

Invariants : INV-242-01, INV-242-02, INV-242-03, INV-242-04, INV-242-06, INV-242-07, INV-242-08


TASK-4 — Composants UI Recovery

Agent : Claude Fichiers : - src/components/recovery/MnemonicDisplay.tsx (CREATE) - src/components/recovery/MnemonicInput.tsx (CREATE) - src/components/recovery/RecoveryProgress.tsx (CREATE)

Contract : CC-04

Dépendances : - React Native - src/crypto/bip39.ts (TASK-2 — pour wordlist validation)

Invariants : INV-242-11, INV-242-12


TASK-5 — RecoveryCreateScreen

Agent : Claude Fichiers : - src/screens/recovery/RecoveryCreateScreen.tsx (CREATE) - src/navigation/types.ts (UPDATE — ajouter route)

Contract : CC-05

Dépendances : - RecoveryService (TASK-3) - Composants UI (TASK-4) - API backend /recovery/envelope

Invariants : INV-242-02, INV-242-09


TASK-6 — RecoveryRestoreScreen

Agent : Claude Fichiers : src/screens/recovery/RecoveryRestoreScreen.tsx (CREATE)

Contract : CC-06

Dépendances : - RecoveryService (TASK-3) - Composants UI (TASK-4) - API backend /recovery/h_verify, /recovery/envelope - KeychainStorage (PD-98)

Invariants : INV-242-08, INV-242-10, INV-242-13


TASK-7 — RecoveryRegenerateScreen

Agent : Claude Fichiers : src/screens/recovery/RecoveryRegenerateScreen.tsx (CREATE)

Contract : CC-07

Dépendances : - RecoveryService (TASK-3) - Composants UI (TASK-4) - useReauth hook - API backend DELETE + POST /recovery/envelope

Invariants : INV-242-02, INV-242-09


TASK-8 — Tests

Agent : Claude Fichiers : - src/__tests__/crypto/bip39.test.ts (CREATE) - src/__tests__/services/recoveryService.test.ts (CREATE)

Contract : CC-08

Couverture requise : - Vecteurs BIP-39 officiels (TREZOR) - Round-trip envelope - Rejet phrase incorrecte - Performance < 3s


Ordre d'exécution

Phase Tâches Parallélisable
1 TASK-1 Non
2 TASK-2 Non
3 TASK-3, TASK-4 Oui
4 TASK-5, TASK-6, TASK-7 Oui (après phase 3)
5 TASK-8 Non (après phase 4)

Checklist pré-commit

  • Tous les fichiers créés/modifiés listés
  • Imports vérifiés (pas de circular dependencies)
  • Types exportés correctement
  • Console.log supprimés (sauf debug temporaire)
  • Zeroize appelé sur K_recovery après usage