ci: docker_tag=dev-test

**Motivations :**
- Correction du chiffrement : PBKDF2 génère les clés du SDK, pas des clés personnalisées
- WebAuthn chiffre maintenant les clés du SDK générées par PBKDF2
- Ajout de getDeviceFromSDK() pour récupérer les clés du SDK

**Modifications :**
- Remplacement de generateSpendKey/generateScanKey par getDeviceFromSDK()
- WebAuthn chiffre maintenant device.sp_wallet.spend_key et device.sp_wallet.scan_key
- Ajout de la méthode getDeviceFromSDK() pour accéder au SDK

**Pages affectées :**
- src/services/secure-credentials.service.ts
This commit is contained in:
NicolasCantu 2025-10-24 01:57:30 +02:00
parent 3f387ee97f
commit 4a3b23c9d7
3 changed files with 81 additions and 64 deletions

View File

@ -137,13 +137,15 @@ export class SecureCredentialsService {
const publicKey = response.getPublicKey(); const publicKey = response.getPublicKey();
const credentialId = credential.id; const credentialId = credential.id;
// Générer les clés privées réelles (spend/scan) avec PBKDF2 // Récupérer les clés du SDK générées par PBKDF2
const spendKey = await this.generateSpendKey(password); const device = await this.getDeviceFromSDK();
const scanKey = await this.generateScanKey(password); if (!device || !device.sp_wallet) {
throw new Error('SDK device not found or wallet not initialized');
}
// Chiffrer les clés privées avec la clé WebAuthn // Chiffrer les clés du SDK avec la clé WebAuthn
const encryptedSpendKey = await this.encryptWithWebAuthn(spendKey, publicKey, credentialId); const encryptedSpendKey = await this.encryptWithWebAuthn(device.sp_wallet.spend_key, publicKey, credentialId);
const encryptedScanKey = await this.encryptWithWebAuthn(scanKey, publicKey, credentialId); const encryptedScanKey = await this.encryptWithWebAuthn(device.sp_wallet.scan_key, publicKey, credentialId);
const credentialData: CredentialData = { const credentialData: CredentialData = {
spendKey: encryptedSpendKey, // Clé chiffrée spendKey: encryptedSpendKey, // Clé chiffrée
@ -173,6 +175,21 @@ export class SecureCredentialsService {
} }
} }
/**
* Récupère le device du SDK pour obtenir les clés générées par PBKDF2
*/
private async getDeviceFromSDK(): Promise<any> {
try {
// Importer le service pour accéder au SDK
const { Services } = await import('./service');
const service = await Services.getInstance();
return service.dumpDeviceFromMemory();
} catch (error) {
console.error('❌ Failed to get device from SDK:', error);
throw error;
}
}
/** /**
* Génère une clé spend avec PBKDF2 * Génère une clé spend avec PBKDF2
*/ */