{"id":13511897,"url":"https://github.com/cryptocoinjs/secp256k1-node","last_synced_at":"2025-05-14T05:07:53.889Z","repository":{"id":21408654,"uuid":"24726646","full_name":"cryptocoinjs/secp256k1-node","owner":"cryptocoinjs","description":"Node.js binding for an Optimized C library for EC operations on curve secp256k1","archived":false,"fork":false,"pushed_at":"2024-11-07T20:24:49.000Z","size":579,"stargazers_count":355,"open_issues_count":15,"forks_count":126,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-12T17:22:29.567Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cryptocoinjs.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":"2014-10-02T16:19:53.000Z","updated_at":"2025-05-10T03:08:01.000Z","dependencies_parsed_at":"2024-06-18T11:21:17.442Z","dependency_job_id":"5cd7a7c8-3cdf-4ceb-b696-e1265650aa7f","html_url":"https://github.com/cryptocoinjs/secp256k1-node","commit_stats":{"total_commits":398,"total_committers":22,"mean_commits":18.09090909090909,"dds":"0.46482412060301503","last_synced_commit":"358c0395e0323a48ea8aad8911c650c15c7efe32"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fsecp256k1-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fsecp256k1-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fsecp256k1-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fsecp256k1-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cryptocoinjs","download_url":"https://codeload.github.com/cryptocoinjs/secp256k1-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254076687,"owners_count":22010611,"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-01T03:01:17.456Z","updated_at":"2025-05-14T05:07:53.849Z","avatar_url":"https://github.com/cryptocoinjs.png","language":"JavaScript","readme":"# secp256k1-node\n\nThis module provides native bindings to [bitcoin-core/secp256k1](https://github.com/bitcoin-core/secp256k1). In browser [elliptic](https://github.com/indutny/elliptic) will be used as fallback.\n\nWorks on node version 14.0.0 or greater, because use [N-API](https://nodejs.org/api/n-api.html).\n\n## Installation\n\n##### from npm\n\n`npm install secp256k1`\n\n##### from git\n\n```\ngit clone git@github.com:cryptocoinjs/secp256k1-node.git\ncd secp256k1-node\ngit submodule update --init\nnpm install\n```\n\n##### Windows\n\nThe easiest way to build the package on windows is to install [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools).\n\nOr install the following software:\n\n  * Git: https://git-scm.com/download/win\n  * nvm: https://github.com/coreybutler/nvm-windows\n  * Python 2.7: https://www.python.org/downloads/release/python-2712/\n  * Visual C++ Build Tools: http://landinghub.visualstudio.com/visual-cpp-build-tools (Custom Install, and select both Windows 8.1 and Windows 10 SDKs)\n\nAnd run commands:\n\n```\nnpm config set msvs_version 2015 --global\nnpm install npm@next -g\n```\n\nBased on:\n\n  * https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245\n  * https://github.com/nodejs/node-gyp/issues/972\n\n## Usage\n\n* [API Reference (v4.x)](API.md) (current version)\n* [API Reference (v3.x)](https://github.com/cryptocoinjs/secp256k1-node/blob/v3.x/API.md)\n* [API Reference (v2.x)](https://github.com/cryptocoinjs/secp256k1-node/blob/v2.x/API.md)\n\n##### Private Key generation, Public Key creation, signature creation, signature verification\n\n```js\nconst { randomBytes } = require('crypto')\nconst secp256k1 = require('secp256k1')\n// or require('secp256k1/elliptic')\n//   if you want to use pure js implementation in node\n\n// generate message to sign\n// message should have 32-byte length, if you have some other length you can hash message\n// for example `msg = sha256(rawMessage)`\nconst msg = randomBytes(32)\n\n// generate privKey\nlet privKey\ndo {\n  privKey = randomBytes(32)\n} while (!secp256k1.privateKeyVerify(privKey))\n\n// get the public key in a compressed format\nconst pubKey = secp256k1.publicKeyCreate(privKey)\n\n// sign the message\nconst sigObj = secp256k1.ecdsaSign(msg, privKey)\n\n// verify the signature\nconsole.log(secp256k1.ecdsaVerify(sigObj.signature, msg, pubKey))\n// =\u003e true\n```\n\n\\* **.verify return false for high signatures**\n\n##### Get X point of ECDH\n\n```js\nconst { randomBytes } = require('crypto')\n// const secp256k1 = require('./elliptic')\nconst secp256k1 = require('./')\n\n// generate privKey\nfunction getPrivateKey () {\n  while (true) {\n    const privKey = randomBytes(32)\n    if (secp256k1.privateKeyVerify(privKey)) return privKey\n  }\n}\n\n// generate private and public keys\nconst privKey = getPrivateKey()\nconst pubKey = secp256k1.publicKeyCreate(privKey)\n\n// compressed public key from X and Y\nfunction hashfn (x, y) {\n  const pubKey = new Uint8Array(33)\n  pubKey[0] = (y[31] \u0026 1) === 0 ? 0x02 : 0x03\n  pubKey.set(x, 1)\n  return pubKey\n}\n\n// get X point of ecdh\nconst ecdhPointX = secp256k1.ecdh(pubKey, privKey, { hashfn }, Buffer.alloc(33))\nconsole.log(ecdhPointX.toString('hex'))\n```\n\n## LICENSE\n\nThis library is free and open-source software released under the MIT license.\n","funding_links":[],"categories":["JavaScript","List of content"],"sub_categories":["Cryptography"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptocoinjs%2Fsecp256k1-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptocoinjs%2Fsecp256k1-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptocoinjs%2Fsecp256k1-node/lists"}