**7. Conclusions**

In this paper, we have described the architecture of a decentralized personal data marketplace and provided an implementation based on Distributed Ledger Technologies (DLTs), Decentralized File Storages (DFS) and smart contracts. Data are stored in Personal Data Stores (PDS) and then accessed through an authorization blockchain using a Threshold Proxy Re-Encryption (TPRE) schema. Moreover, we have provided a Layer-2 solution based on the use of an hypercube-structured Distributed Hash Table (DHT), with the aim of facilitating the retrieval of large amounts of data using specific keywords. We focused specifically on retrieving data stored in IOTA stream channel messages. We discussed a use case for participation in the creation of citizen-generated data with the aim of describing our implementation and of validating it against a real-world scenario. The proposal validation then continued with a performance evaluation divided in three steps: (i) hypercube DHT simulation, (ii) distributed authorization testing and (iii) smart contract gas usage.

The solution we provided for the hypercube DHT consists of a decentralized system that provides an efficient routing mechanism based on keyword sets. The simulation analysis shows that searching for an object with an exact keyword set requires on average log(*n*) 2 hops, where *n* is the number of logical nodes of the hypercube. This solution presents an efficient trade-off between memory space and response time, thus making a first contribution towards the creation of a system that allows complex queries on DLT.

The distributed authorization is implemented using the GoQuorum permissioned blockchain, a set of smart contracts for implementing data owner's policies and the TPRE cryptographic schema for distributing the keys that decrypt data. The results show that writing on the blockchain represents a bottleneck, but that the citizen-generated data use case implementation is viable. Moreover, the results beyond the ledger writing part gives good reason to believe that a similar approach can be easily implemented in more performing blockchains with much better results.

Smart contracts that implement access control and DAO operations have adequate gas usage. The use of patterns such as the Minimal Proxy pattern helps to reduce the gas usage of some contract methods.

Finally, for future work, we are preparing the deployment of such a decentralized marketplace in larger networks, formed by more performing nodes. This will allow us to better test the influence of the network transmission and the system scalability. Moreover, we will focus on the integration of richer policy expression languages for managing personal data access control, adding a layer of policy declaration and reasoning on top of smart contracts.

**Author Contributions:** Conceptualization, M.Z. and S.F.; methodology, M.Z. and S.F.; software, M.Z.; validation, M.Z. and S.F.; formal analysis, M.Z.; investigation, M.Z., S.F. and V.R.-D.; resources, M.Z. and V.R.-D.; data curation, M.Z.; writing—original draft preparation, M.Z.; writing—review and editing, M.Z., S.F. and V.R.-D.; visualization, M.Z.; supervision, S.F. and V.R.-D.; project administration, S.F. and V.R.-D.; funding acquisition, M.Z., S.F. and V.R.-D. All authors have read and agreed to the published version of the manuscript.

**Funding:** This work has received funding from the European Union's Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie International Training Network European Joint Doctorate gran<sup>t</sup> agreemen<sup>t</sup> No. 814177 Law, Science and Technology Joint Doctorate—Rights of the Internet of Everything.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** The complete dataset and the reference software referenced in the performance evaluation are stored in [77,82,84], following the FAIR data principles for access and reuse of models [86].

**Acknowledgments:** An early version of this work appeared in [87]. This paper is an extensively revised and extended version where more than 50% is new material. We are indebted to Gabriele D'Angelo for his support in the research conducted for this work and to Cesare Giansante for his contribution on a preliminary implementation of the hypercube DHT simulation.

**Conflicts of Interest:** The authors declare no conflict of interest.
