// restrict iv to 96 bits per GCM best practice
const iv = crypto.getRandomValues(new Uint8Array(12)).buffer
const additionalData = utf8.toBuffer(`${type};${id}`)
- const encoded = new Uint8Array([...new Uint8Array(seed), ...new Uint8Array(mnemonic ?? [])])
+ const s = new Uint8Array(seed)
+ const m = new Uint8Array(mnemonic ?? [])
+ const encoded = new Uint8Array([...s, ...m])
+ s.fill(0)
+ m.fill(0)
return crypto.subtle
.encrypt({ name: 'AES-GCM', iv, additionalData }, key, encoded)
.then(encrypted => {
encoded.fill(0)
+ key
return { iv, encrypted }
})
}