tendermint/p2p/util.go

16 lines
333 B
Go
Raw Normal View History

2015-10-25 18:21:51 -07:00
package p2p
import (
"crypto/sha256"
)
// doubleSha256 calculates sha256(sha256(b)) and returns the resulting bytes.
func doubleSha256(b []byte) []byte {
hasher := sha256.New()
2017-11-27 14:05:55 -08:00
hasher.Write(b) // nolint: errcheck, gas
2015-10-25 18:21:51 -07:00
sum := hasher.Sum(nil)
hasher.Reset()
2017-11-27 14:05:55 -08:00
hasher.Write(sum) // nolint: errcheck, gas
2015-10-25 18:21:51 -07:00
return hasher.Sum(nil)
}