def window_compress16

bend-collections@1.0.0.0 · proofs/crypto/sha/packed/core_model.bend:115

import bend-collections@1.0.0.0/proofs/crypto/sha/packed/core_model.bend as CoreModel
import Base
import bend-collections@1.0.0.0/src/crypto/sha/packed/core.bend as Runtime
import bend-collections@1.0.0.0/src/crypto/sha/state.bend as S

115# Fast path for the 16-word blocks produced by block_bytes. It executes the
116# seed rounds directly and constructs only the fixed rolling window.
117def window_compress16(+a: U32, +b: U32, +c: U32, +d: U32,
118  +e: U32, +f: U32, +g: U32, +h: U32,
119  +i: U32, +j: U32, +k: U32, +l: U32,
120  +m: U32, +n: U32, +o: U32, +p: U32,
121  +extra: Nat, +ks: List<&2, U32>, +s: S.State) -> S.State:
122  match ks:
123    case k0 <> k1 <> k2 <> k3 <> k4 <> k5 <> k6 <> k7 <>
124      k8 <> k9 <> k10 <> k11 <> k12 <> k13 <> k14 <> k15 <> kt:
125      s1 = Runtime.step(s, k0, a)
126      s2 = Runtime.step(s1, k1, b)
127      s3 = Runtime.step(s2, k2, c)
128      s4 = Runtime.step(s3, k3, d)
129      s5 = Runtime.step(s4, k4, e)
130      s6 = Runtime.step(s5, k5, f)
131      s7 = Runtime.step(s6, k6, g)
132      s8 = Runtime.step(s7, k7, h)
133      s9 = Runtime.step(s8, k8, i)
134      s10 = Runtime.step(s9, k9, j)
135      s11 = Runtime.step(s10, k10, k)
136      s12 = Runtime.step(s11, k11, l)
137      s13 = Runtime.step(s12, k12, m)
138      s14 = Runtime.step(s13, k13, n)
139      s15 = Runtime.step(s14, k14, o)
140      s16 = Runtime.step(s15, k15, p)
141      Runtime.feedforward(s, window_rounds(extra,
142        Runtime.W{p, o, n, m, l, k, j, i, h, g, f, e, d, c, b, a}, kt, s16))
143    case _:
144      fused_compress([a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p], extra, ks, s)

Uses (9)

Used by (6)