def message_chunks
import bend-collections-laws-crypto@1.0.0.0/spec/crypto/blake/blake3.bend as Blake3import Base
import bend-collections-laws-crypto@1.0.0.0/src/crypto/blake/blake3/types.bend as T
210# A message of `length` bytes has max(1, ceil(length/1024)) chunks: n =
211# (length - 1) div 1024 full ones, then the last of length - 1024n bytes.
212def message_chunks(a: Array<U32>, +length: Nat) -> List<&2,T.Out>:
213 +n = Nat.div(Nat.sub(length,1n),1024n)
214 +last = Nat.sub(length,Nat.mul(n,1024n))
215 chunks(n,0,0,last,chunk_at(n,0,0,last,a))