A file sharing system and method based on blockchain and IPFS
By combining blockchain and IPFS technologies, distributed storage and encrypted sharing of files are achieved, solving the data security and privacy protection issues of centralized storage, improving the efficiency and security of file sharing, and meeting the needs of massive data storage.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-31
- Publication Date
- 2026-04-07
AI Technical Summary
Existing file sharing methods have issues with data security and privacy protection. Centralized storage methods are unable to meet the needs of massive data storage, and traditional sharing methods are inefficient and unreliable.
By employing blockchain and IPFS technologies, and deploying blockchain consensus nodes and IPFS nodes, distributed storage and encrypted sharing of files are achieved. The security and privacy of files are ensured by utilizing blockchain evidence storage mechanisms and IPFS distributed storage, combined with threshold secret sharing technology, and transmission efficiency is improved through the IPFS protocol.
It enables trusted file sharing, ensures the authenticity and integrity of files, reduces the risk of loss and tampering, improves transmission efficiency and storage space utilization, and at the same time protects the security and privacy of user data.
Smart Images

Figure CN115865951B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of blockchain and file sharing, in particular to a file sharing system and method based on blockchain and IPFS. BACKGROUND
[0002] Blockchain is an important part of new generation information technology, and has great value and broad prospects in supporting digital economy empowerment, entity economy upgrading and governance capability improvement. Its system is composed of data layer, network layer, consensus layer, incentive layer, contract layer and application layer. The system has high transparency and is difficult to be controlled by an individual or an organization, which can reduce the problems caused by information leakage and information overload. The design of blockchain is a protective measure, such as a high fault-tolerant distributed computing system, which can effectively protect data security.
[0003] IPFS cuts and stores files on each node, effectively ensuring the security of file data. Compared with traditional Internet storage methods, IPFS distributed storage will be much lower than centralized storage costs, saving 60% of data storage, and the speed of downloading and transmitting files will be faster. At the same time, distributed storage does not need to worry about file loss, tampering and other problems caused by single node failure or hacker attacks. As a data transmission protocol, IPFS saves 60% of bandwidth compared to traditional http protocol, and the distributed network effectively reduces network congestion problems, no longer relies on the backbone network, reduces service interruption problems caused by force majeure, and the access speed is significantly improved based on the point-to-point transmission network.
[0004] With the exponential growth of Internet data, the existing mainstream storage technology needs to be innovated, and the defects of centralized storage are highlighted, making it difficult to meet the storage needs of massive data, and the degree of uncertainty in the world is deepening. At present, the main file sharing methods on the market are offline copying, SMB service, central server hosting, etc. These sharing methods have certain limitations. Offline copying and SMB service are not enough to meet market demand in multi-user Internet application scenarios. The central server hosting method is also widely used in file sharing, but its disadvantage is that user-shared files are stored in the central server, and the software service provider has all the user-shared files, which poses a huge vulnerability and risk to user data security and privacy protection. At the same time, most of these traditional file sharing methods use centralized hard disk storage and TCP, UDP, HTTP, FTP and other protocols to transmit files, and the efficiency and reliability of the storage and transmission process need to be improved. SUMMARY
[0005] The purpose of this invention is to address the shortcomings of existing technologies and provide a trusted file sharing system and method based on blockchain and IPFS that ensures data security and privacy while enabling trusted file sharing, improving file transfer efficiency and reducing file storage.
[0006] To achieve the above objectives, a file-sharing method based on blockchain and IPFS is designed, as follows:
[0007] S1. Deploy the environment: On the server side, deploy multiple blockchain consensus nodes to form a trusted network environment for data storage; deploy multiple IPFS nodes to form a distributed storage cluster for hosting and sharing encrypted files; on the user side, deploy a blockchain application node and connect it to the blockchain consensus node on the server side for important process information of the on-chain file sharing process; deploy an IPFS node and connect it to the IPFS node cluster on the server side for local file storage and remote hosting.
[0008] S2. The sharing party selects the specified file sharing method based on the sharing target, which can be either sharing with all users or sharing with specified authorized users;
[0009] S21. If the sharing party chooses to share the file with all users, the sharing party will upload the file to the local IPFS node and upload the file sharing data in JSON format, consisting of the file verification information, the file's unique identifier ID in the IPFS system, and the user ID, to the local blockchain application node through the evidence storage module. The application node will then broadcast the data to the consensus node to complete the file sharing data evidence storage.
[0010] S22. If the sharing party chooses to share the file with a subset of authorized users, to protect file security, the sharing party encrypts the file using a threshold-based secret sharing method with the authorized party's corresponding public key before uploading the file to the local IPFS.
[0011] S3. After the sharing party specifies the sharing target, it selects the specified file sharing method based on the network and environment conditions, which can be divided into online sharing and offline sharing;
[0012] S31. After the sharing party completes step S21 or S22, it remains online. The receiving party queries the sharing party's storage details on the blockchain, obtains the file's unique identifier ID and unique feature value in IPFS, and retrieves the file from the IPFS node based on the IPFS ID.
[0013] S32. After the sharing party completes step S21 or S22, it hosts the file in the server's IPFS storage. After the receiving party comes online, the receiving party queries the sharing party's storage details on the blockchain, obtains the file's unique IPFS identifier ID and file unique feature value, and retrieves the file from the IPFS node based on the IPFS ID.
[0014] Preferably, in step S22, for large files, the overall file encryption efficiency is very low. Due to the characteristics of IPFS distributed storage, the first segment of the file can be encrypted to ensure that only users (IPFS nodes) who have all the segments of the file and can decrypt the first segment can restore the original file.
[0015] Preferably: In step S31, if step S22 is used, the file is decrypted and then restored, and the file verification feature value is calculated. If the file unique feature value = the file verification feature value, it proves that the received file has not been tampered with.
[0016] Preferably, in step S32, if step S22 is used, the file is decrypted and then restored, and the file verification feature value is calculated. If the file unique feature value equals the file verification feature value, it proves that the received file has not been tampered with.
[0017] Preferred options include: S4. When sharing a file, the sharing party specifies the effective time for file sharing. By deploying a blockchain smart contract, when the file exceeds the sharing period, the system deletes the file hosted by the local IPFS node and storage node. This function cannot delete the cached files of the recipient's local IPFS node; S5. After the recipient accepts the file, the system sets the local IPFS cached files to be automatically cleared after the file is received, or to be selectively deleted or retained as needed from the system cache management page.
[0018] This invention also relates to a file-sharing system employing a file-sharing method based on blockchain and IPFS, comprising:
[0019] The encryption module is used to fragment and encrypt files, manage the corresponding file permissions, connect to the storage module to interact with IPFS, and connect to the evidence storage module to interact with the blockchain.
[0020] The evidence storage module is used to upload the verification element information of shared files to the blockchain for evidence storage.
[0021] The storage module is used to store files and transfer files via the IPFS protocol;
[0022] The decryption module is used to obtain file fragments and decrypt the file.
[0023] Preferably, the encryption module includes: a file fragmentation unit, which fragments the file and encrypts the first fragment using a threshold secret sharing method between the sharing party's private key and the authorized receiver's public key; a file upload unit, which compresses the encrypted file fragments from the file fragmentation unit, uploads them to IPFS, and obtains the IPFS ID returned by IPFS; an application unit, where the receiver provides the sharing party with a public key and initiates a file sharing request; and an authorization unit, where the sharing party, after receiving and approving one or more sharing requests, authorizes the file to a specified public key user.
[0024] Preferably, the storage module includes: a local storage unit, an IPFS system deployed locally by both the sharing party and the receiving party, which can store shared files; a managed storage unit, where files shared by the sharing party can be stored either locally on the deployed IPFS system or managed on a server-side IPFS cluster, with managed storage applied to offline file sharing; and a file transfer unit, where, when sharing files online, the receiving party directly pulls the files from the sharing party's IPFS node to their local machine; and, when sharing files offline, the sharing party notifies the server to transfer the files to the server-side IPFS cluster for managed storage, and the receiving party pulls the files from the server-side IPFS cluster when they come online.
[0025] Preferably, the decryption module includes: a file acquisition unit, which acquires the shared file from the IPFS system using the file's IPFS ID, and decompresses the file to obtain file fragments, wherein the first fragment is encrypted; and a file restoration unit, which uses the private key of the authorized recipient to decrypt the first fragment of the file fragments acquired by the file acquisition unit, and restores the decrypted fragments and other fragments to form a complete file.
[0026] Compared with the prior art, the advantages of this invention are:
[0027] 1. By uploading file verification information and file sharing operation process nodes to the blockchain in the form of JSON data, it is ensured that the file recipient can verify the authenticity of the file, and the file sharing operation is also recorded, which is convenient for subsequent audit and verification.
[0028] 2. By storing shared files in a distributed manner using IPFS, the risk of shared files being lost or tampered with is reduced, while also saving a significant amount of storage space;
[0029] 3. Transferring files via the IPFS protocol improves transmission efficiency and stability while saving significant bandwidth resources;
[0030] 4. By encrypting the first segment of a shared file using a threshold secret sharing method before sharing, it is possible to share the file with a specific recipient, while also eliminating concerns about users using files obtained from the server for malicious purposes, thus ensuring file security and privacy without affecting efficiency. Attached Figure Description
[0031] Figure 1 This is a flowchart of the file sharing method of the present invention;
[0032] Figure 2 This is a schematic diagram of the file sharing system module of the present invention;
[0033] Figure 3 This is a schematic diagram of the file sharing system of the present invention. Detailed Implementation
[0034] Example 1
[0035] See Figure 1 A trusted file sharing method based on blockchain and IPFS, the implementation steps of which include:
[0036] Step S1: Deploy the environment according to requirements. On the server side, deploy multiple blockchain consensus nodes to form a trusted network environment for data storage; deploy multiple IPFS nodes to form a distributed storage cluster for hosting and sharing encrypted files. On the user side, deploy a blockchain application node and connect it to the blockchain consensus nodes on the server side for important process information in the on-chain file sharing process; deploy an IPFS node and connect it to the server-side IPFS node cluster for local file storage and remote hosting.
[0037] Step S2: The sharing party selects the specified file sharing method based on the sharing recipients, which can be divided into sharing to all users and sharing to specified authorized users:
[0038] In step S21, if the sharing party chooses to share the file with all users, the sharing party will upload the file to the local IPFS node and upload the file sharing data in JSON format, consisting of file verification information (including file MD5 hash, file name, file size, file description, upload time, etc.), the file's unique identifier ID in the IPFS system (i.e., IPFS ID), and the user ID, to the local blockchain application node via the notarization module. The application node will then broadcast the data to the consensus node to complete the notarization of the file sharing data.
[0039] In step S22, the sharing party chooses to share the file with a subset of authorized users. To protect file security, before uploading the file to the local IPFS, the sharing party first encrypts the file using a threshold secret sharing method with the corresponding public key of the authorized party. For large files, overall file encryption is very inefficient. Due to the distributed storage characteristics of IPFS, the first segment of the file can be encrypted, ensuring that only users (IPFS nodes) who have all the file segments and can decrypt the first segment can restore the original file.
[0040] Step S3: After the sharing party specifies the sharing target, they can choose the specified file sharing method based on network and environment conditions, which can be divided into online sharing and offline sharing.
[0041] In step S31, after the sharing party completes operation S21 or S22, it remains online. The receiving party queries the blockchain for the sharing party's evidence details, obtaining the file's unique IPFS identifier ID (i.e., IPFS ID) and file unique feature value (MD5). The receiving party can retrieve the file from the IPFS node based on the IPFS ID. If step S22 is used, the file is first decrypted and then restored, and the file verification feature value (MD5') is calculated. If MD5 = MD5', it proves that the received file has not been tampered with.
[0042] In step S32, after completing operation S21 or S22, the sharing party hosts the file in the server's IPFS storage. Once the receiving party comes online, it queries the blockchain for the sharing party's storage details, obtaining the file's unique IPFS identifier (IPFS ID) and unique file hash (MD5). The receiving party can retrieve the file from the IPFS node based on the IPFS ID. If step S22 is used, the file is first decrypted and then restored, and the file verification hash (MD5') is calculated. If MD5 = MD5', it proves that the received file has not been tampered with.
[0043] In a preferred embodiment of the present invention, the following steps may also be included:
[0044] Step S4: When sharing a file, the sharing party can specify the validity period of the file sharing. By deploying a blockchain smart contract, when the file exceeds the sharing period, the system can delete the file hosted on the local IPF node and storage node. This function cannot delete cached files on the recipient's local IPFS node;
[0045] Step S5: After the recipient receives the file, it can set the local IPFS cache file to be automatically cleared after the file is received, or it can selectively delete or retain the file as needed from the system cache management page.
[0046] Example 2
[0047] SeeFigure 2 and Figure 3 A file-sharing system employing the blockchain and IPFS-based file-sharing method described in the above embodiments includes the following modules:
[0048] 1. The encryption module is used to fragment and encrypt files, manage corresponding file permissions, and connect to the storage module for interaction with IPFS, and to the evidence storage module for interaction with the blockchain. Specifically, the encryption module consists of a file fragmentation unit, a file upload unit, an application unit, and an authorization unit.
[0049] The file fragmentation unit divides the file into fragments and encrypts the first fragment using a threshold secret sharing method using the private key of the sharing party and the public key of the authorized receiver.
[0050] The file upload unit compresses the encrypted file fragments from the file fragmentation unit, uploads them to IPFS, and obtains the IPFS ID returned by IPFS.
[0051] The request unit receives a request from the sharing party to provide a public key and initiate file sharing;
[0052] The authorization unit is a process where, after receiving and approving one or more sharing requests, the sharing party authorizes the file to a designated public key user.
[0053] 2. The evidence storage module is used to upload verification information such as the MD5 code and IPFS ID of shared files to the blockchain for evidence storage.
[0054] 3. Storage module, used for storing files and transferring files via the IPFS protocol. Storage units include local storage units, managed storage units, and file transfer units.
[0055] Local storage units are IPFS systems deployed locally by both the sharing and receiving parties, which can store shared files.
[0056] Hosted storage units allow users to share files not only locally on an IPFS system, but also on a server-side IPFS cluster. Hosted storage is used for offline file sharing.
[0057] In the file transfer unit, when sharing files online, the recipient can directly pull the file from the sharer's IPFS node to their local machine; when sharing files offline, the sharer notifies the server to transfer the file to the server's IPFS cluster for hosting and storage, and the recipient can pull the file from the server's IPFS cluster when they come online.
[0058] 4. Decryption module, used to obtain file fragments and decrypt the file. The decryption module includes a file acquisition unit and a file restoration unit.
[0059] The file acquisition unit retrieves the shared file from the IPFS system using the file's IPFS ID, and decompresses the file to obtain file fragments, with the first fragment being encrypted.
[0060] The file restoration unit uses the authorized recipient's private key to decrypt the first fragment of the file obtained from the file acquisition unit, and then restores the decrypted fragment and other fragments into a complete file.
[0061] The above description is merely a specific embodiment of the invention, but the scope of protection of the invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the technical scope disclosed in the invention, based on the technical solutions and novel concepts of the invention, should be covered within the scope of protection of the invention.
Claims
1. A file-sharing method based on blockchain and IPFS, characterized in that... The method is as follows: S1. Deploy the environment: On the server side, deploy multiple blockchain consensus nodes to form a trusted network environment for data storage; deploy multiple IPFS nodes to form a distributed storage cluster for hosting and sharing encrypted files; on the user side, deploy a blockchain application node and connect it to the blockchain consensus node on the server side for important process information of the on-chain file sharing process; deploy an IPFS node and connect it to the IPFS node cluster on the server side for local file storage and remote hosting. S2. The sharing party selects the specified file sharing method based on the sharing target, which can be either sharing with all users or sharing with specified authorized users; S21. If the sharing party chooses to share the file with all users, the sharing party will upload the file to the local IPFS node and upload the file sharing data in JSON format, consisting of the file verification information, the file's unique identifier ID in the IPFS system, and the user ID, to the local blockchain application node through the evidence storage module. The application node will then broadcast the data to the consensus node to complete the file sharing data evidence storage. S22. The sharing party chooses to share the file with some authorized users. To protect the file security, before uploading the file to the local IPFS, the sharing party first encrypts the file using the authorized party's corresponding public key through threshold secret sharing. In step S22, when the file is a large file, the first segment of the file is encrypted to ensure that only users who have obtained all segments of the file and can decrypt the first segment can restore the original file. S3. After specifying the sharing target, the sharing party selects the specified file sharing method based on network and environment conditions. File sharing methods are divided into online sharing and offline sharing; S31. After the sharing party completes step S21 or S22, it remains online. The receiving party queries the sharing party's evidence storage details on the blockchain to obtain the file's unique identifier ID and unique feature value in IPFS. The receiving party retrieves the file from the IPFS node based on the IPFS ID. In step S31, if step S22 is used, the file is decrypted and then restored. The file verification feature value is calculated. If the file's unique feature value equals the file verification feature value, it proves that the received file has not been tampered with. S32. After the sharing party completes step S21 or S22, it hosts the file in the server's IPFS storage. After the receiving party comes online, the receiving party queries the sharing party's storage details on the blockchain to obtain the file's unique IPFS identifier ID and file unique feature value. The receiving party retrieves the file from the IPFS node based on the IPFS ID. In step S32, if step S22 is used, the file is first decrypted and then restored, and the file verification feature value is calculated. If the file unique feature value = the file verification feature value, it proves that the received file has not been tampered with.
2. The file sharing method based on blockchain and IPFS as described in claim 1, characterized in that... Also includes S4. When sharing a file, the sharing party specifies the effective time of the file sharing. By deploying a blockchain smart contract, when the file exceeds the sharing period, the system deletes the file hosted by the local IPFS node and storage node. This S4 cannot delete the cached files of the receiving party's local IPFS node. S5. After the recipient receives the file, set it to automatically clear the local IPFS cache file after the file reception is complete, or selectively delete or retain it as needed from the system cache management page.
3. A file-sharing system employing the file-sharing method based on blockchain and IPFS as described in claim 1, characterized in that... include The encryption module is used to fragment and encrypt files, manage the corresponding file permissions, connect to the storage module to interact with IPFS, and connect to the evidence storage module to interact with the blockchain. The evidence storage module is used to upload the verification element information of shared files to the blockchain for evidence storage. The storage module is used to store files and transfer files via the IPFS protocol; The decryption module is used to obtain file fragments and decrypt the file.
4. The file sharing system as described in claim 3, characterized in that... The encryption module includes The file fragmentation unit divides the file into fragments and encrypts the first fragment using a threshold secret sharing method using the private key of the sharing party and the public key of the authorized receiver; The file upload unit compresses the encrypted file fragments from the file fragmentation unit, uploads them to IPFS, and obtains the IPFS ID returned by IPFS. The requesting unit receives a request from the sharing party, which includes the public key and initiates a file sharing process. The authorization unit is a process where, after receiving and approving one or more sharing requests, the sharing party authorizes the file to a designated public key user.
5. The file sharing system as described in claim 3, characterized in that... The storage module includes Local storage units are IPFS systems deployed locally by both the sharing and receiving parties, which can store shared files; Hosted storage units are used for sharing files with other parties. In addition to storing the files on a locally deployed IPFS system, the files can be hosted on a server-side IPFS cluster. Hosted storage is used for offline file sharing. In the file transfer unit, when sharing files online, the recipient directly pulls the file from the sharer's IPFS node to their local machine; when sharing files offline, the sharer notifies the server to transfer the file to the server's IPFS cluster for hosting and storage, and the recipient pulls the file from the server's IPFS cluster when they come online.
6. The file sharing system as described in claim 3, characterized in that... The decryption module includes The file acquisition unit retrieves the shared file from the IPFS system using the file's IPFS ID, and decompresses the file to obtain file fragments, with the first fragment being encrypted. The file restoration unit uses the authorized recipient's private key to decrypt the first fragment of the file obtained from the file acquisition unit, and then restores the decrypted fragment and other fragments into a complete file.
Citation Information
Patent Citations
File sharing method and system based on block chain, electronic equipment and storage medium
CN114650144A