{"name":"noise-handshake","version":"1.2.1","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":"70bbdf05f79571a53398c648f8bb3fa01e02aae1","bugs":{"url":"https://github.com/chm-diederichs/noise-handshake/issues"},"homepage":"https://github.com/chm-diederichs/noise-handshake#readme","_id":"noise-handshake@1.2.1","_nodeVersion":"12.18.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-64vJk0o8if6LLoQ8AquVaT3HWfoQEJN75OgrWt64kQGw2EpUVRb2v3nR/36px5SIm27Dk8qTsDXoG+db4U1b4g==","shasum":"2dfc65fed52ee524b45e0b72ccc1a64b02dc959c","tarball":"http://registry-npm.ywwl.com/noise-handshake/download/noise-handshake-1.2.1.tgz","fileCount":13,"unpackedSize":32049,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg8Xm1CRA9TVsSAnZWagAAhAsQAJVvpvfygqj6ECG1zE2B\n5h1kfBx7XNEr3wh6EWhPE0lIqoCzV1fxhipfteSDjnPvPimfa21ynJQAFBSc\n2Y6c6twfzxfVWhJrt+4jmYaTZUTFpK+ovhIhBlcNWwiLHS/TCZQAs6sJLmuH\nECL9tdWap6RgHTooDcodDb67DTemIICUlq/I1nFwdfPBkkKSEnUE9oUvavbT\nFHaNqUoEXN+I+jFNmtUYF4secriXSvahVisz9QqR+ZC4t5hH57CjgYIvA+43\nk298kFNYshWqonVkZH6hYPsnDQGWTdvujk/zo04LmInstHsxxwnlU7L/0TXh\nLfCMryOHRW+JFpamXIOLDKU8LtxFNACIpTTf/QC3c/pwtXSyjCCsbroPKAvY\nKeX/oKKqkH9jSquRyIumJRS0rmaJ+Cthlv3Zob9FZW0Yt5QbvBmf4KRfdmeV\nrJgLm40QMFOL5Vm3c3a7Apfu3shEmMP6OSKUAkASLVxjw4E24ZCtZ7H5cH0Z\nDB3m0S3UX1AjsGr4rcLNTCXGH+R6ZpTwQHLyUfORefFmHvQ25SMHS333oR55\nvqm+zIK+evMzT7SI5zlaMwb7Tk+V3HHGMsag06mFp8c74qBQbHUzaDRkb3e2\n87pHDiE+tymd3fTu88dLd39tGBMAOFPxTa1RTlHvHNSwC5IvMxhV0wWMSNwl\n+mkk\r\n=J8YK\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCT4qxe0GMeDeP3kmyUAB9vZfQN4Fs2y1a1nmcXX/dHcwIgMuC25WaNPqG9gLhc6usjTFiRhGmW8UnmtI+T4HObKrg="}],"size":6813,"noattachment":false,"key":"/noise-handshake/-/noise-handshake-1.2.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_1.2.1_1626438068853_0.962004765283963"},"_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":1626438069034,"_cnpm_publish_time":1626438069034,"dist-tags":{"latest":"4.2.0"}}