blake3_g
stdlib/blake3/blake3_g.nbv
blake3_g(state, mx, my)
The BLAKE3 G function on every column of a batch of states. state holds the rows a, b, c and d one after the other, each row the 128 bits of words 0..4, 4..8, 8..12 or 12..16 of every state in the batch. G acts on word i of each row, mx and my are the message words in the same layout as a row.
a += b + mx; d ^= a; d >>>= 16;
c += d; b ^= c; b >>>= 12;
a += b + my; d ^= a; d >>>= 8;
c += d; b ^= c; b >>>= 7;
- Calls
bits/add32_bits,bits/rotl32_bits,slice,bits/xor_bits_vec_wtns- Precompiles
clone!,concat!,div_exact!,len!- Used by
blake3/blake3_compress
Source
# The BLAKE3 G function on every column of a batch of states. `state` holds
# the rows a, b, c and d one after the other, each row the 128 bits of words
# 0..4, 4..8, 8..12 or 12..16 of every state in the batch. G acts on word i
# of each row, `mx` and `my` are the message words in the same layout as a
# row.
#
# a += b + mx; d ^= a; d >>>= 16;
# c += d; b ^= c; b >>>= 12;
# a += b + my; d ^= a; d >>>= 8;
# c += d; b ^= c; b >>>= 7;
(state, mx, my)
static w = div_exact! (len! state), 4
let mut a = slice((clone! state), 0, w)
let mut b = slice((clone! state), w, w)
let mut c = slice((clone! state), 2 * w, w)
let mut d = slice(state, 3 * w, w)
# right rotations by r are left rotations by 32 - r. The xors are
# materialized so b and d, which are only ever xored, do not accumulate
# linear combinations across rounds
a = add32_bits((clone! a) + (clone! b) + mx, 3)
d = rotl32_bits(xor_bits_vec_wtns((clone! d), (clone! a)), 16)
c = add32_bits((clone! c) + (clone! d), 2)
b = rotl32_bits(xor_bits_vec_wtns((clone! b), (clone! c)), 20)
a = add32_bits((clone! a) + (clone! b) + my, 3)
d = rotl32_bits(xor_bits_vec_wtns((clone! d), (clone! a)), 24)
c = add32_bits((clone! c) + (clone! d), 2)
b = rotl32_bits(xor_bits_vec_wtns(b, (clone! c)), 25)
concat! a, b, c, d