diff options
Diffstat (limited to 'types')
| -rw-r--r-- | types/util.go | 8 | 
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...)) +} | 
