Usage of named constants

In the function prepare_preimage in circuits/src/keccak/multivar.rs, there are some places in which literal constants are used instead of defined named constants that are intended for the respective use case. For best practice, we would recommend to use the named constants in those cases.

Some examples are present in the following snippet,

let mut preimage = Vec::with_capacity(
    self.fixed_input.len() + var_preimage_len / 3 * 32,
);
preimage.extend_from_slice(&self.fixed_input);
let var_bytes = multi_coordinates_to_bytes(ctx, range, &preimage_var);
assert_eq!(var_bytes.len(), var_preimage_len / 3 * 32);
preimage.extend_from_slice(&var_bytes);

where it would be more consistent to use NUM_LIMBS instead of 3 (as is done elsewhere in the file).

Similarly for

let three = ctx.load_constant(F::from(3u64));

where NUM_LIMBS could also be used.

Finally, in the following snippet, one could use NUM_BYTES_FQ, which is also used elsewhere, instead of 32u64.

let thirty_two = ctx.load_constant(F::from(32u64));
Zellic © 2025Back to top ↑