def absorb3

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

import bend-collections-laws-crypto@1.0.0.0/src/crypto/hash.bend as Hash
import Base
import bend-collections-laws-crypto@1.0.0.0/src/crypto/keccak/types.bend as TK
import bend-collections-laws-crypto@1.0.0.0/src/crypto/keccak/permutation.bend as P
import bend-collections-laws-crypto@1.0.0.0/src/crypto/sha3/core.bend as C3

481# Compress every whole block (fuel bounds the count: any fuel >= the number of
482# blocks reads them all; fewer leaves the rest buffered, still correct). The
483# chaining state and the unread bytes; orig is the list the read r started at.
484# q is the algorithm's round parameter (24n), kept a variable for the proofs.
485def absorb3(fuel: Nat, r: Read3, orig: List<&2, U32>, +q: Nat, s: TK.State) -> Sha3State:
486  match fuel r:
487    case 0n _:
488      St3{s, orig}
489    case 1n+p Short3{}:
490      St3{s, orig}
491    case 1n+p Blk3{w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15, w16, +rest}:
492      absorb3(p, read3_0(rest), rest, q, P.rounds(q, 0n, C3.inject(s, w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15, w16)))

Uses (9)

Used by (2)