github.com/franono/tendermint@v0.32.2-0.20200527150959-749313264ce9/crypto/merkle/hash.go (about)

     1  package merkle
     2  
     3  import (
     4  	"github.com/franono/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(0x00 || leaf)
    14  func leafHash(leaf []byte) []byte {
    15  	return tmhash.Sum(append(leafPrefix, leaf...))
    16  }
    17  
    18  // returns tmhash(0x01 || left || right)
    19  func innerHash(left []byte, right []byte) []byte {
    20  	return tmhash.Sum(append(innerPrefix, append(left, right...)...))
    21  }