* @param {number} account - Account number between 0 and 2^31-1
* @param {number} [change] - Used for change transactions, 0 for external and 1 for internal
* @param {number} [address] - Sequentially increasing index of addresses to use for each account
- * @returns {Promise<ArrayBuffer>} Private child key for the account
+ * @returns {Promise<Bytes>} Private child key for the account
*/
-export function Bip44 (curve: Curve, seed: ArrayBuffer, coin: number, account: number, change?: number, address?: number): Promise<ArrayBuffer>
-export function Bip44 (curve: unknown, seed: unknown, coin: unknown, account: unknown, change?: unknown, address?: unknown): Promise<ArrayBuffer> {
+export function Bip44 (curve: Curve, seed: ArrayBuffer, coin: number, account: number, change?: number, address?: number): Promise<Bytes>
+export function Bip44 (curve: unknown, seed: unknown, coin: unknown, account: unknown, change?: unknown, address?: unknown): Promise<Bytes> {
if (curve !== 'Bitcoin seed' && curve !== 'ed25519 seed') {
throw new TypeError(`Unsupported curve ${curve}`)
}
if (address !== undefined && (!Number.isSafeInteger(address) || address < 0 || address > 0x7fffffff)) {
throw new RangeError(`Invalid address index 0x${dec.toHex(account)}`)
}
- return ckd(curve, seed, coin, account, change, address)
+ return new Uint8Array(ckd(curve, seed, coin, account, change, address))
}
function ckd (curve: Curve, seed: ArrayBuffer, coin: number, account: number, change?: number, address?: number): Promise<ArrayBuffer> {
* 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
+ * @returns {Promise<Bytes>} Private key for the account
*/
-function _ckd (index?: number): Promise<ArrayBuffer> {
+function _ckd (index?: number): Promise<Bytes> {
if (_seed == null) {
throw new VaultError('Wallet seed not found')
}
_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)
+ return Promise.resolve(sk)
}
}
}