Ciphertext graph K-hop reachability rapid query method supporting privacy protection
By employing multi-round root node BFS spanning tree and cyclic pruning techniques, combined with homomorphic encryption and order-preserving encryption, the efficiency and security issues in K-hop reachability queries of large-scale DAG graphs are resolved. This achieves efficient queries with full path coverage and privacy protection, and is applicable to fields such as social networks, recommendation systems, and knowledge graphs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-08
- Publication Date
- 2026-04-07
AI Technical Summary
Existing technologies suffer from incomplete path coverage, high query complexity, and low efficiency in K-hop reachability queries for large-scale DAG graphs. This is especially true when the spanning tree coverage is scattered and there is no clear path guidance for root node selection, making it difficult to achieve efficient and secure queries.
We employ multi-round root node BFS spanning tree construction and cyclic pruning techniques, combined with homomorphic encryption and order-preserving encryption. By querying the reachability of nodes in the spanning tree with K hops, we establish a multi-spanning tree index to achieve full path coverage and ensure data security in a ciphertext environment.
It enables efficient and secure K-hop reachability queries on encrypted graphs, improving query efficiency and enabling privacy-preserving, efficient queries in fields such as social networks, recommendation systems, and knowledge graphs, thus meeting business needs.
Smart Images

Figure CN121808113A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of graph data processing, and particularly relates to multi-spanning tree construction and K-hop reachability query optimization of a directed acyclic graph (DAG), and is suitable for large-scale DAG application scenarios such as social networks, task scheduling, biological networks and the like which are sensitive to query delay. BACKGROUND
[0002] In the field of data management and analysis, graph structure has been widely used in social network analysis, biological molecule structure research, financial transaction risk monitoring and the like as a model for efficiently organizing and processing complex relational data. With the improvement of data security requirements, encrypted graph query technology has become a research hotspot, aiming to protect the privacy of sensitive data while realizing efficient graph traversal and query, and the core challenge lies in balancing the security and query efficiency of data encryption. Meanwhile, a directed acyclic graph (DAG) plays a key role in task scheduling, version control, blockchain transaction confirmation and the like due to its acyclic property.
[0003] The K-hop reachability query of a DAG graph, that is, judging whether there is a path with a length not exceeding K between any two nodes in the graph, is a basic operation for realizing path planning, dependency analysis and the like. The traditional query method often faces problems such as incomplete path coverage and high query complexity when processing large-scale DAG graphs, and there is an urgent need for a more efficient solution with full path coverage capability.
[0004] In the prior art, the K-hop query scheme for spanning trees has the following key defects:
[0005] A node only belongs to a small number of spanning trees, and a large number of node pairs need to be realized through cross-tree queries, and the efficiency is very low due to the dependence on adjacency list recursive traversal of non-tree edges; the root node selection has no clear path starting point direction, resulting in scattered spanning tree coverage range and insufficient maximum coverage capacity.
[0006] In view of the defects of the prior art, the purpose of the present application is to provide a high-coverage, high-security and high-efficiency encrypted graph K-hop reachability fast query method supporting privacy protection. SUMMARY
[0007] In order to solve the above problems, the application discloses a ciphertext graph K-hop reachability fast query method supporting privacy protection. The application aims to provide an efficient and secure ciphertext directed acyclic graph node K-hop reachability query technology, and the core targets include: breaking through the low-efficiency bottleneck of traditional reachability calculation, adopting a multi-round root node BFS generation tree construction and a loop pruning cooperation technology, gradually narrowing the original graph range, and covering all edges in the DAG, judging the K-hop reachability result in the original graph by relying on the K-hop reachability result of the node in the generation tree, and reducing the search time of the traditional query; at the same time, homomorphic encryption, order-preserving encryption and other cryptographic technologies are adopted to support the graph query demand in the ciphertext environment, guarantee the fast response of the query result, and guarantee the data security; the scheme provides an efficient and secure solution for the privacy protection of graph data query, and is suitable for social networks, recommendation systems, knowledge graphs and the like.
[0008] The application mainly includes two role subjects: a user and a cloud server, and mainly includes the following four core processes:
[0009] 1) The user generates a K-hop reachability query index according to an original graph G and encrypts and uploads the K-hop reachability query index to the cloud server;
[0010] 2) The user generates a query trapdoor and sends a query request to the cloud server;
[0011] 3) The cloud server runs a ciphertext graph K-hop reachability query algorithm, and returns a ciphertext query result to the user;
[0012] 4) The user decrypts the returned ciphertext result, and completes the query process.
[0013] In order to achieve the above purpose, the technical scheme of the application is as follows:
[0014] A DAG ciphertext graph K-hop reachability query method based on full-path coverage multi-generation tree takes a node with an in-degree of 0 as a root, constructs a maximum generation tree and a loop pruning through BFS, guarantees full coverage of edges in the original graph, records the triple information of each node in each generation tree, establishes a multi-generation tree attribution index, matches a common generation tree first during query, and then verifies the ancestor relationship and the number of hops based on the triple, so that cross-tree query is not needed. The scheme realizes full-path coverage, greatly improves the query efficiency, and integrates homomorphic encryption, order-preserving and other cryptographic technologies, so that safe search is realized.
[0015] The specific steps are as follows:
[0016] Step 1: all nodes in the DAG are traversed, and nodes with an in-degree of 0 are included in a candidate root node set;
[0017] Step 2: Select each node in the root node set as the root in turn to generate the corresponding breadth-first search (BFS) tree for the graph. In the BFS construction process, in order to optimize query efficiency, the selection strategy of the edge is to prefer the edge that has not been visited in the previous root node generation tree process. Then, each tree is numbered, such as T1, T2, T3, and so on, until the traversal of all nodes in the set is completed.
[0018] Step 3: Prune all edges used in the tree construction process in step 2 above, and reselect all nodes with an in-degree of 0 in the pruned graph to form the root node set for the next round;
[0019] Step 4: In the current round root node set, select the root node in turn, and repeat the steps of step 2 BFS tree construction, step 3 graph pruning, and new root node screening until all edges in the original graph are covered in the generated tree.
[0020] Step 5: Based on the Tree-Cover (Interval Labeling) idea, generate a two-dimensional coordinate [i, j] for each node in the generated tree, and add a level value to represent the level of the node in the generated tree, together forming the node representation triple [i, j, level]. Select the BFS generated tree, and give the post-order traversal of the tree, with the rule of traversing child nodes first and parent nodes later. After traversal, the node sequence of the tree is obtained, and the post-order value j of each node is assigned as the position of the node in the post-order traversal sequence. The pre-order value i of each node is calculated as the smallest post-order traversal sequence number j in the subtree with the current node as the root. If the node is a child node, there is no subtree, then the pre-order value i of the node is assigned as the post-order value j. According to the structure of the generated tree, the depth of the root node is initialized as 1, and the depth of each other node in the tree is calculated to obtain the level value of each node. According to the calculation result, the node triple [i, j, level] is spliced to obtain the node index;
[0021] Step 6: According to the query requirement, generate a key pair by the user. Wherein k1 is the node encryption key, k2 is the order-preserving encryption key, k3 is the Paillier encryption public key, and k4 is the Paillier encryption public key. ;
[0022] Step 7: Construct the node-generated tree ciphertext mapping table: encrypt or hash each node and each generated tree number in the tree, and generate key-value pairs in the node-generated tree manner to represent which generated trees the node exists in. For example, node v1 belongs to different generated trees T1 and T3. After encryption, it is represented as ;
[0023] Step 8: Encryption node triplets: For the triplets (i, j, level) in the nodes, in order to facilitate the query under the ciphertext, the i and j values need to be order-preserving encrypted, such as OPE encryption; for the level value, because K-hop reachability calculation under the ciphertext is needed, the level value is Paillier homomorphic encrypted. For example, for node v2, after encryption, the triplets value of v2 is: ;
[0024] Step 9: Constructing the spanning tree-node triplet ciphertext table: according to the spanning tree ciphertext and node triplet ciphertext constructed in the above steps, the ciphertext mapping table is constructed to save the ciphertext of the spanning tree and each node triplet in the tree, so as to facilitate the query of the specific information of the nodes in the tree. For example, in tree T2, the nodes v2, v5 are saved, and the spanning tree-node triplet ciphertext table can be constructed as
[0025]
[0026]
[0027]
[0028] Step 10: The node-spanning tree ciphertext mapping table generated in the above steps, and the spanning tree-node triplet ciphertext table, together constitute the ciphertext index of the graph, and are uploaded to the cloud server;
[0029] Step 11: The user queries the information according to the need , and generates a query trapdoor by encrypting it. For nodes u and v, k1 is used for node encryption; for the hop number k, Paillier public key k3 is used for homomorphic encryption, and the trapdoor is: and the trapdoor is uploaded to the cloud server;
[0030] Step 12: The cloud server extracts the value in the trapdoor, obtains the start and end points of the ciphertext and the ciphertext K value, and initializes the step correction value ;
[0031] Step 13: According to the start and end points of the ciphertext, search the node-spanning tree ciphertext mapping table, calculate whether there is an intersection according to the spanning tree set where the two nodes are located, and judge whether they are in the same spanning tree. If there is no intersection, the start and end points are not in the same spanning tree, the node is not reachable, and the Paillier encryption value '-1' is used, and the result is returned ; if there is an intersection, extract all intersection results, and preferentially select the spanning tree with an earlier round of root node;
[0032] Step 14: Tree reachability interval verification: the start and end points are in a tree, find the same tree, and go to the spanning tree-node triplet ciphertext table of the ciphertext index to locate the ciphertext triplets of the start and end points:
[0033]
[0034]
[0035] And perform calculations and judgments: if If yes, proceed to step 15; otherwise, proceed to step 16.
[0036] Step 15: Jump Count Constraint Confirmation: Calculate the jump count difference between the start and end points and return the result. .
[0037] Step 16: Start and End Point Node Expansion and Multi-Tree Query: Obtain the ciphertext [i,j] values of the start and end points in the current spanning tree. Based on the ordered ciphertext interval, find the ordered ciphertext interval closest to the start point interval according to the following rules: For the start point u, the ciphertext interval of the new node s to be found must be smaller than the ciphertext interval of u, that is, find the child node of the start point u. If the start point u is already a leaf node, no operation is performed; For the end point v, the ciphertext interval of the new node t to be found must be greater than the ciphertext interval of v, that is, find the parent node of the end point v. If the end point v is already a root node, no operation is performed.
[0038] Extract the new ciphertext node sets {u,t}, {s,v}, and {s,t}. Then, in other spanning tree sets, search for any non-current spanning tree that contains one of the aforementioned node pairs. If found, adjust the hop count according to the following rules:
[0039] If the set is {u,t} or {s,v}, adjust the hop count.
[0040] If the set is {s,t}, adjust the jump count.
[0041] Then jump to the new spanning tree, using the new node pair as the start and end point pair (u,v), and jump to step 14;
[0042] If no spanning tree is found in the new node pair, continue to step 15.
[0043] If the starting point u has reached a leaf node while searching for a child node, and the ending point v has reached the root node while searching for a new node, and a spanning tree containing both of these newly searched nodes is still not found, then it proves that the two nodes are unreachable. The Paillier encryption value '-1' is used, and the result is returned. ;
[0044] Step 17: The user receives the encrypted result returned by the cloud server. Decrypt using Paillier's private key k4 to obtain the plaintext result: If the Result value is less than 0, the start and end points are unreachable within K hops; if the Result value is greater than or equal to 0, the start and end points are reachable within K hops, thus completing the entire query process.
[0045] Compared with existing technologies, this invention has the following advantages: Existing encrypted query technologies have shortcomings in encrypted index design and query efficiency. This invention proposes a node-spanning tree encrypted mapping table and a spanning tree-node triple encrypted table as the core of the index. By combining homomorphic encryption and order-preserving encryption, a high-efficiency encrypted index system is constructed, enabling rapid judgment of node reachability in the encrypted graph and rapid inference of graph reachability based on tree membership. In addition, a technique that integrates multi-round root node BFS spanning tree and cyclic pruning is designed to achieve full edge coverage of the original graph, avoiding the inefficiency problem caused by frequent recursive calls to cross-tree queries in traditional encrypted K-hop queries.
[0046] This invention's solution can be efficiently adapted to the actual business needs of fields such as financial risk control, smart grids, and social networks. Specific application scenarios are as follows: In the field of financial risk control, through risk link analysis under limited association levels, abnormal relationships between entities can be accurately identified, enabling core functions such as tracing the flow of fraudulent funds, identifying illegal money laundering activities, and investigating insider trading clues. In the field of smart grids, relying on the topology association hop count limitation mechanism, the scope of fault impact and the analysis of critical equipment fault infection paths can be completed, providing reliable technical support for the safe operation of the power grid. In the field of social networks, based on the assessment of social association strength using limited relationship chains, business objectives such as personalized friend recommendations, control of public opinion dissemination paths, and compliant social advertising can be achieved. Furthermore, the objects of K-hop reachability analysis in the above scenarios are all high-value, sensitive information directly related to data association queries and link tracing. Once such information is leaked, it will trigger a series of serious consequences, including targeted financial fraud, targeted attacks on the power grid, and leakage of user social relationship privacy. The technical solution designed in this invention can accurately determine K-hop reachability in encrypted form, which not only achieves full-process security protection for sensitive data, but also meets the core needs of correlation analysis in various business scenarios, and has significant practical value and broad application prospects. Attached Figure Description
[0047] Figure 1 This invention relates to the main roles and system architecture involved in the method.
[0048] Figure 2 The original directed acyclic graph G is used as an example of the method of the present invention;
[0049] Figure 3 The three BFS spanning tree graphs constructed for the first round of multi-tree traversal of the root node;
[0050] Figure 4This is a graph of three BFS spanning trees constructed for the second round of multi-tree traversal of the root node after pruning. Detailed Implementation
[0051] The present invention will be further illustrated below with reference to the accompanying drawings and specific embodiments. It should be understood that the following specific embodiments are for illustrative purposes only and are not intended to limit the scope of the invention.
[0052] Example 1: The main contribution of this invention lies in proposing a multi-round root node BFS spanning tree and cyclic pruning collaborative technique, which solves the efficiency bottleneck of frequent recursive operations in traditional graph cross-spanning tree K-hop queries, and can quickly determine the reachability result through the intersection operation of the spanning tree sets where the start and end points are located; in addition, it integrates cryptographic techniques such as homomorphic encryption and order-preserving encryption to construct an efficient ciphertext index architecture of node-spanning tree and spanning tree-node triples, which together achieve a dual breakthrough in efficiency and security of ciphertext DAG graph K-hop reachability queries, providing a new technical approach and solution for privacy-preserving graph data processing.
[0053] System architecture such as Figure 1 As shown, it mainly includes two roles: user and cloud server. Figure 2 To explain in detail the original directed acyclic graph example designed in this invention, the specific steps of this invention are as follows:
[0054] Step 1: Traverse all nodes in the DAG and add the nodes {a,j,m} with in-degree = 0 to the candidate root node set;
[0055] Step 2: Select each node in the root node set {a,j,m} as the root, and generate the corresponding breadth-first search (BFS) tree for the graph. Number each tree, such as... Figure 3 As shown, the three spanning trees are T1, T2, and T3.
[0056] Step 3: Prune all edges used in the tree construction process in Step 2 above, and reselect all nodes with in-degree = 0 in the pruned graph to form the root node set {i,p,r} for the next round.
[0057] Step 4: In the current set of root nodes {i,p,r}, select root nodes sequentially, and repeat Step 2 (BFS spanning tree construction), Step 3 (graph pruning), and new root node selection to generate a tree like the one shown in Step 4. Figure 4 The three spanning trees T4, T5, and T6 shown represent the edges of the original graph, which are now completely covered.
[0058] Step 5: Taking spanning tree T1 as an example, construct the triplet for each node. A postorder traversal sequence of T1 is as follows: According to the Tree-Cover algorithm, the post-order value j of each node is set to the order value of seq, and based on the minimum value of the node's child nodes and the depth of each node in the spanning tree, the triplet of each node in the spanning tree T1 is calculated as follows:
[0059]
[0060] Similarly, in spanning tree T4, the node and triplet values are:
[0061]
[0062] Step 6: Based on the query requirements, the user generates a key pair. Here, k1 is the node encryption key, k2 is the order-preserving encryption key, k3 is the Paillier encryption public key, and k4 is the Paillier encryption public key. ;
[0063] Step 7: Construct the Node-Spanning Tree Ciphertext Mapping Table: Encrypt or hash the number of each node and each spanning tree in the tree, and generate key-value pairs according to the node-spanning tree method. Calculate the node-spanning tree ciphertext mapping table, as shown in the table below.
[0064]
[0065] Step 8: Encrypt node triples: For the triples (i, j, level) in a node, to facilitate querying in the ciphertext, the values of i and j need to be encrypted in order, such as OPE encryption; for the level value, because K-hop reachability calculation in the ciphertext is required, the level value is encrypted using Paillier homomorphic encryption.
[0066] Step 9: Construct the spanning tree-node triplet ciphertext table: Based on the spanning tree ciphertext and node triplet ciphertext constructed in the above steps, construct a ciphertext mapping table to store the spanning tree and the ciphertext of each node triplet in the tree. The spanning tree-node triplet ciphertext table is constructed as follows:
[0067]
[0068] Step 10: Combine the node-spanning tree ciphertext mapping table and the spanning tree-node triplet ciphertext table generated in the above steps to form the ciphertext index of the graph, and upload them to the cloud server.
[0069] Step 11: The user retrieves the information they need. The query trapdoor is generated by encrypting the nodes u and v. For nodes u and v, node encryption is performed using k1; for the hop count k, homomorphic encryption is performed using the Paillier public key k3, generating the trapdoor as follows: And upload the trapdoor to the cloud server;
[0070] Step 12: The cloud server extracts the value from the trapdoor, obtains the start and end points of the ciphertext and the ciphertext K value, and initializes the step correction value. ;
[0071] Three different examples are provided to illustrate the encrypted reachability query process under different start and end points and hop count constraints.
[0072] ①Step 13: Obtain the spanning tree set containing the two ciphertext nodes, where The spanning tree is Hash(T3). The spanning trees are Hash(T1), Hash(T2), and Hash(T4). If the spanning trees of two nodes do not intersect, the result is returned directly. The cloud server segment query algorithm has ended.
[0073] ②Step 13: Obtain the spanning tree set containing the two ciphertext nodes, where The spanning tree is Hash(T1). The spanning trees are Hash(T1), Hash(T2), and Hash(T3). They have an intersection of Hash(T1), which means that within the same spanning tree, the spanning tree Hash(T1) is selected for querying.
[0074] ②Step 14: Find the ciphertext table of the spanning tree Hash(T1) - node triples, and locate the triple of node a.
[0075]
[0076] The triplet for node f is:
[0077] Comparison revealed:
[0078]
[0079] If the interval range verification is satisfied, it means that the two nodes are reachable. Calculate the hop count:
[0080]
[0081] The ciphertext value is constrained by the number of jumps in the trapdoor. The calculation returned the following result:
[0082]
[0083] End the cloud server reachability query process.
[0084] ③
[0085] ③ Step 13: Obtain the spanning tree set of the two ciphertext nodes, where the spanning tree of Enc(k1,h) is Hash(T1), the spanning tree of Enc(k1,e) is Hash(T1), and Hash(T2) has an intersection of Hash(T1), indicating that they are in the same spanning tree.
[0086] ③Step 14: Find the ciphertext table of the spanning tree Hash(T1) - node triples, and locate the triple of node h.
[0087]
[0088] The triplet for node e is:
[0089] Comparison revealed:
[0090]
[0091] The interval range verification is not satisfied, indicating that the two nodes are unreachable in the spanning tree Hash(T1), but further verification is still needed. Jump to step 16.
[0092] ③Step 16: Based on the two-dimensional value of the ciphertext triplet at the starting point h And the two-dimensional value of the endpoint e-ciphertext triple. Find the interval of the two-dimensional ciphertext values closest to the starting point h. It is a ciphertext node. Simultaneously, the interval of the ciphertext two-dimensional value closest to the endpoint e is found. It is a ciphertext node. .
[0093] Construct new start and end point ciphertext value pairs { }、{ }、{ }, and search for whether the new ciphertext value pair has an intersection in the non-Hash(T1) range. After calculation and search, the ciphertext value pair { is obtained. There is an intersection in Hash(T4) because both the starting and ending points have been offset, so a step correction value is set. .
[0094] Jump to Hash(T4) to... As a new starting point, with For the new endpoint, obtain the ciphertext triplet ciphertext of the two sections in T4:
[0095]
[0096]
[0097] The interval verification within the same tree in T4 passed, indicating that a path exists that can be obtained from there. arrive The two points are reachable. Further, calculate the number of hops between the new start and end points: At the same time, the correction step count is increased, resulting in the original start and end point jump count as follows:
[0098] Based on the above operations, the ciphertext returned is calculated as follows:
[0099]
[0100] Step 17: The user receives the ciphertext value returned by the cloud server and decrypts it using the locally generated Paillier private key k4. Based on the return results from the three different start and end points, the following decryption methods are used:
[0101] The reachability query results for a starting point m, an ending point c, and a hop count of 3 are as follows: = = -1. A value less than 0 indicates that it is unreachable.
[0102] The reachability query results for starting point a, ending point f, and hop count 3 are as follows: = = 0. A value greater than or equal to 0 indicates that it is reachable.
[0103] The reachability query results for starting point h, ending point e, and hop count 3 are as follows: = = 0. A value greater than or equal to 0 indicates that it is reachable.
[0104] It should be noted that the above content merely illustrates the technical concept of the present invention and should not be construed as limiting the scope of protection of the present invention. For those skilled in the art, various improvements and modifications can be made without departing from the principle of the present invention, and all such improvements and modifications fall within the scope of protection of the claims of the present invention.
Claims
1. A method for fast K-hop reachability lookup of encrypted graphs supporting privacy protection, characterized in that, The method includes the following steps: Step 1: Traverse all nodes in the DAG and add nodes with in-degree = 0 to the candidate root node set; Step 2: Select each node in the root node set as the root, and generate the corresponding breadth-first search (BFS) tree for the graph. Step 3: Prune all edges used in the spanning tree construction process in Step 2, and in the pruned graph, reselect all nodes with in-degree = 0 to form the root node set for the next round. Step 4: In the current set of root nodes, select the root node in turn, and repeat Step 2 BFS spanning tree construction, Step 3 graph pruning and new root node selection until all edges in the original graph are completely covered in the spanning tree; Step 5: Based on the Tree-Cover (Interval Labeling) concept, generate a two-dimensional coordinate [i,j] for each node in the spanning tree, and add a level value to represent the node's level in the spanning tree, together forming the node representation triple [i, j, level]. Step 6: Based on the query requirements, the user generates a key pair, where k1 is the node encryption key, k2 is the order-preserving encryption key, k3 is the Paillier encryption public key, and k4 is the Paillier encryption public key. ; Step 7: Construct the node-spanning tree ciphertext mapping table. Step 8: Encrypt node triples, Step 9: Construct the spanning tree - node triplet ciphertext table. Step 10: Combine the node-spanning tree ciphertext mapping table and the spanning tree-node triplet ciphertext table generated in the above steps to form the ciphertext index of the graph, and upload them to the cloud server. Step 11: The user retrieves the information they need. To generate a query trapdoor, the nodes u and v are encrypted using k1; the hop count k is homomorphically encrypted using the Paillier public key k3, resulting in the trapdoor: And upload the trapdoor to the cloud server; Step 12: The cloud server extracts the value from the trapdoor, obtains the start and end points of the ciphertext and the ciphertext K value, and initializes the step correction value. ; Step 13: Based on the ciphertext start and end points, retrieve the node-spanning tree ciphertext mapping table. Calculate the intersection of the two nodes' spanning tree sets to determine if they are in the same spanning tree. If there is no intersection, the start and end points are not in the same spanning tree, the node is unreachable, and Paillier encryption is applied with the value '-1'. Return the result. If there is an intersection, extract all intersection results and prioritize the spanning tree with the earlier root node round number. Step 14: Verify reachability intervals within the same tree. Step 15: Jump Count Constraint Confirmation: Calculate the jump count difference between the start and end points and return the result. , Step 16: Expanding start and end points and multi-tree queries. Step 17: The user receives the encrypted result returned by the cloud server. Decrypt using Paillier's private key k4 to obtain the plaintext result: If the Result value is less than 0, the start and end points are unreachable within K hops; if the Result value is greater than or equal to 0, the start and end points are reachable within K hops, thus completing the entire query process.
2. The method for fast K-hop reachability lookup of encrypted graphs supporting privacy protection according to claim 1, characterized in that, Step 2: Select each node in the root node set as the root in turn to generate the corresponding breadth-first search (BFS) tree for the graph. In the BFS construction process, in order to optimize the query efficiency, the edge selection strategy prioritizes the edges that have not been visited in the previous root node's tree generation process. Then, number each tree as T1, T2, T3, etc. until all nodes in the set have been traversed.
3. The method for fast K-hop reachability lookup of encrypted graphs supporting privacy protection according to claim 2, characterized in that, Step 5: Based on the Tree-Cover (Interval Labeling) concept, generate a two-dimensional coordinate [i,j] for each node in the spanning tree, and add a level value to represent the node's level in the spanning tree. Together, they form a node representation triple [i, j, level]. Select the BFS spanning tree and give the post-order traversal of the tree. The rule is to traverse the child nodes first and then the parent nodes. After the traversal, the node sequence of the tree is obtained. Assign the post-order value j of the two-dimensional coordinate of each node as the position of the node in the post-order traversal sequence. For each node's post-order value, calculate the previous value i of the node's coordinate. The calculation rule is to find the smallest post-order traversal index j in the subtree rooted at the current node. If the node is a child node and there is no subtree, then assign the previous value i to the post-order value j. According to the structure of the spanning tree, initialize the root node depth to 1, and calculate the depth of each other node in the tree to obtain the level value of each node. Based on the calculation results, concatenate to obtain the node triple [i, j, level], which serves as the node index.
4. The method for fast K-hop reachability lookup of encrypted graphs supporting privacy protection according to claim 3, characterized in that, Step 7: Construct a Node-Spanning Tree Ciphertext Map: Encrypt or hash each node and each spanning tree number in the tree, and generate key-value pairs in the node-spanning tree format to indicate which spanning trees a node exists in. Step 8: Encrypt node triples: For the triples (i, j, level) in the node, in order to facilitate querying in the ciphertext, the values of i and j need to be encrypted in order. For the level value, since K-hop reachability calculation in the ciphertext is required, the level value is encrypted using Paillier homomorphic encryption. Step 9: Construct the spanning tree-node triplet ciphertext table: Based on the spanning tree ciphertext and node triplet ciphertext constructed in the above steps, construct a ciphertext mapping table to store the spanning tree and the ciphertext of each node triplet in the tree, so as to facilitate the search for specific information of the nodes in the tree.
5. The method for fast K-hop reachability lookup of encrypted graphs supporting privacy protection according to claim 4, characterized in that, Step 14: Same-tree reachability interval verification: If the start and end points are in the same tree, find the same tree, go to the spanning tree of the ciphertext index - node triple ciphertext table, and locate the ciphertext triples of the start and end points: And perform calculations and judgments: like If the condition is met, proceed to step 15; otherwise, proceed to step 16.
6. The method for fast K-hop reachability lookup of encrypted graphs supporting privacy protection according to claim 5, characterized in that, Step 16: Start and End Point Node Expansion and Multi-Tree Query: Obtain the ciphertext [i,j] values of the start and end points in the current spanning tree. Based on the ordered ciphertext interval, find the ordered ciphertext interval closest to the start point interval according to the following rules: For the start point u, the ciphertext interval of the new node s to be found must be smaller than the ciphertext interval of u, that is, find the child node of the start point u. If the start point u is already a leaf node, no operation is performed; For the end point v, the ciphertext interval of the new node t to be found must be greater than the ciphertext interval of v, that is, find the parent node of the end point v. If the end point v is already a root node, no operation is performed. Extract the new ciphertext node sets {u,t}, {s,v}, and {s,t}. Then, in other spanning tree sets, search for any non-current spanning tree that contains one of the aforementioned node pairs. If found, adjust the hop count according to the following rules: If the set is {u,t} or {s,v}, adjust the hop count. If the set is {s,t}, adjust the jump count. Then jump to the new spanning tree, using the new node pair as the start and end point pair (u,v), and jump to step 14; If no spanning tree is found in the new node pair, continue to step 15; If the starting point u has reached a leaf node while searching for a child node, and the ending point v has reached the root node while searching for a new node, and a spanning tree containing both of these newly searched nodes is still not found, then it proves that the two nodes are unreachable. The Paillier encryption value '-1' is used, and the result is returned. .
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the privacy-preserving ciphertext graph K-hop reachability fast query method as described in any one of claims 1 to 6.
8. A computer-readable storage medium storing computer instructions thereon, characterized in that, When executed by a processor, the computer instructions implement the privacy-preserving ciphertext graph K-hop reachability fast query method as described in any one of claims 1-6.