ts-slip32
Installation
From npm:
npm install slip32
From git:
git clone https://github.com/witnet/ts-slip32.git
cd ts-slip32
yarn
yarn build
Usage
The main two functions are described in slip32.d.ts
:
export declare const importKeyFromSlip32: (slip32: string) => {
keyPath: number[];
extendedKey: ExtendedKey<PrivateKey | PublicKey>;
};
export declare const exportKeyToSlip32: (keyPath: number[], extendedKey: ExtendedKey<PrivateKey | PublicKey>) => string;
The aforementioned functions use the following interfaces and types, defined in keys.d.ts
:
export interface Key {
bytes: Uint8Array;
}
export declare type ChainCode = Uint8Array;
export interface PrivateKey extends Key {
type: "private";
}
export interface PublicKey extends Key {
type: "public";
}
export declare type ExtendedKey<Key> = {
key: Key;
chainCode: ChainCode;
};
Example
import * as Slip32 from "slip32"
const keyToImport = "xprv1qxqqqqqq78qr7hlewyyfzt74vasa87k63pu7g9e6hfzlzrdyh0v5k8zfw9sqpsyv7vcejeyzcpkm85jel7vmujlhpquzf4f3sh3nry0w0n4jh7t0jhc039"
const importedKey = Slip32.importKeyFromSlip32(keyToImport)
const exportedKey = Slip32.exportKeyToSlip32(importedKey.keyPath, importedKey.extendedKey)
License
This library is free and open-source software released under the MIT license.