Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

[Go] Implement GetProofByHash #1249

Merged
merged 1 commit into from
Aug 4, 2016
Merged

[Go] Implement GetProofByHash #1249

merged 1 commit into from
Aug 4, 2016

Conversation

gdbelvin
Copy link
Contributor

@gdbelvin gdbelvin commented Jun 14, 2016

This PR includes the code required to fetch inclusion proofs

Contributes to #1159

@gdbelvin
Copy link
Contributor Author

Added tests

@pphaneuf
Copy link
Contributor

Another merge crept up, these muddle up the PRs a bit, you should use something along the lines of git fetch https://github.com/google/certificate-transparency.git master && git rebase FETCH_BASE (could be simplified a bit, but the exact command-line would depend on what the remotes on your local repo are named).

@gdbelvin
Copy link
Contributor Author

Rebased as requested. PTAL

@gdbelvin gdbelvin force-pushed the hash branch 3 times, most recently from 6a85d30 to f537683 Compare July 14, 2016 11:21
@gdbelvin
Copy link
Contributor Author

Rebased again. PTAL
@pphaneuf

@@ -105,6 +101,19 @@ type getEntryAndProofResponse struct {
AuditPath []string `json:"audit_path"` // the corresponding proof
}

type getProofByHashResponse struct {
LeafIndex int `json:"leaf_index"` // The 0-based index of the end entity corresponding to the "hash" parameter.
AuditPath []string `json:"audit_path"` // An array of base64-encoded Merkle Tree nodes proving the inclusion of the chosen certificate.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work if you make this field a [][]byte instead (and strip out the base64 decoding at line 423)?

@pphaneuf
Copy link
Contributor

Hmm... Am I missing some reference from logclient.go, or are the changes in serialization.go, types.go, and signatures.go are not related at all to what's in the description of this PR? Other change got mixed in?

@gdbelvin gdbelvin force-pushed the hash branch 4 times, most recently from 69dda11 to 53113ef Compare July 18, 2016 17:49
@googlebot
Copy link
Collaborator

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@gdbelvin gdbelvin force-pushed the hash branch 3 times, most recently from 7fcc5f9 to 63c35e6 Compare July 18, 2016 18:05
@googlebot
Copy link
Collaborator

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Aug 3, 2016
@gdbelvin
Copy link
Contributor Author

gdbelvin commented Aug 3, 2016

@pphaneuf @taknira

Cleaned up this PR, and made it exclusively about fetching the inclusion proof.

@gdbelvin gdbelvin force-pushed the hash branch 4 times, most recently from 67d3d8d to 9f25b9d Compare August 3, 2016 21:13
@gdbelvin gdbelvin changed the title Implement GetProofByHash in Go client [Go] Implement GetProofByHash Aug 3, 2016
@@ -319,6 +319,7 @@ type TimestampedEntry struct {
X509Entry ASN1Cert
JSONData []byte
PrecertEntry PreCert
JSONData []byte
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the one at line 320? This causes a build error. 😉

@gdbelvin
Copy link
Contributor Author

gdbelvin commented Aug 4, 2016

Fixed

@@ -308,3 +317,12 @@ func (c *LogClient) GetSTH() (sth *ct.SignedTreeHead, err error) {
sth.TreeHeadSignature = *ds
return
}

// GetProofByHash returns an audit path for the hash of an SCT.
func (c *LogClient) GetProofByHash(hash []byte, treeSize uint64) (GetProofByHashResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big enough that GetProofByHashResponse should be returned as a pointer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would also allow returning nil in the case of an error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some historical baggage, but might as well take a context.Context as the first parameter on new methods?

@pphaneuf
Copy link
Contributor

pphaneuf commented Aug 4, 2016

Done with this round of review, should be straightforward... 😃

func (c *LogClient) GetProofByHash(hash []byte, treeSize uint64) (GetProofByHashResponse, error) {
var resp GetProofByHashResponse
func (c *LogClient) GetProofByHash(ctx context.Context, hash []byte, treeSize uint64) (*GetProofByHashResponse, error) {
resp := new(GetProofByHashResponse)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, you've seen my comment in #1285? I like var better than new: it seems there's no case where new does anything that you can't do with var and &, so I'd rather have just one way of doing things, for consistency, and let the compiler do the escape analysis...

And either way, I'd still want it declared "at the last moment". 😉

@pphaneuf
Copy link
Contributor

pphaneuf commented Aug 4, 2016

LGTM, waiting on Travis to merge.

@pphaneuf pphaneuf added the LGTM label Aug 4, 2016
@pphaneuf pphaneuf self-assigned this Aug 4, 2016
@pphaneuf
Copy link
Contributor

pphaneuf commented Aug 4, 2016

Will need a rebase (and you can squash into one commit, if you want).

@gdbelvin
Copy link
Contributor Author

gdbelvin commented Aug 4, 2016

Rebased on master

@pphaneuf pphaneuf merged commit 51e504a into google:master Aug 4, 2016
@gdbelvin gdbelvin deleted the hash branch August 5, 2016 15:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants