feature. See also
. The project being documented here (as the example) is the Zig library itself.
blake3.roundFnVec
fn roundFnVec(comptime Vec: type, v: *[16]Vec, m: *const [16]Vec, r: usize) void
File
Code
fn roundFnVec(comptime Vec: type, v: *[16]Vec, m: *const [16]Vec, r: usize) void {
const schedule = &msg_schedule[r];
inline for (0..4) |i| {
v[i] +%= m[schedule[i * 2]];
}
inline for (0..4) |i| {
v[i] +%= v[i + 4];
}
inline for (0..4) |i| {
v[i + 12] ^= v[i];
}
inline for (0..4) |i| {
v[i + 12] = rotr(Vec, v[i + 12], 16);
}
inline for (0..4) |i| {
v[i + 8] +%= v[i + 12];
}
inline for (0..4) |i| {
v[i + 4] ^= v[i + 8];
}
inline for (0..4) |i| {
v[i + 4] = rotr(Vec, v[i + 4], 12);
}
inline for (0..4) |i| {
v[i] +%= m[schedule[i * 2 + 1]];
}
inline for (0..4) |i| {
v[i] +%= v[i + 4];
}
inline for (0..4) |i| {
v[i + 12] ^= v[i];
}
inline for (0..4) |i| {
v[i + 12] = rotr(Vec, v[i + 12], 8);
}
inline for (0..4) |i| {
v[i + 8] +%= v[i + 12];
}
inline for (0..4) |i| {
v[i + 4] ^= v[i + 8];
}
inline for (0..4) |i| {
v[i + 4] = rotr(Vec, v[i + 4], 7);
}
inline for (0..4) |i| {
v[i] +%= m[schedule[i * 2 + 8]];
}
const b_indices = [4]u8{ 5, 6, 7, 4 };
inline for (0..4) |i| {
v[i] +%= v[b_indices[i]];
}
const d_indices = [4]u8{ 15, 12, 13, 14 };
inline for (0..4) |i| {
v[d_indices[i]] ^= v[i];
}
inline for (0..4) |i| {
v[d_indices[i]] = rotr(Vec, v[d_indices[i]], 16);
}
const c_indices = [4]u8{ 10, 11, 8, 9 };
inline for (0..4) |i| {
v[c_indices[i]] +%= v[d_indices[i]];
}
inline for (0..4) |i| {
v[b_indices[i]] ^= v[c_indices[i]];
}
inline for (0..4) |i| {
v[b_indices[i]] = rotr(Vec, v[b_indices[i]], 12);
}
inline for (0..4) |i| {
v[i] +%= m[schedule[i * 2 + 9]];
}
inline for (0..4) |i| {
v[i] +%= v[b_indices[i]];
}
inline for (0..4) |i| {
v[d_indices[i]] ^= v[i];
}
inline for (0..4) |i| {
v[d_indices[i]] = rotr(Vec, v[d_indices[i]], 8);
}
inline for (0..4) |i| {
v[c_indices[i]] +%= v[d_indices[i]];
}
inline for (0..4) |i| {
v[b_indices[i]] ^= v[c_indices[i]];
}
inline for (0..4) |i| {
v[b_indices[i]] = rotr(Vec, v[b_indices[i]], 7);
}
}