{"_id":"noise-protocol","_rev":"239163","name":"noise-protocol","description":"Javascript implementation of the Noise Protocol Framework based on libsodium","dist-tags":{"latest":"3.0.2"},"maintainers":[{"name":"emilbayes","email":""}],"time":{"modified":"2023-03-24T16:52:38.000Z","created":"2018-08-07T17:22:28.216Z","3.0.2":"2023-01-12T22:16:37.936Z","3.0.1":"2020-09-24T08:28:18.356Z","3.0.0":"2020-08-31T09:43:19.450Z","2.0.0":"2020-05-12T23:18:18.126Z","1.0.0":"2018-11-14T11:25:06.417Z","0.3.1":"2018-11-14T11:23:49.505Z","0.3.0":"2018-11-14T09:23:37.789Z","0.2.1":"2018-10-03T12:19:34.309Z","0.2.0":"2018-10-03T12:09:52.706Z","0.1.1":"2018-08-07T17:22:28.216Z"},"users":{},"author":{"name":"Emil Bay","email":"github@tixz.dk"},"repository":{"type":"git","url":"git+https://github.com/emilbayes/noise-protocol.git"},"versions":{"3.0.2":{"name":"noise-protocol","version":"3.0.2","description":"Javascript implementation of the Noise Protocol Framework based on libsodium","main":"index.js","dependencies":{"clone":"^2.1.2","hmac-blake2b":"^2.0.2","nanoassert":"^2.0.0","sodium-universal":"^4.0.0"},"devDependencies":{"browserify":"^17.0.0","c8":"^7.12.0","standard":"^17.0.0","tape":"^5.6.1","tape-run":"^10.0.0"},"scripts":{"pretest":"standard","test":"tape 'test/**/*.js'","posttest":"browserify --debug test/**/*.js | tape-run","coverage":"c8 npm test"},"repository":{"type":"git","url":"git+https://github.com/emilbayes/noise-protocol.git"},"keywords":[],"author":{"name":"Emil Bay","email":"github@tixz.dk"},"license":"ISC","bugs":{"url":"https://github.com/emilbayes/noise-protocol/issues"},"homepage":"https://github.com/emilbayes/noise-protocol#readme","gitHead":"8e139740bdaccc0f5b282bbeca3e77b1a7cbb07e","_id":"noise-protocol@3.0.2","_nodeVersion":"19.3.0","_npmVersion":"8.19.2","dist":{"shasum":"550f7ae6ddab0073ac1d12bd9c1390a43599c49e","size":11587,"noattachment":false,"key":"/noise-protocol/-/noise-protocol-3.0.2.tgz","tarball":"http://name.csiicloud.com:7001/noise-protocol/download/noise-protocol-3.0.2.tgz"},"_npmUser":{"name":"emilbayes","email":"github@tixz.dk"},"directories":{},"maintainers":[{"name":"emilbayes","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-protocol_3.0.2_1673561797606_0.5836662849892804"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-01-12T22:16:37.936Z","publish_time":1673561797936,"_cnpm_publish_time":1673561797936},"3.0.1":{"name":"noise-protocol","version":"3.0.1","description":"Javascript implementation of the Noise Protocol Framework based on libsodium","main":"index.js","dependencies":{"clone":"^2.1.2","hmac-blake2b":"^2.0.0","nanoassert":"^2.0.0","sodium-universal":"^3.0.2"},"devDependencies":{"browserify":"^16.5.1","c8":"^7.1.2","standard":"^14.3.4","tape":"^5.0.0","tape-run":"^7.0.0"},"scripts":{"pretest":"standard","test":"tape 'test/**/*.js'","posttest":"browserify --debug test/**/*.js | tape-run","coverage":"c8 npm test"},"repository":{"type":"git","url":"git+https://github.com/emilbayes/noise-protocol.git"},"keywords":[],"author":{"name":"Emil Bay","email":"github@tixz.dk"},"license":"ISC","bugs":{"url":"https://github.com/emilbayes/noise-protocol/issues"},"homepage":"https://github.com/emilbayes/noise-protocol#readme","gitHead":"331566df32160ce8a7fdfab9d4556b00301af999","_id":"noise-protocol@3.0.1","_nodeVersion":"14.4.0","_npmVersion":"6.14.5","dist":{"shasum":"e1102eceebf8ac4a7b00d7ff911bab3a769fc3ac","size":12173,"noattachment":false,"key":"/noise-protocol/-/noise-protocol-3.0.1.tgz","tarball":"http://name.csiicloud.com:7001/noise-protocol/download/noise-protocol-3.0.1.tgz"},"maintainers":[{"name":"emilbayes","email":""}],"_npmUser":{"name":"emilbayes","email":"github@tixz.dk"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-protocol_3.0.1_1600936098203_0.28672364736621603"},"_hasShrinkwrap":false,"publish_time":1600936098356,"_cnpm_publish_time":1600936098356,"_cnpmcore_publish_time":"2021-12-16T22:50:02.860Z"},"3.0.0":{"name":"noise-protocol","version":"3.0.0","description":"Javascript implementation of the Noise Protocol Framework based on libsodium","main":"index.js","dependencies":{"clone":"^2.1.2","hmac-blake2b":"^2.0.0","nanoassert":"^2.0.0","sodium-universal":"^3.0.2"},"devDependencies":{"browserify":"^16.5.1","c8":"^7.1.2","standard":"^14.3.4","tape":"^5.0.0","tape-run":"^7.0.0"},"scripts":{"pretest":"standard","test":"tape 'test/**/*.js'","posttest":"browserify --debug test/**/*.js | tape-run","coverage":"c8 npm test"},"repository":{"type":"git","url":"git+https://github.com/emilbayes/noise-protocol.git"},"keywords":[],"author":{"name":"Emil Bay","email":"github@tixz.dk"},"license":"ISC","bugs":{"url":"https://github.com/emilbayes/noise-protocol/issues"},"homepage":"https://github.com/emilbayes/noise-protocol#readme","gitHead":"12e1cc580baeaee48e64a6094ce257c4d8207f87","_id":"noise-protocol@3.0.0","_nodeVersion":"14.4.0","_npmVersion":"6.14.5","dist":{"shasum":"53360a3eeee0ec7aee484ab2682e2eb926835b23","size":12163,"noattachment":false,"key":"/noise-protocol/-/noise-protocol-3.0.0.tgz","tarball":"http://name.csiicloud.com:7001/noise-protocol/download/noise-protocol-3.0.0.tgz"},"maintainers":[{"name":"emilbayes","email":""}],"_npmUser":{"name":"emilbayes","email":"github@tixz.dk"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-protocol_3.0.0_1598866999336_0.9119404572808185"},"_hasShrinkwrap":false,"publish_time":1598866999450,"_cnpm_publish_time":1598866999450,"_cnpmcore_publish_time":"2021-12-16T22:50:03.126Z"},"2.0.0":{"name":"noise-protocol","version":"2.0.0","description":"Javascript implementation of the Noise Protocol Framework based on libsodium","main":"index.js","dependencies":{"clone":"^2.1.2","hmac-blake2b":"^1.0.0","nanoassert":"^2.0.0","sodium-native":"^3.1.1"},"devDependencies":{"c8":"^7.1.2","standard":"^14.3.4","tape":"^5.0.0"},"scripts":{"pretest":"standard","test":"tape 'test/**/*.js'","coverage":"c8 npm test"},"repository":{"type":"git","url":"git+https://github.com/emilbayes/noise-protocol.git"},"keywords":[],"author":{"name":"Emil Bay","email":"github@tixz.dk"},"license":"ISC","bugs":{"url":"https://github.com/emilbayes/noise-protocol/issues"},"homepage":"https://github.com/emilbayes/noise-protocol#readme","gitHead":"6de13e7b9008c6299b9028e8eb79dc99878cab00","_id":"noise-protocol@2.0.0","_nodeVersion":"14.2.0","_npmVersion":"6.14.4","dist":{"shasum":"a9544b96dcf41b9c21eb68100f1a5bb0b2657c90","size":11759,"noattachment":false,"key":"/noise-protocol/-/noise-protocol-2.0.0.tgz","tarball":"http://name.csiicloud.com:7001/noise-protocol/download/noise-protocol-2.0.0.tgz"},"maintainers":[{"name":"emilbayes","email":""}],"_npmUser":{"name":"emilbayes","email":"github@tixz.dk"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-protocol_2.0.0_1589325497955_0.38751313745309957"},"_hasShrinkwrap":false,"publish_time":1589325498126,"_cnpm_publish_time":1589325498126,"_cnpmcore_publish_time":"2021-12-16T22:50:03.325Z"},"1.0.0":{"name":"noise-protocol","version":"1.0.0","description":"Javascript implementation of the Noise Protocol Framework based on libsodium","main":"index.js","dependencies":{"clone":"^2.1.2","hmac-blake2b":"^0.2.0","nanoassert":"^1.1.0","sodium-native":"^2.2.1"},"devDependencies":{"c8":"^3.2.0","standard":"^11.0.1","tape":"^4.9.0"},"scripts":{"test":"tape test/**/*","coverage":"c8 npm test"},"repository":{"type":"git","url":"git+https://github.com/emilbayes/noise-protocol.git"},"keywords":[],"author":{"name":"Emil Bay","email":"github@tixz.dk"},"license":"ISC","bugs":{"url":"https://github.com/emilbayes/noise-protocol/issues"},"homepage":"https://github.com/emilbayes/noise-protocol#readme","gitHead":"ad2f08fd09af1eb55433b9d34f71a85979cbbe9d","_id":"noise-protocol@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"11.1.0","_npmUser":{"name":"emilbayes","email":"github@tixz.dk"},"dist":{"shasum":"260e0447ddabc6f1d40f4c5829a64aba38c08768","size":11483,"noattachment":false,"key":"/noise-protocol/-/noise-protocol-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/noise-protocol/download/noise-protocol-1.0.0.tgz"},"maintainers":[{"name":"emilbayes","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-protocol_1.0.0_1542194706277_0.5040437260322093"},"_hasShrinkwrap":false,"publish_time":1542194706417,"_cnpm_publish_time":1542194706417,"_cnpmcore_publish_time":"2021-12-16T22:50:03.541Z"},"0.3.1":{"name":"noise-protocol","version":"0.3.1","description":"Javascript implementation of the Noise Protocol Framework based on libsodium","main":"index.js","dependencies":{"clone":"^2.1.2","hmac-blake2b":"^0.2.0","nanoassert":"^1.1.0","sodium-native":"^2.2.1"},"devDependencies":{"c8":"^3.2.0","standard":"^11.0.1","tape":"^4.9.0"},"scripts":{"test":"tape test/**/*","coverage":"c8 npm test"},"repository":{"type":"git","url":"git+https://github.com/emilbayes/noise-protocol.git"},"keywords":[],"author":{"name":"Emil Bay","email":"github@tixz.dk"},"license":"ISC","bugs":{"url":"https://github.com/emilbayes/noise-protocol/issues"},"homepage":"https://github.com/emilbayes/noise-protocol#readme","gitHead":"475e2a722721312618ae44151daf0369deabb16c","_id":"noise-protocol@0.3.1","_npmVersion":"6.4.1","_nodeVersion":"11.1.0","_npmUser":{"name":"emilbayes","email":"github@tixz.dk"},"dist":{"shasum":"6b17ca6095c3ef53ace06831c4d15f3360f5a778","size":11485,"noattachment":false,"key":"/noise-protocol/-/noise-protocol-0.3.1.tgz","tarball":"http://name.csiicloud.com:7001/noise-protocol/download/noise-protocol-0.3.1.tgz"},"maintainers":[{"name":"emilbayes","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-protocol_0.3.1_1542194629363_0.9465990809805473"},"_hasShrinkwrap":false,"publish_time":1542194629505,"_cnpm_publish_time":1542194629505,"_cnpmcore_publish_time":"2021-12-16T22:50:04.132Z"},"0.3.0":{"name":"noise-protocol","version":"0.3.0","description":"Javascript implementation of the Noise Protocol Framework based on libsodium","main":"index.js","dependencies":{"clone":"^2.1.2","hmac-blake2b":"^0.2.0","nanoassert":"^1.1.0","sodium-native":"^2.2.1"},"devDependencies":{"c8":"^3.2.0","standard":"^11.0.1","tape":"^4.9.0"},"scripts":{"test":"tape test/**/*","coverage":"c8 npm test"},"repository":{"type":"git","url":"git+https://github.com/emilbayes/noise-protocol.git"},"keywords":[],"author":{"name":"Emil Bay","email":"github@tixz.dk"},"license":"ISC","bugs":{"url":"https://github.com/emilbayes/noise-protocol/issues"},"homepage":"https://github.com/emilbayes/noise-protocol#readme","gitHead":"c7ddeebf67101e5132c5369877a29028e5a3e83a","_id":"noise-protocol@0.3.0","_npmVersion":"6.4.1","_nodeVersion":"11.1.0","_npmUser":{"name":"emilbayes","email":"github@tixz.dk"},"dist":{"shasum":"23f51a14fa425946585945f0cfc2814ea0aee4e9","size":11478,"noattachment":false,"key":"/noise-protocol/-/noise-protocol-0.3.0.tgz","tarball":"http://name.csiicloud.com:7001/noise-protocol/download/noise-protocol-0.3.0.tgz"},"maintainers":[{"name":"emilbayes","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-protocol_0.3.0_1542187417603_0.020196830640746954"},"_hasShrinkwrap":false,"publish_time":1542187417789,"_cnpm_publish_time":1542187417789,"_cnpmcore_publish_time":"2021-12-16T22:50:04.412Z"},"0.2.1":{"name":"noise-protocol","version":"0.2.1","description":"Javascript implementation of the Noise Protocol Framework based on libsodium","main":"index.js","dependencies":{"clone":"^2.1.2","hmac-blake2b":"^0.2.0","nanoassert":"^1.1.0","sodium-native":"^2.2.1"},"devDependencies":{"c8":"^3.2.0","standard":"^11.0.1","tape":"^4.9.0"},"scripts":{"test":"tape test/**/*","coverage":"c8 npm test"},"repository":{"type":"git","url":"git+https://github.com/emilbayes/noise-protocol.git"},"keywords":[],"author":{"name":"Emil Bay","email":"github@tixz.dk"},"license":"ISC","bugs":{"url":"https://github.com/emilbayes/noise-protocol/issues"},"homepage":"https://github.com/emilbayes/noise-protocol#readme","gitHead":"217990e3035fb8dac5fbf5eca281f93e2f1dede4","_id":"noise-protocol@0.2.1","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"emilbayes","email":"github@tixz.dk"},"dist":{"shasum":"c5c124f3711c75ed120536230fe0fb37eac65951","size":11373,"noattachment":false,"key":"/noise-protocol/-/noise-protocol-0.2.1.tgz","tarball":"http://name.csiicloud.com:7001/noise-protocol/download/noise-protocol-0.2.1.tgz"},"maintainers":[{"name":"emilbayes","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-protocol_0.2.1_1538569174153_0.06814527613738841"},"_hasShrinkwrap":false,"publish_time":1538569174309,"_cnpm_publish_time":1538569174309,"_cnpmcore_publish_time":"2021-12-16T22:50:04.612Z"},"0.2.0":{"name":"noise-protocol","version":"0.2.0","description":"Javascript implementation of the Noise Protocol Framework based on libsodium","main":"index.js","dependencies":{"clone":"^2.1.2","hmac-blake2b":"^0.2.0","nanoassert":"^1.1.0","sodium-native":"^2.2.1"},"devDependencies":{"c8":"^3.2.0","standard":"^11.0.1","tape":"^4.9.0"},"scripts":{"test":"tape test/**/*","coverage":"c8 npm test"},"repository":{"type":"git","url":"git+https://github.com/emilbayes/noise-protocol.git"},"keywords":[],"author":{"name":"Emil Bay","email":"github@tixz.dk"},"license":"ISC","bugs":{"url":"https://github.com/emilbayes/noise-protocol/issues"},"homepage":"https://github.com/emilbayes/noise-protocol#readme","gitHead":"119304325d7b36848eebe345ad085fa94c25734a","_id":"noise-protocol@0.2.0","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"emilbayes","email":"github@tixz.dk"},"dist":{"shasum":"9e262a6b7246c1f7b4e0f80d8bd17179b974b1ad","size":102726,"noattachment":false,"key":"/noise-protocol/-/noise-protocol-0.2.0.tgz","tarball":"http://name.csiicloud.com:7001/noise-protocol/download/noise-protocol-0.2.0.tgz"},"maintainers":[{"name":"emilbayes","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-protocol_0.2.0_1538568592581_0.4265063832064271"},"_hasShrinkwrap":false,"publish_time":1538568592706,"_cnpm_publish_time":1538568592706,"_cnpmcore_publish_time":"2021-12-16T22:50:04.977Z"},"0.1.1":{"name":"noise-protocol","version":"0.1.1","description":"Javascript implementation of the Noise Protocol Framework based on libsodium","main":"index.js","dependencies":{"hmac-blake2b":"^0.2.0","nanoassert":"^1.1.0","sodium-native":"^2.2.1"},"devDependencies":{"standard":"^11.0.1","tape":"^4.9.0"},"scripts":{"test":"tape test/**/*"},"repository":{"type":"git","url":"git+https://github.com/emilbayes/noise-protocol.git"},"keywords":[],"author":{"name":"Emil Bay","email":"github@tixz.dk"},"license":"ISC","bugs":{"url":"https://github.com/emilbayes/noise-protocol/issues"},"homepage":"https://github.com/emilbayes/noise-protocol#readme","gitHead":"d961357ac0a90976f1b0bb2e5a4884fb16ec7219","_id":"noise-protocol@0.1.1","_shasum":"2bf39aaf3e8d846846c3fc59202a12a36a92941c","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.5","_npmUser":{"name":"emilbayes","email":"github@tixz.dk"},"dist":{"shasum":"2bf39aaf3e8d846846c3fc59202a12a36a92941c","size":11161,"noattachment":false,"key":"/noise-protocol/-/noise-protocol-0.1.1.tgz","tarball":"http://name.csiicloud.com:7001/noise-protocol/download/noise-protocol-0.1.1.tgz"},"maintainers":[{"name":"emilbayes","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noise-protocol_0.1.1_1533662548115_0.10100955323612726"},"_hasShrinkwrap":false,"publish_time":1533662548216,"_cnpm_publish_time":1533662548216,"_cnpmcore_publish_time":"2021-12-16T22:50:05.255Z"}},"readme":"# `noise-protocol`\n\n[![Build Status](https://github.com/emilbayes/noise-protocol/actions/workflows/npm.yml/badge.svg?branch=master)](https://github.com/emilbayes/noise-protocol/actions/workflows/npm.yml)\n\n> Javascript implementation of the Noise Protocol Framework based on libsodium\n\n:rotating_light: :warning: :rotating_light: BETA :rotating_light: :warning: :rotating_light:\n\nNote that this implementation is low level and requires knowledge of the\n[Noise Protocol Framework](http://noiseprotocol.org/noise.html), and is aimed to\nbe a building block for higher-level modules wishing to implement\napplication-specific handshakes securely.\n\nThis module only implements the `Noise_*_25519_ChaChaPoly_BLAKE2b` handshake,\nmeaning `Curve25519` for DH, `ChaCha20Poly1305` for AEAD and `BLAKE2b` for\nhashing.\n\n## Usage\n\n```js\nvar noise = require('noise-protocol')\n\nvar sClient = noise.keygen()\nvar sServer = noise.keygen()\n\n// Initialize a Noise_KK_25519_ChaChaPoly_BLAKE2b handshake\nvar client = noise.initialize('KK', true, Buffer.alloc(0), sClient, null, sServer.publicKey)\nvar server = noise.initialize('KK', false, Buffer.alloc(0), sServer, null, sClient.publicKey)\n\nvar clientTx = Buffer.alloc(128)\nvar serverTx = Buffer.alloc(128)\n\nvar clientRx = Buffer.alloc(128)\nvar serverRx = Buffer.alloc(128)\n\n// -> e, es, ss\nnoise.writeMessage(client, Buffer.alloc(0), clientTx)\nnoise.readMessage(server, clientTx.subarray(0, noise.writeMessage.bytes), serverRx)\n\n// <- e, ee, se\nvar serverSplit = noise.writeMessage(server, Buffer.alloc(0), serverTx)\nvar clientSplit = noise.readMessage(client, serverTx.subarray(0, noise.writeMessage.bytes), clientRx)\n\n// Safely dispose of finished HandshakeStates\nnoise.destroy(client)\nnoise.destroy(server)\n\n// Can now do transport encryption with splits\nconsole.log(serverSplit)\nconsole.log(clientSplit)\n```\n\n## API\n\n### Constants\n\n- `noise.PKLEN` length of a public key in bytes\n- `noise.SKLEN` length of a secret key in bytes\n\n### Supported Patterns\n\nAll one-way and fundamental handshake patterns are currently supported:\n\n- `N`\n- `K`\n- `X`\n- `NN`\n- `KN`\n- `NK`\n- `KK`\n- `NX`\n- `KX`\n- `XN`\n- `IN`\n- `XK`\n- `IK`\n- `XX`\n- `IX`\n\n### `var handshakeState = noise.initialize(handshakePattern, initiator, prologue, [staticKeys], [ephemeralKeys], [remoteStaticKey], [remoteEphemeralKey])`\n\nCreate a new Noise handshake instance with:\n\n* `handshakePattern` must be String and one of [supported patterns](#supported-patterns)\n* `initiator` must be Boolean\n* `prologue` must be Buffer. This can be an empty Buffer (`Buffer.alloc(0)`) if\n  not used\n* `staticKeys` is local static keys as an object of `{publicKey, secretKey}`.\n  This is only required if the handshake pattern mandates these as shared out of band (premessages)\n* `ephemeralKeys` is local ephemeral keys as an object of `{publicKey, secretKey}`.\n  This is only required if the handshake pattern mandates these as shared out of band (premessages)\n* `remoteStaticKey` is a Buffer of `PKLEN` bytes. This is most likely not required\n* `remoteEphemeralKey` is a Buffer of `PKLEN` bytes. This is most likely not required\n\n:alert: Key material passed in is copied into libsodium Secure Buffers, which\ncan be cleared with `noise.destroy(state)`. Be aware that you manually have to\ndestroy this state object, unless you want to rely on GC clearing it for you.\n\nReturns a `HandshakeState` object, which should be treated as an opaque object.\nThis state is passed as the first argument to subsequent `noise` functions.\n\n### `var maybeSplit = noise.writeMessage(state, payload, messageBuffer)`\n\nProcess a new message pattern and write any output to be transmitted to the\nreceiving party into `messageBuffer`. Any payload data can be passed as\n`payload`, or the empty Buffer in case of no payload.\n\n* `state` must be a `HandshakeState` as returned by `noise.initialize`\n* `payload` must be Buffer. Use the empty Buffer (`Buffer.alloc(0)`) in case of\n  no payload. Whether it is safe to send a `payload` at a specific step of the\n  handshake is at the discretion of the user. Please refer to [Noise - 7.3. Handshake pattern validity](http://noiseprotocol.org/noise.html#handshake-pattern-validity)\n* `messageBuffer` must be Buffer. In the worst case it requires\n  `PKLEN + PKLEN + MACLEN` (32 + 32 + 16) bytes, for a two keys and a MAC,\n  plus any bytes required for `payload.byteLength + MACLEN` (`MACLEN = 16`)\n\nIf no more message patterns are left to process, a **Split** will occur. Please\nsee below for details. If more patterns are pending, nothing is returned.\n\nThe function may throw an error if:\n* There are no more message patterns to be processed (meaning a split already\n  occurred)\n* The current state expects a message to be read and not written\n* The `HandshakeState` is invalid for the current message pattern\n* `messageBuffer` is too small to contain the required data\n* An encryption error occurred\n\nIn any of these cases there was a misuse and the `HandshakeState` should be\n`noise.destroy`ed and connection aborted.\n\n### `noise.writeMessage.bytes`\n\nThis property is set after `noise.writeMessage` has been successfully executed\nand signals how many bytes were written to `messageBuffer`\n\n### `var maybeSplit = noise.readMessage(state, message, payloadBuffer)`\n\nProcess a new message pattern and read any input received from `message`.\nAny remaining data in `message` is treated as payload data and will be decrypted\n(depending on the `HandshakeState`) and written to `payloadBuffer`.\n\n* `state` must be a `HandshakeState` as returned by `noise.initialize`\n* `message` must be a Buffer, as produced by `noise.writeMessage`. Any framing\n  or length information is left to the application as described in the Noise\n  Specification.\n* `payloadBuffer` must be Buffer. Use the empty Buffer (`Buffer.alloc(0)`) if no\n  payload is expected, though this may throw an error if a payload is attempted\n  written\n\nIf no more message patterns are left to process, a **Split** will occur. Please\nsee below for details. If more patterns are pending, nothing is returned.\n\nThe function may throw an error if:\n* There are no more message patterns to be processed (meaning a split already\n  occurred)\n* The current state expects a message to be written and not read\n* The `HandshakeState` is invalid for the current message pattern\n* `payloadBuffer` is too small for the required data\n* An decryption error occurred\n\nIn any of these cases there was a misuse and the `HandshakeState` should be\n`noise.destroy`ed and connection aborted.\n\n### `noise.readMessage.bytes`\n\nThis property is set after `noise.readMessage` has been successfully executed\nand signals how many bytes were written to `payloadBuffer`\n\n### `noise.destroy(state)`\n\nTakes a `HandshakeState` and destroys all internal data (eg. securely zeros out\ndata contained in Buffer-like objects and resets state). Use this to dispose of\nstate objects after a split has occurred or upon error\n\n### Split\n\nIf no more message patterns are left to process, a **Split** will occur, as\ndescribed in the Noise Specification. In this implementation an object with\n`{tx: Buffer, rx: Buffer}` will be returned, each being a\n[`sodium-native` Secure Buffer](https://github.com/sodium-friends/sodium-native#memory-protection)\ncontaining a cipher state as a contiguous piece of memory. It is encoded as\n`32 byte k | 8 byte n`, as describe in the Noise Specification. You can either\nchoose to use these Buffers with the [`cipherState`](cipher-state.js)\nfunctions or extract values and use with another transport encryption, as long\nas you are aware of the security implication of either choice. For initiator and\nresponder, `tx` and `rx` are opposite so a responders `rx` is equal to an\ninitiators `tx`.\n\n### Custom algorithms\n\nYou can customise the handshake state by calling `noise.createHandshake(algs)`\nwith `algs = { dh, hash, cipher, cipherState, symmetricState }`. Please refer\nto the respective implementations in the source to see how to swap pieces.\nPlease note that this is dangerous, unless you've read the noise specification\nvery carefully and know what you are doing. `createHandshake` will then return\na new `initialize` function from which you can create start handshakes with\nyour custom algorithms.\n\n## Install\n\n```sh\nnpm install noise-protocol\n```\n\n## Deviations from the Noise specification\n\n* Functions follow the `fn(state, output, args...)` convention\n* Names the 16 bytes for an authentication tag as `MACLEN`\n\n## Unsupported features\n\n- Any other cryptographic primitives than the ones mentioned above\n- PSK, fallback and deferred patterns. Support may be added at a later time\n\n## License\n\n[ISC](LICENSE)\n","_attachments":{},"homepage":"https://github.com/emilbayes/noise-protocol#readme","bugs":{"url":"https://github.com/emilbayes/noise-protocol/issues"},"license":"ISC"}