## 4 Proposed Security Algorithm for Patient Data in WBSN and IoMTs Applications
### Visual Encryption of QR Code Image  
The purpose of the present phase is the visual encryption of the QR code image of size \(M\times M\). For this purpose, use the 2 DSCLM for generating two chaotic sequences denoted \(SH\) and \(SW\), each of size \(L=50+M\). After eliminating the first 50 values of these sequences, they are normalized and rounded in the interval \([-M,+M]\). Next, \(SH\) and \(SW\) sequences are employed to confuse the QR code pixels as described in the next steps. _Step_**1**: Use the elements of \(SH\) to confuse each line of the QR code image via a circular shifting by \(k\)-positions as follows:  
\[ \begin{array}{l}QR^{*}(i,:)=\textit{cirxshift}(QR(i,:),k_{i}),i=1,2,\ldots,M \\ \text{with }k_{i}=SH(i),i=1,2,\ldots,M\end{array}  \tag{17}\]  
where \(Y=\textit{cirxshift(A,k)}\) is a function that circularly shifts the elements of \(A\) array by \(k\)-positions [40]. _Step_**2**: Use \(SW\) elements to confuse each row of the \(QR^{*}\) image by k-positions via the next circular shifting operation:  
\[ \begin{array}{l}QR^{**}(:,\ j)=\textit{cirxshift}(QR^{*}(:,\ j),k_{i}),j=1,2, \ldots,M\\ \text{with }k_{i}=SW(i),=1,2,\ldots,M\end{array}  \tag{18}\]  
It should be noted that the parameters \(\left\{\alpha^{*},\beta^{*},\delta^{*},\varphi^{*},x_{0}^{*},y_{0}^{*}\right\}\) of the 2 DSCLM are given as a security key denoted _KEY3_. _Step_**3**: Generate two chaotic sequences (\(X\) and \(Y\)), each of size \(L=M\times M+50\), using the proposed chaotic system, in which \(M\times M\) represents the QR code dimensions. Then, the first 50 values of the generated sequences are eliminated. Next, the median values \(M_{1}\) and \(M_{2}\) of \(X\) and \(Y\) sequences are calculated, respectively. Finally, the created sequences are binarized as follows:  
\[B_{1}(i)=\left\{ \begin{array}{ll}1&if\ X(i)\geq M_{1}\\ 0&\text{otherwise}\end{array} \right. ;\ i=1,2,\ldots,M\times M \tag{19}\]  
Figure 6: QR code of size \(282\times 282\), which includes the encrypted bio-signal feature vectors and confidential patient information. \[B_{2}(j)=\left\{ \begin{array}{ll}1&if\ Y(j)\geq M_{2}\\ 0&\text{otherwise}\end{array} \right. ;\ j=1,2,\ldots,M\times M \tag{20}\]  
The parameters of the 2 DSCLM are given in the current step as a security key denoted \(KEY4=\left\{\alpha^{**},\beta^{**},\delta^{**},\varphi^{**},x_{0}^{**},y_{0}^{**}\right\}\). _Step_ **4**: In the current step, the XOR operator is used as follows:  
\[E=B_{1}\otimes B_{2}\ \ \ k_{i}=SW(i),=1,2,\ldots,M \tag{21}\]  
_Step_ **5**: The purpose of this step is the diffusion of the QR** image using the \(E\) binary matrix as follows:  
\[E_{QR}=QR^{**}\otimes E \tag{22}\]  
Finally, the produced \(E_{QR}\) image, which is called the zero-watermark image, is attached to the EPF. The EPF can now be safely transmitted via IoMTs. Figure 7 shows an example of a produced QR code using our scheme; with encrypted and decrypted versions. The security keys used during the encryption and decryption phases are  
\[KEY=\left\{\{a1,b1,a2,b2\},\left\{a,\beta,\delta,\varphi,x_{0},y_{0}\right\},\left\{\alpha^{*},\beta^{*},\delta^{*},\varphi^{*},x_{0}^{*},y_{0}^{*}\right\},\left\{\alpha^{**},\beta^{**},\delta^{**},\varphi^{**},x_{0}^{**},y_{0}^{**} \right\}\right\}\]  
\[=\left\{2.16,5.22,6.98,3.38\right\},\left\{3.97,0.020,4,0.045,0.8,0.6\right\},\left\{3.99,0.020,3.98,0.030,0.5,0.6\right\},\left\{3.98,0.022,3.99,0.034,0.6, 0.5\right\}.\]  
It can be seen from Figure 8b that the encrypted QR code completely masks the visual information of the original QR code (Figure 7a). As a result, no information can be retrieved from the encrypted QR code using a QR code scanner. We can also observe that the QR code image (Figure 7c) is correctly retrieved in the decryption phase using correct security keys. This finding shows good security provided by our scheme. To further support this finding, we slightly modified one of the KEY parameters in the decryption phase, and then we display in Figure 8 the decrypted QR code when using the wrong security key.