File transmission method and system, electronic equipment and storage medium

By using the Merkle tree data structure and Merkle proof parameters on the blockchain, independent verification of file content is achieved, solving the problem of time-consuming file transmission and verification processes with large amounts of data, improving efficiency and reducing resource consumption.

CN118631801APending Publication Date: 2024-09-10CHINA STATE SHIPBUILDING CORP LTD RESEARCH INSTITUTE 719 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410893717.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-04
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

When the amount of data is large, the existing blockchain-based file transfer solution needs to collect all file contents before performing summary verification, resulting in a long time-consuming transmission and verification process.

Method used

The file is split into multiple leaf nodes using the Merkle tree data structure, and the handshake is completed on the blockchain. The network message sent contains the target leaf node and Merkle proof parameters, allowing the receiving end to independently verify each network message. file contents in .

Benefits of technology

It improves file verification efficiency, reduces resource consumption caused by intermediate data, and reduces delays caused by temporary data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118631801A
    Figure CN118631801A
Patent Text Reader

Abstract

The invention relates to a file transmission method and system, electronic equipment and a storage medium, which are applied to the technical field of computers, and the method comprises the following steps: determining the maximum transmission data volume of a single network message; a Merkel tree data structure of a to-be-transmitted file is constructed, the Merkel tree data structure comprises a plurality of leaf nodes and Merkel proof parameters of each leaf node, and the leaf nodes carry contents in the to-be-transmitted file; handshake with a receiving end is completed based on the block chain; and sending a network message to the receiving end, the network message comprising a target leaf node and a target Merkel proof parameter of the target leaf node, so that the receiving end verifies the target leaf node based on the target Merkel proof parameter.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a file transmission method, system, electronic device and storage medium. Background Art

[0002] For blockchain-based file transfer solutions, blockchain is generally responsible for the storage of file content summaries, and the summary evidence value is generally used for subsequent file content verification. The generation logic of the summary value is generally the process of calculating a final hash value, and the specific generation process is generally to calculate the hash of the complete content once or to calculate the hash of the file content in segments, then integrate the hash list and calculate the final hash again.

[0003] The file receiver generally needs to receive all the file blocks or file fragments, integrate them into a complete file, and then perform summary verification. In this way, the data recipient can only verify the correctness of the file after receiving all the files. This means that all the received file fragment data is non-deterministic in the eyes of the receiver, that is, it is intermediate data and cannot be directly used as deterministic or correct final file data. After receiving all the file contents, it is necessary to perform a summary calculation of the full content. Especially for files with large data volumes, this process is very time-consuming. Summary of the invention

[0004] The present application provides a file transmission method, system, electronic device and storage medium to solve the problem in the prior art that after all file contents are collected, a summary calculation of the entire content needs to be performed, and the transmission and verification process is very time-consuming, especially for files with large data volumes.

[0005] In a first aspect, an embodiment of the present application provides a file transmission method, which is applied to a sending end, and the method includes:

[0006] Determine the maximum amount of data that can be transmitted for a single network message;

[0007] Constructing a Merkle tree data structure of the file to be transmitted, wherein the Merkle tree data structure includes a plurality of leaf nodes and a Merkle proof parameter of each leaf node, wherein the leaf node carries the content of the file to be transmitted;

[0008] Complete the handshake with the receiving end based on the blockchain;

[0009] A network message is sent to the receiving end, wherein the network message includes a target leaf node and a target Merkel proof parameter of the target leaf node, so that the receiving end verifies the target leaf node based on the target Merkel proof parameter, and the target leaf node is at least one of the multiple leaf nodes.

[0010] Optionally, construct a Merkle tree data structure of the file to be transferred, including:

[0011] Splitting the file to be transmitted according to the first file size to obtain multiple sub-files;

[0012] Determine that at least one of the sub-files is a leaf node; the second file size of the leaf node is greater than or equal to the first file size;

[0013] Determine that the data structure composed of the leaf nodes is the Merkle tree data structure.

[0014] Optionally, determine the maximum amount of data that can be transmitted for a single network message, including:

[0015] Obtain network configuration information with the receiving end;

[0016] Determine a transmission data range corresponding to the network configuration information;

[0017] A maximum value in the transmission data range is determined as the maximum transmission data amount.

[0018] In a second aspect, an embodiment of the present application provides a file transmission method, which is applied to a receiving end, and the method includes:

[0019] Complete the handshake with the sender based on the blockchain;

[0020] Acquire a network message sent by the sending end, wherein the network message includes a target leaf node carrying the content of the file to be transmitted and a target Merkel proof parameter of the target leaf node;

[0021] The target leaf node is verified based on the target Merkle proof parameters.

[0022] Optionally, completing the handshake with the sender based on the blockchain includes:

[0023] Obtaining meta information of the file to be transmitted on the chain from the sender; the meta information includes the file size of the file to be transmitted, the file Merkel proof parameters, the receiving end information and the sending end information;

[0024] Generate confirmation information for the meta-information, and upload the confirmation information to the chain; so that the sending end can obtain the confirmation information on the chain and complete the handshake with the sending end.

[0025] Optionally, the method further includes:

[0026] In the case where the target leaf node is successfully verified, determining the target position of the target leaf node in the file to be transmitted;

[0027] Starting from the target location, the target leaf node is persisted as a file.

[0028] Optionally, the method further includes:

[0029] In the case where the verification of the target leaf node fails, a retry message is sent to the sending end, so that the sending end resends the target leaf node that failed verification based on the retry message.

[0030] Optionally, the method further includes:

[0031] After the target leaf node is persisted, a confirmation message of the target leaf node is sent to the sending end, so that the sending end ignores the retry message of the target leaf node that has received the confirmation message.

[0032] In a third aspect, an embodiment of the present application provides a file transmission system, including: a sending end and a receiving end;

[0033] The transmitting end is used to determine the maximum transmission data volume of a single network message; construct a Merkle tree data structure of the file to be transmitted, the Merkle tree data structure includes multiple leaf nodes and Merkle proof parameters of each leaf node, and the leaf node carries the content of the file to be transmitted; complete the handshake with the receiving end based on the blockchain; send a network message to the receiving end, the network message includes a target leaf node and a target Merkle proof parameter of the target leaf node;

[0034] The receiving end is used to obtain the network message sent by the sending end; and verify the target leaf node based on the target Merkel proof parameter.

[0035] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0036] The memory is used to store computer programs;

[0037] The processor is used to execute the program stored in the memory to implement the file transfer method described in the first aspect or the second aspect.

[0038] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the file transfer method described in the first aspect or the second aspect.

[0039] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application determines the maximum transmission data volume of a single network message; constructs a Merkle tree data structure of the file to be transmitted, the Merkle tree data structure includes multiple leaf nodes and Merkle proof parameters of each leaf node, and the leaf node carries the content of the file to be transmitted; completes the handshake with the receiving end based on the blockchain; sends a network message to the receiving end, the network message includes a target leaf node, and a target Merkle proof parameter of the target leaf node, so that the receiving end verifies the target leaf node based on the target Merkle proof parameter. In this way, in the network message sent to the receiving end, the target leaf node and the corresponding target Merkle proof parameter are configured, so that the receiving end does not have to wait for all the contents of the files to be transmitted to be obtained before verification. The target Merkle proof parameter carried can realize independent verification of the file content in each network message, thereby improving the verification efficiency of the files to be transmitted and reducing the resource consumption caused by the temporarily stored intermediate data. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0042] Figure 1 A structural diagram of a file transmission system provided in one embodiment of the present application;

[0043] Figure 2 A flowchart of a file transmission method provided in one embodiment of the present application;

[0044] Figure 3 A schematic diagram of a Merkle tree structure provided in an embodiment of the present application;

[0045] Figure 4 A flowchart of a file transmission method provided by another embodiment of the present application;

[0046] Figure 5 A structural diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0048] Before further describing the embodiments of the present invention in detail, the nouns and terms involved in the embodiments of the present invention are described. The nouns and terms involved in the embodiments of the present invention are subject to the following explanations.

[0049] Blockchain: It is a new decentralized infrastructure and distributed computing paradigm that has gradually emerged and has attracted great attention and widespread concern from government departments, financial institutions, technology companies and capital markets. Blockchain technology has the characteristics of decentralization, time-series data, collective maintenance, programmability and security and reliability. It is particularly suitable for building programmable currency systems, financial systems and even macro-social systems.

[0050] Hash is to transform an input of any length (also called pre-image) into an output of fixed length through a hash algorithm. The output is the hash value. This conversion is a compression mapping, that is, the space of hash values ​​is usually much smaller than the space of inputs. Different inputs may hash to the same output, so it is impossible to uniquely determine the input value from the hash value. Simply put, it is a function that compresses a message of any length into a message digest of a fixed length.

[0051] Merkle tree: It is an important data structure of blockchain, which is used to quickly summarize and verify the existence and integrity of block data. Generally speaking, it is a way to hash a large number of data "blocks". It relies on splitting these data "blocks" into smaller units of data blocks. Each bucket block contains only a few data "blocks". Then take each bucket unit data block and hash it again, repeating the same process until the total number of remaining hashes becomes only 1.

[0052] According to an embodiment of the present application, a file transmission system is provided. Figure 1 , the system comprises: a sending end 101 and a receiving end 102;

[0053] The transmitting end is used to determine the maximum transmission data volume of a single network message; construct a Merkle tree data structure of the file to be transmitted, the Merkle tree data structure includes multiple leaf nodes and Merkle proof parameters of each leaf node, and the leaf node carries the content of the file to be transmitted; complete the handshake with the receiving end based on the blockchain; send a network message to the receiving end, the network message includes a target leaf node and a target Merkle proof parameter of the target leaf node;

[0054] The receiving end is used to obtain the network message sent by the sending end; and verify the target leaf node based on the target Merkel proof parameter.

[0055] In one embodiment of the present application, a file transmission method is provided, which can be applied to any form of electronic device, such as a terminal and a server at the sending end. Figure 2 As shown, the file transmission method includes:

[0056] Step 201: Determine the maximum transmission data volume of a single network message.

[0057] In some embodiments, the maximum transmission data volume indicates the maximum data volume of data content included in each network message sent when the sending end sends data to the receiving end.

[0058] In an optional embodiment, determining the maximum transmission data volume of a single network message includes:

[0059] Obtain network configuration information with the receiving end;

[0060] Determine a transmission data range corresponding to the network configuration information;

[0061] A maximum value in the transmission data range is determined as the maximum transmission data amount.

[0062] In some embodiments, the sending end is usually able to obtain network configuration information with the receiving end before sending data, such as network bandwidth, etc. If the network configuration information is different, it will affect the amount of data that can be transmitted between the two. Therefore, by obtaining the network configuration information, the maximum amount of transmitted data is determined, that is, the upper limit of the data amount of a file content transmission message.

[0063] It is understandable that the maximum amount of transmitted data may also be customized by the user.

[0064] Exemplarily, the maximum amount of data transmitted may be, but is not limited to, 10K.

[0065] It is understandable that, in addition to the network configuration information of the sender and receiver, the maximum amount of data transmitted is also determined based on the MerkleTree tree height, because the tree height directly affects the number of leaf nodes and the size of the MerkleProof parameter. For example, the corresponding relationship between the MerkleTree tree height and the maximum amount of data transmitted is set, and different MerkleTree tree heights correspond to different maximum amounts of data transmitted.

[0066] Step 202: construct a Merkle tree data structure of the file to be transmitted, wherein the Merkle tree data structure includes multiple leaf nodes and Merkle proof parameters of each leaf node, and the leaf nodes carry the content of the file to be transmitted.

[0067] In some embodiments, by constructing a Merkle tree data structure of the file to be transmitted, not only is it possible to split the file to be transmitted to avoid the file being too large and the transmission efficiency being low, but it is also possible to use Merkle proof parameters for verification to improve the efficiency of file verification.

[0068] The Merkle tree data structure may be, but is not limited to, any integer tree structure, such as a binary tree structure.

[0069] In an optional embodiment, the file to be transmitted is split according to a first file size to obtain a plurality of sub-files, and the first file size is smaller than the maximum transmission amount;

[0070] Determine at least one of the sub-files as a leaf node; the second file size of the leaf node is greater than or equal to the first file size and is less than the maximum transmission data amount;

[0071] Determine that the data structure composed of the leaf nodes is the Merkle tree data structure.

[0072] In some embodiments, the first file size can be set based on actual conditions. Usually, the read and write file size of the operating system is generally 4K, so based on operating system performance-friendly considerations, the first file size can be set to 4K or an integer multiple of 4K.

[0073] After the file to be transmitted is divided according to the first file size, at least one sub-file can be used as a leaf node. Based on network message transmission performance considerations, the second file size usually does not exceed the maximum transmission data volume.

[0074] Based on the above-mentioned related embodiments, when the maximum transmission data volume is 10K, one or two sub-files can constitute a leaf node.

[0075] For example, a sub-file constitutes a leaf node. Except for the last leaf node, the remaining leaf nodes are all 4K in size, and the content range of the last leaf node is (0,4K]; if the file to be transferred is 30K, there are 8 leaf nodes in MerkleTree, and the sizes are: 4K, 4K, 4K, 4K, 4K, 4K, 2K.

[0076] The process of constructing MerkleTree can be completed in memory. If the merkleTree data structure occupies too much memory, you can also consider using the local disk to temporarily store part of the data to reduce memory usage.

[0077] It should be noted that there is a mature algorithm solution for the scenario where the number of leaf nodes in the MerkleTree data structure is an odd number. This solution directly adopts the traditional MerkleTree algorithm for processing odd number nodes, which will not be repeated here.

[0078] Step 203: Complete the handshake with the receiving end based on the blockchain.

[0079] In some embodiments, the sending end and the receiving end complete a handshake protocol so that mutual authentication is achieved between the two ends.

[0080] In an optional embodiment, completing the handshake with the receiving end based on the blockchain includes:

[0081] Putting the meta information of the file to be transmitted on the chain, so that after the receiving end obtains the meta information on the chain, it generates confirmation information of the meta information and puts the confirmation information on the chain; the meta information includes the file size of the file to be transmitted, the file Merkel proof parameters, the receiving end information and the sending end information;

[0082] If the confirmation information is obtained on the chain, the handshake with the receiving end is completed.

[0083] In some embodiments, the meta-information may include but is not limited to the number of MerkleTree forks, the name of the file to be transferred, the ID of the file to be transferred, the size of the file to be transferred, the last update time, the initiator and receiver of the file to be transferred, the final MerkleRoot of the file to be transferred, and other basic information, which is stored on the chain.

[0084] Then, the receiving end obtains the transaction including the meta-information by polling or subscribing to the information on the chain, parses the meta-information, generates a confirmation transaction for the transmission request and stores it on the chain. Furthermore, the receiving end can also cache the meta-information locally and prepare to receive the file content.

[0085] After the sender obtains the confirmation information on the chain from the receiver through polling or subscribing to information on the chain, it is equivalent to the sender and the receiver completing a round of handshake protocol based on the blockchain for the transmission process of the file to be transmitted. The sender can then start transmitting specific file content data.

[0086] Step 204: Send a network message to the receiving end, wherein the network message includes a target leaf node and a target Merkel proof parameter of the target leaf node, so that the receiving end verifies the target leaf node based on the target Merkel proof parameter.

[0087] In some embodiments, the network information includes not only the target leaf node, that is, the content of the file to be transferred, but also the target Merkle proof parameters of the target leaf node, that is, MerkleProof data, wherein, when there are more than two target leaf nodes, the target Merkle proof parameters include the Merkle proof parameters corresponding to each leaf node.

[0088] The target leaf node in each network message is different, and all the leaf nodes are sent to the receiving end by sending multiple network messages.

[0089] For example, see Figure 3 The MerkleTree data structure shown in the figure has 4 layers in total. A single network message can contain 2 leaf nodes (taking each leaf node as 4K as an example) and a MerkleProof data of length 3 (32B*3=96B). Considering the amplification of some encoded data volume, such as the offset of the leaf node among all the leaf nodes of the MerkleTree, the maximum transmission data volume can be set to 10K to be sufficient to accommodate the above data.

[0090] Considering the simplicity of the protocol, a single network message can try to include as many leaf nodes as possible.

[0091] For example, the target leaf node in the network information is Figure 3 Taking leaf nodes 0 and 1 in as examples, the MerkleProof data mainly includes: branch node 1 and branch node 5.

[0092] The feasible structure of the network message transmitted by the sender may include: the starting offset of the leaf node list, the ending offset of the leaf node, and the MerkleProof data organized layer by layer from low to high.

[0093] Based on the same concept, a file transmission method is provided in the embodiment of the present application. The specific implementation of the method can refer to the description of the sending end method embodiment part, and the repeated parts will not be repeated. The method can be applied to any form of electronic equipment, such as the receiving end terminal and the server. Figure 4 As shown, the method mainly includes:

[0094] Step 401: Complete the handshake with the sender based on the blockchain.

[0095] In an optional embodiment, completing the handshake with the receiving end based on the blockchain includes:

[0096] Putting the meta information of the file to be transmitted on the chain, so that after the receiving end obtains the meta information on the chain, it generates confirmation information of the meta information and puts the confirmation information on the chain; the meta information includes the file size of the file to be transmitted, the file Merkel proof parameters, the receiving end information and the sending end information;

[0097] If the confirmation information is obtained on the chain, the handshake with the receiving end is completed.

[0098] Step 402: Obtain a network message sent by the sending end, wherein the network message includes a target leaf node carrying the content of the file to be transmitted and a target Merkel proof parameter of the target leaf node.

[0099] In some embodiments, the network message may be first sent by the sender to the blockchain and then obtained by the receiver from the blockchain, or may be directly sent by the sender to the receiver.

[0100] Step 403: Verify the target leaf node based on the target Merkle proof parameter.

[0101] In some embodiments, the receiving end uses the size of the file to be transmitted in the stored metadata to verify whether the number of elements in the MerkleProof data is correct; and verifies whether the content of the file being transmitted is correct through the start and end offsets of the leaf node and the MerkleProof provided by the sending end.

[0102] In addition, since each network message carries the proof information that needs to be verified (ie, MerkleProof), the network messages do not affect each other. Therefore, the network messages can be transmitted in parallel, thereby improving the transmission efficiency of the files to be transmitted.

[0103] Furthermore, in order to reduce the amount of data in the network message, the receiving end may also perform verification based on the local received data of the receiving end.

[0104] Specifically, after receiving the meta-information, the receiving end will locally construct a Merkletree with the same data structure as the sending end, and after each successful verification, the received leaf node data will be stored in the corresponding position of the Merkletree.

[0105] Based on this, in the MerkleProof data sent by the sender, the data that has been received by the receiver is no longer transmitted. The nodes in the MerkleProof that can be constructed using the data that has been received, such as Figure 3 In the example, the leaf nodes of this transmission are leaf node 2 and leaf node 3; then the MerkleProof data provided by the sender can be [number 0, branch node 5]; the number 0 represents the global position number of the branch node, because leaf nodes 0 and leaf nodes 1 have reached the receiving end in the previous transmission process, so the receiving end theoretically has the opportunity to construct the data of branch node 0. Therefore, it is only necessary to instruct the receiving end to construct branch node 0 based on the data already available at the receiving end.

[0106] In an optional embodiment, the file transmission method further includes:

[0107] In the case where the target leaf node is successfully verified, determining the target position of the target leaf node in the file to be transmitted;

[0108] Starting from the target location, the target leaf node is persisted as a file.

[0109] In some embodiments, after the receiving end completes verification, the location of the file content of the leaf node can be calculated according to the offset (offset*4K), and starting from this location, the leaf node content can be persisted as a file in sequence.

[0110] In an optional embodiment, the file transmission method further includes:

[0111] In the case where the verification of the target leaf node fails, a retry message is sent to the sending end, so that the sending end resends the target leaf node that failed verification based on the retry message.

[0112] In some embodiments, if the receiving end makes an error in the verification process of the received network message, the sending end may be actively requested to resend the message, thereby timely discovering and reducing the cost of repairing the error.

[0113] In an optional embodiment, the file transmission method further includes:

[0114] After the target leaf node is persisted, a confirmation message of the target leaf node is sent to the sending end, so that the sending end ignores the retry message of the target leaf node that has received the confirmation message.

[0115] In some embodiments, after the receiving end completes persistence, it can asynchronously provide an acknowledgment (ACK) message to institution A; this step does not affect correctness, but is only convenient for the sending end to decide whether to respond to the receiving end's active pull request in abnormal scenarios such as disordered network messages or network jitter. For example, if the receiving end first sends a retry and then sends an ACK for the same file block, then as long as the sending end has received the ACK message for the file block, it can ignore any retry messages that arrive later.

[0116] The file transfer method of the present application introduces the MerkleTree structure and combines it with the MerkleProof feature to achieve the above-mentioned instant verification of file content blocks, reduce the granularity of file error correction, and other effects; considering the linearization characteristics of blockchain system transactions, the handshake protocol of both parties is simplified, avoiding various abnormal situations that need to be considered by both parties involved in most distributed systems.

[0117] Each network message can be verified for correctness and persisted completely independently. Therefore, if file transfer efficiency is considered, the sender can independently send each pre-calculated network message concurrently. The verification and persistence logic of the receiving end does not strictly depend on the sequence of messages, that is, parallel sending can greatly improve the overall file transfer efficiency.

[0118] In addition, each file content data packet carries a MerkleProof message, that is, the file content in each message can be independently verified and deterministically stored without waiting for the correctness of all file content transmission to be completed, avoiding resource consumption caused by the receiving end temporarily storing a large amount of intermediate data; for the receiving end, compared with the solution of performing a unified hash check after receiving all data, if there is a problem with the final verification file content, this solution can limit the erroneous file content to the scope of one message. In order to fix the error, this solution only needs to resend the content involved in the message, and there is no need to resend the entire file; that is, the cost of locating and fixing errors in this solution is low; the on-chain handshake protocol avoids various abnormal scenarios that may be introduced by the handshake protocol of direct network interaction through the nature of linearization characteristics of the order between on-chain transactions, and the protocol is simpler.

[0119] Based on the same concept, a file transmission device is provided in the embodiment of the present application. The specific implementation of the device can refer to the description of the method embodiment part, and the repeated parts will not be repeated. The device mainly includes:

[0120] A determination module, used to determine the maximum transmission data volume of a single network message;

[0121] A construction module, used to construct a Merkle tree data structure of the file to be transmitted, wherein the Merkle tree data structure includes a plurality of leaf nodes and a Merkle proof parameter of each leaf node, and the leaf node carries the content of the file to be transmitted;

[0122] The first handshake module is used to complete the handshake with the receiving end based on the blockchain;

[0123] A sending module is used to send a network message to the receiving end, wherein the network message includes a target leaf node and a target Merkel proof parameter of the target leaf node, so that the receiving end verifies the target leaf node based on the target Merkel proof parameter, and the target leaf node is at least one of the multiple leaf nodes.

[0124] Based on the same concept, a file transmission device is provided in the embodiment of the present application. The specific implementation of the device can refer to the description of the method embodiment part, and the repeated parts will not be repeated. The device mainly includes:

[0125] The second handshake module is used to complete the handshake with the sender based on the blockchain;

[0126] An acquisition module, used for acquiring a network message sent by the sending end, wherein the network message includes a target leaf node carrying the content of the file to be transmitted and a target Merkel proof parameter of the target leaf node;

[0127] A verification module is used to verify the target leaf node based on the target Merkle proof parameter.

[0128] Based on the same concept, an electronic device is also provided in the embodiment of the present application, such as Figure 5 As shown, the electronic device mainly includes: a processor 501, a memory 502 and a communication bus 503, wherein the processor 501 and the memory 502 communicate with each other through the communication bus 503. The memory 502 stores a program executable by the processor 501, and the processor 501 executes the program stored in the memory 502 to implement the following steps:

[0129] Determine the maximum amount of data that can be transmitted for a single network message;

[0130] Constructing a Merkle tree data structure of the file to be transmitted, wherein the Merkle tree data structure includes a plurality of leaf nodes and a Merkle proof parameter of each leaf node, wherein the leaf node carries the content of the file to be transmitted;

[0131] Complete the handshake with the receiving end based on the blockchain;

[0132] Sending a network message to the receiving end, the network message including a target leaf node and a target Merkle proof parameter of the target leaf node, so that the receiving end verifies the target leaf node based on the target Merkle proof parameter, the target leaf node being at least one of the multiple leaf nodes. Or,

[0133] Complete the handshake with the sender based on the blockchain;

[0134] Acquire a network message sent by the sending end, wherein the network message includes a target leaf node carrying the content of the file to be transmitted and a target Merkel proof parameter of the target leaf node;

[0135] The target leaf node is verified based on the target Merkle proof parameters.

[0136] The communication bus 503 mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus 503 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0137] The memory 502 may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Alternatively, the memory may also be at least one storage device located away from the processor 501 .

[0138] The above-mentioned processor 501 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc., and can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.

[0139] In another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed on a computer, the computer executes the file transfer method described in the above embodiment.

[0140] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instruction is loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instruction is transmitted from a website site, a computer, a server or a data center by wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, a data center, etc. that contains one or more available media integration. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape, etc.), an optical medium (such as a DVD) or a semiconductor medium (such as a solid-state hard disk), etc.

[0141] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0142] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A file transmission method, characterized in that: Applied to the sending end, the method includes: Determine the maximum amount of data that can be transmitted for a single network message; Constructing a Merkle tree data structure of the file to be transmitted, wherein the Merkle tree data structure includes a plurality of leaf nodes and a Merkle proof parameter of each leaf node, wherein the leaf node carries the content of the file to be transmitted; Complete the handshake with the receiving end based on the blockchain; A network message is sent to the receiving end, wherein the network message includes a target leaf node and a target Merkel proof parameter of the target leaf node, so that the receiving end verifies the target leaf node based on the target Merkel proof parameter, and the target leaf node is at least one of the multiple leaf nodes.

2. The file transmission method according to claim 1, characterized in that: Construct the Merkle tree data structure of the file to be transferred, including: Splitting the file to be transmitted according to the first file size to obtain multiple sub-files; Determine that at least one of the sub-files is a leaf node; the second file size of the leaf node is greater than or equal to the first file size; Determine that the data structure composed of the leaf nodes is the Merkle tree data structure.

3. The file transmission method according to claim 1, characterized in that: Determine the maximum amount of data that can be transmitted in a single network message, including: Obtain network configuration information with the receiving end; Determine a transmission data range corresponding to the network configuration information; A maximum value in the transmission data range is determined as the maximum transmission data amount.

4. A file transmission method, characterized in that: Applied to the receiving end, the method comprises: Complete the handshake with the sender based on the blockchain; Acquire a network message sent by the sending end, wherein the network message includes a target leaf node carrying the content of the file to be transmitted and a target Merkel proof parameter of the target leaf node; The target leaf node is verified based on the target Merkle proof parameters.

5. The file transmission method according to claim 4, characterized in that: The handshake with the sender based on blockchain includes: Obtaining meta information of the file to be transmitted on the chain from the sender; the meta information includes the file size of the file to be transmitted, the file Merkel proof parameters, the receiving end information and the sending end information; Generate confirmation information for the meta-information, and upload the confirmation information to the chain; so that the sending end can obtain the confirmation information on the chain and complete the handshake with the sending end.

6. The file transmission method according to claim 4, characterized in that: The method further comprises: In the case where the target leaf node is successfully verified, determining the target position of the target leaf node in the file to be transmitted; Starting from the target location, the target leaf node is persisted as a file.

7. The file transmission method according to claim 4, characterized in that: The method further comprises: After the target leaf node is persisted, a confirmation message of the target leaf node is sent to the sending end, so that the sending end ignores the retry message of the target leaf node that has received the confirmation message.

8. A file transfer system, characterized in that: include: The sender and receiver; The sending end is used to determine the maximum transmission data volume of a single network message; Constructing a Merkle tree data structure of the file to be transmitted, wherein the Merkle tree data structure includes a plurality of leaf nodes and a Merkle proof parameter of each leaf node, wherein the leaf node carries the content of the file to be transmitted; completing a handshake with the receiving end based on the blockchain; Sending a network message to the receiving end, wherein the network message includes a target leaf node and a target Merkel proof parameter of the target leaf node; The receiving end is used to obtain the network message sent by the sending end; The target leaf node is verified based on the target Merkle proof parameters.

9. An electronic device, characterized in that: include: A processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is used to execute the program stored in the memory to implement the file transmission method described in any one of claims 1 to 3 or the file transmission method described in any one of claims 4 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the file transmission method described in any one of claims 1 to 3 or the file transmission method described in any one of claims 4 to 7 is implemented.