# Blockchain Private File Storage-Sharing Method Based on IPFS
## 2 Related Theory
### Ndn  
The basic design principle of an NDN is based on the Internet [5], so it can directly use major IP services, such as a Domain Name System (DNS) and an interzone routing policy. It allows routers to track the status of packets and supports multipath forwarding. These features allow content to be cached in the router to meet future requests while enabling user mobility. Consumers send requests for the required data, called interest packets, which are forwarded to data producers by the NDN forwarding daemon (NFD) [6]. Each NFD also includes a forwarding policy module that determines whether, when and through which interfaces the received interest is forwarded [7]. In an NDN, the content packet consists of the data name, the encrypted content, and the signature with the publisher [8]. In addition, the NDN network has only two types of data packets, and the data packet format is shown in Figure 1.  
An NDN router consists of three main components: an undetermined interest table (PIT), a content store table (CS) and a forwarding information table (FIB). The PIT acts as a logger or recording system for recording packets that have been served by the router but whose contents have not yet reached the consumer. Moreover, the CS is a place to store data that has been submitted for a while. If other consumers request some interest  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Layer** & **Conclusion** \\ \hline \hline Data layer & The transaction data and code received by the node are packaged into time-stamped blocks of data linked to the current longest blockchain \\ Network layer & Including the blockchain system networking mode, message transmission protocol, data verification mechanism, etc. \\ Consensus layer & Solve the problem of how to effectively reach consensus in distributed systems \\ \hline \hline \end{tabular}
\end{table}
Table 1: Blockchain system architecture.  
Figure 1: The interest packet (**a**) and the data packet (**b**).  
and it is already in CS, then the storage mechanism can be very useful, and you can send the requested data immediately. Different from a PIT, an FIB, as a recorder or recording system [9], only stores the path where the content is located, and the communication forwarding process is shown in Figure 2. During a sharing process, the requester based on the name KP/NDN/blockchain.doc files sends a request packet, which then goes through the CS table the pit table and the FIB table looking up in turn. If there is a result in the CS, the CS forwards a content packet on a direct reverse path request route, otherwise the pit query continues. If there is a pit request and a corresponding interface after feedback from other nodes, the reverse path feedback and the content in CS is stored for a period of time for multiplexing and storage security aspects. The NDN network itself signs and encrypts content packets provided neither CS nor pit are present and finally found by the FIB. The FIB updates the request to content in potential nodes based on manually configured or named routing protocols, discarding the request package if the FIB is not present to indicate inaccessibility.  
In general, compared with blockchain technology, a P2P network may cause message delay and duplication, low reuse rate of forwarded data, mobility restrictions and additional data security protection problems. An NDN has advantages in the following aspects:  
1. Flexible routing and forwarding policies to balance network traffic by forwarding content in reverse paths;
2. Name, sign and encrypt the content, and the content-centered transmission mechanism optimizes the mobility limitation;
3. Routing naming cache mechanism ensures content security and transmission reuse rate.