A knowledge graph file storage method enabled by blockchain sharding

The knowledge graph file storage method empowered by blockchain sharding solves the challenges of scalability and transaction security of the blockchain system, achieves safe and efficient storage of knowledge graph files and improves transaction security, avoiding Issues of repetitive work and performance degradation.

CN113626875BInactive Publication Date: 2024-09-27BEIJING INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110761601.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-06
Publication Date
2024-09-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The scalability and transaction security of the blockchain system present challenges in the sharding solution, especially security threats such as performance degradation and double-spend attacks caused by frequent cross-shard communications, which are difficult to effectively defend against.

Method used

Adopting the knowledge graph file storage method empowered by blockchain sharding, it generates hash encrypted transactions, divides network shards, elects leader nodes, uses verifiable random functions and improved consensus mechanisms, and dynamic programming algorithms to optimize transaction distribution. Prevent double-spending attacks and malicious behaviors, and improve system throughput and security.

Benefits of technology

It achieves safe and efficient storage of knowledge graph files, prevents tampering and repeated construction, improves the throughput and transaction security of the blockchain system, and avoids repetitive work and extended business response time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113626875B
    Figure CN113626875B
Patent Text Reader

Abstract

The present invention relates to a knowledge graph file storage method enabled by blockchain sharding, and belongs to the field of blockchain application technology. The method stores the knowledge graph file in the blockchain, solving the problems of secure storage and traceability of the knowledge graph construction file. When there is an inference error or file security problem in the knowledge graph, the corresponding process file can be obtained from the blockchain according to demand, and the repetitive construction process can be avoided. The method is based on the inter-shard communication confirmation mechanism to prevent double-spending attacks on different shards. Through random verification functions, asset mortgages and improved practical Byzantine fault tolerance mechanisms, malicious behavior of nodes is prevented and transaction security in the shards is guaranteed. The method adopts an optimized sharding scheme to improve the throughput of the blockchain system. Under multiple constraints, the optimal transaction selection scheme is given based on a dynamic programming algorithm to maximize the benefits of this shard, and efficient and reasonable transaction sharding is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a knowledge graph file storage method enabled by blockchain sharding, and belongs to the technical field of blockchain application. Background Art

[0002] With the vigorous development of artificial intelligence, knowledge graphs have received widespread attention. In the process of building knowledge graphs, process files are easily tampered with and forged maliciously, resulting in deviations in reasoning results. Blockchain has the characteristics of transparency, tamper-proofing, and traceability, and has broad prospects in the process of building knowledge graphs. When reasoning errors or file security issues occur, the corresponding process files can be obtained from the blockchain as needed to avoid repetitive work such as knowledge graph reconstruction.

[0003] Scalability is a key factor that hinders the further widespread application of blockchain systems. Its core is to solve the two aspects of transaction throughput and transaction speed. In order to improve the scalability of blockchain systems, there are currently three basic types from the perspective of technical implementation: state channels, directed acyclic graphs, and sharding.

[0004] The basic idea of ​​the sidechain is that traders communicate through state channels. All transactions occur outside the main chain, and only the final state is broadcast to the main chain for verification. This method is suitable for high-frequency small transactions, but not for frequent changes in participants. Its disadvantage is that it requires participants to be online for a long time.

[0005] DAG (Directed Acyclic Graph) is a graph structure with vertices and directed edges. When DAG is used as the underlying data structure of blockchain, there is no concept of blocks. It is composed of transactions, and each newly constructed transaction needs to be linked to multiple previous transactions. When a user initiates a transaction, he first needs to find two transactions in the network to verify their legitimacy, and then bind his transaction with the two verified transactions and broadcast it to the network. After that, the transactions initiated by the user will be verified in the same way. The more other transactions verify a transaction, the higher the certainty of the transaction. When a critical value is reached, the transaction is considered to be confirmed. In theory, the larger the transaction volume, the faster the verification speed of the technology, so that high concurrency can be achieved. The disadvantage of DAG is that the transaction duration is uncontrollable, and it is easy for subsequent transactions to be delayed in verification.

[0006] Blockchain sharding is an on-chain scalability solution, which can be divided into network sharding, transaction sharding and state sharding according to technology. Network sharding is the basis of other sharding solutions. Its core idea is to divide the entire blockchain network into multiple shards, and all shards process transactions in the network in parallel. The main issue of transaction sharding is which transactions should be assigned to which shards for processing according to specific attributes. The core idea of ​​state sharding is that different shards store different parts of the blockchain ledger. Each node is only responsible for storing and managing the data of its own shard, and does not store the complete blockchain state.

[0007] There are at least two key challenges in optimization based on transaction sharding. First, unreasonable transaction allocation in shards may lead to huge communication overhead and even reduce the performance of the entire blockchain system. Specifically, frequent cross-shard communication will occupy a lot of bandwidth, increase transaction confirmation time, and ultimately reduce the throughput of the blockchain system. Second, there are transaction security threats in shards, such as double-spending attacks, distributed denial of service attacks, etc., so it is necessary to ensure that most nodes in each shard are honest. In the account / balance model, transactions are usually sharded to a certain shard based on the sender address. Using this method, double-spending transactions can be easily detected without cross-shard communication, but it cannot defend against distributed denial of service attacks. When an attacker initiates a large number of transactions using the same address, these transactions will be assigned to the same shard, causing the shard resources to be quickly exhausted. Summary of the invention

[0008] The purpose of this invention is to solve the technical problem of safe and efficient storage of knowledge graphs, and to propose a safe and efficient knowledge graph file storage method enabled by blockchain sharding.

[0009] In order to achieve the above object, the present invention adopts the following technical scheme.

[0010] A knowledge graph file storage method enabled by blockchain sharding.

[0011] First, explain the relevant concepts:

[0012] Definition 1: Knowledge Graph Process File

[0013] Refers to the document output during the knowledge graph construction process.

[0014] Definition 2: Blockchain Ledger

[0015] Refers to the infrastructure used to store knowledge graph files. In essence, it is a distributed database that integrates peer-to-peer transmission, consensus mechanism, and cryptographic algorithm.

[0016] Definition 3: Sharding

[0017] It is an on-chain solution to solve the scalability of blockchain. The blockchain nodes are divided into several independent network partitions, and transactions are processed in parallel by different shards to improve the throughput of the entire system.

[0018] Definition 4: Leader Node

[0019] It means that a leader node is elected in each shard through an asset mortgage mechanism. This node is responsible for transaction selection, block generation, and verification of blocks from other shards.

[0020] Definition 5: Follower Node

[0021] Refers to the nodes other than the leader node in each shard. Follower nodes are responsible for participating in the consensus process of their shards.

[0022] Definition 6: Verifiable Random Function

[0023] It refers to an encryption scheme that maps input to verifiable pseudo-random output. In this scheme, it is used to divide nodes when the network is sharded, thereby preventing malicious nodes from occupying a certain shard.

[0024] Definition 7: Consensus Mechanism

[0025] It refers to the verification and confirmation of transactions in a short period of time through voting by special nodes in the blockchain network.

[0026] Step 1: Generate blockchain transactions.

[0027] Export the process file of knowledge graph construction from the database and perform hash encryption. The user uses the generated hash value to construct a transaction and send it to the blockchain network.

[0028] Step 2: Shard the blockchain network.

[0029] The nodes in the entire blockchain network are divided into N subnets to verify transactions simultaneously, thereby improving the parallel processing capabilities of the system.

[0030] Step 3: Elect a leader node.

[0031] A leader node is selected in each shard to complete special tasks, including evaluating transactions, selecting transactions, generating blocks, verifying blocks, etc.

[0032] Step 4: Trade allocation and execution.

[0033] Transactions are assigned to different shards for execution, and each shard executes consensus independently. Step 4 specifically includes the following sub-steps:

[0034] Step 4.1: The leader node evaluates the transaction costs, including computing costs, storage space, and communication costs, and decides whether to process the transaction based on the costs and benefits.

[0035] Step 4.2: The leader node sorts the collected transactions and stores them in a transaction list, broadcasting the list to all follower nodes of this shard.

[0036] Step 4.3: After receiving the transaction list, the following node verifies and simulates the execution of these transactions. Based on the simulation execution results, the hash summary of the newly generated block is calculated and broadcast to other nodes in the shard.

[0037] Step 5: Conduct inter-shard communication.

[0038] Since transactions are dynamically assigned to different shards for consensus, communication between shards is required to prevent double spending. When a shard generates a block, it needs to be broadcast to the leader nodes of other network shards. The leader node puts it into the buffer, checks the legitimacy of the block structure, traverses all transactions in the block to check the legitimacy of the transaction, and detects whether there is double spending according to the transaction allocation table.

[0039] Step 6: The leader nodes of other shards sign and confirm the valid blocks, and send the confirmation message to the leader node of the shard where the block is generated;

[0040] Step 7: The leader node of the shard that generates the block receives messages from the leader nodes of other shards. If the leader nodes of other shards return conflicting messages, the other shards are notified to delete the invalid blocks in the buffer. If they are all confirmation messages, the node is notified to add the block to the ledger.

[0041] Beneficial Effects

[0042] Compared with the prior art, the method of the present invention has the following advantages:

[0043] 1. The method has good reliability, specifically: storing the knowledge graph file in the blockchain solves the problem of secure storage and traceability of the knowledge graph construction file. The tamper-proof feature of the blockchain prevents the process file from being tampered with or forged. When there is a reasoning error or file security problem in the knowledge graph, the corresponding process file can be obtained from the blockchain as needed, which can avoid repetitive construction processes.

[0044] 2. The method has good security, specifically: based on the inter-shard communication confirmation mechanism, double-spending attacks on different shards are prevented. In addition, through random verification functions, asset mortgages, and improved practical Byzantine fault tolerance mechanisms, malicious behavior of nodes is prevented, ensuring transaction security in the shards.

[0045] 3. The method has good performance, specifically: optimizing the sharding scheme to improve the throughput of the blockchain system, and giving the optimal transaction selection scheme based on the dynamic programming algorithm under multiple constraints to maximize the benefits of the shard, and realize efficient and reasonable transaction sharding. Compared with the genetic algorithm, this method has less time overhead, can reduce the response time of the business, and is more efficient. Compared with the greedy algorithm, as the problem scale grows, the performance of this method is stable and the optimal solution can always be obtained. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 Flow chart of the method of the present invention. DETAILED DESCRIPTION

[0047] The specific implementation process of the method of the present invention is further described in detail below in conjunction with the drawings and embodiments.

[0048] Example

[0049] like Figure 1 As shown, specifically, this embodiment elaborates on the transaction allocation in the scenario of secure and efficient storage of knowledge graphs enabled by blockchain sharding, and its system performance is reflected by the effect and time of the transaction allocation plan.

[0050] This embodiment describes the use of the method of the present invention to distribute and process transactions constructed for the knowledge graph process file in the above blockchain system, including the following process:

[0051] Step 1: During the construction of a knowledge graph project, many intermediate files are generated. Users export relevant process files from the knowledge graph database, hash the files, and use the encrypted hash value and their own signature to build a transaction and send it to the blockchain network. Once the file is changed and re-saved, the hash value calculated before and after in the same way will change, while file renaming, compression, decompression, copying and other operations will not change the hash value. In specific implementation, algorithms such as SHA256 and MD5 can be used. This stage corresponds to step 1 in the content of the invention.

[0052] Step 2: Blockchain network sharding. The nodes in the entire blockchain network are divided into N subnets to verify transactions simultaneously, thereby improving the parallel processing capabilities of the system.

[0053] When sharding the network, it is necessary to ensure that the number of malicious nodes in each network shard is small enough, that is, to ensure the randomness of node allocation. A random verification function is used to randomly select nodes to join the shard to prevent malicious nodes from occupying a shard. Each node generates a pair of keys (SK, PK), where SK represents the private key and PK represents the public key.

[0054] The node generates a random number through result = VRF_HASH (SK, info), which means: the evaluation function VRF_HASH calculates and generates the random number result based on the private key SK and an original random number info (which can be set to the previous block number, the block header information generated by the proposal node, etc.) that is publicly available on the entire network. According to the preset number of network shards, the number of digits of the truncated result is flexibly selected (ensuring that the number of network shards is greater than the result truncation value), and then the node is assigned to the corresponding network shard.

[0055] At the same time, the node calculates the zero-knowledge proof through proof = VRF_PROVE (SK, info), which specifically means: the proof function VRF_PROVE is calculated based on the private key SK and the original random number info disclosed by the entire network (which can be set to the previous block number, the block header information generated by the proposal node, etc.) to calculate the concatenation of the random number and the proof to obtain the result as proof.

[0056] Since proof is generated by info, and result can be calculated by proof, it can be deduced that info and result are correspondingly matched. Therefore, the node submits both result and proof to the verifier, and the verifier calculates whether result and info match through the verification function, and then can verify whether the node is correctly assigned to the corresponding network partition.

[0057] Other nodes in the network verify the correctness of the calculation results through the public key and the certificate. This stage corresponds to step 2 in the content of the invention.

[0058] Step 3: Elect the leader node. The leader node needs to pledge a portion of its assets, which will be confiscated if it is found to be malicious. At the same time, a shard routing table is maintained in the network to record the leader routing information of each shard. This stage corresponds to step 3 in the content of the invention.

[0059] Step 4: Transaction allocation and execution. Transactions are allocated to different shards for execution, and each shard executes consensus independently. This stage corresponds to step 4 in the content of the invention, and the specific implementation includes the following sub-steps:

[0060] Step 4.1: When a transaction is detected, the leader node evaluates the transaction cost, including the computing resources consumed, the storage space required to process the transaction, the communication cost required for consensus, and the benefits obtained from processing the transaction, and stores the evaluation information of each transaction in the transaction information list.

[0061] Step 4.2: The leader node sorts the collected transactions and determines the best transaction selection scheme based on the dynamic programming algorithm, and then broadcasts the list of transaction information to be processed by this shard to the follower nodes.

[0062] Specifically, different transactions require different computing resources, storage space, and communication costs, and the benefits of processing transactions are also different. Shard resources are limited, and the allocation of transactions is related to the benefits of shards and the performance of the entire system.

[0063] The characters involved in the method in this embodiment are shown in Table 1:

[0064] Table 1 Description of characters involved in the method in this embodiment

[0065]

[0066] The present invention proposes a method for the leader node to find the optimal transaction allocation scheme to maximize the benefits of the shard. The transaction allocation method based on dynamic programming is as follows:

[0067] Input: TL, C c , S c , T c

[0068] Output: F-Table, P-Table

[0069]

[0070]

[0071] One input of the above algorithm is the transaction list TL. The transactions in TL contain four attributes, namely the computing resources required to process the transaction, the space occupied by the transaction storage, the communication cost required to verify the transaction communication, and the processing fee provided by the transaction. Another input is the resource constraints of the shard, including the computing resource upper limit C c , Storage resource upper limit S c , communication resource upper limit T c The output is F-Table and P-Table, where F-Table stores the maximum profit obtained by the shard and P-Table stores the optimal transaction selection plan.

[0072] First, initialize the F-Table and P-Table.

[0073] Then, we traverse the transactions in the list TL, and when considering the strategy of the i-th transaction (select or not), it is transformed into a problem involving only the first (i-1) transaction. A set of temporary variables, including cal, sto, com, and fee, are used to save the transaction attributes at (i-1).

[0074] Since F[i][j][k][l] is related to F[i-1][j][k][l] and F[i-1][j-cal][k-sto][l-com], we use the three-dimensional array F[C c ][S c ][T c ] to save the previous (i-1) transaction status.

[0075] After that, traverse C in reverse order c , S c , T c . Compare the profit when the i-th transaction is selected with the profit when it is not selected, and take the larger value between the two. If the transaction is selected, mark the execution loop accordingly in the P-Table until all transactions in TL are processed and the optimal transaction selection plan is obtained.

[0076] Step 4.3: After receiving the transaction list, the following node verifies and simulates the execution of these transactions. Based on the simulation execution results, the hash summary of the newly generated block is calculated and broadcast to other nodes in the shard.

[0077] Assume that there are f Byzantine nodes in a network shard. If a node receives the same summary information from other 2f nodes, the node will broadcast a commit message. When a node receives (2f+1) commit messages, it will temporarily put the newly generated block (not verified by other shards) into the buffer.

[0078] Step 5: Inter-shard communication.

[0079] Since transactions are dynamically assigned to different shards for consensus, communication between shards is required to prevent double spending. When a shard generates a block, it needs to be broadcast to the leader nodes of other network shards. The leader node puts it into the buffer, checks the legitimacy of the block structure, traverses all transactions in the block to check the legitimacy of the transaction, and detects whether there is double spending according to the transaction allocation table. This stage corresponds to step 5 in the invention content.

[0080] Step 6: The leader nodes of other shards sign and confirm the valid blocks, and send the confirmation message to the leader node of the shard where the block is generated. This stage corresponds to step 6 in the content of the invention.

[0081] Step 7: The leader node of the shard that generates the block receives messages from the leader nodes of other shards. If the leader nodes of other shards return conflicting messages, the other shards will be notified to delete the invalid blocks in the buffer. If they are all confirmation messages, the notification node will add the block to the ledger.

[0082] When a block is verified to be valid, the leader node that generates the block sends a (shard_id, block_id, ack, sig) message to the leader nodes of other shards, where shard_id is the shard number, block_id is the block number, ack is the confirmation flag, and sig is the leader signature of the shard. The leader node that receives the confirmation message notifies the following nodes in the shard to add the corresponding block to the ledger. This stage corresponds to step 7 in the content of the invention.

[0083] The above is only a preferred embodiment of the present invention, and the present invention should not be limited to the contents disclosed in the embodiment and the drawings. Any equivalent or modification completed without departing from the spirit disclosed in the present invention shall fall within the protection scope of the present invention.

Claims

1. A knowledge graph file storage method enabled by blockchain sharding, characterized in that: The following steps are involved: Step 1: Generate blockchain transactions; Export the process file of knowledge graph construction from the database and perform hash encryption. The user uses the generated hash value to construct a transaction and send it to the blockchain network. Step 2: Shard the blockchain network; The nodes in the entire blockchain network are divided into N subnets to verify transactions simultaneously; Sharding is an on-chain solution to solve the scalability of blockchain. Blockchain nodes are divided into several independent network partitions, and transactions are processed in parallel by different shards to improve the throughput of the entire system. Step 3: Elect the leader node; A leader node is selected in each shard to complete special tasks, including evaluating transactions, selecting transactions, generating blocks, and verifying blocks; Among them, the leader node refers to a leader node elected in each shard through the asset mortgage mechanism. This node is responsible for transaction selection, block generation, and verification of blocks from other shards; Step 4: Trade allocation and execution; Transactions are distributed to different shards for execution, and each shard executes consensus independently, including the following sub-steps: Step 4.1: The leader node evaluates the transaction costs, including computing costs, storage space, and communication costs, and decides whether to process the transaction based on the costs and benefits; Step 4.2: The leader node sorts the collected transactions and stores them in a transaction list, broadcasting the list to all follower nodes of this shard; Among them, follower nodes refer to other nodes in each shard except the leader node. Follower nodes are responsible for participating in the consensus process of their shards; Step 4.3: After receiving the transaction list, follow the node to verify and simulate the execution of these transactions. According to the simulation execution results, the hash summary of the newly generated block is calculated and broadcast to other nodes in the shard; Step 5: Conduct inter-shard communication; When a shard generates a block, it needs to broadcast it to the leader nodes of other network shards. The leader node puts it into the buffer, checks the legitimacy of the block structure, traverses all transactions in the block to check the legitimacy of the transactions, and detects whether there is double spending according to the transaction allocation table; Step 6: The leader nodes of other shards sign and confirm the valid blocks, and send the confirmation message to the leader node of the shard where the block is generated; Step 7: The leader node of the shard that generates the block receives messages from the leader nodes of other shards. If the leader nodes of other shards return conflicting messages, the other shards are notified to delete the invalid blocks in the buffer. If they are all confirmation messages, the node is notified to add the block to the ledger.

2. A knowledge graph file storage method enabled by blockchain sharding as claimed in claim 1, characterized in that: When performing blockchain network sharding in step 2, a random verification function is used to randomly select nodes to join the sharding to prevent malicious nodes from occupying a shard. Each node generates a pair of keys (SK, PK), where SK represents the private key and PK represents the public key. The node generates a random number through result = VRF_HASH (SK, info), which means: the evaluation function VRF_HASH calculates and generates a random number result based on the private key SK and an original random number info disclosed to the entire network; according to the preset number of network shards, the number of digits of the truncated result is selected to ensure that the number of network shards is greater than the result truncation value, and then the node is assigned to the corresponding network shard; At the same time, the node calculates the zero-knowledge proof through proof = VRF_PROVE (SK, info), which specifically means: the proof function VRF_PROVE is calculated based on the private key SK and the original random number info disclosed by the entire network to calculate the concatenation of the random number and the proof to obtain the result as proof; The node submits both the result and the proof to the verifier. The verifier uses the verification function to calculate whether the result and info match, and then can verify whether the node is correctly assigned to the corresponding network partition.

3. A knowledge graph file storage method enabled by blockchain sharding as claimed in claim 1, characterized in that: In step 4.2, assume that one input is the transaction list TL. The transactions in TL contain four attributes, namely, the computing resources required to process the transaction, the space occupied by the transaction storage, the communication cost required to verify the transaction communication, and the processing fee provided by the transaction; the other input is the resource constraint of the shard, including the computing resource upper limit C c , Storage resource upper limit S c , communication resource upper limit T c ; The output includes the maximum profit table F-Table and the best selection plan table P-Table. The F-Table stores the maximum profit obtained by the shard, and the P-Table stores the optimal transaction selection plan. First, initialize the F-Table and P-Table; Then, we traverse the transactions in the list TL. When considering the strategy of the i-th transaction, we transform it into a problem involving only the first (i-1) transaction. We use a set of temporary variables, including cal, sto, com, and fee, to save the transaction attributes at (i-1). We use the three-dimensional array F[C c ][S c ][T c ] to save the previous (i-1) transaction status; After that, traverse C in reverse order c , S c , T c , compare the profit when the i-th transaction is selected with the profit when it is not selected, and take the larger value between the two; if the transaction is selected, mark the execution loop accordingly in the P-Table until all transactions in TL are processed and the optimal transaction selection plan is obtained.

4. A knowledge graph file storage method enabled by blockchain sharding as claimed in claim 1, characterized in that: In step 7, when a block is verified to be valid, the leader node that generates the block sends a (shard_id, block_id, ack, sig) message to the leader nodes of other shards, where shard_id is the shard number, block_id is the block number, ack is the confirmation flag, and sig is the signature of the leader of the shard. The leader node that receives the confirmation message notifies the follower nodes in this shard to add the corresponding block to the ledger.