Documentation
¶
Overview ¶
Package b3 implements the BLAKE3 hash function: hashing, keyed hashing, key derivation, and extendable output.
on amd64 and arm64 it runs asm kernels. the purego build tag does not use asm; add GOEXPERIMENT=simd and that build vectorizes through simd/archsimd.
Index ¶
Constants ¶
const ( // Size is the default digest length in bytes. Size = 32 // BlockSize is the compression block length in bytes. BlockSize = 64 // KeySize is the key length for NewKeyed in bytes. KeySize = 32 )
Variables ¶
This section is empty.
Functions ¶
func DeriveKey ¶
DeriveKey returns the 32-byte key derived from material in the given context. context should be a hardcoded, globally unique application string.
Types ¶
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher is a hash.Hash for streaming BLAKE3 state.
func NewDeriveKey ¶
NewDeriveKey returns a Hasher for the key derivation mode: write the key material, read the derived key out. context should be a hardcoded, globally unique application string.
func NewKeyed ¶
NewKeyed returns a Hasher that uses the 32-byte key. it panics on any other length.
func (*Hasher) BlockSize ¶
BlockSize returns the compression block length (64).
func (*Hasher) Clone ¶
Clone returns an independent copy of the state. it never fails.
func (*Hasher) Reset ¶
func (h *Hasher) Reset()
Reset restores the state to as-created, including key and mode if applicable.
func (*Hasher) Sum ¶
Sum appends the digest of the data written to b and returns the resulting slice.
func (*Hasher) Write ¶
Write absorbs p. it never fails.
func (*Hasher) XOF ¶
func (h *Hasher) XOF() *OutputReader
XOF returns a reader over the output of the data written. the reader is an independent snapshot.
type OutputReader ¶
type OutputReader struct {
// contains filtered or unexported fields
}
OutputReader streams the output of a finalized hash. it implements io.Reader and io.Seeker.
func (*OutputReader) Read ¶
func (r *OutputReader) Read(p []byte) (int, error)
func (*OutputReader) Seek ¶
func (r *OutputReader) Seek(offset int64, whence int) (int64, error)
Seek repositions the stream. offsets past 2^63-1 are rejected because io.Seeker returns an int64, and io.SeekEnd is rejected outright.
Source Files
¶
- avx2_amd64.go
- avx512_amd64.go
- b3.go
- chain.go
- engine_amd64.go
- engine_simd.go
- errors.go
- parallel.go
- scalar_amd64.go
- vendor_amd64.go
- xof.go