aboutsummaryrefslogtreecommitdiff
path: root/pkg/db/trillian.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@mullvad.net>2022-05-21 20:32:17 +0200
committerRasmus Dahlberg <rasmus@mullvad.net>2022-05-21 20:32:17 +0200
commit1224f565a27155c3abef3ecf4d86cf6f472b1374 (patch)
tree8eecc23f18f2b65ef25e5c67c7ec7b499d3c3129 /pkg/db/trillian.go
parent45d7f7875ce885369b1d1aecc644875cf6bbfdba (diff)
pick-up merkle package
TODO(ln5): upgrade sigsum-go dependency in go.mod file
Diffstat (limited to 'pkg/db/trillian.go')
-rw-r--r--pkg/db/trillian.go15
1 files changed, 8 insertions, 7 deletions
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]))
}