From bd7f85f538a14e59efd647c3fadf9e6dbc6383f7 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Wed, 2 Jun 2021 00:40:31 +0200 Subject: added leaf hash helper --- types/util.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'types') diff --git a/types/util.go b/types/util.go index dc8ccba..3cd7dfa 100644 --- a/types/util.go +++ b/types/util.go @@ -4,6 +4,10 @@ import ( "crypto/sha256" ) +const ( + LeafHashPrefix = 0x00 +) + func Hash(buf []byte) *[HashSize]byte { var ret [HashSize]byte hash := sha256.New() @@ -11,3 +15,7 @@ func Hash(buf []byte) *[HashSize]byte { copy(ret[:], hash.Sum(nil)) return &ret } + +func HashLeaf(buf []byte) *[HashSize]byte { + return Hash(append([]byte{LeafHashPrefix}, buf...)) +} -- cgit v1.2.3