aboutsummaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-06-01 00:21:30 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-06-01 00:21:30 +0200
commit519784b5ee58370d6c1262b0eb6c72ee3580f293 (patch)
tree29b9aa8b28aec09d8a49a53e783cc82ad0183ec2 /util.go
parent1ac7f1bad7596bc0cc489d85de8bdf5d195b99a3 (diff)
started to update stfe server
Work in progress.
Diffstat (limited to 'util.go')
-rw-r--r--util.go48
1 files changed, 25 insertions, 23 deletions
diff --git a/util.go b/util.go
index 847c3f7..b5cca48 100644
--- a/util.go
+++ b/util.go
@@ -1,40 +1,42 @@
package stfe
import (
- "fmt"
+ //"fmt"
- "github.com/google/trillian"
+ //"github.com/google/trillian"
ttypes "github.com/google/trillian/types"
"github.com/system-transparency/stfe/types"
)
-func NewTreeHeadV1FromLogRoot(lr *ttypes.LogRootV1) *types.TreeHeadV1 {
- return &types.TreeHeadV1{
- Timestamp: uint64(lr.TimestampNanos / 1000 / 1000),
+func NewTreeHeadFromLogRoot(lr *ttypes.LogRootV1) *types.TreeHead {
+ var hash [types.HashSize]byte
+ th := types.TreeHead{
+ Timestamp: uint64(lr.TimestampNanos / 1000 / 1000 / 1000),
TreeSize: uint64(lr.TreeSize),
- RootHash: types.NodeHash{
- Data: lr.RootHash,
- },
- Extension: make([]byte, 0),
+ RootHash: &hash,
}
+ copy(th.RootHash[:], lr.RootHash)
+ return &th
}
-func NewNodePathFromHashPath(hashes [][]byte) []types.NodeHash {
- path := make([]types.NodeHash, 0, len(hashes))
+func NodePathFromHashes(hashes [][]byte) []*[types.HashSize]byte {
+ var path []*[types.HashSize]byte
for _, hash := range hashes {
- path = append(path, types.NodeHash{hash})
+ var h [types.HashSize]byte
+ copy(h[:], hash)
+ path = append(path, &h)
}
return path
}
-func NewStItemListFromLeaves(leaves []*trillian.LogLeaf) (*types.StItemList, error) {
- items := make([]types.StItem, 0, len(leaves))
- for _, leaf := range leaves {
- var item types.StItem
- if err := types.Unmarshal(leaf.LeafValue, &item); err != nil {
- return nil, fmt.Errorf("Unmarshal failed: %v", err)
- }
- items = append(items, item)
- }
- return &types.StItemList{items}, nil
-}
+//func NewStItemListFromLeaves(leaves []*trillian.LogLeaf) (*types.StItemList, error) {
+// items := make([]types.StItem, 0, len(leaves))
+// for _, leaf := range leaves {
+// var item types.StItem
+// if err := types.Unmarshal(leaf.LeafValue, &item); err != nil {
+// return nil, fmt.Errorf("Unmarshal failed: %v", err)
+// }
+// items = append(items, item)
+// }
+// return &types.StItemList{items}, nil
+//}