NODE: parentPort?.postMessage({ data: { url: threadId.toString(), id, isLocked } })
}
+const _index = new DataView(new ArrayBuffer(4))
+/**
+ * Derives account private keys from the wallet seed using either the BIP-44
+ * derivation algorithm or the BLAKE2b hashing algorithm.
+ *
+ * Separately, account public keys are derived from the private key using the
+ * Ed25519 key algorithm, and account addresses are derived from the public key
+ * as described in the Nano documentation.
+ *
+ * https://docs.nano.org/integration-guides/the-basics/
+ *
+ * @param {number} index - 4-byte index of account to derive
+ * @returns {Promise<ArrayBuffer>} Private key for the account
+*/
function _ckd (index: number): Promise<ArrayBuffer> {
if (_seed == null) {
throw new Error('Wallet seed not found')
return Bip44('Bitcoin seed', _seed, 0x100, index, 0, 0)
}
default: {
- /**
- * Derives account private keys from a wallet seed using the BLAKE2b hashing
- * algorithm.
- *
- * Separately, account public keys are derived from the private key using the
- * Ed25519 key algorithm, and account addresses are derived from the public key
- * as described in the Nano documentation.
- * https://docs.nano.org/integration-guides/the-basics/
- *
- * @param {ArrayBuffer} seed - 32-byte secret seed of the wallet
- * @param {number} index - 4-byte index of account to derive
- * @returns {Promise<ArrayBuffer>} Private key for the account
- */
- const i = new ArrayBuffer(4)
- new DataView(i).setUint32(0, index, false)
- const sk = new Blake2b(32).update(_seed).update(i).digest()
+ _index.setUint32(0, index, false)
+ const sk = new Blake2b(32).update(_seed).update(_index.buffer).digest()
+ _index.setUint32(0, 0)
return Promise.resolve(sk.buffer)
}
}