github.com/Team-Kujira/tendermint@v0.34.24-indexer/crypto/merkle/hash.go (about) 1 package merkle 2 3 import ( 4 "github.com/tendermint/tendermint/crypto/tmhash" 5 ) 6 7 // TODO: make these have a large predefined capacity 8 var ( 9 leafPrefix = []byte{0} 10 innerPrefix = []byte{1} 11 ) 12 13 // returns tmhash(<empty>) 14 func emptyHash() []byte { 15 return tmhash.Sum([]byte{}) 16 } 17 18 // returns tmhash(0x00 || leaf) 19 func leafHash(leaf []byte) []byte { 20 return tmhash.Sum(append(leafPrefix, leaf...)) 21 } 22 23 // returns tmhash(0x01 || left || right) 24 func innerHash(left []byte, right []byte) []byte { 25 return tmhash.Sum(append(innerPrefix, append(left, right...)...)) 26 }