# Confidential Smart Contracts and Blockchain to Implement a Watermarking Protocol
## 6 The Protocol  
The proposed watermarking protocol is of the \"buyer-seller\" type and is based on a \"buyer-friendly\" approach [4]. It is implemented by a smart contract executed by TEE nodes. The execution result is then validated by the blockchain nodes (miners) according to the layer-2 scheme described in Section 4. In particular, the execution of the smart contract consists of two phases. In the first phase, the smart contract is activated by the content provider and the buyer and generates the tokens needed to start inserting the watermark into the content to be protected. This phase ends with publishing a series of information preparatory to activating the next phase. All information is exchanged and published in encrypted form to guarantee complete confidentiality. In the second phase, the smart contract generates the final information constituting the content purchase license published in the blockchain ledger. This phase can be activated only if the information sent as input to the smart contract by the buyer and the content provider is consistent with that published previously, downstream of the first phase. The proposed protocol does not employ any TTP and, thanks to the layer-2 execution scheme, executes the smart contract entirely \"off-chain\", within the enclave provided by the TEE. It can be described at a high level as follows: (1) the protocol is implemented by a smart contract that is published by a blockchain (\(\mathcal{BC}\)); (2) the protocol can be used by any seller or content provider (\(\mathcal{CP}\)) who wishes to protect its content distributed on the web; (3) by activating the smart contract, \(\mathcal{CP}\) and the buyer (\(\mathcal{B}\)) enable the execution of the watermarking protocol, after which the purchased content is released in encrypted form and protected by the watermark; (4) \(\mathcal{B}\), at the end of the execution of the smart contract, decrypts the received content, obtaining its version with the customized protection; (5) the smart contract takes care of generating all the tokens and information needed to protect the content without resorting to TTP; (6) \(\mathcal{CP}\)s are able, once they have found a suspicious copy of their content sold on the Internet, to trace it back to the original purchaser and establish whether there has been illicit distribution. The proposed protocol comprises the _protection protocol_ and the _identification and arbitration protocol_. Table 1 defines the symbols used to describe the protocol. \begin{table}
\begin{tabular}{c l} \hline \hline
**Symbols** & \multicolumn{1}{c}{**Meaning**} \\ \hline \(\mathcal{B}\) & buyer \\ \(\mathcal{CP}\) & content provider or seller \\ \(\mathcal{BC}\) & blockchain \\ \(\mathcal{CN}\) & computation node equipped with TEE \\ \(\mathcal{CN}_{TEE_{DD12}}\) & \(\mathcal{CN}\) executes in TEE the deployment, first or second phase of the smart contract \\ \(\mathcal{CODE}_{sc}\) & code of the smart contract \(sc\) \\ \(KMS\) & key management server \\ \(X\) & digital content purchased by \(\mathcal{B}\) \\ \(X_{d}\) & information used by \(\mathcal{CP}\) to unambiguously identify \(X\) \\ \(T_{X}\) & timestamp referred to the transaction by which \(\mathcal{B}\) buys \(X\) \\ \(B_{id}\) & information used to identify \(\mathcal{B}\) \\ \(c_{id}\) & smart contract identifier \\ \(in_{cid}\) & initial state of the smart contract \\ \(N\) & nonce used to mark the watermarking transaction \\ \(W\) & watermark \\ \(W_{Ent.}\) & part of the watermark \(W\) generated by the entity \(Ent\). \\ \(X\) & watermarked \(X\) \\ \(pk_{id}\) & public key referred to _id_ \\ \(sk_{id}\) & secret key referred to _id_ \\ \(pk^{X}\) & one-time public key used to watermark \(X\) \\ \(sk^{X}\) & one-time secret key used to watermark \(X\) \\ \(K^{t}_{cid}\) & symmetric key used by the contract indicated by \(c_{id}\) to encrypt state information \\ \(K^{X}_{Ent.}\) & symmetric key of the entity \(Ent.\) used in the transaction to watermark \(X\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Symbols used in the protocol.