From c11006fb89bcac7fdfc2278990b2b1a3a3553ba9 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Tue, 17 Nov 2020 15:34:33 +0100 Subject: added type tests As a result these changes were made: - Simplified a few New* functions - Allowed empty inclusion and consistency proofs, which is in contrast to not being able to marshal them due to `tls:"minlen:1"`. For example, an inclusion proof will be empty for a Merkle tree of size 1. - Disallowed empty signatures and chains in a leaf's Appendix - Removed unnecessary examples --- handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'handler.go') diff --git a/handler.go b/handler.go index d77379d..839a310 100644 --- a/handler.go +++ b/handler.go @@ -138,7 +138,7 @@ func getProofByHash(ctx context.Context, i *Instance, w http.ResponseWriter, r * return status, fmt.Errorf("bad GetInclusionProofByHashResponse: %v", errInner) } - rsp, err := NewInclusionProofV1(i.LogParameters.LogId, uint64(req.TreeSize), trsp.Proof[0]).MarshalB64() + rsp, err := NewInclusionProofV1(i.LogParameters.LogId, uint64(req.TreeSize), uint64(trsp.Proof[0].LeafIndex), trsp.Proof[0].Hashes).MarshalB64() if err != nil { return http.StatusInternalServerError, err } @@ -165,7 +165,7 @@ func getConsistencyProof(ctx context.Context, i *Instance, w http.ResponseWriter return status, fmt.Errorf("bad GetConsistencyProofResponse: %v", errInner) } - rsp, err := NewConsistencyProofV1(i.LogParameters.LogId, req.First, req.Second, trsp.Proof).MarshalB64() + rsp, err := NewConsistencyProofV1(i.LogParameters.LogId, uint64(req.First), uint64(req.Second), trsp.Proof.Hashes).MarshalB64() if err != nil { return http.StatusInternalServerError, err } @@ -186,7 +186,7 @@ func getSth(ctx context.Context, i *Instance, w http.ResponseWriter, _ *http.Req return status, fmt.Errorf("bad GetLatestSignedLogRootResponse: %v", errInner) } - sth, err := i.LogParameters.genV1Sth(NewTreeHeadV1(i.LogParameters, &lr)) + sth, err := i.LogParameters.genV1Sth(NewTreeHeadV1(&lr)) if err != nil { return http.StatusInternalServerError, fmt.Errorf("failed creating signed tree head: %v", err) } -- cgit v1.2.3