# Decentralized Storage with Access Control and Data Persistence for e-Book Stores
## 4 Proposed System
### Decentralized Access Control to the Stored Data
#### 4.2.1 Access Control Contract (ACC)
Upon uploading, the e-book data provided by the author are divided into \(k\) shards using Reed-Solomon codes, with the \(i\)th shard being stored on all storage nodes within the \(i\)th group. Utilizing Reed-Solomon codes for shard generation ensures that the original data can be restored from only a certain number of shards without requiring all types of shards. This property enables the restoration of the e-book data even if some groups encounter issues or entirely disappear (similar techniques are also observed in RAID5 and RAID6). In the mentioned distributed storage method, a storage node belonging to the \(i\)th group stores only the \(i\)th shard and no other shards. Consequently, if a storage node B does not own the access rights to the e-book, it cannot restore the complete e-book data solely from locally stored shards. Although it may attempt to recover e-book data by acquiring shards one by one from \(k-1\) other storage nodes, the ACC prevents unauthorized acquisition requests if storage node B lacks access rights to the e-book. ### Incentive Mechanisms for Permanence Enhancement

In the proposed method, each shard generated by the author is stored in all storage nodes in a node group, and such a configuration is achieved by a combination of two processes. The first is a push process in which storage nodes participating in the d-book-repository are subscribed to a topic for the node group to which they belong in advance, and shards published to that topic by the author are propagated to the entire group using gossipsub [25]. Note that gossipsub can spread data only to the nodes that have not yet received them by sending gossip messages before spreading the data themselves, so shard propagation can be performed more efficiently than normal floodsub. The second is a pull process, in which each node goes for its own missing shard, usually after the shard has been distributed to the entire group by the gossipsub. From the discussion described above, each storage node can identify its own missing shards in the following steps: (1) Each storage node can obtain a list of e-books from the book information registered on the ACC, and if it stores no shard of an e-book in the list, it recognizes that a shard of the e-book is missing. (2) Each node can determine which of the \(k\) shards it should store from its own PeerID, and if shards generated from the e-book have been pushed by the author, someone in the group must have stored the shard (even if it does not have it itself). In order to enhance the persistency of stored data, the proposed system provides an incentive for each storage node to \"repeat the pull process within a node group until the storage node that finds its missing shard runs out of missing shards\". Specifically, it verifies the absence of missing shards by using a sampling quiz, where smart contracts are used to answer quizzes and receive rewards. (In the current implementation, such a quiz function is included on the ACC to save on gas costs, but it is possible to implement it as a completely separate smart contract). The sampling quiz is issued every time \(N\) blocks are added to the blockchain used by the ACC. Note that it is issued at approximately regular time intervals without any trigger by the central authority since blocks in a blockchain are autonomously created at regular time intervals. In the sampling quiz, each storage node is requested to (1) extract segments specified by random values from the shards in its own storage and (2) concatenate them to form the answer (i.e., a proof), where the hash value of the latest (i.e., the \(N\)th) block is used as the random number. See Figure 4 for an illustration. The **answer period** for a quiz is until the \((N+X)\)th block is generated after issuing the quiz. Each storage node creates a new common key by the end of the answer period and records the encrypted proof in the ACC.