{"action":"created","comment":{"url":"https://api.github.com/repos/google/trillian/pulls/comments/72243411","id":72243411,"diff_hunk":"@@ -60,21 +60,60 @@ func signSCT(km crypto.KeyManager, t time.Time, sctData []byte) (ct.SignedCertif\n \t\tSignature:  digitallySigned}, nil\n }\n \n-// CreateV1SCTForCertificate builds and signs a V1 CT SCT for a certificate using the key held\n-// by a key manager.\n-func SignV1SCTForCertificate(km crypto.KeyManager, cert *x509.Certificate, t time.Time) (ct.SignedCertificateTimestamp, error) {\n-\treturn signSCT(km, t, cert.Raw)\n+// CreateV1SCTForCertificate creates a MerkleTreeLeaf and builds and signs a V1 CT SCT for a certificate\n+// using the key held by a key manager.\n+func SignV1SCTForCertificate(km crypto.KeyManager, cert *x509.Certificate, t time.Time) (ct.MerkleTreeLeaf, ct.SignedCertificateTimestamp, error) {\n+\t// Temp SCT for input to the serializer\n+\tsctInput := ct.SignedCertificateTimestamp{\n+\t\tSCTVersion: ct.V1,\n+\t\tTimestamp:  uint64(t.UnixNano() / millisPerNano), // spec uses millisecond timestamps\n+\t\tExtensions: ct.CTExtensions{}}\n+\n+\t// Build up a MerkleTreeLeaf for the cert\n+\ttimestampedEntry := ct.TimestampedEntry{Timestamp:sctInput.Timestamp, EntryType:ct.X509LogEntryType, X509Entry:cert.Raw}\n+\tleaf := ct.MerkleTreeLeaf{Version: ct.V1, LeafType:ct.TimestampedEntryLeafType, TimestampedEntry:timestampedEntry}\n+\n+\t// Serialize SCT signature input to get the bytes that need to be signed\n+\tres, err := ct.SerializeSCTSignatureInput(sctInput, ct.LogEntry{Leaf:leaf})\n+\n+\tif err != nil {\n+\t\treturn ct.MerkleTreeLeaf{}, ct.SignedCertificateTimestamp{}, err\n+\t}\n+\n+\t// Create a complete SCT including signature\n+\tsct, err := signSCT(km, t, res)\n+\n+\treturn leaf, sct, err\n }\n \n // CreateV1SCTForPrecertificate builds and signs a V1 CT SCT for a pre-certificate using the key\n // held by a key manager.\n-func SignV1SCTForPrecertificate(km crypto.KeyManager, cert *x509.Certificate, t time.Time) (ct.SignedCertificateTimestamp, error) {\n+func SignV1SCTForPrecertificate(km crypto.KeyManager, cert *x509.Certificate, t time.Time) (ct.MerkleTreeLeaf, ct.SignedCertificateTimestamp, error) {","path":"examples/ct/structures.go","position":37,"original_position":37,"commit_id":"293642a78e05f27c082da169198f11945be9d902","original_commit_id":"293642a78e05f27c082da169198f11945be9d902","user":{"login":"phad","id":874173,"avatar_url":"https://avatars.githubusercontent.com/u/874173?v=3","gravatar_id":"","url":"https://api.github.com/users/phad","html_url":"https://github.com/phad","followers_url":"https://api.github.com/users/phad/followers","following_url":"https://api.github.com/users/phad/following{/other_user}","gists_url":"https://api.github.com/users/phad/gists{/gist_id}","starred_url":"https://api.github.com/users/phad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phad/subscriptions","organizations_url":"https://api.github.com/users/phad/orgs","repos_url":"https://api.github.com/users/phad/repos","events_url":"https://api.github.com/users/phad/events{/privacy}","received_events_url":"https://api.github.com/users/phad/received_events","type":"User","site_admin":false},"body":"there's a lot of duplicated code.\r\n\r\ncan you extract a helper function that does the bulk of it, and to which these exported functions pass a func object for the bits in the middle that differ?","created_at":"2016-07-26T12:59:30Z","updated_at":"2016-07-26T12:59:30Z","html_url":"https://github.com/google/trillian/pull/84#discussion_r72243411","pull_request_url":"https://api.github.com/repos/google/trillian/pulls/84","_links":{"self":{"href":"https://api.github.com/repos/google/trillian/pulls/comments/72243411"},"html":{"href":"https://github.com/google/trillian/pull/84#discussion_r72243411"},"pull_request":{"href":"https://api.github.com/repos/google/trillian/pulls/84"}}},"pull_request":{"url":"https://api.github.com/repos/google/trillian/pulls/84","id":78843871,"html_url":"https://github.com/google/trillian/pull/84","diff_url":"https://github.com/google/trillian/pull/84.diff","patch_url":"https://github.com/google/trillian/pull/84.patch","issue_url":"https://api.github.com/repos/google/trillian/issues/84","number":84,"state":"open","locked":false,"title":"Fix that SCTs were not being correctly signed","user":{"login":"Martin2112","id":13366863,"avatar_url":"https://avatars.githubusercontent.com/u/13366863?v=3","gravatar_id":"","url":"https://api.github.com/users/Martin2112","html_url":"https://github.com/Martin2112","followers_url":"https://api.github.com/users/Martin2112/followers","following_url":"https://api.github.com/users/Martin2112/following{/other_user}","gists_url":"https://api.github.com/users/Martin2112/gists{/gist_id}","starred_url":"https://api.github.com/users/Martin2112/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Martin2112/subscriptions","organizations_url":"https://api.github.com/users/Martin2112/orgs","repos_url":"https://api.github.com/users/Martin2112/repos","events_url":"https://api.github.com/users/Martin2112/events{/privacy}","received_events_url":"https://api.github.com/users/Martin2112/received_events","type":"User","site_admin":false},"body":"Also builds MerkleTreeLeaf structure for them, which will shortly be used in the add chain handlers.","created_at":"2016-07-26T12:37:42Z","updated_at":"2016-07-26T12:59:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d4a1991108902aa160320484b1d0cc3ed9b6576c","assignee":{"login":"phad","id":874173,"avatar_url":"https://avatars.githubusercontent.com/u/874173?v=3","gravatar_id":"","url":"https://api.github.com/users/phad","html_url":"https://github.com/phad","followers_url":"https://api.github.com/users/phad/followers","following_url":"https://api.github.com/users/phad/following{/other_user}","gists_url":"https://api.github.com/users/phad/gists{/gist_id}","starred_url":"https://api.github.com/users/phad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phad/subscriptions","organizations_url":"https://api.github.com/users/phad/orgs","repos_url":"https://api.github.com/users/phad/repos","events_url":"https://api.github.com/users/phad/events{/privacy}","received_events_url":"https://api.github.com/users/phad/received_events","type":"User","site_admin":false},"assignees":[{"login":"phad","id":874173,"avatar_url":"https://avatars.githubusercontent.com/u/874173?v=3","gravatar_id":"","url":"https://api.github.com/users/phad","html_url":"https://github.com/phad","followers_url":"https://api.github.com/users/phad/followers","following_url":"https://api.github.com/users/phad/following{/other_user}","gists_url":"https://api.github.com/users/phad/gists{/gist_id}","starred_url":"https://api.github.com/users/phad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phad/subscriptions","organizations_url":"https://api.github.com/users/phad/orgs","repos_url":"https://api.github.com/users/phad/repos","events_url":"https://api.github.com/users/phad/events{/privacy}","received_events_url":"https://api.github.com/users/phad/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/google/trillian/milestones/2","html_url":"https://github.com/google/trillian/milestones/Log%20M2","labels_url":"https://api.github.com/repos/google/trillian/milestones/2/labels","id":1850239,"number":2,"title":"Log M2","description":"Serving inclusion proofs via Log API / RPC server and consistency proofs if there's time (not at intermediate tree sizes yet).\r\n\r\nStrawman CT front end with API implementing RFC 6962 requests, cert chain checking and valid roots. (not a complete implementation matching our C++ server at this point)","creator":{"login":"Martin2112","id":13366863,"avatar_url":"https://avatars.githubusercontent.com/u/13366863?v=3","gravatar_id":"","url":"https://api.github.com/users/Martin2112","html_url":"https://github.com/Martin2112","followers_url":"https://api.github.com/users/Martin2112/followers","following_url":"https://api.github.com/users/Martin2112/following{/other_user}","gists_url":"https://api.github.com/users/Martin2112/gists{/gist_id}","starred_url":"https://api.github.com/users/Martin2112/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Martin2112/subscriptions","organizations_url":"https://api.github.com/users/Martin2112/orgs","repos_url":"https://api.github.com/users/Martin2112/repos","events_url":"https://api.github.com/users/Martin2112/events{/privacy}","received_events_url":"https://api.github.com/users/Martin2112/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":11,"state":"open","created_at":"2016-06-27T11:26:41Z","updated_at":"2016-07-26T12:52:28Z","due_on":"2016-07-30T23:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/google/trillian/pulls/84/commits","review_comments_url":"https://api.github.com/repos/google/trillian/pulls/84/comments","review_comment_url":"https://api.github.com/repos/google/trillian/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/trillian/issues/84/comments","statuses_url":"https://api.github.com/repos/google/trillian/statuses/293642a78e05f27c082da169198f11945be9d902","head":{"label":"Martin2112:fix_scts","ref":"fix_scts","sha":"293642a78e05f27c082da169198f11945be9d902","user":{"login":"Martin2112","id":13366863,"avatar_url":"https://avatars.githubusercontent.com/u/13366863?v=3","gravatar_id":"","url":"https://api.github.com/users/Martin2112","html_url":"https://github.com/Martin2112","followers_url":"https://api.github.com/users/Martin2112/followers","following_url":"https://api.github.com/users/Martin2112/following{/other_user}","gists_url":"https://api.github.com/users/Martin2112/gists{/gist_id}","starred_url":"https://api.github.com/users/Martin2112/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Martin2112/subscriptions","organizations_url":"https://api.github.com/users/Martin2112/orgs","repos_url":"https://api.github.com/users/Martin2112/repos","events_url":"https://api.github.com/users/Martin2112/events{/privacy}","received_events_url":"https://api.github.com/users/Martin2112/received_events","type":"User","site_admin":false},"repo":{"id":60082567,"name":"trillian","full_name":"Martin2112/trillian","owner":{"login":"Martin2112","id":13366863,"avatar_url":"https://avatars.githubusercontent.com/u/13366863?v=3","gravatar_id":"","url":"https://api.github.com/users/Martin2112","html_url":"https://github.com/Martin2112","followers_url":"https://api.github.com/users/Martin2112/followers","following_url":"https://api.github.com/users/Martin2112/following{/other_user}","gists_url":"https://api.github.com/users/Martin2112/gists{/gist_id}","starred_url":"https://api.github.com/users/Martin2112/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Martin2112/subscriptions","organizations_url":"https://api.github.com/users/Martin2112/orgs","repos_url":"https://api.github.com/users/Martin2112/repos","events_url":"https://api.github.com/users/Martin2112/events{/privacy}","received_events_url":"https://api.github.com/users/Martin2112/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Martin2112/trillian","description":null,"fork":true,"url":"https://api.github.com/repos/Martin2112/trillian","forks_url":"https://api.github.com/repos/Martin2112/trillian/forks","keys_url":"https://api.github.com/repos/Martin2112/trillian/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Martin2112/trillian/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Martin2112/trillian/teams","hooks_url":"https://api.github.com/repos/Martin2112/trillian/hooks","issue_events_url":"https://api.github.com/repos/Martin2112/trillian/issues/events{/number}","events_url":"https://api.github.com/repos/Martin2112/trillian/events","assignees_url":"https://api.github.com/repos/Martin2112/trillian/assignees{/user}","branches_url":"https://api.github.com/repos/Martin2112/trillian/branches{/branch}","tags_url":"https://api.github.com/repos/Martin2112/trillian/tags","blobs_url":"https://api.github.com/repos/Martin2112/trillian/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Martin2112/trillian/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Martin2112/trillian/git/refs{/sha}","trees_url":"https://api.github.com/repos/Martin2112/trillian/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Martin2112/trillian/statuses/{sha}","languages_url":"https://api.github.com/repos/Martin2112/trillian/languages","stargazers_url":"https://api.github.com/repos/Martin2112/trillian/stargazers","contributors_url":"https://api.github.com/repos/Martin2112/trillian/contributors","subscribers_url":"https://api.github.com/repos/Martin2112/trillian/subscribers","subscription_url":"https://api.github.com/repos/Martin2112/trillian/subscription","commits_url":"https://api.github.com/repos/Martin2112/trillian/commits{/sha}","git_commits_url":"https://api.github.com/repos/Martin2112/trillian/git/commits{/sha}","comments_url":"https://api.github.com/repos/Martin2112/trillian/comments{/number}","issue_comment_url":"https://api.github.com/repos/Martin2112/trillian/issues/comments{/number}","contents_url":"https://api.github.com/repos/Martin2112/trillian/contents/{+path}","compare_url":"https://api.github.com/repos/Martin2112/trillian/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Martin2112/trillian/merges","archive_url":"https://api.github.com/repos/Martin2112/trillian/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Martin2112/trillian/downloads","issues_url":"https://api.github.com/repos/Martin2112/trillian/issues{/number}","pulls_url":"https://api.github.com/repos/Martin2112/trillian/pulls{/number}","milestones_url":"https://api.github.com/repos/Martin2112/trillian/milestones{/number}","notifications_url":"https://api.github.com/repos/Martin2112/trillian/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Martin2112/trillian/labels{/name}","releases_url":"https://api.github.com/repos/Martin2112/trillian/releases{/id}","deployments_url":"https://api.github.com/repos/Martin2112/trillian/deployments","created_at":"2016-05-31T11:07:09Z","updated_at":"2016-05-31T11:07:10Z","pushed_at":"2016-07-26T12:51:44Z","git_url":"git://github.com/Martin2112/trillian.git","ssh_url":"git@github.com:Martin2112/trillian.git","clone_url":"https://github.com/Martin2112/trillian.git","svn_url":"https://github.com/Martin2112/trillian","homepage":null,"size":774,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":false,"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":"google:master","ref":"master","sha":"52f5c84e72cdad13077a30dcdd7f03396042997c","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":58654489,"name":"trillian","full_name":"google/trillian","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/trillian","description":null,"fork":false,"url":"https://api.github.com/repos/google/trillian","forks_url":"https://api.github.com/repos/google/trillian/forks","keys_url":"https://api.github.com/repos/google/trillian/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/trillian/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/trillian/teams","hooks_url":"https://api.github.com/repos/google/trillian/hooks","issue_events_url":"https://api.github.com/repos/google/trillian/issues/events{/number}","events_url":"https://api.github.com/repos/google/trillian/events","assignees_url":"https://api.github.com/repos/google/trillian/assignees{/user}","branches_url":"https://api.github.com/repos/google/trillian/branches{/branch}","tags_url":"https://api.github.com/repos/google/trillian/tags","blobs_url":"https://api.github.com/repos/google/trillian/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/trillian/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/trillian/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/trillian/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/trillian/statuses/{sha}","languages_url":"https://api.github.com/repos/google/trillian/languages","stargazers_url":"https://api.github.com/repos/google/trillian/stargazers","contributors_url":"https://api.github.com/repos/google/trillian/contributors","subscribers_url":"https://api.github.com/repos/google/trillian/subscribers","subscription_url":"https://api.github.com/repos/google/trillian/subscription","commits_url":"https://api.github.com/repos/google/trillian/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/trillian/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/trillian/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/trillian/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/trillian/contents/{+path}","compare_url":"https://api.github.com/repos/google/trillian/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/trillian/merges","archive_url":"https://api.github.com/repos/google/trillian/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/trillian/downloads","issues_url":"https://api.github.com/repos/google/trillian/issues{/number}","pulls_url":"https://api.github.com/repos/google/trillian/pulls{/number}","milestones_url":"https://api.github.com/repos/google/trillian/milestones{/number}","notifications_url":"https://api.github.com/repos/google/trillian/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/trillian/labels{/name}","releases_url":"https://api.github.com/repos/google/trillian/releases{/id}","deployments_url":"https://api.github.com/repos/google/trillian/deployments","created_at":"2016-05-12T15:37:35Z","updated_at":"2016-07-20T21:10:19Z","pushed_at":"2016-07-26T12:51:44Z","git_url":"git://github.com/google/trillian.git","ssh_url":"git@github.com:google/trillian.git","clone_url":"https://github.com/google/trillian.git","svn_url":"https://github.com/google/trillian","homepage":null,"size":885,"stargazers_count":64,"watchers_count":64,"language":"Go","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":2,"forks":4,"open_issues":2,"watchers":64,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/trillian/pulls/84"},"html":{"href":"https://github.com/google/trillian/pull/84"},"issue":{"href":"https://api.github.com/repos/google/trillian/issues/84"},"comments":{"href":"https://api.github.com/repos/google/trillian/issues/84/comments"},"review_comments":{"href":"https://api.github.com/repos/google/trillian/pulls/84/comments"},"review_comment":{"href":"https://api.github.com/repos/google/trillian/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/trillian/pulls/84/commits"},"statuses":{"href":"https://api.github.com/repos/google/trillian/statuses/293642a78e05f27c082da169198f11945be9d902"}}}}
{"actor":{"display_login":"phad"}}