{"id":17815624,"url":"https://github.com/bitcoinjs/ecpair","last_synced_at":"2025-04-05T01:03:48.758Z","repository":{"id":38011734,"uuid":"419230560","full_name":"bitcoinjs/ecpair","owner":"bitcoinjs","description":"The ECPair module for bitcoinjs-lib","archived":false,"fork":false,"pushed_at":"2025-03-07T14:48:29.000Z","size":108,"stargazers_count":20,"open_issues_count":4,"forks_count":30,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T00:04:34.650Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/bitcoinjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2021-10-20T07:38:39.000Z","updated_at":"2025-03-24T15:58:13.000Z","dependencies_parsed_at":"2024-09-08T15:38:18.963Z","dependency_job_id":null,"html_url":"https://github.com/bitcoinjs/ecpair","commit_stats":{"total_commits":39,"total_committers":3,"mean_commits":13.0,"dds":0.4871794871794872,"last_synced_commit":"737b406462d88bb4b8056f03c2334cb4119fe14d"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcoinjs%2Fecpair","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcoinjs%2Fecpair/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcoinjs%2Fecpair/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcoinjs%2Fecpair/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitcoinjs","download_url":"https://codeload.github.com/bitcoinjs/ecpair/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247271515,"owners_count":20911587,"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":[],"created_at":"2024-10-27T16:17:15.802Z","updated_at":"2025-04-05T01:03:48.738Z","avatar_url":"https://github.com/bitcoinjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ecpair\n[![Github CI](https://github.com/bitcoinjs/ecpair/actions/workflows/main_ci.yml/badge.svg)](https://github.com/bitcoinjs/ecpair/actions/workflows/main_ci.yml) [![NPM](https://img.shields.io/npm/v/ecpair.svg)](https://www.npmjs.org/package/ecpair) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\nA library for managing SECP256k1 keypairs written in TypeScript with transpiled JavaScript committed to git.\n\n**Note** `ECPair`.makeRandom() uses the `crypto.getRandomValues` if there is no custom `rng` function provided. This API currently is still an experimental feature as of Node.js 18.19.0. To work around this you can do one of the following:\n1. Use a polyfill for crypto.getRandomValues()\n2. Use the `--experimental-global-webcrypto` flag when running node.js.\n3. Pass in a custom rng function to generate random values.\n\n## Example\n\nTypeScript\n\n``` typescript\nimport { Signer, SignerAsync, ECPairInterface, ECPairFactory, ECPairAPI, TinySecp256k1Interface } from 'ecpair';\nimport * as crypto from 'crypto';\n\n// You need to provide the ECC library. The ECC library must implement \n// all the methods of the `TinySecp256k1Interface` interface.\nconst tinysecp: TinySecp256k1Interface = require('tiny-secp256k1');\nconst ECPair: ECPairAPI = ECPairFactory(tinysecp);\n\n// You don't need to explicitly write ECPairInterface, but just to show\n// that the keyPair implements the interface this example includes it.\n\n// From WIF\nconst keyPair1: ECPairInterface = ECPair.fromWIF('KynD8ZKdViVo5W82oyxvE18BbG6nZPVQ8Td8hYbwU94RmyUALUik');\n// Random private key\nconst keyPair2 = ECPair.fromPrivateKey(crypto.randomBytes(32));\n// OR (uses randombytes library, compatible with browser)\nconst keyPair3 = ECPair.makeRandom();\n// OR use your own custom random buffer generator BE CAREFUL!!!!\nconst customRandomBufferFunc = (size: number): Buffer =\u003e crypto.randomBytes(size);\nconst keyPair4 = ECPair.makeRandom({ rng: customRandomBufferFunc });\n// From pubkey (33 or 65 byte DER format public key)\nconst keyPair5 = ECPair.fromPublicKey(keyPair1.publicKey);\n\n// Pass a custom network\nconst network = {}; // Your custom network object here\nECPair.makeRandom({ network });\nECPair.fromPrivateKey(crypto.randomBytes(32), { network });\nECPair.fromPublicKey(keyPair1.publicKey, { network });\n// fromWIF will check the WIF version against the network you pass in\n// pass in multiple networks if you are not sure\nECPair.fromWIF('wif key...', network);\nconst network2 = {}; // Your custom network object here\nconst network3 = {}; // Your custom network object here\nECPair.fromWIF('wif key...', [network, network2, network3]);\n```\n\n## LICENSE [MIT](LICENSE)\nWritten and tested by [bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib) contributors since 2014.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitcoinjs%2Fecpair","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitcoinjs%2Fecpair","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitcoinjs%2Fecpair/lists"}