Data storage method and device, computer equipment, program product and storage medium
By corrective coding and decentralized storage of blockchain data, and using the credibility of blockchain nodes to differentiate storage, the problems of blockchain data storage security and storage space waste are solved, and high security and reliability of data are achieved. restorative.
Patent Information
- Application Number
- CN202410577860.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-10
- Publication Date
- 2024-08-30
AI Technical Summary
When storing data on the blockchain, there are security issues such as malicious attacks leading to data theft, and the full replication solution leads to a waste of storage space and the problem of data being easily obtained illegally.
By correcting and encoding the data to be stored, n data blocks and m redundant blocks are generated and stored in different blockchain nodes. The credibility of the blockchain node is used to distinguish the first blockchain node. and the second blockchain node to ensure that the data cannot be completely stolen when the node is attacked, and that the data can be restored when the node fails.
It improves the security and recoverability of data storage, avoids the problem of data being stolen after a node is maliciously attacked, saves storage space, and reduces storage waste.
Smart Images

Figure CN118568761A
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and more specifically, to a data storage method, a data storage device, a computer device, a computer program product, and a non-volatile computer-readable storage medium. Background Art
[0002] At present, when storing data on the blockchain, a full replication solution can be adopted, which stores a complete copy of the data on each node of the blockchain. When adopting the full replication solution, even if data is lost on some nodes, the complete data can be retrieved by communicating with other nodes.
[0003] However, if a blockchain node is attacked maliciously, it is easy for the complete data to be illegally stolen, affecting the security of data storage. Summary of the invention
[0004] The embodiments of the present application provide a data storage method, a data storage device, a computer device, a computer program product, and a non-volatile computer-readable storage medium, which can avoid the problem that all data is stolen after a blockchain node is maliciously attacked, thereby improving the security of data storage.
[0005] The data storage method of the present application includes: performing correction encoding on the data to be stored to generate n data blocks and m redundant blocks, wherein when the data blocks or the redundant blocks are missing, the data to be stored can be restored based on the remaining data blocks and the redundant blocks, wherein n is determined according to the number of first blockchain nodes, and m is determined according to the number of second blockchain nodes, and the credibility of the second blockchain nodes is lower than that of the first blockchain nodes; and each of the data blocks is stored in each of the first blockchain nodes, and each of the redundant blocks is stored in each of the second blockchain nodes.
[0006] In some embodiments, the correction encoding of the data to be stored to generate n data blocks and m redundant blocks includes: dividing the data to be stored to obtain the n data blocks; generating a coding matrix based on the number of the first blockchain nodes and the number of the second blockchain nodes; and multiplying the coding matrix and the column vector of the n data blocks to obtain the m redundant blocks.
[0007] In certain embodiments, generating a coding matrix based on the number of the first blockchain nodes and the number of the second blockchain nodes includes: generating a first matrix and a second matrix, the number of rows and the number of columns of the first matrix are the same as the number of the first blockchain nodes, the first matrix is a unit matrix, the number of columns of the second matrix is the same as the number of the first blockchain nodes, and the number of rows of the second matrix is the same as the number of the second blockchain nodes; and vertically splicing the first matrix and the second matrix to generate the coding matrix.
[0008] In certain embodiments, storing each of the data blocks separately in each of the first blockchain nodes includes: when the block size of the data block is greater than a block storage threshold preset by the first blockchain node, based on the number of first blockchain nodes, splitting the data block again to obtain split data blocks, wherein the block size of the split data blocks is less than or equal to the block storage threshold; and storing each of the split data blocks separately in each of the first blockchain nodes.
[0009] In certain embodiments, the data storage method further includes: generating i keys based on the number t of the first blockchain nodes and the number p of virtual blockchain nodes, each blockchain node consisting of the first blockchain node and the virtual blockchain node corresponds one-to-one to the key, the virtual blockchain node includes a plurality of the second blockchain nodes, t, p, and i are all positive integers; based on the i keys, allocating key data to the first blockchain node and the virtual blockchain node; based on the key data, generating a private key for decryption and a public key for encryption.
[0010] In some embodiments, the key data includes first key data, second key data, and third key data, and the allocating key data to the first blockchain node and the virtual blockchain node based on the i keys includes: allocating the first key data to each first blockchain node based on the i keys; allocating the second key data to each of the second blockchain nodes in the virtual blockchain node based on the first target key corresponding to the virtual blockchain node; allocating the third key data to the virtual blockchain node based on t second target keys corresponding to t first blockchain nodes respectively, and splitting the third key data into each of the second blockchain nodes in the virtual blockchain node.
[0011] In some embodiments, the third key data includes t pieces, the third key data and the second target key correspond one-to-one, and the splitting of the third key data into each of the second blockchain nodes in the virtual blockchain node includes: splitting the t pieces of the third key data based on the number of the second blockchain nodes in the virtual blockchain node, so as to distribute the t pieces of the third key data to each of the second blockchain nodes respectively.
[0012] In some embodiments, generating a private key for decryption and a public key for encryption based on the key data includes: obtaining the first key data; in a case where at least part of the first key data is missing, obtaining the second key data and the third key data, and generating a private key for decryption and a public key for encryption based on the first key data, the second key data and the third target key that are not missing; in a case where the first key data is not missing, generating a private key for decryption and a public key for encryption based on the first key data that are not missing.
[0013] In some embodiments, the key includes a polynomial, and the number of terms of the polynomial is determined according to the number t of the first blockchain nodes.
[0014] In some embodiments, before storing each of the data blocks in each of the first blockchain nodes and storing each of the redundant blocks in each of the second blockchain nodes, the data storage method further includes: encrypting the data blocks and the redundant blocks based on the public key.
[0015] In certain embodiments, the data storage method further includes: upon receiving a data block of the first blockchain node and at least one of a redundant block of the second blockchain node, decrypting the received data block and the redundant block based on the private key.
[0016] In certain embodiments, the data storage method further includes: after the public key and private key are generated for the last time, if the stored data of each node meets a preset condition, re-entering the step of generating i keys based on the number t of the first blockchain nodes and the number p of virtual blockchain nodes.
[0017] In some embodiments, the preset condition includes at least one of the following conditions: the number of storage rounds of the stored data is greater than the preset number of rounds; the storage amount of the stored data is greater than the preset storage amount; and the storage duration of the stored data is greater than the preset duration.
[0018] In certain embodiments, the data storage method further includes: when all of the first blockchain nodes respond, obtaining the data blocks from each of the first blockchain nodes to restore the data to be stored based on the obtained data blocks; when at least one of the first blockchain nodes does not respond, obtaining the data blocks from each of the first blockchain nodes and obtaining the redundant blocks from each of the second blockchain nodes to restore the data to be stored based on the obtained data blocks and the redundant blocks.
[0019] In some embodiments, the data storage method further includes: determining the first blockchain node and the second blockchain node in each of the nodes based on at least one of the number of responses and data tampering information of each node. The data storage device of the embodiment of the present application includes an acquisition module and a control module, the acquisition module is used to acquire environmental information around the vehicle when a door opening action of the vehicle is detected; the control module is used to issue data storage information when it is determined that the door opening action is risky based on the environmental information.
[0020] The data storage device of the present application includes a correction coding module and a storage module. The correction coding module is used to perform correction coding on the data to be stored to generate n data blocks and m redundant blocks. When the data blocks or the redundant blocks are missing, the data to be stored can be restored based on the remaining data blocks and the redundant blocks. The n is determined according to the number of first blockchain nodes, and the m is determined according to the number of second blockchain nodes. The credibility of the second blockchain nodes is lower than that of the first blockchain nodes. The storage module is used to store each of the data blocks in each of the first blockchain nodes, and store each of the redundant blocks in each of the second blockchain nodes.
[0021] The computer device of the present application includes: a processor, the processor is connected to a memory; a computer program is stored in the memory, and the processor executes the computer program to implement instructions of the data storage method described in any of the above embodiments.
[0022] The computer program product of the present application includes a computer program, and the computer program includes instructions for the data storage method described in any of the above embodiments.
[0023] The non-volatile computer-readable storage medium of the embodiment of the present application includes a computer program. When the computer program is executed by a processor, the processor executes the data storage method described in any of the above embodiments.
[0024] The data storage method, data storage device, computer equipment, computer program product, and non-volatile computer-readable storage medium of the embodiments of the present application perform correction encoding on the data to be stored to generate n data blocks and m redundant blocks, and store the n data blocks in a dispersed manner to each first blockchain node, and store the m redundant blocks in a dispersed manner to each second blockchain node. Even if some blockchain nodes are attacked, the complete data cannot be obtained, thereby avoiding the problem of complete data being completely stolen after the nodes are maliciously attacked, thereby improving the security of data storage.
[0025] Moreover, when it is necessary to restore the data to be stored, not only can the data blocks stored in the first blockchain node with higher credibility be combined to obtain the data to be stored; but even if some data blocks or redundant blocks are missing, the data to be stored can be restored based on the remaining data blocks and redundant blocks, thereby ensuring the recoverability of the data to be stored.
[0026] In addition, compared with storing the data to be stored completely in each node, which wastes the node storage space, the data blocks generated by correction coding of the data to be stored are dispersedly stored in the first blockchain node, and the redundant blocks are dispersedly stored in the second blockchain node, which can also save the storage space of each node.
[0027] Additional aspects and advantages of the embodiments of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0029] Figure 1 It is a schematic diagram of an application scenario of a data storage method in some embodiments of the present application;
[0030] Figure 2 It is a schematic diagram of a scenario of a data storage method in some embodiments of the present application;
[0031] Figure 3 is a flowchart of a data storage method according to certain embodiments of the present application;
[0032] Figure 4 is a flowchart of a data storage method according to certain embodiments of the present application;
[0033] Figure 5 is a flowchart of a data storage method according to certain embodiments of the present application;
[0034] Figure 6is a flowchart of a data storage method according to certain embodiments of the present application;
[0035] Figure 7 is a flowchart of a data storage method according to certain embodiments of the present application;
[0036] Figure 8 is a flowchart of a data storage method according to certain embodiments of the present application;
[0037] Fig. 9 It is a schematic diagram of a scenario of a data storage method in some embodiments of the present application;
[0038] Fig.10 is a flowchart of a data storage method according to certain embodiments of the present application;
[0039] Fig.11 is a flowchart of a data storage method according to certain embodiments of the present application;
[0040] Fig.12 It is a schematic diagram of a scenario of a data storage method in some embodiments of the present application;
[0041] Fig.13 is a flowchart of a data storage method according to certain embodiments of the present application;
[0042] Fig.14 is a flowchart of a data storage method according to certain embodiments of the present application;
[0043] Fig.15 is a flowchart of a data storage method according to certain embodiments of the present application;
[0044] Fig.16 is a flowchart of a data storage method according to certain embodiments of the present application;
[0045] Fig.17 It is a schematic diagram of a scenario of a data storage method in some embodiments of the present application;
[0046] Fig.18 is a flowchart of a data storage method according to certain embodiments of the present application;
[0047] Fig.19 is a flowchart of a data storage method according to certain embodiments of the present application;
[0048] Fig. 20 is a flowchart of a data storage method according to certain embodiments of the present application;
[0049] Fig.21 is a schematic diagram of a module of a data storage device according to some embodiments of the present application;
[0050] Fig. 22 is a schematic diagram of the structure of a computer device of certain embodiments of the present application;
[0051] Fig.23 It is a schematic diagram of the connection status of a non-volatile computer-readable storage medium and a processor in certain embodiments of the present application. DETAILED DESCRIPTION
[0052] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the embodiments of the present application, and cannot be understood as limiting the embodiments of the present application.
[0053] Below, the nouns appearing in this application are explained:
[0054] 1. Blockchain is a decentralized distributed technology that maintains and updates data through multiple nodes in the network. Blockchain has the characteristics of being tamper-proof and traceable. It is a new application scenario for scientific and technological technologies such as distributed storage, identity authentication and recording, and secure communication.
[0055] 2. Erasure Coding (EC): A data protection method. The working principle of erasure coding is to convert the original information into longer encoded data through a matrix. These encoded data contain redundant correction information, which can ensure the complete recovery of the original data after partial loss of the encoded data. It has good universality in data integrity protection in complex application scenarios.
[0056] 3. Reed-solomon codes (RS codes): Also known as Reed-Solomon codes, they are a type of erasure code. RS codes construct a Vandermonde matrix, based on the Vandermonde matrix and the original data, to encode the original data for data storage. When encoding data, the Vandermonde matrix can generally be used for calculation.
[0057] 4. Data consensus: A technology that verifies and confirms transactions in a distributed system through voting by special nodes. It ensures the accuracy and security of recorded information in a decentralized network, even if the nodes do not know each other and are unreliable by default, and cannot determine whether other nodes are down or betrayed.
[0058] 5. Distributed key generation DKG (distributed key generation): refers to the technology in which multiple nodes in a system jointly generate private keys without relying on a trusted third party. It ensures that no party can access the private key alone and recover the private key when the number of participating nodes is greater than the threshold value.
[0059] 6. Threshold value: refers to a standard, threshold or limit set in a specific field or application to determine whether a process or operation continues. This application sets a threshold value for blockchain nodes. If the number of first blockchain nodes meets the threshold value, this application can be executed.
[0060] 7. Asymmetric encryption RSA algorithm: refers to constructing a pair of public keys and private keys through a cryptographic scheme. The public key is public and used for data encryption, and the private key is confidential and used for data decryption.
[0061] At present, when storing data on the blockchain, a full replication solution can be used to store a complete copy of the data on each node of the blockchain. The full replication solution can ensure that even if some nodes fail or data is lost, the complete data can be obtained by communicating with other nodes.
[0062] However, the full replication solution causes the storage space of each node to be consumed too quickly during operation, and the blockchain cannot provide storage services continuously; and if a node is attacked maliciously, it is easy for all data in the entire blockchain to be illegally stolen. In addition, there is currently no solution to encrypt nodes on the blockchain individually, which makes it easy for data on the blockchain to be illegally obtained.
[0063] In order to solve the above technical problems, an embodiment of the present application provides a data storage method.
[0064] The following first introduces an application scenario of the technical solution of this application. Figure 1 As shown, the data storage method provided by the present application can be applied to Figure 1 In the application scenario shown. The data storage method is applied to a data storage system 1000. The data storage system 1000 is used to store data in a blockchain node or obtain data from a blockchain node.
[0065] In one embodiment, a blockchain node may be a server or a terminal device, such as Figure 1 As shown, the blockchain node is server 100.
[0066] In the embodiments of the present application, the terminal devices include but are not limited to mobile phones, tablet computers, laptop computers, desktop computers, e-book readers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft and other devices; blockchain-related services can be installed on the terminal devices, and the server 100 is a background server 100 corresponding to the software or web pages, applets, etc., or a server 100 specifically used for blockchain services, which is not specifically limited in the present application.
[0067] The server 100 may be an independent physical server 100, or a server 100 cluster or distributed system composed of multiple physical servers 100, or a cloud server 100 that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The embodiments of the present application do not limit this.
[0068] It should be noted that the data storage method of the present application can be executed by an electronic device, which can be a server 100 or a terminal device, that is, the method can be executed by the server 100 or the terminal device alone, or by the server 100 and the terminal device together. For example, when executed by the server 100, the server 100 receives the data to be stored, performs correction encoding on the data to be stored, and then stores each data block in each first blockchain node, and each redundant block in each second blockchain node.
[0069] In one embodiment, the terminal device and the server 100 can communicate with each other through a communication network.
[0070] In one embodiment, the communication network is a wired network or a wireless network.
[0071] It should be noted that Figure 1 The figure is only an example. In fact, the number of terminal devices and servers 100, that is, the number of blockchain nodes is not limited and is not specifically limited in the embodiments of the present application.
[0072] See also Figure 2, the data storage system 1000 may include an information management module, a coding and decoding module, a key generation module and an encryption and decryption module. The information management module is used to provide the function of storing the data to be stored on the node and the function of obtaining the data stored on the node; the coding and decoding module is used to encode the data to be stored to generate data blocks and redundant blocks, and decode the data blocks and redundant blocks to obtain the data to be stored. In the embodiment of the present application, the encoding and decoding of data by RS coding technology in the coding and decoding module is used as an example for description; the key generation module is used to generate a public key for encryption and a private key for decryption. In the embodiment of the present application, the generation of private keys and public keys based on distributed key generation DKG technology is used as an example for description; the encryption and decryption module is used to encrypt the data blocks and redundant blocks using the public key when storing the data blocks and redundant blocks, and to decrypt the encrypted data blocks and redundant blocks using the private key when obtaining the stored data; the information management module is connected to the coding and decoding module and the key generation module, the coding and decoding module is connected to the encryption and decryption module, and the key generation module is unidirectionally connected to the encryption and decryption module.
[0073] The above-mentioned information management module, encoding and decoding module, key generation module and encryption and decryption module can be set in at least one of the terminal device and the server.
[0074] The following describes the method for distributing creation tasks on a cloud server provided by an exemplary embodiment of the present application in combination with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not subject to any limitation in this regard.
[0075] See also Figure 1 , Figure 2 and Figure 3 , the embodiment of the present application provides a data storage method, the data storage method comprising:
[0076] Step 011: Correction encoding is performed on the data to be stored to generate n data blocks and m redundant blocks. In the event that a data block or a redundant block is missing, the data to be stored can be restored based on the remaining data blocks and redundant blocks. n is determined according to the number of first blockchain nodes, and m is determined according to the number of second blockchain nodes. The credibility of the second blockchain nodes is lower than that of the first blockchain nodes.
[0077] The data to be stored may be data that needs to be uploaded to the blockchain system for storage. For example, taking the blockchain system applied in buildings as an example, the data to be stored may be newly added lighting data, air conditioning data, property fee records, etc. The data block may be an independent information block obtained by segmenting the data to be stored and used to store and transmit the data to be stored. The redundant block includes correction information and may include redundant information blocks generated after encoding the data to be stored. During data transmission and storage, the redundant block may be used to detect and repair errors. The storage capacity occupied by the data block and the redundant block is less than the storage value of each node. The credibility may be the reliability and trust of each node in the blockchain. For example, if no data tampering or other behaviors occur in the historical usage record of a node, it can be considered that the reliability and trust of the node are both high, and thus the credibility of the node is high. The blockchain nodes are connected and communicated with each other to form a blockchain network. The first blockchain node and the second blockchain node may be any blockchain node on the blockchain network, wherein the credibility of the first blockchain node is higher than the credibility of the second blockchain node.
[0078] Specifically, the data to be stored can be obtained through the information management module of the blockchain system. When the data to be stored is obtained, in the encoding and decoding module, the data to be stored is corrected and encoded by the erasure code technology. For example, the data to be stored can be divided into n data blocks by RS coding technology, and then m redundant blocks are generated based on n data blocks and RS coding technology. In the case where a data block or redundant block is missing, and the total number of missing blocks is less than or equal to m, the remaining data blocks and redundant blocks can be decoded to restore the data to be stored. The number of data blocks n can be determined by the number of nodes of the first blockchain, and the number of redundant blocks m can be determined by the number of nodes of the second blockchain. For example, n can be equal to the number of nodes of the first blockchain; or, n can be equal to several times the number of nodes of the first blockchain, etc.; similarly, m can be equal to the number of nodes of the second blockchain; or, m can be equal to several times the number of nodes of the second blockchain, etc.
[0079] The nodes on the blockchain may include a first blockchain node and a second blockchain node, wherein the credibility of the second blockchain node is lower than that of the first blockchain node. Each node may be determined as a first blockchain node or a second blockchain node according to the credibility of each node. For example, by receiving the operation data of each node (such as the historical performance data of the node: the accuracy of node transaction verification, the broadcast efficiency of the node, whether the node is malicious, etc.), the corresponding credibility value of each node may be assigned according to the operation data of each node, or the credibility value of each node may be determined by consensus of data on each node. After determining the credibility value of each node, a preset credibility threshold can be used to determine a node with a credibility value greater than a preset credibility threshold as a first blockchain node, and a node with a credibility value less than the preset credibility threshold as a second blockchain node; alternatively, each node is sorted according to the credibility value, and according to the sorting result of the credibility value of each node, a preset number of nodes are determined as the first blockchain node (or the second blockchain node), and the remaining nodes are the second blockchain nodes (or the first blockchain nodes). For example, by sorting each node from high to low according to the credibility value, the top 50 nodes are determined as the first blockchain nodes, and the remaining nodes are determined as the second blockchain nodes.
[0080] See also Figure 4 Optionally, the data storage method further includes:
[0081] Step 013: Based on at least one of the number of responses of each node and the data tampering information, determine the first blockchain node and the second blockchain node in each node.
[0082] Among them, the data tampering information may include data tampering behavior and the number of data tampering. For example, it may be whether each node has data tampering behaviors such as modification, deletion or forgery of data when the data consensus is reached on each node; or it may be a record of the number of data tampering behaviors such as modification, deletion or forgery of data made by each node. When determining the first blockchain node and the second blockchain node in each node, it may be based on the number of responses of each node; or based on the data tampering information of each node; or based on the number of responses and data tampering information of each node, etc. This application does not limit it and will not be listed here one by one.
[0083] Specifically, data consensus can be reached on each node based on each data block, and then data tampering information (such as the number of data tampering times, etc.) of each node can be obtained, and the credibility of each node can be determined based on the data tampering information. For example, after data consensus is reached on each node based on each data block, the data tampering information of each node is obtained, and the nodes in the blockchain that have not had any data tampering behavior are used as the first blockchain nodes, and the nodes that have had data tampering behavior (regardless of the number of data tampering behaviors) are used as the second blockchain nodes; or, the data tampering information of each node is obtained, and each node is sorted according to the number of data tampering times of each node, and then according to the preset number of first blockchain nodes, a preset number of nodes with the lowest number of times in the sorting are used as the first blockchain nodes, and the remaining nodes are used as the second blockchain nodes.
[0084] The first blockchain node and the second blockchain node can also be determined according to the number of responses and data tampering information of each node during data consensus. For example, a ranking value is assigned to each node according to the number of responses and data tampering information of each node, and the ranking value is matched with the credibility, and then each node is sorted according to the ranking value, and finally a number of nodes with a ranking value at the front or back are taken as the first blockchain node, and the remaining nodes are the second blockchain node, etc. According to the number of responses and the number of data tampering of each node, the first blockchain node and the second blockchain node in each node are determined to ensure the correct distinction between the first blockchain node and the second blockchain node in each node, and improve the stability and reliability of the blockchain system. It can be set that the more the number of responses, the larger the ranking value, the more the number of data tampering, the smaller the ranking value, and then the ranking value and credibility are matched, that is, the higher the ranking value, the higher the credibility; or, it can also be set that the more the number of responses, the smaller the ranking value, the more the number of data tampering, the larger the ranking value, and then the ranking value and credibility are matched, that is, the higher the ranking value, the lower the credibility, etc.
[0085] For example, the ranking value of each node can be determined by the number of responses of each node, and then the ranking value of each node can be adjusted (increased or decreased) according to the number of data tampering of each node, and finally the first blockchain node and the second blockchain node can be determined in each node according to the ranking value; similarly, the ranking value of each node can be determined by the number of data tampering of each node, and then the ranking value of each node can be adjusted (increased or decreased) according to the number of responses of each node, and finally the first blockchain node and the second blockchain node can be determined in each node according to the ranking value: the blockchain includes node A and node B, and node A has not responded the number of times. Taking the example that the number of data tampering times is 1, the number of node B unresponsive times is 0, and the number of data tampering times is 1, we can first determine the ranking value of node A to be 1 and the ranking value of node B to be 0 through the number of unresponsive times of node A and node B, and then adjust the ranking values of node A and node B according to the number of data tampering times. After the adjustment, the ranking value of node A is 3, and the ranking value of node B is 1. According to the ranking value, they are sorted from large to small, and the ranking is: node A, node B. The ranking value is corresponded to the credibility. The higher the ranking value and the closer the node is to the front, the lower the credibility. Therefore, node B is determined to be the first blockchain node and node A is determined to be the second blockchain node.
[0086] You can also set different weights for the number of responses and data tampering times of the nodes, so as to calculate the ranking value of each node according to the number of responses and data tampering times of the nodes: Continuing with the previous example, take the blockchain including nodes A and node B, the number of unresponsive times of node A is 1, the number of data tampering times is 2, the number of unresponsive times of node B is 0, the number of data tampering times is 1, the weight of the number of responses of the nodes is 0.4, and the weight of the number of data tampering times is 0.6 as an example for explanation. Through calculation, the ranking value of node A is obtained as: 1*0.4+2*0.6=1.6, and the ranking value of node B is: 0*0.4+1*0.6=0.6. Sorting is performed from small to large according to the ranking value, and the ranking is: node B, node A. Then the ranking value is matched with the credibility. The lower the ranking value, the higher the credibility of the node. Therefore, node B is determined to be the first blockchain node and node A is determined to be the second blockchain node.
[0087] By using at least one of the response times and data tampering information of each node, the first blockchain node and the second blockchain node in each node are determined, thereby improving the accuracy of determining the first blockchain node or the second blockchain node, thereby improving the security and reliability of data storage.
[0088] Step 012: Store each data block in each first blockchain node respectively, and store each redundant block in each second blockchain node respectively.
[0089] Specifically, each data block is stored in the first blockchain node, and each redundant block is stored in the second blockchain node. For example, when n is the number of the first blockchain node and m is the number of the second blockchain node, n data blocks are stored in each first blockchain node and m redundant blocks are stored in each second blockchain node. For another example, when n is twice the number of the first blockchain node and m is the number of the second blockchain node, two data blocks are stored in one first blockchain node and one redundant block is stored in one second blockchain node, thereby completing the storage of data blocks and redundant blocks. By flexibly allocating and storing data blocks and redundant blocks in the first blockchain node or the second blockchain node, that is, each node on the blockchain stores the corresponding data blocks or redundant blocks respectively, it is no longer necessary to store the complete data to be stored, thus saving the storage space of each node and avoiding the problems of wasting node storage space and poor node scalability when the load and data volume increase.
[0090] It can be understood that the first blockchain node is more credible than the second blockchain node. Storing the data blocks obtained by segmenting the data to be stored in the more credible first blockchain node can prevent the data from being stolen after the node is maliciously attacked, thereby improving the security of data storage; and, since the data blocks are dispersedly stored in the more credible first blockchain nodes instead of storing all the data blocks in the same first blockchain node, the risk of data loss caused by node failure is reduced, thereby improving the fault tolerance and stability of the blockchain system.
[0091] It should be pointed out that the credibility of the node also changes with the change of the running time and the running environment. Therefore, in order to improve the security of data storage, after determining the first blockchain node and the second blockchain node in the blockchain node, the first blockchain node and the second blockchain node in the blockchain node can be re-determined by setting the data storage round number threshold, the running time threshold, etc. For example, by setting the data storage round number threshold to 2, after storing two rounds of data to be stored in the blockchain, the nodes in the blockchain are re-distinguished and determined to be the first blockchain node or the second blockchain node.
[0092] In this way, by performing correction coding on the data to be stored to generate n data blocks and m redundant blocks, and distributing and storing the n data blocks in each first blockchain node, and distributing and storing the m redundant blocks in each second blockchain node, even if some blockchain nodes are attacked, the complete data cannot be obtained, thereby avoiding the problem of complete data being completely stolen after the node is maliciously attacked, thereby improving the security of data storage.
[0093] Moreover, when it is necessary to restore the data to be stored, not only can the data blocks stored in the first blockchain node with higher credibility be combined to obtain the data to be stored; but even if some data blocks or redundant blocks are missing, the data to be stored can be restored based on the remaining data blocks and redundant blocks, thereby ensuring the recoverability of the data to be stored.
[0094] In addition, compared with storing the data to be stored completely in each node, which wastes the node storage space, the data blocks generated by correction coding of the data to be stored are dispersedly stored in the first blockchain node, and the redundant blocks are dispersedly stored in the second blockchain node, which can also save the storage space of each node.
[0095] See also Figure 5 and Figure 6 Optionally, the data storage method further includes:
[0096] Step 014: When all first blockchain nodes respond, obtain data blocks from each first blockchain node to restore the data to be stored according to each obtained data block;
[0097] Step 015: When at least one of the first blockchain nodes does not respond, data blocks are obtained from the first blockchain nodes and redundant blocks are obtained from the second blockchain nodes to restore the data to be stored based on the obtained data blocks and redundant blocks.
[0098] Specifically, when all the first blockchain nodes respond, it can be considered that all the data blocks can be obtained. After obtaining the data blocks from each first blockchain node, the data to be stored can be obtained based on each data block (such as aggregating, combining, etc.) without decoding. When at least one of the first blockchain nodes does not respond, the data to be stored cannot be obtained by aggregating, combining, etc. the data blocks. The remaining data blocks and redundant blocks can be obtained from each responding first blockchain node and each responding second blockchain node, and the remaining data blocks and redundant blocks can be decoded to restore the data to be stored.
[0099] That is to say, when obtaining the data to be stored, the data to be stored can be obtained by combining the various data blocks stored in the first blockchain node without decoding; even if the first blockchain node or the second blockchain node fails and some data blocks and redundant blocks cannot be obtained; or when some data blocks and redundant blocks are lost (the total number of lost blocks is less than the number m of redundant blocks), the remaining first blockchain nodes and the second blockchain nodes can communicate with each other, and decode to restore the data to be stored based on the remaining data blocks and redundant blocks, thereby ensuring the recoverability of the data to be stored and improving the practicality of data storage.
[0100] See also Figure 7 In some implementations, step 011: performing correction encoding on the data to be stored to generate n data blocks and m redundant blocks, including:
[0101] Step 0111: dividing the data to be stored to obtain n data blocks;
[0102] Step 0112: Generate a coding matrix based on the number of nodes in the first blockchain and the number of nodes in the second blockchain;
[0103] Step 0113: Multiply the coding matrix and the column vectors of the n data blocks to obtain m redundant blocks.
[0104] Specifically, in the encoding and decoding module, based on the RS encoding technology, the data to be stored can be divided according to the number of the first blockchain nodes, thereby obtaining n data blocks, and then according to the number of the first blockchain nodes and the number of the second blockchain nodes, a coding matrix is generated, the number of rows of the coding matrix is the same as the number of the first blockchain nodes, the number of columns of the coding matrix is the same as the total number of the first blockchain nodes and the second blockchain nodes, and then the coding matrix is multiplied by the column vector composed of n data blocks to obtain m redundant blocks. For example, taking the number of data blocks as the same as the number of the first blockchain nodes, the number of redundant blocks as the number of the second blockchain nodes, the number of the first blockchain nodes as n, and the number of the second blockchain nodes as m as an example, the data to be stored is divided by the RS encoding technology to obtain n data blocks, and then according to n and m, a (n+m)×n coding matrix is generated, and then the (n+m)×n coding matrix is multiplied by the n×1 column vector composed of n data blocks to obtain a (n+m)×1 data matrix, and the data matrix includes n data blocks and m redundant blocks.
[0105] See also Figure 8 Optionally, step 0112: generating a coding matrix based on the number of the first blockchain nodes and the number of the second blockchain nodes, including:
[0106] Step 01121: Generate a first matrix and a second matrix, the number of rows and columns of the first matrix are the same as the number of nodes of the first blockchain, the first matrix is a unit matrix, the number of columns of the second matrix is the same as the number of nodes of the first blockchain, and the number of rows of the second matrix is the same as the number of nodes of the second blockchain;
[0107] Step 01122: vertically concatenate the first matrix and the second matrix to generate a coding matrix.
[0108] The second matrix may be a Vandermonde matrix.
[0109] Specifically, based on RS coding, taking the number of first blockchain nodes as n, the number of second blockchain nodes as m, n data blocks and m redundant blocks as an example, according to the number of first blockchain nodes n and the number of second blockchain nodes m, an n×n first matrix and an m×n Vandermonde matrix are generated, the first matrix is the unit matrix, and then the first matrix and the second matrix are vertically spliced, and the first matrix is located above the second matrix, so as to generate a coding matrix.
[0110] For example, see Fig. 9 , taking the number of the first blockchain nodes as n, the number of the second blockchain nodes as m, the number of data blocks as n, and the number of redundant blocks as m, where n=3 and m=2 as an example, based on RS coding, according to the number of the first blockchain nodes, the following is generated: Fig. 9 The 3×3 unit matrix and the 2×3 Vandermonde matrix are shown. The 2×3 Vandermonde matrix is concatenated under the 3×3 unit matrix to obtain a 5×3 coding matrix. The 5×3 coding matrix is then multiplied by a 3×1 column vector consisting of three data blocks to obtain a data column vector. The data column vector includes the three data blocks sorted on top (i.e., n1, n2, and n3 in the figure) and the two redundant blocks sorted on the bottom (i.e., m1 and m2 in the figure).
[0111] It can be understood that the first blockchain node and the second blockchain node can be sorted with the first blockchain node in front and the second blockchain node in the back, and then according to the sorting, the three data blocks sorted at the top in the data column vector are correspondingly stored in the three first blockchain nodes sorted in front, and the two redundant blocks sorted at the bottom in the data column vector are correspondingly stored in the two second blockchain nodes sorted in the back.
[0112] See also Fig.10 In some embodiments, step 012: storing each data block in each first blockchain node respectively includes:
[0113] Step 0121: when the block size of the data block is greater than the block storage threshold preset by the first blockchain node, the data block is split again based on the number of the first blockchain nodes to obtain split data blocks, and the block size of the split data blocks is less than or equal to the block storage threshold;
[0114] Step 0122: Store each divided data block in each first blockchain node respectively.
[0115] Among them, the block storage threshold can be 10 bytes (kb), 15kb, 20kb, 50kb, etc. The block storage threshold can be determined according to the minimum storage threshold among the storage thresholds of each node in the blockchain. For example, the storage thresholds of each node in the blockchain are obtained as follows: 10kb, 12kb, 24kb, then the block storage threshold is determined to be 10kb.
[0116] Specifically, when the block size of a data block is greater than the block storage threshold preset by the first blockchain node, the data block is divided again based on the number of the first blockchain nodes. For example, each data block may be divided equally, and each equally divided data block is stored in the first blockchain node respectively; or, the data block may be divided into the size of the storage threshold according to the storage threshold of each node, and the data block is stored in the corresponding node in sequence; or, the data block may be divided into multiple small data blocks, and different numbers of small data blocks are stored in different nodes. The block size of the divided data block is less than or equal to the block storage threshold, and the number n of the divided data blocks may be an integer multiple of the number of the first blockchain nodes, and each divided data block is stored in each first blockchain node respectively.
[0117] See also Fig.11 In some embodiments, the data storage method further comprises:
[0118] Step 016: Based on the number t of the first blockchain nodes and the number p of the virtual blockchain nodes, i keys are generated, each blockchain node consisting of the first blockchain node and the virtual blockchain node corresponds to the key one by one, the virtual blockchain node includes multiple second blockchain nodes, and t, p, and i are all positive integers;
[0119] Step 017: Based on the i keys, key data is allocated to the first blockchain node and the virtual blockchain node;
[0120] Step 018: Based on the key data, generate a private key for decryption and a public key for encryption.
[0121] Among them, i=t+p. When generating a private key and a public key, it can be based on an asymmetric encryption algorithm, such as RSA algorithm. This application does not impose any restrictions on this. The embodiment of this application takes the generation of private keys and public keys based on RSA algorithm as an example for explanation; when generating private keys and public keys, multiple (such as 2, 3, 4, etc., this application does not impose any restrictions on this) second blockchain nodes can be regarded as a virtual blockchain node, and one virtual blockchain node generates one key; the key data can be data calculated based on the key, and the private key can be calculated based on multiple keys and the key data corresponding to the multiple keys.
[0122] Specifically, in the key generation module, based on the distributed key generation DKG technology, each first blockchain node and each virtual blockchain node can be sorted and numbered. For example, t first blockchain nodes and a number of second blockchain nodes are sorted from high to low credibility, and then the second blockchain nodes in the sorting are grouped in pairs, and each group of second blockchain nodes is used as a virtual blockchain node, thereby obtaining p virtual blockchain nodes; then the t first blockchain nodes and p virtual blockchain nodes are numbered according to the sorting to obtain each blockchain node numbered 1 to i, and i keys are generated through the encryption and decryption module, and each blockchain node consisting of the first blockchain node and the virtual blockchain node corresponds to the key one by one.
[0123] Optionally, the key includes a polynomial, and the number of terms of the polynomial is determined according to the number t of the first blockchain nodes.
[0124] Specifically, the key can be based on the key polynomial Generate, where etc. are all randomly selected values or values randomly selected by each node, i is the number of each blockchain node, each blockchain node includes a first blockchain node and a virtual blockchain node, and t is the number of first blockchain nodes.
[0125] Specifically, each key can be based on the key polynomial Generation can generate each key polynomial according to each node, that is, t first blockchain nodes and p virtual blockchain nodes, a total of i blockchain nodes corresponding to the generation of i key polynomials, each first blockchain node or virtual blockchain node corresponds to a key polynomial; then based on the i key polynomials, generate multiple key data, and based on the multiple key data, generate a private key for decryption and a public key for encryption; the number of terms of the key polynomial is determined according to the number t of the first blockchain nodes. In the present application, the threshold value is also determined according to the number t of the first blockchain nodes, so the threshold value is the same as the number of terms of the key polynomial.
[0126] For example, see Fig.12 , after sorting the three first blockchain nodes (i.e., node 1, node 2, and node 3) and the two second blockchain nodes (i.e., node 4 and node 5) according to their credibility, we get the following: Fig.12 The order shown in is: node 1, node 2, node 3, node 4, node 5, as an example for explanation, where the number of the first blockchain nodes is 3, that is, t = 3, then the number of terms in the polynomial is 3, and the two second blockchain nodes are used as one virtual blockchain node, and then the three first blockchain nodes and one virtual blockchain node are numbered, and the result is as follows Fig.12The first blockchain node numbered 1, the first blockchain node numbered 2, the first blockchain node numbered 3, and the virtual blockchain node numbered 4 are shown. The four blockchain nodes generate four keys f correspondingly. i (x), that is, the first blockchain node numbered 1 generates the first key The first blockchain node numbered 2 generates the first key The first blockchain node numbered 3 generates the first key The virtual blockchain node numbered 4 generates the second key Four keys generate multiple key data correspondingly. For example, key f1(x) generates key data (1, f1(1)), (2, f1(2)), (3, f1(3)) and (4, f1(4)), key f2(x) generates key data (1, f2(1)), (2, f2(2)), (3, f2(3)) and (4, f2(4)), key f3(x) generates key data (1, f3(1)), (2, f3(2)), (3, f3(3)) and (4, f3(4)), key f4(x) generates key data (1 , f4(1)), (2, f4(2)), (3, f4(3)) and (4, f4(4)), and then assign key data to the first blockchain node and the virtual blockchain node. For example, each key data is assigned to the first blockchain node, and then any part of the key data is taken from each key data and assigned to the second blockchain node in the virtual blockchain node, etc. Private keys and public keys are generated based on multiple key data corresponding to the four keys. Private keys and public keys can be generated based on all the above key data, or private keys and public keys can be generated based on the key data corresponding to the first blockchain node, etc.
[0127] See also Fig.13 Optionally, the key data includes first key data, second key data, and third key data. Step 017: Based on the i keys, assigning key data to the first blockchain node and the virtual blockchain node includes:
[0128] Step 0171: Allocate first key data to each first blockchain node based on i keys;
[0129] Step 0172: Based on the first target key corresponding to the virtual blockchain node, allocate second key data to each second blockchain node in the virtual blockchain node;
[0130] Step 0173: Based on the t second target keys corresponding to the t first blockchain nodes, third key data is allocated to the virtual blockchain node, and the third key data is split into each second blockchain node in the virtual blockchain node.
[0131] Among them, the first target key can be the corresponding generated key determined by each virtual blockchain node from the i keys, such as Fig.12 In the example, the virtual blockchain node numbered 4 corresponds to the first target key f4(x); the second target key can be the corresponding generated key determined by each first blockchain node from the i keys, such as Fig.12 , the first blockchain node numbered 1 corresponds to the second target key f1(x).
[0132] Specifically, the key data includes first key data, second key data and third key data. Based on i keys, multiple key data are generated, and then the first key data in the key data is distributed to each first blockchain node. When the key is generated based on the key polynomial, after the first blockchain nodes and the virtual blockchain nodes are sorted and numbered, the first key data can be the data obtained by substituting the numbers corresponding to each first blockchain node into each key polynomial for calculation. For example, taking two keys, namely key f1(x) and key f2(x), only one first blockchain node, and the first blockchain node is blockchain node No. 1 as an example, the first key data can be F1(1) obtained by adding (1, f1(1)) and (1, f2(1)).
[0133] Then, based on the first target key corresponding to the virtual blockchain node, second key data is allocated to each second blockchain node in the virtual blockchain node. After taking multiple second blockchain nodes as a group and determining a group of second blockchain nodes as virtual blockchain nodes, the first blockchain node and the virtual blockchain node are numbered and corresponding keys are generated. Then, the key generated corresponding to the virtual blockchain node (such as f4(x) corresponding to the blockchain node numbered 4 in the figure) is used as the first target key. Then, according to the first target key, the numbers corresponding to each virtual blockchain node are substituted into the first target key to calculate the second key data, and the second key data is allocated to each second blockchain node in the virtual blockchain node. For example, please refer to Fig.12 Continuing with the example of generating the key f4(x) corresponding to blockchain node number 4, determine that the first target key is f4(x), obtain the second key data (4, f4(4)) based on f4(x), and distribute the second key data (4, f4(4)) to the second blockchain node 4 and the second blockchain node 5 included in blockchain node number 4.
[0134] Finally, based on the t second target keys corresponding to the t first blockchain nodes, the third key data is allocated to the virtual blockchain node, and the third key data is split into each second blockchain node in the virtual blockchain node. When the first blockchain node and the virtual blockchain node are numbered, and keys are generated for each numbered blockchain node, the key generated for the first blockchain node (such as f1(x) corresponding to the numbered blockchain node 1, f2(x) corresponding to the numbered blockchain node 2, etc.) is used as the second target key, and then the number of the virtual blockchain node is substituted into each second target key according to the second target key to obtain multiple third key data, and then the multiple third key data are split, and the split third key data are respectively distributed to each second blockchain node in the virtual blockchain node.
[0135] See also Fig.14 Optionally, the third key data includes t pieces, and the third key data corresponds to the second target key one by one. Step 0173: splitting the third key data into each second blockchain node in the virtual blockchain node includes:
[0136] Step 01731: Split the t third key data based on the number of second blockchain nodes in the virtual blockchain node to distribute the t third key data to each second blockchain node respectively.
[0137] Specifically, based on the number of second blockchain nodes in the virtual blockchain node, t third key data are split to distribute t third key data to each second blockchain node respectively. When distributing the third key data, the third key data may be evenly distributed to each second blockchain node in the virtual blockchain node, or unevenly distributed to each second blockchain node in the virtual blockchain node. No matter how the third key data is distributed, any second blockchain node in the virtual blockchain node cannot have all the third key data. For example, if the virtual blockchain node includes 2 second blockchain nodes, the third key data is split into 2 groups, and the 2 groups of third key data are respectively distributed to the 2 second blockchain nodes; or, if the virtual blockchain node includes 3 second blockchain nodes, the third key data is split into 6 groups, and the 6 groups of third key data are evenly distributed to the 3 second blockchain nodes, that is, each second blockchain node is allocated 2 groups of third key data; or, if the virtual blockchain node includes 2 second blockchain nodes, the third key data is split into 3 groups, and any two groups of third key data are distributed to any second blockchain node, and the remaining third key data is distributed to another second blockchain node.
[0138] For another example, please see Fig.12, after sorting the three first blockchain nodes (i.e., node 1, node 2, and node 3) and the two second blockchain nodes (i.e., node 4 and node 5) according to their credibility, we get the following: Fig.12 The order shown in is: node 1, node 2, node 3, node 4, node 5, as an example for explanation, where the number of the first blockchain nodes is 3, that is, t = 3, then the number of terms in the polynomial is 3, and the two second blockchain nodes are used as one virtual blockchain node, and then the three first blockchain nodes and one virtual blockchain node are numbered, and the result is as follows Fig.12 The first blockchain node numbered 1, the first blockchain node numbered 2, the first blockchain node numbered 3, and the virtual blockchain node numbered 4 are shown. The four blockchain nodes generate four keys f correspondingly. i (x), the first blockchain node numbered 1 generates a key f1(x), the first blockchain node numbered 2 generates a key f2(x), the first blockchain node numbered 3 generates a key f3(x), and the virtual blockchain node numbered 4 generates a key f4(x). The three keys corresponding to the three first blockchain nodes, namely, key f1(x), key f2(x), and key f3(x), are determined as the second target keys. The third key data are calculated according to the number of the virtual blockchain node (namely, number 4): (4, f1(4)), (4, f2(4)) and (4, f3(4)), and then according to the threshold value s=t=3, the third key data of i>s / 2 is distributed to any second blockchain node in the virtual blockchain node (i.e., blockchain node numbered 4), and the remaining third key data is distributed to another second blockchain node in the virtual blockchain node. If s / 2=1.5, (4, f1(4)) is distributed to the second blockchain node 4 in the virtual blockchain node, and (4, f2(4)) and (4, f3(4)) are distributed to the second blockchain node 5 in the virtual blockchain node.
[0139] See also Fig.15 and Fig.16 In some embodiments, step 018: generating a private key for decryption and a public key for encryption based on the key data includes:
[0140] Step 0181: Obtain first key data;
[0141] Step 0182: In the case where at least part of the first key data is missing, the second key data and the third key data are obtained, and based on the first key data, the second key data and the third key data that are not missing, a private key for decryption and a public key for encryption are generated;
[0142] Step 0183: When the first key data is not missing, generate a private key for decryption and a public key for encryption based on the first key data that is not missing.
[0143] Specifically, the first key data generated by each first blockchain node is obtained, and a private key for decryption and a public key for encryption are generated according to each first key data, such as adding each first key data to obtain the corresponding private key and public key. Before the data block (or redundant block) is stored in the corresponding first blockchain node (or second blockchain node), it will be encrypted using the public key. When decryption is required, each first blockchain can communicate with each other to obtain each first key data. When the first key data is not missing, a private key for decryption is generated based on the first key data that is not missing. After the first blockchains communicate with each other, if at least some of the first blockchain nodes do not respond, that is, when at least some of the first key data is missing, the second key data and the third key data are obtained through communication between the second blockchain nodes, and then a private key for decryption is generated based on the first key data that is not missing, so as to perform decryption.
[0144] For example, see Fig.12 and Fig.17 Continuing with the previous example, the three first blockchain nodes (i.e., node 1, node 2, and node 3) and the two second blockchain nodes (i.e., node 4 and node 5) are sorted by credibility to obtain the following: Fig.12 Taking the order shown in: node 1, node 2, node 3, node 4, node 5 as an example, a first key is assigned to each first blockchain node based on four keys (f1(x), f2(x), f3(x), and f4(x)), as shown in Fig.17, the first blockchain node 1 is allocated (1, f1(1)), (1, f2(1)), (1, f3(1)) and (1, f4(1)), and the first key data F1 is obtained by adding (1, f1(1)), (1, f2(1)), (1, f3(1)) and (1, f4(1)); the first blockchain node 2 is allocated (2, f1(2)), (2, f2(2)), (2, f3(2)) and (2, f4(2)), and the first key data F2 is obtained by adding (2, f1(2)), (2, f2(2)), (2, f3(2)) and (2, f4(2)); the first blockchain node 3 is allocated (3, f1(3)), (3, f2(3)), (3, f3(3)) and (3, f4(3)), and the first key data F2 is obtained by adding (3, f1(3)), (3, f2(3)), (3, f3(3)) and (3, f4(3)). (3, f2(3)), (3, f3(3)) and (3, f4(3)) are added to obtain the first key data F3; for the virtual blockchain node numbered 4 (including the second blockchain node 4 and the second blockchain node 5), the first target key is determined to be f4(x), and the second blockchain node 4 and the second blockchain node 5 in the virtual blockchain node are allocated the second key data (4, f4(4)), based on the three first blockchain nodes (i.e., the first blockchain node 1, the first blockchain node 2 and the first blockchain node 3), three second target keys, i.e., f1(x), f2(x) and f3(x), are determined, and the third key data are determined to be: (4, f1(4)), (4, f2(4)) and (4, f3(4)), and the three third key data are split to be allocated to each second blockchain node, as shown in FIG. Fig.17 In the example, the second blockchain node 4 is assigned (4, f1(4)), and the second blockchain node 5 is assigned (4, f2(4)) and (4, f3(4)).
[0145] By obtaining the first keys F1, F2 and F3, when none of the first keys F1, F2 and F3 are missing, by performing calculations such as addition on the first keys F1, F2 and F3, a private key sk for decryption and a public key pk for encryption are generated; when part of the first keys F1, F2 and F3 are missing, Fig.17 In the example, assuming that F1 is missing, the second blockchain node 4 and the second blockchain node 5 communicate with each other to obtain the third key data (4, f1(4)), (4, f2(4)) and (4, f3(4)). Based on the first key data F2 and F3, the second key data (4, f4(4)), the third key data (4, f1(4)), (4, f2(4)) and (4, f3(4)), the private key sk and the public key pk are calculated by the interpolation recovery method.
[0146] It can be understood that the existing DKG distributed key generation technology uses each blockchain node to participate in the generation of system public and private keys with the same and equal weights. In this way, in the process of generating keys in the blockchain field, malicious nodes cannot be distinguished from non-malicious nodes. However, this application takes the credibility of each blockchain node into consideration, first distinguishes the first blockchain node with higher credibility and the second blockchain node with lower credibility. The second blockchain node with lower credibility has a lower weight when generating keys, and needs to communicate with another second blockchain node to obtain the third key data, and then communicate with the remaining high-credibility nodes to calculate the private key and public key. Therefore, through the differential construction of key generation by this application, not only can the independence and feasibility of key generation without the participation of a third party be achieved, but also the credibility of the generated key can be guaranteed.
[0147] See also Fig.18 In some embodiments, before storing each data block in each first blockchain node and storing each redundant block in each second blockchain node, the data storage method further includes:
[0148] Step 019: Encrypt the data block and the redundant block based on the public key.
[0149] Specifically, through the encryption and decryption module, before each data block is stored in each first blockchain node respectively and each redundant block is stored in each second blockchain node respectively, each data block and each redundant block is encrypted according to the generated public key to improve the security of data storage.
[0150] See also Fig.19 In some embodiments, the data storage method further comprises:
[0151] Step 020: Upon receiving a data block of a first blockchain node and at least one of a redundant block of a second blockchain node, decrypt the received data block and redundant block based on a private key.
[0152] Specifically, through the encryption and decryption module, when the data block of the first blockchain node and at least one of the redundant blocks of the second blockchain node are received, the private key is calculated according to each first key, and the received data block and redundant block are decrypted according to the private key; or, the private key is calculated according to the non-missing first key data, the second key data and the third target key, and the received data block and redundant block are decrypted according to the private key.
[0153] See also Fig. 20 In some embodiments, the data storage method further comprises:
[0154] Step 021: After the public key and private key are generated last time, if the stored data of each node meets the preset conditions, re-enter the step of generating i keys based on the number of first blockchain nodes t and the number of virtual blockchain nodes p.
[0155] Among them, the preset condition can be at least one of the following: the number of storage rounds of stored data is greater than the preset number of rounds, the storage capacity of stored data is greater than the preset storage capacity, and the storage duration of stored data is greater than the preset duration; the number of storage rounds can be the number of rounds in which the blockchain stores the data to be stored and completes the storage; the preset storage capacity can be set according to the node storage capacity, such as 100kb, 200kb, etc.; the storage duration can be 15 minutes (min), 30min, 1 hour (h), 2h, etc.
[0156] Specifically, in order to prevent the leakage of private keys and further improve the security of data storage, after the last generation of public keys and private keys, if the data to be stored stored in each node meets the preset conditions, the public keys and private keys are regenerated. For example, if the preset condition is that the number of storage rounds of the stored data is greater than the preset number of rounds, the preset number of rounds is taken as an example to illustrate that after the last generation of public keys and private keys, the data to be stored is encrypted according to the public key and the data to be stored is stored three times, and after the third storage is completed or the data to be stored is received for the fourth time, i keys are regenerated; if the preset condition is that the storage amount of the stored data is greater than the preset storage amount, the preset storage amount is 500kb as an example to illustrate that when the storage amount of the node reaches 500kb, it is considered that the preset condition is met and i keys are regenerated; if the preset condition is that the storage time of the stored data is greater than the preset time, the preset time is 45min as an example to illustrate that after the data to be stored is stored and converted to the stored data, i keys are regenerated when the storage time of the stored data meets 45min.
[0157] See also Fig.21 In order to better implement the data storage method of the embodiment of the present application, the embodiment of the present application also provides a data storage device 10. The data storage device 10 may include a correction coding module 11 and a storage module 12. The correction coding module 11 is used to perform correction coding on the data to be stored to generate n data blocks and m redundant blocks. In the case of missing data blocks or redundant blocks, the data to be stored can be restored based on the remaining data blocks and redundant blocks. n is determined according to the number of first blockchain nodes, and m is determined according to the number of second blockchain nodes. The credibility of the second blockchain node is lower than that of the first blockchain node. The storage module 12 is used to store each data block in each first blockchain node, and store each redundant block in each second blockchain node.
[0158] In one embodiment, the correction coding module 11 is specifically used to divide the data to be stored to obtain n data blocks; generate a coding matrix based on the number of first blockchain nodes and the number of second blockchain nodes; multiply the coding matrix and the column vector of the n data blocks to obtain m redundant blocks.
[0159] In one embodiment, the correction coding module 11 is specifically used to generate a first matrix and a second matrix, the number of rows and columns of the first matrix are the same as the number of first blockchain nodes, the first matrix is a unit matrix, the number of columns of the second matrix is the same as the number of first blockchain nodes, and the number of rows of the second matrix is the same as the number of second blockchain nodes; the first matrix and the second matrix are vertically spliced to generate a coding matrix.
[0160] In one embodiment, the storage module 12 is further specifically used to split the data block again based on the number of first blockchain nodes to obtain split data blocks when the block size of the data block is greater than the block storage threshold preset by the first blockchain node, and the block size of the split data block is less than or equal to the block storage threshold; and store each split data block in each first blockchain node respectively.
[0161] In one embodiment, the data storage device 10 also includes a generation module 13, which is used to generate i keys based on the number of first blockchain nodes t and the number of virtual blockchain nodes p, each blockchain node consisting of the first blockchain node and the virtual blockchain node corresponds to the key one by one, the virtual blockchain node includes multiple second blockchain nodes, t, p, and i are all positive integers; based on the i keys, key data is allocated to the first blockchain node and the virtual blockchain node; based on the key data, a private key for decryption and a public key for encryption are generated.
[0162] In one embodiment, the key data includes first key data, second key data and third key data, and the generation module 13 is specifically used to allocate first key data to each first blockchain node based on i keys; allocate second key data to each second blockchain node in the virtual blockchain node based on the first target key corresponding to the virtual blockchain node; allocate third key data to the virtual blockchain node based on t second target keys corresponding to t first blockchain nodes, and split the third key data into each second blockchain node in the virtual blockchain node.
[0163] In one embodiment, the third key data includes t pieces, and the third key data and the second target key correspond one to one. The generation module 13 is also specifically used to split the t pieces of third key data based on the number of second blockchain nodes in the virtual blockchain node, so as to distribute the t pieces of third key data to each second blockchain node respectively.
[0164] In one embodiment, the generation module 13 is specifically used to obtain first key data; when at least part of the first key data is missing, obtain second key data and third key data, and generate a private key for decryption and a public key for encryption based on the first key data, the second key data and the third target key that are not missing; when the first key data is not missing, generate a private key for decryption and a public key for encryption based on the first key data that are not missing.
[0165] In one embodiment, the data storage device 10 further includes an encryption module 14, which is used to encrypt the data block and the redundant block based on a public key.
[0166] In one embodiment, the data storage device 10 also includes a decryption module 15, which is used to decrypt the received data block and redundant block based on a private key when receiving a data block of a first blockchain node and at least one of a redundant block of a second blockchain node.
[0167] In one embodiment, the generation module 13 is also specifically used to re-enter the step of generating i keys based on the number t of the first blockchain nodes and the number p of the virtual blockchain nodes if the stored data of each node meets the preset conditions after the public key and the private key were generated last time.
[0168] In one embodiment, the data storage device 10 also includes a recovery module 16, which is used to obtain data blocks from each first blockchain node when all first blockchain nodes respond, so as to recover the data to be stored based on the obtained data blocks; when at least one of the first blockchain nodes does not respond, obtain data blocks from each first blockchain node and obtain redundant blocks from each second blockchain node, so as to recover the data to be stored based on the obtained data blocks and redundant blocks.
[0169] In one embodiment, the data storage device 10 also includes a determination module 17, which is used to determine the first blockchain node and the second blockchain node in each node based on at least one of the response times and data tampering information of each node.
[0170] The data storage device 10 is described above from the perspective of a functional module in conjunction with the accompanying drawings. The functional module can be implemented in hardware form, can be implemented in software form, or can be implemented in combination with hardware and software modules. Specifically, the steps of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit in the processor and / or the instructions in software form. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware coding processor to execute, or can be executed by a combination of hardware and software modules in the coding processor. Optionally, the software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the steps in the above method embodiment in conjunction with its hardware.
[0171] See also Fig. 22 The computer device of the embodiment of the present application includes a processor 402, a memory 403 and a computer program, wherein the computer program is stored in the memory 403 and executed by the processor 402, and the computer program includes instructions for executing the data storage method of any of the above embodiments.
[0172] In one embodiment, the computer device may be a terminal 400 or a server 100. Its internal structure diagram may be as follows: Fig.12 The computer device includes a processor 402, a memory 403, a network interface 404, a display screen 401 and an input device 405 connected via a system bus.
[0173] Among them, the processor 402 of the computer device is used to provide computing and control capabilities. The memory 403 of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface 404 of the computer device is used to communicate with an external device through a network connection. When the computer program is executed by the processor, the data storage method of any of the above-mentioned embodiments is implemented. The display screen 401 of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device 405 of the computer device can be a touch layer covering the display screen 401, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0174] Those skilled in the art will understand that Fig. 22The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0175] The embodiments of the present application further provide a computer program product, including a computer program, wherein the computer program includes instructions for the data storage method of any one of the above embodiments, which will not be described in detail here for the sake of brevity.
[0176] See also Fig.23 The embodiment of the present application also provides a computer-readable storage medium 600 on which a computer program 610 is stored. When the computer program 610 is executed by a processor 620, the steps of the data storage method of any of the above-mentioned embodiments are implemented. For the sake of brevity, they are not repeated here.
[0177] In the description of this specification, the descriptions with reference to the terms "certain embodiments", "in an example", "exemplarily", etc., mean that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0178] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0179] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A data storage method, characterized in that: include: Correction encoding is performed on the data to be stored to generate n data blocks and m redundant blocks. When the data blocks or the redundant blocks are missing, the data to be stored can be restored based on the remaining data blocks and the redundant blocks. The n is determined according to the number of first blockchain nodes, and the m is determined according to the number of second blockchain nodes. The credibility of the second blockchain nodes is lower than the credibility of the first blockchain nodes. Each of the data blocks is stored in each of the first blockchain nodes, and each of the redundant blocks is stored in each of the second blockchain nodes.
2. The data storage method according to claim 1, characterized in that: The correction encoding of the data to be stored to generate n data blocks and m redundant blocks includes: Splitting the data to be stored to obtain the n data blocks; Generate a coding matrix based on the number of the first blockchain nodes and the number of the second blockchain nodes; The encoding matrix and the column vectors of the n data blocks are multiplied to obtain the m redundant blocks.
3. The data storage method according to claim 2, characterized in that: The generating a coding matrix based on the number of the first blockchain nodes and the number of the second blockchain nodes includes: Generate a first matrix and a second matrix, wherein the number of rows and the number of columns of the first matrix are both the same as the number of the first blockchain nodes, the first matrix is a unit matrix, the number of columns of the second matrix is the same as the number of the first blockchain nodes, and the number of rows of the second matrix is the same as the number of the second blockchain nodes; The first matrix and the second matrix are vertically spliced to generate the encoding matrix.
4. The data storage method according to claim 2, characterized in that: The storing each of the data blocks to each of the first blockchain nodes respectively includes: When the block size of the data block is greater than the block storage threshold preset by the first blockchain node, the data block is split again based on the number of first blockchain nodes to obtain split data blocks, and the block size of the split data blocks is less than or equal to the block storage threshold; The divided data blocks are stored in the first blockchain nodes respectively.
5. The data storage method according to claim 1, characterized in that: The data storage method further comprises: Based on the number t of the first blockchain nodes and the number p of virtual blockchain nodes, i keys are generated, each blockchain node consisting of the first blockchain node and the virtual blockchain node corresponds to the key one by one, the virtual blockchain node includes a plurality of the second blockchain nodes, and t, p, and i are all positive integers; Based on the i keys, assign key data to the first blockchain node and the virtual blockchain node; Based on the key data, a private key for decryption and a public key for encryption are generated.
6. The data storage method according to claim 5, characterized in that: The key data includes first key data, second key data, and third key data, and the allocating key data to the first blockchain node and the virtual blockchain node based on the i keys includes: Allocate the first key data to each first blockchain node based on the i keys; Based on the first target key corresponding to the virtual blockchain node, assign the second key data to each of the second blockchain nodes in the virtual blockchain node; Based on the t second target keys corresponding to the t first blockchain nodes respectively, the third key data is allocated to the virtual blockchain node, and the third key data is split into each of the second blockchain nodes in the virtual blockchain node.
7. The data storage method according to claim 6, characterized in that: The third key data includes t pieces, the third key data and the second target key correspond one to one, and the splitting of the third key data into each of the second blockchain nodes in the virtual blockchain node includes: The t pieces of the third key data are split based on the number of the second blockchain nodes in the virtual blockchain node, so as to distribute the t pieces of the third key data to each of the second blockchain nodes respectively.
8. The data storage method according to claim 6 or 7, characterized in that: The step of generating a private key for decryption and a public key for encryption based on the key data comprises: Obtaining the first key data; In the case where at least part of the first key data is missing, acquiring the second key data and the third key data, and generating a private key for decryption and a public key for encryption based on the first key data, the second key data and the third key data that are not missing; In a case where the first key data is not missing, a private key for decryption and a public key for encryption are generated based on the first key data that is not missing.
9. The data storage method according to any one of claims 5 to 8, characterized in that: The key includes a polynomial, and the number of terms of the polynomial is determined according to the number t of the first blockchain nodes.
10. The data storage method according to claim 5, characterized in that: Before storing each of the data blocks in each of the first blockchain nodes and storing each of the redundant blocks in each of the second blockchain nodes, the data storage method further includes: The data block and the redundant block are encrypted based on the public key.
11. The data storage method according to claim 5, characterized in that: The data storage method further comprises: Upon receiving at least one of the data block of the first blockchain node and the redundant block of the second blockchain node, the received data block and the redundant block are decrypted based on the private key.
12. The data storage method according to claim 5, characterized in that: The data storage method further comprises: After the public key and private key are generated last time, if the stored data of each node meets the preset conditions, the step of generating i keys based on the number t of the first blockchain nodes and the number p of virtual blockchain nodes is re-entered.
13. The data storage method according to claim 12, characterized in that: The preset condition includes at least one of the following conditions: The number of storage rounds of the stored data is greater than a preset number of rounds; The storage capacity of the stored data is greater than the preset storage capacity; and The storage time of the stored data is greater than the preset time.
14. The data storage method according to claim 1, characterized in that: The data storage method further comprises: When all the first blockchain nodes respond, the data blocks are obtained from the first blockchain nodes to restore the data to be stored according to the obtained data blocks; In the event that at least one of the first blockchain nodes does not respond, the data blocks are obtained from the first blockchain nodes and the redundant blocks are obtained from the second blockchain nodes, so as to restore the data to be stored based on the obtained data blocks and redundant blocks.
15. The data storage method according to any one of claims 1 to 14, characterized in that: The data storage method further comprises: Based on at least one of the number of responses of each node and the data tampering information, the first blockchain node and the second blockchain node are determined in each of the nodes.
16. A data storage device, characterized in that: include: A correction coding module, used for performing correction coding on the data to be stored to generate n data blocks and m redundant blocks. In the case where the data blocks or the redundant blocks are missing, the data to be stored can be restored based on the remaining data blocks and the redundant blocks, wherein n is determined according to the number of first blockchain nodes, and m is determined according to the number of second blockchain nodes, and the credibility of the second blockchain nodes is lower than the credibility of the first blockchain nodes; A storage module is used to store each of the data blocks in each of the first blockchain nodes, and to store each of the redundant blocks in each of the second blockchain nodes.
17. A computer device, characterized in that: include: A processor, the processor is connected to a memory; a computer program is stored in the memory, and the processor executes the computer program to implement instructions of the data storage method described in any one of claims 1 to 15.
18. A computer program product, characterized in that Comprising a computer program, the computer program comprising instructions for executing the data storage method according to any one of claims 1 to 15.
19. A non-volatile computer-readable storage medium, characterized in that: The invention comprises a computer program, which, when executed by a processor, enables the processor to execute the data storage method according to any one of claims 1 to 15.
