Skip to content

Commit

Permalink
Update the dependency on merkle (#2688)
Browse files Browse the repository at this point in the history
  • Loading branch information
pav-kv authored Apr 6, 2022
1 parent 33ad835 commit 936a097
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions client/log_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (c *LogVerifier) VerifyRoot(trusted *types.LogRootV1, newRoot *trillian.Sig
// Implicitly trust the first root we get.
if trusted.TreeSize != 0 {
// Verify consistency proof.
if err := c.v.VerifyConsistencyProof(int64(trusted.TreeSize), int64(r.TreeSize), trusted.RootHash, r.RootHash, consistency); err != nil {
if err := c.v.VerifyConsistency(trusted.TreeSize, r.TreeSize, trusted.RootHash, r.RootHash, consistency); err != nil {
return nil, fmt.Errorf("failed to verify consistency proof from %d->%d %x->%x: %v", trusted.TreeSize, r.TreeSize, trusted.RootHash, r.RootHash, err)
}
}
Expand All @@ -90,8 +90,7 @@ func (c *LogVerifier) VerifyInclusionByHash(trusted *types.LogRootV1, leafHash [
return fmt.Errorf("VerifyInclusionByHash() error: proof == nil")
}

return c.v.VerifyInclusionProof(proof.LeafIndex, int64(trusted.TreeSize), proof.Hashes,
trusted.RootHash, leafHash)
return c.v.VerifyInclusion(uint64(proof.LeafIndex), trusted.TreeSize, leafHash, proof.Hashes, trusted.RootHash)
}

// BuildLeaf runs the leaf hasher over data and builds a leaf.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/prometheus/client_golang v1.12.1
github.com/prometheus/client_model v0.2.0
github.com/pseudomuto/protoc-gen-doc v1.5.0
github.com/transparency-dev/merkle v0.0.0-20220119214824-02a3e2029520
github.com/transparency-dev/merkle v0.0.0-20220331122146-fd7bbd80f70a
go.etcd.io/etcd/client/v3 v3.5.2
go.etcd.io/etcd/etcdctl/v3 v3.5.2
go.etcd.io/etcd/server/v3 v3.5.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,8 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA=
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4=
github.com/transparency-dev/merkle v0.0.0-20220119214824-02a3e2029520 h1:G8YKtExgEBSSHbrQKa10Tv+sEixDIuLP11m6yC5agaY=
github.com/transparency-dev/merkle v0.0.0-20220119214824-02a3e2029520/go.mod h1:B8FIw5LTq6DaULoHsVFRzYIUDkl8yuSwCdZnOZGKL/A=
github.com/transparency-dev/merkle v0.0.0-20220331122146-fd7bbd80f70a h1:LGI/LDlV3b2RYQGvaLlPFPjMJuos4dG1yWCSb95/RL8=
github.com/transparency-dev/merkle v0.0.0-20220331122146-fd7bbd80f70a/go.mod h1:B8FIw5LTq6DaULoHsVFRzYIUDkl8yuSwCdZnOZGKL/A=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
Expand Down
6 changes: 3 additions & 3 deletions integration/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func checkInclusionProofsAtIndex(index int64, logID int64, tree *inmemory.Merkle
resp, err := client.GetInclusionProof(ctx, &trillian.GetInclusionProofRequest{
LogId: logID,
LeafIndex: index,
TreeSize: int64(treeSize),
TreeSize: treeSize,
})
cancel()

Expand All @@ -469,7 +469,7 @@ func checkInclusionProofsAtIndex(index int64, logID int64, tree *inmemory.Merkle
verifier := merkle.NewLogVerifier(rfc6962.DefaultHasher)
// Offset by 1 to make up for C++ / Go implementation differences.
merkleLeafHash := tree.LeafHash(index + 1)
if err := verifier.VerifyInclusionProof(index, treeSize, resp.Proof.Hashes, root, merkleLeafHash); err != nil {
if err := verifier.VerifyInclusion(uint64(index), uint64(treeSize), merkleLeafHash, resp.Proof.Hashes, root); err != nil {
return err
}
}
Expand Down Expand Up @@ -506,7 +506,7 @@ func checkConsistencyProof(consistParams consistencyProofParams, treeID int64, t
verifier := merkle.NewLogVerifier(rfc6962.DefaultHasher)
root1 := tree.RootAtSnapshot(req.FirstTreeSize).Hash()
root2 := tree.RootAtSnapshot(req.SecondTreeSize).Hash()
return verifier.VerifyConsistencyProof(req.FirstTreeSize, req.SecondTreeSize,
return verifier.VerifyConsistency(uint64(req.FirstTreeSize), uint64(req.SecondTreeSize),
root1, root2, resp.Proof.Hashes)
}

Expand Down

0 comments on commit 936a097

Please sign in to comment.