def absorb

bend-collections-laws-crypto@1.0.0.0 · spec/crypto/sha3.bend:84

import bend-collections-laws-crypto@1.0.0.0/spec/crypto/sha3.bend as Sha3
import Base
import bend-collections-laws-crypto@1.0.0.0/src/crypto/keccak/types.bend as T
import bend-collections-laws-crypto@1.0.0.0/spec/crypto/keccak/permutation.bend as K

84# Section 4, step 6: S = f(S XOR (P_i || 0^c)) for each r-bit block P_i.
85def absorb(ls: List<&2, T.Lane>, +rounds: Nat, s: T.State) -> T.State:
86  match ls:
87    case l0 <> l1 <> l2 <> l3 <> l4 <> l5 <> l6 <> l7 <> l8 <> l9 <> l10 <> l11 <> l12 <> l13 <> l14 <> l15 <> l16 <> rest:
88      absorb(rest, rounds, K.rounds(rounds, 0n, of_lanes(xor_lanes(to_lanes(s),
89        [l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16]))))
90    case _:
91      s

Uses (8)

Used by (3)