{"_id":"@arve.knudsen/libp2p-crypto-secp256k1","_rev":"1-472b2b95e742d218d1fdc1b2cb12adca","name":"@arve.knudsen/libp2p-crypto-secp256k1","dist-tags":{"latest":"0.3.0"},"versions":{"0.3.0":{"name":"@arve.knudsen/libp2p-crypto-secp256k1","version":"0.3.0","description":"Support for secp256k1 keys in libp2p-crypto","leadMaintainer":"Arve Knudsen <arve.knudsen@gmail.com>","main":"src/index.js","browser":{"secp256k1":"secp256k1/js"},"scripts":{"lint":"aegir lint","build":"aegir build","test":"aegir test -t node -t browser","test:node":"aegir test -t node","test:browser":"aegir test -t browser","release":"aegir release","release-minor":"aegir release --type minor","release-major":"aegir release --type major","coverage":"aegir coverage","coverage-publish":"aegir coverage publish"},"keywords":["IPFS","libp2p","crypto","secp256k1"],"license":"MIT","dependencies":{"async":"^2.6.2","bs58":"^4.0.1","multihashing-async":"~0.6.0","nodeify":"^1.0.1","safe-buffer":"^5.1.2","secp256k1":"^3.6.2"},"devDependencies":{"aegir":"^18.2.2","benchmark":"^2.1.4","chai":"^4.2.0","dirty-chai":"^2.0.1","libp2p-crypto":"~0.16.1"},"engines":{"node":">=6.0.0","npm":">=3.0.0"},"repository":{"type":"git","url":"git+https://github.com/aknuds1/js-libp2p-crypto-secp256k1.git"},"bugs":{"url":"https://github.com/aknuds1/js-libp2p-crypto-secp256k1/issues"},"homepage":"https://github.com/aknuds1/js-libp2p-crypto-secp256k1","contributors":[{"name":"Alberto Elias","email":"hi@albertoelias.me"},{"name":"David Dias","email":"daviddias.p@gmail.com"},{"name":"Friedel Ziegelmayer","email":"dignifiedquire@gmail.com"},{"name":"Hugo Dias","email":"hugomrdias@gmail.com"},{"name":"Victor Bjelkholm","email":"victorbjelkholm@gmail.com"},{"name":"Yusef Napora","email":"yusef@napora.org"},{"name":"dignifiedquire","email":"dignifiedquire@users.noreply.github.com"}],"gitHead":"dfb8431d0c51b8dee8290d6a903f477a0355c78c","_id":"@arve.knudsen/libp2p-crypto-secp256k1@0.3.0","_nodeVersion":"12.5.0","_npmVersion":"6.10.0","dist":{"integrity":"sha512-RhSwg50HlUBaKSNdVi1CPtdoEVYSgGJdQ7BUHUG1JstUgQGatynlTKm4SI2f28ssLSbzYBXCoc67I3C1OhK7Qw==","shasum":"a7d38f2b9a2317740d2cacd708d40c95347de276","tarball":"https://registry.npmjs.org/@arve.knudsen/libp2p-crypto-secp256k1/-/libp2p-crypto-secp256k1-0.3.0.tgz","fileCount":7,"unpackedSize":16158,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdHe6OCRA9TVsSAnZWagAAXCoP/jJ8DAEz2fhz+y8o8FZo\nfODVzJNy+zserve1xeXLb0y6wow+8I57m3HiM3ObSptOp747CFVu6S6Xr5bN\nwTmW/No6ou6z22KchBb9oOVwZK0owNU/Z8wwoVHZ0y86F4mLM4x6b6HHaonP\nmw1JtHB1eIE5hDvb8W/vHrZWvGKFH2RV5PN/njlonI+Cc+4pWeoVnpZncI5I\nWg9DS5+Ii7RMEXAkE9TY8du0mJEUYpz9eKiSh8uAnaVLXjofXHgyEjKPbfWj\n2el7gdSduU0Ne7pNgP5Jw3DHp11UPBvjO/4NHeZKWinU4ViY3cmfFTBK5uWz\ntdsG2Eb2OnEsdh76eJQubecg+auEW6pjiYHFMzTYKVCFIwn+l2kHdTBiuZ5j\nJQHWjZ/ubBikTFPY9Gh2R/It7QWTNYwYUMFdjVJcnYnG8jMjbGdYHOrfTB7S\nfR8FX0JlmUhKpzVtYdgXJaClILAcKPvpgYP4JSgXjFmRZEd15XhaD93R2GDP\n5gree0lTgKJJO1bwc7CvQBL5wpF6O7HVA6wHeXZdzMBbe88LfUZhyf0fIxZP\n82gElRTsaE+xomFj1aO9GlfSg30YXu4rgmLEUfgiBG6zToYgK3Ben05Nm8Lu\n+RIykQtnqGo62eyZTmDPhuKHK63Meq0v2N+IfbHQk+BrIfK05HUcbXLwyFnp\nZuKq\r\n=0lbF\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEQi77+6am+q2x6cr/JPT7iVLVwW/hEmj5tmggLeDd5XAiEA0MaLWiQS2vpyGJ87TiF81t7AvyxpC6rg8EThIVonMWU="}]},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"_npmUser":{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/libp2p-crypto-secp256k1_0.3.0_1562242701940_0.25019391796431734"},"_hasShrinkwrap":false}},"time":{"created":"2019-07-04T12:18:21.733Z","0.3.0":"2019-07-04T12:18:22.072Z","modified":"2022-04-04T15:41:15.889Z"},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"description":"Support for secp256k1 keys in libp2p-crypto","homepage":"https://github.com/aknuds1/js-libp2p-crypto-secp256k1","keywords":["IPFS","libp2p","crypto","secp256k1"],"repository":{"type":"git","url":"git+https://github.com/aknuds1/js-libp2p-crypto-secp256k1.git"},"contributors":[{"name":"Alberto Elias","email":"hi@albertoelias.me"},{"name":"David Dias","email":"daviddias.p@gmail.com"},{"name":"Friedel Ziegelmayer","email":"dignifiedquire@gmail.com"},{"name":"Hugo Dias","email":"hugomrdias@gmail.com"},{"name":"Victor Bjelkholm","email":"victorbjelkholm@gmail.com"},{"name":"Yusef Napora","email":"yusef@napora.org"},{"name":"dignifiedquire","email":"dignifiedquire@users.noreply.github.com"}],"bugs":{"url":"https://github.com/aknuds1/js-libp2p-crypto-secp256k1/issues"},"license":"MIT","readme":"# js-libp2p-crypto-secp256k1\n\n[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)\n[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)\n[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)\n[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)\n[![](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-crypto-secp256k1.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-crypto-secp256k1)\n[![](https://img.shields.io/travis/libp2p/js-libp2p-crypto-secp256k1.svg?style=flat-square)](https://travis-ci.com/libp2p/js-libp2p-crypto-secp256k1)\n[![Dependency Status](https://david-dm.org/libp2p/js-libp2p-crypto-secp256k1.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-crypto-secp256k1)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)\n![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)\n![](https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square)\n\n> Support for secp256k1 keys in js-libp2p-crypto\n\nThis repo contains a [js-libp2p-crypto](https://github.com/libp2p/js-libp2p-crypto)-compatible \nimplementation of cryptographic signature generation and verification using the \n[secp256k1 elliptic curve](https://en.bitcoin.it/wiki/Secp256k1) popularized by Bitcoin and other \ncrypto currencies.  \n\n## Lead Captain\n\n[Friedel Ziegelmayer](https://github.com/dignifiedquire/)\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n  - [Example](#example)\n- [API](#api)\n  - [`generateKeyPair([bits,] callback)`](#generatekeypairbits-callback)\n  - [`unmarshalSecp256k1PublicKey(bytes)`](#unmarshalsecp256k1publickeybytes)\n  - [`unmarshalSecp256k1PrivateKey(bytes, callback)`](#unmarshalsecp256k1privatekeybytes-callback)\n  - [`Secp256k1PublicKey`](#secp256k1publickey)\n    - [`.verify(data, sig, callback)`](#verifydata-sig-callback)\n  - [`Secp256k1PrivateKey`](#secp256k1privatekey)\n    - [`.public`](#public)\n    - [`.sign(data, callback)`](#signdata-callback)\n- [Contribute](#contribute)\n- [License](#license)\n\n## Install\n\n```sh\nnpm install --save libp2p-crypto-secp256k1\n```\n\n## Usage\n\nThis module is designed to work with [js-libp2p-crypto](https://github.com/libp2p/js-libp2p-crypto).  \nInstalling `libp2p-crypto-secp256k1` will automatically add support for the `'secp256k1'` key type, which\ncan be used as an argument to the [libp2p-crypto API functions](https://github.com/libp2p/js-libp2p-crypto#api)\n`generateKeyPair`, `unmarshalPublicKey`, and `marshalPrivateKey`.  The keys returned from those functions will be\ninstances of the `Secp256k1PublicKey` or `Secp256k1PrivateKey` classes provided by this module.\n\n### Example\n\n```js\nconst crypto = require('libp2p-crypto')\n\nconst msg = Buffer.from('Hello World')\n\ncrypto.generateKeyPair('secp256k1', 256, (err, key) => {\n  // assuming no error, key will be an instance of Secp256k1PrivateKey\n  // the public key is available as key.public\n  key.sign(msg, (err, sig) => {\n    key.public.verify(msg, sig, (err, valid) => {\n      assert(valid, 'Something went horribly wrong')\n    })\n  })\n})\n```\n\n## API\n\nThe functions below are the public API of this module.\nFor usage within libp2p-crypto, see the [libp2p-crypto API documentation](https://github.com/libp2p/js-libp2p-crypto#api).\n\n### `generateKeyPair([bits, ] callback)`\n- `bits: Number` - Optional, included for compatibility with js-libp2p-crypto. Ignored if present; private keys will always be 256 bits.\n- `callback: Function`\n\n### `unmarshalSecp256k1PublicKey(bytes)`\n- `bytes: Buffer`\n\nConverts a serialized secp256k1 public key into an instance of `Secp256k1PublicKey` and returns it\n\n### `unmarshalSecp256k1PrivateKey(bytes, callback)`\n- `bytes: Buffer`\n- `callback: Function`\n\nConverts a serialized secp256k1 private key into an instance of `Secp256k1PrivateKey`, passing it to `callback` on success\n\n### `Secp256k1PublicKey`\n\n#### `.verify(data, sig, callback)`\n- `data: Buffer`\n- `sig: Buffer`\n- `callback: Function`\n\nCalculates the SHA-256 hash of `data`, and verifies the DER-encoded signature in `sig`, passing the result to `callback`\n\n### `Secp256k1PrivateKey`\n\n#### `.public`\n\nAccessor for the `Secp256k1PublicKey` associated with this private key.\n\n#### `.sign(data, callback)`\n- `data: Buffer`\n\nCalculates the SHA-256 hash of `data` and signs it, passing the DER-encoded signature to `callback`\n\n## Contribute\n\nFeel free to join in. All welcome. Open an [issue](https://github.com/libp2p/js-libp2p-crypto/issues)!\n\nThis repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).\n\n[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md)\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md"}