Documentation ¶
Overview ¶
Package hashutil includes all hash-function related helpers for Prysm.
Index ¶
- Variables
- func CustomSHA256Hasher() func([]byte) [32]byte
- func FastSum256(data []byte) [32]byte
- func FastSum64(data []byte) uint64
- func Hash(data []byte) [32]byte
- func HashKeccak256(data []byte) [32]byte
- func HashProto(msg proto.Message) (result [32]byte, err error)
- func MerkleRoot(values [][]byte) []byte
Constants ¶
This section is empty.
Variables ¶
var ErrNilProto = errors.New("cannot hash a nil protobuf message")
ErrNilProto can occur when attempting to hash a protobuf message that is nil or has nil objects within lists.
Functions ¶
func CustomSHA256Hasher ¶ added in v0.3.2
CustomSHA256Hasher returns a hash function that uses an enclosed hasher. This is not safe for concurrent use as the same hasher is being called throughout.
Note: that this method is only more performant over hashutil.Hash if the callback is used more than 5 times.
func FastSum256 ¶ added in v0.3.0
FastSum256 returns a hash sum of the input data using highwayhash. This method is not secure, but may be used as a quick identifier for objects where collisions are acceptable.
func FastSum64 ¶
FastSum64 returns a hash sum of the input data using highwayhash. This method is not secure, but may be used as a quick identifier for objects where collisions are acceptable.
func Hash ¶
Hash defines a function that returns the sha256 checksum of the data passed in. https://github.com/ethereum/eth2.0-specs/blob/v0.9.3/specs/core/0_beacon-chain.md#hash
func HashKeccak256 ¶
HashKeccak256 defines a function which returns the Keccak-256/SHA3 hash of the data passed in.
func MerkleRoot ¶
MerkleRoot derives the merkle root from a 2d byte array with each element in the outer array signifying the data that is to be represented in the merkle tree. Note: This function is only used to merklize a list of block root hashes. As such, we assume the input comes pre-hashed and do NOT hash the leaves. Spec:
def merkle_root(values): o = [0] * len(values) + values for i in range(len(values)-1, 0, -1): o[i] = hash(o[i*2] + o[i*2+1]) return o[1]
Types ¶
This section is empty.