def absorb512

bend-collections@1.0.0.0 · src/crypto/hash.bend:327

import bend-collections@1.0.0.0/src/crypto/hash.bend as Hash
import Base
import bend-collections@1.0.0.0/src/crypto/sha512/types.bend as T512
import bend-collections@1.0.0.0/src/crypto/sha512/core.bend as C512

327# Compress every whole block (fuel bounds the count: any fuel >= the number of
328# blocks reads them all; fewer leaves the rest buffered, still correct). The
329# chaining state and the unread bytes; orig is the list the read r started at.
330# q is the algorithm's round parameter (64n), kept a variable for the proofs.
331def absorb512(fuel: Nat, r: Read512, orig: List<&2, U32>, +q: Nat, s: T512.State) -> Sha512State:
332  match fuel r:
333    case 0n _:
334      St512{s, orig}
335    case 1n+p Short512{}:
336      St512{s, orig}
337    case 1n+p Blk512{w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15, +rest}:
338      absorb512(p, read512_0(rest), rest, q, C512.compress16(w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15, q, C512.round_constants(), s))

Uses (9)

Used by (1)