https://github.com/chainsafe/bls-keystore
Implementation of bls keystore - EIP 2335
https://github.com/chainsafe/bls-keystore
bls eip2335 eth2 ethereum
Last synced: 3 months ago
JSON representation
Implementation of bls keystore - EIP 2335
- Host: GitHub
- URL: https://github.com/chainsafe/bls-keystore
- Owner: ChainSafe
- License: mit
- Created: 2019-11-07T07:45:22.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-07-15T21:23:27.000Z (over 1 year ago)
- Last Synced: 2025-10-02T02:53:25.667Z (4 months ago)
- Topics: bls, eip2335, eth2, ethereum
- Language: TypeScript
- Homepage:
- Size: 593 KB
- Stars: 29
- Watchers: 13
- Forks: 7
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# @ChainSafe/bls-keystore


[](https://opensource.org/licenses/MIT)


> Typescript implementation of [EIP 2335](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2335.md) for node and browser.
### How to use?
Functional interface
```typescript
import {
IKeystore,
create,
decrypt,
verifyPassword,
isValidKeystore,
validateKeystore,
} from "@chainsafe/bls-keystore";
// encrypt private key
const password: string | Uint8Array = "SomePassword123";
const privateKey: Uint8Array = ...;
const publicKey: Uint8Array = ...;
const path: string = "m/12381/60/0/0";
// keystore is an `object` that follows the EIP-2335 schema
const keystore: IKeystore = await create(password, privateKey, publicKey, path);
// verify password
await verifyPassword(keystore, password); //true | false
// decrypt
const decryptedPrivateKey: Uint8Array = await decrypt(keystore, password);
// convert to string
JSON.stringify(keystore); //string
// determine if unsanitized data fits the EIP-2335 schema
const data: unknown = ...;
isValidKeystore(data); // true | false
validateKeystore(data); // throws if invalid
```
Class-based interface
```typescript
import {
Keystore,
} from "@chainsafe/bls-keystore";
// encrypt private key
const password: string | Uint8Array = "SomePassword123";
const privateKey: Uint8Array = ...;
const publicKey: Uint8Array = ...;
const path: string = "m/12381/60/0/0";
// keystore is a `Keystore` instance that follows the EIP-2335 schema with additional convenience methods
const keystore: Keystore = await Keystore.create(password, privateKey, publicKey, path);
// verify password
await keystore.verifyPassword(password); //true | false
// decrypt
const decryptedPrivateKey: Uint8Array = await keystore.decrypt(password);
// convert to string
keystore.stringify(); //string
// determine if unsanitized data fits the EIP-2335 schema
const data: unknown = ...;
Keystore.fromObject(data); // returns a Keystore or throws if data is invalid
```
For key derivation checkout [@chainsafe/bls-keygen](https://github.com/ChainSafe/bls-keygen)
### Contribute
- get yarn
- yarn install
- yarn test