{"action":"created","comment":{"url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/comments/155705166","pull_request_review_id":82065464,"id":155705166,"diff_hunk":"@@ -513,116 +405,92 @@ The structure of packets on the wire resembles the following:\n +-------------------------------\n |                               |\n |                               |\n-|     encrypted lightning       |\n+|     encrypted Lightning       |\n |            message            |\n |                               |\n +-------------------------------\n |     16-byte MAC of the        |\n-|      lightning message        |\n+|      Lightning message        |\n +-------------------------------\n ```\n-The prefixed message length is encoded as a `2-byte` big-endian integer,\n+The prefixed message length is encoded as a 2-byte big-endian integer,\n for a total maximum packet length of `2 + 16 + 65535 + 16` = `65569` bytes.\n \n ### Encrypting Messages\n \n-\n-In order to encrypt a lightning message (`m`), given a sending key (`sk`), and a nonce\n+In order to encrypt a Lightning message (`m`), given a sending key (`sk`) and a nonce\n (`sn`), the following is done:\n \n-\n-  * let `l = len(m)`,\n-     where `len` obtains the length in bytes of the lightning message.\n-\n-\n-  * Serialize `l` into `2-bytes` encoded as a big-endian integer.\n-\n-\n-  * Encrypt `l` using `ChaChaPoly-1305`, `sn`, and `sk` to obtain `lc`\n-    (`18-bytes`)\n-    * The nonce `sn` is encoded as a 96-bit little-endian number. As our\n-      decoded nonces a 64-bit, we encode the 96-bit nonce as follows: 32-bits\n+  * let `l = len(m)`\n+    * where `len` obtains the length in bytes of the Lightning message\n+  * Serialize `l` into 2 bytes encoded as a big-endian integer.\n+  * Encrypt `l` using `ChaChaPoly-1305`, `sn`, and `sk`, to obtain `lc`\n+    (18 bytes)\n+    * The nonce `sn` is encoded as a 96-bit little-endian number. As the\n+      decoded nonce is 64 bits, the 96-bit nonce is encoded as: 32 bits\n       of leading zeroes followed by a 64-bit value.\n         * The nonce `sn` MUST be incremented after this step.\n     * A zero-length byte slice is to be passed as the AD (associated data).\n-\n-  * Finally encrypt the message itself (`m`) using the same procedure used to\n+  * Finally, encrypt the message itself (`m`) using the same procedure used to\n     encrypt the length prefix. Let encrypted ciphertext be known as `c`.\n     * The nonce `sn` MUST be incremented after this step.\n-\n   * Send `lc || c` over the network buffer.\n \n \n ### Decrypting Messages\n \n-\n In order to decrypt the _next_ message in the network stream, the following is\n done:\n \n-\n-  * Read _exactly_ `18-bytes` from the network buffer.\n-\n-\n+  * Read _exactly_ 18 bytes from the network buffer.\n   * Let the encrypted length prefix be known as `lc`\n-\n-\n-  * Decrypt `lc` using `ChaCha20-Poly1305`, `rn`, and `rk` to obtain size of\n+  * Decrypt `lc` using `ChaCha20-Poly1305`, `rn`, and `rk`, to obtain the size of\n     the encrypted packet `l`.\n     * A zero-length byte slice is to be passed as the AD (associated data).\n     * The nonce `rn` MUST be incremented after this step.\n-\n-\n   * Read _exactly_ `l+16` bytes from the network buffer, let the bytes be known as\n     `c`.\n-\n-\n-  * Decrypt `c` using `ChaCha20-Poly1305`, `rn`, and `rk` to obtain decrypted\n+  * Decrypt `c` using `ChaCha20-Poly1305`, `rn`, and `rk`, to obtain decrypted\n     plaintext packet `p`.\n-\n     * The nonce `rn` MUST be incremented after this step.\n \n \n ## Lightning Message Key Rotation\n \n-\n-Changing keys regularly and forgetting the previous key is useful for\n-preventing decryption of old messages in the case of later key leakage (ie.\n+Changing keys regularly and forgetting previous keys is useful to\n+prevent the decryption of old messages in the case of later key leakage (i.e.","path":"08-transport.md","position":705,"original_position":705,"commit_id":"913751ef6ecd242ae3334ff5d442b7f0b7e356e3","original_commit_id":"913751ef6ecd242ae3334ff5d442b7f0b7e356e3","user":{"login":"toadlyBroodle","id":13908213,"avatar_url":"https://avatars1.githubusercontent.com/u/13908213?v=4","gravatar_id":"","url":"https://api.github.com/users/toadlyBroodle","html_url":"https://github.com/toadlyBroodle","followers_url":"https://api.github.com/users/toadlyBroodle/followers","following_url":"https://api.github.com/users/toadlyBroodle/following{/other_user}","gists_url":"https://api.github.com/users/toadlyBroodle/gists{/gist_id}","starred_url":"https://api.github.com/users/toadlyBroodle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toadlyBroodle/subscriptions","organizations_url":"https://api.github.com/users/toadlyBroodle/orgs","repos_url":"https://api.github.com/users/toadlyBroodle/repos","events_url":"https://api.github.com/users/toadlyBroodle/events{/privacy}","received_events_url":"https://api.github.com/users/toadlyBroodle/received_events","type":"User","site_admin":false},"body":"...messages, in...","created_at":"2017-12-08T05:15:56Z","updated_at":"2017-12-08T05:19:19Z","html_url":"https://github.com/lightningnetwork/lightning-rfc/pull/311#discussion_r155705166","pull_request_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/311","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/comments/155705166"},"html":{"href":"https://github.com/lightningnetwork/lightning-rfc/pull/311#discussion_r155705166"},"pull_request":{"href":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/311"}}},"pull_request":{"url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/311","id":157135503,"html_url":"https://github.com/lightningnetwork/lightning-rfc/pull/311","diff_url":"https://github.com/lightningnetwork/lightning-rfc/pull/311.diff","patch_url":"https://github.com/lightningnetwork/lightning-rfc/pull/311.patch","issue_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/issues/311","number":311,"state":"open","locked":false,"title":"BOLT-8 Edits","user":{"login":"shannona","id":1110886,"avatar_url":"https://avatars0.githubusercontent.com/u/1110886?v=4","gravatar_id":"","url":"https://api.github.com/users/shannona","html_url":"https://github.com/shannona","followers_url":"https://api.github.com/users/shannona/followers","following_url":"https://api.github.com/users/shannona/following{/other_user}","gists_url":"https://api.github.com/users/shannona/gists{/gist_id}","starred_url":"https://api.github.com/users/shannona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shannona/subscriptions","organizations_url":"https://api.github.com/users/shannona/orgs","repos_url":"https://api.github.com/users/shannona/repos","events_url":"https://api.github.com/users/shannona/events{/privacy}","received_events_url":"https://api.github.com/users/shannona/received_events","type":"User","site_admin":false},"body":"More clarity and copyediting. I also removed quite a few `s that didn't seem to match general usage for \"code\".","created_at":"2017-12-08T00:18:29Z","updated_at":"2017-12-08T05:19:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bfa6d61d76331d431ef262776a08be37af4bd30d","assignee":null,"assignees":[],"requested_reviewers":[{"login":"Roasbeef","id":998190,"avatar_url":"https://avatars3.githubusercontent.com/u/998190?v=4","gravatar_id":"","url":"https://api.github.com/users/Roasbeef","html_url":"https://github.com/Roasbeef","followers_url":"https://api.github.com/users/Roasbeef/followers","following_url":"https://api.github.com/users/Roasbeef/following{/other_user}","gists_url":"https://api.github.com/users/Roasbeef/gists{/gist_id}","starred_url":"https://api.github.com/users/Roasbeef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roasbeef/subscriptions","organizations_url":"https://api.github.com/users/Roasbeef/orgs","repos_url":"https://api.github.com/users/Roasbeef/repos","events_url":"https://api.github.com/users/Roasbeef/events{/privacy}","received_events_url":"https://api.github.com/users/Roasbeef/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/311/commits","review_comments_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/311/comments","review_comment_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/issues/311/comments","statuses_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/statuses/913751ef6ecd242ae3334ff5d442b7f0b7e356e3","head":{"label":"shannona:bolt8-edit","ref":"bolt8-edit","sha":"913751ef6ecd242ae3334ff5d442b7f0b7e356e3","user":{"login":"shannona","id":1110886,"avatar_url":"https://avatars0.githubusercontent.com/u/1110886?v=4","gravatar_id":"","url":"https://api.github.com/users/shannona","html_url":"https://github.com/shannona","followers_url":"https://api.github.com/users/shannona/followers","following_url":"https://api.github.com/users/shannona/following{/other_user}","gists_url":"https://api.github.com/users/shannona/gists{/gist_id}","starred_url":"https://api.github.com/users/shannona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shannona/subscriptions","organizations_url":"https://api.github.com/users/shannona/orgs","repos_url":"https://api.github.com/users/shannona/repos","events_url":"https://api.github.com/users/shannona/events{/privacy}","received_events_url":"https://api.github.com/users/shannona/received_events","type":"User","site_admin":false},"repo":{"id":113379533,"name":"lightning-rfc","full_name":"shannona/lightning-rfc","owner":{"login":"shannona","id":1110886,"avatar_url":"https://avatars0.githubusercontent.com/u/1110886?v=4","gravatar_id":"","url":"https://api.github.com/users/shannona","html_url":"https://github.com/shannona","followers_url":"https://api.github.com/users/shannona/followers","following_url":"https://api.github.com/users/shannona/following{/other_user}","gists_url":"https://api.github.com/users/shannona/gists{/gist_id}","starred_url":"https://api.github.com/users/shannona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shannona/subscriptions","organizations_url":"https://api.github.com/users/shannona/orgs","repos_url":"https://api.github.com/users/shannona/repos","events_url":"https://api.github.com/users/shannona/events{/privacy}","received_events_url":"https://api.github.com/users/shannona/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shannona/lightning-rfc","description":"Lightning Network Specifications","fork":true,"url":"https://api.github.com/repos/shannona/lightning-rfc","forks_url":"https://api.github.com/repos/shannona/lightning-rfc/forks","keys_url":"https://api.github.com/repos/shannona/lightning-rfc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shannona/lightning-rfc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shannona/lightning-rfc/teams","hooks_url":"https://api.github.com/repos/shannona/lightning-rfc/hooks","issue_events_url":"https://api.github.com/repos/shannona/lightning-rfc/issues/events{/number}","events_url":"https://api.github.com/repos/shannona/lightning-rfc/events","assignees_url":"https://api.github.com/repos/shannona/lightning-rfc/assignees{/user}","branches_url":"https://api.github.com/repos/shannona/lightning-rfc/branches{/branch}","tags_url":"https://api.github.com/repos/shannona/lightning-rfc/tags","blobs_url":"https://api.github.com/repos/shannona/lightning-rfc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shannona/lightning-rfc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shannona/lightning-rfc/git/refs{/sha}","trees_url":"https://api.github.com/repos/shannona/lightning-rfc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shannona/lightning-rfc/statuses/{sha}","languages_url":"https://api.github.com/repos/shannona/lightning-rfc/languages","stargazers_url":"https://api.github.com/repos/shannona/lightning-rfc/stargazers","contributors_url":"https://api.github.com/repos/shannona/lightning-rfc/contributors","subscribers_url":"https://api.github.com/repos/shannona/lightning-rfc/subscribers","subscription_url":"https://api.github.com/repos/shannona/lightning-rfc/subscription","commits_url":"https://api.github.com/repos/shannona/lightning-rfc/commits{/sha}","git_commits_url":"https://api.github.com/repos/shannona/lightning-rfc/git/commits{/sha}","comments_url":"https://api.github.com/repos/shannona/lightning-rfc/comments{/number}","issue_comment_url":"https://api.github.com/repos/shannona/lightning-rfc/issues/comments{/number}","contents_url":"https://api.github.com/repos/shannona/lightning-rfc/contents/{+path}","compare_url":"https://api.github.com/repos/shannona/lightning-rfc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shannona/lightning-rfc/merges","archive_url":"https://api.github.com/repos/shannona/lightning-rfc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shannona/lightning-rfc/downloads","issues_url":"https://api.github.com/repos/shannona/lightning-rfc/issues{/number}","pulls_url":"https://api.github.com/repos/shannona/lightning-rfc/pulls{/number}","milestones_url":"https://api.github.com/repos/shannona/lightning-rfc/milestones{/number}","notifications_url":"https://api.github.com/repos/shannona/lightning-rfc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shannona/lightning-rfc/labels{/name}","releases_url":"https://api.github.com/repos/shannona/lightning-rfc/releases{/id}","deployments_url":"https://api.github.com/repos/shannona/lightning-rfc/deployments","created_at":"2017-12-06T23:44:31Z","updated_at":"2017-12-06T23:17:43Z","pushed_at":"2017-12-08T00:17:57Z","git_url":"git://github.com/shannona/lightning-rfc.git","ssh_url":"git@github.com:shannona/lightning-rfc.git","clone_url":"https://github.com/shannona/lightning-rfc.git","svn_url":"https://github.com/shannona/lightning-rfc","homepage":null,"size":831,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"lightningnetwork:master","ref":"master","sha":"e840fdbded4b20e57c11f5ce10bec3e699950a36","user":{"login":"lightningnetwork","id":13424735,"avatar_url":"https://avatars0.githubusercontent.com/u/13424735?v=4","gravatar_id":"","url":"https://api.github.com/users/lightningnetwork","html_url":"https://github.com/lightningnetwork","followers_url":"https://api.github.com/users/lightningnetwork/followers","following_url":"https://api.github.com/users/lightningnetwork/following{/other_user}","gists_url":"https://api.github.com/users/lightningnetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/lightningnetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightningnetwork/subscriptions","organizations_url":"https://api.github.com/users/lightningnetwork/orgs","repos_url":"https://api.github.com/users/lightningnetwork/repos","events_url":"https://api.github.com/users/lightningnetwork/events{/privacy}","received_events_url":"https://api.github.com/users/lightningnetwork/received_events","type":"Organization","site_admin":false},"repo":{"id":73738971,"name":"lightning-rfc","full_name":"lightningnetwork/lightning-rfc","owner":{"login":"lightningnetwork","id":13424735,"avatar_url":"https://avatars0.githubusercontent.com/u/13424735?v=4","gravatar_id":"","url":"https://api.github.com/users/lightningnetwork","html_url":"https://github.com/lightningnetwork","followers_url":"https://api.github.com/users/lightningnetwork/followers","following_url":"https://api.github.com/users/lightningnetwork/following{/other_user}","gists_url":"https://api.github.com/users/lightningnetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/lightningnetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightningnetwork/subscriptions","organizations_url":"https://api.github.com/users/lightningnetwork/orgs","repos_url":"https://api.github.com/users/lightningnetwork/repos","events_url":"https://api.github.com/users/lightningnetwork/events{/privacy}","received_events_url":"https://api.github.com/users/lightningnetwork/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lightningnetwork/lightning-rfc","description":"Lightning Network Specifications","fork":false,"url":"https://api.github.com/repos/lightningnetwork/lightning-rfc","forks_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/forks","keys_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/teams","hooks_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/hooks","issue_events_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/issues/events{/number}","events_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/events","assignees_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/assignees{/user}","branches_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/branches{/branch}","tags_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/tags","blobs_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/git/refs{/sha}","trees_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/statuses/{sha}","languages_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/languages","stargazers_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/stargazers","contributors_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/contributors","subscribers_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/subscribers","subscription_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/subscription","commits_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/commits{/sha}","git_commits_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/git/commits{/sha}","comments_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/comments{/number}","issue_comment_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/issues/comments{/number}","contents_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/contents/{+path}","compare_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/merges","archive_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/downloads","issues_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/issues{/number}","pulls_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls{/number}","milestones_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/milestones{/number}","notifications_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/labels{/name}","releases_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/releases{/id}","deployments_url":"https://api.github.com/repos/lightningnetwork/lightning-rfc/deployments","created_at":"2016-11-14T19:21:45Z","updated_at":"2017-12-08T01:47:33Z","pushed_at":"2017-12-08T03:50:23Z","git_url":"git://github.com/lightningnetwork/lightning-rfc.git","ssh_url":"git@github.com:lightningnetwork/lightning-rfc.git","clone_url":"https://github.com/lightningnetwork/lightning-rfc.git","svn_url":"https://github.com/lightningnetwork/lightning-rfc","homepage":null,"size":856,"stargazers_count":281,"watchers_count":281,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":71,"mirror_url":null,"archived":false,"open_issues_count":32,"license":null,"forks":71,"open_issues":32,"watchers":281,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/311"},"html":{"href":"https://github.com/lightningnetwork/lightning-rfc/pull/311"},"issue":{"href":"https://api.github.com/repos/lightningnetwork/lightning-rfc/issues/311"},"comments":{"href":"https://api.github.com/repos/lightningnetwork/lightning-rfc/issues/311/comments"},"review_comments":{"href":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/311/comments"},"review_comment":{"href":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lightningnetwork/lightning-rfc/pulls/311/commits"},"statuses":{"href":"https://api.github.com/repos/lightningnetwork/lightning-rfc/statuses/913751ef6ecd242ae3334ff5d442b7f0b7e356e3"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"toadlyBroodle"}}