Previous Article in Journal
Bell–Clauser–Horne–Shimony–Holt Behavior Under Quantum Loss and Decoherence
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Affine Cipher Encryption Technique Using Residue Number System

1
Department of Cyber Security, West Ukrainian National University, 46009 Ternopil, Ukraine
2
Department of Computer Science and Automatics, University of Bielsko-Biala, 43-309 Bielsko-Biala, Poland
3
Department of Computer Science, West Ukrainian National University, 46009 Ternopil, Ukraine
4
Aston Business School, Aston University, Birmingham B4 7ET, UK
5
Department of Foreign Languages, Information and Communication Technologies, West Ukrainian National University, 46009 Ternopil, Ukraine
*
Author to whom correspondence should be addressed.
Cryptography 2025, 9(2), 26; https://doi.org/10.3390/cryptography9020026
Submission received: 11 March 2025 / Revised: 17 April 2025 / Accepted: 22 April 2025 / Published: 24 April 2025

Abstract

:
This paper presents a new encryption technique, which combines affine ciphers and the residue number system. This makes it possible to eliminate the shortcomings and vulnerabilities of affine ciphers, which are sensitive to cryptanalysis, using the advantages of the residue number system, i.e., the parallelization of calculation processes, performing operations on low bit numbers, and the linear combination of encrypted residues. A mathematical apparatus and a graphic scheme of affine encryption using the residue number system is developed, and a corresponding example is given. Special cases of affine ciphers such as shift and linear ciphers are considered. The cryptographic strength of the proposed cryptosystem when the moduli are prime numbers is estimated, and an example of its estimation is given. The number of bits and the number of moduli of the residue number system, which ensure the same cryptographic strength as the longest key of the AES algorithm, are determined.

1. Introduction

The protection of information that is constantly transmitted and electronically stored is a critical issue in modern society [1,2,3,4,5], and cryptographic methods [6,7,8,9] are one of the key components of data security that ensure the confidentiality, integrity, and authenticity of data, which is especially important in the age of digital technologies. Given the ever-increasing number of cyber threats [10,11,12,13], cryptographic protection plays a crucial role in ensuring privacy and security in the digital environment. Encryption methods are used to prevent data leakage and ensure reliable functioning of modern information systems [14,15,16]. However, with increasing key lengths, especially in asymmetric cryptosystems, certain problems arise when encrypting short messages.
Affine ciphers are among the simplest symmetric ciphers. They are easy to implement and require low computational resources, which makes them suitable for use in resource-constrained environments, such as embedded systems, mobile devices, or Internet of Things systems [17,18,19]. Due to their simplicity, they quickly perform encryption and decryption, providing a sufficient level of protection in many everyday applications without requiring a lot of power or memory. However, it is relatively easy to cryptanalyze affine ciphers, which limits their applications.
The combination of affine ciphers and the residue number system (RNS) [20,21] provides an additional level of protection by dividing the numeric notation of characters into several independent components. This complicates cryptanalysis, as the attacker needs to take into account the number of moduli and their combinations. This approach increases the cipher resistance to various attacks, including brute force attacks [22,23]. Affine ciphers based on the RNS (ACRNS) can be easily adapted to different sizes of alphabets and coding systems. This makes them flexible for a variety of applications, ranging from textual data to specialized data formats [24]. Scalability is ensured by selecting appropriate moduli [25], which allows one to control the level of security [26].

1.1. Contribution

The main contribution of this paper is as follows:
(1)
A new efficient technique for the encryption of information flows based on a combination of affine ciphers and the RNS is developed, and its scheme and mathematical justification are proposed;
(2)
An example of affine encryption using RNS is given, in which the calculation of the basic parameters of the RNS, key generation, as well as the encryption and decryption features are considered;
(3)
It is determined that the cryptographic strength of the proposed system depends on the number of moduli and their bit size;
(4)
The parameters of the cryptographic system, which has the same resistance to cryptanalysis as the AES-256 symmetric encryption standard, are defined.

1.2. Organization

The rest of this paper is organized as follows: Section 2 presents an analysis of the related work. The theoretical foundations of affine ciphers and the RNS are given in Section 3. Based on the use of affine ciphers and the RNS, a new technique for encrypting information flows is developed. Section 4 presents an example of the cryptographic transformation of integer data using the developed technique. Section 5 provides an estimation of the cryptographic strength of the proposed technique and a comparison with the AES-256 symmetric encryption standard. Section 6 summarizes the contents of the paper and outlines the prospects for further research.

2. Related Work

ACRNSs can provide a significant level of information protection due to their simplicity, efficiency, and security, which the RNS ensures. Although they are not the most resistant to all possible attacks, their use can be justified in practice, especially when speed and simplicity of implementation are required [27]. They also serve as a good basis for the further study and development of more complex cryptographic systems.
For example, in [28], to increase the security level of databases, it was suggested to use an affine cipher after the Caesar cipher. The encrypted text is stored as raw data in a text file that is separated between fields. In [29], using the State Transition Diagram technique, a cryptographic password prototype was built and implemented using modified affine transformations.
One of the ways to increase the cryptographic strength of affine ciphers is to use additional keys. In particular, the algorithm proposed in [30] combines the advantages of affine and stream ciphers, which makes it possible to reduce the number of operations that are required for modern modifications of affine ciphers. The new cipher also increases the degree randomization for the affine cipher by adding an additional key and can be used in online data transmission. In [31], a method was developed in which the first random number is used to generate the key stream of unique values of an affine cipher. This makes it possible to dynamically change the encryption process. The simulation results showed that, on the basis of the proposed method, a more randomized encrypted text is created, in contrast to the traditional affine cipher. In [32], an affine cipher with the Diffie–Hellman key exchange was successfully implemented on an Arduino ATmega2560 device. It can be applied on IoT devices, given their limited computing resources. In the avalanche test, the algorithm showed a high security level.
Affine ciphers are also used to protect graphic resources. For example, in [33], a new algorithm for encrypting color images was presented using a related configuration of a two-dimensional Henon map, a three-dimensional logistic map with XOR operation, and an affine Hill cipher (AHC) technique. The proposed scheme introduces a modified procedure for generating the initial key values of the three-dimensional logistic map, which significantly increases the security of the system. The obtained results and comparative analysis with the existing methods prove the safety, efficiency, and effectiveness of the proposed method. In addition, the correct location of the keys in the AHC technique at the decryption stage, the key space, and their sensitivity counteract various types of cryptanalytic attacks, increasing the overall security of the system.
An algorithm for image encryption based on an affine cipher was presented in [34]. The algorithm first encrypts the pixel positions using a Lorenz chaotic sequence; then, an affine cipher is used to scatter and scramble the pixel values. The theoretical analysis and experimental results showed that the algorithm has keys with high sensitivity, better encryption security, and high diffusion and confusion values. In [35], the concept of the theory of affine groups was applied to protect digital images using the DES algorithm and wavelet transform. Matrix multiplication and vector addition operations were used. As a result, the image that was transformed using the affine transformation was saved without changing its dimensions.
Increasing the reliability of affine ciphers can be achieved by combining them with other cryptographic algorithms. Thus, in [36], the affine cryptography technique was first used, and then, a transposition cipher was applied to the received text. This complicates the cryptanalysis of ciphertext due to the use of keys of different types. At the same time, in general, plaintext and encrypted text differ in the number of characters. In [37], the authors combined the Rabin asymmetric cryptographic algorithm and a symmetric affine cipher. As a result, a hybrid scheme was obtained, in which the affine transformation was used to encrypt messages, and the Rabin cryptosystem was used to encrypt and decrypt the key. It was shown that *.pdf files could be recovered without the loss of integrity.
In [38], an affine cipher using asymmetric keys generated from rectangular matrices was introduced. This made it possible to increase the cryptographic strength of the proposed encryption algorithm. An asymmetric cryptosystem using an affine Hill cipher was developed in [39]. The proposed method increases the security of the system, as it involves the use of two or more digital signatures when modulating a prime number. In [40], it was shown that the modification of the original message using a linear congruent generator could increase the level of security by increasing the number of messages and adding random numerical values to the plaintext. In [41], a cryptographic algorithm was proposed, combining an affine cipher with the Blum Blum Shub pseudorandom number generation algorithm. This made it possible to generate a random stream of keys, the use of which increases the unpredictability of the encrypted text and, accordingly, increases the cryptographic strength of the proposed algorithm.
Therefore, the combination of affine ciphers and the RNS allows us to use the advantages of the latter, in particular the parallelization of the calculation process, the possibility of performing arithmetic operations on lower bit operands, and the absence of inter-bit carriers. The proposed cryptosystem shows high cryptographic strength due to the linear combination of encrypted residues.

3. Materials and Methods

Section 3.1 and Section 3.2, respectively, highlight the theoretical foundations of affine ciphers and the RNS. In Section 3.3, a new encryption technique based on a combination of affine ciphers and the RNS is developed, and the use of the developed technique in some special cases is discussed in Section 3.4.

3.1. Analysis of Affine Ciphers

An affine cipher is a special case of the more general monoalphabetic substitution cipher, and it has all the vulnerabilities of this type of ciphers. In particular, it is easily subjected to frequency cryptanalysis; that is, its cryptographic properties are weak. In an affine cipher, each character of the plaintext is mapped to a numeric equivalent of the letter in the English alphabet, not taking into account uppercase and lowercase characters. The correspondence between letters and numbers can be made as shown, for example, in Table 1.
Table 1 can be expanded to include not only textual information but also any other kind of information such as video, audio, graphic, etc. In addition, standard encoding schemes such as ASCCI code or Unicode can be used.
Then, based on the properties of modular arithmetic, for each number that corresponds to a plaintext character, a new number is calculated that replaces the previous one. Thus, the ciphertext is generated. At the same time, each letter is encrypted on the basis of the linear function and can be shown as follows:
X = (ax + s) mod n,
where x and X are letter numbers of the plaintext and encrypted text, respectively; pair a and s are cipher keys, for which the following conditions must be met: 1 ≤ an − 1, and GCD (a, n) = 1, 0 ≤ sn − 1.
The following conversion is used for decryption:
x = (AX + S) mod n,
where A = a−1 mod n is the inverse of number a relatively prime modulo n; S = (−As) mod n.
The number of possible keys for an affine cipher can be written using Euler’s function as follows: ϕ(n) = −1 (in the case when a = 1, s = 0 is not taken into account).
If a = 1, the Caesar cipher is obtained, and the encryption and decryption functions are reduced to a simple linear shift:
X = (x + s) mod n, x = (X + S) mod n,
where S = (−s) mod n = ns.
The number of keys in this case is n − 1 (the case when s = 0 is not taken into account).
If a ≠ 1 and s = 0, then only the multiplication operation is performed for encryption and decryption:
X = (ax) mod n, x = (AX) mod n,
The number of keys will be ϕ(n) − 1.

3.2. Theoretical Foundations of the Residue Number System

Any number N, given in the decimal number system, can be written in the RNS as a set of residues bi from its division by certain selected numbers pi, which are called moduli [42,43,44]:
bi = N mod pi.
At the same time, two conditions must be met:
(1)
All moduli are relatively prime;
(2)
The selected number N is less than the product of all moduli:  N < P = i = 1 k p i , where k is a number of moduli.
To recover the decimal notation of a number from its residues, the Chinese Remainder Theorem (CRT) can be used [45,46]:
N = i = 1 k M i m i b i mod P ,
where  M i = P p i = p 1 p 2 p i 1 p i + 1 p k  is the product of all moduli, except for pi m i = M i 1 mod p i = M i mod p i 1 mod p i  represent the corresponding modular inverses.
Another method for decimal number recovery from its residues is to use Garner’s algorithm, according to which N can be uniquely noted as follows:
N = N 0 + N 1 p 1 + N 2 p 1 p 2 + + N k 1 p 1 p 2 p k 1 ,
where 0 ≤ Ni < pi+1, i = 0, 1, …, k − 1; Ni parameters can be successively calculated one by one using the recurrence relation:
N i = p 1 p 2 p i 1 mod p i + 1 b i + 1 N 0 + N 1 p 1 + + N i 1 p 1 p 2 p i 1 mod p i + 1 ,
These and other methods of recovering a decimal number from its residues (such as adding the product of moduli or residues from the product of moduli) [47] are rather cumbersome and are characterized by high time requirements. It can be reduced using the modified perfect form (MPF) of the RNS [48], in which the moduli are selected in such a way that the following conditions are met for any of them:
m i = M i 1 mod p i = M i mod p i 1 mod p i = ± 1 ,
Calculations are carried out according to the CRT based on Formula (6), in which the sum becomes sign-changing and each term consists of two, not three, factors. In addition, it is not necessary to find the multiplicative modular inverse.

3.3. Affine Ciphers in the Residue Number System

The difference between a simple affine cipher and a combination of an affine cipher and the RNS is that when using a simple affine cipher, each letter is separately encrypted, and a combination of an affine cipher and the RNS makes it possible to convert a block of plaintext N, which must be smaller than the product of the selected moduli P.
Then, residues bi are found by Formula (5) and subjected to cryptographic transformation:
Bi = (aibi + si) mod pi.
Similar conditions that must be met for affine ciphers are required for the ai, si, and pi keys: 1 ≤ aipi − 1, and GCD (ai, pi) = 1, 0 ≤ sipi − 1.
If ai = 1 (shift cipher) or si = 0, the formulas for encryption are as follows:
Bi = (bi + si) mod pi;
Bi = (aibi) mod pi.
The concatenation of the changed residues Bi can be a ciphertext. However, in order to increase the resistance of the latter to cryptanalysis, it is expedient to recover the decimal number K with residues Bi:
K = i = 1 k M i m i B i mod P .
Message K is the final ciphertext.
To decipher it, it is first necessary to find the changed residues from the following expressions:
Bi = (aibi + si) mod pi.
The calculation of real residues is performed according to formulas that are similar to (2):
bi = (AiBi + Si) mod pi,
where Ai = ai−1 mod pi represent the inverses of ai by relatively prime moduli pi; correspondingly, Si = (−Aisi) mod pi.
Figure 1 shows the scheme of the proposed affine encryption technique using the RNS.
The number of possible keys in this case increases significantly compared to the classical affine cipher. Its value can be estimated as  i = 1 k ϕ p i p i 1  (the possibility when ai = 1 and si = 0 is not considered). If we assume that all moduli are prime numbers, the number of keys can be estimated from the expression  i = 1 k p i 1 p i 1 .
The encryption and decryption process is described in the following (see Algorithms 1 and 2, respectively).
Algorithm 1: The ACRNS encryption algorithm
  Input:
  N—number to be encrypted
  pi—list of pairwise coprime moduli [p1, p2, …, pk]
  ai, si—encryption keys, where 0 < ai < pi, 0 ≤ si < pi, GCD(ai, pi) = 1
  Output:
  K—encrypted number
   function Encrypt(N, pi, ai, si):
  // Compute remainders of N modulo each modulus
  for x from 0 to k − 1:
    r = N mod pi[x]
    b.append(r)
  // Encrypt each remainder using the affine cipher:
  //  B[x] = (ai[x] × b[x] + si[x]) mod pi[x]
  for x from 0 to k − 1:
    encrypted = (ai[x] × b[x] + si[x]) mod pi[x]
    B.append(encrypted)
  // Compute modular inverse using Extended Euclidean Algorithm
  function modular_inverse(a, m):
      t, newt = 0, 1
      r, newr = m, a
    while newr ≠ 0:
      quotient = r // newr
      t, newt = newt, t − quotient × newt
      r, newr = newr, r − quotient × newr
      if r > 1:
      error “Inverse does not exist”
      if t < 0:
      t = t + m
      return t
  // CRT to reconstruct the encrypted number
   function CRT(residues, moduli):
      P = 1
      for p in moduli:
       P = P × p
      result = 0
      for i from 0 to length(moduli) − 1:
       pi = moduli[i]
       ri = residues[i]
       mi = P/pi
       mi_inv = modular_inverse(mi, pi)
       result = result + ri × mi × mi_inv
      return result mod P
  // 5. Build encrypted number K from wrong remainders
  K = CRT(B, pi)
  return K
Algorithm 2: The ACRNS decryption algorithm
Input:
K—the encrypted number
pi—list of moduli [p1, p2, …, pk]
ai, si—encryption keys, where 0 < ai < pi, 0 ≤ si < pi, GCD(ai, pi) = 1
Output:
N — decoded number
function Decrypt(K, pi, ai, si):
  k = length(pi)
  B = [] // encrypted remainders extracted from K
   // Extract encrypted remainders by taking K mod each pi
  for x from 0 to k − 1:
    r = K mod pi[x]
    B.append(r)
  // Recover original remainders using inverse affine transformation
  b = [] # decrypted (correct) remainders
  for x from 0 to k − 1:
    ai_inv = modular_inverse(ai[x], pi[x])
    b_x = (ai_inv × (B[x] − si[x])) mod pi[x]
    b.append(b_x)
   // Modular inverse function
  function modular_inverse(a, m):
    t, newt = 0, 1
    r, newr = m, a
     while newr ≠ 0:
        quotient = r // newr
        t, newt = newt, t − quotient × newt
        r, newr = newr, r − quotient × newr
     if r > 1:
      error “Inverse does not exist”
     if t < 0:
      t = t + m
     return t
  // Use CRT to recover the original number from correct remainders
  function CRT(residues, moduli):
    P = 1
    for p in moduli:
      P = P × p
    result = 0
    for i from 0 to length(moduli) − 1:
      pi = moduli[i]
      ri = residues[i]
      mi = P/pi
      mi_inv = modular_inverse(mi, pi)
      result = result + ri × mi × mi_inv
    return result mod P
  // Recover the original number N
  N = CRT(b, pi)
  return N
If the plaintext message N exceeds the product of moduli P, then it, similarly to block ciphers, is divided into numerical blocks that are smaller than P, which can be encrypted according to the corresponding modes. Another method is to increase the number of moduli or their bit size and, accordingly, the number P.

3.4. Special Cases of Affine Ciphers

If ai = 1 (shift cipher) or si = 0, the formulas for calculating the real residues are simplified:
bi = (Bi + Si) mod pi;
bi = (AiBi) mod pi,
where Ai = ai−1 mod pi; Si = (−si) mod pi = (pi si) mod pi.
The number of possible variants of the keys will be, respectively,  i = 1 k p i 1  and  i = 1 k ϕ p i 1  (or  i = 1 k p i 1 1  if the moduli pi are prime numbers.
For example, a plaintext message can be recovered on the basis of the RNS according to Formula (6).

4. Results

Section 4.1 shows an example of affine encryption of integers in general using the residue number system, and in Section 4.2, the applications of some special cases are given.

4.1. An Example of Affine Ciphers Using the Residue Number System

Let us consider the system of moduli p1 = 9; p2 = 10; p3 = 11; and p4 = 17. Their product (range of calculations) P = 16,830. Next, the basic parameters of this system are calculated: M1 = 10⋅11⋅17 = 1870; M2 = 9⋅11⋅17 = 1683; M3 = 9⋅10⋅17 = 1530; M4 = 9⋅10⋅11 = 990; 1870 mod 9 = 7; 1683 mod 10 = 3; 1530 mod 11 = 1; and 990 mod 17 = 4. Since the selected moduli are relatively small, it is expedient to determine the modular inverses of the found numbers in the following way: add 1 to the modulus and check whether the found sum is evenly divisible by the corresponding number. If so, then the quotient is the inverse; if not, then the modulus is added until the quotient is an integer. Therefore, 1 + 9 = 10; 10 + 9 = 19; and 19 + 9 = 28; then, m1 = 28:7 = 4; 1 + 10 = 11; 11 + 10 = 21; m2 = 21:7 = 3; m3 = 1; 1 + 17 = 18; 18 + 17 = 35; 35 + 17 = 52; and m4 = 52:4 = 13.
The obtained results are given in Table 2.
Let us assume that the message “bot” needs to be encrypted in this system of the selected moduli: 9, 10, 11, and 17. According to Table 1, this message in a number format is as follows: 011419. The input data (plaintext N = 11,419), selected keys for encryption, and results obtained from expressions (5), (10), and (13) are shown in Table 3.
It should be noted that the ciphertext can be both the concatenation of the true bi or the changed residues of Bi (07090112 and 05030904, respectively) and the number K = (1870⋅4⋅5 + 1683⋅7⋅3 + 1530⋅1⋅9 + 990⋅13⋅4) mod 16,830 = 3353, recovered from the changed residues using the CRT (Formula (13)).
Ai’s parameters, which are one part of the decryption key and are defined as modular inverses, are easy to find by adding the modulus: 1 + 9 = 10; 10 + 9 = 19; and 19 + 9 = 28; then, A1 = 28:4 = 7; 1 + 10 = 11; 11 + 10 = 21; A2 = 21:3 = 7; 1 + 11 = 12; A3 = 12:4 = 3; 1 + 17 = 18; 18 + 17 = 35; 35 + 17 = 52; 52 + 17 = 69; 69 + 17 = 88; and A4 = 88:8 = 11. The rest of the decryption keys (Bi parameters) are determined as follows: S1 = (−7⋅4) mod 9 = 8; S2 = (−7⋅6) mod 10 = 8; S3 = (−3⋅5) mod 11 = 7; and S4 = (−11⋅10) mod 17 = 9. Having obtained the true bi residues, using the CRT and the data in Table 2, the plaintext can be recovered: N = (1870⋅4⋅7 + 1683⋅7⋅9 + 1530⋅1⋅1 + 990⋅13⋅12) mod 16,830 = 11,419. Therefore, the decrypted message corresponds to the original plaintext.
The input parameters, decryption keys, and decryption results are given in Table 4.

4.2. Example of the Use of Special Cases of Affine Ciphers

When si = 0 (ai ≠ 1), using the same input parameters and having found the changed residues, the ciphertext is determined as follows: K = (1870⋅4⋅1 + 1683⋅7⋅7 + 1530⋅1⋅4 + 990⋅13⋅11) mod 16,830 = 2017. During decryption, the true bi residues are found first, from which the plaintext is recovered using the CRT and the data in Table 2. The encryption and decryption results are shown in Table 5.
When ai = 1 (si ≠ 0), using the same input parameters and having found the changed residues, the ciphertext is determined as follows: K = (1870⋅4⋅2 + 1683⋅7⋅5 + 1530⋅1⋅6 + 990⋅13⋅5) mod 16,830 = 12755. During decryption, the true bi residues are found first, from which the plaintext is recovered using the CRT and the data in Table 2. The encryption and decryption results are given in Table 6.
In all these cases, the decrypted text is equal to the input plaintext.

5. Discussion of the Results

Section 5.1 is devoted to the study of the cryptographic strength of the ACRNS. Section 5.2 provides a comparison of the cryptographic strength of the proposed technique and the AES-256 symmetric encryption standard.

5.1. Cryptographic Strength of Affine Ciphers Using the Residue Number System

The cryptographic strength of ACRNSs is their ability to resist cryptanalysis, which refers to the product of the time complexity of one key variant, which is estimated using Big-Oh notation, multiplying by a number of key variants.
To approximately estimate the cryptographic strength of the ACRNS, let us assume that the moduli are prime numbers, the bit size of which is in the range from (nt) to n. According to the prime number theorem describing the asymptotic distribution of prime numbers, their number in this range can be approximated as follows:  π n = 2 n n ln 2 2 n t n t ln 2 . Then, k moduli can be selected in the following number of ways:  C π n k = π n ! k ! π n k ! = i = 0 k 1 π n i k ! . For the convenience of estimating the number of ways to select moduli, the last expression can be approximated as follows:  2 π n k + 1 k k .
For an approximate estimation of the number of key variants ai and si, which is  i = 1 k p i 1 p i 1 i = 1 k p i 2 , it can be assumed that their average length will not be less than  n t 2 . Thus, the total number of variants can be approximated as  2 k n t . In addition, the time complexity of affine transformations and the RNS for k moduli can be approximated as n2k.
Therefore, the overall cryptographic strength of the proposed system will be equal to the product of these three estimated parameters:
O ( n , k , t ) 2 k n t n 2 k k k 2 n n ln 2 2 n t n t ln 2 k + 1 k .
For example, Table 7 shows the values of the decimal logarithm (or orders) of the cryptographic strength with different values of the t, k, and n parameters.
According to Table 7, it can be stated that with an increase in the number of moduli and their bit size, the strength of the cryptosystem increases, and with an increase in the t parameter, it decreases.
Figure 2 shows a logarithmic scale of graphical dependence of the cryptographic strength on the bit size of moduli n and their number k when t = 3. It can be seen that with an increase in the specified parameters, the complexity of the cryptanalysis significantly increases.
Figure 3 shows a logarithmic scale of the graphical dependence of the cryptographic strength of the ACRNS on the bit size of moduli when their number differs and t = 10.
The presented graphs are linear. It can be seen that the resistance to cryptanalysis increases with an increase in the bit size of the moduli.

5.2. Comparison of the Cryptographic Strength of an Affine Cipher Using the Residue Number System with the AES Cryptographic Algorithm

According to [49,50], it is known that 2n−1 bit operations are required for cryptanalysis of the modern symmetric AES cryptographic algorithm with an n-bit key (the maximum key length of the AES algorithm is 256 bits). Then, due to the equality O(n, k, t) = 2255, the number of RNS moduli and their bit sizes can be determined, which ensures that the cryptographic strength that is no less than that ensured by the longest key of the AES algorithm (Table 8).
The presented table shows that as the number of moduli increases, their bit size decreases, and this dependence is non-linear.

6. Prospects and Directions for Further Research

Due to their structural simplicity, affine ciphers provide a high speed when performing encryption/decryption operations. Therefore, despite their limited cryptographic strength, their use appears promising for solving a wide range of applied problems that require low computing resources, in particular, in mobile devices, various embedded systems, and Internet of Things technologies. The combination of affine ciphers with a non-positional RNS will allow us to increase the cryptographic strength of encryption without a significant loss of performance. This can be achieved due to the properties of the RNS, that is, parallelization of the computation process and execution of arithmetic operations on relatively small operands. Therefore, the use of the ACRNS is especially promising in systems where time is a critical parameter.
The software and hardware–software implementation of the proposed ACRNS is considered a promising direction for further research. This will allow for comparing experimental results, in particular the strength and performance of this cipher and known standards of symmetric and asymmetric encryption. In addition, research can be carried out using a different number of moduli and their bit size, due to which it is possible to achieve an acceptable level of resistance to cryptanalysis and the speed of the algorithm.
An extremely important and promising direction for further research in this field is the development of a matrix ACRNS, as well as the use of a perfect and modified form of the RNS, which significantly simplifies the process of converting a number into a decimal notation from its residues.

7. Conclusions

In this paper, a new encryption technique is developed, which consists of combining affine ciphers and a non-positional RNS. This approach makes it possible to eliminate the shortcomings of affine ciphers, which are sensitive to cryptanalysis, due to the advantages of the residue number system, in particular the parallelization of calculation processes, the performance of operations on low bit numbers, and linear combinations of real and encrypted residues. Mathematical support is developed, and a graphical scheme for affine encryption using the RNS and an implementation example are given. Special cases of affine ciphers, including a shift cipher and a linear cipher, are considered. The cryptographic strength of the proposed encryption algorithm is estimated. When prime numbers of a given bit size are selected as moduli, its graphical dependence and a corresponding example are shown. The bit sizes and the number of RNS moduli that ensure the same cryptographic strength as the longest key of the AES algorithm are determined.

Author Contributions

Conceptualization, M.K. and R.S.; methodology, M.K. and M.H.; validation, I.S., R.S., B.A., V.B. and M.K.; formal analysis, M.H., V.B. and I.S.; investigation, R.S., B.A., M.H. and M.K.; resources, I.S.; data duration, R.S.; writing—original draft preparation, M.K., M.H. and I.S.; writing—review and editing, M.H. and R.S.; supervision, M.K.; funding acquisition, R.S. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The data presented in this study are available on request from the corresponding author.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Nieles, M.; Dempsey, K.; Pillitteri, V.Y. An Introduction to Information Security; National Institute of Standards and Technology: Gaithersburg, MD, USA, 2017. [Google Scholar]
  2. Shirazi, S.-R.; Shah, S.A.; Anwar, A. Information Security. In Proceedings of the 27th International Conference, Arlington, VA, USA, 23–25 October 2024. [Google Scholar]
  3. Andrzejewski, K. Security Information Management Systems. Nauki Zarz. 2020, 24, 1–9. [Google Scholar] [CrossRef]
  4. Andrijchuk, V.A.; Kuritnyk, I.P.; Kasyanchuk, M.M.; Karpinski, M.P. Modern Algorithms and Methods of the Person Biometric Identification. In Proceedings of the 2005 IEEE Intelligent Data Acquisition and Advanced Computing Systems: Technology and Applications, Sofia, Bulgaria, 5–7 September 2005; pp. 403–406. [Google Scholar]
  5. Laybats, C.; Tredinnick, L. Information Security. Bus. Inf. Rev. 2016, 33, 76–80. [Google Scholar] [CrossRef]
  6. Hoffstein, J.; Pipher, J.; Silverman, J. An Introduction to Mathematical Cryptography; Springer New York: New York, NY, USA, 2008; ISBN 9780387779935. [Google Scholar]
  7. Jeffrey, H.; Jill, P.; Joseph, H. An Introduction to Cryptography; Springer: New York, NY, USA, 2008. [Google Scholar]
  8. Adki, V.; Hatkar, S. A Survey on Cryptography Techniques. Int. J. Adv. Res. Comput. Sci. Softw. Eng. 2015, 6, 469–475. [Google Scholar]
  9. Washington, L.C. Elliptic Curves; Chapman and Hall/CRC: London, UK, 2008; ISBN 9780429140808. [Google Scholar]
  10. Fadziso, T.; Thaduri, U.R.; Dekkati, S.; Ballamudi, V.-R.; Desamsetti, H. Evolution of the Cyber Security Threat: An Overview of the Scale of Cyber Threat. Digit. Sustain. Rev. 2023, 3, 1–12. [Google Scholar]
  11. Asaad, R.R.; Saeed, V.A. A Cyber Security Threats, Vulnerability, Challenges and Proposed Solution. Appl. Comput. J. 2022, 2, 227–244. [Google Scholar] [CrossRef]
  12. Wang, Z.; Adeyemo, D.; Akinsoto, A. Summary of Cyber Threat Intelligence. Int. J. Innov. Res. Multidiscip. Field 2022, 8, 32–42. [Google Scholar]
  13. Humayun, M.; Niazi, M.; Jhanjhi, N.Z.; Alshayeb, M.; Mahmood, S. Cyber Security Threats and Vulnerabilities: A Systematic Mapping Study. Arab. J. Sci. Eng. 2020, 45, 3171–3189. [Google Scholar] [CrossRef]
  14. Tarawneh, M. Perspective Chapter: Cryptography—Recent Advances and Research Perspectives. Biometrics and Cryptography; IntechOpen: London, UK, 2024; ISBN 9781837682621. [Google Scholar]
  15. Kumar, D.V.; Raheja, E.G.; Sareen, M.S. CRYPTOGRAPHY. Int. J. Comput. Technol. 2013, 4, 29–32. [Google Scholar] [CrossRef]
  16. Onwutalobi, A.-C. Overview of Cryptography. SSRN Electron. J. 2011, 1, 1–10. [Google Scholar] [CrossRef]
  17. Om, H.; Patwa, R. Affine Transformation in Cryptography. J. Discret. Math. Sci. Cryptogr. 2008, 11, 59–65. [Google Scholar] [CrossRef]
  18. Dhaief, Z.S. Encryption of Data Based on Triple Encryption and Affine Algorithm. Int. J. Adv. Sci. Res. Eng. 2021, 7, 25–34. [Google Scholar] [CrossRef]
  19. Rachmawati, D.; Budiman, M.A. New Approach toward Data Hiding by Using Affine Cipher and Least Significant Bit Algorithm. In Proceedings of the 2017 4th International Conference on Computer Applications and Information Processing Technology (CAIPT), Kuta Bali, Indonesia, 8–10 August 2017; pp. 1–6. [Google Scholar]
  20. Omondi, A.R.; Benjamin Premkumar, A. Residue Number Systems: Theory and Implementation; World Scientific: Singapore, 2007; ISBN 9781908979117. [Google Scholar]
  21. Mohan, P.-A. Residue Number Systems; Springer International Publishing: Cham, Switzerland, 2016; ISBN 9783319413839. [Google Scholar]
  22. Mezaal, Y.S.; Abdulkareem, S.F. Affine Cipher Cryptanalysis Using Genetic Algorithms. JP J. Algebra Number Theory Appl. 2017, 39, 785–802. [Google Scholar] [CrossRef]
  23. Mathews, M.M.; Panchami, V.; Ajith, V. Quantum Cryptanalysis of Affine Cipher. Res. Sq. 2022, 14, 507–519. [Google Scholar] [CrossRef]
  24. Lalitha, K.V.; Sailaja, V. High Performance Adder Using Residue Number System. J. Mater. Chem. A Mater. Energy Sustain. 2014, 5, 1323–1332. [Google Scholar]
  25. Nykolaychuk, Y.M.; Kasianchuk, M.M.; Yakymenko, I.Z. Theoretical Foundations for the Analytical Computation of Coefficients of Basic Numbers of Krestenson’s Transformation. Cybern. Syst. Anal. 2014, 50, 649–654. [Google Scholar] [CrossRef]
  26. Kasianchuk, M.M.; Yakymenko, I.Z.; Nykolaychuk, Y.M. Symmetric Cryptoalgorithms in the Residue Number System. Cybern. Syst. Anal. 2021, 57, 329–336. [Google Scholar] [CrossRef]
  27. Kazemi, M.; Naraghi, H.; Golshan, H.M. On the Affine Ciphers in Cryptography. Communications in Computer and Information Science; Springer Berlin Heidelberg: Berlin, Germany, 2011; pp. 185–199. ISBN 9783642253263. [Google Scholar]
  28. Hammood, D.A.; Maitham, A. Implementation and Enhancement Affine Cipher of Database. J. Eng. Sustain. Dev. 2016, 20, 264–276. [Google Scholar]
  29. Babu, S.A. Modification Affine Ciphers Algorithm for Cryptography Password. Int. J. Res. Sci. Eng. 2017, 3, 346–351. [Google Scholar]
  30. Al-Nuaimy, L. Internal Affine Stream Cipher. J. Appl. Eng. Technol. Sci. (JAETS) 2014, 1, 1–5. [Google Scholar]
  31. Carlo, J. A Keystream-Based Affine Cipher for Dynamic Encryption. Int. J. Emerg. Trends Eng. Res. 2020, 8, 2919–2922. [Google Scholar] [CrossRef]
  32. Putra, P.; Sari, C.A.; Isinkaye, F.O. Secure Text Encryption for IoT Communication Using Affine Cipher and Diffie-Hellman Key Distribution on Arduino Atmega2560 IoT Devices. J. Tek. Inform. (JUTIF) 2023, 4, 849–855. [Google Scholar] [CrossRef]
  33. Lone, M.A.; Qureshi, S. Encryption Scheme for RGB Images Using Chaos and Affine Hill Cipher Technique. Nonlinear Dyn. 2023, 111, 5919–5939. [Google Scholar] [CrossRef]
  34. Ke, Q.; Liao, Q.-N.; Li, A.-Q.; Gao, R. Digital Image Encryption Algorithm Based on Affine Cipher. In Advances in Intelligent Systems and Computing; Springer International Publishing: Cham, Switzerland, 2019; pp. 578–585. ISBN 9783319987750. [Google Scholar]
  35. Soekarta, R.; Sigit, M. Implementation of Affine Group Algebra on Digital Image Security. Mob. Forensics 2023, 4, 137–146. [Google Scholar] [CrossRef]
  36. Alhassan, M.J.; Hassan, A.; Sani, S.; Alhassan, Y. A Combine Technique of an Affine Cipher and Transposition Cipher. J. Res. Appl. Math. 2021, 7, 8–12. [Google Scholar]
  37. Budiman, M.A.; Handrizal; Azzahra, S. An Implementation of Rabin-p Cryptosystem and Affine Cipher in a Hybrid Scheme to Secure Text. J. Phys. Conf. Ser. 2021, 1898, 012042. [Google Scholar] [CrossRef]
  38. Maxrizal, M.; Aniska Prayanti, B.D. Application of Rectangular Matrices: Affine Cipher Using Asymmetric Keys. CAUCHY 2019, 5, 181–185. [Google Scholar] [CrossRef]
  39. Sundarayya, P.; Vara Prasad, G. A Public Key Cryptosystem Using Affine Hill Cipher under Modulation of Prime Number. J. Inf. Optim. Sci. 2019, 40, 919–930. [Google Scholar] [CrossRef]
  40. Arroyo, J.-T. An Improved Affine Cipher Using Blum Blum Shub Algorithm. Int. J. Adv. Trends Comput. Sci. Eng. 2020, 9, 3295–3298. [Google Scholar] [CrossRef]
  41. Shoup, V. A Computational Introduction to Number Theory and Algebra; Cambridge University Press: Cambridge, UK, 2009; ISBN 9780521516440. [Google Scholar]
  42. Laia, O.; Zamzami, E.M.; Sutarman; Larosa, F.-N.; Gea, A. Application of Linear Congruent Generator in Affine Cipher Algorithm to Produce Dynamic Encryption. J. Phys. Conf. Ser. 2019, 1361, 012001. [Google Scholar] [CrossRef]
  43. Stillwell, J. Elements of Number Theory; Springer New York: New York, NY, USA, 2003; ISBN 9781441930668. [Google Scholar]
  44. Hardy, G.H.; Wright, E.M.; Silverman, J. An Introduction to the Theory of Numbers, 6th ed.; Oxford University Press: London, UK, 2008; ISBN 9780199219865. [Google Scholar]
  45. Srivastava, A.; Mathur, A. The Rabin Cryptosystem & Analysis in Measure of Chinese Reminder Theorem. Int. J. Sci. Res. Publ. 2013, 3, 1–4. [Google Scholar]
  46. Venturi, D. Lecture Notes on Algorithmic Number Theory; Springer: New-York, NY, USA, 2009; 217p, ISSN 1433-8092. [Google Scholar]
  47. Karpinski, M.; Rajba, S.; Zawislak, S.; Warwas, K.; Kasianchuk, M.; Ivasiev, S.; Yakymenko, I. A Method for Decimal Number Recovery from Its Residues Based on the Addition of the Product Modules. In Proceedings of the 2019 10th IEEE International Conference on Intelligent Data Acquisition and Advanced Computing Systems: Technology and Applications (IDAACS), Metz, France, 18–21 September 2019; Volume 5, pp. 13–17. [Google Scholar]
  48. Nykolaychuk, Y.M.; Kasianchuk, M.M.; Yakymenko, I.Z. Theoretical Foundations of the Modified Perfect Form of Residue Number System. Cybern. Syst. Anal. 2016, 52, 219–223. [Google Scholar] [CrossRef]
  49. Bogdanov, A.; Khovratovich, D.; Rechberger, C. Biclique Cryptanalysis of the Full AES. In Lecture Notes in Computer Science; Springer Berlin Heidelberg: Berlin, Germany, 2011; pp. 344–371. ISBN 9783642253843. [Google Scholar]
  50. Tiessen, T. Polytopic Cryptanalysis. Lecture Notes in Computer Science; Springer Berlin Heidelberg: Berlin, Germany, 2016; pp. 214–239. ISBN 9783662498897. [Google Scholar]
Figure 1. Affine encryption scheme using RNS.
Figure 1. Affine encryption scheme using RNS.
Cryptography 09 00026 g001
Figure 2. Graphical dependence of the cryptographic strength of the proposed technique on the bit size of moduli and their number.
Figure 2. Graphical dependence of the cryptographic strength of the proposed technique on the bit size of moduli and their number.
Cryptography 09 00026 g002
Figure 3. Graphical dependence of the cryptographic strength of the ACRNS on the bit size of moduli when their number differs and t = 10.
Figure 3. Graphical dependence of the cryptographic strength of the ACRNS on the bit size of moduli when their number differs and t = 10.
Cryptography 09 00026 g003
Table 1. Correspondence between letters of the English alphabet and numbers.
Table 1. Correspondence between letters of the English alphabet and numbers.
Letterabcdefghijklm
Number00010203040506070809101112
Letternopqrstuvwxyz
Number13141516171819202122232425
Table 2. Basic parameters for the system of selected moduli.
Table 2. Basic parameters for the system of selected moduli.
i1234
pi9101117
Mi187016831530990
Mi mod pi7314
mi47113
Table 5. Input data, encryption keys, and obtained results for si = 0.
Table 5. Input data, encryption keys, and obtained results for si = 0.
i1234
pi9101117
ai4348
N11,419
bi = N mod pi79112
Bi = (aibi) mod pi17411
K = i = 1 k M i m i B i mod P 2017
Ai77315
bi = (AiBi) mod pi79112
N = i = 1 k M i m i b i mod P 11,419
Table 6. Input data, encryption keys, and obtained results for ai = 1.
Table 6. Input data, encryption keys, and obtained results for ai = 1.
i1234
pi9101117
si46510
N11,419
bi = N mod pi79112
Bi = (bi + si) mod pi2565
K12,755
Si5467
bi = (AiBi) mod pi79112
N = i = 1 k M i m i b i mod P 11,419
Table 3. Input data, keys for encryption, and obtained results.
Table 3. Input data, keys for encryption, and obtained results.
i1234
pi9101117
ai4348
si46510
N11,419
bi = N mod pi79112
Bi = (aibi + si) mod pi5394
K = i = 1 k M i m i B i mod P 3353
Table 4. Input data, decryption keys, and decryption results.
Table 4. Input data, decryption keys, and decryption results.
i1234
pi9101117
Ai77315
Si8873
K3353
Bi = K mod pi5394
bi = (AiBi + Si) mod pi79112
N = i = 1 k M i m i b i mod P 11,419
Table 7. The values of the decimal logarithm lg(O(n, k, t)) of cryptographic strength with different values of the t, k, and n parameters.
Table 7. The values of the decimal logarithm lg(O(n, k, t)) of cryptographic strength with different values of the t, k, and n parameters.
tkn
1632641282565121024
1329591182344669301855
65711723446793118583709
1093193388777155030956180
10322521112274599221848
64310222045391718443695
1069169364753152630716156
Table 8. Bit sizes and the number of RNS moduli, which ensure that the cryptographic strength is not less than that ensured by the longest key of the AES cryptographic algorithm when the parameter t has different values.
Table 8. Bit sizes and the number of RNS moduli, which ensure that the cryptographic strength is not less than that ensured by the longest key of the AES cryptographic algorithm when the parameter t has different values.
Number of Moduli23456789101112131415
Bit size when t = 16342322622191716141312111110
Bit size when t = 106646362925232119181716151414
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Kasianchuk, M.; Shevchuk, R.; Adamyk, B.; Benson, V.; Shylinska, I.; Holembiovskyi, M. Affine Cipher Encryption Technique Using Residue Number System. Cryptography 2025, 9, 26. https://doi.org/10.3390/cryptography9020026

AMA Style

Kasianchuk M, Shevchuk R, Adamyk B, Benson V, Shylinska I, Holembiovskyi M. Affine Cipher Encryption Technique Using Residue Number System. Cryptography. 2025; 9(2):26. https://doi.org/10.3390/cryptography9020026

Chicago/Turabian Style

Kasianchuk, Mykhailo, Ruslan Shevchuk, Bogdan Adamyk, Vladlena Benson, Inna Shylinska, and Mykhailo Holembiovskyi. 2025. "Affine Cipher Encryption Technique Using Residue Number System" Cryptography 9, no. 2: 26. https://doi.org/10.3390/cryptography9020026

APA Style

Kasianchuk, M., Shevchuk, R., Adamyk, B., Benson, V., Shylinska, I., & Holembiovskyi, M. (2025). Affine Cipher Encryption Technique Using Residue Number System. Cryptography, 9(2), 26. https://doi.org/10.3390/cryptography9020026

Article Metrics

Back to TopTop