{"id":15673073,"url":"https://github.com/paulmillr/bls12-381-keygen","last_synced_at":"2025-04-19T10:30:43.432Z","repository":{"id":45974797,"uuid":"315546060","full_name":"paulmillr/bls12-381-keygen","owner":"paulmillr","description":"BLS12-381 Key Generation compatible with EIP-2333.","archived":false,"fork":false,"pushed_at":"2024-03-24T13:15:08.000Z","size":69,"stargazers_count":15,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-08T17:03:14.025Z","etag":null,"topics":["bls","bls12-381","eip2333","eip2334","eth","keygen"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paulmillr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-24T07:00:53.000Z","updated_at":"2024-01-02T22:22:38.000Z","dependencies_parsed_at":"2024-02-14T02:24:04.103Z","dependency_job_id":"f3b7bafa-ec6f-4d51-a21a-831847cdff66","html_url":"https://github.com/paulmillr/bls12-381-keygen","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulmillr%2Fbls12-381-keygen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulmillr%2Fbls12-381-keygen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulmillr%2Fbls12-381-keygen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulmillr%2Fbls12-381-keygen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulmillr","download_url":"https://codeload.github.com/paulmillr/bls12-381-keygen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249675557,"owners_count":21309323,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bls","bls12-381","eip2333","eip2334","eth","keygen"],"created_at":"2024-10-03T15:36:36.149Z","updated_at":"2025-04-19T10:30:43.230Z","avatar_url":"https://github.com/paulmillr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bls12-381-keygen\n\n\u003e [!WARNING]  \n\u003e The repository has been merged into [micro-key-producer](https://github.com/paulmillr/micro-key-producer). Please head to the new repo for updates.\n\n    npm install micro-key-producer\n\n---\n\nMinimal BLS12-381 Key Generation compatible with [EIP-2333](https://eips.ethereum.org/EIPS/eip-2333).\n\nCan be used to generate EIP-2334 keys for ETH beacon chain. Has only one dependency on `@noble/hashes` for SHA256 and HKDF.\n\nIf you're looking for actual implementation of the bls12-381 elliptic curve,\nuse module [noble-curves](https://github.com/paulmillr/noble-curves).\nThe bls12-381-keygen only generates private keys, by EIP-2333 specification.\n\nCheck out live demo in iancoleman's [eip2333-tool](https://iancoleman.io/eip2333/)\n\n## Usage\n\nNode.js and browser:\n\n\u003e npm install bls12-381-keygen\n\nThe API is the following:\n\n```typescript\nfunction deriveMaster(seed: Uint8Array): Uint8Array;\nfunction deriveChild(parentKey: Uint8Array, index: number): Uint8Array;\nfunction deriveSeedTree(seed: Uint8Array, path: string): Uint8Array;\nconst EIP2334_KEY_TYPES: readonly ['withdrawal', 'signing'];\ntype EIP2334KeyType = (typeof EIP2334_KEY_TYPES)[number];\nfunction deriveEIP2334Key(\n  seed: Uint8Array,\n  type: EIP2334KeyType,\n  index: number\n): {\n  key: Uint8Array;\n  path: string;\n};\n```\n\nUsage example:\n\n```ts\nimport { deriveEIP2334Key, deriveSeedTree } from 'bls12-381-keygen';\n\nconst seed = new Uint8Array(32).fill(7); // must be random\nderiveEIP2334Key(seed, 'withdrawal', 6);\n\n// Those two are equal\nconst signKey1a = deriveEIP2334Key(seed, 'signing', 0);\nconst signKey1b = deriveSeedTree(seed, 'm/12381/3600/0/0/0');\n\n// To generate mnemonics for EIP-2334 keystores\nimport { entropyToMnemonic, mnemonicToSeedSync } from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english';\n// bytes = some random sequence\nconst mnSeed = mnemonicToSeedSync(entropyToMnemonic(bytes, wordlist));\nderiveEIP2334Key(mnSeed, 'signing', index);\n\n// To generate BLS12-381 public key, use @noble crypto\nimport { getPublicKey } from '@noble/bls12-381';\ngetPublicKey(signKey1a);\n```\n\n## License\n\nMIT (c) Paul Miller [(https://paulmillr.com)](https://paulmillr.com), see LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulmillr%2Fbls12-381-keygen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulmillr%2Fbls12-381-keygen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulmillr%2Fbls12-381-keygen/lists"}