{"id":13773096,"url":"https://github.com/cryptocoinjs/coinkey","last_synced_at":"2025-05-11T05:34:19.524Z","repository":{"id":14854098,"uuid":"17577285","full_name":"cryptocoinjs/coinkey","owner":"cryptocoinjs","description":"JavaScript component for private keys, public keys, and addresess for crypto currencies such as Bitcoin, Litecoin, and Dogecoin","archived":false,"fork":false,"pushed_at":"2022-08-11T15:47:03.000Z","size":53,"stargazers_count":152,"open_issues_count":7,"forks_count":58,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-07T19:02:24.537Z","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":"CachetHQ/Cachet","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cryptocoinjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-10T00:26:34.000Z","updated_at":"2025-03-30T00:41:05.000Z","dependencies_parsed_at":"2022-09-26T20:20:53.171Z","dependency_job_id":null,"html_url":"https://github.com/cryptocoinjs/coinkey","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fcoinkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fcoinkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fcoinkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fcoinkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cryptocoinjs","download_url":"https://codeload.github.com/cryptocoinjs/coinkey/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253523690,"owners_count":21921815,"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-08-03T17:01:11.305Z","updated_at":"2025-05-11T05:34:19.241Z","avatar_url":"https://github.com/cryptocoinjs.png","language":"JavaScript","readme":"coinkey\n=======\n\n[![Version](http://img.shields.io/npm/v/coinkey.svg)](https://www.npmjs.org/package/coinkey)\n[![build status](https://secure.travis-ci.org/cryptocoinjs/coinkey.png)](http://travis-ci.org/cryptocoinjs/coinkey)\n[![Coverage Status](https://img.shields.io/coveralls/cryptocoinjs/coinkey.svg)](https://coveralls.io/r/cryptocoinjs/coinkey)\n\nJavaScript component for private keys, public keys, and addresses for crypto currencies such as Bitcoin, Litecoin, and Dogecoin. Works\nin both Node.js and the browser.\n\n\n\nPackage Info\n------------\n- github: [https://github.com/cryptocoinjs/coinkey](https://github.com/cryptocoinjs/coinkey)\n- tests: [https://github.com/cryptocoinjs/coinkey/tree/master/test](https://github.com/cryptocoinjs/coinkey/tree/master/test)\n- issues: [https://github.com/cryptocoinjs/coinkey/issues](https://github.com/cryptocoinjs/coinkey/issues)\n- license: **MIT**\n- versioning: **SemVer**\n\n\nInstallation\n------------\n\n    npm i --save coinkey\n\n\nUsage\n-----\n\n### Common Use Cases\n\n### Generate a Bunch of Bitcoin Keys/Addresses\n\n```js\nvar CoinKey = require('coinkey')\n\nvar bitcoinKeys = []\nfor (var i = 0; i \u003c 10; ++i) {\n  // bitcoin supported by default\n  bitcoinKeys.push(CoinKey.createRandom())\n}\n```\n\n\n#### Generate a Bunch of Namecoin Keys/Addresses\n\n```js\nvar CoinKey = require('coinkey')\n// npm install --save coininfo\nvar ci = require('coininfo')\n\nvar namecoins = []\nfor (var i = 0; i \u003c 10; ++i) {\n  namecoins.push(CoinKey.createRandom(ci('NMC')))\n}\n```\n\n\n#### Parse a Wallet Import Key and Determine Crypto Currency\n\n```js\nvar CoinKey = require('coinkey')\nvar ci = require('coininfo')\n\nvar ck = CoinKey.fromWif('QVD3x1RPiWPvyxbTsfxVwaYLyeBZrQvjhZ2aZJUsbuRgsEAGpNQ2')\n\nconsole.log(ck.privateKey.toString('hex')) // =\u003e c4bbcb1fbec99d65bf59d85c8cb62ee2db963f0fe106f483d9afa73bd4e39a8a\nconsole.log(ck.publicAddress) // =\u003e DGG6AicS4Qg8Y3UFtcuwJqbuRZ3Q7WtYXv\nconsole.log(ck.compressed) // =\u003e true\nconsole.log(ck.versions.public === ci('DOGE').versions.public) // =\u003e true\n```\n\n\n#### Change to Testnet Later\n\n```js\nvar CoinKey = require('coinkey')\nvar ci = require('coininfo')\n\nvar ck = new CoinKey(new Buffer('1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd', 'hex'))\nconsole.log(ck.publicAddress) // =\u003e 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS\n\n//change to Testnet\nck.versions = ci('BTC-TEST')\n\nconsole.log(ck.publicAddress) // =\u003e mkzgubTA5Ahi6BPSkE6MN9pEafRutznkMe\n```\n\n\n### API\n\n#### CoinKey(privateKey, [versions])\n\nConstructor function.\n\n- **privateKey**: The private key bytes. Must be 32 bytes in length. Should be an `Array`, `Uint8Array`, or a `Buffer`.\n- **versions**: An object that specifies the public and private key versions for addresses and wifs. Defaults to Bitcoin `mainnet`.\n\nKeys are default set to `compressed` is `true`.\n\n```js\nvar CoinKey = require('coinkey')\n//npm install --save secure-random@1.x\nvar secureRandom = require('secure-random')\n\nvar bytes = secureRandom.randomBuffer(32)\nvar key1 = new CoinKey(bytes)\nconsole.log(key1.compressed) // =\u003e true\n```\n\n\n### Properties\n\n\n#### compressed\n\nInherited from [ECKey][eckey]. [eckey.compressed](http://cryptocoinjs.com/modules/currency/eckey/#compressed)\n\n\n#### privateKey\n\nInherited from [ECKey][eckey]. [eckey.privateKey](http://cryptocoinjs.com/modules/currency/eckey/#privatekey)\n\n\n#### privateExportKey\n\nInherited from [ECKey][eckey]. [eckey.privateExportKey](http://cryptocoinjs.com/modules/currency/eckey/#privateexportkey)\n\n\n#### privateWif\n\nGet the private WIF (Wallet Import Format).\n\n```js\nvar CoinKey = require('coinkey')\n\nvar privateKeyHex = \"1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd\"\n\n//Bitcoin WIF\nvar key = new CoinKey(new Buffer(privateKeyHex, 'hex'))\nkey.compressed = false\nconsole.log(key.privateWif) // =\u003e 5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD\n\n//Litecoin WIF\nvar key = new CoinKey(new Buffer(privateKeyHex, 'hex'), {private: 0xB0, public: 0x30})\nkey.compressed = false\nconsole.log(key.privateWif) // =\u003e 6uFjYQnot5Gtg3HpP87bp4JUpg4FH1gkkV3RyS7LHBbD9Hpt1na\n```\n\n\n#### publicKey\n\nInherited from [ECKey][eckey]. [eckey.publicKey](http://cryptocoinjs.com/modules/currency/eckey/#publickey)\n\n\n#### publicAddress\n\nGet the public address.\n\n```js\nvar CoinKey = require('coinkey')\n\nvar privateKeyHex = \"1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd\"\n\n// Bitcoin Address\nvar key = new CoinKey(new Buffer(privatKeyHex, 'hex'))\nconsole.log(key.publicAddress) // =\u003e 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS\n\n// Litecoin Address\nvar key = new CoinKey(new Buffer(privateKeyHex, 'hex'), {private: 0xB0, public: 0x30})\nconsole.log(key.publicAddress) // =\u003e 'LZyGd5dCPVkVUjA5QbpuUfMNgcmNDLjswH'\n```\n\n\n#### publicHash\n\nAlias: `pubKeyHash`\n\nInherited from [ECKey][eckey]. [eckey.publicHash](http://cryptocoinjs.com/modules/currency/eckey/#publicHash)\n\n\n#### publicPoint\n\nInherited from [ECKey][eckey]. [eckey.publicPoint](http://cryptocoinjs.com/modules/currency/eckey/#publicPoint)\n\n\n#### toString()\n\nReturns the string representation.\n\n```js\nvar CoinKey = require('coinkey')\n\nvar privateKeyHex = \"1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd\"\n\n//Litecoin Address\nvar key = new CoinKey(new Buffer(privateKeyHex, 'hex'), {private: 0xB0, public: 0x30})\nconsole.log(key.toString())\n// =\u003e T3e2me1BvRs95K7E8eQ8eha9oRPL1g2U6vmjE5px6RjzbUTvKZsf: LZyGd5dCPVkVUjA5QbpuUfMNgcmNDLjswH\n```\n\n\n### Methods\n\n#### fromWif(wif, [versions])\n\nClass method to create a `CoinKey` from a wif.\n\n```js\nvar ck = CoinKey.fromWif('KwomKti1X3tYJUUMb1TGSM2mrZk1wb1aHisUNHCQXTZq5auC2qc3');\nconsole.log(ck.compressed) // =\u003e true\nconsole.log(ck.privateKey.toString('hex')) // =\u003e 1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd\nconsole.log(ck.publicAddress) // =\u003e 1FkKMsKNJqWSDvTvETqcCeHcUQQ64kSC6s\n```\n\n\nBrowser Support\n---------------\n\nClone the repo:\n\n    git clone https://github.com/cryptocoinjs/coinkey\n\nInstall Browserify\n\n    npm install -g browserify\n\nNav to repo:\n\n    cd coinkey\n\nInstall dependencies:\n\n    npm install\n\nRun browserify:\n\n    browserify --standalone coinkey lib/coinkey.js \u003e lib/coinkey.bundle.js\n\nYou can now drop `coinkey.bundle.js` in a `\u003cscript\u003e` tag.\n\n\n[eckey]: https://github.com/cryptocoinjs/eckey\n[coinstring]: https://github.com/cryptocoinjs/coinstring\n\n\nHack on CoinKey\n---------------\n\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n","funding_links":[],"categories":["JavaScript","List of content"],"sub_categories":["Utilities"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptocoinjs%2Fcoinkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptocoinjs%2Fcoinkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptocoinjs%2Fcoinkey/lists"}