{"name":"libp2p-keychain","version":"0.3.2","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.4.2","libp2p-crypto":"~0.13.0","lodash":"^4.6.1","pull-stream":"^3.6.8","sanitize-filename":"^1.6.1"},"devDependencies":{"aegir":"^14.0.0","chai":"^4.1.2","chai-string":"^1.4.0","datastore-fs":"~0.5.0","datastore-level":"~0.8.0","dirty-chai":"^2.0.1","level-js":"^3.0.0","mocha":"^5.2.0","peer-id":"~0.10.7","rimraf":"^2.6.2"},"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":"Victor Bjelkholm","email":"victorbjelkholm@gmail.com"}],"gitHead":"5d3f489f23622415cb6d29d891d87743f295b06a","_id":"libp2p-keychain@0.3.2","_npmVersion":"5.6.0","_nodeVersion":"8.11.3","_npmUser":{"name":"vascosantos","email":"vasco.santos@moxy.studio"},"dist":{"integrity":"sha512-bJYJoHQod58iixiOwJhbjgGXS5JKY5Ry1yS0CqxatAkd3vxhfUBdz80AVGxoGczLNPc/b3jKdCb+mzKjLiuACA==","shasum":"9a572343d04dc790109a2750fa91adafadc5378e","tarball":"http://registry-npm.ywwl.com/libp2p-keychain/download/libp2p-keychain-0.3.2.tgz","fileCount":20,"unpackedSize":84023,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJboOl7CRA9TVsSAnZWagAA3XgP/3FXlABCqLnTfNnx4US4\nwMhpYTgQFm6StaK0koNtKbAMngaKZiBfxXZuq2vEX86zDUFEc950aQOF+vS5\nEaxvakXBmWs6I0WD2keTWTLkhaO84EvBXx03M4SdR+AzPAe/b17taWrNL6X5\nX2cTzC3U8divl7iia2sZS4EhnnbgwvTXORZ7a59LW9rwXgz9+IggEuJ63aUa\neJvLg9RbK4TWiwBrQ6oGFWimf5p71CyVKSgmxdn2oqkewanHdyVKR10f6XHj\nsL5/p0xDnu4DroE/TSOstxfJTGWYWhq0/oJ5oHZ6Uj+8CkdiiWostWaqFT5x\nPyE2UeQbRqX2QG1m3dFS+Od1TCyrXqOB3vADI5cwYlS3cAB9lLOpFtjgE0z0\nTdmRJ6f0CYhxJaLEE0166N8SF6b6Jn1ek1wKJhqUecax2+m+sFrvgbgfReQR\nS2bZxwiKn+axyLuo/WI+XJ/NlaYFyuQ22B5iuFKFbA1HiRcS8ObKN/OPLx8j\nNmyh2qP7y5AQPR+qHP4gu4fyUuANj/sWfcwYgmjg08dZ53GJ2wUeIopHfyHi\n5Z/TFB8Hqrz2rzWAFy++5jcRWgYqd2hOFtTTSp0HPyjkm1COBDjHpMQMSN47\npKFQdSZ+p9WyWIhBr7Gsm2TcQJSg0nhoW6amlUTO8Q1uHBAmAqG4KOvg0vpP\nh9Wq\r\n=FChB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCeZt577/nVUWSOXPI6NDSOSSVAMVuH3F/6xPWKFOaiywIgCxVT7n6jCOIUnEQF2gAP9PkBuxzK0iT+BtHGxscX+OU="}],"size":43168,"noattachment":false,"key":"/libp2p-keychain/-/libp2p-keychain-0.3.2.tgz"},"maintainers":[{"name":"daviddias","email":"daviddias.p@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/libp2p-keychain_0.3.2_1537272187185_0.4874917895476789"},"_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":1537272187316,"_cnpm_publish_time":1537272187316,"dist-tags":{"latest":"0.6.1"}}