guts

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package guts provides a low-level interface to the BLAKE3 cryptographic hash function.

Index

Constants

View Source
const (
	FlagChunkStart = 1 << iota
	FlagChunkEnd
	FlagParent
	FlagRoot
	FlagKeyedHash
	FlagDeriveKeyContext
	FlagDeriveKeyMaterial

	BlockSize = 64
	ChunkSize = 1024

	MaxSIMD = 16 // AVX-512 vectors can store 16 words
)

Various constants.

Variables

View Source
var IV = [8]uint32{
	0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
	0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19,
}

IV is the BLAKE3 initialization vector.

Functions

func BytesToWords

func BytesToWords(bytes [64]byte) [16]uint32

BytesToWords converts an array of 64 bytes to an array of 16 bytes.

func ChainingValue

func ChainingValue(n Node) (cv [8]uint32)

ChainingValue compresses n and returns the first 8 output words.

func CompressBlocks

func CompressBlocks(out *[MaxSIMD * BlockSize]byte, n Node)

CompressBlocks compresses MaxSIMD copies of n with successive counter values, storing the results in out.

func CompressNode

func CompressNode(n Node) (out [16]uint32)

CompressNode compresses a node into a 16-word output.

func WordsToBytes

func WordsToBytes(words [16]uint32) [64]byte

WordsToBytes converts an array of 16 words to an array of 64 bytes.

Types

type Node

type Node struct {
	CV       [8]uint32 // chaining value from previous node
	Block    [16]uint32
	Counter  uint64
	BlockLen uint32
	Flags    uint32
}

A Node represents a chunk or parent in the BLAKE3 Merkle tree.

func CompressBuffer

func CompressBuffer(buf *[MaxSIMD * ChunkSize]byte, buflen int, key *[8]uint32, counter uint64, flags uint32) Node

CompressBuffer compresses up to MaxSIMD chunks in parallel and returns their root node.

func CompressChunk

func CompressChunk(chunk []byte, key *[8]uint32, counter uint64, flags uint32) Node

CompressChunk compresses a single chunk, returning its final (uncompressed) node.

func ParentNode

func ParentNode(left, right [8]uint32, key *[8]uint32, flags uint32) Node

ParentNode returns a Node that incorporates the chaining values of two child nodes.

Jump to

Keyboard shortcuts

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