def quarter
bend-collections-laws-math@1.0.0.0 · spec/math/random/chacha8rand.bend:58
import bend-collections-laws-math@1.0.0.0/spec/math/random/chacha8rand.bend as Chacha8rand
import Base
58
59
60def quarter(+x: List<&2, U32>, +a: Nat, +b: Nat, +c: Nat, +d: Nat) -> List<&2, U32>:
61 +a1 = U32.add(get(x, a), get(x, b))
62 +d1 = rotl(U32.xor(get(x, d), a1), 16n)
63 +c1 = U32.add(get(x, c), d1)
64 +b1 = rotl(U32.xor(get(x, b), c1), 12n)
65 +a2 = U32.add(a1, b1)
66 +d2 = rotl(U32.xor(d1, a2), 8n)
67 +c2 = U32.add(c1, d2)
68 +b2 = rotl(U32.xor(b1, c2), 7n)
69 put(put(put(put(x, a, a2), b, b2), c, c2), d, d2)