aboutsummaryrefslogtreecommitdiff
path: root/types/util.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-06-02 00:40:31 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-06-02 00:40:31 +0200
commitbd7f85f538a14e59efd647c3fadf9e6dbc6383f7 (patch)
tree8c471732ba8706f40c3335fe88aa61520ab5046c /types/util.go
parent2dcaf038655426c572c5d292973001c581f0a1a2 (diff)
added leaf hash helper
Diffstat (limited to 'types/util.go')
-rw-r--r--types/util.go8
1 files changed, 8 insertions, 0 deletions
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...))
+}