static HARDENED_OFFSET = 0x80000000
static SLIP10_ED25519 = 'ed25519 seed'
- /**
- * Derives a private child key following the BIP-32 and BIP-44 derivation path
- * registered to the Nano block lattice. Only hardened child keys are defined.
- *
- * @param {ArrayBuffer} seed - Hexadecimal seed derived from mnemonic phrase
- * @param {number} index - Account number between 0 and 2^31-1
- * @returns {Promise<ArrayBuffer>} Private child key for the account
- */
- static async nanoCKD (seed: ArrayBuffer, index: number): Promise<ArrayBuffer> {
- return await this.ckd(seed, this.BIP44_COIN_NANO, index)
- }
-
/**
* Derives a private child key for a coin by following the specified BIP-32 and
- * BIP-44 derivation path. Purpose is always 44'. Coin defaults to Nano. Only
- * hardened child keys are defined.
+ * BIP-44 derivation path. Purpose is always 44'. Only hardened child keys are
+ * defined.
*
* @param {ArrayBuffer} seed - Hexadecimal seed derived from mnemonic phrase
- * @param {number} coin - Number registered to a specific coin in SLIP-044
* @param {number} index - Account number between 0 and 2^31-1
+ * @param {number} coin - Number registered to a specific coin in SLIP-044. Default: 165 (Nano)
* @returns {Promise<ArrayBuffer>} Private child key for the account
*/
- static async ckd (seed: ArrayBuffer, coin: number = this.BIP44_COIN_NANO, index: number): Promise<ArrayBuffer> {
+ static async ckd (seed: ArrayBuffer, index: number, coin: number = this.BIP44_COIN_NANO): Promise<ArrayBuffer> {
if (seed.byteLength < 16 || seed.byteLength > 64) {
throw new RangeError(`Invalid seed length`)
}
throw new Error('Invalid wallet account index')
}
const prv = this.#type === 'BIP-44'
- ? await Bip44Ckd.nanoCKD(this.#seed, index)
+ ? await Bip44Ckd.ckd(this.#seed, index)
: await Blake2bCkd.ckd(this.#seed, index)
const pub = await NanoNaCl.convert(new Uint8Array(prv))
return { index, publicKey: pub.buffer }
if (data == null) {
throw new Error('Data to sign not found')
}
- const prv = await Bip44Ckd.nanoCKD(this.#seed, index)
+ const prv = await Bip44Ckd.ckd(this.#seed, index)
const sig = await NanoNaCl.detached(new Uint8Array(data), new Uint8Array(prv))
return { signature: sig.buffer }
} catch (err) {