const promises = []
const values = typeof index === 'number' ? [index] : index.values()
for (const i of values) {
- promises.push(_ckd(i).then(result => {
- const prv = new Uint8Array(result)
- const pub = nano25519_derive(prv)
- prv.fill(0)
- return { index: i, publicKey: pub.buffer }
- }))
+ const prv = new Uint8Array(32)
+ promises.push(_ckd(i)
+ .then(result => {
+ prv.set(result)
+ result.fill(0)
+ const pub = nano25519_derive(prv)
+ return { index: i, publicKey: pub.buffer }
+ })
+ .finally(() => {
+ prv.fill(0)
+ })
+ )
}
return Promise.all(promises)
.then(results => {
}
if (data == null) {
throw new VaultError('Data to sign not found')
- }
+ const prv = new Uint8Array(32)
return _ckd(index[0])
.then(result => {
- const prv = new Uint8Array(result)
+ prv.set(result)
+ result.fill(0)
const pub = nano25519_derive(prv)
const sk = new Uint8Array([...prv, ...pub])
prv.fill(0)
_timer.resume()
throw new VaultError('Failed to sign message', { cause: err })
})
+ .finally (() => {
+ prv.fill(0)
+ })
} catch (err) {
console.error(err)
_timer.resume()