erigon-pulse/cmd/lightclient/utils/crypto.go
Giulio rebuffo 59df60a2c1
Added proper Message Id for Consensus Gossip subscription (#5584)
* first prototype

* Added Proper Message ID to gossip

* ops

* ops

* lint why?

* u kidding?

* just why

* maybe

Co-authored-by: giuliorebuffo <giuliorebuffo@system76-pc.localdomain>
2022-09-30 23:53:54 +02:00

30 lines
350 B
Go

package utils
import (
"crypto/sha256"
"hash"
"sync"
)
var hasherPool = sync.Pool{
New: func() interface{} {
return sha256.New()
},
}
func Keccak256(data []byte) [32]byte {
h, ok := hasherPool.Get().(hash.Hash)
if !ok {
h = sha256.New()
}
defer hasherPool.Put(h)
h.Reset()
var b [32]byte
h.Write(data)
h.Sum(b[:0])
return b
}