From 26b786d9857db21fdf110eaf9cb6d1d6e4e68ef9 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Mon, 13 Sep 2021 19:53:17 +0200 Subject: updated (co)signed tree head structures - 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 --- pkg/types/trunnel.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'pkg/types/trunnel.go') 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 } -- cgit v1.2.3