blake3

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: MIT Imports: 4 Imported by: 253

README

blake3

GoDoc Go Report Card

go get lukechampine.com/blake3

blake3 implements the BLAKE3 cryptographic hash function.

This implementation is a port of the Rust reference implementation, refactored into more idiomatic Go style and with a handful of performance tweaks. Performance is not great, not terrible. Eventually an assembly-optimized implementation will be merged into x/crypto, and then you should switch to that. In the meantime, you can use this package for code that needs BLAKE3 compatibility and doesn't need to be blazing fast.

Documentation

Overview

Package blake3 implements the BLAKE3 cryptographic hash function.

This is a direct port of the Rust reference implementation. It is not optimized for performance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveKey added in v0.2.0

func DeriveKey(subKey []byte, ctx string, srcKey []byte)

DeriveKey derives a subkey from ctx and srcKey.

func Sum256 added in v0.2.0

func Sum256(b []byte) [32]byte

Sum256 returns the unkeyed BLAKE3 hash of b, truncated to 256 bits.

func Sum512 added in v0.2.0

func Sum512(b []byte) [64]byte

Sum512 returns the unkeyed BLAKE3 hash of b, truncated to 512 bits.

Types

type Hasher

type Hasher struct {
	// contains filtered or unexported fields
}

Hasher implements hash.Hash.

func New

func New(size int, key []byte) *Hasher

New returns a Hasher for the specified size and key. If key is nil, the hash is unkeyed.

func (*Hasher) BlockSize

func (h *Hasher) BlockSize() int

BlockSize implements hash.Hash.

func (*Hasher) Reset

func (h *Hasher) Reset()

Reset implements hash.Hash.

func (*Hasher) Size

func (h *Hasher) Size() int

Size implements hash.Hash.

func (*Hasher) Sum

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

Sum implements hash.Hash.

func (*Hasher) Write

func (h *Hasher) Write(p []byte) (int, error)

Write implements hash.Hash.

func (*Hasher) XOF

func (h *Hasher) XOF() *OutputReader

XOF returns an OutputReader initialized with the current hash state.

type OutputReader

type OutputReader struct {
	// contains filtered or unexported fields
}

An OutputReader produces an seekable stream of output. Up to 2^64 - 1 bytes can be safely read from the stream.

func (*OutputReader) Read

func (or *OutputReader) Read(p []byte) (int, error)

Read implements io.Reader. It always return len(p), nil.

func (*OutputReader) Seek added in v0.2.0

func (or *OutputReader) Seek(offset int64, whence int) (int64, error)

Seek implements io.Seeker. SeekEnd is defined as 2^64 - 1 bytes, the maximum safe output of a BLAKE3 stream.

Jump to

Keyboard shortcuts

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