## 2 Related Work  
This study is about relying on blockchain to securely store data. The related studies reported in the literature can be roughly divided into three categories: (1) custom-builtblockchain systems designed specifically for secure data storage (such as [14; 15]); (2) storing data directly in transactions using public blockchains; and (3) storing data in smart contract using public blockchains. Although the work in the first category has some merit, for example, a system was designed to handle large-scale Internet of Things (IoT) data with data trading functionalities in [14], and another system was designed to self-repair corrupted data with local repair groups in [15], the proposed systems are not actually implemented, let alone available for other researchers to use for secure data storage. As such, we do not draw comparisons with this line of work. Studies in the second category predominately used the IOTA distributed ledger IOTA [16; 17]. IOTA was designed to support high-throughput transactions using a direct acyclic graph instead of a single chain of blocks. Furthermore, IOTA does not impose a transaction fee. To mitigate spamming attacks, all clients must perform a moderate amount of proof-of-work in every transaction submitted to the IOTA network. IOTA provides application programming interfaces (APIs) for the construction of a transaction that only contains data. The transaction size in IOTA is limited to 32 KB. In 2017, IOTA introduced the masked authenticated message (MAM) to facilitate secure communication between IoT devices and IOTA ([[https://github.com/iotaledger/mam.client.js/](https://github.com/iotaledger/mam.client.js/)]([https://github.com/iotaledger/mam.client.js/](https://github.com/iotaledger/mam.client.js/)) (accessed on 1 March 2023)). A number of studies used IOTA MAM for securing IoT data [18; 19; 20], for supply chain applications [21], for health data sharing [22; 23] and management [24; 25], for manufacturing applications [26; 27], for securing industry control [28], for securing system logs [29], for securing vehicular networks [30; 31], and for securing power systems [32]. Previously, we also focused on using IOTA to store sensing data securely [10]. The system adopted a hierarchical aggregation scheme for the sensing data [33] to reduce the amount of data to be placed on IOTA. Recently, we extended the work to store sensing data directly in the data field of Ethereum transactions [13]. Our previous work has a number of limitations as a result of storing of data directly as part of blockchain transactions. A major concern of the approach is the lack of user access control regarding who may upload the data into the blockchain. Not addressing this issue could lead to serious security issues because the integrity of the data may be compromised if adversaries could upload faulty data to the blockchain. Second, the data stored in the blockchain are publicly accessible, which could present confidentiality and privacy issues. By adding user access control, we address both concerns. Third, it is difficult to query the data stored in the blockchain. One would have to know the transaction hash to retrieve the data stored in a particular transaction. In [13], we proposed a workaround by introducing an indexing scheme. However, the indexing data must also be stored securely. If the indexing data are compromised or lost, data query would not be possible. In the current study, the datastore offers the functionality of data queries. In the remainder of this section, we consider related studies in the third category. We note that although there is a large body of work on smart contract applications and this line of work has been well reviewed (for example, [34; 35]), most such studies focus on using smart contracts for access control and coordination. A small fraction of studies are dedicated to secure data storage using smart contracts.