## 4 Mechanisms of Our Proposed Protocol
### XSalsa20 Algorithm  
XSalsa20 is a cryptographic algorithm used primarily for encryption and decryption. It is an extended version of the Salsa20 stream cipher, which was designed by [PERSON] [24]. The number 20 refers to the number of rounds of the XSalsa20 core function that are applied during the encryption process. The Xsalsa20 stream cipher is a potent cryptographic method intended for the high-performance encryption of data streams. The Salsa20 family of ciphers, which is renowned for its effectiveness and security, includes this one. Stream ciphers generate a keystream of pseudorandom bits, which are XORed with the plaintext to produce the ciphertext. This ciphertext can be deciphered by XORing it with the same keystream. The fundamental characteristic of this algorithm, which is the reasons we utilize it as the foundation of our suggested protocol, is its speed: Xsalsa20 works well for real-time applications that need fast encryption and decryption because of its speed. Its efficiency can be attributed to its emphasis on simple operations and lightweight architecture. In terms of safety, Xsalsa20 has proven its strong security profile by thwarting multiple cryptanalytic assaults. Certain components of its architecture guard against well-known attacks like differential and linear cryptanalysis. Hence, stream ciphers such as Xsalsa20 are perfect for encrypting data streams, because they operate with single bits as opposed to large data blocks. Because of this, they work well for protocols like financial transactions and applications in general. XSalsa20 is clarified in detail, with all its phases in Algorithm 1. ```
1:Input:
256-bit key \(N\longleftarrow\) 64-bit nonce \(C\longleftarrow\) 64-bit counter \(H\longleftarrow\) 256-bit encryption key Output:
3:\(Z\longleftarrow\) 512-bit keystream block Start
4:Initialize parameters State Vector (\(S\)): The algorithm uses a 16-byte states vector (\(S\)) containing various elements: \(S\longleftarrow\) (sigma, \(C\)[0], \(C\)[1], \(C\)[2], \(C\)[3], \(H\)[0], \(H\)[1], \(H\)[2], \(H\)[3], \(N\)[0], \(N\)[1], \(N\)[2], \(N\)[3], \(K\)[0], \(K\)[1], \(K\)[2], \(K\)[3])
5:Set up the internal state
6:Core Round Loop (20 rounds) This function operates on a 16-byte input (\(X\)) and performs bitwise operations to mix its elements: \(\text{Core}(X\longleftarrow)\)\((rotateLeft(X[0],7)^{X[4]})^{(X[12])^{\textit{\scriptsize\{}} innateRight(X[1],9)}})\) \(+\)\((X[2]^{X[0]})^{\textit{\scriptsize\{}}(rotateLeft(X[8],13))})\) \(+\)\((X[10]^{X[6]})^{\textit{\scriptsize\{}}(rotateRight(X[5],15))})\)
7:Quarter Round: Perform a specific mixing operation on subsections of the state (four words each) using additions, shifts, and XORs. 8:Permute the state \(S\) by shifting rows and rotating columns to further enhance diffusion. \(rotateLeft(X,N)\): Shifts the bits of \(X\) left by \(N\) positions. \(rotateRight(X,N)\): Shifts the bits of \(X\) right by \(N\) positions. Bitwise XOR operation
9:Introduce a round constant that changes with each round to improve confusion. 10:Final Output Generation
11:Apply the quarter round operation one last time on the final state. 12:Generate Keystream Block: The key (\(K\)) and nonce (\(N\)) are combined using the HChaCha20 construction (similar to XSalsa20) to generate the initial key (\(H\)). 13:Extract a 64-byte \(S\) block of pseudorandom bytes from the final state as the keystream. 14:Repeat (for additional keystream blocks). 15:Increment a counter in the state to distinguish different keystream blocks. 16:Return to the core round loop to generate the next keystream block. 17:The resulting ciphertext or plaintext is the final output after all blocks have been processed. End
```  
**Algorithm 1** XSalsa20 steps. The permutation procedure in XSalsa20, which applies several rounds of the Salsa20 core function, is in fact essential to the algorithm's general functionality and security.