# FarpScun: Fully Anonymous Routing Protocol with Self-Healing Capability in Unstable Sensor Networks
## 2 Preliminary
### Homomorphic Encryption  
Homomorphic encryption provides a function to process the encrypted data. It can perform mathematical operations without decrypting the data, which is equivalent to performing operations on the original data. An encryption scheme is called a homomorphic encryption scheme if it satisfies the following operations: \(E\left(x\right)\odot E\left(y\right)=E\left(x\otimes y\right)\),\(\forall x,y\in M\), where \(E\) delegates the encryption algorithm, \(M\) delegates the space of all the possible messages, and \(\odot\) and \(\otimes\) delegate two different operations applied to the plaintext field and to the ciphertext field, respectively [19].  
If \"\(\otimes\)\" delegates a multiplication operation, the scheme is a multiplication homomorphism. At the same time, \"\(\odot\)\" means an addition operation.  
The Paillier homomorphic encryption scheme is a public key encryption scheme that is based on the security assumption of the decisive combinatorial residue class problem. It is an addition homomorphism [10].  
\begin{table}
\begin{tabular}{c|c} \hline \hline
**The Serial Number** & **The Destination IP Address** & **The Number of Hops Required to Reach the Destination** \\ \hline \multicolumn{3}{c}{The symbol of the legitimate destination serial number} \\ \hline \multicolumn{3}{c}{Other status and routing symbol bits} \\ \hline \multicolumn{3}{c}{Network Interface} \\ \hline \multicolumn{3}{c}{Next hop} \\ \hline \multicolumn{3}{c}{Survival time} \\ \hline \hline \end{tabular}
\end{table}
Table 1: Routing Table Structure.  
Key generation:  
For large prime numbers \(p\) and \(q\) with \(\gcd(pq,(p-1)(q-1))=1\), calculate \(n=pq\) and \(\omega=lcm(p-1,q-1)\). Then, a random integer \(\mathbf{g}\in Z_{n^{2}}^{*}\) is selected satisfying \(\gcd(n,L(pow(g,\omega\bmod n^{2})))=1\), where the function \(L\) is defined for each \(u\in Z_{n^{2}}^{*}\), as follows: \(L(u)=(u-1)\big{/}n\). Consequently, the public key is \((n,g)\) and the private key is \((p,q)\).  
Encryption:  
The message \(\mathrm{x}\) is encrypted as follows.  
\(c=E(x)=g^{x}r^{n}\left(\bmod n^{2}\right)\), where \(r\) is a randomly selected number.  
Decryption:  
Ciphertext \(c<n^{2}\) can be decrypted, as below:  
\(D\left(c\right)=\left(L\left(c^{\omega}\left(\bmod n^{2}\right)\right)/L \left(g^{\omega}\left(\bmod n^{2}\right)\right)\right)\left(\bmod n\right)=x\), using the private key \((p,q)\).  
Homomorphic Property:  
\(E\left(x\right)*E\left(y\right)=\left(g^{x}r_{1}^{n}\left(\bmod n^{2}\right) \right)*\left(g^{y}r_{2}^{n}\left(\bmod n^{2}\right)\right)=g^{x+y}(r_{1}*r_{2 })^{n}\left(\bmod n^{2}\right)=E\left(x+y\right)\), whereas \(r_{1}\) and \(r_{2}\) are the random numbers chosen to encrypt \(x\) and \(y\), respectively.  
Based on public key pair \((n,g)\), over operation \"+\", the Paillier encryption scheme can perform special homomorphic operations on plaintexts \(x\), \(y\) and encrypted plaintexts \(E(x)\), \(E(y)\). The homomorphic operation details are as follows.  
\[E(x)*E(y)(\bmod n^{2})=E(x+y(\bmod n)), \tag{1}\]  
\[E(x)*g^{y}(\bmod n^{2})=E(x+y(\bmod n)), \tag{2}\]  
\[E(x)^{y}(\bmod n^{2})=E(x*y(\bmod n)). \tag{3}\]  
We use Paillier cryptosystem to significantly reduce the overall computational load on the network: The relay nodes build a cryptographic onion architecture, which can be decoded at the destination in a single pass of asymmetric decryption while using its private key. Additionally, the lightweight encryption and decryption algorithms are implemented.