{"name":"noise-handshake","version":"2.1.1","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":{"bint8array":"^1.1.3","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":"27f4177cfda31e0b0ee6794cace9afcf039feeba","bugs":{"url":"https://github.com/chm-diederichs/noise-handshake/issues"},"homepage":"https://github.com/chm-diederichs/noise-handshake#readme","_id":"noise-handshake@2.1.1","_nodeVersion":"14.17.3","_npmVersion":"6.14.13","dist":{"integrity":"sha512-g5dFZ+Seh8AeoTXSxyuXrBSpyxR6l7nW9NKZZfO4Sxy9gRaJ4x/izTk4lLKDPfWiXxzGHpayyJlZjBSSCdusqQ==","shasum":"eb148da857994f8941759b3b34d8fba2a1a236e5","tarball":"http://registry-npm.ywwl.com/noise-handshake/download/noise-handshake-2.1.1.tgz","fileCount":12,"unpackedSize":34068,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhnX1oCRA9TVsSAnZWagAA2ZwP/i3GS2IQzDBoBwNdXUIk\nHWbCzOY2Fz3E8Z/cYfW6bTA8NK7+ywMkPP3xWhfv0zs+0X/MLUihpZggPPcV\nlxJStd4EJudMu6w3dWQQKpi1RjoD0qaJal59Vrl0xIZoXcrnB9dvsA3c65VH\nBl0FwPbS6Mj3LVi0m58y9bAs5tMPSqeVT22JMsxplY4aNGCfOe/sir8uArKu\nyL/Z28Cpu5nvK+NWlVO7/YxbKMeg+KUNbbFPUZvb+HO7MIUESKcaXMrT1cEY\nv0gxlnUe+Z8Fle1EFeBald5wvDSonSbXKDE62lj/LTHoStrpFwkT5vK4dCFA\nm8/LN6man+fY/fkNqgHRlc84lDWMgsoAfQ/R17WCCH4/erBoQtMXRJXxDSK8\nh+ItsFMKND+yGk3CZYjvUielHEdCT2IJ7Vh8QdG/hAg1VMxT8ZYfhmQswg5W\navSQXNMlLgptseF8JR23xe62Hd6OH+VMJfF2NsRrtloe7rnJ41L9fVpuIJdx\n2Up8LJX0OttKrb3QJJgyJo5fI/FDN+2svex0g8pIbn7vXqQNZCtuwKU4Re+I\nuSLeTPH57kNbARKqN6oSO/zVnJ4W0r+WTslzuv9H6Au5W8Lo6Kpv55YZyeDu\nJEsK3s3kojophYV76JHZCwgxuvBxAgdiNrrBZ1erkP4ineyr0Uj/Olm3X/rG\n11X9\r\n=0yOU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCDIjf3IgnaTf15bQ02oQKhOjoIpNw36LIgagrwX/un4QIgV6n6TsyZw8Uwzf/PIo1MYaua6Te9hW8SnMPV1nnK/5Y="}],"size":7015,"noattachment":false,"key":"/noise-handshake/-/noise-handshake-2.1.1.tgz"},"_npmUser":{"name":"chm-diederichs","email":"christophe.diederichs@googlemail.com"},"directories":{},"maintainers":[{"name":"chm-diederichs","email":"christophe.diederichs@googlemail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-handshake_2.1.1_1637711208119_0.5244038574912593"},"_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":1637711208301,"_cnpm_publish_time":1637711208301,"dist-tags":{"latest":"4.2.0"}}