{"action":"created","comment":{"url":"https://api.github.com/repos/DeDiS/prifi/pulls/comments/25025004","id":25025004,"diff_hunk":"@@ -0,0 +1,254 @@\n+package insure\n+\n+import (\n+\t\"math\"\n+\t\"math/big\"\n+\t\"bytes\"\n+\n+\t\"github.com/dedis/crypto/abstract\"\n+\t\"github.com/dedis/crypto/anon\"\n+\t\"github.com/dedis/crypto/config\"\n+\t\"github.com/dedis/crypto/nist\"\n+\t\"github.com/dedis/crypto/poly\"\n+\t\"github.com/dedis/crypto/random\"\n+\t\n+\t\"github.com/dedis/protobuf\"\n+)\n+\n+/* Modelled off coco/signingMessage.go, this file is responsible for encoding/\n+ * decoding messages sent as a part of the insurance policy protocol.\n+ */\n+\n+type MessageType int\n+\n+const (\n+\tError MessageType = iota\n+\tRequestInsurance\n+\tPolicyApproved\n+)\n+\n+type PolicyMessage struct {\n+\tType MessageType\n+\trim  *RequestInsuranceMessage\n+\tpam  *PolicyApprovedMessage\n+}\n+\n+/* Creates a new PolicyMessage\n+ *\n+ * Arguments:\n+ *\tm = A RequestInsuranceMessage for sending over the network\n+ *\n+ * Returns:\n+ *\tA new PolicyMessage responsible for sending an RequestInsuranceMessage\n+ */\n+func (pm *PolicyMessage) createRIMessage(m *RequestInsuranceMessage) *PolicyMessage {\n+\tpm.Type = RequestInsurance\n+\tpm.rim  = m\n+\treturn pm\n+}\n+\n+/* Creates a new PolicyMessage\n+ *\n+ * Arguments:\n+ *\tm = A PolicyApprovedMessage for sending over the network\n+ *\n+ * Returns:\n+ *\tA new PolicyMessage responsible for sending an PolicyApprovedMessage\n+ */\n+func (pm *PolicyMessage) createPAMessage(m *PolicyApprovedMessage) *PolicyMessage {\n+\tpm.Type = PolicyApproved\n+\tpm.pam  = m\n+\treturn pm\n+}\n+\n+// Returns the RequestInsuranceMessage of this PolicyMessage\n+func (pm *PolicyMessage) getRIM() *RequestInsuranceMessage {\n+\treturn pm.rim\n+}\n+\n+// Returns the PolicyApprovedMessage of this PolicyMessage\n+func (pm *PolicyMessage) getPAM() *PolicyApprovedMessage {\n+\treturn pm.pam\n+}\n+\n+// This code is responsible for mashalling the message for sending off.\n+func (pm *PolicyMessage) MarshalBinary() ([]byte, error) {\n+\tvar b bytes.Buffer\n+\tvar sub []byte\n+\tvar err error\n+\tb.WriteByte(byte(pm.Type))\n+\t// marshal sub message based on its Type\n+\tswitch pm.Type {\n+\tcase RequestInsurance:\n+\t\tsub, err = pm.rim.MarshalBinary()\n+\tcase PolicyApproved:\n+\t\tsub, err = pm.pam.MarshalBinary()\n+\t}\n+\tif err == nil {\n+\t\tb.Write(sub)\n+\t}\n+\treturn b.Bytes(), err\n+}\n+\n+// This function is responsible for unmarshalling the data. It keeps track\n+// of which type the message is and decodes it properly.\n+func (pm *PolicyMessage) UnmarshalBinary(data []byte) error {\n+\tpm.Type = MessageType(data[0])\n+\tmsgBytes := data[1:]\n+\tvar err error\n+\tswitch pm.Type {\n+\tcase RequestInsurance:\n+\t\tpm.rim, err = new(RequestInsuranceMessage).UnmarshalBinary(msgBytes)\n+\tcase PolicyApproved:\n+\t\tpm.pam, err = new(PolicyApprovedMessage).UnmarshalBinary(msgBytes)\n+\t}\n+\treturn err\n+}\n+\n+\n+// These messages are used to send insurance requests. A node looking for an\n+// insurance policy will send these to other nodes to ask them to become\n+// insurers.\n+type RequestInsuranceMessage struct {\n+\t// The public key of the insured.\n+\tPubKey abstract.Point\n+\t\n+\t// The number of the share being sent.\n+\tShareNumber *nist.Int","path":"coco/insure/policyMessage.go","position":117,"original_position":117,"commit_id":"6b10c53ba049e72d39073d8d3f04f21444322ec2","original_commit_id":"6b10c53ba049e72d39073d8d3f04f21444322ec2","user":{"login":"bford","id":1106207,"avatar_url":"https://avatars.githubusercontent.com/u/1106207?v=3","gravatar_id":"","url":"https://api.github.com/users/bford","html_url":"https://github.com/bford","followers_url":"https://api.github.com/users/bford/followers","following_url":"https://api.github.com/users/bford/following{/other_user}","gists_url":"https://api.github.com/users/bford/gists{/gist_id}","starred_url":"https://api.github.com/users/bford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bford/subscriptions","organizations_url":"https://api.github.com/users/bford/orgs","repos_url":"https://api.github.com/users/bford/repos","events_url":"https://api.github.com/users/bford/events{/privacy}","received_events_url":"https://api.github.com/users/bford/received_events","type":"User","site_admin":false},"body":"Why nist.Int here?  I think any conceivably sane number of shares should fit into a normal 'int' or 'int32' for example.","created_at":"2015-02-19T21:00:59Z","updated_at":"2015-02-19T21:00:59Z","html_url":"https://github.com/DeDiS/prifi/pull/5#discussion_r25025004","pull_request_url":"https://api.github.com/repos/DeDiS/prifi/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/DeDiS/prifi/pulls/comments/25025004"},"html":{"href":"https://github.com/DeDiS/prifi/pull/5#discussion_r25025004"},"pull_request":{"href":"https://api.github.com/repos/DeDiS/prifi/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/DeDiS/prifi/pulls/5","id":28370070,"html_url":"https://github.com/DeDiS/prifi/pull/5","diff_url":"https://github.com/DeDiS/prifi/pull/5.diff","patch_url":"https://github.com/DeDiS/prifi/pull/5.patch","issue_url":"https://api.github.com/repos/DeDiS/prifi/issues/5","number":5,"state":"open","locked":false,"title":"Coco: Life Insurance Policy","user":{"login":"WEB3-GForce","id":9469966,"avatar_url":"https://avatars.githubusercontent.com/u/9469966?v=3","gravatar_id":"","url":"https://api.github.com/users/WEB3-GForce","html_url":"https://github.com/WEB3-GForce","followers_url":"https://api.github.com/users/WEB3-GForce/followers","following_url":"https://api.github.com/users/WEB3-GForce/following{/other_user}","gists_url":"https://api.github.com/users/WEB3-GForce/gists{/gist_id}","starred_url":"https://api.github.com/users/WEB3-GForce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WEB3-GForce/subscriptions","organizations_url":"https://api.github.com/users/WEB3-GForce/orgs","repos_url":"https://api.github.com/users/WEB3-GForce/repos","events_url":"https://api.github.com/users/WEB3-GForce/events{/privacy}","received_events_url":"https://api.github.com/users/WEB3-GForce/received_events","type":"User","site_admin":false},"body":"@davidiw \r\n@bford \r\n@dyv \r\n@iuliatamas \r\n\r\nThis will be the first iteration of the life insurance policy. I'm opening this pull request primarily to serve as a forum of discussion on technical aspects of the code. Please feel free to comment as I add code.","created_at":"2015-01-30T15:44:00Z","updated_at":"2015-02-19T21:00:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed861fda9e298564bfbb8a26e82e2c3be5295916","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DeDiS/prifi/pulls/5/commits","review_comments_url":"https://api.github.com/repos/DeDiS/prifi/pulls/5/comments","review_comment_url":"https://api.github.com/repos/DeDiS/prifi/pulls/comments/{number}","comments_url":"https://api.github.com/repos/DeDiS/prifi/issues/5/comments","statuses_url":"https://api.github.com/repos/DeDiS/prifi/statuses/6b10c53ba049e72d39073d8d3f04f21444322ec2","head":{"label":"WEB3-GForce:life_insurance","ref":"life_insurance","sha":"6b10c53ba049e72d39073d8d3f04f21444322ec2","user":{"login":"WEB3-GForce","id":9469966,"avatar_url":"https://avatars.githubusercontent.com/u/9469966?v=3","gravatar_id":"","url":"https://api.github.com/users/WEB3-GForce","html_url":"https://github.com/WEB3-GForce","followers_url":"https://api.github.com/users/WEB3-GForce/followers","following_url":"https://api.github.com/users/WEB3-GForce/following{/other_user}","gists_url":"https://api.github.com/users/WEB3-GForce/gists{/gist_id}","starred_url":"https://api.github.com/users/WEB3-GForce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WEB3-GForce/subscriptions","organizations_url":"https://api.github.com/users/WEB3-GForce/orgs","repos_url":"https://api.github.com/users/WEB3-GForce/repos","events_url":"https://api.github.com/users/WEB3-GForce/events{/privacy}","received_events_url":"https://api.github.com/users/WEB3-GForce/received_events","type":"User","site_admin":false},"repo":{"id":30077765,"name":"prifi","full_name":"WEB3-GForce/prifi","owner":{"login":"WEB3-GForce","id":9469966,"avatar_url":"https://avatars.githubusercontent.com/u/9469966?v=3","gravatar_id":"","url":"https://api.github.com/users/WEB3-GForce","html_url":"https://github.com/WEB3-GForce","followers_url":"https://api.github.com/users/WEB3-GForce/followers","following_url":"https://api.github.com/users/WEB3-GForce/following{/other_user}","gists_url":"https://api.github.com/users/WEB3-GForce/gists{/gist_id}","starred_url":"https://api.github.com/users/WEB3-GForce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WEB3-GForce/subscriptions","organizations_url":"https://api.github.com/users/WEB3-GForce/orgs","repos_url":"https://api.github.com/users/WEB3-GForce/repos","events_url":"https://api.github.com/users/WEB3-GForce/events{/privacy}","received_events_url":"https://api.github.com/users/WEB3-GForce/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/WEB3-GForce/prifi","description":"Work-in-progress Dissent port/rewrite for low-latency anonymous communication","fork":true,"url":"https://api.github.com/repos/WEB3-GForce/prifi","forks_url":"https://api.github.com/repos/WEB3-GForce/prifi/forks","keys_url":"https://api.github.com/repos/WEB3-GForce/prifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WEB3-GForce/prifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WEB3-GForce/prifi/teams","hooks_url":"https://api.github.com/repos/WEB3-GForce/prifi/hooks","issue_events_url":"https://api.github.com/repos/WEB3-GForce/prifi/issues/events{/number}","events_url":"https://api.github.com/repos/WEB3-GForce/prifi/events","assignees_url":"https://api.github.com/repos/WEB3-GForce/prifi/assignees{/user}","branches_url":"https://api.github.com/repos/WEB3-GForce/prifi/branches{/branch}","tags_url":"https://api.github.com/repos/WEB3-GForce/prifi/tags","blobs_url":"https://api.github.com/repos/WEB3-GForce/prifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WEB3-GForce/prifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WEB3-GForce/prifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/WEB3-GForce/prifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WEB3-GForce/prifi/statuses/{sha}","languages_url":"https://api.github.com/repos/WEB3-GForce/prifi/languages","stargazers_url":"https://api.github.com/repos/WEB3-GForce/prifi/stargazers","contributors_url":"https://api.github.com/repos/WEB3-GForce/prifi/contributors","subscribers_url":"https://api.github.com/repos/WEB3-GForce/prifi/subscribers","subscription_url":"https://api.github.com/repos/WEB3-GForce/prifi/subscription","commits_url":"https://api.github.com/repos/WEB3-GForce/prifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/WEB3-GForce/prifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/WEB3-GForce/prifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/WEB3-GForce/prifi/issues/comments/{number}","contents_url":"https://api.github.com/repos/WEB3-GForce/prifi/contents/{+path}","compare_url":"https://api.github.com/repos/WEB3-GForce/prifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WEB3-GForce/prifi/merges","archive_url":"https://api.github.com/repos/WEB3-GForce/prifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WEB3-GForce/prifi/downloads","issues_url":"https://api.github.com/repos/WEB3-GForce/prifi/issues{/number}","pulls_url":"https://api.github.com/repos/WEB3-GForce/prifi/pulls{/number}","milestones_url":"https://api.github.com/repos/WEB3-GForce/prifi/milestones{/number}","notifications_url":"https://api.github.com/repos/WEB3-GForce/prifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WEB3-GForce/prifi/labels{/name}","releases_url":"https://api.github.com/repos/WEB3-GForce/prifi/releases{/id}","created_at":"2015-01-30T15:27:03Z","updated_at":"2015-01-30T15:27:03Z","pushed_at":"2015-02-19T00:24:05Z","git_url":"git://github.com/WEB3-GForce/prifi.git","ssh_url":"git@github.com:WEB3-GForce/prifi.git","clone_url":"https://github.com/WEB3-GForce/prifi.git","svn_url":"https://github.com/WEB3-GForce/prifi","homepage":"http://dedis.cs.yale.edu/dissent/","size":4123,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"DeDiS:master","ref":"master","sha":"b0e95688f949c05ce83d1ef365b39646e635fea2","user":{"login":"DeDiS","id":3638331,"avatar_url":"https://avatars.githubusercontent.com/u/3638331?v=3","gravatar_id":"","url":"https://api.github.com/users/DeDiS","html_url":"https://github.com/DeDiS","followers_url":"https://api.github.com/users/DeDiS/followers","following_url":"https://api.github.com/users/DeDiS/following{/other_user}","gists_url":"https://api.github.com/users/DeDiS/gists{/gist_id}","starred_url":"https://api.github.com/users/DeDiS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeDiS/subscriptions","organizations_url":"https://api.github.com/users/DeDiS/orgs","repos_url":"https://api.github.com/users/DeDiS/repos","events_url":"https://api.github.com/users/DeDiS/events{/privacy}","received_events_url":"https://api.github.com/users/DeDiS/received_events","type":"Organization","site_admin":false},"repo":{"id":28921102,"name":"prifi","full_name":"DeDiS/prifi","owner":{"login":"DeDiS","id":3638331,"avatar_url":"https://avatars.githubusercontent.com/u/3638331?v=3","gravatar_id":"","url":"https://api.github.com/users/DeDiS","html_url":"https://github.com/DeDiS","followers_url":"https://api.github.com/users/DeDiS/followers","following_url":"https://api.github.com/users/DeDiS/following{/other_user}","gists_url":"https://api.github.com/users/DeDiS/gists{/gist_id}","starred_url":"https://api.github.com/users/DeDiS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeDiS/subscriptions","organizations_url":"https://api.github.com/users/DeDiS/orgs","repos_url":"https://api.github.com/users/DeDiS/repos","events_url":"https://api.github.com/users/DeDiS/events{/privacy}","received_events_url":"https://api.github.com/users/DeDiS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DeDiS/prifi","description":"Work-in-progress Dissent port/rewrite for low-latency anonymous communication","fork":false,"url":"https://api.github.com/repos/DeDiS/prifi","forks_url":"https://api.github.com/repos/DeDiS/prifi/forks","keys_url":"https://api.github.com/repos/DeDiS/prifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DeDiS/prifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DeDiS/prifi/teams","hooks_url":"https://api.github.com/repos/DeDiS/prifi/hooks","issue_events_url":"https://api.github.com/repos/DeDiS/prifi/issues/events{/number}","events_url":"https://api.github.com/repos/DeDiS/prifi/events","assignees_url":"https://api.github.com/repos/DeDiS/prifi/assignees{/user}","branches_url":"https://api.github.com/repos/DeDiS/prifi/branches{/branch}","tags_url":"https://api.github.com/repos/DeDiS/prifi/tags","blobs_url":"https://api.github.com/repos/DeDiS/prifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DeDiS/prifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DeDiS/prifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/DeDiS/prifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DeDiS/prifi/statuses/{sha}","languages_url":"https://api.github.com/repos/DeDiS/prifi/languages","stargazers_url":"https://api.github.com/repos/DeDiS/prifi/stargazers","contributors_url":"https://api.github.com/repos/DeDiS/prifi/contributors","subscribers_url":"https://api.github.com/repos/DeDiS/prifi/subscribers","subscription_url":"https://api.github.com/repos/DeDiS/prifi/subscription","commits_url":"https://api.github.com/repos/DeDiS/prifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/DeDiS/prifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/DeDiS/prifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/DeDiS/prifi/issues/comments/{number}","contents_url":"https://api.github.com/repos/DeDiS/prifi/contents/{+path}","compare_url":"https://api.github.com/repos/DeDiS/prifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DeDiS/prifi/merges","archive_url":"https://api.github.com/repos/DeDiS/prifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DeDiS/prifi/downloads","issues_url":"https://api.github.com/repos/DeDiS/prifi/issues{/number}","pulls_url":"https://api.github.com/repos/DeDiS/prifi/pulls{/number}","milestones_url":"https://api.github.com/repos/DeDiS/prifi/milestones{/number}","notifications_url":"https://api.github.com/repos/DeDiS/prifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DeDiS/prifi/labels{/name}","releases_url":"https://api.github.com/repos/DeDiS/prifi/releases{/id}","created_at":"2015-01-07T15:47:28Z","updated_at":"2015-02-19T20:46:33Z","pushed_at":"2015-02-19T20:46:37Z","git_url":"git://github.com/DeDiS/prifi.git","ssh_url":"git@github.com:DeDiS/prifi.git","clone_url":"https://github.com/DeDiS/prifi.git","svn_url":"https://github.com/DeDiS/prifi","homepage":"http://dedis.cs.yale.edu/dissent/","size":4852,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":1,"forks":5,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DeDiS/prifi/pulls/5"},"html":{"href":"https://github.com/DeDiS/prifi/pull/5"},"issue":{"href":"https://api.github.com/repos/DeDiS/prifi/issues/5"},"comments":{"href":"https://api.github.com/repos/DeDiS/prifi/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/DeDiS/prifi/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/DeDiS/prifi/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/DeDiS/prifi/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/DeDiS/prifi/statuses/6b10c53ba049e72d39073d8d3f04f21444322ec2"}}}}