# Color Visual Secret Sharing for QR Code with Perfect Module Reconstruction
## 4 Security Analysis
### Decoding from One Share  
Given only one share, we show that the probability of codeword error is far beyond the ECC capability of QR code version 4-H. The share image consists of color module, so a conversion from color module to B/W module is necessary. This problem is referred as _module recovery_ and can be stated as follows. A secret QR code \(\mathbf{H}\) is encoded into three shares \(\mathbf{S}_{1},\;\mathbf{S}_{2},\;\mathbf{S}_{3}\). Given only one share \(\mathbf{S}\in\left\{\mathbf{S}_{1},\;\mathbf{S}_{2},\;\mathbf{S}_{3}\right\}\), where \(\mathbf{S}(x,\;y)\in\left\{\text{R},\;\text{G},\;\text{B}\right\}\), determine a binary QR code \(\mathbf{\hat{H}}(x,\;y)\in\left\{0,\;1\right\}\) to minimize the probability that \(\mathbf{\hat{H}}(x,\;y)\
eq\mathbf{H}(x,\;y)\). We define the module recovery error as  
\[e_{m}\triangleq\left\{\mathbf{\hat{H}}(x,\;y)\
eq\mathbf{H}(x,\;y)\right\}. \tag{21}\]  
To minimize the probability of module recovery error \(\Pr(e_{m})\), the optimal detector is a MAP (maximum a posteriori probability) detector under the condition of equal probability for \(\mathbf{H}(x,\;y)\in\left\{0,\;1\right\}\)[34]. To calculate the a posteriori probabilities, recall that \(\mathcal{E}_{0}=\left\{\text{R},\;\text{B}\right\}\) and \(\mathcal{E}_{1}=\left\{\text{R},\;\text{G},\;\text{B}\right\}\). So, given a blue module in \(\mathbf{S}\), we have  
\[\Pr\left(\mathbf{H}(x,\;y)=0|\mathbf{S}(x,\;y)=\text{G}\right) = 0, \tag{22}\] \[\Pr\left(\mathbf{H}(x,\;y)=1|\mathbf{S}(x,\;y)=\text{G}\right) = 1. \tag{23}\]  
To calculate other a posteriori probabilities, we need \(\Pr\left(\mathbf{H}(x,\;y)=t_{1}\right)\), where \(t_{1}\in\left\{0,\;1\right\}\), and \(\Pr\left(\mathbf{S}(x,\;y)=t_{2}\right)\), where \(t_{2}\in\left\{\text{R},\;\text{G},\;\text{B}\right\}\). For the secret QR code, it is usually assumed that \(\Pr\left(\mathbf{H}(x,\;y)=0\right)=\Pr\left(\mathbf{H}(x,\;y)=1\right)=1/2\), because the masking operation balances the number of B/W modules. For the share image \(\mathbf{S}\), we can obtain:  
\[\Pr\left(\mathbf{S}(x,\;y)=\text{R}\right) = \frac{1}{2}\cdot\frac{1}{2}+\frac{1}{2}\cdot\frac{1}{3}=\frac{5}{ 12}, \tag{24}\] \[\Pr\left(\mathbf{S}(x,\;y)=\text{G}\right) = \frac{1}{2}\cdot\frac{1}{3}=\frac{1}{6},\] (25) \[\Pr\left(\mathbf{S}(x,\;y)=\text{B}\right) = \frac{1}{2}\cdot\frac{1}{2}+\frac{1}{2}\cdot\frac{1}{3}=\frac{5}{ 12}. \tag{26}\]  
The a posteriori probability then can be determined from the Bayes rule:  
\[\Pr\left(\mathbf{H}(x,\;y)=0|\mathbf{S}(x,\;y)=\text{R}\right)=\frac{\frac{1}{ 2}\times\frac{1}{2}}{\frac{1}{2}\times\frac{1}{2}+\frac{1}{2}\times\frac{1}{3} }=\frac{3}{5}. \tag{27}\]  
Similarly, we get \(\Pr\left(\mathbf{H}(x,\;y)=1|\mathbf{S}(x,\;y)=\text{R}\right)=2/5\), \(\Pr\left(\mathbf{H}(x,\;y)=0|\mathbf{S}(x,\;y)=\text{B}\right)=3/5\) and \(\Pr\left(\mathbf{H}(x,\;y)=1|\mathbf{S}(x,\;y)=\text{B}\right)=2/5\), which are summarized in Table 2.  
Based on the above a posteriori probabilities, the MAP module detector decodes  
\[\hat{\mathbf{H}}(x,\;y)=\left\{ \begin{array}{ll}0,&\text{if }\mathbf{S}(x,\;y) \in\left\{\text{R},\;\text{B}\right\},\\ 1,&\text{if }\mathbf{S}(x,\;y)=\text{G}.\end{array} \right. \tag{28}\]  
The probability of module recovery error can be calculated as:  
\[\Pr\left(e_{m}\right) = \Pr\left\{\hat{\mathbf{H}}(x,\;y)\
eq\mathbf{H}(x,\;y)\right\} \tag{29}\] \[= 2\cdot\frac{5}{12}\cdot\Pr\left(\hat{\mathbf{H}}(x,\;y)=0| \mathbf{H}(x,\;y)=1\right)\] \[= \frac{1}{3}.\]  
Since each codeword consists of 8 modules, the probability of codeword error \(e_{c}\) is  
\[\Pr\left(e_{c}\right)=1-\prod_{t=1}^{8}\left[1-\Pr\left(e_{m}(t)\right)\right] =1-\left(\frac{2}{3}\right)^{8}=0.961. \tag{30}\]  
where \(e_{m}(t)\) denotes error of the \(t\)-th module in the codeword. For QR code (4-H), there are four blocks. For each block, the Reed-Solomon code is \((\hat{c},\;\hat{k},\;\hat{r})=(25,\;9,\;8)\)[23], where \(\hat{c}\) is the total number of codewords in a block, \(\hat{k}\) the number of data codewords, and \(\hat{r}\) is the ECC capability.