You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
470 B

  1. package merkle
  2. import (
  3. "github.com/tendermint/tendermint/crypto/tmhash"
  4. )
  5. // TODO: make these have a large predefined capacity
  6. var (
  7. leafPrefix = []byte{0}
  8. innerPrefix = []byte{1}
  9. )
  10. // returns tmhash(0x00 || leaf)
  11. func leafHash(leaf []byte) []byte {
  12. return tmhash.Sum(append(leafPrefix, leaf...))
  13. }
  14. // returns tmhash(0x01 || left || right)
  15. func innerHash(left []byte, right []byte) []byte {
  16. return tmhash.Sum(append(innerPrefix, append(left, right...)...))
  17. }