A method and device for resource sharing based on blockchain

By dividing resource files into blocks, generating routing tables, and storing them in the blockchain, the security and non-tamperability issues of the blockchain system when storing large files are solved, and safe sharing and efficient storage of resource files are achieved.

CN112328565BActive Publication Date: 2024-09-06CHINA UNIONPAY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011228411.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-06
Publication Date
2024-09-06
Estimated Expiration
2040-11-06

AI Technical Summary

Technical Problem

When the existing blockchain system handles large file storage, it uses an off-chain system, which cannot achieve consensus on the files on the blockchain, resulting in the inability to guarantee the security and non-tamperability of the files.

Method used

By dividing resource files into blocks, a routing table is generated, and the blocks and routing tables are stored in the blockchain to achieve storage and consensus of resource files on the blockchain, ensuring the security and non-tamperability of files.

Benefits of technology

It realizes the safe storage and sharing of resource files on the blockchain, prevents files from being tampered with, and improves the processing capabilities and security of the blockchain system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112328565B
    Figure CN112328565B
Patent Text Reader

Abstract

The present invention discloses a method and device for resource sharing based on blockchain, the method comprising obtaining a resource file to be stored, processing the resource file into blocks to obtain a plurality of resource blocks, generating a routing table of the resource file according to the resource file and the plurality of resource blocks, and storing the plurality of resource blocks and the routing table in the blockchain. By processing the resource file into blocks to obtain a plurality of resource blocks, and then processing the plurality of resource blocks on the chain, the resource file can be stored on the blockchain, the security of the resource file when being shared can be ensured, and the resource file can be prevented from being tampered with.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a method and device for resource sharing based on blockchain. Background Art

[0002] With the development of computer technology, more and more technologies are applied in the financial field. Traditional finance is gradually transforming into financial technology. However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on technology. In the blockchain technology in the financial field, large file storage is an important research issue.

[0003] The existing blockchain system is limited by its processing power. To solve the problem of large file storage, it has always used an off-chain system, where only the file summary information is stored on the blockchain for evidence storage. However, this method of separating file storage from the blockchain system cannot achieve consensus on the file itself on the blockchain system, and thus cannot guarantee the security and immutability of the file. Summary of the invention

[0004] The embodiments of the present invention provide a method and device for resource sharing based on blockchain, so as to improve the security of resource sharing.

[0005] In a first aspect, an embodiment of the present invention provides a resource sharing method based on blockchain, comprising:

[0006] Get the resource file to be stored;

[0007] Processing the resource file in blocks to obtain a plurality of resource blocks; generating a routing table of the resource file according to the resource file and the plurality of resource blocks;

[0008] The plurality of resource chunks and the routing table are stored in a blockchain.

[0009] In the above technical solution, by dividing the resource file into blocks to obtain multiple resource blocks, and then uploading the multiple resource blocks to the chain, the resource file can be stored on the blockchain, which can ensure the security of resource file sharing and prevent the resource file from being tampered with.

[0010] Optionally, the resource file is processed into blocks to obtain multiple resource blocks, including:

[0011] The resource file is processed into blocks by using a byte stream processing method to obtain the multiple resource blocks.

[0012] Optionally, generating a routing table of the resource file according to the resource file and the multiple resource blocks includes:

[0013] Perform hash processing on each resource block to obtain a hash value of each resource block;

[0014] Generate a Merkle tree according to the hash value of each resource block;

[0015] Performing statistics on the resource file and each resource block to obtain file information of the resource file;

[0016] A routing table of the resource file is generated according to the hash value of each resource block, the root of the Merkle tree and the file information of the resource file.

[0017] Optionally, the file information of the resource file includes at least identification information, the number of resource blocks and serial numbers of the resource blocks.

[0018] Optionally, storing the multiple resource blocks and the routing table in a blockchain includes:

[0019] Determine whether there are resource blocks with the same hash value on the blockchain according to the hash value of each resource block, and if so, determine the resource blocks with different hash values ​​from the resource blocks on the blockchain;

[0020] The resource blocks having different hash values ​​from those on the blockchain and the routing table are stored in the blockchain.

[0021] In a second aspect, an embodiment of the present invention provides a resource sharing method based on blockchain, the method comprising:

[0022] Obtain identification information of the resource file to be queried;

[0023] Obtaining a routing table of the resource file to be queried from the blockchain according to the identification information of the resource file to be queried;

[0024] Obtaining each resource block of the resource file to be queried from the blockchain according to the routing table of the resource file to be queried;

[0025] Each resource block of the resource file to be queried is verified, and after determining that the verification passes, the resource blocks of the resource file to be queried are integrated according to the sequence numbers of the resource blocks in the routing table of the resource file to be queried to obtain the resource file to be queried.

[0026] Optionally, the routing table of the resource file to be queried includes a hash value of each resource block of the resource file to be queried;

[0027] The obtaining each resource block of the resource file to be queried from the blockchain according to the routing table of the resource file to be queried includes:

[0028] Using the hash value of each resource block of the resource file to be queried as a key, each resource block of the resource file to be queried is obtained from the blockchain.

[0029] Optionally, the routing table of the resource file to be queried is determined by a provider of the resource file to be queried according to hash values ​​of each resource block of the resource file to be queried and file information of the resource file to be queried.

[0030] Optionally, the verifying each resource block of the resource file to be queried includes:

[0031] Performing hash calculation on each resource block of the resource file to be queried to obtain a hash value of each resource block of the resource file to be queried;

[0032] Obtaining a root hash value of the Merkle tree according to the hash values ​​of each resource block of the resource file to be queried;

[0033] Determine whether the root hash value of the Merkle tree is the same as that in the routing table of the resource file to be queried, and if so, determine that the verification is passed, otherwise determine that the verification is not passed.

[0034] In a third aspect, an embodiment of the present invention provides a resource sharing device based on blockchain, comprising:

[0035] An acquisition unit, used for acquiring resource files to be stored;

[0036] A processing unit is used to process the resource file in blocks to obtain multiple resource blocks; generate a routing table for the resource file according to the resource file and the multiple resource blocks; and store the multiple resource blocks and the routing table in a blockchain.

[0037] Optionally, the processing unit is specifically used for:

[0038] The resource file is processed into blocks by using a byte stream processing method to obtain the multiple resource blocks.

[0039] Optionally, the processing unit is specifically used for:

[0040] Perform hash processing on each resource block to obtain a hash value of each resource block;

[0041] Generate a Merkle tree according to the hash value of each resource block;

[0042] Performing statistics on the resource file and each resource block to obtain file information of the resource file;

[0043] A routing table of the resource file is generated according to the hash value of each resource block, the root of the Merkle tree and the file information of the resource file.

[0044] Optionally, the file information of the resource file includes at least identification information, the number of resource blocks and serial numbers of the resource blocks.

[0045] Optionally, the processing unit is specifically used for:

[0046] Determine whether there are resource blocks with the same hash value on the blockchain according to the hash value of each resource block, and if so, determine the resource blocks with different hash values ​​from the resource blocks on the blockchain;

[0047] The resource blocks having different hash values ​​from those on the blockchain and the routing table are stored in the blockchain.

[0048] In a fourth aspect, an embodiment of the present invention provides a resource sharing device based on blockchain, comprising:

[0049] An acquisition unit, used to acquire identification information of a resource file to be queried;

[0050] A processing unit is used to obtain a routing table of the resource file to be queried from the blockchain according to the identification information of the resource file to be queried; obtain each resource block of the resource file to be queried from the blockchain according to the routing table of the resource file to be queried; verify each resource block of the resource file to be queried, and after determining that the verification passes, integrate each resource block of the resource file to be queried according to the sequence number of each resource block in the routing table of the resource file to be queried to obtain the resource file to be queried.

[0051] Optionally, the routing table of the resource file to be queried includes a hash value of each resource block of the resource file to be queried;

[0052] The processing unit is specifically used for:

[0053] Using the hash value of each resource block of the resource file to be queried as a key, each resource block of the resource file to be queried is obtained from the blockchain.

[0054] Optionally, the routing table of the resource file to be queried is determined by a provider of the resource file to be queried according to hash values ​​of each resource block of the resource file to be queried and file information of the resource file to be queried.

[0055] Optionally, the processing unit is specifically used for:

[0056] Performing hash calculation on each resource block of the resource file to be queried to obtain a hash value of each resource block of the resource file to be queried;

[0057] Obtaining a root hash value of the Merkle tree according to the hash values ​​of each resource block of the resource file to be queried;

[0058] Determine whether the root hash value of the Merkle tree is the same as that in the routing table of the resource file to be queried, and if so, determine that the verification is passed, otherwise determine that the verification is not passed.

[0059] In a fifth aspect, an embodiment of the present invention further provides a computing device, including:

[0060] A memory for storing program instructions;

[0061] The processor is used to call the program instructions stored in the memory and execute the above-mentioned blockchain-based resource sharing method according to the obtained program.

[0062] In a sixth aspect, an embodiment of the present invention also provides a computer-readable non-volatile storage medium, comprising computer-readable instructions. When a computer reads and executes the computer-readable instructions, the computer executes the above-mentioned blockchain-based resource sharing method. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0064] Figure 1 A schematic diagram of a system architecture provided for an embodiment of the present invention;

[0065] Figure 2 A flowchart of a resource sharing method based on blockchain provided by an embodiment of the present invention;

[0066] Figure 3 A schematic diagram of a resource file block processing provided by an embodiment of the present invention;

[0067] Figure 4 A schematic diagram of resource block transmission provided by an embodiment of the present invention;

[0068] Figure 5 A flowchart of a resource sharing method based on blockchain provided by an embodiment of the present invention;

[0069] Figure 6A schematic diagram of a process for contract transfer and signing provided by an embodiment of the present invention;

[0070] Figure 7 A schematic diagram of a resource sharing system structure provided by an embodiment of the present invention;

[0071] Figure 8 A schematic diagram of video clip file storage provided by an embodiment of the present invention;

[0072] Fig. 9 A schematic diagram of the structure of a resource sharing device based on blockchain provided by an embodiment of the present invention;

[0073] Fig.10 A schematic diagram of the structure of a blockchain-based resource sharing device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0074] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0075] Figure 1 A system architecture is provided for an embodiment of the present invention. Figure 1 As shown, the system architecture may include a blockchain 100 and multiple resource-sharing participants 200 (1-n);

[0076] Among them, the participants 200 can be different organizations participating in resource sharing. The multiple participants 200 are located in the same blockchain. When sharing a resource file, one of the participants 200 creates the resource file and uploads it to the blockchain, and then other resource-sharing participants 200 query the resource file from the blockchain.

[0077] The blockchain 100 is composed of multiple blocks and is used to store shared resource files.

[0078] It should be noted that the above Figure 1 The structure shown is only an example and is not limited to this embodiment of the present invention.

[0079] Based on the above description, Figure 2 The process of a blockchain-based resource sharing method provided by an embodiment of the present invention is shown in detail, and the process can be executed by a blockchain-based resource sharing device.

[0080] like Figure 2 As shown in the figure, the process specifically includes:

[0081] Step 201: Obtain resource files to be stored.

[0082] In the embodiment of the present invention, the resource file may be a file that needs to be shared, or may be a common file.

[0083] Step 202, the resource file is divided into blocks to obtain a plurality of resource blocks; a routing table of the resource file is generated according to the resource file and the plurality of resource blocks.

[0084] Among them, the resource file can be processed in blocks according to the preset block size by using the byte stream processing method to obtain multiple resource blocks. Then, each resource block is hashed to obtain the hash value of each resource block. According to the hash value of each resource block, a Merkle tree is generated, and the resource file and each resource block are counted to obtain the file information of the resource file. Finally, according to the hash value of each resource block, the root of the Merkle tree and the file information of the resource file, a routing table of the resource file is generated. The preset block size can be set based on experience. Among them, the file information of the resource file includes at least identification information, the number of resource blocks and the sequence number of the resource blocks, etc., and can also include information such as the resource size, the size of the resource block and the start and end bytes of the resource block (the start byte and the end byte in the original file). The identification information can be information such as the file name and identity identification number of the resource file. The root of the Merkle tree is the root hash value of the Merkle tree.

[0085] Specifically, Figure 3 As shown, the resource file resources are stored in the form of blocks on the blockchain to make up for the lack of processing power of the blockchain system. In order to ensure the availability of resources, it is necessary to create a resource routing table to retrieve the specific information of each block and obtain the file. The resource routing table consists of two parts: the routing table header contains: resource name, the root hash of the merkle tree, the resource size and the total number of resource blocks; the routing table body contains: the specific information of each block, that is, the block hash obtained by hashing the block resource, the sequence number of the block in the file (based on this field to ensure that each block can be pieced together into a complete file), the size of the resource block, and the starting byte and ending byte number of the resource block in the original file. The specific process is as follows:

[0086] 1. Resource files can be processed in blocks by byte stream processing. The specific implementation plan is to convert the resource file into a byte input stream and divide the resource file input stream according to the preset block size, such as 300kb. It can be found that the block size of the previous sequence of resource blocks is 300kb, and only the last block may be smaller than 300kb. In this way, the block operation of the file is completed.

[0087] 2. Each resource block is hashed to obtain the hash value of each block resource, which is the block hash field in the routing table. This field is also the key value for subsequent block files to be stored on the chain.

[0088] 3. In order to ensure that the block files cannot be tampered with, a merkle tree is constructed through each resource block, and the merkle root value is filled into the merkle root field of the routing table. This field can be used as the basis for resource verification. If the block file is tampered with, it can be verified through this value.

[0089] 4. Process the resource file and each block file to obtain the resource size, block number, block sequence number, block size and block start and end bytes to obtain a complete resource routing table.

[0090] It should be noted that the method of obtaining the routing table in the embodiment of the present invention can be processed off-chain, that is, the client of the participant processes it. It can also be processed on-chain using smart contracts. It should be noted that using smart contracts to process resource blocks on-chain to obtain the corresponding routing table also falls within the scope of protection of the embodiment of the present invention.

[0091] Step 203: store the multiple resource blocks and the routing table in a blockchain.

[0092] After obtaining each resource block and routing table, the chain operation can be performed, that is, each resource block and routing table can be stored in the blockchain. This step can be done by interacting with the smart contract of the blockchain system through the blockchain SDK to complete the chain processing of each resource block and resource routing table information of the file. For example, it can be achieved through the file transfer module, where Figure 4 As shown, the file transfer module can have the following functions:

[0093] 1. Resource blocks generally exist in the system in the form of byte arrays. However, the application system and the underlying smart contract language of the blockchain are different. For example, the application system is Java and the Fabric system smart contract language is Go. The two languages ​​have different byte value ranges. Java is [-128, 127] and Go is [0, 127]. Therefore, when interacting directly with file byte arrays, inconsistent byte values ​​will occur when performing chain operations. Therefore, it is necessary to set up a codec function block in the file transfer module to perform Base64 codec operations on the resource blocks, and perform file chain and query operations respectively.

[0094] 2. The file transfer module has a retry operation for failed uploads. Due to network problems and other reasons, the upload process may fail. Therefore, in order to ensure the successful upload of resource blocks, a retry operation is required for failed resource uploads.

[0095] 3. The file transfer module may include an asynchronous chain-up module. Since the resource file is large, there will be a delay in executing the chain-up operation. It is necessary to establish an asynchronous chain-up mechanism in the transmission module. After the asynchronous operation is completed, the chain-up result will be passed to the client of the participant.

[0096] 4. When the file is large, the number of blocks of the file may be large. Therefore, when performing file query operations, multi-threaded operations are required to ensure fast file query. Therefore, the file transfer module needs to have a multi-threaded file query function.

[0097] After the resource blocks are stored, the routing table storage operation can be performed. After the routing table storage is completed, the resource file storage process is completed.

[0098] When a participant who creates a resource file uploads the resource file to the blockchain, other resource sharing parties can query the resource file from the blockchain. Figure 5 The process shown includes:

[0099] Step 501: Obtain identification information of a resource file to be queried.

[0100] When a resource sharing point needs to query a resource file shared on the blockchain, it can send identification information of the resource file to be queried, and the identification information can be the file name, identity number and other information of the resource file.

[0101] Step 502: Obtain a routing table of the resource file to be queried from the blockchain according to the identification information of the resource file to be queried.

[0102] The routing table of the resource file to be queried can be queried from the blockchain through the identification information, which is stored on the blockchain by other resource providers.

[0103] Step 503: Obtain each resource block of the resource file to be queried from the blockchain according to the routing table of the resource file to be queried.

[0104] The routing table of the resource file to be queried includes the hash value of each resource block of the resource file to be queried. Specifically, the hash value of each resource block of the resource file to be queried can be used as a key to obtain each resource block of the resource file to be queried from the blockchain.

[0105] According to the above embodiment, the routing table of the resource file to be queried is determined by the provider of the resource file to be queried according to the hash value of each resource block of the resource file to be queried and the file information of the resource file to be queried. The specific determination method has been detailed in the above embodiment and will not be repeated here.

[0106] Step 504, verify each resource block of the resource file to be queried, and after determining that the verification passes, integrate each resource block of the resource file to be queried according to the sequence number of each resource block in the routing table of the resource file to be queried to obtain the resource file to be queried.

[0107] When the resource blocks of the resource file to be queried are obtained, they can be integrated according to the sequence numbers of the resource blocks. Before that, each resource block needs to be verified. Only after the verification passes can it be indicated that the resource file has not been tampered with.

[0108] Among them, when verifying the resource blocks, each resource block of the resource file to be queried can be hashed to obtain the hash value of each resource block of the resource file to be queried, and then the root hash value of the Merkle tree is obtained according to the hash value of each resource block of the resource file to be queried. Finally, it is determined whether the root hash value of the Merkle tree is the same as that in the routing table of the resource file to be queried. If so, it is determined that the verification is passed, otherwise it is determined that the verification is not passed.

[0109] For example, according to the resource name, the routing table information of the resource is obtained from the chain. The routing table information includes the hash value and serial number of each resource block. The hash value is used as the key information to obtain each resource block from the chain.

[0110] Perform hash verification on the obtained resource blocks to check whether the hashed resource blocks are the same as the key values ​​of the resource blocks in the routing table. Perform merkle root hash calculation on the resource blocks to check whether the obtained value is equal to the merkle root in the routing table. If the verification passes, it proves that the resource file has not been tampered with.

[0111] Finally, according to the resource block sequence number in the routing table, the resource blocks are integrated in order. The method is opposite to the block process. Each resource block is converted into stream information in order and then the files are spliced. After the integration is completed, the resource file is output to obtain the original resource file.

[0112] In addition, with the improvement of blockchain processing performance, the above-mentioned file block processing or splicing process can be carried out in the smart contract on the blockchain.

[0113] It should be noted that in order to avoid repeatedly uploading the same resource block to the blockchain, which reduces the processing capacity of the blockchain, when multiple resource blocks and routing tables are put on the blockchain, it is possible to first determine whether there are resource blocks with the same hash value on the blockchain based on the hash value of each resource block. If so, determine the resource blocks with different hash values ​​on the blockchain among the multiple resource blocks. Finally, the resource blocks and routing tables with different hash values ​​on the blockchain are put on the blockchain. This method can improve the processing capacity of the blockchain and increase processing efficiency.

[0114] In order to better explain the embodiments of the present invention, the above-mentioned blockchain-based resource sharing process will be described below in a specific implementation scenario.

[0115] Embodiment 1: Multi-party contract signing solution.

[0116] In business scenarios involving multi-party cooperation, all parties are generally required to sign the contract together. The existing method is generally that one party drafts the contract, and the other parties review the contract and finalize the draft. After no objection is raised, the parties sign the contract separately. Generally, the contract is mailed to the other party after one party signs it, until all parties have signed it. If there are many companies involved and they are far apart, the entire process will be long and inefficient.

[0117] This embodiment adopts Fabric as the underlying blockchain to realize a blockchain-based multi-party contract signing blockchain platform. Using the solution proposed in this patent, the multi-party contract signing starts from the finalization, and the finalized contract file is uploaded to the blockchain system in blocks. The participating parties download the finalized file from the blockchain system, and upload the signed file to the blockchain platform. If the parties have a signing order, they can sign it in sequence on the blockchain system.

[0118] Based on the above resource file sharing process, the process steps for signing a multi-party contract are as follows:

[0119] 1. The parties involved divide the finalized electronic version of the contract into blocks and construct a routing table for the finalized contract file.

[0120] 2. Upload each finalized contract block file to the blockchain system through the file transfer module and blockchain SDK, and store it with the hash value of the file block as the key and the file block itself as the value. After the file block information is uploaded, the finalized contract routing table is stored on the chain.

[0121] 3. After obtaining the finalized contract document through the query verification module, Company A signs it. After completion, the electronic version of the contract signed by Company A is uploaded to the blockchain system. Figure 6It can be seen that the contract document signed by Company A may only differ from the final draft document in the last block. Therefore, when uploading the file, Company A only needs to upload the last block that is different from the final draft document, and the rest can reuse the final draft contract document.

[0122] 3. After Company A has uploaded the contract, Company B can obtain the contract signed by Company A through the file routing table signed by Company A. After Company B gets the contract, it signs it. After signing, similarly, Figure 6 As shown, you only need to upload the last block that is different from the one signed by Company A, and upload your own signed file routing table to the blockchain.

[0123] The process of multiple parties signing a contract provided by the embodiment of the present invention has the following advantages:

[0124] 1. Each version of the contract can be tracked on the chain. Through the routing table of each contract version, different contracts can be obtained. The signing process is placed on the chain to ensure that the entire process is credible and can greatly shorten the time cost of mailing contracts.

[0125] 2. When signing a contract, generally only a few blocks of the file will be changed. Therefore, when the signed file is uploaded to the chain, only the changed parts need to be stored on the chain, and the remaining unchanged parts do not need to be uploaded to the chain repeatedly, which can greatly reduce the storage pressure. Due to the existence of the resource routing table, it can ensure that the file has not been modified, and the original text of each state of the file can be obtained.

[0126] It should be noted that the embodiments of the present invention are only for assisting in explaining the core content of the present invention. When it is applied in practice, privacy protection, encryption, etc. also need to be considered.

[0127] Embodiment 2: Distributed video website clip storage.

[0128] In addition to the movies, TV shows, open courses and other resources provided by the website itself, there is also a part for users to create secondary works based on the website's movies, TV and other resources, which is commonly known as film and television editing. For this type of scenario, the embodiment of the present invention considers implementing a distributed video website platform, with Fabric as the underlying blockchain platform, on which resource storage and query smart contracts are deployed.

[0129] Based on the above resource sharing process, the implementation steps of the distributed video website clip storage case are as follows:

[0130] 1. Through Figure 7 The resource sharing system structure shown divides resources such as movies and television into resource blocks through a resource block module, and constructs a routing table for each resource file.

[0131] 2. Upload each resource block file to the blockchain system through the file transfer module and blockchain SDK, use the hash value of the resource block as the key and the resource block itself as the value for storage. After the information of each resource block is uploaded, the resource routing table is stored on the chain.

[0132] 3. If Figure 8 As shown, the clipped video created by the user for secondary creation is composed of the first block of the video clip file, the second block of resource file 1 and the last block of resource file 2. Therefore, for the user, when uploading the clipped file to the platform, it is actually only necessary to upload the first file block and the routing information of the clipped file.

[0133] 4. Since resource blocks are stored on the chain in the form of block hash values ​​as keys and resource blocks as values, as long as the block hash values ​​are consistent, the resource file information must be consistent. Therefore, when a clip file is uploaded to the blockchain, since some of the resource blocks it contains may have been stored on the chain, there is no need to store them repeatedly.

[0134] 5. When the user is watching or downloading the clip file, Figure 8 As shown, the various components of the clip file can be obtained by simply obtaining the block files through the routing table of the clip file.

[0135] This method can greatly reduce the storage of such applications, and resource blocks with the same hash value only need to be stored once. It can also be found that when using the solution designed by this patent, when downloading files, the various parts that make up the target file may come from different file blocks, and the target file can be successfully restored in the end.

[0136] The embodiment of the present invention proposes a resource sharing storage scheme based on blockchain. First, when the resource file is uploaded to the chain, the resource file is processed, the large resource is processed into blocks, and a routing table of the resource file is generated. Then the resource file block is uploaded to the chain, and the hash summary of the resource block is used as the key and the resource block itself is used as the value. After the resource file block is uploaded to the chain, the resource routing table is uploaded to the chain. Each participant can query each file block according to the file resource routing table, integrate the resource blocks, obtain the original file, and check whether the file has been tampered with and whether it is the source file. Since the resource is processed in blocks, the resource cutting size can be set to be small to meet the processing capacity of the blockchain at this stage; the user obtains each file block according to the file routing table, restores the resource file, and verifies the resource file; since the resource file block is stored in the file hash value, when uploading other resources, if there is a resource block with the same hash value, it is not necessary to upload it repeatedly. In the scenario where the resource changes are frequent and each revision needs to be uploaded to the chain, the storage pressure of the blockchain system can be greatly reduced. This solution can effectively solve the problem of uploading large resource files to the chain.

[0137] In an embodiment of the present invention, a resource file to be stored is obtained, the resource file is processed into blocks to obtain multiple resource blocks, a routing table of the resource file is generated according to the resource file and the multiple resource blocks, and the multiple resource blocks and the routing table are put on the blockchain to enable other resource sharing parties to query the resource file from the blockchain. By processing the resource file into blocks to obtain multiple resource blocks, and then putting the multiple resource blocks on the blockchain, the resource file can be stored on the blockchain, which can ensure the security of the resource file when it is shared, and prevent the resource file from being tampered with.

[0138] Based on the same technical concept, Fig. 9 The structure of a blockchain-based resource sharing device provided by an embodiment of the present invention is exemplarily shown, and the device can execute a blockchain-based resource sharing process.

[0139] like Fig. 9 As shown, the device specifically includes:

[0140] The acquisition unit 901 is used to acquire the resource file to be stored;

[0141] The processing unit 902 is used to process the resource file into blocks to obtain multiple resource blocks; generate a routing table for the resource file according to the resource file and the multiple resource blocks; and store the multiple resource blocks and the routing table in the blockchain.

[0142] Optionally, the processing unit 902 is specifically configured to:

[0143] The resource file is processed into blocks by using a byte stream processing method to obtain the multiple resource blocks.

[0144] Optionally, the processing unit 902 is specifically configured to:

[0145] Perform hash processing on each resource block to obtain a hash value of each resource block;

[0146] Generate a Merkle tree according to the hash value of each resource block;

[0147] Performing statistics on the resource file and each resource block to obtain file information of the resource file;

[0148] A routing table of the resource file is generated according to the hash value of each resource block, the root of the Merkle tree and the file information of the resource file.

[0149] Optionally, the file information of the resource file includes at least identification information, the number of resource blocks and serial numbers of the resource blocks.

[0150] Optionally, the processing unit 902 is specifically configured to:

[0151] Determine whether there are resource blocks with the same hash value on the blockchain according to the hash value of each resource block, and if so, determine the resource blocks with different hash values ​​from the resource blocks on the blockchain;

[0152] The resource blocks having different hash values ​​from those on the blockchain and the routing table are stored in the blockchain.

[0153] Based on the same technical concept, Fig.10 The structure of a blockchain-based resource sharing device provided by an embodiment of the present invention is exemplarily shown, and the device can execute a blockchain-based resource sharing process.

[0154] like Fig.10 As shown, the device specifically includes:

[0155] The acquisition unit 1001 is used to acquire identification information of the resource file to be queried;

[0156] The processing unit 1002 is used to obtain the routing table of the resource file to be queried from the blockchain according to the identification information of the resource file to be queried; obtain each resource block of the resource file to be queried from the blockchain according to the routing table of the resource file to be queried; verify each resource block of the resource file to be queried, and after determining that the verification passes, integrate the resource blocks of the resource file to be queried according to the sequence numbers of each resource block in the routing table of the resource file to be queried to obtain the resource file to be queried.

[0157] Optionally, the routing table of the resource file to be queried includes a hash value of each resource block of the resource file to be queried;

[0158] The processing unit 1002 is specifically used for:

[0159] Using the hash value of each resource block of the resource file to be queried as a key, each resource block of the resource file to be queried is obtained from the blockchain.

[0160] Optionally, the routing table of the resource file to be queried is determined by a provider of the resource file to be queried according to hash values ​​of each resource block of the resource file to be queried and file information of the resource file to be queried.

[0161] Optionally, the processing unit 1002 is specifically configured to:

[0162] Performing hash calculation on each resource block of the resource file to be queried to obtain a hash value of each resource block of the resource file to be queried;

[0163] Obtaining a root hash value of the Merkle tree according to the hash values ​​of each resource block of the resource file to be queried;

[0164] Determine whether the root hash value of the Merkle tree is the same as that in the routing table of the resource file to be queried, and if so, determine that the verification is passed, otherwise determine that the verification is not passed.

[0165] Based on the same technical concept, an embodiment of the present invention further provides a computing device, including:

[0166] A memory for storing program instructions;

[0167] The processor is used to call the program instructions stored in the memory and execute the above-mentioned blockchain-based resource sharing method according to the obtained program.

[0168] Based on the same technical concept, an embodiment of the present invention also provides a computer-readable non-volatile storage medium, including computer-readable instructions. When a computer reads and executes the computer-readable instructions, the computer executes the above-mentioned blockchain-based resource sharing method.

[0169] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0170] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0171] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0172] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0173] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A resource sharing method based on blockchain, characterized in that: include: Get the resource file to be stored; Processing the resource file in blocks to obtain multiple resource blocks; Generate a routing table of the resource file according to the resource file and the multiple resource blocks; the routing table of the resource file includes a hash value of each resource block, a root of a Merkle tree and file information of the resource file, and the Merkle tree is generated according to the hash value of each resource block; Determine whether there are resource blocks with the same hash value on the blockchain according to the hash value of each resource block, and if so, determine the resource blocks with different hash values ​​from the resource blocks on the blockchain; Performing an on-chain operation, the on-chain operation comprising storing the resource blocks having different hash values ​​from those on the blockchain and the routing table of the resource file in the blockchain; If the on-chain operation fails, a retry operation is performed on the resource blocks or routing tables that failed to be on-chain; after the storage of the resource blocks with hash values ​​different from those on the blockchain and the routing tables of the resource files is completed, the on-chain results are transmitted to other participants in resource sharing.

2. The method according to claim 1, characterized in that The resource file is processed into blocks to obtain multiple resource blocks, including: The resource file is processed into blocks by using a byte stream processing method to obtain the multiple resource blocks.

3. The method according to claim 1 or 2, characterized in that The file information of the resource file at least includes identification information, the number of resource blocks and the sequence numbers of the resource blocks.

4. A resource sharing method based on blockchain, characterized in that: The blockchain includes resource blocks and a routing table corresponding to a resource file stored by a method according to any one of claims 1 to 3, wherein the method includes: Obtain identification information of the resource file to be queried; Obtaining a routing table of the resource file to be queried from the blockchain according to the identification information of the resource file to be queried; the routing table of the resource file to be queried is determined by the provider of the resource file to be queried according to the hash value of each resource block of the resource file to be queried and the file information of the resource file to be queried, and the routing table of the resource file to be queried includes the hash value of each resource block of the resource file to be queried; any resource block on the blockchain is stored when it is determined that there is no hash value identical to that of the resource block on the blockchain; According to the routing table of the resource file to be queried, using the hash value of each resource block of the resource file to be queried as a key, obtaining each resource block of the resource file to be queried from the blockchain; Each resource block of the resource file to be queried is verified, and after determining that the verification passes, the resource blocks of the resource file to be queried are integrated according to the sequence numbers of the resource blocks in the routing table of the resource file to be queried to obtain the resource file to be queried.

5. The method according to claim 4, characterized in that The verifying each resource block of the resource file to be queried includes: Performing hash calculation on each resource block of the resource file to be queried to obtain a hash value of each resource block of the resource file to be queried; Obtaining a root hash value of the Merkle tree according to the hash values ​​of each resource block of the resource file to be queried; Determine whether the root hash value of the Merkle tree is the same as that in the routing table of the resource file to be queried, and if so, determine that the verification is passed, otherwise determine that the verification is not passed.

6. A resource sharing storage device based on blockchain, characterized in that: include: An acquisition unit, used for acquiring resource files to be stored; A processing unit, used for processing the resource file into blocks to obtain a plurality of resource blocks; Generate a routing table of the resource file according to the resource file and the multiple resource blocks; the routing table of the resource file includes a hash value of each resource block, a root of a Merkle tree and file information of the resource file, and the Merkle tree is generated according to the hash value of each resource block; Determine whether there are resource blocks with the same hash value on the blockchain according to the hash value of each resource block, and if so, determine the resource blocks with different hash values ​​from the blockchain among the multiple resource blocks; perform an on-chain operation, which includes storing the resource blocks with different hash values ​​from the blockchain and the routing table of the resource file in the blockchain; if the on-chain operation fails, perform an on-chain retry operation for the resource blocks or routing table that failed to be on-chain; after the storage of the resource blocks with different hash values ​​from the blockchain and the routing table of the resource file is completed, transmit the on-chain result to other participants participating in resource sharing.

7. The device according to claim 6, characterized in that The processing unit is specifically used for: The resource file is processed into blocks by using a byte stream processing method to obtain the multiple resource blocks.

8. The device according to claim 6 or 7, characterized in that The file information of the resource file at least includes identification information, the number of resource blocks and the sequence numbers of the resource blocks.

9. A resource sharing device based on blockchain, characterized in that: The blockchain includes resource blocks and a routing table corresponding to a resource file stored by the method according to any one of claims 1 to 3, and the device includes: An acquisition unit, used to acquire identification information of a resource file to be queried; A processing unit, configured to obtain a routing table of the resource file to be queried from the blockchain according to the identification information of the resource file to be queried; the routing table of the resource file to be queried is determined by the provider of the resource file to be queried according to the hash values ​​of the resource blocks of the resource file to be queried and the file information of the resource file to be queried; the routing table of the resource file to be queried includes the hash values ​​of the resource blocks of the resource file to be queried; any resource block on the blockchain is stored when it is determined that there is no hash value identical to the resource block on the blockchain; according to the routing table of the resource file to be queried, the hash values ​​of the resource blocks of the resource file to be queried are used as keys to obtain the resource blocks of the resource file to be queried from the blockchain; the resource blocks of the resource file to be queried are verified, and after the verification is determined to be passed, the resource blocks of the resource file to be queried are integrated according to the sequence numbers of the resource blocks in the routing table of the resource file to be queried to obtain the resource file to be queried.

10. The device according to claim 9, characterized in that The processing unit is specifically used for: Performing hash calculation on each resource block of the resource file to be queried to obtain a hash value of each resource block of the resource file to be queried; Obtaining a root hash value of the Merkle tree according to the hash values ​​of each resource block of the resource file to be queried; Determine whether the root hash value of the Merkle tree is the same as that in the routing table of the resource file to be queried, and if so, determine that the verification is passed, otherwise determine that the verification is not passed.

11. A computing device, characterized in that: include: A memory for storing program instructions; A processor, configured to call the program instructions stored in the memory, and execute the method according to any one of claims 1 to 5 according to the obtained program.

12. A computer-readable non-volatile storage medium, characterized in that: The method comprises computer-readable instructions, and when a computer reads and executes the computer-readable instructions, the computer is caused to execute the method according to any one of claims 1 to 5.