{"name":"libp2p-keychain","version":"0.3.4","description":"Key management and cryptographically protected messages","leadMaintainer":"Vasco Santos <vasco.santos@moxy.studio>","main":"src/index.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"},"pre-push":["lint","test"],"engines":{"node":">=6.0.0","npm":">=3.0.0"},"repository":{"type":"git","url":"git+https://github.com/libp2p/js-libp2p-keychain.git"},"keywords":["IPFS","libp2p","keys","encryption","secure","crypto"],"license":"MIT","bugs":{"url":"https://github.com/libp2p/js-libp2p-keychain/issues"},"homepage":"https://github.com/libp2p/js-libp2p-keychain#readme","dependencies":{"async":"^2.6.1","interface-datastore":"~0.6.0","libp2p-crypto":"~0.15.0","lodash":"^4.17.11","pull-stream":"^3.6.9","sanitize-filename":"^1.6.1"},"devDependencies":{"aegir":"^18.0.2","chai":"^4.2.0","chai-string":"^1.5.0","datastore-fs":"~0.7.0","datastore-level":"~0.10.0","dirty-chai":"^2.0.1","level-js":"^4.0.0","mocha":"^5.2.0","peer-id":"~0.12.1","rimraf":"^2.6.3"},"contributors":[{"name":"Alan Shaw","email":"alan.shaw@protocol.ai"},{"name":"David Dias","email":"daviddias.p@gmail.com"},{"name":"Maciej Krüger","email":"mkg20001@gmail.com"},{"name":"Masahiro Saito","email":"camelmasa@gmail.com"},{"name":"Richard Schneider","email":"makaretu@gmail.com"},{"name":"Vasco Santos","email":"vasco.santos@ua.pt"},{"name":"Vasco Santos","email":"vasco.santos@moxy.studio"},{"name":"Victor Bjelkholm","email":"victorbjelkholm@gmail.com"}],"gitHead":"4b895cf46ffdf0eae8ae15fee1bb4800d6f97e9b","_id":"libp2p-keychain@0.3.4","_npmVersion":"6.5.0","_nodeVersion":"10.14.1","_npmUser":{"name":"vascosantos","email":"vasco.santos@moxy.studio"},"dist":{"integrity":"sha512-utuH3LcWUDI2EPa8AhLQHqnH1eBDCl1uXf0D5jobc1pGkYuMTwFxHQ8SfxwVAhXAH/VtTlb2O98tX/nivNhwLQ==","shasum":"4e407753b0c5dba9517cf1ab8eb7044e6acc7221","tarball":"http://registry-npm.ywwl.com/libp2p-keychain/download/libp2p-keychain-0.3.4.tgz","fileCount":18,"unpackedSize":83143,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcLzuFCRA9TVsSAnZWagAA0AsP/Ah4TfCoTI+9q3Fb5uNC\nv/1FrAzM7dJH3HEDue4TdN6abKG5Az1YayjbhhkiV9pQTmU8E+iL7VWI53jo\nvZcqOO3cxPadxySLl7Gss+EX3/+3DmOmjEJs6leIPuJvjVSrqiUxOfoTBuTP\nm0gRSZe+/R+A2c69n0PSpoN29CAOl6OgjLUbwB00Vft4xio9kLt36shB9M4v\nwXgGuIxWFzkmUiuXYbpOBQSu1mZ3PxYXirIWN+vTiKLxVLrRjhPMnyFFwipM\nZzu7/7l5DM2KRbtxmSOh8M7G7QW9037KdVzFd4r3bMLenj5BQrjVKqC/xaz7\nfIusJWeXSGxBrrInstr00SVZFQfOhVurgQUMupcY8UmxunOACUCGjKXrwuxN\nJCJz3Gy+P+18sL3YycuAosbqnO7DfwAxw5/XM/TGV+JlgEzSQd+b/JB6ERp7\nBNSQNyMTSNlJ50NJ2FjNYjn4zfY+lGUmS6IBKN2zm/ZE9pCJ9Z9fhSNVh0Sg\n14Hw7Fshlu80IXyCn3gbbE6GZyMgajW7UBjqlYVxLJL/GQlMuzvEJNJ47WF+\n+SnZ/kbfBRQ3EQsthI3p/FN53DYeXjH9WGW/gK/i9bIGJxIRmm71O3IpSceH\nqt9YLZ9B1zGixyG2sJT6x8WTpoTCnty9FIXOtzL7/2xnJWiIktU+aDQzOc0v\nQwTB\r\n=YROa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC9Wz+HxAebYReZy8R6EgBIvncydWKwR3ffU4eNOpukggIhAI/j6ohCnOvlApLuirTKrhb3vtVwZ8M9zRF399H2COa2"}],"size":42753,"noattachment":false,"key":"/libp2p-keychain/-/libp2p-keychain-0.3.4.tgz"},"maintainers":[{"name":"daviddias","email":"daviddias.p@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/libp2p-keychain_0.3.4_1546599301276_0.67850945836139"},"_hasShrinkwrap":false,"deprecated":"No longer supported for js-libp2p0.28.0 or later","readme":"# js-libp2p-keychain\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-keychain.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-keychain)\n[![](https://img.shields.io/travis/libp2p/js-libp2p-keychain.svg?style=flat-square)](https://travis-ci.com/libp2p/js-libp2p-keychain)\n[![Dependency Status](https://david-dm.org/libp2p/js-libp2p-keychain.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-keychain)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)\n\n> A secure key chain for libp2p in JavaScript\n\n## Lead Maintainer\n\n[Vasco Santos](https://github.com/vasco-santos).\n\n## Features\n\n- Manages the lifecycle of a key\n- Keys are encrypted at rest\n- Enforces the use of safe key names\n- Uses encrypted PKCS 8 for key storage\n- Uses PBKDF2 for a \"stetched\" key encryption key\n- Enforces NIST SP 800-131A and NIST SP 800-132\n- Uses PKCS 7: CMS (aka RFC 5652) to provide cryptographically protected messages\n- Delays reporting errors to slow down brute force attacks\n\n## Table of Contents\n\n## Install\n\n```sh\nnpm install --save libp2p-keychain\n```\n\n### Usage\n\n```js\nconst Keychain = require('libp2p-keychain')\nconst FsStore = require('datastore-fs')\n\nconst datastore = new FsStore('./a-keystore')\nconst opts = {\n  passPhrase: 'some long easily remembered phrase'\n}\nconst keychain = new Keychain(datastore, opts)\n```\n\n## API\n\nManaging a key\n\n- `async createKey (name, type, size)`\n- `async renameKey (oldName, newName)`\n- `async removeKey (name)`\n- `async exportKey (name, password)`\n- `async importKey (name, pem, password)`\n- `async importPeer (name, peer)`\n\nA naming service for a key\n\n- `async listKeys ()`\n- `async findKeyById (id)`\n- `async findKeyByName (name)`\n\nCryptographically protected messages\n\n- `async cms.encrypt (name, plain)`\n- `async cms.decrypt (cmsData)`\n\n### KeyInfo\n\nThe key management and naming service API all return a `KeyInfo` object.  The `id` is a universally unique identifier for the key.  The `name` is local to the key chain.\n\n```js\n{\n  name: 'rsa-key',\n  id: 'QmYWYSUZ4PV6MRFYpdtEDJBiGs4UrmE6g8wmAWSePekXVW'\n}\n```\n\nThe **key id** is the SHA-256 [multihash](https://github.com/multiformats/multihash) of its public key. The *public key* is a [protobuf encoding](https://github.com/libp2p/js-libp2p-crypto/blob/master/src/keys/keys.proto.js) containing a type and the [DER encoding](https://en.wikipedia.org/wiki/X.690) of the PKCS [SubjectPublicKeyInfo](https://www.ietf.org/rfc/rfc3279.txt).\n\n### Private key storage\n\nA private key is stored as an encrypted PKCS 8 structure in the PEM format. It is protected by a key generated from the key chain's *passPhrase* using **PBKDF2**.\n\nThe default options for generating the derived encryption key are in the `dek` object.  This, along with the passPhrase, is the input to a `PBKDF2` function.\n\n```js\nconst defaultOptions = {\n  //See https://cryptosense.com/parameter-choice-for-pbkdf2/\n  dek: {\n    keyLength: 512 / 8,\n    iterationCount: 1000,\n    salt: 'at least 16 characters long',\n    hash: 'sha2-512'\n  }\n}\n```\n\n![key storage](./doc/private-key.png?raw=true)\n\n### Physical storage\n\nThe actual physical storage of an encrypted key is left to implementations of [interface-datastore](https://github.com/ipfs/interface-datastore/).  A key benifit is that now the key chain can be used in browser with the [js-datastore-level](https://github.com/ipfs/js-datastore-level) implementation.\n\n### Cryptographic Message Syntax (CMS)\n\nCMS, aka [PKCS #7](https://en.wikipedia.org/wiki/PKCS) and [RFC 5652](https://tools.ietf.org/html/rfc5652), describes an encapsulation syntax for data protection. It is used to digitally sign, digest, authenticate, or encrypt arbitrary message content. Basically, `cms.encrypt` creates a DER message that can be only be read by someone holding the private key.\n\n## Contribute\n\nFeel free to join in. All welcome. Open an [issue](https://github.com/libp2p/js-libp2p-keychain/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","publish_time":1546599301410,"_cnpm_publish_time":1546599301410,"dist-tags":{"latest":"0.6.1"}}