def chunk_blocks

bend-collections-laws-crypto@1.0.0.0 · spec/crypto/blake/blake3.bend:180

import bend-collections-laws-crypto@1.0.0.0/spec/crypto/blake/blake3.bend as Blake3
import Base
import bend-collections-laws-crypto@1.0.0.0/src/crypto/blake/blake3/types.bend as T

180# The blocks of a chunk are compressed in order starting from the key (IV in
181# hash mode), all with the chunk counter t; the first block carries
182# CHUNK_START and the last CHUNK_END. The last block is not compressed here:
183# it is the chunk's output node (2.5, 2.6 decide its flags and use).
184# n blocks follow the current block (in pair); the last block has len bytes.
185def chunk_blocks(n: Nat, +t: U32, +index: U32, +flags: U32, +len: Nat, cv: T.CV, pair: Array<U32> & T.Block) -> Array<U32> & T.Out:
186  match n pair:
187    case 0n Tuple{a,b}: (a,T.Out{cv,zero_tail(b,len),t,U32.from_nat(len),U32.or(flags,chunk_end())})
188    case 1n+p Tuple{a,b}: chunk_blocks(p,t,U32.add(index,16),0,len,compress(cv,zero_tail(b,64n),t,64,flags),read_block(a,U32.add(index,16)))

Uses (15)

Used by (9)