# A Watermarking Protocol Based on Blockchain
## 7 Implementation  
The first prototype implementation of the proposed protocol is mainly based on the experiences documented in [22; 24]. It consists of two parts.  
The former comprises the same set of C++ separate programs that implement \(\mathcal{B},\mathcal{CP},\mathcal{R}\mathcal{A}\), and \(\mathcal{J}\) in [22; 24]. The programs run on Linux operating system and communicate via TCP implemented by standard socket library. They implement the encryption/decryption and watermark insertion algorithms by exploiting the NTL library and the GNU Multi Precision Arithmetic library. In particular, watermark insertion is based on the \"Quantization Index Modulation\" algorithm [61] extended to the homomorphic cryptosystem proposed by [PERSON] [69] according to the main ideas reported in [9; 63]. It follows the indications reported in [42], which successfully address a number of problems that tend to make watermark insertion directly into the encrypted domain inefficient. In this regard, in order to reduce both the number of encryptions and the operations performed on encrypted values, watermark insertion is carried out in the encrypted domain by exploiting the specific technique of the \"composite signal representation\" described in [42], also called \"efficient composite embedding\" [50].  
The latter implements the blockchain \(\mathcal{BC}\) according to the Figure 1. In particular, the blockchain can be classified as \"public\", with a fully decentralized architecture, and based on the classic \"proof of work\" consensus algorithm [27]. Furthermore, the nodes of the blockchain are implemented in Ethereum [70], whereas the smart contract employed by the proposed protocol is written in Solidity [71].  
The performance of the proposed prototype implementation mainly depends on both the basic operations characterizing watermarking protocols and the overhead induced by the blockchain management. In fact, the former are the classic encryption/decryption and watermark insertion operations. Their performances are omitted because, as reported above, they are well documented  
Figure 1: The blockchain within the proposed watermarking protocol.  
by the results published in [22; 24]. On the contrary, the latter depends on a number of factors, such as, for example, the Ethereum node implementation, the adopted consensus algorithm, and the number of nodes averagely involved in the blockchain, which are essentially independent of proposed watermarking protocol [28; 29]. In this regard, it is worth noting that an Ethereum, public and decentralized blockchain, based on the \"proof of work\" consensus algorithm, is characterized by undoubted advantages, such as decentralization, lack of trusted third parties, and immutability [27; 28; 29], but it is also affected by low performance and efficiency levels caused by the time needed for propagating, processing, and validating the purchase transactions [72]. In fact, the higher the number of nodes participating in the blockchain is, the more limiting power consumption and block generation rate become. However, the main goals of the proposed protocols are to achieve high levels of robustness and security without reducing simplicity of the protection scheme. After all, it is not wrong to think that the proposed watermarking protocol will be able to take advantage of the next generation blockchains, which promise to achieve higher performance and efficiency levels, particularly in terms of power consumption, due the development of new consensus algorithms. Nevertheless, such performance aspects have not been investigated because they are out of the scope of this paper.