def chunk

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

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

190# A chunk of len bytes (1..1024; 0 only for the empty message) at word index
191# has max(1, ceil(len/64)) blocks: n = (len - 1) div 64 full blocks, then a
192# last block of len - 64n bytes.
193def chunk(a: Array<U32>, +t: U32, +index: U32, +len: Nat) -> Array<U32> & T.Out:
194  +n = Nat.div(Nat.sub(len,1n),64n)
195  chunk_blocks(n,t,index,chunk_start(),Nat.sub(len,Nat.mul(n,64n)),cv_of(iv()),read_block(a,index))

Uses (13)

Used by (7)