Merge pull request #566 from cosmos/HdPath-docs

Add docs to HdPath
This commit is contained in:
Will Clark 2020-12-08 11:03:27 +01:00 committed by GitHub
commit 14a6527213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;