Data processing method, device, electronic device and medium
By introducing a database proxy device between the application service device and the database, the dense data in the database is directly calculated, and the problem of inefficient processing of sensitive data in the prior art is solved, and efficient query and stability of dense data is achieved.
Patent Information
- Application Number
- CN202411782562.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-04-04
AI Technical Summary
In the prior art, when processing sensitive data, it is necessary to encrypt and decrypt it on the application server, resulting in inefficient processing of sensitive data.
A database proxy device is introduced between the application service device and the database. The proxy device assists the application server to perform query operations on the confidential data in the database and directly calculates the confidential data without decryption. Finally, the confidential query result is returned to the application service device.
With the assistance of the database proxy, the query efficiency and stability of dense data can be improved without affecting the original business logic of the application server and the original database functions.
Smart Images

Figure CN119759963A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud security technology, and in particular to a data processing method, device, electronic device and medium. Background Art
[0002] After the original data is encrypted using traditional encryption technology, the obtained secret data will lose its original semantic features, making it difficult to perform calculations directly on the secret data. In order to calculate the secret data, the secret data can only be decrypted first, and then calculated based on the plain text. In addition, the existing method of encrypting sensitive data is mainly to encrypt it on the application server side. This encryption and decryption method will cause significant changes to the code and is highly invasive. At the same time, it is affected by the encryption and decryption interface, which can easily lead to inefficient sensitive data processing. Summary of the invention
[0003] To this end, the present application provides a data processing method, device, electronic device and medium to solve the problem of low efficiency in sensitive data processing caused by the need to encrypt and decrypt sensitive data on the application server side when processing sensitive data in the prior art.
[0004] In order to achieve the above-mentioned purpose, the first aspect of the present application provides a data processing method, which is applied to a database proxy device. The method includes: receiving a data operation request sent by an application service device; parsing the data operation request to obtain a parsing result; generating a first operation request based on the data operation request when the parsing result indicates that the data operation request is a selection query request for a sensitive data field; sending the first operation request to a database; receiving confidential data returned by the database in response to the first operation request; performing a corresponding query operation on the confidential data according to the parsing result to obtain a confidential query result; sending the confidential query result to the application service device, so that the application service device decrypts the confidential query result based on a pre-stored private key to obtain a corresponding plaintext query result.
[0005] According to the first aspect, the method also includes: when the parsing result indicates that the data operation request is a change request for a sensitive data field, encrypting the target change data based on a pre-stored first key and public key to generate a corresponding ciphertext; the change request includes a data insertion request or a data update request; based on the ciphertext and the data operation request, generating a second operation request; sending the second operation request to the database, so that the database responds to the second operation request and performs a corresponding data change operation based on the ciphertext.
[0006] According to the first aspect, the data operation request is parsed to obtain the parsing result, including: determining the request type of the data operation request, the request type is any one of a selection query request, a data insertion request or a data update request; extracting key information according to the request type of the operation request, the key information includes target change data or an aggregate function; based on the pre-configured sensitive data field, determining whether the data operation request is an operation on a sensitive data field.
[0007] According to the first aspect, or any implementation method of the first aspect above, the parsing result includes an aggregation function; according to the parsing result, a corresponding query operation is performed on the confidential data to obtain a confidential query result, including: when the aggregation function indicates a sum operation, an addition operation of a homomorphic encryption algorithm is performed on the confidential data to obtain the sum of the confidential data as the confidential query result; or, when the aggregation function indicates a subtraction operation, a multiplication operation of a homomorphic encryption algorithm is performed on the inverse elements of the first data and the second data in the confidential data to obtain the difference between the confidential data as the confidential query result; or, when the aggregation function indicates a maximum value operation, a multiplication operation of a homomorphic encryption algorithm is performed on the confidential data. A maximum value operation is performed to take the maximum value in the confidential data as the confidential query result; or, when the aggregation function indicates a minimum value operation, a minimum value operation is performed on the confidential data to take the minimum value in the confidential data as the confidential query result; or, when the aggregation function indicates an equal value judgment operation, the confidential data is compared with the target encrypted data, and the comparison result is taken as the confidential query result; the target encrypted data is data encrypted by an order-preserving encryption algorithm for the plaintext parameters in the data operation request; or, when the aggregation function indicates a range search operation, data in the confidential data that is smaller than or larger than the target encrypted data is taken as the confidential query result.
[0008] According to the first aspect, or any implementation method of the first aspect above, the target change data is encrypted based on the pre-stored first key and public key to generate corresponding ciphertext, including: based on the homomorphic encryption algorithm and the public key, the target change data is encrypted to obtain a first encryption result; based on the order-preserving encryption algorithm and the first key, the target change data is encrypted to obtain a second encryption result; the first encryption result and the second encryption result are concatenated to obtain a ciphertext.
[0009] According to the first aspect, or any implementation of the first aspect above, before receiving a data operation request sent by an application service device, the method also includes: receiving and storing a first key and a public key generated by the application service device; encrypting the user's plaintext privacy data based on the first key and the public key to generate corresponding secret data; and storing the secret data in a database.
[0010] According to a second aspect of the present application, there is provided a database proxy device, which includes: a first receiving module, which is used to receive a data operation request sent by an application service device; a SQL parsing module, which parses the data operation request to obtain a parsing result; a SQL rewriting module, which is used to generate a first operation request based on the data operation request when the parsing result indicates that the data operation request is a selection query request for a sensitive data field; a first sending module, which sends the first operation request to a database; a second receiving module, which receives confidential data returned by the database in response to the first operation request; a confidential data calculation module, which is used to perform a corresponding query operation on the confidential data according to the parsing result to obtain a confidential query result; and a second sending module, which sends the confidential query result to the application service device, so that the application service device decrypts the confidential query result based on a pre-stored private key to obtain a corresponding plaintext query result.
[0011] A third aspect of the present application provides a data processing system, which includes: an application service device, a database and a database proxy device of the second aspect; the application service device accesses the database through the database proxy device.
[0012] The fourth aspect of the present application provides an electronic device, which includes: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by one or more processors, the one or more processors implement any one of the methods in the first aspect; one or more I / O interfaces, connected between the processor and the memory, configured to implement information interaction between the processor and the memory.
[0013] A fifth aspect of the present application provides a computer-readable medium having a computer program stored thereon, which implements any one of the methods in the first aspect when the program is executed by a processor.
[0014] The present application has the following advantages: The present application embodiment provides a data processing method, which is executed by a database proxy device added between an application service device and a database, and can ensure that the original business logic of the application service end and the original function of the database are not affected while processing the access request of the application service device to the data in the database. In the data processing method, the database proxy assists the application service end in executing the query operation on the confidential data in the database. During the query process, the database proxy can directly calculate the confidential data without decrypting the confidential data, and finally return the confidential query result to the application service device, which can effectively improve the query efficiency and stability for the confidential data. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings are used to provide further understanding of the present application and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present application, but do not constitute a limitation to the present application.
[0016] Figure 1 A flowchart of a data processing method provided in an embodiment of the present application;
[0017] Figure 2 A flowchart of another data processing method provided in an embodiment of the present application;
[0018] Figure 3 A schematic diagram of the structure of a database proxy device provided in an embodiment of the present application;
[0019] Figure 4 A schematic diagram of the structure of a data processing system provided in an embodiment of the present application;
[0020] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0022] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0023] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0024] The terms used in this application are only used to describe specific embodiments and are not intended to limit the present application.As used in this application, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0025] When the terms “comprising” and / or “made of…” are used in this application, it specifies the existence of the stated features, integers, steps, operations, elements and / or components, but does not exclude the existence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0026] The embodiments described in the present application may be described with reference to plan views and / or cross-sectional views by means of ideal schematic diagrams of the present application. Therefore, the exemplary illustrations may be modified according to manufacturing techniques and / or tolerances.
[0027] Unless otherwise defined, all terms (including technical and scientific terms) used in this application have the same meaning as those commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this application, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined in this application.
[0028] After the original data is encrypted using traditional encryption technology, the obtained secret data will lose its original semantic features, making it difficult to perform calculation operations directly on the secret data, and it is impossible to perform queries such as SUM, MAX, AVG, and range on the stored secret data. To implement these queries, it is necessary to decrypt it on the application server and then perform operations based on the plain text, which increases a lot of communication overhead.
[0029] In addition, the existing method of encrypting sensitive data is mainly to encrypt it on the application server side. This encryption and decryption method will cause major changes to the code and is highly invasive to the code. At the same time, it is necessary to call the encryption and decryption interface, and the communication overhead is large and unstable, which can easily lead to inefficient sensitive data processing.
[0030] To this end, the present application adds a database proxy between the application server and the database, and the database proxy executes the data processing method provided by the embodiment of the present application. The process does not require modification of the code of the application server, ensuring that the original business logic (insert, update and query logic) of the application server is not affected, and the existing functions of the database are not affected. In the data processing method, the database proxy assists the application server in executing the query operation on the confidential data in the database. During the query process, the database proxy can directly calculate the confidential data and return the calculation results to the application server without decrypting the confidential data, thereby improving the efficiency and stability of the query of the confidential data.
[0031] Figure 1 A flow chart of a data processing method provided in an embodiment of the present application. The data processing method is applied to a database proxy device in a data processing system. The data processing system also includes an application service device and a database, wherein the application service device is used to process tasks such as front-end business logic and user requests, and the database is responsible for storing and managing data. The database proxy device is located in the middle layer between the application service device and the database, and is used to proxy all requests from the application service device to access the database. In an embodiment of the present application, by introducing a database proxy device, developers can more easily manage the communication between the application service device and the database, thereby improving the availability and performance of the cloud system. Figure 1 As shown, the data processing method includes: the following steps S101 to S106.
[0032] Step S101: The database proxy device receives a data operation request sent by the application service device.
[0033] The data operation request is a Structured Query Language (SQL) request, which is used to request to perform a corresponding operation on the data in the database. The type of the data operation request is any one of a select query (SELECT) request, a data update (UPDATE) request, and a data insert (INSERT) request.
[0034] In the embodiment of the present application, before the database proxy device receives the data operation request sent by the application service device, the application service device generates a hash value for the security parameter using a hash algorithm, and intercepts n bits of the hash value to generate a first key; then, a public-private key generation algorithm of a homomorphic encryption algorithm is used to generate a public key and a private key. The application service device stores the private key, and the database proxy device receives and stores the first key and public key generated by the application service device.
[0035] When sensitive data needs to be stored, the database proxy device encrypts the user's plaintext privacy data based on the first key and the public key, generates corresponding secret data, and then stores the secret data in the database. As a result, the database stores data that supports the operation of the application service device, and the sensitive data in the data is stored in the database in an encrypted state.
[0036] In the embodiment of the present application, the database proxy device encrypts the user's plaintext privacy data based on the first key and the public key to generate corresponding encrypted data, including: the user's plaintext privacy data is [x1, x2, ..., x n ], for each plaintext private data x of the user i , based on the homomorphic encryption algorithm Enc1 and the public key pk, the plaintext privacy data x i Encryption is performed to obtain the third encryption result Xa=Enc1(pk,x i ), and, based on the order-preserving encryption algorithm Enc2 and the first key k, the plaintext privacy data x i Encryption is performed to obtain the fourth encryption result Xb=Enc2(k,x i ); then concatenate Xa and Xb to obtain X = (Xa||Xb), and use X as x i The ciphertext is stored. Among them, the fourth encryption result Enc2(k,x i )=(x i +k)modN, where N is the modulus used for encryption.
[0037] It can be understood that encrypting the stored sensitive data using the aforementioned encryption method allows calculations to be performed on the encrypted data, and the results of the calculations are consistent with the results of the same calculations performed on the plain text after decryption.
[0038] In one embodiment, before the database proxy device receives the data operation request sent by the application service device, the data processing method further includes: receiving configuration information for the sensitive data field.
[0039] In the embodiments of the present application, users can flexibly add and modify fields related to privacy data to better meet various needs and business scenarios.
[0040] Step S102: The database proxy device analyzes the data operation request to obtain an analysis result.
[0041] The parsing result includes at least: the type of data operation request and whether it is an operation request for a sensitive data field.
[0042] In one embodiment, parsing the data operation request to obtain the parsing result includes: the following steps 1 to 3.
[0043] Step 1: Determine the request type of the data operation request, where the request type is any one of a selection query request, a data insertion request, or a data update request.
[0044] Step 2: Extract key information according to the request type of the operation request, where the key information includes target change data or aggregate function.
[0045] In the embodiment of the present application, when the type of the data operation request is a SELECT request, the parsing result also includes an aggregation function. The aggregation function is used to explain how to perform calculation operations on the queried confidential data, and the aggregation function is any one of the following functions: an equivalence judgment function, a range search function, a sum function SUM(), an average function AVG(), a maximum function MAX(), and a minimum function MIN(), etc.
[0046] It can be understood that the aggregation function is not limited to the aforementioned functions exemplified in the embodiments of the present application. In actual applications, other aggregation functions can be configured in the SELECT request.
[0047] In an embodiment of the present application, when the type of the data operation request is a selection query request and a data update request, the parsing result also includes target change data, which is plaintext data to be used for insertion or plaintext data to be used for update.
[0048] It should be noted that in conventional data processing methods, when the target change data is sensitive data, the application service device needs to call an encryption interface, encrypt the target change data, and send it to the database so that the database performs corresponding operations. In the embodiment of the present application, regardless of whether the target change data is sensitive data, the application service device does not need to perform encryption operations on the target change data, but directly includes the plain text in the data operation request to send it to the database proxy device, and the database proxy device performs subsequent operations.
[0049] Step 3: Based on the pre-configured sensitive data fields, determine whether the data operation request is for an operation on a sensitive data field.
[0050] Step S103: When the analysis result indicates that the data operation request is a selection query request for a sensitive data field, the database proxy device generates a first operation request based on the data operation request.
[0051] It is understandable that, when the parsing result indicates that the data operation request is a selection query request for a sensitive data field, the data operation request also includes an aggregation function. Therefore, the data operation request needs to be rewritten.
[0052] In an embodiment of the present application, the database proxy device generates a first operation request based on the data operation request. The first operation request is also an SQL request. Compared with the data operation request, the first operation request excludes the aggregation function. That is, the first operation request is only used to obtain all the confidential data required for this query operation from the database.
[0053] Step S104: The database proxy device sends the first operation request to the database.
[0054] In the embodiment of the present application, after receiving the first operation request, the database queries the corresponding confidential data and sends the confidential data to the database proxy device.
[0055] Step S105: The database proxy device receives the confidential data returned by the database in response to the first operation request.
[0056] Step S106: The database proxy device performs a corresponding query operation on the confidential data according to the analysis result to obtain a confidential query result.
[0057] The parsing result includes an aggregation function.
[0058] In an embodiment of the present application, after the database proxy device receives the confidential data returned by the CNC library, it performs corresponding query operations on the confidential data according to the aggregation function in the parsing result to obtain the confidential query result.
[0059] It should be noted that in the embodiment of the present application, the secret data stored in the database allows calculations to be performed on the encrypted data, and the calculation results are consistent with the results of the same calculations performed on the plain text after decryption. Therefore, the database proxy device does not need to decrypt the secret data before calculation, but directly calculates the secret data, and the secret query results obtained are also encrypted information.
[0060] Step S107: The database proxy device sends the encrypted query result to the application service device, so that the application service device decrypts the encrypted query result based on the pre-stored private key to obtain the corresponding plaintext query result.
[0061] The embodiment of the present application provides a data processing method, which is executed by a database proxy device added between an application service device and a database, and can ensure that the original business logic of the application service end and the original function of the database are not affected, while processing the query request of the application service device for the data in the database. In the data processing method, the database proxy assists the application service end in executing the query operation on the confidential data in the database. During the query process, the database proxy can directly calculate the confidential data without decrypting the confidential data, and finally return the confidential query result to the application service device, which can effectively improve the query efficiency and stability for the confidential data.
[0062] In the embodiment of the present application, the analysis result includes an aggregation function. The above-mentioned performing a corresponding query operation on the confidential data according to the analysis result to obtain the confidential query result (the above-mentioned step S106) includes: any one of the following steps a to f.
[0063] Step a: When the aggregation function indicates a sum operation, perform an addition operation of the homomorphic encryption algorithm on the secret data to take the sum of the secret data as the secret query result.
[0064] For example, when there are two secret data, the two secret data X1 and X2 are added using the homomorphic encryption algorithm to obtain X=Add(X1+X2), and the secret result X is returned as the secret query result.
[0065] For another example, based on the SUM operation to sum two data, multiple confidential data can be summed up, and the sum result can be used as the confidential query result.
[0066] It is understandable that if the aggregation function indicates an average operation, multiple data can be summed first, and then the average value is calculated by querying the database to obtain the number of data items, thereby realizing the AVG operation of multiple confidential data.
[0067] Step b: When the aggregation function indicates a subtraction operation, a multiplication operation of the homomorphic encryption algorithm is performed on the inverse elements of the first data and the second data in the secret data, so as to use the difference between the secret data as the secret query result.
[0068] For example, two secret data X1 and X2 are subtracted, and the difference between the two secret data is obtained by multiplication using the homomorphic encryption algorithm: X = Add(X1+(X2) -1 ), where (X2) -1 It is the inverse element of X2.
[0069] Step c: when the aggregation function indicates a maximum value operation, perform a maximum value operation on the confidential data to take the maximum value in the confidential data as the confidential query result.
[0070] For example, compare two encrypted data X1 and X2 using the order-preserving encryption scheme. If X1>X2, it means that the size relationship between the plaintext x1 corresponding to X1 and the plaintext x2 corresponding to X2 is x1>x2, and return X1, otherwise return X2. For multiple data, you can perform MAX operations on each of them, and then get the maximum value of multiple encrypted data.
[0071] Step d: When the aggregation function indicates a minimum operation, a minimum operation is performed on the confidential data to take the minimum value in the confidential data as the confidential query result.
[0072] For example, compare two encrypted data X1 and X2 using the order-preserving encryption scheme. If X1<X2, then the relationship between the plaintext x1 corresponding to X1 and the plaintext x2 corresponding to X2 is x1<x2, and X1 is returned. Otherwise, X2 is returned. For multiple data, the MIN operation can be performed on each of them, and then the minimum value of multiple encrypted data can be obtained.
[0073] Step e: when the aggregation function indicates an equal value judgment operation, the confidential data is compared with the target encrypted data, and the comparison result is used as the confidential query result.
[0074] The target encrypted data is data encrypted using an order-preserving encryption algorithm for a plaintext parameter in a data operation request. The plaintext parameter is a parameter value in an aggregation function and is used to indicate a query range.
[0075] For example, if you need to determine whether the plaintext x corresponding to the secret data X that has been encrypted in an order-preserving manner is equal to the plaintext parameter n, first execute the order-preserving encryption algorithm on the plaintext parameter n to obtain the secret value N that has been encrypted in an order-preserving algorithm, and compare X and N. If X=N, then x=n, and return true, otherwise return false.
[0076] Step f: When the aggregation function indicates a range search operation, the data in the confidential data that is smaller than or larger than the target encrypted data is used as the confidential query result.
[0077] For example, in the secret data {X1,X2,..,X n}, first perform the order-preserving encryption algorithm on the plaintext parameter n to obtain the secret value N after the order-preserving encryption algorithm, and initialize a List to store the search results, and then put the secret data {X1,X2,..,X n Each data X in n Perform the MAX operation with N. If the MAX operation returns X n Then X n Add to List, and finally return List, which is the search result of the range greater than the plaintext parameter n. Similarly, in the secret data {X1,X2,..,X n} to search for all data less than the plaintext parameter n. The MIN operation can be performed on all encrypted data to obtain a range search result less than the plaintext parameter n.
[0078] In the embodiment of the present application, the database proxy device does not need to decrypt the secret data, and can complete the calculation of the secret data using the public key. The database proxy device implements MAX, MIN, AVG, SUM, =, and range queries based on the calculation scheme of the secret data, thereby improving the efficiency and stability of the query of the secret data.
[0079] Above Figure 1 In the data processing method provided, the case where the data operation request is a select query request for a sensitive data field is described. The data operation request may also be a data insertion request or a data update request. Therefore, the embodiment of the present application provides another data processing method to describe the case where the data operation request is a data insertion request or a data update request.
[0080] Figure 2 A flowchart of another data processing method provided in an embodiment of the present application. Figure 2 After the database proxy device parses the data operation request and obtains the parsing result (the above step S102), the method further includes: steps S108-S110.
[0081] Step S108: When the parsing result indicates that the data operation request is a request to modify a sensitive data field, the database proxy device encrypts the target modified data based on the pre-stored first key and public key to generate corresponding ciphertext.
[0082] The change request includes a data insertion request or a data update request. The target change data is plain text data to be inserted or plain text data to be updated.
[0083] In an optional implementation provided in an embodiment of the present application, the database proxy device encrypts the target change data based on a pre-stored first key and a public key to generate corresponding ciphertext, including: the following steps 1 to 3.
[0084] Step 1: Based on the homomorphic encryption algorithm and the public key, encrypt the target change data to obtain a first encryption result.
[0085] Among them, the process of encrypting the target change data based on the homomorphic encryption algorithm and the public key is similar to the process of encrypting the user's plaintext privacy data based on the homomorphic encryption algorithm in the aforementioned step. Therefore, the specific steps of encrypting the target change data based on the homomorphic encryption algorithm and the public key to obtain the first encryption result can be found in the aforementioned detailed description and will not be repeated here.
[0086] Step 2: Encrypt the target change data based on the order-preserving encryption algorithm and the first key to obtain a second encryption result.
[0087] Among them, the process of encrypting the target change data based on the order-preserving encryption algorithm and the first key is similar to the process of encrypting the user's plaintext privacy data based on the order-preserving encryption algorithm in the aforementioned step. Therefore, the specific steps of encrypting the target change data based on the order-preserving encryption algorithm and the first key to obtain the second encryption result can be found in the aforementioned detailed description and will not be repeated here.
[0088] Step 3: Concatenate the first encryption result and the second encryption result to obtain a ciphertext.
[0089] In an embodiment of the present application, when the application service device needs to change the data in the database, there is no need to encrypt the target changed data on the application service device side. Instead, the encryption operation is performed on the database proxy device side, which can effectively reduce the communication overhead on the application service device side.
[0090] Step S109: The database proxy device generates a second operation request based on the ciphertext and the data operation request.
[0091] The second operation request includes the ciphertext and also includes an insert request or an update request.
[0092] Step S110: The database proxy device sends the second operation request to the database, so that the database responds to the second operation request and performs a corresponding data modification operation based on the ciphertext.
[0093] In one implementation, after the database receives the second operation request, if the second operation request is an update request, the database performs an update operation based on the ciphertext in the second operation request.
[0094] In another embodiment, after the database receives the second operation request, when the second operation request is an insert request, the database performs an insert operation based on the ciphertext in the second operation request.
[0095] The embodiment of the present application provides another data processing method, which is executed by a database proxy device added between the application service device and the database, and can ensure that the original business logic of the application service end and the original function of the database are not affected while processing the access insertion or update request of the application service device to the data in the database. In this data processing method, the database proxy assists the application service end in performing the change operation on the confidential data in the database. During the change process, the database proxy encrypts the target change data (plain text) and then sends the encrypted ciphertext to the database so that the database performs the corresponding change operation, which can effectively improve the stability of the change to the confidential data.
[0096] It should be noted that in an embodiment of the present application, when the parsing result indicates that the data operation request is an operation request (query, insert or update) for a non-sensitive data field, the database proxy device directly sends the data operation request to the database so that the database performs the corresponding operation.
[0097] The step division of the above methods is only for clear description. When implemented, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this application; adding insignificant modifications to the algorithm or process or introducing insignificant designs without changing the core design of the algorithm and process are all within the scope of protection of this application.
[0098] In a second aspect, an embodiment of the present application provides a database proxy device.
[0099] Figure 3 A schematic diagram of the structure of a database proxy device provided in an embodiment of the present application. Figure 3 As shown, the database proxy device includes: a first receiving module 31, an SQL parsing module 32, an SQL rewriting module 33, a first sending module 34, a second receiving module 35, a secret data calculation module 36, and a second sending module 37.
[0100] The first receiving module 31 is used to receive a data operation request sent by an application service device.
[0101] The SQL parsing module 32 parses the data operation request to obtain a parsing result.
[0102] The SQL rewriting module 33 is configured to generate a first operation request based on the data operation request when the parsing result indicates that the data operation request is a selection query request for a sensitive data field.
[0103] The first sending module 34 sends the first operation request to the database.
[0104] The second receiving module 35 receives the confidential data returned by the database in response to the first operation request.
[0105] The secret data calculation module 36 is used to perform corresponding query operations on the secret data according to the analysis results to obtain secret query results.
[0106] The second sending module 37 sends the encrypted query result to the application service device, so that the application service device decrypts the encrypted query result based on the pre-stored private key to obtain the corresponding plaintext query result.
[0107] In the embodiment of the present application, the database proxy device also includes a first configuration module, which is used to configure information such as encryption fields, secret keys (the aforementioned first secret key and public key).
[0108] The embodiment of the present application provides a database proxy device, which is located between the application service device and the database, and can process the access request of the application service device to the data in the database without affecting the original business logic of the application service end and the original function of the database. In the process of assisting the application service end in executing the query operation on the confidential data in the database, the database proxy can directly calculate the confidential data without decrypting the confidential data, and finally return the confidential query result to the application service device, which can effectively improve the query efficiency and stability for the confidential data.
[0109] It should be noted that the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. For example, the above-mentioned SQL rewriting module, the first sending module, the second sending module, the first receiving module and the second receiving module may together constitute a logic processing module in the CNC library proxy device, which is used to rewrite SQL based on SQL parsing results and configuration information, send new SQL to the database end, and after obtaining the SQL query results, call the calculation module according to SQL to perform different calculation operations on confidential data, and finally return the confidential query results to the application server.
[0110] It should be clear that the present application is not limited to the specific configurations and processes described in the above embodiments and shown in the figures. For the convenience and brevity of description, a detailed description of the known methods is omitted here, and the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, which will not be repeated here.
[0111] In a third aspect, an embodiment of the present application provides a data processing system. Figure 4 A schematic diagram of the structure of a data processing system provided in an embodiment of the present application. Figure 4 As shown, the system includes: an application service device 41, a database proxy device 42 and a database 43. The application service device accesses the database through the database proxy device.
[0112] The application service device 41 is responsible for key generation, query request generation, key configuration and decryption of secret data. The application service device 41 includes three modules, namely a key generation module 411, a decryption module 412 and a second configuration module 413.
[0113] The key generation module 411 is responsible for the generation of the key, which refers to the first key and the public key and private key in the aforementioned data processing method. The generation process of the key can refer to the detailed description in the aforementioned data processing method, which will not be repeated here.
[0114] The decryption module 412 is responsible for decrypting the encrypted data returned by the proxy service device to obtain plaintext data.
[0115] The second configuration module 413 is responsible for storing key information, such as storing a generated private key.
[0116] The database proxy device 42 includes: an SQL parsing module 421 , a first configuration module 422 , an encryption module 423 , a secret data calculation module 424 , and a logic processing module 425 .
[0117] Among them, the SQL parsing module 421 is used to parse the SQL request and obtain the parsed data; the first configuration module 422 is used to configure encryption fields, keys and other information; the encryption module 423 is used to encrypt privacy data; the confidential data calculation module 424 is used to calculate confidential data and complete related calculations for searches such as MAX, MIN, AVG, SUM, =, range, etc.; the logic processing module 425 rewrites the SQL based on the SQL parsing results and configuration information, sends a new SQL to the database side, and after obtaining the SQL query results, calls the calculation module according to the SQL to perform different confidential data calculation operations, and finally returns the confidential query results to the application server.
[0118] The numerical control library 43 is responsible for executing the SQL request sent by the database agent and returning the result.
[0119] An embodiment of the present application provides a data processing system, which includes: an application service device, a database proxy device and a database. The system executes a database proxy device added between the application service device and the database, which can ensure that the application service device's access request to the data in the database is processed without affecting the original business logic of the application server and the original function of the database. The database proxy device is responsible for parsing the SQL of the application server and performing different operations according to the parsed SQL. For INSERT operations, the privacy data is encrypted; for SELECT queries, different confidential data calculation operations are performed according to different keywords such as MAX, MIN, AVG, SUM, and finally the query is completed and the result is returned. The core confidential data calculation function realizes that only the public key is required to perform calculations on confidential data without decryption, which reduces communication overhead and improves the stability and efficiency of confidential data queries.
[0120] It should be clear that the present application is not limited to the specific configurations and processes described in the above embodiments and shown in the figures. For the convenience and brevity of description, a detailed description of the known methods is omitted here, and the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, which will not be repeated here.
[0121] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 5 The electronic device includes: one or more processors 501; a memory 502, on which one or more programs are stored. When the one or more programs are executed by one or more processors, the one or more processors implement any of the above-mentioned data processing methods; one or more I / O interfaces 503, connected between the processor and the memory, and configured to realize information interaction between the processor and the memory.
[0122] Among them, the processor 501 is a device with data processing capabilities, including but not limited to a central processing unit (CPU); the memory 502 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface (read-write interface) 503 is connected between the processor 501 and the memory 502, and can realize information interaction between the processor 501 and the memory 502, including but not limited to a data bus (Bus), etc.
[0123] In some embodiments, the processor 501, the memory 502, and the I / O interface 503 are connected to each other through a bus, and further connected to other components of the computing device.
[0124] This embodiment also provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the data processing method provided by this embodiment is implemented. To avoid repeated description, the specific steps of the data processing method are not repeated here.
[0125] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the invented method described above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0126] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0127] Those skilled in the art will understand that although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features from different embodiments is meant to be within the scope of the present embodiment and to form different embodiments.
[0128] It is to be understood that the above embodiments are merely exemplary embodiments used to illustrate the principles of the present application, but the present application is not limited thereto. For those skilled in the art, various modifications and improvements can be made without departing from the spirit and substance of the present application, and these modifications and improvements are also considered to be within the scope of protection of the present application.
Claims
1. A data processing method, characterized in that: The method is applied to a database proxy device; the method comprises: receiving a data operation request sent by an application service device; Parsing the data operation request to obtain a parsing result; In a case where the parsing result indicates that the data operation request is a selection query request for a sensitive data field, generating a first operation request based on the data operation request; Sending the first operation request to a database; Receiving confidential data returned by the database in response to the first operation request; According to the analysis result, a corresponding query operation is performed on the confidential data to obtain a confidential query result; The encrypted query result is sent to the application service device, so that the application service device decrypts the encrypted query result based on a pre-stored private key to obtain a corresponding plaintext query result.
2. The method according to claim 1, characterized in that The method further comprises: In the case where the parsing result indicates that the data operation request is a change request for a sensitive data field, encrypting the target change data based on the pre-stored first key and public key to generate corresponding ciphertext; the change request includes a data insertion request or a data update request; Generate a second operation request based on the ciphertext and the data operation request; The second operation request is sent to a database, so that the database performs a corresponding data modification operation based on the ciphertext in response to the second operation request.
3. The method according to claim 1, characterized in that The step of parsing the data operation request to obtain a parsing result includes: Determine a request type of the data operation request, where the request type is any one of a selection query request, a data insertion request, or a data update request; extracting key information according to a request type of the operation request, where the key information includes target change data or an aggregate function; Based on a pre-configured sensitive data field, it is determined whether the data operation request is to operate on the sensitive data field.
4. The method according to claim 3, characterized in that The analysis result includes an aggregation function; and performing a corresponding query operation on the confidential data according to the analysis result to obtain a confidential query result, including: When the aggregation function indicates a sum operation, performing an addition operation of a homomorphic encryption algorithm on the secret data, so as to use the sum of the secret data as the secret query result; Alternatively, when the aggregation function indicates a subtraction operation, a multiplication operation of a homomorphic encryption algorithm is performed on the inverse elements of the first data and the second data in the secret data, so as to use the difference between the secret data as the secret query result; Alternatively, when the aggregation function indicates a maximum value operation, a maximum value operation is performed on the secret state data to take the maximum value in the secret state data as the secret state query result; Alternatively, when the aggregation function indicates a minimum operation, a minimum operation is performed on the secret state data, so as to take the minimum value in the secret state data as the secret state query result; Alternatively, when the aggregation function indicates an equal value judgment operation, the secret state data is compared with the target encrypted data, and the comparison result is used as the secret state query result; the target encrypted data is the data encrypted by the order-preserving encryption algorithm using the plaintext parameters in the data operation request; Alternatively, when the aggregation function indicates a range search operation, data in the secret data that is smaller than or larger than the target encrypted data is used as the secret query result.
5. The method according to claim 2, characterized in that: Based on the pre-stored first key and public key, the target change data is encrypted to generate corresponding ciphertext, including: Based on the homomorphic encryption algorithm and the public key, encrypt the target change data to obtain a first encryption result; Encrypting the target change data based on an order-preserving encryption algorithm and the first key to obtain a second encryption result; The first encryption result and the second encryption result are concatenated to obtain the ciphertext.
6. The method according to claim 1, characterized in that Before receiving the data operation request sent by the application service device, the method further includes: Receiving and storing a first key and a public key generated by an application service device; Based on the first key and the public key, encrypt the user's plaintext privacy data to generate corresponding encrypted data; The secret data is stored in a database.
7. A database proxy device, characterized in that: The device comprises: A first receiving module, used to receive a data operation request sent by an application service device; SQL parsing module, parses the data operation request to obtain parsing results; A SQL rewriting module, configured to generate a first operation request based on the data operation request when the parsing result indicates that the data operation request is a selection query request for a sensitive data field; A first sending module, sending the first operation request to a database; A second receiving module receives the confidential data returned by the database in response to the first operation request; A secret data calculation module, used to perform a corresponding query operation on the secret data according to the analysis result to obtain a secret query result; The second sending module sends the encrypted query result to the application service device, so that the application service device decrypts the encrypted query result based on a pre-stored private key to obtain a corresponding plaintext query result.
8. A data processing system, characterized in that: The system comprises: an application service device, a database and a database proxy device as claimed in claim 7; The application service device accesses the database through the database proxy device.
9. An electronic device, characterized in that: include: one or more processors; A storage device having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6; One or more I / O interfaces are connected between the processor and the memory and are configured to implement information interaction between the processor and the memory.
10. A computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method according to any one of claims 1 to 6.