Creates a hint bit to help recover high bits after a small perturbation. Given:
This implements makeHint from FIPS 204. The hint helps recover r1 from r' = r - f without knowing f explicitly.
fn makeHint(z0: u32, r1: u32, comptime gamma2: u32) u32
fn makeHint(z0: u32, r1: u32, comptime gamma2: u32) u32 {
// If -alpha/2 < r0 - f <= alpha/2, then r1*alpha + r0 - f is a valid
// decomposition of r' with the restrictions of decompose() and so r'1 = r1.
// So the hint should be 0. This is covered by the first two inequalities.
// There is one other case: if r0 - f = -alpha/2, then r1*alpha + r0 - f is
// also a valid decomposition if r1 = 0. In the other cases a one is carried
// and the hint should be 1.
const cond1 = @intFromBool(z0 <= gamma2);
const cond2 = @intFromBool(z0 > Q - gamma2);
const eq_gamma2 = @intFromBool(z0 == Q - gamma2);
const r1_is_zero = @intFromBool(r1 == 0);
const cond3 = eq_gamma2 & r1_is_zero;
return 1 - (cond1 | cond2 | cond3);
}