# SIMECK-T: An Ultra-Lightweight Encryption Scheme for Resource-Constrained Devices
## 2 Methodology
### Implementation
```
1 longintcalculate_bias(uint32_t*plain0,uint32_t*plain1,
2 uint32_t*cipher0,uint32_t*cipher1,longintnum_pairs,
3 intguess_key){
4 longintcount=0;
5 for(uint32_ti=0;i<num_pairs;i++){
6 intp_pos=rand()%32;
7 intc_pos=rand()%32;
8 intk_pos=rand()%8;
9
10 intp_bit=(plain0[i]>>p_pos)&1;
11 intc_bit=(cipher1[i]>>c_pos)&1;
12 intkey_guess_bit=(guess_key>>k_pos)&1;
13
14 if((p_bit^c_bit)==key_guess_bit){
15 count++;
16}
17}
18 returncount-(num_pairs/2);
19}
```
**Listing 1**Bias calculation function for linear approximations of SIMECK-T. The largest experimental linear attack we attempted against the proposed SIMECK-T cipher has \(2^{32}\) pairs, and the source code for the tool is available at [34] and requires 60 GB of free hard disk space. #### 3.2.3 Differential Cryptanalysis

Algorithm 6 shows the corresponding distinguisher used to identify differential trails. For such a distinguisher to be effective, a large number of randomly sampled pairs should be available. ```
Input:An oracle \(\Omega\) implementing an unknown permutation \(U\) on \(\mathbb{B}\), a complexity \(\
u\), a differential \((a,b)\), an acceptance function accept. Output:A decision bit. 1 Initialize \(u\gets 0\);
2 for\(i\gets 1\)to\(\
u\)do
3 Pick \(x\) uniformly at random;
4 Query \(\Omega\) for \(U(x)\) and \(U(x+a)\);
5 if\(U(x+a)=U(x)+b\)then
6\(u\gets u+1\);
7
8 returnaccept(\(u\))
```

**Algorithm 6**Generic Distinguisher for Permutations based on [PERSON] [75]Listing 2 constructs the hash table to count difference pairs in SIMECK-T.

**Listing 2. ** Hash table algorithm for counting difference pairs during differential cryptanalysis of SIMECK-T.

1 // _Hash table size_

2 #define TABLE_SIZE 10000007 // _Prime number for hash tablesize_

3 DifferenceEntry *hash_table;

4
5 // _Hash function for the differences_

6 unsigned in hash_function(uint32_t diff1, uint32_t diff2) {
7 return (diff1 * 31 + diff2) % TABLE_SIZE;

8 }

9
10 // _Insert orincrement the counter_

11 void insert_or_increment(uint32_t diff1, uint32_t diff2) {
12 unsigned in index = hash_function(diff1, diff2);

13 while (hash_table[index].count > 0) {
14 if (hash_table[index].diff1 == diff1

15 && hash_table[index].diff2 == diff2) {
16 hash_table[index].count++;

17 return;

18 }
19 index = (index + 1) % TABLE_SIZE;

20 }
21 hash_table[index].diff1 = diff1;

22 hash_table[index].diff2 = diff2;

23 hash_table[index].count = 1;

24 }

XOR-Based Differences

Differential cryptanalysis is a method used to analyze the security of symmetric key ciphers, particularly block ciphers. This technique focuses on how differences in plaintext input can affect differences in the resulting ciphertext output. By examining the relationship between these differences, cryptanalysts can identify vulnerabilities in the encryption algorithm. In differential cryptanalysis, the difference between two plaintexts \(P_{1}\) and \(P_{2}\) is often calculated using the following XOR operation:

\[\Delta P=P_{1}\oplus P_{2}.\]

A differential pair is defined as a pair of plaintexts together with their corresponding ciphertexts:

\[(P_{1},C_{1})\quad\text{and}\quad(P_{2},C_{2}),\]

where \(C_{1}\) and \(C_{2}\) are the ciphertexts obtained after encrypting \(P_{1}\) and \(P_{2}\) using a secret key. The difference between the ciphertexts is computed as follows:

\[\Delta C=C_{1}\oplus C_{2}.\]The key focus of differential cryptanalysis is to understand how differences propagate through the encryption process. Observing how an input difference \(\Delta P\) leads to an output difference \(\Delta C\), cryptanalysts can identify patterns that can indicate weaknesses in the cipher. Cryptanalysts study the frequency distribution of output differences for a given input difference. If certain output differences occur more frequently than expected, it may reveal vulnerabilities in the cipher's structure. A differential characteristic describes the probability that a specific input difference \(\Delta P\) will produce a specific output difference \(\Delta C\).