Skip to main content

blake3_chunk

Function blake3_chunk 

Source
pub fn blake3_chunk(
    builder: &CircuitBuilder,
    key: Option<[Wire; 8]>,
    blocks: &[[Wire; 16]],
    block_lens: &[Wire],
    counter: u64,
    last_flags_extra: u32,
) -> [Wire; 8]
Expand description

Computes the BLAKE3 chaining value of a single chunk.

A BLAKE3 chunk is up to 16 blocks (1024 bytes) compressed in a chain: the chaining value is threaded block-to-block starting from key, or from the IV when unkeyed. The first block carries CHUNK_START and the last carries CHUNK_END; every block carries the chunk’s counter (its chunk index). last_flags_extra is OR’d into the last block’s flags — pass ROOT when this chunk is the entire message (no parent tree), otherwise 0.

§Arguments

  • builder: Circuit builder.
  • key: the 8-word key in keyed mode, None in unkeyed mode.
  • blocks: the chunk’s message blocks (1..=16), each 16 little-endian 32-bit words.
  • block_lens: the byte length (0..=64) of each block; the trailing block may be partial.
  • counter: the chunk index, used as the 64-bit block counter for every block.
  • last_flags_extra: extra flags OR’d into the last block (e.g. ROOT for a lone chunk).

§Returns

The chunk’s 8-word chaining value, each word a 32-bit value in its low 32 bits.