Table 1 Proposed algorithm for n×n S-boxes construction.

From: Multiple color images security by SPN over the residue classes of Gaussian integer \(\:Z{\left[i\right]}_{h}\)

Input: Integer p (prime), Gaussian integers a, b, c, d Z_p[i], n (size of S-box)

Output: Two n×n S-boxes, S_1 and S_2

Step 1: Construct cyclic group G of order p-1 over Gaussian integers (GI)

1.1 Initialize an empty list G

1.2 For each integer x in range [1, p-1]:

1.3 If x is a valid element over GI, add x to G

Step 2: Apply the mapping f on group G

2.1 For each x_i in G:

2.2 Calculate f(x_i) = 1 / (a * x_i^(-1) + b)

2.3 Ensure that ax_i + b ≠ 0

Step 3: Separate the real and imaginary parts of f(x_i)

3.1 Initialize two empty sets: Re_part and Im_part

3.2 For each f(x_i):

3.3 Extract the real part and add it to Re_part

3.4 Extract the imaginary part and add it to Im_part

Step 4: Apply modulo 2^n over the real and imaginary parts

4.1 For each element in Re_part:

4.2 Apply modulo 2^n and update Re_part

4.3 For each element in Im_part:

4.4 Apply modulo 2^n and update Im_part

Step 5: Apply affine mapping g(x_j) = (c * x_j + d) mod 2^n on Re_part and Im_part

5.1 For each x_j in Re_part:

5.2 Calculate g(x_j) = (c * x_j + d) mod 2^n and update Re_part

5.3 For each x_j in Im_part:

5.4 Calculate g(x_j) = (c * x_j + d) mod 2^n and update Im_part

Step 6: Generate the final pair of S-boxes

6.1 Let S_1 = Re_part and S_2 = Im_part

6.2 Return S_1 and S_2

End