Documentation ¶
Overview ¶
Package ssz defines HashTreeRoot utility functions.
Index ¶
- func BitlistRoot(bfield bitfield.Bitfield, maxCapacity uint64) ([32]byte, error)
- func BitwiseMerkleize(chunks [][32]byte, count, limit uint64) ([32]byte, error)
- func ByteArrayRootWithLimit(roots [][]byte, limit uint64) ([32]byte, error)
- func ByteSliceRoot(slice []byte, maxLength uint64) ([32]byte, error)
- func CheckpointRoot(checkpoint *ethpb.Checkpoint) ([32]byte, error)
- func ConsolidationRequestsSliceRoot(consolidationRequests []*enginev1.ConsolidationRequest, limit uint64) ([32]byte, error)
- func DepositRequestsSliceRoot(depositRequests []*enginev1.DepositRequest, limit uint64) ([32]byte, error)
- func Depth(v uint64) (out uint8)
- func ForkRoot(fork *ethpb.Fork) ([32]byte, error)
- func Merkleize(hasher Hasher, count, limit uint64, leaf func(i uint64) []byte) (out [32]byte)
- func MerkleizeByteSliceSSZ(input []byte) ([32]byte, error)
- func MerkleizeListSSZ[T Hashable](elements []T, limit uint64) ([32]byte, error)
- func MerkleizeVector(elements [][32]byte, length uint64) [32]byte
- func MerkleizeVectorSSZ[T Hashable](elements []T, length uint64) ([32]byte, error)
- func MixInLength(root [32]byte, length []byte) [32]byte
- func PackByChunk(serializedItems [][]byte) ([][bytesPerChunk]byte, error)
- func SlashingsRoot(slashings []uint64) ([32]byte, error)
- func SliceRoot[T Hashable](slice []T, limit uint64) ([32]byte, error)
- func TransactionsRoot(txs [][]byte) ([32]byte, error)
- func Uint64Root(val uint64) [32]byte
- func WithdrawalRequestsSliceRoot(withdrawalRequests []*enginev1.WithdrawalRequest, limit uint64) ([32]byte, error)
- func WithdrawalSliceRoot(withdrawals []*enginev1.Withdrawal, limit uint64) ([32]byte, error)
- type HashFn
- type Hashable
- type Hasher
- type HasherFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BitlistRoot ¶
BitlistRoot returns the mix in length of a bitwise Merkleized bitfield.
func BitwiseMerkleize ¶
BitwiseMerkleize - given ordered BYTES_PER_CHUNK-byte chunks, if necessary utilize zero chunks so that the number of chunks is a power of two, Merkleize the chunks, and return the root. Note that merkleize on a single chunk is simply that chunk, i.e. the identity when the number of chunks is one.
func ByteArrayRootWithLimit ¶
ByteArrayRootWithLimit computes the HashTreeRoot Merkleization of a list of [32]byte roots according to the Ethereum Simple Serialize specification.
func ByteSliceRoot ¶
ByteSliceRoot is a helper func to merkleize an arbitrary List[Byte, N] this func runs Chunkify + MerkleizeVector max length is dividable by 32 ( root length )
func CheckpointRoot ¶
func CheckpointRoot(checkpoint *ethpb.Checkpoint) ([32]byte, error)
CheckpointRoot computes the HashTreeRoot Merkleization of a InitWithReset struct value according to the Ethereum Simple Serialize specification.
func ConsolidationRequestsSliceRoot ¶ added in v5.1.0
func ConsolidationRequestsSliceRoot(consolidationRequests []*enginev1.ConsolidationRequest, limit uint64) ([32]byte, error)
func DepositRequestsSliceRoot ¶ added in v5.1.0
func DepositRequestsSliceRoot(depositRequests []*enginev1.DepositRequest, limit uint64) ([32]byte, error)
DepositRequestsSliceRoot computes the HTR of a slice of deposit receipts. The limit parameter is used as input to the bitwise merkleization algorithm.
func ForkRoot ¶
ForkRoot computes the HashTreeRoot Merkleization of a Fork struct value according to the Ethereum Simple Serialize specification.
func MerkleizeByteSliceSSZ ¶
MerkleizeByteSliceSSZ hashes a byteslice by chunkifying it and returning the corresponding HTR as if it were a fixed vector of bytes of the given length.
func MerkleizeListSSZ ¶
MerkleizeListSSZ hashes each element in the list and then returns the HTR of the list of corresponding roots, with the length mixed in.
func MerkleizeVector ¶
MerkleizeVector uses our optimized routine to hash a list of 32-byte elements.
func MerkleizeVectorSSZ ¶
MerkleizeVectorSSZ hashes each element in the list and then returns the HTR of the corresponding list of roots
func MixInLength ¶
MixInLength appends hash length to root
func PackByChunk ¶
PackByChunk a given byte array's final chunk with zeroes if needed.
func SlashingsRoot ¶
SlashingsRoot computes the HashTreeRoot Merkleization of a list of uint64 slashing values according to the Ethereum Simple Serialize specification.
func TransactionsRoot ¶
TransactionsRoot computes the HTR for the Transactions' property of the ExecutionPayload The code was largely copy/pasted from the code generated to compute the HTR of the entire ExecutionPayload.
func Uint64Root ¶
Uint64Root computes the HashTreeRoot Merkleization of a simple uint64 value according to the Ethereum Simple Serialize specification.
func WithdrawalRequestsSliceRoot ¶ added in v5.1.0
func WithdrawalRequestsSliceRoot(withdrawalRequests []*enginev1.WithdrawalRequest, limit uint64) ([32]byte, error)
WithdrawalRequestsSliceRoot computes the HTR of a slice of withdrawal requests from the EL. The limit parameter is used as input to the bitwise merkleization algorithm.
func WithdrawalSliceRoot ¶
func WithdrawalSliceRoot(withdrawals []*enginev1.Withdrawal, limit uint64) ([32]byte, error)
WithdrawalSliceRoot computes the HTR of a slice of withdrawals. The limit parameter is used as input to the bitwise merkleization algorithm.
Types ¶
type Hasher ¶
type Hasher interface { Hash(a []byte) [32]byte Combi(a [32]byte, b [32]byte) [32]byte MixIn(a [32]byte, i uint64) [32]byte }
Hasher describes an interface through which we can perform hash operations on byte arrays,indices,etc.
type HasherFunc ¶
type HasherFunc struct {
// contains filtered or unexported fields
}
HasherFunc defines a structure to hold a hash function and can be used for multiple rounds of hashing.
func NewHasherFunc ¶
func NewHasherFunc(h HashFn) *HasherFunc
NewHasherFunc is the constructor for the object that fulfills the Hasher interface.
func (*HasherFunc) Combi ¶
func (h *HasherFunc) Combi(a, b [32]byte) [32]byte
Combi appends the two inputs and hashes them.
func (*HasherFunc) Hash ¶
func (h *HasherFunc) Hash(a []byte) [32]byte
Hash utilizes the provided hash function for the object.