aboutsummaryrefslogtreecommitdiff
path: root/pkg/types/trunnel.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-09-13 19:53:17 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-09-13 19:53:17 +0200
commit26b786d9857db21fdf110eaf9cb6d1d6e4e68ef9 (patch)
tree92606f47a91ebcc9e3cb4258af7a9472fc6f2e07 /pkg/types/trunnel.go
parentf34351da0731a11316e2266d2aadd62554a5b867 (diff)
updated (co)signed tree head structuresv0.2.0
- Added key_hash in tree head, see motivation in api.md - Added separate types for (co)signed tree heads - Refactored tree head HTTP APIs to be current, see api.md
Diffstat (limited to 'pkg/types/trunnel.go')
-rw-r--r--pkg/types/trunnel.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/pkg/types/trunnel.go b/pkg/types/trunnel.go
index 268f6f7..5350c5b 100644
--- a/pkg/types/trunnel.go
+++ b/pkg/types/trunnel.go
@@ -10,6 +10,8 @@ const (
MessageSize = 8 + HashSize
// LeafSize is the number of bytes in a Trunnel-encoded leaf
LeafSize = MessageSize + SignatureSize + HashSize
+ // TreeHeadSize is the number of bytes in a Trunnel-encoded tree head
+ TreeHeadSize = 8 + 8 + HashSize + HashSize
)
// Marshal returns a Trunnel-encoded message
@@ -30,10 +32,11 @@ func (l *Leaf) Marshal() []byte {
// Marshal returns a Trunnel-encoded tree head
func (th *TreeHead) Marshal() []byte {
- buf := make([]byte, 8+8+HashSize)
+ buf := make([]byte, TreeHeadSize)
binary.BigEndian.PutUint64(buf[0:8], th.Timestamp)
binary.BigEndian.PutUint64(buf[8:16], th.TreeSize)
- copy(buf[16:], th.RootHash[:])
+ copy(buf[16:16+HashSize], th.RootHash[:])
+ copy(buf[16+HashSize:], th.KeyHash[:])
return buf
}