# Confidential Smart Contracts and Blockchain to Implement a Watermarking Protocol
## 6 The Protocol
### The Protection Protocol
#### 6.1.2 Protection
\begin{table}
\begin{tabular}{l l} \hline \hline \multicolumn{2}{c}{**Entities and**} \\
**Interactions** & \\ \hline \(\mathcal{B}\xrightarrow{m_{1}}\mathcal{CP}\) & : \(m_{1}=\{\text{request for }X,B_{id}\}\) \\ \(\mathcal{CP}\xrightarrow{m_{2}}\mathcal{CN}\) & : \(m_{2}=\{c_{id},E_{pk_{id}}(B_{id},X_{d},T_{X},K^{X}_{\mathcal{CP}},\sigma(X))\}\) \\ \(\mathcal{CP}\xrightarrow{m_{3}}\mathcal{B}\) & : \(m_{3}=\{\mathcal{CN},X_{d},T_{X},c_{id},pk_{c_{id}}\}\) \\ \(\mathcal{B}\xrightarrow{m_{4}}\mathcal{CN}\) & : \(m_{4}=\{c_{id},E_{pk_{id}}(B_{id},X_{d},T_{X},K^{X}_{\mathcal{B}})\}\) \\ \(\mathcal{CN}_{TE_{1}}\) & : starts the execution in TEE of the smart contract identified by \(c_{id}\) \\  & and fetches from \(\mathcal{BC}\) the contract code and \(E_{K^{u}_{id}}(in_{c_{id}})\), \(\Pi[AttD]\) and \(pk_{c_{id}}\) \\ \(\mathcal{CN}_{TE_{1}}\xrightarrow{m_{5}}\mathcal{KMS}\) & : request for keys \\ \(KMS\xrightarrow{m_{5}}\mathcal{CN}_{TE_{1}}\) & : \(m_{6}=\{K^{st}_{cl},s_{Ko_{id}}\}\) \\ \(\mathcal{CN}_{TE_{1}}\) & : generates \(Block^{X},sk^{X},N,\mathbb{E}_{pk^{X}}(N)\) \\ \(\mathcal{CN}_{TE_{1}}\) & : generates \(Block=[B_{id},X_{d},T_{X},pk^{X},sk^{X},N,\mathbb{E}_{pk^{X}}(N),K^{X}_{\mathcal{ CP}},K^{X}_{\mathcal{CP}}]\) \\ \(\mathcal{CN}_{TE_{1}}\) & : generates \(E_{K^{u}_{id}}\) (\(Block\)), \(H(Block)\), and obtains \(\Pi[Att1]\) \\ \(\mathcal{CN}_{TE_{1}}\) & : publishes \(T_{X}\), \(E_{K^{u}_{id}}\) (\(Block\)), \(H(Block)\), \(\Pi[Att1]\) \\ \(\mathcal{CN}_{TE_{1}}\xrightarrow{m_{3}}\mathcal{CP}\) & : \(m_{7}=\{E_{K^{u}_{\mathcal{CP}}}(T_{X},pk^{X},\mathbb{E}_{pk^{X}}(N),H(Block))\}\) \\ \(\mathcal{CN}_{TE_{1}}\xrightarrow{m_{5}}\mathcal{B}\) & : \(m_{8}=\{E_{K^{u}_{\mathcal{CP}}}(T_{X},H(Block))\}\) \\ \(\mathcal{CP}\) & : generates \(W_{\mathcal{CP}},\mathbb{E}_{pk^{X}}(W_{\mathcal{CP}}),\mathbb{E}_{pk^{X}}(X)\) \\ \(\mathcal{CP}\) & : generates \(\mathbb{E}_{pk^{X}}(W)=\mathbb{E}_{pk^{X}}(W_{\mathcal{CP}},N)=\mathbb{E}_{pk^{X }}(W_{\mathcal{CP}}),\mathbb{E}_{pk^{X}}(N)\) \\ \(\mathcal{CP}\) & : generates \(\mathbb{E}_{pk^{X}}(X)=\mathbb{E}_{pk^{X}}(X)\oplus\mathbb{E}_{pk^{X}}(W)\) \\ \(\mathcal{CP}\xrightarrow{m_{9}}\mathcal{B}\) & : \(m_{9}=\{\overline{E}_{pk^{X}}(X)\}\) \\ \(\mathcal{CP}\xrightarrow{m_{10}}\mathcal{CN}_{TE_{2}}\) & : \(m_{10}=\{c_{id},B_{id},T_{X},E_{K^{u}_{\mathcal{CP}}}(T_{X},pk^{X},\mathbb{E}_{pk^ {X}}(N),H(Block))\}\) \\ \(\mathcal{CP}\) & : saves \(B_{id}\), \(X_{d}\), \(T_{X}\), \(pk^{X}\), \(\mathbb{E}_{pk^{X}}(N)\), and \(K^{X}_{\mathcal{CP}}\) in its database, \\  & associating \(W_{\mathcal{CP}}\) as the lookup key \\ \(\mathcal{B}\xrightarrow{m_{1}}\mathcal{CN}_{TE_{1}}\) & : \(m_{11}=\{c_{id},B_{id},T_{X},E_{K^{u}_{\mathcal{B}}}(T_{X},H(Block))\}\) \\ \(\mathcal{CN}_{TE_{2}}\) & : accesses \(\mathcal{BC}\) and fetches \(E_{K^{u}_{id}}\) (\(Block\)) and \(H(Block)\) \\ \(\mathcal{CN}_{TE_{2}}\) & : compares tokens with those received in \(m_{10}\) and \(m_{11}\) \\ \(\mathcal{CN}_{TE_{2}}\) & : publishes the purchase license represented by \\ \(\mathcal{CN}_{TE_{2}}\) & : \(X_{d}\), \(T_{X}\), \(H(B_{id},X_{d},T_{X},pk^{X},K^{X}_{\mathcal{CP}},\mathbb{E}_{pk^{X}}(N),N)\) \\ \(\mathcal{CN}_{TE_{2}}\xrightarrow{m_{10}}\mathcal{B}\) & : \(m_{12}=\{sk^{X}\}\) \\ \(\mathcal{B}\) & : \(\mathbb{X}=\mathbb{D}_{sk^{X}}(\overline{\mathbb{E}_{pk^{X}}(X)})\) \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Protection protocol. the watermark \(W_{\mathcal{CP}}\), which consists of the union of an anti-collusion code and an error-correcting code needed to correct any errors that may occur while extracting the watermark from \(X\). Then, \(\mathcal{CP}\) encrypts \(X\) and \(W_{\mathcal{CP}}\) with the key \(pk^{X}\) and with the same homomorphic encryption system used to obtain \(\mathbb{E}_{pk^{X}}(N)\). Once the tokens \(\mathbb{E}_{pk^{X}}(X)\) and \(\mathbb{E}_{pk^{X}}(W_{\mathcal{CP}})\) have been generated, \(\mathcal{CP}\) can proceed to insert the watermark directly into the encrypted domain as indicated in the previous Section 5.