{"name":"noise-handshake","version":"1.2.0","description":"## Usage ```js const Noise = require('basic-noise') 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":{"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":"ac49dd17295560ab0ec43cc88342f0055ff6f9ca","bugs":{"url":"https://github.com/chm-diederichs/noise-handshake/issues"},"homepage":"https://github.com/chm-diederichs/noise-handshake#readme","_id":"noise-handshake@1.2.0","_nodeVersion":"12.18.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-e5KZzv6Dz6cArOmMPWcIIj65hjZEyvRvMUi9SlyXSgdB1tavuwkC0Zminy09jdhv3iA6Gk2iwr/Mc/hqJDQ/wA==","shasum":"d4e5cd87d2c5b066f6cc25ee4277f741337593d2","tarball":"http://registry-npm.ywwl.com/noise-handshake/download/noise-handshake-1.2.0.tgz","fileCount":13,"unpackedSize":33064,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg8XJZCRA9TVsSAnZWagAA+uIP+weUo6l5Gfvtng+zQg7y\nU8ct1GWMRWFoobWlD38zC2FWHIt/l1GiqOM+xpRMNS6Oc9HAMfyrDlCREFIY\ne327RcX066yhuRtPp5pt7BeDK8+qARL458S/cVMEDOkzL/4jnbnNxb35Zfto\n5XsMWGRS8YkDbLpXzurujN6JgFfAvQq5s5FrbyMCe+aYkVJcF/q9WMl1Mu0Q\n3a8zKkj9NF66zNhf4tVY5EnwjfaOun63MtmbEN+JJsg2x0TN+XCWBHk27ueV\nBRY42m8LLk2s9gUB9CvINu/Tgo3iiiu67p/UKiwGffLc1UD/qMwieXhKyvqX\nlcBqsIKBiSPWrt88xFMO+OHe1eg63xif60YKTozDJCP4nWTF7deNe8eM1D+Y\n2EouuKeYNGYH8XNzavZGbDT2eCXs5UUR0fthYqvh84XSDOGui2cH6ZfeJyqu\n/4jh7eLpGOxMvNSqb0uP10wbTWQYtRTqdjf31rGNouPgo8a9Z2qfOjZpDYHG\niwGt3Ok+44CuYIsncy4ICedNfH0a2iozXRPniL8Nzr+VwCuSTcwIPQhMvXTN\nQwbN1x9t1zR8CseA+w3qzCIMufLegWlm9T0RJ/tbY6SkugK9TegbEu2PnOow\nX/I1tmBVx/nB8KsZkO0fE/RgROq0mFQwZeDtb8ssbklH1kaQwXXp90Uxpcyw\nFPyd\r\n=K+8l\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFc5AnDKLi8UQoX2z6r9NO9EpZuhops8ptsqphaufornAiEA/YGk435kc8+VRVOnEwYElVjsWyEtUOc8V9vg0kniQ28="}],"size":6914,"noattachment":false,"key":"/noise-handshake/-/noise-handshake-1.2.0.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_1.2.0_1626436185044_0.9414486002340365"},"_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":1626436185178,"_cnpm_publish_time":1626436185178,"dist-tags":{"latest":"4.2.0"}}