hasher

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2025 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetZeroHash added in v1.1.1

func GetZeroHash(depth int) []byte

func GetZeroHashLevel added in v1.1.1

func GetZeroHashLevel(hash string) (int, bool)

func GetZeroHashes added in v1.1.1

func GetZeroHashes() [65][32]byte

func ParseBitlist

func ParseBitlist(dst, buf []byte) ([]byte, uint64)

func WithDefaultHasher added in v1.1.1

func WithDefaultHasher(fn func(hh sszutils.HashWalker) error) error

Types

type HashFn

type HashFn func(dst []byte, input []byte) error

func NativeHashWrapper

func NativeHashWrapper(hashFn hash.Hash) HashFn

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 NewHasher

func NewHasher() *Hasher

NewHasher creates a new Hasher object with sha256 hash

func NewHasherWithHash

func NewHasherWithHash(hh hash.Hash) *Hasher

NewHasherWithHash creates a new Hasher object with a custom hash.Hash function

func NewHasherWithHashFn

func NewHasherWithHashFn(hh HashFn) *Hasher

NewHasherWithHashFn creates a new Hasher object with a custom HashFn function

func (*Hasher) Append

func (h *Hasher) Append(i []byte)

func (*Hasher) AppendBool

func (h *Hasher) AppendBool(b bool)

func (*Hasher) AppendBytes32

func (h *Hasher) AppendBytes32(b []byte)

func (*Hasher) AppendUint8

func (h *Hasher) AppendUint8(i uint8)

func (*Hasher) AppendUint16

func (h *Hasher) AppendUint16(i uint16)

func (*Hasher) AppendUint32

func (h *Hasher) AppendUint32(i uint32)

func (*Hasher) AppendUint64

func (h *Hasher) AppendUint64(i uint64)

func (*Hasher) FillUpTo32

func (h *Hasher) FillUpTo32()

func (*Hasher) Hash

func (h *Hasher) Hash() []byte

func (*Hasher) HashRoot

func (h *Hasher) HashRoot() (res [32]byte, err error)

HashRoot creates the hash final hash root

func (*Hasher) Index

func (h *Hasher) Index() int

Index marks the current buffer index

func (*Hasher) Merkleize

func (h *Hasher) Merkleize(indx int)

Merkleize is used to merkleize the last group of the hasher

func (*Hasher) MerkleizeProgressive

func (h *Hasher) MerkleizeProgressive(indx int)

Merkleize is used to merkleize the last group of the hasher

func (*Hasher) MerkleizeProgressiveWithActiveFields

func (h *Hasher) MerkleizeProgressiveWithActiveFields(indx int, activeFields []byte)

MerkleizeProgressiveWithMixin is used to merkleize progressive lists with length mixin

func (*Hasher) MerkleizeProgressiveWithMixin

func (h *Hasher) MerkleizeProgressiveWithMixin(indx int, num uint64)

MerkleizeProgressiveWithMixin is used to merkleize progressive lists with length mixin

func (*Hasher) MerkleizeWithMixin

func (h *Hasher) MerkleizeWithMixin(indx int, num, limit uint64)

MerkleizeWithMixin is used to merkleize the last group of the hasher

func (*Hasher) PutBitlist

func (h *Hasher) PutBitlist(bb []byte, maxSize uint64)

PutBitlist appends a ssz bitlist

func (*Hasher) PutBool

func (h *Hasher) PutBool(b bool)

PutBool appends a boolean

func (*Hasher) PutBytes

func (h *Hasher) PutBytes(b []byte)

PutBytes appends bytes

func (*Hasher) PutProgressiveBitlist

func (h *Hasher) PutProgressiveBitlist(bb []byte)

func (*Hasher) PutRootVector

func (h *Hasher) PutRootVector(b [][]byte, maxCapacity ...uint64) error

PutRootVector appends an array of roots

func (*Hasher) PutUint8

func (h *Hasher) PutUint8(i uint8)

PutUint8 appends a uint8 in 32 bytes

func (*Hasher) PutUint16

func (h *Hasher) PutUint16(i uint16)

PutUint16 appends a uint16 in 32 bytes

func (*Hasher) PutUint32

func (h *Hasher) PutUint32(i uint32)

PutUint32 appends a uint32 in 32 bytes

func (*Hasher) PutUint64

func (h *Hasher) PutUint64(i uint64)

PutUint64 appends a uint64 in 32 bytes

func (*Hasher) PutUint64Array

func (h *Hasher) PutUint64Array(b []uint64, maxCapacity ...uint64)

PutUint64Array appends an array of uint64

func (*Hasher) Reset

func (h *Hasher) Reset()

Reset resets the Hasher obj

func (*Hasher) WithTemp

func (h *Hasher) WithTemp(fn func(tmp []byte) []byte)

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

FastHasherPool is the fast hasher pool that uses the hashtree library if cgo is enabled

func (*HasherPool) Get

func (hh *HasherPool) Get() *Hasher

Get acquires a Hasher from the pool.

func (*HasherPool) Put

func (hh *HasherPool) Put(h *Hasher)

Put releases the Hasher to the pool.

Directories

Path Synopsis
MIT License
MIT License

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL