mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
* Begin simple merkle compatibility PR * Fix query_test * Use trillian test vectors * Change the split point per RFC 6962 * update spec * refactor innerhash to match spec * Update changelog * Address @liamsi's comments * Write the comment requested by @liamsi
22 lines
470 B
Go
22 lines
470 B
Go
package merkle
|
|
|
|
import (
|
|
"github.com/tendermint/tendermint/crypto/tmhash"
|
|
)
|
|
|
|
// TODO: make these have a large predefined capacity
|
|
var (
|
|
leafPrefix = []byte{0}
|
|
innerPrefix = []byte{1}
|
|
)
|
|
|
|
// returns tmhash(0x00 || leaf)
|
|
func leafHash(leaf []byte) []byte {
|
|
return tmhash.Sum(append(leafPrefix, leaf...))
|
|
}
|
|
|
|
// returns tmhash(0x01 || left || right)
|
|
func innerHash(left []byte, right []byte) []byte {
|
|
return tmhash.Sum(append(innerPrefix, append(left, right...)...))
|
|
}
|