w3pk 0.9.3 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/index.d.mts +213 -1
- package/dist/index.d.ts +213 -1
- package/dist/index.js +102 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -102
- package/dist/index.mjs.map +1 -1
- package/docs/API_REFERENCE.md +269 -1
- package/docs/ARCHITECTURE.md +42 -45
- package/docs/POST_QUANTUM.md +288 -3
- package/docs/SECURITY.md +239 -20
- package/package.json +13 -10
package/docs/API_REFERENCE.md
CHANGED
|
@@ -20,6 +20,7 @@ Complete reference for all methods, types, and utilities in the w3pk SDK.
|
|
|
20
20
|
- [Standalone Utilities](#standalone-utilities)
|
|
21
21
|
- [Validation Utilities](#validation-utilities)
|
|
22
22
|
- [Build Verification Utilities](#build-verification-utilities)
|
|
23
|
+
- [Post-Quantum Cryptography](#post-quantum-cryptography)
|
|
23
24
|
- [Wallet Generation Utilities](#wallet-generation-utilities)
|
|
24
25
|
- [Security Inspection](#security-inspection)
|
|
25
26
|
- [Browser Inspection](#browser-inspection)
|
|
@@ -1613,6 +1614,8 @@ const w3pk = createWeb3Passkey({
|
|
|
1613
1614
|
|
|
1614
1615
|
All stealth address methods are accessed via `w3pk.stealth.*`
|
|
1615
1616
|
|
|
1617
|
+
> **🔒 Security Note:** The ERC-5564 implementation properly reduces all scalars modulo the secp256k1 curve order to prevent unspendable funds. The same reduced scalar is used consistently in both public-key operations (`s_h × G`) and private-key operations (`spendingKey + s_h`) to ensure the derived stealth address always matches the derived private key.
|
|
1618
|
+
|
|
1616
1619
|
### `stealth.generateStealthAddress(options?: { requireAuth?: boolean }): Promise<StealthAddressResult>`
|
|
1617
1620
|
|
|
1618
1621
|
Generate a fresh ERC-5564 compliant stealth address for a recipient.
|
|
@@ -3207,7 +3210,89 @@ console.log(encoded) // => SGVsbG8gV29ybGQ=
|
|
|
3207
3210
|
### Cryptographic Utilities
|
|
3208
3211
|
|
|
3209
3212
|
```typescript
|
|
3210
|
-
import {
|
|
3213
|
+
import {
|
|
3214
|
+
extractRS,
|
|
3215
|
+
deriveEncryptionKeyFromWebAuthn,
|
|
3216
|
+
generateSalt
|
|
3217
|
+
} from 'w3pk'
|
|
3218
|
+
```
|
|
3219
|
+
|
|
3220
|
+
#### `deriveEncryptionKeyFromWebAuthn(prfOutput: ArrayBuffer, salt: Uint8Array): Promise<CryptoKey>`
|
|
3221
|
+
|
|
3222
|
+
**🔐 SECURE - WebAuthn PRF-based encryption**
|
|
3223
|
+
|
|
3224
|
+
Derives an AES-256-GCM encryption key from WebAuthn PRF (Pseudo-Random Function) extension output.
|
|
3225
|
+
|
|
3226
|
+
**Security:**
|
|
3227
|
+
- Uses authenticator-held secrets via PRF extension (never exposed)
|
|
3228
|
+
- Implements random unique salts (no precomputation attacks)
|
|
3229
|
+
- PBKDF2 with 210,000 iterations (OWASP 2023 recommendation)
|
|
3230
|
+
- Prevents offline decryption attacks
|
|
3231
|
+
|
|
3232
|
+
**Parameters:**
|
|
3233
|
+
- `prfOutput: ArrayBuffer` - 32-byte secret from WebAuthn PRF extension
|
|
3234
|
+
- `salt: Uint8Array` - 32-byte random salt (generate with `generateSalt()`)
|
|
3235
|
+
|
|
3236
|
+
**Returns:** `Promise<CryptoKey>` - AES-256-GCM key for encryption/decryption
|
|
3237
|
+
|
|
3238
|
+
**Example:**
|
|
3239
|
+
```typescript
|
|
3240
|
+
// 1. Enable PRF during WebAuthn registration
|
|
3241
|
+
const credential = await navigator.credentials.create({
|
|
3242
|
+
publicKey: {
|
|
3243
|
+
challenge: new Uint8Array(32),
|
|
3244
|
+
rp: { name: "Example" },
|
|
3245
|
+
user: { id: userId, name: "user", displayName: "User" },
|
|
3246
|
+
pubKeyCredParams: [{ alg: -7, type: "public-key" }],
|
|
3247
|
+
extensions: {
|
|
3248
|
+
prf: {} // Enable PRF extension
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
});
|
|
3252
|
+
|
|
3253
|
+
// 2. Get PRF output during authentication
|
|
3254
|
+
const assertion = await navigator.credentials.get({
|
|
3255
|
+
publicKey: {
|
|
3256
|
+
challenge: new Uint8Array(32),
|
|
3257
|
+
extensions: {
|
|
3258
|
+
prf: {
|
|
3259
|
+
eval: {
|
|
3260
|
+
first: new Uint8Array(32) // Salt for PRF
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
});
|
|
3266
|
+
|
|
3267
|
+
const prfOutput = assertion.getClientExtensionResults().prf.results.first;
|
|
3268
|
+
|
|
3269
|
+
// 3. Generate and store salt
|
|
3270
|
+
const salt = generateSalt(); // Store this with your ciphertext
|
|
3271
|
+
|
|
3272
|
+
// 4. Derive encryption key
|
|
3273
|
+
const encryptionKey = await deriveEncryptionKeyFromWebAuthn(
|
|
3274
|
+
prfOutput,
|
|
3275
|
+
salt
|
|
3276
|
+
);
|
|
3277
|
+
|
|
3278
|
+
// 5. Encrypt sensitive data
|
|
3279
|
+
const encrypted = await crypto.subtle.encrypt(
|
|
3280
|
+
{ name: "AES-GCM", iv: crypto.getRandomValues(new Uint8Array(12)) },
|
|
3281
|
+
encryptionKey,
|
|
3282
|
+
new TextEncoder().encode("secret data")
|
|
3283
|
+
);
|
|
3284
|
+
```
|
|
3285
|
+
|
|
3286
|
+
#### `generateSalt(): Uint8Array`
|
|
3287
|
+
|
|
3288
|
+
Generates a cryptographically secure random 32-byte salt for encryption.
|
|
3289
|
+
|
|
3290
|
+
**Returns:** `Uint8Array` - 32 random bytes
|
|
3291
|
+
|
|
3292
|
+
**Example:**
|
|
3293
|
+
```typescript
|
|
3294
|
+
const salt = generateSalt();
|
|
3295
|
+
// Store salt alongside ciphertext for later decryption
|
|
3211
3296
|
```
|
|
3212
3297
|
|
|
3213
3298
|
#### `extractRS(derSignature: Uint8Array): { r: string; s: string }`
|
|
@@ -3265,6 +3350,189 @@ This ensures compatibility with Ethereum's signature malleability protection.
|
|
|
3265
3350
|
|
|
3266
3351
|
---
|
|
3267
3352
|
|
|
3353
|
+
### Post-Quantum Cryptography
|
|
3354
|
+
|
|
3355
|
+
w3pk provides ML-KEM-1024 encryption both as instance methods (recommended) and standalone functions.
|
|
3356
|
+
|
|
3357
|
+
#### Instance Methods (Recommended)
|
|
3358
|
+
|
|
3359
|
+
Use these methods with your w3pk wallet instance - no private key exposure:
|
|
3360
|
+
|
|
3361
|
+
##### `w3pk.deriveMLKemPublicKey(options?): Promise<string>`
|
|
3362
|
+
|
|
3363
|
+
Derive your ML-KEM-1024 public key for sharing with others.
|
|
3364
|
+
|
|
3365
|
+
**Parameters:**
|
|
3366
|
+
```typescript
|
|
3367
|
+
{
|
|
3368
|
+
context?: string; // Domain separation (default: 'mlkem-v1')
|
|
3369
|
+
mode?: SecurityMode; // 'STANDARD', 'STRICT', or 'YOLO' (default: 'STANDARD')
|
|
3370
|
+
tag?: string; // Address derivation tag (default: 'MAIN')
|
|
3371
|
+
origin?: string; // Origin (default: current origin)
|
|
3372
|
+
requireAuth?: boolean; // Force re-auth (default: false, always true in STRICT)
|
|
3373
|
+
}
|
|
3374
|
+
```
|
|
3375
|
+
|
|
3376
|
+
**Returns:** Base64-encoded public key (1568 bytes)
|
|
3377
|
+
|
|
3378
|
+
**Example:**
|
|
3379
|
+
```typescript
|
|
3380
|
+
const w3pk = createWeb3Passkey();
|
|
3381
|
+
await w3pk.login();
|
|
3382
|
+
|
|
3383
|
+
const myPubKey = await w3pk.deriveMLKemPublicKey();
|
|
3384
|
+
// Share myPubKey with others
|
|
3385
|
+
```
|
|
3386
|
+
|
|
3387
|
+
**Note:** PRIMARY mode not supported (uses P-256 WebAuthn keys).
|
|
3388
|
+
|
|
3389
|
+
---
|
|
3390
|
+
|
|
3391
|
+
##### `w3pk.mlkemEncrypt(plaintext: string, recipientPublicKeys: Array<string | Uint8Array>, options?): Promise<EncryptedPayload>`
|
|
3392
|
+
|
|
3393
|
+
Encrypt data for yourself and additional recipients.
|
|
3394
|
+
|
|
3395
|
+
**Parameters:**
|
|
3396
|
+
```typescript
|
|
3397
|
+
{
|
|
3398
|
+
context?: string; // Domain separation (default: 'mlkem-v1')
|
|
3399
|
+
mode?: SecurityMode; // Security mode (default: 'STANDARD')
|
|
3400
|
+
tag?: string; // Tag (default: 'MAIN')
|
|
3401
|
+
origin?: string; // Origin (default: current)
|
|
3402
|
+
requireAuth?: boolean; // Force re-auth (default: false)
|
|
3403
|
+
}
|
|
3404
|
+
```
|
|
3405
|
+
|
|
3406
|
+
**Example:**
|
|
3407
|
+
```typescript
|
|
3408
|
+
const serverPubKey = await fetch('/api/mlkem-key').then(r => r.text());
|
|
3409
|
+
|
|
3410
|
+
const encrypted = await w3pk.mlkemEncrypt(
|
|
3411
|
+
'my secret data',
|
|
3412
|
+
[serverPubKey] // You + server can both decrypt
|
|
3413
|
+
);
|
|
3414
|
+
```
|
|
3415
|
+
|
|
3416
|
+
---
|
|
3417
|
+
|
|
3418
|
+
##### `w3pk.mlkemDecrypt(payload: EncryptedPayload, options?): Promise<string>`
|
|
3419
|
+
|
|
3420
|
+
Decrypt data encrypted for your wallet.
|
|
3421
|
+
|
|
3422
|
+
**Parameters:** Same options as `mlkemEncrypt`
|
|
3423
|
+
|
|
3424
|
+
**Example:**
|
|
3425
|
+
```typescript
|
|
3426
|
+
const plaintext = await w3pk.mlkemDecrypt(encrypted);
|
|
3427
|
+
```
|
|
3428
|
+
|
|
3429
|
+
---
|
|
3430
|
+
|
|
3431
|
+
#### Standalone Functions
|
|
3432
|
+
|
|
3433
|
+
Low-level functions for direct key management:
|
|
3434
|
+
|
|
3435
|
+
```typescript
|
|
3436
|
+
import { mlkemEncrypt, mlkemDecrypt, deriveMLKemKeypair, type EncryptedPayload } from 'w3pk'
|
|
3437
|
+
```
|
|
3438
|
+
|
|
3439
|
+
##### `deriveMLKemKeypair(privateKey: string | Uint8Array, context?: string): Promise<MLKemKeypair>`
|
|
3440
|
+
|
|
3441
|
+
Derive deterministic ML-KEM keypair from any private key using HKDF-SHA256.
|
|
3442
|
+
|
|
3443
|
+
**Parameters:**
|
|
3444
|
+
- `privateKey` - Ethereum private key (hex with optional `0x` prefix or Uint8Array)
|
|
3445
|
+
- `context` - Context string for domain separation (default: `'mlkem-v1'`)
|
|
3446
|
+
|
|
3447
|
+
**Returns:**
|
|
3448
|
+
```typescript
|
|
3449
|
+
{
|
|
3450
|
+
publicKey: Uint8Array; // 1568 bytes
|
|
3451
|
+
privateKey: Uint8Array; // 3168 bytes
|
|
3452
|
+
}
|
|
3453
|
+
```
|
|
3454
|
+
|
|
3455
|
+
**Example:**
|
|
3456
|
+
```typescript
|
|
3457
|
+
const keypair = await deriveMLKemKeypair('0x1234...', 'my-app');
|
|
3458
|
+
```
|
|
3459
|
+
|
|
3460
|
+
---
|
|
3461
|
+
|
|
3462
|
+
##### `mlkemEncrypt(plaintext: string, publicKeys: (string | Uint8Array) | Array<string | Uint8Array>): Promise<EncryptedPayload>`
|
|
3463
|
+
|
|
3464
|
+
Encrypt data using ML-KEM-1024 (post-quantum KEM) + AES-256-GCM for one or more recipients.
|
|
3465
|
+
|
|
3466
|
+
**Parameters:**
|
|
3467
|
+
- `plaintext: string` - The data to encrypt
|
|
3468
|
+
- `publicKeys: (string | Uint8Array) | Array<string | Uint8Array>` - Single public key or array of ML-KEM-1024 public keys (1568 bytes each)
|
|
3469
|
+
|
|
3470
|
+
**Returns:**
|
|
3471
|
+
```typescript
|
|
3472
|
+
{
|
|
3473
|
+
recipients: Array<{
|
|
3474
|
+
publicKey: string; // Base64 recipient public key (1568 bytes)
|
|
3475
|
+
ciphertext: string; // Base64 ML-KEM ciphertext for this recipient (1600 bytes)
|
|
3476
|
+
}>;
|
|
3477
|
+
encryptedData: string; // Base64 AES-encrypted data (shared across all recipients)
|
|
3478
|
+
iv: string; // Base64 initialization vector (12 bytes)
|
|
3479
|
+
authTag: string; // Base64 authentication tag (16 bytes)
|
|
3480
|
+
}
|
|
3481
|
+
```
|
|
3482
|
+
|
|
3483
|
+
**Example:**
|
|
3484
|
+
|
|
3485
|
+
```typescript
|
|
3486
|
+
import { mlkemEncrypt } from 'w3pk'
|
|
3487
|
+
|
|
3488
|
+
// Single recipient
|
|
3489
|
+
const encrypted = await mlkemEncrypt('my secret data', publicKey1)
|
|
3490
|
+
|
|
3491
|
+
// Multiple recipients
|
|
3492
|
+
const encrypted = await mlkemEncrypt('my secret data', [publicKey1, publicKey2, publicKey3])
|
|
3493
|
+
|
|
3494
|
+
console.log('Recipients:', encrypted.recipients.length)
|
|
3495
|
+
```
|
|
3496
|
+
|
|
3497
|
+
**Security:**
|
|
3498
|
+
- ✅ **Quantum-resistant** - ML-KEM-1024 (NIST FIPS 203)
|
|
3499
|
+
- ✅ **Multi-recipient support** - Encrypt once for multiple recipients
|
|
3500
|
+
- ✅ **Key zeroization** - All secrets securely wiped from memory
|
|
3501
|
+
- ✅ **Authenticated encryption** - AES-256-GCM with 128-bit auth tag
|
|
3502
|
+
|
|
3503
|
+
---
|
|
3504
|
+
|
|
3505
|
+
#### `mlkemDecrypt(payload: EncryptedPayload, privateKey: string | Uint8Array, publicKey?: string | Uint8Array): Promise<string>`
|
|
3506
|
+
|
|
3507
|
+
Decrypt data encrypted with `mlkemEncrypt()`.
|
|
3508
|
+
|
|
3509
|
+
**Parameters:**
|
|
3510
|
+
- `payload: EncryptedPayload` - The encrypted payload from `mlkemEncrypt()`
|
|
3511
|
+
- `privateKey: string | Uint8Array` - ML-KEM-1024 private key (3168 bytes)
|
|
3512
|
+
- `publicKey?: string | Uint8Array` - (Optional) Your public key for faster recipient lookup (1568 bytes)
|
|
3513
|
+
|
|
3514
|
+
**Returns:** `string` - Decrypted plaintext
|
|
3515
|
+
|
|
3516
|
+
**Example:**
|
|
3517
|
+
|
|
3518
|
+
```typescript
|
|
3519
|
+
import { mlkemDecrypt } from 'w3pk'
|
|
3520
|
+
|
|
3521
|
+
// Auto-detect which recipient you are
|
|
3522
|
+
const plaintext = await mlkemDecrypt(encrypted, privateKey)
|
|
3523
|
+
|
|
3524
|
+
// Or specify your public key for faster lookup
|
|
3525
|
+
const plaintext = await mlkemDecrypt(encrypted, privateKey, myPublicKey)
|
|
3526
|
+
```
|
|
3527
|
+
|
|
3528
|
+
**Throws:** Error if decryption fails (invalid key, no matching recipient, corrupted data, or tampered auth tag)
|
|
3529
|
+
|
|
3530
|
+
**Related:**
|
|
3531
|
+
- See [POST_QUANTUM.md](../docs/POST_QUANTUM.md) for full quantum readiness roadmap
|
|
3532
|
+
- See [NIST FIPS 203](https://csrc.nist.gov/pubs/fips/203/final) for ML-KEM specification
|
|
3533
|
+
|
|
3534
|
+
---
|
|
3535
|
+
|
|
3268
3536
|
### Wallet Generation Utilities
|
|
3269
3537
|
|
|
3270
3538
|
```typescript
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -148,33 +148,42 @@ m/44'/60'/0'/0/2 ← Third address
|
|
|
148
148
|
|
|
149
149
|
**Purpose**: Link WebAuthn authentication to wallet encryption
|
|
150
150
|
|
|
151
|
-
**Implementation**: [src/wallet/crypto.ts
|
|
151
|
+
**Implementation**: [src/wallet/crypto.ts](src/wallet/crypto.ts)
|
|
152
|
+
|
|
153
|
+
✅ **SECURITY**: Uses PRF-based encryption with authenticator-held secrets and random salts
|
|
152
154
|
|
|
153
|
-
**
|
|
155
|
+
**SECURE Implementation (PRF-based)**:
|
|
154
156
|
```typescript
|
|
155
157
|
function deriveEncryptionKeyFromWebAuthn(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
prfOutput: ArrayBuffer, // From WebAuthn PRF extension
|
|
159
|
+
salt: Uint8Array // Random 32-byte salt
|
|
158
160
|
): CryptoKey {
|
|
159
|
-
// Step 1:
|
|
160
|
-
|
|
161
|
+
// Step 1: Validate inputs
|
|
162
|
+
assert(prfOutput.byteLength === 32);
|
|
163
|
+
assert(salt.byteLength === 32);
|
|
161
164
|
|
|
162
|
-
// Step 2:
|
|
163
|
-
const
|
|
165
|
+
// Step 2: Import PRF output (authenticator-held secret)
|
|
166
|
+
const keyMaterial = importKey(prfOutput);
|
|
164
167
|
|
|
165
|
-
// Step 3: PBKDF2 key derivation
|
|
166
|
-
const encryptionKey = PBKDF2(
|
|
168
|
+
// Step 3: PBKDF2 key derivation with random salt
|
|
169
|
+
const encryptionKey = PBKDF2(keyMaterial, salt, 210000);
|
|
167
170
|
|
|
168
171
|
// Result: AES-256-GCM key (NEVER STORED)
|
|
169
172
|
return encryptionKey;
|
|
170
173
|
}
|
|
171
174
|
```
|
|
172
175
|
|
|
173
|
-
**Properties**:
|
|
174
|
-
- **
|
|
175
|
-
- **
|
|
176
|
-
- **
|
|
177
|
-
- **
|
|
176
|
+
**Security Properties**:
|
|
177
|
+
- **Authenticator Secret**: Uses PRF output from hardware (never exposed to application)
|
|
178
|
+
- **Random Salts**: Each encryption uses unique 32-byte salt (prevents precomputation)
|
|
179
|
+
- **PBKDF2**: 210,000 iterations (OWASP 2023 recommendation)
|
|
180
|
+
- **AES-256-GCM**: Strong authenticated encryption
|
|
181
|
+
- **Authentication-gated**: Requires biometric/PIN to trigger PRF
|
|
182
|
+
|
|
183
|
+
**Implementation Note**:
|
|
184
|
+
The SDK uses `deriveEncryptionKeyAuto()` as a helper that:
|
|
185
|
+
1. Uses PRF-based encryption when available (secure)
|
|
186
|
+
2. Falls back to v2 implementation for existing wallets without PRF support
|
|
178
187
|
|
|
179
188
|
---
|
|
180
189
|
|
|
@@ -217,11 +226,12 @@ STEP 2: Create WebAuthn Credential (INDEPENDENT)
|
|
|
217
226
|
|
|
218
227
|
STEP 3: Derive Encryption Key
|
|
219
228
|
┌──────────────────────────────────────┐
|
|
220
|
-
│
|
|
229
|
+
│ deriveEncryptionKeyFromWebAuthn() │
|
|
221
230
|
│ │
|
|
222
|
-
│
|
|
231
|
+
│ Input: PRF output (32 bytes secret) │
|
|
232
|
+
│ + random salt (32 bytes) │
|
|
223
233
|
│ ↓ │
|
|
224
|
-
│
|
|
234
|
+
│ Import PRF as key material │
|
|
225
235
|
│ ↓ │
|
|
226
236
|
│ PBKDF2 (210,000 iterations) │
|
|
227
237
|
│ ↓ │
|
|
@@ -486,43 +496,29 @@ const signedTx = await wallet.signTransaction(tx);
|
|
|
486
496
|
**Implementation**: [src/wallet/crypto.ts:21-66](src/wallet/crypto.ts#L21-L66)
|
|
487
497
|
|
|
488
498
|
```javascript
|
|
499
|
+
// SECURE: PRF-based key derivation
|
|
489
500
|
async function deriveEncryptionKeyFromWebAuthn(
|
|
490
|
-
|
|
491
|
-
|
|
501
|
+
prfOutput: ArrayBuffer, // From WebAuthn PRF extension
|
|
502
|
+
salt: Uint8Array // Random 32-byte salt
|
|
492
503
|
): Promise<CryptoKey> {
|
|
493
|
-
// 1.
|
|
494
|
-
const keyMaterial =
|
|
495
|
-
|
|
496
|
-
// 2. SHA-256 hash
|
|
497
|
-
const keyMaterialHash = await crypto.subtle.digest(
|
|
498
|
-
"SHA-256",
|
|
499
|
-
new TextEncoder().encode(keyMaterial)
|
|
500
|
-
);
|
|
501
|
-
|
|
502
|
-
// 3. Import as PBKDF2 base key
|
|
503
|
-
const importedKey = await crypto.subtle.importKey(
|
|
504
|
+
// 1. Import PRF output as key material (authenticator secret)
|
|
505
|
+
const keyMaterial = await crypto.subtle.importKey(
|
|
504
506
|
"raw",
|
|
505
|
-
|
|
507
|
+
prfOutput, // SECRET from authenticator
|
|
506
508
|
{ name: "PBKDF2" },
|
|
507
509
|
false,
|
|
508
510
|
["deriveKey"]
|
|
509
511
|
);
|
|
510
512
|
|
|
511
|
-
//
|
|
512
|
-
const salt = await crypto.subtle.digest(
|
|
513
|
-
"SHA-256",
|
|
514
|
-
new TextEncoder().encode("w3pk-salt-v4")
|
|
515
|
-
);
|
|
516
|
-
|
|
517
|
-
// 5. Derive AES-256-GCM key
|
|
513
|
+
// 2. Derive AES-256-GCM key with PBKDF2
|
|
518
514
|
return crypto.subtle.deriveKey(
|
|
519
515
|
{
|
|
520
516
|
name: "PBKDF2",
|
|
521
|
-
salt:
|
|
517
|
+
salt: salt, // Random 32-byte salt (stored with ciphertext)
|
|
522
518
|
iterations: 210000, // OWASP 2023 recommendation
|
|
523
519
|
hash: "SHA-256",
|
|
524
520
|
},
|
|
525
|
-
|
|
521
|
+
keyMaterial, // PRF output from authenticator
|
|
526
522
|
{ name: "AES-GCM", length: 256 },
|
|
527
523
|
false,
|
|
528
524
|
["encrypt", "decrypt"]
|
|
@@ -530,11 +526,12 @@ async function deriveEncryptionKeyFromWebAuthn(
|
|
|
530
526
|
}
|
|
531
527
|
```
|
|
532
528
|
|
|
533
|
-
**Properties**:
|
|
534
|
-
- **
|
|
535
|
-
- **
|
|
529
|
+
**Security Properties**:
|
|
530
|
+
- **Authenticator-Bound**: PRF output is hardware-held secret (never exposed)
|
|
531
|
+
- **Unique Salts**: Each encryption uses random salt (no precomputation)
|
|
532
|
+
- **Strong KDF**: 210,000 PBKDF2 iterations make brute-force impractical (OWASP 2023)
|
|
536
533
|
- **Stateless**: No need to store the encryption key
|
|
537
|
-
- **Fast
|
|
534
|
+
- **Fast**: ~100-200ms on modern devices
|
|
538
535
|
|
|
539
536
|
---
|
|
540
537
|
|