Skip to content

crypto.blake3 #

Constants #

const size256 = 32

size256 is the size, in bytes, of a Blake3 256 checksum.

const key_length = 32

key_length is the length, in bytes, of a Blake3 key

const block_size = 64

block_size is the block size, in bytes, of the Blake3 hash functions.

const chunk_size = 1024

chunk_size is the chunk size, in bytes, of the Blake3 hash functions. A chunk consists of 16 blocks.

fn sum256 #

fn sum256(data []u8) []u8

sum256 returns the Blake3 256 bit hash of the data.

fn sum_derive_key256 #

fn sum_derive_key256(context []u8, key_material []u8) []u8

sum_derived_key256 returns the Blake3 256 bit derived key hash of the key material

fn sum_keyed256 #

fn sum_keyed256(data []u8, key []u8) []u8

sum_keyed256 returns the Blake3 256 bit keyed hash of the data.

fn Digest.new_derive_key_hash #

fn Digest.new_derive_key_hash(context []u8) !Digest

Digest.new_derive_key_hash initializes a Digest structure for deriving a Blake3 key

fn Digest.new_hash #

fn Digest.new_hash() !Digest

Digest.new_hash initializes a Digest structure for a Blake3 hash

fn Digest.new_keyed_hash #

fn Digest.new_keyed_hash(key []u8) !Digest

Digest.new_keyed_hash initializes a Digest structure for a Blake3 keyed hash

fn (Digest) write #

fn (mut d Digest) write(data []u8) !

write adds bytes to the hash

fn (Digest) checksum #

fn (mut d Digest) checksum(size u64) []u8

checksum finalizes the hash and returns the generated bytes.

This is the point in the hashing operation that we need to know how many bytes of hash to generate. Normally this is 32 but can be any size up to 2**64.