Documentation
¶
Index ¶
- func GetZeroHash(depth int) []byte
- func GetZeroHashLevel(hash string) (int, bool)
- func GetZeroHashes() [65][32]byte
- func ParseBitlist(dst, buf []byte) ([]byte, uint64)
- func ParseBitlistWithHasher(hw sszutils.HashWalker, buf []byte) ([]byte, uint64)
- func WithDefaultHasher(fn func(hh sszutils.HashWalker) error) error
- type HashFn
- type Hasher
- func (h *Hasher) Append(i []byte)
- func (h *Hasher) AppendBool(b bool)
- func (h *Hasher) AppendBytes32(b []byte)
- func (h *Hasher) AppendUint8(i uint8)
- func (h *Hasher) AppendUint16(i uint16)
- func (h *Hasher) AppendUint32(i uint32)
- func (h *Hasher) AppendUint64(i uint64)
- func (h *Hasher) FillUpTo32()
- func (h *Hasher) Hash() []byte
- func (h *Hasher) HashRoot() (res [32]byte, err error)
- func (h *Hasher) Index() int
- func (h *Hasher) Merkleize(indx int)
- func (h *Hasher) MerkleizeProgressive(indx int)
- func (h *Hasher) MerkleizeProgressiveWithActiveFields(indx int, activeFields []byte)
- func (h *Hasher) MerkleizeProgressiveWithMixin(indx int, num uint64)
- func (h *Hasher) MerkleizeWithMixin(indx int, num, limit uint64)
- func (h *Hasher) PutBitlist(bb []byte, maxSize uint64)
- func (h *Hasher) PutBool(b bool)
- func (h *Hasher) PutBytes(b []byte)
- func (h *Hasher) PutProgressiveBitlist(bb []byte)
- func (h *Hasher) PutRootVector(b [][]byte, maxCapacity ...uint64) error
- func (h *Hasher) PutUint8(i uint8)
- func (h *Hasher) PutUint16(i uint16)
- func (h *Hasher) PutUint32(i uint32)
- func (h *Hasher) PutUint64(i uint64)
- func (h *Hasher) PutUint64Array(b []uint64, maxCapacity ...uint64)
- func (h *Hasher) Reset()
- func (h *Hasher) WithTemp(fn func(tmp []byte) []byte)
- type HasherPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetZeroHash ¶ added in v1.1.1
func GetZeroHashLevel ¶ added in v1.1.1
func GetZeroHashes ¶ added in v1.1.1
func GetZeroHashes() [65][32]byte
func ParseBitlist ¶
ParseBitlist decodes an SSZ-encoded bitlist into its raw bit representation.
SSZ bitlists include a mandatory termination bit: a single `1` bit appended immediately after the final data bit, then padded to a full byte. The position of this termination bit defines the logical length of the bitlist.
This function performs the inverse transformation:
- Identify the termination bit in the final byte and compute the logical bitlist length (`size`).
- Clear the termination bit, leaving only the actual data bits.
- Trim any trailing zero bytes introduced by SSZ padding.
- Return the compact raw bitlist (no termination bit, no padding) together with its logical size.
The returned `[]byte` contains the data bits packed little-endian in each byte, and `size` is the exact number of meaningful bits in that raw bitlist.
func ParseBitlistWithHasher ¶ added in v1.2.0
func ParseBitlistWithHasher(hw sszutils.HashWalker, buf []byte) ([]byte, uint64)
func WithDefaultHasher ¶ added in v1.1.1
func WithDefaultHasher(fn func(hh sszutils.HashWalker) error) error
Types ¶
type HashFn ¶
func NativeHashWrapper ¶
NativeHashWrapper wraps a hash.Hash function into a HashFn
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher is a utility tool to hash SSZ structs
func NewHasherWithHash ¶
NewHasherWithHash creates a new Hasher object with a custom hash.Hash function
func NewHasherWithHashFn ¶
NewHasherWithHashFn creates a new Hasher object with a custom HashFn function
func (*Hasher) AppendBool ¶
func (*Hasher) AppendBytes32 ¶
func (*Hasher) AppendUint8 ¶
func (*Hasher) AppendUint16 ¶
func (*Hasher) AppendUint32 ¶
func (*Hasher) AppendUint64 ¶
func (*Hasher) FillUpTo32 ¶
func (h *Hasher) FillUpTo32()
func (*Hasher) MerkleizeProgressive ¶
Merkleize is used to merkleize the last group of the hasher
func (*Hasher) MerkleizeProgressiveWithActiveFields ¶
MerkleizeProgressiveWithMixin is used to merkleize progressive lists with length mixin
func (*Hasher) MerkleizeProgressiveWithMixin ¶
MerkleizeProgressiveWithMixin is used to merkleize progressive lists with length mixin
func (*Hasher) MerkleizeWithMixin ¶
MerkleizeWithMixin is used to merkleize the last group of the hasher
func (*Hasher) PutBitlist ¶
PutBitlist appends a ssz bitlist
func (*Hasher) PutProgressiveBitlist ¶
func (*Hasher) PutRootVector ¶
PutRootVector appends an array of roots
func (*Hasher) PutUint64Array ¶
PutUint64Array appends an array of uint64
type HasherPool ¶
type HasherPool struct {
HashFn HashFn
// contains filtered or unexported fields
}
HasherPool may be used for pooling Hashers for similarly typed SSZs.
var DefaultHasherPool HasherPool
DefaultHasherPool is a default hasher pool
var FastHasherPool HasherPool = HasherPool{ HashFn: hashtree.HashByteSlice, }
FastHasherPool is the fast hasher pool that uses the hashtree library if cgo is enabled