def last_go

bend-collections@1.0.0.0 · src/crypto/blake/blake3/blake3.bend:124

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

124# The last chunk: n full blocks before its last block of len bytes (1..64, or
125# 0 for the empty message). Returns the pending output of the last block.
126def last_go(n: Nat, +counter: U32, +index: U32, +flags: U32, +len: Nat, cv: T.CV, pair: Array<U32> & T.Block) -> Array<U32> & T.Out:
127  match n pair:
128    case 0n Tuple{a,b}: (a,T.Out{cv,mask_block(b,len),counter,U32.from_nat(len),U32.or(flags,2)})
129    case 1n+p Tuple{a,b}: last_go(p,counter,U32.add(index,16),0,len,C.compress(cv,b,counter,64,flags),read_block(a,U32.add(index,16)))

Uses (14)

Used by (1)