external_terminal_permute_state

Function external_terminal_permute_state 

Source
pub fn external_terminal_permute_state<R: PrimeCharacteristicRing, CT: Copy, MdsPerm4: MdsPermutation<R, 4>, const WIDTH: usize>(
    state: &mut [R; WIDTH],
    terminal_external_constants: &[[CT; WIDTH]],
    add_rc_and_sbox: fn(&mut R, CT),
    mat4: &MdsPerm4,
)
Expand description

Applies the terminal external rounds of the Poseidon2 permutation.

Each external round consists of three steps:

  1. Adding round constants to each element of the state.
  2. Apply the S-box to each element of the state.
  3. Applying an external linear layer (based on a 4x4 MDS matrix).

ยงParameters

  • state: The current state of the permutation (size WIDTH).
  • terminal_external_constants: Per-round constants which are added to each state element.
  • add_rc_and_sbox: A function that adds the round constant and applies the S-box to a given element.
  • mat4: The 4x4 MDS matrix used in the external linear layer.