Information query method, information query device, electronic device, and storage medium
By performing semantic analysis and resource evaluation on information query requests and dynamically selecting semi-homomorphic or fully homomorphic encryption strategies, the problem of low query efficiency in existing technologies is solved, thereby improving query efficiency while ensuring data privacy.
Patent Information
- Application Number
- CN202511440034.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-10
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2045-10-10
AI Technical Summary
Existing technologies cannot improve query efficiency while ensuring data privacy, especially in complex query scenarios. Semi-homomorphic encryption schemes are inefficient, while fully homomorphic encryption schemes have excessively high computational costs, thus limiting the scope of database applications.
By receiving information query requests, semantic analysis is performed to evaluate the operation type, nesting level, and number of function calls. Semi-homomorphic or fully homomorphic encryption strategies are dynamically selected, and the encryption strategy is optimized based on query complexity and system resource status to improve query efficiency.
While ensuring data privacy, dynamic selection of encryption strategies improves query efficiency, reduces computational overhead, and solves the problem that a single encryption strategy cannot simultaneously satisfy both efficiency and security.
Smart Images

Figure CN120910101B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information security, and in particular to information retrieval methods, information retrieval devices, electronic devices, and storage media. Background Technology
[0002] With the rapid development of information technology and the increasing prevalence of cloud computing environments, users have an increasingly urgent need to perform data analysis and processing without exposing sensitive information. Homomorphic encryption, as a cutting-edge encryption technology, has the unique advantage of allowing computational operations to be performed on ciphertext without decrypting the original data, providing a new approach to solving data privacy protection issues.
[0003] However, current homomorphic encryption schemes are mainly divided into two categories: semi-homomorphic encryption (PHE) and fully homomorphic encryption (FHE). Semi-homomorphic encryption typically exhibits high efficiency in specific operations, such as addition or multiplication, but its functionality is relatively limited, making it difficult to meet complex computational needs. Conversely, while fully homomorphic encryption can support arbitrary computational operations, its computational cost is too high, leading to performance bottlenecks in practical applications. Since different application scenarios have different encryption requirements, how to intelligently select the appropriate encryption strategy based on specific needs has become a key challenge that urgently needs to be overcome in this field.
[0004] Currently, most database encryption schemes exhibit two extremes when dealing with complex queries. On the one hand, some schemes over-rely on fully homomorphic encryption, which, while meeting the needs of complex calculations, leads to severe performance degradation due to high computational costs, hindering efficient data processing. On the other hand, some schemes inappropriately use semi-homomorphic encryption, failing to provide sufficient support for complex computational demands, making it difficult to strike a balance between data privacy protection and query efficiency. This not only limits the application scope of databases in processing sensitive data but also causes considerable inconvenience to users. Currently, to meet computational operations, fully homomorphic encryption is used throughout.
[0005] There is currently no effective solution to the problem that related technologies cannot improve query efficiency while ensuring data privacy. Summary of the Invention
[0006] This embodiment provides an information query method, an information query device, an electronic device, and a storage medium to solve the problem in related technologies that cannot improve query efficiency while ensuring data privacy.
[0007] Firstly, this embodiment provides an information query method, including:
[0008] Receive information query requests;
[0009] Semantic analysis is performed on the information query request to obtain the operation type, nesting level, number of function calls, and number of tables of the information query request;
[0010] When the number of operation types in the information query request is less than or equal to a preset threshold, the query is performed using pre-encrypted data, and a semi-homomorphic encryption strategy is used as the target encryption strategy.
[0011] When the number of operation types in the information query request exceeds the preset threshold, the complexity evaluation score of the information query request is calculated based on the operation type, nesting level, number of function calls, and number of tables.
[0012] Check the current resource status of the information query system;
[0013] Determine whether the current information query system resources meet the system resources required for the information query request;
[0014] If the complexity evaluation score of the information query request is lower than a preset score threshold, a semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output; if the complexity evaluation score of the information query request is greater than or equal to the preset score threshold, a fully homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output.
[0015] Otherwise, the semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output.
[0016] Execute an encrypted query under the target encryption policy and return the result.
[0017] In some embodiments, prior to performing semantic analysis on the information query request, the method further includes:
[0018] The information query request is subjected to format and permission verification. After the format and permission verifications pass, the information query request is standardized and encapsulated to standardize the data structure of the information query request.
[0019] In some embodiments, the semantic analysis includes lexical analysis and syntactic analysis. The semantic analysis of the information query request to obtain the operation type, nesting level, function call count, and number of tables of the information query request includes:
[0020] The lexical analysis breaks down the information query request into basic units, wherein the basic units include keywords, identifiers, operators, and constants.
[0021] An abstract syntax tree is constructed through the syntactic analysis to obtain the syntactic structure of the information query request;
[0022] Operation type analysis is performed on each node of the abstract syntax tree to obtain the operation types of the information query request, and the nesting level, function call count, and number of tables of the information query request are extracted.
[0023] In some embodiments, the operation type analysis of each node of the abstract syntax tree to obtain the operation types of the information query request includes:
[0024] The operation types of each node in the abstract syntax tree are classified by the trained query classification model to obtain the operation types of the information query request.
[0025] In some embodiments, the operation types include addition, multiplication, function calls, single-table aggregation, and multi-table join operations.
[0026] In some embodiments, before calculating the complexity evaluation score of the information query request based on the operation type, nesting level, number of function calls, and number of tables, the method further includes:
[0027] The required security level for detecting the information query request.
[0028] When the security level required for the information query request is detected to be a preset high security level, the fully homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output.
[0029] In some embodiments, after outputting the target encryption policy, the method further includes:
[0030] Calculate the query time of the information query request, and adjust the weights of each parameter in the complexity evaluation score formula based on the query time.
[0031] Secondly, this embodiment provides an information query device, including: a receiving module, an analysis module, an encryption strategy selection module, and an execution module, wherein...
[0032] The receiving module is used to receive information query requests;
[0033] The analysis module is used to perform semantic analysis on the information query request to obtain the operation type, nesting level, function call count, and number of tables of the information query request;
[0034] The encryption strategy selection module is used to: ...
[0035] The execution module is used to perform encrypted queries under the target encryption policy and return the results.
[0036] Thirdly, this embodiment provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the information query method described in the first aspect above.
[0037] Fourthly, this embodiment provides a storage medium storing a computer program that, when executed by a processor, implements the information query method described in the first aspect above.
[0038] Compared with related technologies, the information query method provided in this embodiment receives an information query request; performs semantic analysis on the information query request to obtain the operation type, nesting level, function call count, and number of tables of the information query request; when the number of operation types of the information query request is less than or equal to a preset threshold, it uses pre-encrypted data for querying and uses a semi-homomorphic encryption strategy as the target encryption strategy; when the number of operation types of the information query request is greater than the preset threshold, it calculates the complexity evaluation score of the information query request based on the operation type, nesting level, function call count, and number of tables of the information query request; detects the current information query system resource status; and determines the current information query... The system determines whether its resources meet the requirements of the information query request. If so, if the complexity evaluation score of the information query request is lower than a preset score threshold, a semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output. If the complexity evaluation score of the information query request is greater than or equal to the preset score threshold, a fully homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output. Otherwise, the semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output. An encrypted query is executed under the target encryption strategy, and the result is returned. This solves the problem of not being able to improve query efficiency while ensuring data privacy, and achieves the goal of improving query efficiency while ensuring data privacy.
[0039] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description
[0040] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0041] Figure 1 This is a hardware structure block diagram of the terminal for the information query method in this embodiment.
[0042] Figure 2 This is a flowchart of the information query method in this embodiment.
[0043] Figure 3 This is a flowchart of the target encryption strategy selection process for the information query method in this embodiment.
[0044] Figure 4 This is a flowchart of another information query method in this embodiment.
[0045] Figure 5 This is a structural block diagram of the information query device in this embodiment. Detailed Implementation
[0046] To better understand the purpose, technical solution, and advantages of this application, the application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0047] Unless otherwise defined, the technical or scientific terms used in this application shall have the general meaning understood by one of ordinary skill in the art to which this application pertains. Words such as “a,” “an,” “an,” “the,” “the,” and “these” used in this application do not indicate quantitative limitation and may be singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps or modules (units) is not limited to the listed steps or modules (units) but may include steps or modules (units) not listed, or may include other steps or modules (units) inherent to these processes, methods, products, or devices. Words such as “connected,” “linked,” and “coupled” used in this application are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. “Multiple” used in this application refers to two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist; for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. Normally, the character " / " indicates that the objects before and after it are in an "or" relationship. The terms "first," "second," "third," etc., used in this application are merely to distinguish similar objects and do not represent a specific order of objects.
[0048] The method embodiments provided in this example can be executed on a terminal, computer, or similar computing device. For example, it can run on a terminal. Figure 1 This is a hardware structure block diagram of the terminal for the information query method in this embodiment. For example... Figure 1 As shown, a terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 and a memory 104 for storing data are also included. The processor 102 may be, but is not limited to, a microprocessor (MCU) or a programmable logic device (FPGA). The terminal may also include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown are illustrated.
[0049] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the information query method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0050] The transmission device 106 is used to receive or send data via a network. This network includes a wireless network provided by the terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 can be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0051] This embodiment provides an information query method. Figure 2 This is a flowchart of the information query method in this embodiment, such as... Figure 2 As shown, the process includes the following steps:
[0052] Step S201: Receive information query request.
[0053] The information query system front-end provides a unified query interface that can simultaneously listen to the following channels: JDBC protocol channel, ODBC protocol channel, and MongoDB Driver channel, but is not limited to these. Clients can connect with zero intrusion according to their own technology stack. Query requests support multiple input command formats, including Structured Query Language (SQL) queries, NoSQL queries, and custom-formatted queries. Structured Query Language (SQL) is the standard language for managing and manipulating relational databases; SQL statements are used for querying, updating, and deleting data in the database. NoSQL queries are designed to handle large-scale data storage needs; unlike traditional relational database management systems, they do not use tables to store data. This query interface receives user information query requests.
[0054] Step S202: Perform semantic analysis on the information query request to obtain the operation type, nesting level, number of function calls, and number of tables of the information query request.
[0055] Specifically, semantic analysis can be performed on received information query requests using methods such as rule-based regular expression pre-filtering, Abstract Syntax Tree (AST), semantic layer abstraction, and machine learning classifiers to obtain the operation type, nesting level, function call count, and number of tables in the information query request. The operation type includes, but is not limited to, addition, multiplication, composite functions, and multi-table joins. The operation type, nesting level, function call count, and number of tables can be used to evaluate the complexity of the information query request.
[0056] Step S203: When the number of operation types in the information query request is less than or equal to a preset threshold, pre-encrypted data is used for the query, and a semi-homomorphic encryption strategy is used as the target encryption strategy. When the number of operation types in the information query request is greater than the preset threshold, the complexity evaluation score of the information query request is calculated based on the operation type, nesting level, function call count, and number of tables. The current information query system resource status is checked. It is determined whether the current information query system resources meet the system resources required for the information query request. If so, if the complexity evaluation score of the information query request is lower than a preset threshold, a semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output. If the complexity evaluation score of the information query request is greater than or equal to a preset threshold, a fully homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output. Otherwise, a semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output.
[0057] Specifically, homomorphic encryption (HE) is a special form of encryption that allows specific types of computations to be performed on ciphertext without decryption, making it possible to perform operations directly on encrypted data. This provides a powerful tool for protecting privacy in data processing. To ensure data security during data retrieval, semi-homomorphic encryption (PHE) or fully homomorphic encryption (FHE) strategies are currently mainly used. Semi-homomorphic encryption supports only a single operation (such as addition or multiplication), is fast and efficient, but has limited functionality, providing efficient data processing capabilities in specific scenarios. Fully homomorphic encryption supports arbitrarily complex computations, is highly secure, and can perform any valid computation on ciphertext without decryption; however, it typically has high computational cost and complexity, resulting in high computational overhead and poor performance. Therefore, to combine the performance of both, this embodiment pre-constructs an encryption strategy decision tree, which can automatically configure the corresponding encryption strategy according to the renewal of different information query requests. The encryption strategy decision tree is composed of multiple factors and is evaluated in combination with multiple dimensions of query features.
[0058] Specifically, the security level can be determined first by assessing the required data security level of the information query request. A security level threshold can be set initially; if the level exceeds this threshold, the query is considered to require a higher security level, and a fully homomorphic encryption strategy is prioritized. Secondly, the encryption strategy is determined based on the number of operation types in the query request. If the number of operation types is less than or equal to a preset threshold (e.g., only addition and multiplication operations), semi-homomorphic encryption can be used directly to improve query efficiency. If the number of operation types exceeds the preset threshold, the complexity of the query request is further evaluated based on the operation types, nesting levels, function call counts, and number of query tables. Requests with diverse operation types, high nesting levels, numerous function calls, and a large number of query tables are considered highly complex. In cases of high complexity, semi-homomorphic encryption is insufficient, and a fully homomorphic encryption strategy is chosen. If the information query request has low complexity, such as containing only a single calculation type and having a low number of calls, a semi-homomorphic encryption strategy can be directly selected to speed up the query and reduce computational overhead. An encryption strategy decision tree is then established based on this.
[0059] For example, the Query Complexity Index (QCI) is calculated based on the operation type, nesting level, number of function calls, and number of tables in the information query request. The specific formula is as follows:
[0060] QCI = α × (number of operation types) + β × (nesting level) + γ × (number of function calls) + δ × (number of JOIN tables);
[0061] The weighting parameters α, β, γ, and δ can be determined based on the on-site environment and configured according to the query application scenario to adjust the importance of different factors.
[0062] A score threshold is pre-defined based on the current query application scenario. The score threshold is used to determine whether the complexity estimate score of the current information query request meets the requirements.
[0063] Before evaluation, the current resource status of the information query system is checked, and CPU utilization, content usage, disk I / O, GPU / FPGA utilization, etc. are collected in real time. When resources are scarce (e.g., CPU > 80%), a semi-homomorphic encryption strategy with lower computational overhead is preferred. If the current production environment cannot meet the query requirements with a semi-homomorphic encryption strategy, such as when complex operation types are involved, a fully homomorphic encryption strategy can also be selected. In this embodiment, it means that a semi-homomorphic encryption strategy is preferred when there are no special scenario requirements.
[0064] If the current information query system resources meet the system resources required for the information query request, the complexity evaluation score (QCI) of the information query request is compared with a preset score threshold. If the QCI is lower than the preset score threshold, a semi-homomorphic encryption strategy is used as the target encryption strategy and output. If the QCI is greater than or equal to the preset score threshold, a fully homomorphic encryption strategy is used as the target encryption strategy and output. This avoids all queries being performed using fully homomorphic encryption, thus speeding up the query process and reducing computational overhead.
[0065] Step S204: Execute an encryption query under the target encryption policy and return the result.
[0066] Specifically, based on the target encryption strategy determined in step S203 above, the original data in the database is encrypted, and the aggregation query is completed in the encrypted state. Finally, the data is decrypted and the plaintext result is returned.
[0067] Through steps S201 to S204 above, an information query request is received; semantic analysis is performed on the information query request to obtain the operation type, nesting level, function call count, and number of tables; when the number of operation types in the information query request is less than or equal to a preset threshold, pre-encrypted data is used for querying, and a semi-homomorphic encryption strategy is used as the target encryption strategy; when the number of operation types in the information query request is greater than the preset threshold, the complexity evaluation score of the information query request is calculated based on the operation type, nesting level, function call count, and number of tables; the current information query system resource status is checked; it is determined whether the current information query system resources meet the system resources required by the information query request; if so, if the complexity evaluation score of the information query request is lower than a preset score threshold, a semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output; if the complexity evaluation score of the information query request is greater than or equal to a preset score threshold, a fully homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output; otherwise, a semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output; an encrypted query is executed under the target encryption strategy, and the result is returned. The method first assesses the number of operation types in the information query request, prioritizing semi-homomorphic encryption for simple queries. Then, for complex queries, a complexity score is calculated, and the appropriate encryption strategy is selected based on the available resources of the information query system. This avoids the slow query speed and high computational cost caused by using fully homomorphic encryption for all information queries. This approach improves query efficiency and reduces computational overhead while ensuring data privacy and security.
[0068] In some embodiments, the method further includes performing semantic analysis on the information query request prior to:
[0069] The information query request is formatted and authorized for verification. After the format and authorization verifications are passed, the information query request is encapsulated in a standardized manner to standardize the data structure of the information query request.
[0070] Specifically, upon receiving an information query request, a preliminary verification is performed, including syntax and format verification and permission verification. Syntax and format verification mainly involves character set and encoding checks, lexical-level format scanning, and context length and complexity restrictions. For example, lexical segmentation based on finite state machines or regular expressions is used to identify keywords, literals, placeholders, and comments, and to prohibit more than two consecutive "--" or " / ". Nested comments (" / ") and closed string literals are required. The system calculates statement length, bracket depth, consecutive UNION counts, and comma-separated element counts; exceeding these thresholds marks the request as "high-risk," leading to direct rejection or manual review. This ensures correct syntax. Permission verification primarily involves a three-factor binding of identity, role, and tenant. For example, based on the JWT / OIDC declaration in the request, user_id, role, and tenant_id are extracted. If the tenant_id does not match the target database instance, the request is rejected. If the role is analyze but a DROP / ALTER request is made, the request is rejected, thus ensuring legitimate permissions.
[0071] After format and permission checks pass, the information query request is standardized and encapsulated, which can be done layer by layer according to "encapsulation goal → information model → field specification → versioning mechanism → lifecycle hooks". The encapsulation goal primarily ensures semantic uniqueness, module decoupling, secure transferability, and version evolution. Semantic uniqueness is ensured by eliminating ambiguities caused by SQL dialects, case sensitivity, aliases, and comments; module decoupling is achieved by ensuring that the parser, optimizer, encryption executor, and auditor rely only on the same data structure, avoiding repeated parsing of the original text; secure transferability is ensured by making the structure itself signatureable, encryptable, and compressible to prevent tampering during transit; and version evolution is ensured by allowing only field additions or modifications when encryption strategies, query syntax, or compliance requirements are upgraded, without disrupting existing processes. The information model can take the form of "three-level nested objects + a metadata table". Standardizing the encapsulation of the information query request standardizes its data structure, facilitating subsequent module processing. After standardization, the information query request can be transmitted using an SSL / TLS encrypted channel to prevent man-in-the-middle attacks and information leakage.
[0072] In another embodiment, semantic analysis includes lexical analysis and syntactic analysis. Semantic analysis of the information query request yields the operation type, nesting level, function call count, and number of tables for the information query request, including:
[0073] Lexical analysis breaks down information query requests into basic units, including keywords, identifiers, operators, and constants. Syntactic analysis constructs an abstract syntax tree to obtain the syntactic structure of the information query request. Operation type analysis is performed on each node of the abstract syntax tree to obtain the operation types of the information query request, and the nesting level, function call count, and number of tables of the information query request are extracted.
[0074] Specifically, information query requests are broken down into basic units through lexical analysis. These basic units include keywords, identifiers, operators, and constants. Keywords are used to describe the syntactic skeleton, identifiers are used to describe semantic entities, operators are used to represent operations or logic, and constants are used to describe literal values.
[0075] Then, an Abstract Syntax Tree (AST) is constructed from the information query requests after grammatical analysis and lattice spacing decomposition to obtain the syntactic structure of the information query requests. The actual meaning of each node in the AST is analyzed to determine the operation type, which includes addition, multiplication, function calls, single-table aggregation, and multi-table join operations. Simultaneously, the nesting level, number of function calls, and number of tables in the information query requests are extracted. These query features are used to more accurately determine the target encryption strategy.
[0076] In some embodiments, operation type analysis is performed on each node of the abstract syntax tree to obtain the operation types of the information query request, including:
[0077] By classifying the operation types of each node in the abstract syntax tree using a trained query classification model, the operation types of information query requests can be obtained.
[0078] In the process of determining the operation type by analyzing the actual meaning of each node in the abstract syntax tree, the query statement can be classified using a trained neural network model BERT or Transformer. The input is SQL text, and the output is an operation type label (such as "single-table aggregation", "multi-table JOIN", "containing complex mathematical operations"). An example of using the BERT neural network model to classify query statements is as follows:
[0079] #BERT+ classification layer model pseudocode class QueryClassifier(nn.Module):
[0080] def__init__(self, bert_model_name):
[0081] super().__init__();
[0082] #Load the pre-trained BERT model as a feature extractor;
[0083] self.bert=BertModel.from_pretrained(bert_model_name);
[0084] #Add a fully connected layer to perform 5-class classification;
[0085] #Categories: 0-Single-table aggregation; 1-Multi-table JOIN; 2-Complex functions; 3-Conditional judgments; 4-Others;
[0086] self.classifier = nn.Linear(768, 5);
[0087] def forward(self, input_ids, attention_mask):
[0088] # Feed the input token sequence to BERT;
[0089] outputs=self.bert(input_ids, attention_mask=attention_mask);
[0090] #Take the [CLS] vector output by BERT as sentence-level features;
[0091] pooled_output=outputs.pooler_output;
[0092] # Obtain 5-dimensional logits through the classification layer;
[0093] logits=self.classifier(pooled_output);
[0094] return logits;
[0095] A well-trained query classification model can more accurately determine the various operation types of information query requests.
[0096] Figure 3 This is a flowchart of the target encryption strategy selection process for the information query method in this embodiment, as follows: Figure 3 As shown, its automatic selection process includes the following steps:
[0097] Step S301: Obtain information query request;
[0098] Step S302: Calculate the complexity evaluation score (QCI) of the information query request based on the operation type, nesting level, number of function calls, and number of tables of the information query request;
[0099] Step S303: Determine whether the system resources meet the system resources required for the information query request. If yes, proceed to step S304; otherwise, proceed to step S305.
[0100] Step S304: Determine whether the complexity evaluation score (QCI) of the information query request is lower than the preset score threshold K. If yes, proceed to step S305; otherwise, proceed to step S306.
[0101] Step S305: Use the semi-homomorphic encryption strategy as the target encryption strategy and output the semi-homomorphic encryption strategy.
[0102] Step S306: Determine if the number of operation types in the information query request is greater than or equal to a preset threshold. If so, proceed to step S307; otherwise, proceed to step S305.
[0103] Step S307: Use the fully homomorphic encryption strategy as the target encryption strategy and output the fully homomorphic encryption strategy.
[0104] Table 1 shows the measured performance data. As can be seen from Table 1, compared with the traditional method using fully homomorphic encryption, the scheme in this embodiment significantly improves query efficiency.
[0105] Table 1
[0106]
[0107] Through steps S301 to S307 above, the complexity evaluation score of the information query request is obtained by calculating the operation type, nesting level, number of function calls, and number of tables of the information query request according to the preset complexity calculation formula. Then, the optimal encryption strategy is automatically determined by combining the system resources and the complexity of the operation type, thereby improving query efficiency while ensuring data privacy.
[0108] In some embodiments, before calculating the complexity evaluation score of the information query request based on the operation type, nesting level, number of function calls, and number of tables, the method further includes:
[0109] The system detects the security level required for the information query request. When the security level required for the information query request is the preset high security level, it uses the fully homomorphic encryption strategy as the target encryption strategy and outputs the target encryption strategy.
[0110] Specifically, before calculating the complexity score of an information query request based on its operation type, nesting level, number of function calls, and number of tables, the security of the information query request should be considered first, ensuring the security of the data query. Appropriate security levels can be set according to the required security level, which can be categorized as high, medium, and low, or the system can automatically determine the security level based on data sensitivity. For high-security scenarios, the fully homomorphic encryption strategy (FHE) should be prioritized even if performance is slightly lower. The FHE strategy should be used as the target encryption strategy, and the FHE strategy should be output.
[0111] In another embodiment, after outputting the target encryption strategy, the method further includes: calculating the query time of the information query request, and adjusting the weights of the parameters in the complexity evaluation score formula based on the query time.
[0112] Specifically, after executing the information query request, the actual time consumed by the query is calculated and compared with the pre-set theoretical query time. Based on the comparison result, the weight coefficients in the QCI calculation formula are adjusted to improve the query speed of the next execution of the same type of information query request. For example, if the current query type is a multi-table query (JOIN table), and the calculated time of the information query request exceeds the theoretical threshold, the weight coefficient δ corresponding to the number of JOIN tables in the QCI formula is automatically increased to improve the query speed when executing multi-table queries next time. This allows the QCI formula in this embodiment to automatically adapt to the query type, further improving information query efficiency.
[0113] This embodiment also provides an information query method. Figure 4 This is a flowchart of another information query method in this embodiment, such as... Figure 4 As shown, the process includes the following steps:
[0114] Step S401: Receive information query request;
[0115] Step S402: Perform format verification and permission verification on the information query request. After the format verification and permission verification pass, standardize and encapsulate the information query request to standardize the data structure of the information query request.
[0116] Step S403: The information query request is broken down into basic units through lexical analysis, where the basic units include keywords, identifiers, operators, and constants; an abstract syntax tree is constructed through syntax analysis to obtain the syntactic structure of the information query request; the operation type analysis of each node of the abstract syntax tree is performed through a trained query classification model to obtain the operation types of the information query request, and the nesting level, function call count, and number of tables of the information query request are extracted.
[0117] Step S404: Determine whether the number of operation types in the information query request is greater than or equal to a preset number threshold. If yes, proceed to step S405; otherwise, proceed to step S408.
[0118] Step S405: Calculate the complexity evaluation score (QCI) of the information query request based on the operation type, nesting level, number of function calls, and number of tables of the information query request.
[0119] Step S406: Determine whether the current information query system resources meet the system resources required for the information query request. If yes, proceed to step S407; otherwise, proceed to step S408.
[0120] Step S407: Determine whether the complexity evaluation score (QCI) of the information query request is lower than the preset score threshold K; if yes, proceed to step S408; otherwise, proceed to step S409.
[0121] Step S408: Use the semi-homomorphic encryption strategy as the target encryption strategy and output the semi-homomorphic encryption strategy.
[0122] Step S409: Use the fully homomorphic encryption strategy as the target encryption strategy and output the fully homomorphic encryption strategy.
[0123] Through steps S401 to S409, operations with lower complexity are first prioritized for semi-homomorphic encryption based on their complexity type. Then, operations with higher complexity are evaluated using a pre-defined complexity calculation formula based on the operation type, nesting level, number of function calls, and number of tables in the query request. This yields a complexity assessment score for the query request. Finally, the optimal encryption strategy is automatically determined by considering system resources, thus improving query efficiency while ensuring data privacy. During the query process, semi-homomorphic encryption (PHE) or fully homomorphic encryption (FHE) is dynamically selected as the encryption scheme based on the complexity of the query operation, the data volume, system resource status, and security level requirements. By intelligently selecting a suitable encryption strategy, query performance is optimized while ensuring data privacy, solving the problem that a single encryption strategy cannot simultaneously satisfy both efficiency and security.
[0124] This embodiment also provides an information query device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. The terms "module," "unit," and "subunit," etc., used below refer to combinations of software and / or hardware that perform a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0125] Figure 5 This is a structural block diagram of the information query device in this embodiment, as shown below. Figure 5 As shown, the device 50 includes: a receiving module 51, an analysis module 52, an encryption strategy selection module 53, and an execution module 54, wherein...
[0126] Receiving module 51 is used to receive information query requests;
[0127] Analysis module 52 is used to perform semantic analysis on information query requests to obtain the operation type, nesting level, number of function calls, and number of tables of the information query request;
[0128] The encryption strategy selection module 53 is used to: ...
[0129] Execution module 54 is used to perform encrypted queries under the target encryption policy and return the results.
[0130] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.
[0131] This embodiment also provides an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0132] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0133] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0134] S1, receives information query requests;
[0135] S2 performs semantic analysis on the information query request to obtain the operation type, nesting level, number of function calls, and number of tables of the information query request;
[0136] S3: When the number of operation types in the information query request is less than or equal to a preset threshold, pre-encrypted data is used for the query, and a semi-homomorphic encryption strategy is used as the target encryption strategy. When the number of operation types in the information query request is greater than the preset threshold, the complexity evaluation score of the information query request is calculated based on the operation type, nesting level, function call count, and number of tables. The current information query system resource status is checked to determine whether the current information query system resources meet the system resources required by the information query request. If so, if the complexity evaluation score of the information query request is lower than a preset score threshold, a semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output. If the complexity evaluation score of the information query request is greater than or equal to a preset score threshold, a fully homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output. Otherwise, a semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output.
[0137] S4 executes an encrypted query under the target encryption policy and returns the result.
[0138] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated in this embodiment.
[0139] Furthermore, in conjunction with the information query methods provided in the above embodiments, this embodiment can also provide a storage medium for implementation. This storage medium stores a computer program; when executed by a processor, the computer program implements any of the information query methods described in the above embodiments.
[0140] It should be understood that the specific embodiments described herein are merely illustrative of the application and not intended to limit it. All other embodiments derived by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.
[0141] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0142] Obviously, the accompanying drawings are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar situations based on these drawings without any creative effort. Furthermore, it is understood that although the work done in this development process may be complex and lengthy, for those skilled in the art, certain design, manufacturing, or production modifications made based on the technical content disclosed in this application are merely conventional technical means and should not be considered as insufficient disclosure of this application.
[0143] The term "embodiment" in this application refers to a specific feature, structure, or characteristic described in connection with an embodiment that may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily imply the same embodiment, nor does it imply that it is mutually exclusive with or independent of other embodiments. It will be clearly or implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0144] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0145] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of patent protection. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the appended claims.
Claims
1. An information retrieval method, characterized in that, include: Receive information query requests; Semantic analysis is performed on the information query request to obtain the operation type, nesting level, number of function calls, and number of tables of the information query request; When the number of operation types in the information query request is less than or equal to a preset threshold, the query is performed using pre-encrypted data, and a semi-homomorphic encryption strategy is used as the target encryption strategy. When the number of operation types in the information query request exceeds the preset threshold, the complexity evaluation score of the information query request is calculated based on the operation type, nesting level, number of function calls, and number of tables. Check the current resource status of the information query system; Determine whether the current information query system resources meet the system resources required for the information query request; If the complexity evaluation score of the information query request is lower than the preset score threshold, the semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output. If the complexity evaluation score of the information query request is greater than or equal to the preset score threshold, the fully homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output. Otherwise, the semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output. Execute an encrypted query under the target encryption policy and return the result.
2. The information query method according to claim 1, characterized in that, Before performing semantic analysis on the information query request, the method further includes: The information query request is subjected to format and permission verification. After the format and permission verifications pass, the information query request is standardized and encapsulated to standardize the data structure of the information query request.
3. The information query method according to claim 1, characterized in that, The semantic analysis includes lexical analysis and syntactic analysis. The semantic analysis of the information query request, to obtain the operation type, nesting level, function call count, and number of tables, includes: The lexical analysis breaks down the information query request into basic units, wherein the basic units include keywords, identifiers, operators, and constants. An abstract syntax tree is constructed through the syntactic analysis to obtain the syntactic structure of the information query request; Operation type analysis is performed on each node of the abstract syntax tree to obtain the operation types of the information query request, and the nesting level, function call count, and number of tables of the information query request are extracted.
4. The information query method according to claim 3, characterized in that, The operation type analysis of each node of the abstract syntax tree yields the operation types of the information query request, including: The operation types of each node in the abstract syntax tree are classified by the trained query classification model to obtain the operation types of the information query request.
5. The information query method according to claim 3 or claim 4, characterized in that, The operation types include addition operations, multiplication operations, function calls, single-table aggregation, and multi-table join operations.
6. The information query method according to claim 1, characterized in that, Before calculating the complexity evaluation score of the information query request based on the operation type, nesting level, number of function calls, and number of tables, the method further includes: The required security level for detecting the information query request. When the security level required for the information query request is detected to be a preset high security level, the fully homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output.
7. The information query method according to claim 1, characterized in that, After outputting the target encryption policy, the method further includes: Calculate the query time of the information query request, and adjust the weights of each parameter in the complexity evaluation score formula based on the query time.
8. An information query device, characterized in that, include: The module comprises a receiving module, an analysis module, an encryption strategy selection module, and an execution module. The receiving module is used to receive information query requests; The analysis module is used to perform semantic analysis on the information query request to obtain the operation type, nesting level, function call count, and number of tables of the information query request; The encryption strategy selection module is used to: ... The execution module is used to perform encrypted queries under the target encryption policy and return the results.
9. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the information query method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the information query method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data circulation method, device, storage medium and terminal
CN110516467A
Data security retrieval method based on homomorphic encryption
CN119474479A