feature. See also
. The project being documented here (as the example) is the Zig library itself.
argon2.indexAlpha
fn indexAlpha(
rand: u64,
lanes: u32,
segments: u32,
threads: u24,
n: u32,
slice: u32,
lane: u24,
index: u32,
) u32
File
Code
fn indexAlpha(
rand: u64,
lanes: u32,
segments: u32,
threads: u24,
n: u32,
slice: u32,
lane: u24,
index: u32,
) u32 {
var ref_lane = @as(u32, @intCast(rand >> 32)) % threads;
if (n == 0 and slice == 0) {
ref_lane = lane;
}
var m = 3 * segments;
var s = ((slice + 1) % sync_points) * segments;
if (lane == ref_lane) {
m += index;
}
if (n == 0) {
m = slice * segments;
s = 0;
if (slice == 0 or lane == ref_lane) {
m += index;
}
}
if (index == 0 or lane == ref_lane) {
m -= 1;
}
var p = @as(u64, @as(u32, @truncate(rand)));
p = (p * p) >> 32;
p = (p * m) >> 32;
return ref_lane * lanes + @as(u32, @intCast(((s + m - (p + 1)) % lanes)));
}