{"name":"secp256k1","version":"4.0.3","description":"This module provides native bindings to ecdsa secp256k1 functions","keywords":["ec","ecdh","ecdsa","secp256k1"],"bugs":{"url":"https://github.com/cryptocoinjs/secp256k1-node/issues"},"repository":{"type":"git","url":"https://github.com/cryptocoinjs/secp256k1-node.git"},"license":"MIT","author":"Martin Becze <mjbecze@gmail.com>","contributors":["Aaron Davis (https://github.com/kumavis)","Ian Matyssik (https://github.com/phpb-com)","Kagami Hiiragi <kagami@genshiken.org> (http://kagami.genshiken.org/)","ethers (https://github.com/ethers)","Kirill Fomichev <fanatid@ya.ru> (https://github.com/fanatid)"],"main":"./index.js","browser":{"./index.js":"./elliptic.js"},"scripts":{"install":"node-gyp-build || exit 0"},"dependencies":{"elliptic":"^6.5.4","node-addon-api":"^2.0.0","node-gyp-build":"^4.2.0"},"engines":{"node":">=10.0.0"},"gypfile":true,"_id":"secp256k1@4.0.3","_integrity":"sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==","_resolved":"/home/kirill/projects/secp256k1-node/secp256k1-4.0.3.tgz","_from":"file:secp256k1-4.0.3.tgz","_nodeVersion":"17.3.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==","shasum":"c4559ecd1b8d3c1827ed2d1b94190d69ce267303","tarball":"http://registry-npm.ywwl.com/secp256k1/download/secp256k1-4.0.3.tgz","fileCount":108,"unpackedSize":1892278,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2UX1CRA9TVsSAnZWagAAz3AP/RrRgoc/+W+CaNjGzVeI\nWXxWJ4xu2PsyMHB15/bKJKuMhOrVcQBXgXzCOuQXlgNoJfhoZ+Pq6RXU6jEd\n8moF3avlKZ26aOm5XbyBv9ewC5gW2PjXHTc7zPdntYVjQa0RZixFaMA1zq5h\nVOnP1VPlJs9naWC4pkehT6aXJzNiq/sLVvaKtANItadVvJGcRPr23/LA8kS/\ncRdCFQ0H/vRp0hwSc4IWV9fl/sImom5tWfLEU6FsBrcUCrE7uBvuy1goraka\nAeomzt0CDCpRK+apog86ZMIRgugBI2jXTL/k4H5anYW2DIHuMDRWVJN+ZLwB\n+Wtzfh+nOPt8pfe/2HvMHtnMRdW2M866aAdZ77BSocFX7y1ji8FgRMplR42q\nwo6V8bVmyk1i8FWgbh4DFGvkGnQEHGMQTKBCUiW7DnnnZldXowUrz+RMeNLG\npLz7vRweh0KKW08J0iI8ZFKknesI7u+ZOtq+KjZI33XwlrzLjhIuYexfk3mE\nQrn+p5fJjABO8EKF7GQS6II8nWSA4YJm/OPnHqvZ4j96DEQ3dBtNB5Sq++h0\n2r6nvuQCfVDhFgLsG9OQpq+czqod6TRWE0nBuIMlpuQiuBNqm0XoCUYpXBEJ\nY+79GmrLbrb8PjgNOkw89gJYjKTMlOyvgLPuFmfh2rlV6d0Ga8qpA0PgYs0W\nd8Gk\r\n=MC6s\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHTI7RIemuNhOG735u8QmdwfnTItwo170kVXQ+8kUqX3AiEAw358cgGNYAhCqw7ALoasrbh3ZKzHu3xQUH6GjJpj8i4="}],"size":532493,"noattachment":false,"key":"/secp256k1/-/secp256k1-4.0.3.tgz"},"_npmUser":{"name":"fanatid","email":"fanatid@ya.ru"},"directories":{},"maintainers":[{"name":"null_radix","email":"null_radix@riseup.net"},{"name":"fanatid","email":"fanatid@ya.ru"},{"name":"jprichardson","email":"jprichardson@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/secp256k1_4.0.3_1641629173215_0.06662284542839703"},"_hasShrinkwrap":false,"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// => 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] & 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","publish_time":1641629173479,"_cnpm_publish_time":1641629173479,"dist-tags":{"latest":"5.0.2"}}