Information query method, information query device, electronic device and storage medium

By performing semantic analysis and complexity assessment on information query requests and dynamically selecting semi-homomorphic or fully homomorphic encryption strategies, the problem of balancing data privacy and query efficiency in existing technologies is solved, and efficient data querying is achieved.

CN120910101AActive Publication Date: 2025-11-07E SURFING VISION TECHNOLOGY CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511440034.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-10
Publication Date
2025-11-07
Estimated Expiration
2045-10-10

AI Technical Summary

Technical Problem

Existing homomorphic encryption schemes cannot effectively improve query efficiency while ensuring data privacy, resulting in limited application scope and low query efficiency when databases process sensitive data.

Method used

By receiving information query requests, performing semantic analysis and evaluating their operation type, nesting level, function call count, and number of tables, the system dynamically selects semi-homomorphic or fully homomorphic encryption strategies and optimizes the encryption strategy based on query complexity and system resource status, thereby improving query efficiency while ensuring data privacy.

Benefits of technology

This approach achieves improved query efficiency, reduced computational overhead, and optimized database query performance while ensuring data privacy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120910101A_ABST
    Figure CN120910101A_ABST
Patent Text Reader

Abstract

The invention relates to an information query method, an information query device, an electronic device and a storage medium, and the information query method comprises the following steps: receiving an information query request; performing semantic analysis on the information query request to obtain an operation type, a nesting hierarchy, a function call frequency and a table quantity of the information query request; calculating a complexity evaluation score according to the information of the information query request; judging whether the current information query system resource meets the system resource required by the information query request or not; if yes, under the condition that the complexity evaluation score is lower than a preset score threshold value, taking the semi-homomorphic encryption strategy as a target encryption strategy; otherwise, taking the semi-homomorphic encryption strategy as a target encryption strategy; and executing encryption query under the target encryption strategy and returning a result. Through the method and the device, the problem that the query efficiency cannot be improved while the data privacy is guaranteed is solved, and the query efficiency is improved while the data privacy is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of information security, and in particular to an information query method, an information query device, an electronic device and a storage medium. BACKGROUND

[0002] With the rapid development of information technology, cloud computing environment is increasingly popular, and users have an increasingly urgent need for data analysis and processing without exposing sensitive information. As a cutting-edge encryption technology, homomorphic encryption has the unique advantage of allowing computation operations on ciphertext without decrypting the original data, providing a new way of thinking for solving data privacy protection problems.

[0003] However, the current existing homomorphic encryption schemes are mainly divided into two categories: partially homomorphic encryption (PHE) and fully homomorphic encryption (FHE). Partially homomorphic encryption usually shows high efficiency on specific operations such as addition or multiplication, but its functionality is relatively limited and difficult to meet complex computing needs. In contrast, fully homomorphic encryption can support arbitrary computing operations, but its computing cost is too high and faces performance bottlenecks in practical applications. Since different application scenarios have different encryption requirements, how to intelligently select the appropriate encryption strategy according to specific needs has become a key problem to be solved in this field.

[0004] Currently, most database encryption schemes generally have two extreme cases when dealing with complex queries. On the one hand, some schemes rely too much on fully homomorphic encryption, which can meet the needs of complex computing, but the high computing cost leads to a serious decline in performance, making it impossible to achieve efficient data processing. On the other hand, some schemes use partially homomorphic encryption unreasonably, which cannot provide sufficient support when facing complex computing needs, making it difficult to balance data privacy protection and query efficiency. This not only limits the application range of the database in processing sensitive data, but also brings many inconveniences to users. At present, in order to meet the computing operation, all use the fully homomorphic encryption mode.

[0005] In view of the problem that the related art cannot guarantee data privacy while improving query efficiency, there is currently no effective solution. SUMMARY

[0006] An information query method, an information query device, an electronic device and a storage medium are provided in the present embodiment to solve the problem that the related art cannot guarantee data privacy while improving query efficiency.

[0007] In a first aspect, an information query method is provided in the present embodiment, comprising:

[0008] receiving an information query request;

[0009] performing semantic analysis on the information query request to obtain an operation type, a nesting level, a function call number, and a table number of the information query request;

[0010] when the number of the operation types of the information query request is less than or equal to a preset number threshold, performing query by using pre-encrypted encrypted data and taking a semi-homomorphic encryption strategy as a target encryption strategy;

[0011] when the number of the operation types of the information query request is greater than the preset number threshold, calculating a complexity evaluation score of the information query request according to the operation type, the nesting level, the function call number, and the table number of the information query request;

[0012] detecting a current information query system resource state;

[0013] judging whether the current information query system resource meets a system resource required by the information query request;

[0014] if yes, taking a semi-homomorphic encryption strategy as a target encryption strategy and outputting the target encryption strategy in a case where the complexity evaluation score of the information query request is less than a preset score threshold, and taking a full-homomorphic encryption strategy as the target encryption strategy and outputting the target encryption strategy in a case where the complexity evaluation score of the information query request is greater than or equal to the preset score threshold;

[0015] otherwise, taking the semi-homomorphic encryption strategy as the target encryption strategy and outputting the target encryption strategy;

[0016] performing encrypted query under the target encryption strategy and returning a result.

[0017] In some embodiments thereof, before the performing semantic analysis on the information query request, the method further comprises:

[0018] performing format verification and permission verification on the information query request, and performing standardized packaging on the information query request to standardize a data structure of the information query request after the format verification and the permission verification pass.

[0019] In some embodiments thereof, the semantic analysis comprises lexical analysis and syntax analysis, and the performing semantic analysis on the information query request to obtain the operation type, the nesting level, the function call number, and the table number of the information query request comprises:

[0020] splitting the information query request into basic units by the lexical analysis, wherein the basic units comprise keywords, identifiers, operators, and constants;

[0021] construct an abstract syntax tree by the syntax analysis, to obtain a syntax structure of the information query request;

[0022] perform operation type analysis on each node of the abstract syntax tree, to obtain each operation type of the information query request, and extract a nesting level, a number of function calls, and a number of tables of the information query request.

[0023] In some embodiments, the operation type analysis on each node of the abstract syntax tree, to obtain each operation type of the information query request, comprises:

[0024] perform operation type classification on each node of the abstract syntax tree by the trained query classification model, to obtain each operation type of the information query request.

[0025] In some embodiments, the operation types comprise addition operation, multiplication operation, function call, single-table aggregation, and multi-table association operation.

[0026] In some embodiments, before calculating the complexity evaluation score of the information query request according to the operation types, the nesting level, the number of function calls, and the number of tables of the information query request, the method further comprises:

[0027] detecting a security level required by the information query request,

[0028] when the detected security level required by the information query request is a preset high security level, taking a full homomorphic encryption strategy as the target encryption strategy, and outputting the target encryption strategy.

[0029] In some embodiments, after outputting the target encryption strategy, the method further comprises:

[0030] calculating a query time consumption of the information query request, and adjusting weights of each parameter in the complexity evaluation score formula according to the query time consumption.

[0031] In a second aspect, the present embodiment provides an information query device, comprising a receiving module, an analysis module, an encryption strategy selection module, and an execution module, wherein,

[0032] The receiving module is configured to receive an information query request.

[0033] The analysis module is configured to perform semantic analysis on the information query request, to obtain operation types, a nesting level, a number of function calls, and a number of tables of the information query request.

[0034] The encryption policy selection module is configured to, when the number of operation types of the information query request is less than or equal to a preset number threshold, perform the query by using pre-encrypted encrypted data, and set a semi-homomorphic encryption policy as a target encryption policy; when the number of operation types of the information query request is greater than the preset number threshold, calculate a complexity evaluation score of the information query request according to the operation types, the nesting levels, the function call times and the table numbers of the information query request; detect a current information query system resource state, and determine whether the current information query system resource meets system resources required by the information query request; if yes, set the semi-homomorphic encryption policy as the target encryption policy in a case where the complexity evaluation score of the information query request is less than a preset score threshold, and output the target encryption policy; set a full-homomorphic encryption policy as the target encryption policy in a case where the complexity evaluation score of the information query request is greater than or equal to the preset score threshold, and output the target encryption policy; otherwise, set the semi-homomorphic encryption policy as the target encryption policy, and output the target encryption policy;

[0035] The execution module is configured to perform the encrypted query under the target encryption policy and return a result.

[0036] In a third aspect, an electronic device is provided in the embodiment, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the information query method in the first aspect when executing the computer program.

[0037] In a fourth aspect, a storage medium is provided in the embodiment, which stores a computer program executable by a processor to implement the information query method in the first aspect.

[0038] Compared with the related art, the information query method provided in the embodiment, by receiving an information query request; performing semantic analysis on the information query request to obtain an operation type, a nesting level, a function call number and a table number of the information query request; when a number of the operation types of the information query request is less than or equal to a preset number threshold, performing query by using pre-encrypted encrypted data, and taking a semi-homomorphic encryption strategy as a target encryption strategy; when the number of the operation types of the information query request is greater than the preset number threshold, calculating a complexity evaluation score of the information query request according to the operation type, the nesting level, the function call number and the table number of the information query request; detecting a current information query system resource state; judging whether the current information query system resource meets a system resource required by the information query request; if yes, in a case where the complexity evaluation score of the information query request is lower than a preset score threshold, taking the semi-homomorphic encryption strategy as the target encryption strategy, and outputting the target encryption strategy; in a case where the complexity evaluation score of the information query request is greater than or equal to the preset score threshold, taking a full-homomorphic encryption strategy as the target encryption strategy, and outputting the target encryption strategy; otherwise, taking the semi-homomorphic encryption strategy as the target encryption strategy, and outputting the target encryption strategy; performing encrypted query under the target encryption strategy and returning a result, the problem that data privacy cannot be ensured while improving query efficiency is solved, and the query efficiency is improved while ensuring the data privacy.

[0039] The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below. Other features, objects, and advantages of the application will be apparent from the description and drawings, and from the claims. BRIEF DESCRIPTION OF DRAWINGS

[0040] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and serve to explain the principles of the application. In the drawings:

[0041] Figure 1 is a hardware structure block diagram of a terminal of the information query method of the embodiment.

[0042] Figure 2 is a flowchart of the information query method of the embodiment.

[0043] Figure 3 is a target encryption strategy selection flowchart of the information query method of the embodiment.

[0044] Figure 4 is a flowchart of another information query method of the embodiment.

[0045] Figure 5 is a structure block diagram of an information query device of the embodiment. DETAILED DESCRIPTION

[0046] In order to clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and explained below in conjunction with the accompanying drawings and embodiments.

[0047] Unless otherwise defined, technical terms or scientific terms used in the present application shall have the general meaning understood by a person skilled in the art to which the present application belongs. In the present application, "one", "a", "an", "the", "these" and similar words do not represent a quantitative limitation, and they can be singular or plural. In the present application, the terms "include", "contain", "have" and any variants thereof have the purpose of covering non-exclusive inclusion; for example, a process, method and system, product or device containing a series of steps or modules (units) are not limited to the listed steps or modules (units), but can include steps or modules (units) not listed, or can include other steps or modules (units) inherent to the process, method, product or device. In the present application, the words "connected", "connected", "coupled" and the like do not limit to physical or mechanical connection, but can include electrical connection, whether direct or indirect. In the present application, "multiple" means two or more. "And / or" describes the association between the associated objects, which means that there can be three relationships, for example, "A and / or B" can mean that A exists alone, A and B exist together, and B exists alone. In general, the character " / " represents an "or" relationship between the objects before and after. In the present application, the terms "first", "second", "third" and the like are only used to distinguish similar objects, and do not represent a specific order for the objects.

[0048] The method embodiments provided in the present embodiment can be executed in a terminal, a computer or a similar computing device. For example, the method embodiments are executed on a terminal, Figure 1 is a hardware structure diagram of the terminal of the information query method of the present embodiment. As shown in Figure 1 , the terminal can include one or more (only one is shown in Figure 1 ) processor 102 and memory 104 for storing data, wherein the processor 102 can include but not limited to processing devices such as microprocessor MCU or programmable logic device FPGA. The above terminal can also include a transmission device 106 for communication function and an input / output device 108. Those skilled in the art can understand that Figure 1 The structure shown in Figure 1 is only a schematic, which does not limit the structure of the above terminal. For example, the terminal can include more or less components than those shown in Figure 1 , or have a different configuration from that shown.

[0049] The memory 104 can be used to store computer programs, such as software programs of application software and modules, such as a computer program corresponding to the information query method in the embodiment. The processor 102 executes various functional applications and data processing, i.e., implements the method described above, by running the computer program stored in the memory 104. The memory 104 can include a high-speed random access memory, and can further include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 104 can further include a memory remotely arranged with respect to the processor 102, which can be connected to the terminal through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0050] The transmission device 106 is used to receive or send data via a network. The network described above includes a wireless network provided by a communication provider of the terminal. In one example, the transmission device 106 includes a network interface controller (NIC) which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module which is used to communicate with the Internet in a wireless manner.

[0051] In the embodiment, an information query method is provided, Figure 2 A flowchart of the information query method of the embodiment is shown in Figure 2 The flowchart includes the following steps:

[0052] In step S201, an information query request is received.

[0053] The information query system front end provides a unified query interface, which can simultaneously listen to the following channels: a JDBC protocol channel, an ODBC protocol channel, and a MongoDB Driver channel, but is not limited to these channels, and a client can be connected according to its own technology stack “zero-intrusion”. The query request supports input instructions in multiple formats, including structured query language (Structured Query Language, SQL) query statements, non-relational query language (NoSQL) query statements, and custom format query statements. Structured query language is a standard language for managing and operating relational databases. SQL statements are used to query, update, and delete data in databases, etc. NoSQL query statements are designed to handle large-scale data storage requirements, and unlike traditional relational database management systems, they do not use tables to store data. The information query request of a user is received through the query interface.

[0054] Step S202, the information query request is analyzed semantically to obtain the operation type, the nesting level, the function call times and the table quantity of the information query request.

[0055] Specifically, the received information query request can be analyzed semantically by a rule-regular fast pre-filtering method, an Abstract Syntax Tree (AST), a semantic layer abstraction and a machine learning classifier, to obtain the operation type, the nesting level, the function call times and the table quantity of the information query request. The operation type includes but is not limited to addition, multiplication, composite function, multi-table association, etc. The operation type, the nesting level, the function call times and the table quantity can evaluate the complexity of the information query request.

[0056] Step S203, when the number of operation types of the information query request is less than or equal to a preset number threshold, the pre-encrypted encrypted data is used for query, and the semi-homomorphic encryption strategy is used as the target encryption strategy; when the number of operation types of the information query request is greater than the preset number threshold, the complexity evaluation score of the information query request is calculated according to the operation type, the nesting level, the function call times and the table quantity of the information query request; the current information query system resource state is detected; it is judged whether the current information query system resource meets the system resource required by the information query request; if yes, in the case that the complexity evaluation score of the information query request is lower than a preset score threshold, the semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output; in the case that the complexity evaluation score of the information query request is greater than or equal to the preset score threshold, the full-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.

[0057] Specifically, homomorphic encryption (HE): a special form of encryption that allows certain types of calculations on ciphertexts without decryption, making it possible to perform operations directly on encrypted data. This provides a powerful tool for privacy-preserving data processing. In order to ensure the security of data during data query process, currently mainly using partially homomorphic encryption strategy (PHE) or fully homomorphic encryption strategy (FHE). Partially homomorphic encryption strategy only supports single operation (such as addition or multiplication), fast, efficient, but the function is limited, in a specific scenario can provide efficient data processing capability. Fully homomorphic encryption strategy supports any complex calculation, strong security, can perform any valid calculation on ciphertext without decryption, however, fully homomorphic encryption strategy usually has high computational cost and complexity, large computational overhead, poor performance. Therefore, in order to integrate the performance of the two, in this embodiment, by pre-constructing an encryption strategy decision tree, the corresponding encryption strategy can be automatically configured according to different information query request. Among them, the encryption strategy decision tree is composed of multiple dimensions, and the query characteristics are evaluated in multiple dimensions.

[0058] Specifically, the security level of the information query request can be determined according to the data security level required by the information query request, wherein a security level threshold can be set first, if the security level threshold is exceeded, it is determined that the security level required by the information query request is high, and in the case of high security level required, the fully homomorphic encryption strategy is preferred. Secondly, the encryption strategy is determined according to the number of operation types in the information query request, wherein if the number of operation types in the information query request is less than or equal to a preset number threshold, for example, there are only two operations of addition and multiplication in the information query request, then the partially homomorphic encryption can be directly used for operation, so as to improve the efficiency of query. If the number of operation types in the information query request is greater than the preset number threshold, then the complexity of the information query request is evaluated according to the operation type, nesting level, function call frequency, number of query tables in the information query request, and the information query request with multiple operation types, multiple nesting levels, multiple function call frequencies and multiple query table numbers can be determined as high complexity. In the case of high complexity of information query request, the partially homomorphic encryption strategy cannot meet the query requirements, and the fully homomorphic encryption strategy is selected. If the complexity of the information query request is low, for example, only a single calculation type is included, and the call frequency is also low, then the partially homomorphic encryption strategy can be directly selected to speed up the query and reduce the computational overhead. In this way, the encryption strategy decision tree is established.

[0059] Exemplarily, the complexity evaluation score (Query Complexity Index, QCI) of the information query request is calculated according to the operation type, the nesting level, the number of function calls and the number of tables of the information query request, and the specific formula is as follows:

[0060] QCI = a x (number of operation types) + b x (nesting level) + g x (number of function calls) + d x (number of JOIN tables);

[0061] Wherein, the weight parameters a, b, g, d can be determined according to the field environment, configured according to the query application scenario, and used to adjust the importance of different factors.

[0062] A score threshold is set in advance according to the current query application scenario, and the complexity estimation score of the current information query request is judged by the score threshold.

[0063] Before evaluation, the current information query system resource state is detected, and CPU usage, content occupation, disk I / O, GPU / FPGA utilization and the like are collected in real time. When the resource is tight (such as CPU > 80%), the semi-homomorphic encryption strategy with smaller calculation overhead is preferentially selected. If the current production environment cannot meet the query requirements through the semi-homomorphic encryption strategy, for example, when complex operation types are involved, the full-homomorphic encryption strategy can also be selected. In the embodiment, the semi-homomorphic encryption strategy is preferentially selected in the absence of special scene requirements.

[0064] When the current information query system resource meets the system resource required by the information query request, the complexity evaluation score QCI of the information query request is compared with the preset score threshold. If the complexity evaluation score QCI of the information query request is lower than the preset score threshold, the semi-homomorphic encryption strategy is selected as the target encryption strategy, and the semi-homomorphic encryption strategy is output. If the complexity evaluation score QCI of the information query request is greater than or equal to the preset score threshold, the full-homomorphic encryption strategy is selected as the target encryption strategy, and the target encryption strategy is output. In this way, all queries are not performed through the full-homomorphic encryption mode, the query speed is accelerated, and the calculation overhead is reduced.

[0065] Step S204, performing encrypted query under the target encryption strategy and returning the result.

[0066] Specifically, according to the target encryption strategy determined in the above step S203, the original data in the database is encrypted, and the aggregation query is completed in the encrypted state, and finally the plaintext result is decrypted and returned.

[0067] According to the above steps S201 to S204, the information query request is received; semantic analysis is performed on the information query request to obtain an operation type, a nesting level, a function call number and a table number of the information query request; when the number of the operation types of the information query request is less than or equal to a preset number threshold, the pre-encrypted encrypted data is used for query, and a semi-homomorphic encryption strategy is used as a target encryption strategy; when the number of the operation types of the information query request is greater than the preset number threshold, a complexity evaluation score of the information query request is calculated according to the operation type, the nesting level, the function call number and the table number of the information query request; a current information query system resource state is detected; it is judged whether the current information query system resource meets a system resource required by the information query request; if yes, in a case where the complexity evaluation score of the information query request is less than a preset score threshold, the semi-homomorphic encryption strategy is used as the target encryption strategy, and the target encryption strategy is output; in a case where the complexity evaluation score of the information query request is greater than or equal to the preset score threshold, a full-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; and an encrypted query is performed under the target encryption strategy, and a result is returned. In the method, simple query requests are preferentially selected to use the semi-homomorphic encryption strategy through the evaluation of the number of operation types in the information query request, and complex query requests are selected to use corresponding encryption strategies by calculating the complexity evaluation score of the information query request and combining the current information query system resource, so that the problem of slow query speed and large calculation cost caused by using the full-homomorphic encryption strategy for all information queries is avoided. The query efficiency is improved and the calculation cost is reduced on the basis of ensuring data privacy security.

[0068] In some embodiments, before the semantic analysis of the information query request, the method further comprises:

[0069] The information query request is subjected to format verification and authority verification, and after the format verification and the authority verification pass, the information query request is standardized encapsulated to standardize a data structure of the information query request.

[0070] Specifically, after receiving the information query request, preliminary verification is performed, including syntax format verification and authority verification. The syntax format verification mainly includes character set and coding verification, lexical level format scanning, and context length and complexity limitation, for example, lexical segmentation based on a finite state machine or regular, identification of keywords, literals, placeholders, comments, prohibition of more than 2 consecutive “--” or “ / The nested comment, the string literal must be closed; the length of the calculation statement, the depth of the parentheses, the number of consecutive UNIONS, and the number of comma-separated elements are calculated, and if the threshold is exceeded, it is marked as “high risk”, which can be directly rejected or put into the manual review queue, so as to ensure the correct syntax format. The permission verification is mainly for the three-way binding of identity-role-tenant, for example: according to the JWT / OIDC declaration carried by the request, extract user_id, role, tenant_id; if tenant_id does not match the target library instance, it is directly rejected; if the role is analyst but requests DROP / ALTER, it is rejected; so as to ensure the legality of the permission.

[0071] After the format verification and permission verification pass, the information query request is standardized and encapsulated, which can be expanded layer by layer according to “encapsulation target→information model→field specification→versioning mechanism→lifecycle hook”. Among them, the encapsulation target is mainly to ensure semantic uniqueness, module decoupling, safe transmission and version evolution. By eliminating the ambiguity caused by SQL dialect, case, alias and comment to ensure semantic uniqueness; make the parser, optimizer, encryption executor and auditor only rely on the same data structure, and no longer parse the original text repeatedly to realize module decoupling; through the structure itself can be signed, encrypted and compressed, to prevent tampering in the middle and ensure safe transmission; when the encryption policy, query syntax or compliance requirements are upgraded, only the field needs to be changed, without destroying the existing link, ensuring version evolution. The information model can adopt the form of “three-layer nested objects + one metadata table”. By standardizing the encapsulation of the information query request, the data structure of the information query request is standardized to facilitate 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 syntax analysis, and the information query request is subjected to semantic analysis to obtain the operation type, nesting level, function call number and table number of the information query request, including:

[0073] The information query request is split into basic units through lexical analysis, wherein the basic units include keywords, identifiers, operators and constants; the syntax structure of the information query request is obtained by constructing an abstract syntax tree through syntax analysis; the operation type of each node of the abstract syntax tree is analyzed to obtain each operation type of the information query request, and the nesting level, function call number and table number of the information query request are extracted.

[0074] Specifically, the information query request is split into basic units by lexical analysis, wherein the basic units include keywords, identifiers, operators, constants, etc., wherein the keywords are used to express the syntax skeleton, the identifiers are used to express semantic entities, the operators are used to represent operations or logics, and the constants are used to express literal values.

[0075] The information query request after the split is further parsed by syntax analysis to construct an abstract syntax tree (AST), so as to obtain the syntax structure of the information query request. The actual meaning of each node in the abstract syntax tree AST is analyzed to determine the operation type, wherein the operation type includes addition operation, multiplication operation, function call, single table aggregation, and multi-table association operation. The nesting level, function call times, and table quantity of the information query request are extracted synchronously. The target encryption strategy is more accurately obtained by extracting these information query features.

[0076] In some embodiments, the operation type analysis is performed on each node of the abstract syntax tree, so as to obtain each operation type of the information query request, including:

[0077] Each node of the abstract syntax tree is classified by the trained query classification model to obtain each operation type of the information query request.

[0078] In the above process of determining the operation type by analyzing the actual meaning of each node of the abstract syntax tree, the neural network model BERT and the Transformer can be used to classify the query statement, the input is the SQL text, and the output is the operation type label (such as "single table aggregation", "multi-table JOIN", and "containing complex mathematical operation"). The code for classifying the query statement by using the neural network model BERT is as follows:

[0079] #BERT+classification layer model pseudo code 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] #Connect a fully connected layer for 5 classification;

[0085] Category: 0 - single table aggregation; 1 - multi-table JOIN; 2 - complex function; 3 - conditional judgment; 4 - other;

[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 of BERT output as the sentence-level feature;

[0091] pooled_output = outputs.pooler_output;

[0092] # Get 5-dimensional logits through the classification layer;

[0093] logits = self.classifier(pooled_output);

[0094] return logits;

[0095] Through the trained query classification model, each operation type of the information query request can be more accurately obtained.

[0096] Figure 3 is the target encryption strategy selection flowchart of the information query method of the embodiment, as shown in Figure 3 , the automatic selection process includes the following steps:

[0097] Step S301, obtaining an information query request;

[0098] Step S302, calculating a complexity evaluation score QCI of the information query request according to an operation type, a nesting level, a function call number and a table number of the information query request;

[0099] Step S303, judging whether the system resources meet the system resources required by the information query request, if yes, executing step S304; otherwise, executing 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, execute step S305, otherwise execute step S306;

[0101] Step S305, take the semi-homomorphic encryption strategy as the target encryption strategy, and output the semi-homomorphic encryption strategy.

[0102] Step S306, determine whether the number of operation types in the information query request is greater than or equal to the preset number threshold, if yes, execute step S307; otherwise, execute step S305;

[0103] Step S307, take the fully homomorphic encryption strategy as the target encryption strategy, and output the fully homomorphic encryption strategy.

[0104] Table 1 is the measured performance data, and from Table 1, it can be seen that compared with the traditional fully homomorphic encryption, the query efficiency is obviously improved by the scheme of the embodiment:

[0105] Table 1

[0106]

[0107] Through the above steps S301 to S307, by calculating the operation type, nesting level, function call number and table number of the information query request according to the preset complexity calculation formula, the complexity evaluation score of the information query request is obtained, and then the optimal encryption strategy is automatically determined according to the system resources and the complexity of the operation type, which improves the query efficiency while ensuring data privacy.

[0108] In some embodiments, before calculating the complexity evaluation score of the information query request according to the operation type, nesting level, function call number and table number of the information query request, it further includes:

[0109] Detect the security level required by the information query request, and when the detected security level required by the information query request is a preset high security level, take the fully homomorphic encryption strategy as the target encryption strategy, and output the target encryption strategy.

[0110] Specifically, before calculating the complexity evaluation score of the information query request according to the operation type, nesting level, function call number and table number of the information query request, the security level of the information query request is considered first, and the security of data query is ensured first. The security level can be set according to the required security level, and the security level can be divided into high, medium and low according to the security level, or the system can automatically judge the security level according to the data sensitivity. For high security demand scene, even if the performance is slightly poor, the fully homomorphic encryption strategy FHE is still preferred. Take the fully homomorphic encryption strategy as the target encryption strategy, and output the fully homomorphic encryption strategy.

[0111] In another embodiment, after outputting the target encryption policy, further comprising: calculating a query time consumption of the information query request, and adjusting the weight of each parameter in the complexity evaluation score formula according to the query time consumption.

[0112] Specifically, after the information query request is executed, the actual time length consumed by the information query request is calculated, and compared with the theoretically set theoretical query time length, and the weight coefficient in the above QCI calculation formula is adjusted according to the comparison result, so as 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), the time consumption of this information query request exceeds the theoretical threshold, and the weight coefficient δ corresponding to the number of JOIN tables in the QCI formula is automatically increased, so that the query speed is improved when the multi-table query is executed next time. The QCI formula of the embodiment can automatically adapt to the query type, and further improve the information query efficiency.

[0113] In the embodiment, an information query method is also provided. Figure 4 is a flowchart of another information query method of the embodiment, as Figure 4 shown, the flowchart includes the following steps:

[0114] Step S401, receiving an information query request;

[0115] Step S402, performing format verification and permission verification on the information query request, and after the format verification and permission verification are passed, standardizing and packaging the information query request, so as to standardize the data structure of the information query request;

[0116] Step S403, splitting the information query request into basic units through lexical analysis, wherein the basic units include keywords, identifiers, operators and constants; constructing an abstract syntax tree through syntax analysis to obtain the syntax structure of the information query request; performing operation type analysis on each node of the abstract syntax tree through the trained query classification model to obtain each operation type of the information query request, and extracting the nesting level, function call times and table number of the information query request;

[0117] Step S404, determining whether the number of operation types in the information query request is greater than or equal to a preset number threshold, if yes, executing step S405; otherwise, executing step S408;

[0118] Step S405, calculating the complexity evaluation score QCI of the information query request according to the operation type, nesting level, function call times and table number of the information query request;

[0119] Step S406, it is judged whether the current information query system resource satisfies the system resource required by the information query request, if yes, step S407 is executed, otherwise, step S408 is executed;

[0120] Step S407, it is judged whether the complexity evaluation score QCI of the information query request is lower than the preset score threshold K; if yes, step S408 is executed; otherwise, step S409 is executed;

[0121] Step S408, the semi-homomorphic encryption strategy is taken as the target encryption strategy, and the semi-homomorphic encryption strategy is output.

[0122] Step S409, the full-homomorphic encryption strategy is taken as the target encryption strategy, and the full-homomorphic encryption strategy is output.

[0123] Through the above steps S401 to S409, first, the semi-homomorphic encryption is preferentially selected according to the complexity of the operation type, the complexity evaluation score of the information query request is calculated according to the operation type, the nesting level, the function call times and the table quantity of the information query request according to the preset complexity calculation formula, and the optimal encryption strategy is automatically determined according to the system resource, so as to improve the query efficiency while ensuring the data privacy. In the query process, the semi-homomorphic encryption (PHE) or the full-homomorphic encryption (FHE) is dynamically selected as the encryption scheme according to the complexity of the query operation, the data size, the system resource state and the security level requirement. By intelligently selecting the appropriate encryption strategy, the query performance is optimized while ensuring the data privacy, and the problem that a single encryption strategy cannot simultaneously meet the efficiency and security is solved.

[0124] In the embodiment, an information query device is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments, and will not be described again. The terms "module", "unit", "sub-unit" and the like used below can be a combination of software and / or hardware that can realize a predetermined function. Although the device described in the following embodiments is preferably realized in software, the realization of hardware, or a combination of software and hardware is also possible and conceived.

[0125] Figure 5 is a structure block diagram of the information query device of the embodiment, as Figure 5 shown, the device 50 comprises a receiving module 51, an analysis module 52, an encryption strategy selection module 53 and an execution module 54, wherein,

[0126] The receiving module 51 is used to receive the information query request;

[0127] The analysis module 52 is used to perform semantic analysis on the information query request to obtain the operation type, the nesting level, the function call times and the table quantity of the information query request;

[0128] The encryption policy selection module 53 is configured to, when the number of operation types of the information query request is less than or equal to a preset number threshold, query using pre-encrypted encrypted data, and set a semi-homomorphic encryption policy as a target encryption policy; when the number of operation types of the information query request is greater than the preset number threshold, calculate a complexity evaluation score of the information query request according to the operation types, the nesting level, the number of function calls, and the number of tables of the information query request; detect a current information query system resource state, and determine whether the current information query system resource meets a system resource required by the information query request; if yes, set the semi-homomorphic encryption policy as the target encryption policy in a case where the complexity evaluation score of the information query request is less than a preset score threshold, and output the target encryption policy; set a full-homomorphic encryption policy as the target encryption policy in a case where the complexity evaluation score of the information query request is greater than or equal to the preset score threshold, and output the target encryption policy; or set the semi-homomorphic encryption policy as the target encryption policy, and output the target encryption policy;

[0129] The execution module 54 is configured to execute the encrypted query under the target encryption policy and return a result.

[0130] It should be noted that each of the above modules can be a functional module or a program module, and can be implemented by software or hardware. For the modules implemented by hardware, each of the above modules can be located in the same processor; or each of the above modules can also be located in different processors in any combination.

[0131] In this embodiment, an electronic device is also provided, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above method embodiments.

[0132] Optionally, the electronic device can further include a transmission device and an input / output device, wherein the transmission device is connected with the processor, and the input / output device is connected with the processor.

[0133] Optionally, in this embodiment, the processor can be configured to execute the following steps through the computer program:

[0134] S1, receiving an information query request;

[0135] S2, performing semantic analysis on the information query request to obtain operation types, a nesting level, a number of function calls, and a number of tables of the information query request;

[0136] S3, when the number of operation types of the information query request is less than or equal to a preset number threshold, the pre-encrypted encrypted data is used for query, and the semi-homomorphic encryption strategy is taken as the target encryption strategy; when the number of operation types of the information query request is greater than the preset number threshold, the complexity evaluation score of the information query request is calculated according to the operation type, the nesting level, the function call times and the table number of the information query request; the current information query system resource state is detected to determine whether the current information query system resource meets the system resource required by the information query request; if yes, in the case that the complexity evaluation score of the information query request is lower than a preset score threshold, the semi-homomorphic encryption strategy is taken as the target encryption strategy, and the target encryption strategy is output; in the case that the complexity evaluation score of the information query request is greater than or equal to the preset score threshold, the full-homomorphic encryption strategy is taken as the target encryption strategy, and the target encryption strategy is output; otherwise, the semi-homomorphic encryption strategy is taken as the target encryption strategy, and the target encryption strategy is output;

[0137] S4, the encrypted query is executed under the target encryption strategy and the result is returned.

[0138] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation manners, which will not be described herein again.

[0139] In addition, in combination with the information query method provided in the above embodiments, a storage medium can also be provided to implement the information query method in this embodiment. The storage medium has a computer program stored thereon; the computer program is executed by a processor to implement any one of the information query methods in the above embodiments.

[0140] It should be understood that the specific embodiments described herein are only used to explain this application, but not to limit it. According to the embodiments provided in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor are within the scope of protection of the present application.

[0141] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties.

[0142] It is apparent that the drawings depict only some embodiments or examples of the application and are therefore not to be considered limiting of its scope, for the application can admit to other similarly effective arrangements, structures, and actions, set forth in the following claims, without the use of creative faculty and collaboration of a inventor. Further, it is intended that any incorporation by reference of the literary and / or other materials not in evidence at the time of filing be expressly excluded.

[0143] The word "comprise" and variations of the word, such as "comprising", "comprises" and "comprised", when used in this document are used to specify the presence of stated features, integers, steps or components but do not preclude the presence or addition of one or more other features, integers, steps, components, or groups thereof.

[0144] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, database or other medium used in the embodiments provided in the present 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 storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.

[0145] The above-mentioned embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the scope of patent protection. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of protection of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.

Claims

1. An information search method characterized by comprising: The method comprises the following steps: receiving an information query request; performing semantic analysis on the information query request to obtain an operation type, a nesting level, a function call number and a table number of the information query request; when the number of operation types of the information query request is less than or equal to a preset number threshold, performing query by using pre-encrypted encrypted data, and taking a semi-homomorphic encryption strategy as a target encryption strategy; when the number of operation types of the information query request is greater than the preset number threshold, calculating a complexity evaluation score of the information query request according to the operation type, the nesting level, the function call number and the table number of the information query request; detecting a current information query system resource state; judging whether the current information query system resource meets a system resource required by the information query request; if yes, taking the semi-homomorphic encryption strategy as the target encryption strategy in a case where the complexity evaluation score of the information query request is lower than a preset score threshold, and outputting the target encryption strategy; taking a full-homomorphic encryption strategy as the target encryption strategy in a case where the complexity evaluation score of the information query request is greater than or equal to the preset score threshold, and outputting the target encryption strategy; otherwise, taking the semi-homomorphic encryption strategy as the target encryption strategy, and outputting the target encryption strategy; performing encrypted query under the target encryption strategy and returning a result.

2. The information query method of claim 1, wherein, Before the semantic analysis on the information query request, the method further comprises the following steps: performing format verification and permission verification on the information query request, and performing standardized packaging on the information query request after the format verification and the permission verification are passed, so as to standardize a data structure of the information query request.

3. The information query method of claim 1, wherein, The semantic analysis comprises lexical analysis and syntax analysis, and the semantic analysis on the information query request to obtain the operation type, the nesting level, the function call number and the table number of the information query request comprises the following steps: splitting the information query request into basic units through the lexical analysis, wherein the basic units comprise keywords, identifiers, operators and constants; constructing an abstract syntax tree through the syntax analysis to obtain a syntax structure of the information query request; performing operation type analysis on each node of the abstract syntax tree to obtain each operation type of the information query request, and extracting the nesting level, the function call number and the table number of the information query request.

4. The information query method of claim 3, wherein, The operation type analysis on each node of the abstract syntax tree to obtain each operation type of the information query request comprises the following step: performing operation type classification on each node of the abstract syntax tree by using a trained query classification model to obtain each operation type of the information query request.

5. The information query method of claim 3 or claim 4, wherein, The operation types comprise addition operation, multiplication operation, function call, single-table aggregation and multi-table association operation.

6. The information query method of claim 1, wherein, Before the calculation of the complexity evaluation score of the information query request according to the operation type, the nesting level, the function call number and the table number of the information query request, the method further comprises the following steps: detecting a security level required by the information query request, When the security level required by the information query request is detected to be a preset high security level, a full homomorphic encryption strategy is taken as the target encryption strategy, and the target encryption strategy is output.

7. The information query method of claim 1, wherein, After the target encryption strategy is output, the method further includes: calculating a query time consumption of the information query request, and adjusting weights of various parameters in a complexity evaluation score formula according to the query time consumption.

8. An information inquiry apparatus characterized by comprising: comprise: a receiving module, an analyzing module, an encryption strategy selection module, and an executing module, wherein the receiving module is configured to receive an information query request; the analyzing module is configured to perform semantic analysis on the information query request to obtain an operation type, a nesting level, a function call frequency, and a table quantity of the information query request; the encryption strategy selection module is configured to, when a number of operation types of the information query request is less than or equal to a preset number threshold, perform a query by using pre-encrypted encrypted data, and take a semi-homomorphic encryption strategy as a target encryption strategy; when the number of operation types of the information query request is greater than the preset number threshold, calculate a complexity evaluation score of the information query request according to the operation type, the nesting level, the function call frequency, and the table quantity of the information query request; detect a current information query system resource state, and determine whether the current information query system resource meets a system resource required by the information query request; if yes, in a case where the complexity evaluation score of the information query request is lower than a preset score threshold, take the semi-homomorphic encryption strategy as the target encryption strategy, and output the target encryption strategy; in a case where the complexity evaluation score of the information query request is greater than or equal to the preset score threshold, take a full-homomorphic encryption strategy as the target encryption strategy, and output the target encryption strategy; otherwise, take the semi-homomorphic encryption strategy as the target encryption strategy, and output the target encryption strategy; the executing module is configured to perform an encrypted query under the target encryption strategy and return a result. 9.An electronic device comprising a memory and a processor, the electronic device characterized by, The memory stores a computer program, and the processor is configured to run the computer program to execute the information query method in any one of claims 1 to 7.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the information query method in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data circulation method, device, storage medium and terminal

    CN110516467A

  • Data processing method and device, equipment, medium and program product

    CN114580002A

  • Aggregated query method and system, electronic equipment and computer storage medium

    CN115525817A

  • Data security retrieval method based on homomorphic encryption

    CN119474479A

  • KR20250055164A