Blake2b.mix: def of bend-collections-laws-crypto@1.0.0.0 Import: import bend-collections-laws-crypto@1.0.0.0/spec/crypto/blake/blake2b.bend as Blake2b Lines 129-143 of bend-collections-laws-crypto@1.0.0.0/spec/crypto/blake/blake2b.bend: https://jend.leeeet.dev/read.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/crypto/blake/blake2b.bend&start_line=129&end_line=143 import Base import bend-collections-laws-crypto@1.0.0.0/src/crypto/blake/blake2b/types.bend as T # RFC 7693 section 3.1, the mixing function G with R1..R4 = 32, 24, 16, 63: # v[a] := (v[a] + v[b] + x) mod 2^64; v[d] := (v[d] ^ v[a]) >>> R1 # v[c] := (v[c] + v[d]) mod 2^64; v[b] := (v[b] ^ v[c]) >>> R2 # v[a] := (v[a] + v[b] + y) mod 2^64; v[d] := (v[d] ^ v[a]) >>> R3 # v[c] := (v[c] + v[d]) mod 2^64; v[b] := (v[b] ^ v[c]) >>> R4 def mix(+s: T.State, +a: Nat, +b: Nat, +c: Nat, +d: Nat, x: T.Lane, y: T.Lane) -> T.State: +a1 = add(add(at(s,a),at(s,b)),x) +d1 = rotr(xor(at(s,d),a1),32n) +c1 = add(at(s,c),d1) +b1 = rotr(xor(at(s,b),c1),24n) +a2 = add(add(a1,b1),y) +d2 = rotr(xor(d1,a2),16n) +c2 = add(c1,d2) +b2 = rotr(xor(b1,c2),63n) 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=Nat https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/crypto/blake/blake2b.bend&name=add https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/crypto/blake/blake2b.bend&name=at https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/crypto/blake/blake2b.bend&name=put https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/crypto/blake/blake2b.bend&name=rotr https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/crypto/blake/blake2b.bend&name=xor https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/crypto/blake/blake2b/types.bend&name=Lane https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/crypto/blake/blake2b/types.bend&name=State