{"action":"created","comment":{"url":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/comments/71997158","id":71997158,"diff_hunk":"@@ -41,29 +45,41 @@ func NewPAD(policies Policies, key crypto.SigningKey, len int64) (*PAD, error) {\n }\n \n // if policies is nil, the previous policies will be used\n-func (pad *PAD) generateNextSTR(policies Policies, m *MerkleTree, epoch uint64) {\n+func (pad *PAD) signTreeRoot(m *MerkleTree, epoch uint64) {\n \tvar prevStrHash []byte\n-\tif pad.currentSTR == nil {\n+\tif pad.latestSTR == nil {\n \t\tprevStrHash = make([]byte, crypto.HashSizeByte)\n \t\tif _, err := rand.Read(prevStrHash); err != nil {\n \t\t\t// panic here since if there is an error, it will break the PAD.\n \t\t\tpanic(err)\n \t\t}\n \t} else {\n-\t\tprevStrHash = crypto.Digest(pad.currentSTR.sig)\n-\t\tif policies == nil {\n-\t\t\tpolicies = pad.currentSTR.policies\n-\t\t}\n+\t\tprevStrHash = crypto.Digest(pad.latestSTR.sig)\n \t}\n-\tpad.currentSTR = NewSTR(pad.key, policies, m, epoch, prevStrHash)\n+\tpad.latestSTR = NewSTR(pad.key, pad.policies, m, epoch, prevStrHash)\n }\n \n func (pad *PAD) updateInternal(policies Policies, epoch uint64) {\n \tpad.tree.recomputeHash()\n \tm := pad.tree.Clone()\n-\tpad.generateNextSTR(policies, m, epoch)\n-\tpad.snapshots[epoch] = pad.currentSTR\n+\t// create STR with the policies that were actually used in the prev.\n+\t// Set() operation\n+\tpad.signTreeRoot(m, epoch)\n+\tpad.snapshots[epoch] = pad.latestSTR\n \tpad.loadedEpochs = append(pad.loadedEpochs, epoch)\n+\n+\tif policies != nil { // update the policies if necessary\n+\t\t// TODO use constant time compare from \"crypto/subtle\" instead (?)\n+\t\tvrfKeyChanged := !bytes.Equal(pad.policies.vrfPrivate()[:],\n+\t\t\tpolicies.vrfPrivate()[:])","path":"merkletree/pad.go","position":71,"original_position":71,"commit_id":"06afc2f61b397dca2c173fd7f1956753d28d5070","original_commit_id":"06afc2f61b397dca2c173fd7f1956753d28d5070","user":{"login":"Liamsi","id":7441766,"avatar_url":"https://avatars.githubusercontent.com/u/7441766?v=3","gravatar_id":"","url":"https://api.github.com/users/Liamsi","html_url":"https://github.com/Liamsi","followers_url":"https://api.github.com/users/Liamsi/followers","following_url":"https://api.github.com/users/Liamsi/following{/other_user}","gists_url":"https://api.github.com/users/Liamsi/gists{/gist_id}","starred_url":"https://api.github.com/users/Liamsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Liamsi/subscriptions","organizations_url":"https://api.github.com/users/Liamsi/orgs","repos_url":"https://api.github.com/users/Liamsi/repos","events_url":"https://api.github.com/users/Liamsi/events{/privacy}","received_events_url":"https://api.github.com/users/Liamsi/received_events","type":"User","site_admin":false},"body":"Any thoughts on this? /cc @c633 @arlolra  @masomel ","created_at":"2016-07-24T22:43:50Z","updated_at":"2016-07-24T22:43:50Z","html_url":"https://github.com/coniks-sys/coniks-go/pull/19#discussion_r71997158","pull_request_url":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/comments/71997158"},"html":{"href":"https://github.com/coniks-sys/coniks-go/pull/19#discussion_r71997158"},"pull_request":{"href":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/19","id":77619896,"html_url":"https://github.com/coniks-sys/coniks-go/pull/19","diff_url":"https://github.com/coniks-sys/coniks-go/pull/19.diff","patch_url":"https://github.com/coniks-sys/coniks-go/pull/19.patch","issue_url":"https://api.github.com/repos/coniks-sys/coniks-go/issues/19","number":19,"state":"open","locked":false,"title":"Vrf integration","user":{"login":"Liamsi","id":7441766,"avatar_url":"https://avatars.githubusercontent.com/u/7441766?v=3","gravatar_id":"","url":"https://api.github.com/users/Liamsi","html_url":"https://github.com/Liamsi","followers_url":"https://api.github.com/users/Liamsi/followers","following_url":"https://api.github.com/users/Liamsi/following{/other_user}","gists_url":"https://api.github.com/users/Liamsi/gists{/gist_id}","starred_url":"https://api.github.com/users/Liamsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Liamsi/subscriptions","organizations_url":"https://api.github.com/users/Liamsi/orgs","repos_url":"https://api.github.com/users/Liamsi/repos","events_url":"https://api.github.com/users/Liamsi/events{/privacy}","received_events_url":"https://api.github.com/users/Liamsi/received_events","type":"User","site_admin":false},"body":"Use coname's vrf implementation to compute the private index\r\n- Should resolve #14 \r\n- commented out parts of a test which is supposed to work with a specific hash (but not with vrf); might be changed with #16 and #18\r\n- replaced `t.Error` in combination with `return` with `t.Fatal`","created_at":"2016-07-15T13:59:34Z","updated_at":"2016-07-24T22:43:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1f55cfecfbdb14339608a3141b8a2ef01647cf6a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/19/commits","review_comments_url":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/19/comments","review_comment_url":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coniks-sys/coniks-go/issues/19/comments","statuses_url":"https://api.github.com/repos/coniks-sys/coniks-go/statuses/06afc2f61b397dca2c173fd7f1956753d28d5070","head":{"label":"coniks-sys:vrf_integration","ref":"vrf_integration","sha":"06afc2f61b397dca2c173fd7f1956753d28d5070","user":{"login":"coniks-sys","id":11236504,"avatar_url":"https://avatars.githubusercontent.com/u/11236504?v=3","gravatar_id":"","url":"https://api.github.com/users/coniks-sys","html_url":"https://github.com/coniks-sys","followers_url":"https://api.github.com/users/coniks-sys/followers","following_url":"https://api.github.com/users/coniks-sys/following{/other_user}","gists_url":"https://api.github.com/users/coniks-sys/gists{/gist_id}","starred_url":"https://api.github.com/users/coniks-sys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coniks-sys/subscriptions","organizations_url":"https://api.github.com/users/coniks-sys/orgs","repos_url":"https://api.github.com/users/coniks-sys/repos","events_url":"https://api.github.com/users/coniks-sys/events{/privacy}","received_events_url":"https://api.github.com/users/coniks-sys/received_events","type":"Organization","site_admin":false},"repo":{"id":60117979,"name":"coniks-go","full_name":"coniks-sys/coniks-go","owner":{"login":"coniks-sys","id":11236504,"avatar_url":"https://avatars.githubusercontent.com/u/11236504?v=3","gravatar_id":"","url":"https://api.github.com/users/coniks-sys","html_url":"https://github.com/coniks-sys","followers_url":"https://api.github.com/users/coniks-sys/followers","following_url":"https://api.github.com/users/coniks-sys/following{/other_user}","gists_url":"https://api.github.com/users/coniks-sys/gists{/gist_id}","starred_url":"https://api.github.com/users/coniks-sys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coniks-sys/subscriptions","organizations_url":"https://api.github.com/users/coniks-sys/orgs","repos_url":"https://api.github.com/users/coniks-sys/repos","events_url":"https://api.github.com/users/coniks-sys/events{/privacy}","received_events_url":"https://api.github.com/users/coniks-sys/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coniks-sys/coniks-go","description":"A CONIKS implementation in Golang","fork":false,"url":"https://api.github.com/repos/coniks-sys/coniks-go","forks_url":"https://api.github.com/repos/coniks-sys/coniks-go/forks","keys_url":"https://api.github.com/repos/coniks-sys/coniks-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coniks-sys/coniks-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coniks-sys/coniks-go/teams","hooks_url":"https://api.github.com/repos/coniks-sys/coniks-go/hooks","issue_events_url":"https://api.github.com/repos/coniks-sys/coniks-go/issues/events{/number}","events_url":"https://api.github.com/repos/coniks-sys/coniks-go/events","assignees_url":"https://api.github.com/repos/coniks-sys/coniks-go/assignees{/user}","branches_url":"https://api.github.com/repos/coniks-sys/coniks-go/branches{/branch}","tags_url":"https://api.github.com/repos/coniks-sys/coniks-go/tags","blobs_url":"https://api.github.com/repos/coniks-sys/coniks-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coniks-sys/coniks-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coniks-sys/coniks-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/coniks-sys/coniks-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coniks-sys/coniks-go/statuses/{sha}","languages_url":"https://api.github.com/repos/coniks-sys/coniks-go/languages","stargazers_url":"https://api.github.com/repos/coniks-sys/coniks-go/stargazers","contributors_url":"https://api.github.com/repos/coniks-sys/coniks-go/contributors","subscribers_url":"https://api.github.com/repos/coniks-sys/coniks-go/subscribers","subscription_url":"https://api.github.com/repos/coniks-sys/coniks-go/subscription","commits_url":"https://api.github.com/repos/coniks-sys/coniks-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/coniks-sys/coniks-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/coniks-sys/coniks-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/coniks-sys/coniks-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/coniks-sys/coniks-go/contents/{+path}","compare_url":"https://api.github.com/repos/coniks-sys/coniks-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coniks-sys/coniks-go/merges","archive_url":"https://api.github.com/repos/coniks-sys/coniks-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coniks-sys/coniks-go/downloads","issues_url":"https://api.github.com/repos/coniks-sys/coniks-go/issues{/number}","pulls_url":"https://api.github.com/repos/coniks-sys/coniks-go/pulls{/number}","milestones_url":"https://api.github.com/repos/coniks-sys/coniks-go/milestones{/number}","notifications_url":"https://api.github.com/repos/coniks-sys/coniks-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coniks-sys/coniks-go/labels{/name}","releases_url":"https://api.github.com/repos/coniks-sys/coniks-go/releases{/id}","deployments_url":"https://api.github.com/repos/coniks-sys/coniks-go/deployments","created_at":"2016-05-31T19:37:35Z","updated_at":"2016-07-22T16:12:10Z","pushed_at":"2016-07-24T22:30:45Z","git_url":"git://github.com/coniks-sys/coniks-go.git","ssh_url":"git@github.com:coniks-sys/coniks-go.git","clone_url":"https://github.com/coniks-sys/coniks-go.git","svn_url":"https://github.com/coniks-sys/coniks-go","homepage":"http://coniks.org/","size":266,"stargazers_count":6,"watchers_count":6,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":17,"forks":0,"open_issues":17,"watchers":6,"default_branch":"master"}},"base":{"label":"coniks-sys:master","ref":"master","sha":"ae15fa391144906fe241c77a88acb49defb3ba57","user":{"login":"coniks-sys","id":11236504,"avatar_url":"https://avatars.githubusercontent.com/u/11236504?v=3","gravatar_id":"","url":"https://api.github.com/users/coniks-sys","html_url":"https://github.com/coniks-sys","followers_url":"https://api.github.com/users/coniks-sys/followers","following_url":"https://api.github.com/users/coniks-sys/following{/other_user}","gists_url":"https://api.github.com/users/coniks-sys/gists{/gist_id}","starred_url":"https://api.github.com/users/coniks-sys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coniks-sys/subscriptions","organizations_url":"https://api.github.com/users/coniks-sys/orgs","repos_url":"https://api.github.com/users/coniks-sys/repos","events_url":"https://api.github.com/users/coniks-sys/events{/privacy}","received_events_url":"https://api.github.com/users/coniks-sys/received_events","type":"Organization","site_admin":false},"repo":{"id":60117979,"name":"coniks-go","full_name":"coniks-sys/coniks-go","owner":{"login":"coniks-sys","id":11236504,"avatar_url":"https://avatars.githubusercontent.com/u/11236504?v=3","gravatar_id":"","url":"https://api.github.com/users/coniks-sys","html_url":"https://github.com/coniks-sys","followers_url":"https://api.github.com/users/coniks-sys/followers","following_url":"https://api.github.com/users/coniks-sys/following{/other_user}","gists_url":"https://api.github.com/users/coniks-sys/gists{/gist_id}","starred_url":"https://api.github.com/users/coniks-sys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coniks-sys/subscriptions","organizations_url":"https://api.github.com/users/coniks-sys/orgs","repos_url":"https://api.github.com/users/coniks-sys/repos","events_url":"https://api.github.com/users/coniks-sys/events{/privacy}","received_events_url":"https://api.github.com/users/coniks-sys/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coniks-sys/coniks-go","description":"A CONIKS implementation in Golang","fork":false,"url":"https://api.github.com/repos/coniks-sys/coniks-go","forks_url":"https://api.github.com/repos/coniks-sys/coniks-go/forks","keys_url":"https://api.github.com/repos/coniks-sys/coniks-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coniks-sys/coniks-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coniks-sys/coniks-go/teams","hooks_url":"https://api.github.com/repos/coniks-sys/coniks-go/hooks","issue_events_url":"https://api.github.com/repos/coniks-sys/coniks-go/issues/events{/number}","events_url":"https://api.github.com/repos/coniks-sys/coniks-go/events","assignees_url":"https://api.github.com/repos/coniks-sys/coniks-go/assignees{/user}","branches_url":"https://api.github.com/repos/coniks-sys/coniks-go/branches{/branch}","tags_url":"https://api.github.com/repos/coniks-sys/coniks-go/tags","blobs_url":"https://api.github.com/repos/coniks-sys/coniks-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coniks-sys/coniks-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coniks-sys/coniks-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/coniks-sys/coniks-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coniks-sys/coniks-go/statuses/{sha}","languages_url":"https://api.github.com/repos/coniks-sys/coniks-go/languages","stargazers_url":"https://api.github.com/repos/coniks-sys/coniks-go/stargazers","contributors_url":"https://api.github.com/repos/coniks-sys/coniks-go/contributors","subscribers_url":"https://api.github.com/repos/coniks-sys/coniks-go/subscribers","subscription_url":"https://api.github.com/repos/coniks-sys/coniks-go/subscription","commits_url":"https://api.github.com/repos/coniks-sys/coniks-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/coniks-sys/coniks-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/coniks-sys/coniks-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/coniks-sys/coniks-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/coniks-sys/coniks-go/contents/{+path}","compare_url":"https://api.github.com/repos/coniks-sys/coniks-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coniks-sys/coniks-go/merges","archive_url":"https://api.github.com/repos/coniks-sys/coniks-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coniks-sys/coniks-go/downloads","issues_url":"https://api.github.com/repos/coniks-sys/coniks-go/issues{/number}","pulls_url":"https://api.github.com/repos/coniks-sys/coniks-go/pulls{/number}","milestones_url":"https://api.github.com/repos/coniks-sys/coniks-go/milestones{/number}","notifications_url":"https://api.github.com/repos/coniks-sys/coniks-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coniks-sys/coniks-go/labels{/name}","releases_url":"https://api.github.com/repos/coniks-sys/coniks-go/releases{/id}","deployments_url":"https://api.github.com/repos/coniks-sys/coniks-go/deployments","created_at":"2016-05-31T19:37:35Z","updated_at":"2016-07-22T16:12:10Z","pushed_at":"2016-07-24T22:30:45Z","git_url":"git://github.com/coniks-sys/coniks-go.git","ssh_url":"git@github.com:coniks-sys/coniks-go.git","clone_url":"https://github.com/coniks-sys/coniks-go.git","svn_url":"https://github.com/coniks-sys/coniks-go","homepage":"http://coniks.org/","size":266,"stargazers_count":6,"watchers_count":6,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":17,"forks":0,"open_issues":17,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/19"},"html":{"href":"https://github.com/coniks-sys/coniks-go/pull/19"},"issue":{"href":"https://api.github.com/repos/coniks-sys/coniks-go/issues/19"},"comments":{"href":"https://api.github.com/repos/coniks-sys/coniks-go/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coniks-sys/coniks-go/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/coniks-sys/coniks-go/statuses/06afc2f61b397dca2c173fd7f1956753d28d5070"}}}}
{"actor":{"display_login":"Liamsi"}}