Chacha.quarter: def of bend-collections@1.0.0.0 Import: import bend-collections@1.0.0.0/spec/crypto/chacha.bend as Chacha Lines 38-52 of bend-collections@1.0.0.0/spec/crypto/chacha.bend: https://jend.leeeet.dev/read.txt?path=bend-collections@1.0.0.0/spec/crypto/chacha.bend&start_line=38&end_line=52 import Base # 2.2: QUARTERROUND(a, b, c, d) applied to the state at those positions: # a += b; d ^= a; d <<<= 16; # c += d; b ^= c; b <<<= 12; # a += b; d ^= a; d <<<= 8; # c += d; b ^= c; b <<<= 7; def quarter(+s: List<&2, U32>, +a: Nat, +b: Nat, +c: Nat, +d: Nat) -> List<&2, U32>: +a1 = U32.add(get(s, a), get(s, b)) +d1 = rotl(U32.xor(get(s, d), a1), 16n) +c1 = U32.add(get(s, c), d1) +b1 = rotl(U32.xor(get(s, b), c1), 12n) +a2 = U32.add(a1, b1) +d2 = rotl(U32.xor(d1, a2), 8n) +c2 = U32.add(c1, d2) +b2 = rotl(U32.xor(b1, c2), 7n) put(put(put(put(s, a, a2), b, b2), c, c2), d, d2) Uses (8): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.xor https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/chacha.bend&name=get https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/chacha.bend&name=put https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/chacha.bend&name=rotl