From 1224f565a27155c3abef3ecf4d86cf6f472b1374 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sat, 21 May 2022 20:32:17 +0200 Subject: pick-up merkle package TODO(ln5): upgrade sigsum-go dependency in go.mod file --- pkg/db/trillian.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'pkg/db/trillian.go') diff --git a/pkg/db/trillian.go b/pkg/db/trillian.go index 3147c8d..ccb5334 100644 --- a/pkg/db/trillian.go +++ b/pkg/db/trillian.go @@ -7,6 +7,7 @@ import ( "git.sigsum.org/sigsum-go/pkg/log" "git.sigsum.org/sigsum-go/pkg/requests" + "git.sigsum.org/sigsum-go/pkg/merkle" "git.sigsum.org/sigsum-go/pkg/types" "github.com/google/trillian" trillianTypes "github.com/google/trillian/types" @@ -26,14 +27,14 @@ func (c *TrillianClient) AddLeaf(ctx context.Context, req *requests.Leaf) error leaf := types.Leaf{ Statement: types.Statement{ ShardHint: req.ShardHint, - Checksum: *types.HashFn(req.Message[:]), + Checksum: *merkle.HashFn(req.Message[:]), }, Signature: req.Signature, - KeyHash: *types.HashFn(req.PublicKey[:]), + KeyHash: *merkle.HashFn(req.PublicKey[:]), } serialized := leaf.ToBinary() - log.Debug("queueing leaf request: %x", types.LeafHash(serialized)) + log.Debug("queueing leaf request: %x", merkle.HashLeafNode(serialized)) rsp, err := c.GRPC.QueueLeaf(ctx, &trillian.QueueLeafRequest{ LogId: c.TreeID, Leaf: &trillian.LogLeaf{ @@ -75,7 +76,7 @@ func (c *TrillianClient) GetTreeHead(ctx context.Context) (*types.TreeHead, erro if err := r.UnmarshalBinary(rsp.SignedLogRoot.LogRoot); err != nil { return nil, fmt.Errorf("no log root: unmarshal failed: %v", err) } - if len(r.RootHash) != types.HashSize { + if len(r.RootHash) != merkle.HashSize { return nil, fmt.Errorf("unexpected hash length: %d", len(r.RootHash)) } return treeHeadFromLogRoot(&r), nil @@ -181,10 +182,10 @@ func treeHeadFromLogRoot(lr *trillianTypes.LogRootV1) *types.TreeHead { return &th } -func nodePathFromHashes(hashes [][]byte) ([]types.Hash, error) { - path := make([]types.Hash, len(hashes)) +func nodePathFromHashes(hashes [][]byte) ([]merkle.Hash, error) { + path := make([]merkle.Hash, len(hashes)) for i := 0; i < len(hashes); i++ { - if len(hashes[i]) != types.HashSize { + if len(hashes[i]) != merkle.HashSize { return nil, fmt.Errorf("unexpected hash length: %v", len(hashes[i])) } -- cgit v1.2.3