{"action":"created","comment":{"url":"https://api.github.com/repos/docker/swarmkit/pulls/comments/85453043","pull_request_review_id":6169642,"id":85453043,"diff_hunk":"@@ -0,0 +1,67 @@\n+package encryption\n+\n+import (\n+\t\"crypto/rand\"\n+\t\"fmt\"\n+\t\"io\"\n+\n+\t\"github.com/docker/swarmkit/api\"\n+\n+\t\"golang.org/x/crypto/nacl/secretbox\"\n+)\n+\n+const naclSecretboxKeySize = 32\n+\n+// This provides the default implementation of an encoder and decoder, as well\n+// as the default KDF function.\n+\n+// NACLSecretbox is an implementation of an encoder/decoder.  Encoding\n+// generates random Nonces.\n+type NACLSecretbox struct {\n+\tkey [naclSecretboxKeySize]byte\n+}\n+\n+// NewNACLSecretbox returns a new NACL secretbox encoder/decoder with the given key\n+func NewNACLSecretbox(key []byte) NACLSecretbox {\n+\tsecretbox := NACLSecretbox{}\n+\tcopy(secretbox.key[:], key)\n+\treturn secretbox\n+}\n+\n+// Algorithm returns the type of algorhtm this is (NACL Secretbox using XSalsa20 and Poly1305)\n+func (n NACLSecretbox) Algorithm() api.MaybeEncryptedRecord_Algorithm {\n+\treturn api.MaybeEncryptedRecord_NACLSecretboxSalsa20Poly1305\n+}\n+\n+// Encode encrypts some bytes and returns an encrypted record\n+func (n NACLSecretbox) Encode(data []byte) (*api.MaybeEncryptedRecord, error) {\n+\tvar nonce [24]byte\n+\tif _, err := io.ReadFull(rand.Reader, nonce[:]); err != nil {","path":"manager/encryption/nacl.go","position":39,"original_position":39,"commit_id":"acf8cbe96aa876f4021bc92d43545a25da4c9dca","original_commit_id":"acf8cbe96aa876f4021bc92d43545a25da4c9dca","user":{"login":"cyli","id":223200,"avatar_url":"https://avatars.githubusercontent.com/u/223200?v=3","gravatar_id":"","url":"https://api.github.com/users/cyli","html_url":"https://github.com/cyli","followers_url":"https://api.github.com/users/cyli/followers","following_url":"https://api.github.com/users/cyli/following{/other_user}","gists_url":"https://api.github.com/users/cyli/gists{/gist_id}","starred_url":"https://api.github.com/users/cyli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyli/subscriptions","organizations_url":"https://api.github.com/users/cyli/orgs","repos_url":"https://api.github.com/users/cyli/repos","events_url":"https://api.github.com/users/cyli/events{/privacy}","received_events_url":"https://api.github.com/users/cyli/received_events","type":"User","site_admin":false},"body":"Tab complete.  :D  Will fix.","created_at":"2016-10-28T00:10:33Z","updated_at":"2016-10-28T00:10:33Z","html_url":"https://github.com/docker/swarmkit/pull/1701#discussion_r85453043","pull_request_url":"https://api.github.com/repos/docker/swarmkit/pulls/1701","_links":{"self":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/comments/85453043"},"html":{"href":"https://github.com/docker/swarmkit/pull/1701#discussion_r85453043"},"pull_request":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/1701"}}},"pull_request":{"url":"https://api.github.com/repos/docker/swarmkit/pulls/1701","id":91114668,"html_url":"https://github.com/docker/swarmkit/pull/1701","diff_url":"https://github.com/docker/swarmkit/pull/1701.diff","patch_url":"https://github.com/docker/swarmkit/pull/1701.patch","issue_url":"https://api.github.com/repos/docker/swarmkit/issues/1701","number":1701,"state":"open","locked":false,"title":"[encryption] NaCL/secretbox + wrapper around etcd wal + snapshot","user":{"login":"cyli","id":223200,"avatar_url":"https://avatars.githubusercontent.com/u/223200?v=3","gravatar_id":"","url":"https://api.github.com/users/cyli","html_url":"https://github.com/cyli","followers_url":"https://api.github.com/users/cyli/followers","following_url":"https://api.github.com/users/cyli/following{/other_user}","gists_url":"https://api.github.com/users/cyli/gists{/gist_id}","starred_url":"https://api.github.com/users/cyli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyli/subscriptions","organizations_url":"https://api.github.com/users/cyli/orgs","repos_url":"https://api.github.com/users/cyli/repos","events_url":"https://api.github.com/users/cyli/events{/privacy}","received_events_url":"https://api.github.com/users/cyli/received_events","type":"User","site_admin":false},"body":"This is some cherry-picked code from https://github.com/docker/swarmkit/pull/1598.\r\n\r\nThis vendors the nacl/secretbox package, and also adds a wrapper around the etcd wal and snapshot packages that can make use of the encrypted records and encoder/decoder.\r\n\r\ncc @aaronlehmann @aluzzardi @stevvooe @lvh","created_at":"2016-10-27T00:37:56Z","updated_at":"2016-10-28T00:10:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b88ea4f0d669b3fe7fa8f37c9727b97c15753af2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/docker/swarmkit/pulls/1701/commits","review_comments_url":"https://api.github.com/repos/docker/swarmkit/pulls/1701/comments","review_comment_url":"https://api.github.com/repos/docker/swarmkit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/swarmkit/issues/1701/comments","statuses_url":"https://api.github.com/repos/docker/swarmkit/statuses/acf8cbe96aa876f4021bc92d43545a25da4c9dca","head":{"label":"cyli:manager-encryption-package","ref":"manager-encryption-package","sha":"acf8cbe96aa876f4021bc92d43545a25da4c9dca","user":{"login":"cyli","id":223200,"avatar_url":"https://avatars.githubusercontent.com/u/223200?v=3","gravatar_id":"","url":"https://api.github.com/users/cyli","html_url":"https://github.com/cyli","followers_url":"https://api.github.com/users/cyli/followers","following_url":"https://api.github.com/users/cyli/following{/other_user}","gists_url":"https://api.github.com/users/cyli/gists{/gist_id}","starred_url":"https://api.github.com/users/cyli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyli/subscriptions","organizations_url":"https://api.github.com/users/cyli/orgs","repos_url":"https://api.github.com/users/cyli/repos","events_url":"https://api.github.com/users/cyli/events{/privacy}","received_events_url":"https://api.github.com/users/cyli/received_events","type":"User","site_admin":false},"repo":{"id":66887622,"name":"swarmkit","full_name":"cyli/swarmkit","owner":{"login":"cyli","id":223200,"avatar_url":"https://avatars.githubusercontent.com/u/223200?v=3","gravatar_id":"","url":"https://api.github.com/users/cyli","html_url":"https://github.com/cyli","followers_url":"https://api.github.com/users/cyli/followers","following_url":"https://api.github.com/users/cyli/following{/other_user}","gists_url":"https://api.github.com/users/cyli/gists{/gist_id}","starred_url":"https://api.github.com/users/cyli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyli/subscriptions","organizations_url":"https://api.github.com/users/cyli/orgs","repos_url":"https://api.github.com/users/cyli/repos","events_url":"https://api.github.com/users/cyli/events{/privacy}","received_events_url":"https://api.github.com/users/cyli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cyli/swarmkit","description":"A toolkit for orchestrating distributed systems at any scale. It includes primitives for node discovery, raft-based consensus, task scheduling and more.","fork":true,"url":"https://api.github.com/repos/cyli/swarmkit","forks_url":"https://api.github.com/repos/cyli/swarmkit/forks","keys_url":"https://api.github.com/repos/cyli/swarmkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cyli/swarmkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cyli/swarmkit/teams","hooks_url":"https://api.github.com/repos/cyli/swarmkit/hooks","issue_events_url":"https://api.github.com/repos/cyli/swarmkit/issues/events{/number}","events_url":"https://api.github.com/repos/cyli/swarmkit/events","assignees_url":"https://api.github.com/repos/cyli/swarmkit/assignees{/user}","branches_url":"https://api.github.com/repos/cyli/swarmkit/branches{/branch}","tags_url":"https://api.github.com/repos/cyli/swarmkit/tags","blobs_url":"https://api.github.com/repos/cyli/swarmkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cyli/swarmkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cyli/swarmkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/cyli/swarmkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cyli/swarmkit/statuses/{sha}","languages_url":"https://api.github.com/repos/cyli/swarmkit/languages","stargazers_url":"https://api.github.com/repos/cyli/swarmkit/stargazers","contributors_url":"https://api.github.com/repos/cyli/swarmkit/contributors","subscribers_url":"https://api.github.com/repos/cyli/swarmkit/subscribers","subscription_url":"https://api.github.com/repos/cyli/swarmkit/subscription","commits_url":"https://api.github.com/repos/cyli/swarmkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/cyli/swarmkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/cyli/swarmkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/cyli/swarmkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/cyli/swarmkit/contents/{+path}","compare_url":"https://api.github.com/repos/cyli/swarmkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cyli/swarmkit/merges","archive_url":"https://api.github.com/repos/cyli/swarmkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cyli/swarmkit/downloads","issues_url":"https://api.github.com/repos/cyli/swarmkit/issues{/number}","pulls_url":"https://api.github.com/repos/cyli/swarmkit/pulls{/number}","milestones_url":"https://api.github.com/repos/cyli/swarmkit/milestones{/number}","notifications_url":"https://api.github.com/repos/cyli/swarmkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cyli/swarmkit/labels{/name}","releases_url":"https://api.github.com/repos/cyli/swarmkit/releases{/id}","deployments_url":"https://api.github.com/repos/cyli/swarmkit/deployments","created_at":"2016-08-29T23:13:03Z","updated_at":"2016-08-29T23:13:05Z","pushed_at":"2016-10-28T00:06:13Z","git_url":"git://github.com/cyli/swarmkit.git","ssh_url":"git@github.com:cyli/swarmkit.git","clone_url":"https://github.com/cyli/swarmkit.git","svn_url":"https://github.com/cyli/swarmkit","homepage":"","size":44589,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"8148920cdfdd43e6426ae5bb9a4e8bd51a7eb522","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":51556828,"name":"swarmkit","full_name":"docker/swarmkit","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/swarmkit","description":"A toolkit for orchestrating distributed systems at any scale. It includes primitives for node discovery, raft-based consensus, task scheduling and more.","fork":false,"url":"https://api.github.com/repos/docker/swarmkit","forks_url":"https://api.github.com/repos/docker/swarmkit/forks","keys_url":"https://api.github.com/repos/docker/swarmkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/swarmkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/swarmkit/teams","hooks_url":"https://api.github.com/repos/docker/swarmkit/hooks","issue_events_url":"https://api.github.com/repos/docker/swarmkit/issues/events{/number}","events_url":"https://api.github.com/repos/docker/swarmkit/events","assignees_url":"https://api.github.com/repos/docker/swarmkit/assignees{/user}","branches_url":"https://api.github.com/repos/docker/swarmkit/branches{/branch}","tags_url":"https://api.github.com/repos/docker/swarmkit/tags","blobs_url":"https://api.github.com/repos/docker/swarmkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/swarmkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/swarmkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/swarmkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/swarmkit/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/swarmkit/languages","stargazers_url":"https://api.github.com/repos/docker/swarmkit/stargazers","contributors_url":"https://api.github.com/repos/docker/swarmkit/contributors","subscribers_url":"https://api.github.com/repos/docker/swarmkit/subscribers","subscription_url":"https://api.github.com/repos/docker/swarmkit/subscription","commits_url":"https://api.github.com/repos/docker/swarmkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/swarmkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/swarmkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/swarmkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/swarmkit/contents/{+path}","compare_url":"https://api.github.com/repos/docker/swarmkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/swarmkit/merges","archive_url":"https://api.github.com/repos/docker/swarmkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/swarmkit/downloads","issues_url":"https://api.github.com/repos/docker/swarmkit/issues{/number}","pulls_url":"https://api.github.com/repos/docker/swarmkit/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/swarmkit/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/swarmkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/swarmkit/labels{/name}","releases_url":"https://api.github.com/repos/docker/swarmkit/releases{/id}","deployments_url":"https://api.github.com/repos/docker/swarmkit/deployments","created_at":"2016-02-12T00:02:15Z","updated_at":"2016-10-27T14:40:52Z","pushed_at":"2016-10-28T00:06:13Z","git_url":"git://github.com/docker/swarmkit.git","ssh_url":"git@github.com:docker/swarmkit.git","clone_url":"https://github.com/docker/swarmkit.git","svn_url":"https://github.com/docker/swarmkit","homepage":"","size":22535,"stargazers_count":1008,"watchers_count":1008,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":199,"mirror_url":null,"open_issues_count":178,"forks":199,"open_issues":178,"watchers":1008,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/1701"},"html":{"href":"https://github.com/docker/swarmkit/pull/1701"},"issue":{"href":"https://api.github.com/repos/docker/swarmkit/issues/1701"},"comments":{"href":"https://api.github.com/repos/docker/swarmkit/issues/1701/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/1701/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/1701/commits"},"statuses":{"href":"https://api.github.com/repos/docker/swarmkit/statuses/acf8cbe96aa876f4021bc92d43545a25da4c9dca"}}}}
{"actor":{"display_login":"cyli"}}