@ChainSafe/bls-keystore
Typescript implementation of EIP 2335 for node and browser.
How to use?
Functional interface
import {Buffer} from "buffer";
import {
IKeystore,
create,
decrypt,
verifyPassword,
isValidKeystore,
validateKeystore,
} from "@chainsafe/bls-keystore";
const password: string | Uint8Array = "SomePassword123";
const privateKey: Uint8Array = ...;
const publicKey: Uint8Array = ...;
const path: string = "m/12381/60/0/0";
const keystore: IKeystore = await create(password, privateKey, publicKey, path);
await verifyPassword(keystore, password);
const decryptedPrivateKey: Buffer = await decrypt(keystore, password);
JSON.stringify(keystore);
const data: unknown = ...;
isValidKeystore(data);
validateKeystore(data);
Class-based interface
import {Buffer} from "buffer";
import {
Keystore,
} from "@chainsafe/bls-keystore";
const password: string | Uint8Array = "SomePassword123";
const privateKey: Uint8Array = ...;
const publicKey: Uint8Array = ...;
const path: string = "m/12381/60/0/0";
const keystore: Keystore = await Keystore.create(password, privateKey, publicKey, path);
await keystore.verifyPassword(password);
const decryptedPrivateKey: Buffer = await keystore.decrypt(password);
keystore.stringify();
const data: unknown = ...;
Keystore.fromObject(data);
For key derivation checkout @chainsafe/bls-keygen
Contribute
- get yarn
- yarn install
- yarn test