def cr.chunks
import bend-osdev-crypto@0.1.0.0/modes.bend as Modesimport Base
111# the whole n-byte pieces of xs, last first (cur: the piece being filled,
112# reversed, i bytes long)
113def cr.chunks(xs: List<&2, U32>, +n: Nat, +i: Nat, +cur: List<&2, U32>, acc: List<&2, List<&2, U32>>) -> List<&2, List<&2, U32>>:
114 match xs:
115 case Nil{}:
116 acc
117 case Con{x, t}:
118 +c : List<&2, U32> = Con{x, cur}
119 +full = Nat.is_eq(1n+i, n)
120 cr.chunks(t, n, cr.pick_n(full, 1n+i), cr.pick_cur(full, c), cr.pick_acc(full, c, acc))