Add docs to HdPath

This commit is contained in:
Simon Warta 2020-12-08 08:40:00 +01:00
parent dec867e0fc
commit 00f734032d
2 changed files with 52 additions and 0 deletions

View File

@ -49,6 +49,32 @@ export class Slip10RawIndex extends Uint32 {
}
}
/**
* An array of raw SLIP10 indices.
*
* This can be constructed via string parsing:
*
* ```ts
* import { stringToPath } from "@cosmjs/crypto";
*
* const path = stringToPath("m/0'/1/2'/2/1000000000");
* ```
*
* or manually:
*
* ```ts
* import { HdPath, Slip10RawIndex } from "@cosmjs/crypto";
*
* // m/0'/1/2'/2/1000000000
* const path: HdPath = [
* Slip10RawIndex.hardened(0),
* Slip10RawIndex.normal(1),
* Slip10RawIndex.hardened(2),
* Slip10RawIndex.normal(2),
* Slip10RawIndex.normal(1000000000),
* ];
* ```
*/
export type HdPath = readonly Slip10RawIndex[];
const secp256k1 = new elliptic.ec("secp256k1");

View File

@ -21,6 +21,32 @@ export declare class Slip10RawIndex extends Uint32 {
static normal(normalIndex: number): Slip10RawIndex;
isHardened(): boolean;
}
/**
* An array of raw SLIP10 indices.
*
* This can be constructed via string parsing:
*
* ```ts
* import { stringToPath } from "@cosmjs/crypto";
*
* const path = stringToPath("m/0'/1/2'/2/1000000000");
* ```
*
* or manually:
*
* ```ts
* import { HdPath, Slip10RawIndex } from "@cosmjs/crypto";
*
* // m/0'/1/2'/2/1000000000
* const path: HdPath = [
* Slip10RawIndex.hardened(0),
* Slip10RawIndex.normal(1),
* Slip10RawIndex.hardened(2),
* Slip10RawIndex.normal(2),
* Slip10RawIndex.normal(1000000000),
* ];
* ```
*/
export declare type HdPath = readonly Slip10RawIndex[];
export declare class Slip10 {
static derivePath(curve: Slip10Curve, seed: Uint8Array, path: HdPath): Slip10Result;