{"name":"noise-handshake","version":"3.0.0","description":"## Usage ```js const Noise = require('noise-handshake') const Cipher = require('noise-handshake/cipher') const initiator = new Noise('IK', true) const responder = new Noise('IK', false)","main":"noise.js","scripts":{"test":"standard && tape test/*.js"},"author":"","license":"ISC","repository":{"type":"git","url":"git+https://github.com/chm-diederichs/noise-handshake.git"},"dependencies":{"b4a":"^1.1.0","hmac-blake2b":"^2.0.0","nanoassert":"^2.0.0","sodium-universal":"^3.0.4"},"devDependencies":{"noise-protocol":"github:chm-diederichs/noise-protocol#xx-ephemeral-key","standard":"^16.0.3","tape":"^5.2.2"},"gitHead":"97565dd0bebbc12444879e9f686fcae4e6fbddd8","bugs":{"url":"https://github.com/chm-diederichs/noise-handshake/issues"},"homepage":"https://github.com/chm-diederichs/noise-handshake#readme","_id":"noise-handshake@3.0.0","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-/EQq+TbCZpOFDg0bD3jtxKYqwgSBCFU1tfGxUzHHy94kBKMwVY8GHNxtWR+gekwkhXCu7TyBXqNPY3qdaxe+fQ==","shasum":"cce40781a4da7c650d62e02d0164f5fb4fd71844","tarball":"http://registry-npm.ywwl.com/noise-handshake/download/noise-handshake-3.0.0.tgz","fileCount":12,"unpackedSize":33518,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC212AQf23QjuOTPSCL8GRAGoGLshPM+LG2rzq2LTSvwQIhALwQuZOlUrrWtSn4r5H9cggxydntimFUCoj9eI+eYLVP"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjKyVxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrbcA/9FV2RxWXHfLLSeidJJ2Gwu4MFLbq0cOwEr9U5Mb/2GJeLb4Pl\r\nZHPaX3rI7NeJ53J2VtNROFpi2s0Uhe2ehNL4npczKXXkVYsUquB0QeKP5p3N\r\nW8pEVIxBPoU6xds+R+St7tXy8uZyW3XGbYkJntIwINAsihJHMw1EWfprXWGs\r\nhlqdHWUMAoMt3YkYYfd4tQcT5rXvpHvOHtasFrZaK26LIk0nSHCciP0q71JX\r\nBW+5x6ZX9+r9Na977eNJaPShe8ceRptWHOCo18M57ClkbO0JQDES7xvpXmjc\r\nRnYtCzvxreN/uBVfHOhCILe75AEoQPhXHQaluPcx2QQRZtDLTf0blYrc4BEJ\r\np098Gwpa5FFtd/zzrk5EDpnOVoCwYfgn1Dq5/MaPOuZzsg4XViVfrA70poAl\r\nj4QVVzpx8fU1DXmDWYKJ/ek1Belv+duxyMWuc+tbIvLM70g6iBuZEQBKOzF6\r\nsbRCuer3xQAnZhgGBSfezmVjKmvI8RvtSw4NiqTYa4IvFz1xdS7hzij7t/p2\r\nYdEehIg3q4tPgUpPtsuVrqRA9bHTX7r4PjRPis23g6+xCIFEDZrqrqP7yjuq\r\nIBp7hUTU9TnK/SU9XO7DqOAyYdKt3RYbMSp//7Quh6OUZrkmY0l3NOqiWczi\r\n9cVjI9AlPbcI9doQ4EE61KVJhn5S6F7Hzbk=\r\n=XIoW\r\n-----END PGP SIGNATURE-----\r\n","size":6937,"noattachment":false,"key":"/noise-handshake/-/noise-handshake-3.0.0.tgz"},"_npmUser":{"name":"chm-diederichs","email":"chm-diederichs@protonmail.com"},"directories":{},"maintainers":[{"name":"chm-diederichs","email":"chm-diederichs@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-handshake_3.0.0_1663772016833_0.7474750194321726"},"_hasShrinkwrap":false,"readme":"# noise-handshake\n\n## Usage\n```js\nconst Noise = require('noise-handshake')\nconst Cipher = require('noise-handshake/cipher')\nconst initiator = new Noise('IK', true)\nconst responder = new Noise('IK', false)\n\nconst prologue = Buffer.alloc(0)\n\n// preshared key\ninitiator.initialise(prologue, responder.s.publicKey)\nresponder.initialise(prologue)\n\n// -> e, es, s, ss\nconst message = initiator.send()\nresponder.recv(message)\n\n// <- e, ee, se\nconst reply = responder.send()\ninitiator.recv(reply)\n\nconsole.log(initiator.complete) // true\n\n// convention is to use rx for\n// sending and tx for receiving\n\n// initiator.rx === responder.tx\n// responder.rx === initiator.tx\n\n// instantiate a cipher using shared secrets\nconst send = new Cipher(initiator.tx)\nconst recieve = new Cipher(responder.rx)\n\nconst msg = Buffer.from('hello, world')\n\nconst enc = send.encrypt(msg)\nconsole.log(recieve.decrypt(enc)) // hello, world\n```\n\n## API\n\n#### `const peer = new Noise(pattern, initiator, staticKeypair, [opts])`\n\nCreate a new handshake state for a given pattern. Initiator should be either `true` or `false` depending on the role. A preexisting keypair may be passed as `staticKeypair`\n\n`opts` may be used to pass in the following:\n- `curve`: module for performing Noise over other curves.\n- `psk`: a 32-byte buffer containing a pre-shared key for patterns containing `psk0`. (Other psk positions are not currently supported.)\n\nCurve modules should export the following:\n```\n{\n  DHLEN,\n  PKLEN,\n  SKLEN,\n  ALG,\n  generateKeyPair,\n  dh\n}\n```\n\nSee [dh.js](./dh) for an example.\n\n#### `peer.initialise(prologue, remoteStatic)`\n\nInitialise the handshake state with a prologue and any preshared keys.\n\n#### `const buf = send([payload])`\n\nSend the next message in the handshake, add an optional payload buffer to be included in the message, payload is a zero length buffer by default.\n\n#### `const payload = peer.recv(buf)`\n\nReceive a handshake message from the peer and return the encrypted payload.\n\n#### `peer.complete`\n\n`true` or `false`. Indicates whether `rx` and `tx` have been created yet.\n\nWhen complete, the working handshake state shall be cleared *only* the following state shall remain on the object:\n\n```js\n{\n  tx, // session key to decrypt messages from remote peer\n  rx, // session key to encrypt messages to remote peer\n  rs, // the remote peer's public key,\n  hash, // a hash of the entire handshake state\n}\n```\n","publish_time":1663772017002,"_cnpm_publish_time":1663772017002,"dist-tags":{"latest":"4.2.0"}}