Hidden query method, readable medium, electronic device and program product
By reducing the number of ciphertext moduli through modulus switching technology, the problem of long time consumption of existing hidden queries is solved, and query efficiency is improved.
Patent Information
- Application Number
- CN202410317172.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-15
- Publication Date
- 2025-09-16
AI Technical Summary
In existing hidden query methods, the query process takes a long time, resulting in low query efficiency.
The modulus switching technology is used to reduce the number of ciphertext moduli in homomorphic encryption, and the switched ciphertext moduli are used for homomorphic calculation to reduce the time complexity.
The time of hidden query is shortened and the query efficiency is improved.
Smart Images

Figure CN120653657A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a hidden query method, a readable medium, an electronic device, and a program product. Background Art
[0002] When the querying party (such as the client) queries the queried party (such as the server) for data, the querying party sends the query content (such as keywords, etc.) to the queried party. The queried party obtains matching query results based on the query content and sends the query results to the querying party.
[0003] In order to improve the privacy of the query content and query results during the data query process, the hidden query method, or private information retrieval (PIR) method, is usually used for query. Figure 1 As shown, client 100 generates a key and encrypts the query content using the key to obtain a query ciphertext, which is then sent to server 200 via the network. After receiving the query ciphertext, server 200 performs a query based on the query ciphertext, obtains a result ciphertext, and sends the result ciphertext to client 100. After receiving the result ciphertext, client 100 decrypts the result ciphertext using the key to obtain the query result. This ensures that the query is encrypted throughout the query process, preventing the query content and corresponding query results from being accessed by the querying party, thereby enhancing the privacy of data queries.
[0004] However, if the queried party performs a query based on the query ciphertext, the process of obtaining the result ciphertext takes a long time, which will cause the data query process to take a long time, thereby reducing the query efficiency. Summary of the Invention
[0005] The purpose of this application is to provide a hidden query method, a readable medium, an electronic device and a program product.
[0006] A first aspect of the present application provides a hidden query method, which is applied to a first electronic device, including: obtaining a query request sent by a second electronic device, wherein the query request includes a first ciphertext; determining a first homomorphic parameter corresponding to the first ciphertext, wherein the first homomorphic parameter includes a first ciphertext modulus; corresponding to the first ciphertext modulus satisfying a switching condition, determining a second homomorphic parameter for modulus switching of the first ciphertext, wherein the second homomorphic parameter includes a second ciphertext modulus, and the number of modulus components of the second ciphertext modulus is less than the number of modulus components of the first ciphertext modulus; switching the first ciphertext using the second ciphertext modulus to obtain a second ciphertext; and querying a result ciphertext corresponding to the query request based on the second ciphertext.
[0007] In an embodiment of the present application, the first ciphertext may be an initial query ciphertext, the first homomorphic parameter may be an initial homomorphic parameter, the first ciphertext modulus may be an initial ciphertext modulus, the switching condition may be a condition for modulus switching of the first ciphertext modulus, the second homomorphic parameter may be a homomorphic parameter after switching, the second ciphertext modulus may be a ciphertext modulus after switching, the modulus component of the second ciphertext modulus may be a residue number system (RNS) modulus component of the ciphertext modulus after switching, the modulus component of the first ciphertext modulus may be an RNS modulus component of the initial ciphertext modulus, and the second ciphertext may be a query ciphertext after switching.
[0008] It can be understood that by reducing the number of RNS modules, the time complexity of homomorphic computation can be reduced, thereby shortening the time of the corresponding hidden query and improving the efficiency of the hidden query.
[0009] In a possible implementation of the first aspect above, the first homomorphic parameter further includes at least one of the following parameters: a modulus component of the first ciphertext modulus, a plaintext modulus, and a ring dimension of the homomorphic calculation.
[0010] In a possible implementation of the first aspect above, the switching condition includes: the first operation result obtained based on the second ciphertext and the second ciphertext modulus is the same as the second operation result obtained based on the first ciphertext and the first ciphertext modulus; and the decryption process corresponding to the operation result of the second ciphertext and the second ciphertext modulus meets the preset conditions.
[0011] In an embodiment of the present application, the switching condition may be that the operation result (as an example of the first operation result) of the switched ciphertext (as an instance of the second ciphertext) and the switched ciphertext modulus (as an example of the second ciphertext modulus) is the same as the operation result (as an example of the second operation result) of the initial ciphertext and the initial ciphertext modulus; and, the decryption result corresponding to the operation result of the switched ciphertext and the switched ciphertext modulus is correct, for example, the noise component in the decryption process is less than the noise threshold.
[0012] In a possible implementation of the first aspect above, the preset condition includes: a noise component in the decryption process is smaller than a noise threshold.
[0013] In a possible implementation of the first aspect above, based on the second ciphertext, querying the result ciphertext corresponding to the query request includes: determining a first homomorphic polynomial and a second homomorphic polynomial corresponding to the query request, wherein the first homomorphic polynomial is used to determine whether data corresponding to the query request exists in the data set corresponding to the first electronic device, and the second homomorphic polynomial is used to determine the data corresponding to the query request in the data set corresponding to the first electronic device; performing homomorphic calculations on the first homomorphic polynomial and the second homomorphic polynomial respectively to obtain a first calculated value and a second calculated value; and using the first calculated value and the second calculated value as the result ciphertext corresponding to the query request.
[0014] In a possible implementation of the first aspect above, determining a first homomorphic polynomial and a second homomorphic polynomial corresponding to a query request includes: obtaining a data set corresponding to a first electronic device, wherein the data set includes multiple keywords and data corresponding to each keyword; determining a first homomorphic polynomial corresponding to the first ciphertext based on a first ciphertext and a first ciphertext modulus, and multiple keywords; determining a first relational expression between the multiple keywords and the data corresponding to each keyword, and determining a second homomorphic polynomial corresponding to the first ciphertext based on the first homomorphic polynomial and the first relational expression.
[0015] In a possible implementation of the first aspect, homomorphic calculations are performed on the first homomorphic polynomial and the second homomorphic polynomial to obtain a first calculated value and a second calculated value, respectively. The method includes: determining multiple powers of the first ciphertext in the first homomorphic polynomial and the second homomorphic polynomial; switching the powers of the first ciphertext in the first homomorphic polynomial and the second homomorphic polynomial to powers of the second ciphertext, respectively; obtaining the first calculated value based on a sum of products of the powers of the second ciphertext and corresponding coefficients in the first homomorphic polynomial; and obtaining the second calculated value based on a sum of products of the powers of the second ciphertext and corresponding coefficients in the second homomorphic polynomial.
[0016] In the embodiment of the present application, the multiple powers of the first ciphertext in the first homomorphic polynomial and the second homomorphic polynomial can be [[y i ]], the powers of the second ciphertext can be [[y i ]]′, the product of each power of the second ciphertext and the corresponding coefficient can be pt i ·[[y i ]]′mod Q′, the sum of the products of each power of the second ciphertext and the corresponding coefficient can be
[0017] A second aspect of the present application provides a readable medium having instructions stored thereon, which, when executed on an electronic device, causes the electronic device to execute any one of the methods described in the first aspect.
[0018] The third aspect of the present application provides an electronic device, comprising a memory for storing instructions executed by one or more processors of the electronic device, and a processor, which is one of the processors of the electronic device, for executing any one of the methods in the above-mentioned first aspect.
[0019] A fourth aspect of the present application provides a program product, which includes instructions. When the instructions are executed on an electronic device, the electronic device implements any one of the methods in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0021] Figure 1 A schematic diagram of a query scenario is shown according to an embodiment of the present application;
[0022] Figure 2 According to an embodiment of the present application, a schematic diagram of homomorphic encryption is shown;
[0023] Figure 3 According to an embodiment of the present application, a schematic diagram of a query process of a hidden query based on homomorphic encryption is shown;
[0024] Figure 4 According to an embodiment of the present application, a flowchart of a hidden query method is shown;
[0025] Figure 5 According to an embodiment of the present application, a flow chart of another hidden query method is shown;
[0026] Figure 6 According to an embodiment of the present application, a structural diagram of an electronic device is shown. DETAILED DESCRIPTION
[0027] The illustrative embodiments of the present application include, but are not limited to, a hidden query method, a readable medium, an electronic device, and a program product.
[0028] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and comprehensively described below with reference to the accompanying drawings.
[0029] Before introducing the technical solutions involved in the embodiments of the present application, some of the terms included in the embodiments of the present application are explained.
[0030] Homomorphic encryption: is an encryption method that allows arithmetic computation on encrypted data.
[0031] For example, refer to Figure 2 The diagram of homomorphic encryption shown in the figure encrypts the initial plaintext data m (for example, the query content entered by the client) to obtain the ciphertext Enc(m). A specific ciphertext calculation is performed on the obtained ciphertext Enc(m) to obtain the calculation result Enc(f(m)). The calculation result Enc(f(m)) is then decrypted to obtain the plaintext f(m) (for example, the search result expected by the client). The same calculation can be performed directly on the plaintext data m to obtain the plaintext f(m). In other words, after homomorphic encryption encrypts the data and operates on the encrypted data, the calculation result obtained by decryption is equal to the calculation result obtained by performing the same operation without encrypting the data.
[0032] It can be understood that the hidden query method provided in the application embodiment is applicable to hidden query scenarios.
[0033] For example, refer to Figure 1 As shown in the schematic diagram of the query scenario, the client 100 can send a query ciphertext to the server 200 through the network, and the server 200 performs a query based on the query ciphertext and sends a result ciphertext to the client device 100.
[0034] Client 100 is a client with a hidden query function, or a querying party. Client 100 may be a client of a target application, which may be an application with a hidden query function, such as a query application, a marketing application, an identity verification application, an anti-fraud application, a financial application, a shopping application, a gaming application, a social application, an interactive entertainment application, and the like. Optionally, the target application has encryption and decryption capabilities.
[0035] The client 100 may also be a terminal with a hidden query function, such as a terminal with a target application installed. The terminal may be an electronic device such as a mobile phone, a tablet computer, a game console, a multimedia player, a personal computer (PC), a vehicle-mounted terminal, etc.
[0036] The server 200 is the party providing data, also known as the queried party. For example, the server 200 can be a server for providing data (such as marketing data, product data, financial data, knowledge data, etc.), and the server 200 can also be a third-party platform, or a backend server of a third-party platform, etc. Among them, the third-party platform can be a platform such as information query, identity verification, social networking, entertainment, shopping, games, etc., and the backend server can be a single server, or a server cluster composed of multiple servers, or a cloud computing service center. Optionally, the server 200 is provided with a database for storing the above data. The server 200 has encryption and decryption capabilities.
[0037] As previously described, the hidden query process includes: client 100 generates a key and encrypts the query content based on the key to obtain a query ciphertext, and then sends the query ciphertext to server 200. After receiving the query ciphertext, server 200 performs a query based on the query ciphertext, obtains a result ciphertext, and sends the result ciphertext to client 100. After receiving the result ciphertext, client 100 decrypts the result ciphertext based on the key to obtain the query result.
[0038] Specifically, the data stored in the database corresponding to server 200 may be stored in the form of key-value pairs, that is, a correspondence between multiple query values and result values is stored. For example, the data stored in the database corresponding to server 200 is (x1, v1), (x2, v2), (x3, v3), (x4, v4), (x5, v5). Among them, x1, x2, x3, x4, x5 are keywords, and v1, v, v3, v4, v5 are the data values corresponding to each keyword.
[0039] like Figure 3 As shown, assuming that the query content is y and y=x2, homomorphic encryption is performed to obtain the query ciphertext [[y]]. The server 200 performs a query based on the query ciphertext, and the process of obtaining the result ciphertext specifically includes:
[0040] 1. Calculate ciphertext 1 (ct1) based on the query ciphertext [[y]] and the keywords x1, x2, x3, x4, and x5 stored in the database corresponding to server 200. Specifically, ciphertext 1 can be calculated based on the difference between the query ciphertext and the keywords stored in the database. For example, reference can be made to the calculation process of polynomial F([[y]]) in the following formula (1).
[0041] ct1=F([[y]])=([[y]]-x1)*([[y]]-x2)*…*([[y]]-x5) Formula (1)
[0042] It can be understood that if the calculation result of ciphertext 1 is 0, it means that there is a difference of 0 among ([[y]]-x1), ([[y]]-x2), ..., ([[y]]-x5). In other words, there is a keyword among keywords x1, x2, x3, x4, and x5 that matches the query content corresponding to the query ciphertext. Conversely, if the calculation result of ciphertext 1 is not 0, it means that there is no keyword among keywords x1, x2, x3, x4, and x5 that matches the query content corresponding to the query ciphertext.
[0043] 2. Determine the interpolation polynomial H(x1,v1), (x2,v2), (x3,v3), (x4,v4), (x5,v5) corresponding to the data stored in the database i ), and H(x i )=v i , and based on ciphertext 1 and the interpolation polynomial, calculate ciphertext 2 (ct2). Specifically, ciphertext 2 can be calculated based on the sum of the interpolation polynomial and ciphertext 1. For example, the calculation process of polynomial G([[y]]) in the following formula (2) can be referred to.
[0044] ct2=G([[y]])=H([[y]])+rF([[y]]) Formula (2)
[0045] Among them, F([[y]])=([[y]]-x1)*([[y]]-x2)*…*([[y]]-x5), which is the polynomial corresponding to ciphertext 1; r is a random number.
[0046] It can be understood that if the calculation result of polynomial F([[y]]) is 0, it means that the data stored in the database corresponding to server 200 contains a keyword that matches the query content (x2) corresponding to the query ciphertext; then rF([[y]]) = 0, G([[y]]) = H([[y]]), and the corresponding calculation result is the result ciphertext corresponding to the query ciphertext. Client 100 decrypts the result ciphertext to obtain the query result v2 corresponding to the query content y = x2.
[0047] If the result of the polynomial F([[y]]) is not 0, it means that the data stored in the database corresponding to server 200 does not contain a keyword that matches the query content corresponding to the query ciphertext; the result of the corresponding polynomial G([[y]]) is a random number. In addition, the introduction of the random number r can prevent the leakage of data stored in the database.
[0048] Optionally, both the polynomial F([[y]]) and the polynomial G([[y]]) can be converted into the form of multi-order polynomials, for example Wherein, g is an integer greater than 1; i is an integer greater than or equal to 0 and less than or equal to g; pt iis the coefficient corresponding to the i-th term of the query content y, and pt i is plain text; [[y i ]] is the ciphertext of the query content y raised to the power of i.
[0049] The following introduces a single g-degree polynomial The calculation process includes:
[0050] Step 1: Perform homomorphic multiplication to calculate the ciphertext of all possible powers of y, that is, calculate [[y i ]], where i=0,1,…,g.
[0051] Step 2: Perform plaintext and ciphertext multiplication, that is, calculate pt i ·[[y i ]], where i=0,1,…,g.
[0052] Step 3: Perform homomorphic addition calculation to add g pt i ·[[y i ]]Add together to get the polynomial The calculation results of .
[0053] Currently, the above ciphertext 1 and ciphertext 2 are usually calculated under the residue number system (RNS). Therefore, the multi-order polynomials corresponding to ciphertext 1 and ciphertext 2 also need to be calculated under RNS. Under RNS, modular operation is usually used to convert plaintext and / or ciphertext into modular form, and then the modular plaintext and / or ciphertext are calculated to improve the data security during the calculation process. For example, to calculate pt i ·[[y i ]] Take it as an example, first determine the ciphertext modulus Q, and then convert pt i ·[[y i ]]Convert to modulus form pt i ·[[y i ]]mod Q.
[0054] However, in homomorphic encryption, the ciphertext modulus Q is usually large, such as hundreds of bits, and computers usually only support 64-bit operations. In order to better perform homomorphic calculations, the ciphertext modulus Q is usually converted into k RNS moduli, that is, let the ciphertext modulus Q = q0*q1*…q k-1 , where k is a positive integer, and q0, q1, ..., q k-1 are all prime numbers with precision less than 64 bits. In other words, [[y i ]]mod Q can be expressed as ([[y i ]]mod q0,[[y i ]]mod q1,…[[yi ]]modq k-1 ). This leads to the calculation of pt i ·[[y i ]]When mod Q, you need to calculate (pt i ·[[y i ]]mod q0,pt i ·[[y i ]]modq1,…,pt i ·[[y i ]]mod q k-1 ), that is, you need to pt i With [[y i ]]mod Q multiplies the components of each RNS together.
[0055] It can be understood that if the number of RNS moduli of the ciphertext modulus Q is greater, the time complexity of the corresponding homomorphic calculation will be greater, which may cause the corresponding hidden query to take longer.
[0056] Modulus switching, also known as modulus reduction, is a technique that converts the ciphertext modulus from a large modulus Q to a small modulus Q′ (modSwitch Q→Q′ ), while keeping the encrypted message unchanged. Under RNS, it is specifically manifested as a reduction in the number of RNS moduli, that is, Q = q0*q1*…q k-1 , Q′=q0*q1*…q k′-1 , where k and k' are both positive integers, and k' is less than k. And the ciphertext before modulus switching (ct mod R Q ) and the ciphertext after modulus switching (ct′mod R Q′ ) can be decrypted to obtain the same and correct calculation result.
[0057] For example, assuming that the ciphertext before modulus switching is ct mod R Q , the ciphertext after modulus switching is ct′mod R Q′ , for example, ct mod R Q and ct′mod R Q′ The expression of can refer to the following formula (3) and formula (4)
[0058] ct mod R Q =(a(x),b(x))mod Q Formula (3)
[0059] ct′ mod R Q′ =(a′(x),b′(x))mod Q′ Formula (4)
[0060] Among them, a(x) and b(x) are the ciphertext ct mod R before modulus switching. Q The corresponding two components, Q is the ciphertext modulus before the modulus switching; a′(x), b′(x) are the ciphertext ct′mod R after the modulus switching. Q′ The corresponding two components, Q′, are the ciphertext modulus after modulus switching.
[0061] Ciphertext ct′mod R after modulus switching Q′ The following conditions need to be met:
[0062] (1) The decryption result and the ciphertext before the modulus switching ct mod R Q For example, ct′mod R Q′ The corresponding components a′(x), b′(x) and ct mod R Q The relationship between the corresponding components a(x) and b(x) can be referred to the following formulas (5) and (6).
[0063] a′(x)=round(a(x)*Q′ / Q) Formula (5)
[0064] b′(x)=round(b(x)*Q′ / Q) Formula (6)
[0065] Among them, round() is a rounding operation.
[0066] (2) It can be correctly decrypted, that is, the noise component is smaller than the noise threshold, such as Q′ / 2P. For example, the correct decryption process can refer to the following formula (7).
[0067]
[0068] Among them, s(x) is the key, m(x) is the ciphertext calculation result, and e′(x) is the noise data.
[0069] In view of this, an embodiment of the present application provides a hidden query method. On the basis of the above method, during the query process of the above server 200, the RNS modulus corresponding to the ciphertext modulus is reduced through the modulus switching technology, that is, the number of RNS moduli corresponding to the ciphertext modulus is switched to at least one, and then calculation is performed based on the switched RNS modulus and the corresponding query ciphertext.
[0070] Specifically, it includes: obtaining a query request sent by a client, wherein the query request includes a first ciphertext; determining homomorphic parameters such as the first ciphertext modulus; corresponding to the first ciphertext modulus satisfying a switching condition, determining a second ciphertext modulus and a second ciphertext after the first ciphertext modulus and the first ciphertext are modulo-switched; determining a first homomorphic polynomial and a second homomorphic polynomial, and performing homomorphic calculations on the first homomorphic polynomial and the second homomorphic polynomial to obtain a first calculated value and a second calculated value; and sending the first calculated value and the second calculated value to the client.
[0071] It can be understood that by reducing the number of RNS modules, the time complexity of homomorphic computation can be reduced, thereby shortening the time of the corresponding hidden query and improving the efficiency of the hidden query.
[0072] For example, Figure 4 According to an embodiment of the present application, a flow chart of a hidden query method is shown. Figure 4 As shown, the process includes but is not limited to the following steps:
[0073] S401: The first electronic device obtains a query request sent by the second electronic device, where the query request includes a first ciphertext.
[0074] It can be understood that the first electronic device may be the server 200, and the second electronic device may be the client 100. The query request includes an initial query ciphertext (as an example of a first ciphertext).
[0075] S402: The first electronic device determines a first homomorphic parameter corresponding to the first ciphertext, where the first homomorphic parameter includes a first ciphertext modulus.
[0076] It can be understood that the initial homomorphic parameter (as an example of the first homomorphic parameter) includes the initial ciphertext modulus (as an example of the first ciphertext modulus).
[0077] In some embodiments, the initial ciphertext modulus may also include an RNS modulus component of the initial ciphertext modulus (as an example of a modulus component of the first ciphertext modulus), a plaintext modulus, a ring dimension of the homomorphic computation, and other parameters.
[0078] S403: Corresponding to the first ciphertext modulus satisfying the switching condition, the first electronic device determines a second homomorphic parameter for modulus switching of the first ciphertext, and switches the first ciphertext using the second ciphertext modulus to obtain a second ciphertext.
[0079] It is understood that the switching condition may be a condition for the first ciphertext modulus to perform modulus switching. In some embodiments, the switching condition may be that the operation result (as an example of the first operation result) of the switched ciphertext (as an example of the second ciphertext) and the switched ciphertext modulus (as an example of the second ciphertext modulus) is the same as the operation result (as an example of the second operation result) of the initial ciphertext and the initial ciphertext modulus; and the decryption result corresponding to the operation result of the switched ciphertext and the switched ciphertext modulus is correct, that is, the preset condition (or decryption condition) is satisfied. For example, the preset condition may be that the noise component in the decryption process is less than the noise threshold.
[0080] In some embodiments, the determination of the switched homomorphic parameters (as an instance of the second homomorphic parameters) can be: modifying the initial ciphertext modulus in the initial homomorphic parameters to the switched ciphertext modulus, and modifying the RNS modulus component of the initial ciphertext modulus in the initial homomorphic parameters to the RNS modulus component of the switched ciphertext modulus (as an instance of the modulus component of the second ciphertext modulus).
[0081] It can be understood that the number of RNS modulus components of the switched ciphertext modulus is smaller than the number of RNS modulus components of the initial ciphertext modulus.
[0082] In some embodiments, the server 200 uses the switched ciphertext modulus to switch the initial ciphertext based on the modulus switching technology to obtain the switched ciphertext.
[0083] S404: The first electronic device searches for a result ciphertext corresponding to the query request based on the first ciphertext and the second ciphertext.
[0084] In some embodiments, the server 200 determines a first homomorphic polynomial and a second homomorphic polynomial corresponding to the query request; performs homomorphic calculations on the first homomorphic polynomial and the second homomorphic polynomial respectively to obtain a first calculated value and a second calculated value; and uses the first calculated value and the second calculated value as the result ciphertext of the corresponding query request.
[0085] The first homomorphic polynomial is used to determine whether the data corresponding to the query request exists in the data set corresponding to the first electronic device, and the second homomorphic polynomial is used to determine the data corresponding to the query request in the data set corresponding to the first electronic device.
[0086] In some embodiments, the first homomorphic polynomial and the second homomorphic polynomial can be determined in the following manner: First, the data corresponding to the storage of the server 200 is obtained (as an example of the data set corresponding to the first electronic device). It can be understood that the data corresponding to the storage of the server 200 is in the form of key-value pairs, that is, the data set includes multiple keywords and data corresponding to each keyword. Then, based on the initial query ciphertext and the initial ciphertext modulus, as well as multiple keywords, the first homomorphic polynomial corresponding to the initial query ciphertext is determined; the interpolation polynomial of the multiple keywords and the data corresponding to each keyword is determined (as an example of the first relational expression), and based on the first homomorphic polynomial and the interpolation polynomial, the second homomorphic polynomial corresponding to the initial query ciphertext is determined.
[0087] For example, the first polynomial can be the polynomial F([[y]]), the second polynomial can be the polynomial G([[y]]), and the interpolation polynomial can be the interpolation polynomial H(x i ).
[0088] The specific calculation process will be described in detail below and will not be elaborated here.
[0089] In order to better understand the technical solutions of the embodiments of the present application, some technical solutions of the present application are introduced in detail below.
[0090] Figure 5 According to the embodiment of the present application, a flow chart of another hidden query method is shown. It can be understood that Figure 5 The execution body of each step of the process shown is the server 200. Figure 5 The execution entities of each step will not be described repeatedly in the steps of the process shown. Figure 5 As shown, the process includes but is not limited to the following steps:
[0091] S501: Obtain an initial query ciphertext and determine initial homomorphic parameters.
[0092] The server 200 receives the query request sent by the client 100 and determines initial homomorphic parameters. The query request includes the initial query ciphertext; the initial homomorphic parameters include but are not limited to the initial ciphertext modulus, the plaintext modulus, and the RNS modulus corresponding to the initial ciphertext modulus.
[0093] In some embodiments, the initial query ciphertext may be encrypted by the client 100 based on the query content input by the user. The encryption process may specifically include: first, determining the key s(x), for example, from the ternary distribution {-1,0,1} / X N +1, where N is the ring R Q(ciphertext domain) corresponds to the ring dimension. Then, the message (such as query content) m(x) is encrypted based on the key. For example, randomly from the ring R Q Select parameter a(x), determine noise polynomial e(x) based on Gaussian parameter σ, and calculate the noise polynomial e(x) in the loop R based on key s(x), parameter a(x), and noise polynomial e(x). Q Calculate parameter b(x). It can be understood that parameters a(x) and b(x) are two components corresponding to the initial query ciphertext, and the initial query ciphertext can be expressed as (a(x), b(x)). For example, the calculation of b(x) can refer to the following formula (8).
[0094] b(x)=a(x)s(x)+Q / Pm(x)+e(x)mod R Q Formula (8)
[0095] S502: Determine whether the number of RNS moduli corresponding to the initial ciphertext modulus is greater than a quantity threshold.
[0096] Server 200 determines the number of RNS moduli corresponding to the initial ciphertext modulus. If the number is greater than a threshold, it indicates that the time complexity of the corresponding plaintext and ciphertext multiplication is high and needs to be processed to reduce the time complexity. It will be understood that the embodiment of the present application uses a threshold of 1 as an example. In other embodiments, the threshold may also be 2, 3, 4, 5, etc., and the present application does not impose any specific limitation on this.
[0097] In some embodiments, if the judgment result is yes, it means that the time complexity of the corresponding plaintext and ciphertext multiplication is high and further processing is required, then step S503 is executed to determine whether it can be correctly decrypted after the number of RNS moduli corresponding to the initial ciphertext modulus is reduced to j through the modulus switching technology.
[0098] In other embodiments, if the judgment result is no, it means that the time complexity of the corresponding plaintext and ciphertext multiplication is low, and no processing is required, and homomorphic ciphertext calculation is performed directly to query the target data, then step S505 is executed to query based on the initial query ciphertext and the initial homomorphic parameters.
[0099] S503: Determine whether correct decryption is possible after reducing the number of RNS moduli corresponding to the initial ciphertext modulus to j through the modulus switching technology.
[0100] The server 200 determines whether it can correctly decrypt after reducing the number of RNS moduli corresponding to the initial ciphertext modulus to j through the modulus switching technology, where j is a positive integer smaller than the number of RNS moduli corresponding to the initial ciphertext modulus.
[0101] In some embodiments, if the judgment result is yes, it means that the decryption can be correct after the number of RNS moduli is reduced to j, that is, the noise meets the decryption conditions, then step S504 is executed, and during the data query process, the number of RNS moduli corresponding to the initial ciphertext modulus is switched to j, and data query is performed based on the switched query ciphertext and the switched homomorphic parameters.
[0102] In other embodiments, if the judgment result is no, it means that after the number of RNS moduli is reduced to j, it cannot be correctly decrypted, that is, the noise does not meet the decryption conditions (for example, exceeds the noise threshold), then step S505 is executed to query based on the initial query ciphertext and the initial homomorphic parameters.
[0103] It can be understood that in some embodiments, j can be a value preset by the server 200, such as 1, 2, 3, 4, 5, etc.
[0104] In other embodiments, j may also be the minimum value among the number of RNS moduli that can be correctly decrypted. For example, the number of RNS moduli corresponding to the initial ciphertext modulus is L. The server 200 may first determine whether it can be correctly decrypted after the number of RNS moduli corresponding to the initial ciphertext modulus is reduced to 1; if it can be correctly decrypted, the value of j is 1; if it cannot be correctly decrypted, it is further determined whether it can be correctly decrypted after the number of RNS moduli corresponding to the initial ciphertext modulus is reduced to 2; if it can be correctly decrypted, the value of j is 2; if it cannot be correctly decrypted, the judgment is continued until the number of RNS moduli corresponding to the initial ciphertext modulus is reduced to L-1. Wherein, L is an integer greater than 1, and j is a positive integer less than L. In other embodiments, j may also be the maximum value among the number of RNS moduli that can be correctly decrypted, or j may be any value among the number of RNS moduli that can be correctly decrypted, and so on. This application does not make any specific limitation on this.
[0105] Exemplarily, if the noise polynomial e(x) before the modulus switching obeys a Gaussian distribution with a parameter σ, the relationship between the components a′(x) and b′(x) corresponding to the ciphertext after the modulus switching and the components a(x) and b(x) corresponding to the ciphertext before the modulus switching can be referred to the following formulas (9) and (10).
[0106]
[0107]
[0108] Among them, a(x), b(x) are the components corresponding to the initial ciphertext; q k′ *…*q k-1 is the ratio of the initial ciphertext modulus Q to the switched ciphertext modulus Q′; r a (x), rb (x) is the rounding error when the above formula (5) and formula (6) are rounded off, and the coefficients are in the interval It can be regarded as obeying the parameter Gaussian distribution.
[0109] For example, the noise polynomial e′(x) after analog-to-digital switching can refer to the following formula (11), and the noise distribution parameter σ′ of the noise polynomial e′(x) can refer to the following formula (12).
[0110]
[0111]
[0112] It can be understood that the decryption condition corresponding to the switched ciphertext is that the noise component is less than the noise threshold, for example, Q′ / 2P. For example, the decryption condition can refer to the following formula (13).
[0113]
[0114] S504: During the data query process, the number of RNS moduli corresponding to the initial ciphertext modulus is switched to j, and data query is performed based on the switched query ciphertext and the switched homomorphic parameters.
[0115] Corresponding to the situation where correct decryption can be achieved after the number of RNS moduli corresponding to the initial ciphertext modulus is reduced to j through the modulus switching technology, the server 200 switches the number of RNS moduli corresponding to the initial ciphertext modulus to j during the data query process, and performs data query based on the switched query ciphertext and homomorphic parameters. If the number of RNS moduli corresponding to the initial ciphertext modulus is L, where L is a positive integer greater than 1, then j is a positive integer less than L.
[0116] It can be understood that, as mentioned above, the main body of the hidden query process based on homomorphic encryption is the process of calculating homomorphic polynomials. Exemplarily, the server 200 determines a first homomorphic polynomial and a second homomorphic polynomial, and performs homomorphic calculations on the first homomorphic polynomial and the second homomorphic polynomial respectively to obtain a first calculated value and a second calculated value. Among them, the first homomorphic polynomial can be the polynomial corresponding to the above formula (1), and the second homomorphic polynomial can be the polynomial corresponding to the above formula (2). The decryption result of the first calculated value identifies whether the target information exists in the data corresponding to the query request; and the decryption result corresponding to the first calculated value is that the target information exists, and the decryption result of the second calculated value is the target information corresponding to the query request.
[0117] The following is still a single g-degree polynomial The calculation process of the homomorphic polynomial is introduced as an example. The number of RNS moduli corresponding to the initial ciphertext modulus is switched to j, and data query is performed based on the query ciphertext and homomorphic parameters after switching, including:
[0118] Step 1: Perform homomorphic multiplication to calculate the ciphertext of all possible powers of y, that is, calculate [[y i ]], where i=0,1,…,g.
[0119] Step 2: Use the modulus switching technology to reduce the number of RNS moduli corresponding to the initial ciphertext modulus to j. That is, if the initial ciphertext modulus Q = q0*q1*…q L-1 , then the switched ciphertext modulus Q′=q0*q1*…q j-1 Where L is an integer greater than 1, and j is a positive integer less than L. The query ciphertext after switching [[y i The determination of ]]′ can refer to the calculation of the above formula (9) and formula (10).
[0120] Step 3: Perform plaintext and ciphertext multiplication, that is, calculate pt i ·[[y i ]]′mod Q′, where i=0,1,…,g.
[0121] It can be understood that compared with using the initial ciphertext modulus Q for plaintext multiplication, the plaintext coefficient pt i No need to [[y i ]]mod Q's L RNS components are multiplied by [[y i ]]′mod Q′ is multiplied by the components of the j RNS. In particular, corresponding to the case of j=1, the plaintext coefficient pt i Just directly with [[y i ]]′mod Q′. This can shorten the time for calculating the plaintext and ciphertext multiplication, thereby increasing the time for calculating the homomorphic polynomial, thereby shortening the time for the corresponding hidden query and improving the efficiency of the hidden query.
[0122] Step 4: Perform homomorphic addition calculation to add g pt i ·[[y i ]]′mod Q′ and add them together to get the polynomial The calculation results of .
[0123] It can be understood that first calculating the ciphertext of all possible powers of y, and then using the modulus switching technology to reduce the number of RNS moduli corresponding to the initial ciphertext modulus to j, can avoid the increase of noise caused by the modulus switching, which affects [[y i ]], which results in the result being unable to be decrypted correctly.
[0124] S505: Perform data query based on the initial query ciphertext and the initial homomorphic parameters.
[0125] Corresponding to the situation where correct decryption cannot be performed after the number of RNS moduli corresponding to the initial ciphertext modulus is reduced to j by the modulus switching technology, the server 200 performs a query based on the initial query ciphertext and the initial homomorphic parameters.
[0126] The following is still a single g-degree polynomial The calculation process of homomorphic polynomials is introduced as an example. The query based on the initial query ciphertext and the initial homomorphic parameters includes:
[0127] Step 1: Perform homomorphic multiplication to calculate the ciphertext of all possible powers of y, that is, calculate [[y i ]], where i=0,1,…,g.
[0128] Step 2: Perform plaintext and ciphertext multiplication, that is, calculate pt i ·[[y i ]]mod Q, where i=0,1,…,g.
[0129] Step 3: Perform homomorphic addition calculation to add g pt i ·[[y i ]]mod Q add, get the polynomial The calculation results of .
[0130] S506: Output the ciphertext result corresponding to the data query.
[0131] The server 200 sends the result ciphertext of the data query based on the switched query ciphertext and homomorphic parameters and / or the result ciphertext of the query based on the initial query ciphertext and initial homomorphic parameters to the client 100. After receiving the result ciphertext, the client 100 can decrypt the result ciphertext based on the key to obtain the query result.
[0132] Exemplarily, the process of the client 100 decrypting the result ciphertext based on the key may refer to the following formula (14) and formula (15).
[0133] b(x)-a(x)s(x)=m′(x)=Q / Pm(x)+e′(x)mod R Q Formula (14)
[0134] round((m'(x)P) / Q)=round(m(x)+e'(x)P / Q)=m(x) Formula (15)
[0135] Wherein, round() indicates rounding to the nearest integer. It can be understood that if the value of each component of the noise e′(x) in the decryption process is less than the noise threshold (for example, Q / 2P), then the decryption can be performed correctly.
[0136] It is understood that in other embodiments, according to actual needs, the above Figure 5 The steps shown can be combined, deleted or replaced with other steps that are conducive to achieving the purpose of this application. For example, the above step S504 can be split into two steps. This application does not limit this.
[0137] Optionally, in some other embodiments, the server 200 may not execute the above Figure 5 That is, after the server 200 obtains the initial query ciphertext and the initial homomorphic parameters, it is not necessary to determine whether the number of RNS moduli corresponding to the initial ciphertext modulus is greater than the quantity threshold, and step S503 can be directly executed to determine whether correct decryption can be performed after reducing the number of RNS moduli corresponding to the initial ciphertext modulus through the modulus switching technology.
[0138] In summary, the hidden query method provided in this application can reduce the time complexity of homomorphic calculation by reducing the number of RNS modules, thereby shortening the time of the corresponding hidden query and improving the efficiency of the hidden query.
[0139] It can be understood that the above embodiment only illustrates the example of querying one query result based on one query content. The hidden query method provided in the embodiment of the present application can also be used for batch query, that is, querying multiple query results based on multiple query contents. This application does not impose any restrictions on this.
[0140] The following describes the effect of the hidden query method provided in the embodiment of the present application on reducing the time complexity of homomorphic computing with reference to specific examples.
[0141] Example 1
[0142] Assume that the number of data entries (eg, key-value pairs) stored in the database corresponding to the server 200 is one million, and the client 100 queries one of the entries, the number of bytes of the returned query result (label) may be one of 16, 32, 64, 128, and 256.
[0143] The plaintext modulus P is 65537, the ring dimension N is 8192, and the RNS modulus corresponding to the initial ciphertext modulus Q is {56, 48, 48}.
[0144] Based on the hidden query method provided in the embodiment of the present application, the query time after switching the initial ciphertext modulus Q to an RNS modulus {56} through the modulus switching technology and the query time directly based on the initial ciphertext modulus Q can be compared with the query time. Please refer to Table 1.
[0145] Illustratively, Table 1 shows a query time comparison table for one query per million according to an embodiment of the present application.
[0146] Table 1 Comparison of query times for one query per million
[0147] Result Bytes Number of threads Original online time (ms) Online time after optimization (ms) Original time / optimized time 16 24 482 351 1.38 32 24 577 406 1.42 64 24 821 489 1.68 128 24 1195 675 1.77 256 24 2146 1063 2.02
[0148] As shown in Table 1, when the number of result bytes is 16 and the number of threads during calculation is 24, the original online time (i.e., the query time based directly on the initial ciphertext modulus Q) is 482 milliseconds (ms), and the optimized online time (i.e., the query time after switching the initial ciphertext modulus Q to an RNS modulus {56} through the modulus switching technology) is 351 ms. The ratio of the original time to the optimized time is 1.38.
[0149] For the case where the number of result bytes is 32 and the number of threads during calculation is 24, the original online time is 577ms, and the optimized online time is 406ms. The ratio of the original time to the optimized time is 1.42.
[0150] For the case where the number of result bytes is 64 and the number of threads during calculation is 24, the original online time is 821ms, and the optimized online time is 489ms. The ratio of the original time to the optimized time is 1.68.
[0151] For a result with 128 bytes and 24 threads during calculation, the original online time is 1195ms, while the optimized online time is 675ms. The ratio of the original time to the optimized time is 1.77.
[0152] For a result with 256 bytes and 24 threads during calculation, the original online time is 2146ms, and the optimized online time is 1063ms. The ratio of the original time to the optimized time is 2.02.
[0153] It can be understood that, corresponding to the scenario of a single query content, switching the initial ciphertext modulus Q to an RNS modulus through the modulus switching technology and then querying (performing homomorphic plaintext and ciphertext multiplication) is compared to directly querying based on the initial ciphertext modulus Q. The number of result bytes is improved by 1.38 times, 1.42 times, 1.68 times, 1.77 times, and 2.02 times respectively.
[0154] Example 2
[0155] Assume that the number of data entries (eg, key-value pairs) stored in the database corresponding to the server 200 is one million, and the client 100 batch queries 4096 entries, the number of bytes of the returned query result (label) may be one of 16, 32, 64, 128, and 256.
[0156] The plaintext modulus P is 65537, the ring dimension N is 8192, and the RNS modulus corresponding to the initial ciphertext modulus Q is {56, 48, 48}.
[0157] Based on the hidden query method provided in the embodiment of the present application, the query time after switching the initial ciphertext modulus Q to an RNS modulus {56} through the modulus switching technology and the query time directly based on the initial ciphertext modulus Q can be compared with the query time. Please refer to Table 2.
[0158] Illustratively, Table 2 shows a query time comparison table for 4096 queries out of a million according to an embodiment of the present application.
[0159] Table 2. Comparison of query times for 4096 queries per million
[0160] Result Bytes Number of threads Original online time (ms) Online time after optimization (ms) Original time / optimized time 16 24 1425 1288 1.16 32 24 1578 1244 1.27 64 24 1754 1389 1.26 128 24 2625 1636 1.60 256 24 3454 2232 1.55
[0161] As shown in Table 2, when the number of result bytes is 16 and the number of threads during calculation is 24, the original online time is 1425ms, the optimized online time is 1288ms, and the ratio of the original time to the optimized time is 1.16.
[0162] For the case where the number of result bytes is 32 and the number of threads during calculation is 24, the original online time is 1578ms, and the optimized online time is 1244ms. The ratio of the original time to the optimized time is 1.27.
[0163] For a result with 64 bytes and 24 threads during calculation, the original online time is 1754ms, and the optimized online time is 1389ms. The ratio of the original time to the optimized time is 1.26.
[0164] For a result with 128 bytes and 24 threads during calculation, the original online time is 2625ms, and the optimized online time is 1636ms. The ratio of the original time to the optimized time is 1.60.
[0165] For a result with 256 bytes and 24 threads during calculation, the original online time is 3454ms, and the optimized online time is 2232ms. The ratio of the original time to the optimized time is 1.55.
[0166] It can be understood that, corresponding to the scenario of single query content, switching the initial ciphertext modulus Q to an RNS modulus through the modulus switching technology and then querying (performing homomorphic plaintext and ciphertext multiplication) is compared to directly querying based on the initial ciphertext modulus Q. The number of result bytes is improved by 1.16 times, 1.27 times, 1.26 times, 1.60 times, and 1.55 times respectively.
[0167] It can be understood that compared with the scenario in Example 1, the scenario in Example 2 is a batch query scenario, and the hidden query method provided in the embodiment of the present application can also achieve optimization of the batch query scenario.
[0168] Example 3
[0169] Assume that the number of data entries (eg, key-value pairs) stored in the database corresponding to the server 200 is 100,000, and the client 100 queries one of the entries. The number of bytes of the returned query result (label) may be one of 16, 32, 64, 128, and 256.
[0170] The plaintext modulus P is 65537, the ring dimension N is 4096, and the RNS modulus corresponding to the initial ciphertext modulus Q is {56, 29, 24}.
[0171] Based on the hidden query method provided in the embodiment of the present application, the query time after switching the initial ciphertext modulus Q to an RNS modulus {56} through the modulus switching technology and the query time directly based on the initial ciphertext modulus Q can be compared with the query time. Please refer to Table 3.
[0172] Illustratively, Table 3 shows a query time comparison table for one out of ten thousand queries according to an embodiment of the present application.
[0173] Table 3 Comparison of query time for one query per 100,000 queries
[0174] Result Bytes Number of threads Original online time (ms) Online time after optimization (ms) Original time / optimized time 16 24 80 47 1.70 32 24 106 55 1.93 64 24 103 65 1.58 128 24 144 85 1.69 256 24 274 137 2.00
[0175] As shown in Table 3, when the number of result bytes is 16 and the number of threads during calculation is 24, the original online time is 80ms, and the optimized online time is 47ms. The ratio of the original time to the optimized time is 1.70.
[0176] For the case where the number of result bytes is 32 and the number of threads during calculation is 24, the original online time is 106ms, and the optimized online time is 55ms. The ratio of the original time to the optimized time is 1.93.
[0177] For a result with 64 bytes and 24 threads during calculation, the original online time is 103ms, while the optimized online time is 65ms. The ratio of the original time to the optimized time is 1.58.
[0178] For a result with 128 bytes and 24 threads during calculation, the original online time is 144ms, while the optimized online time is 85ms. The ratio of the original time to the optimized time is 1.69.
[0179] For a result with 256 bytes and 24 threads, the original online time is 274ms, while the optimized online time is 137ms. The ratio of the original time to the optimized time is 2.00.
[0180] It can be understood that, corresponding to the scenario of a single query content, switching the initial ciphertext modulus Q to an RNS modulus through the modulus switching technology and then querying (performing homomorphic plaintext and ciphertext multiplication) is compared to directly querying based on the initial ciphertext modulus Q. The number of result bytes is improved by 1.70 times, 1.93 times, 1.58 times, 1.69 times, and 2.00 times respectively.
[0181] It can be understood that compared with the scenario in Example 1, the amount of data stored in the database in the scenario in Example 3 and the homomorphic parameters are different from those in Example 1. The hidden query method provided in the embodiment of the present application can also achieve optimization of the scenario and has strong generalization.
[0182] In order to better understand the technical solutions of the embodiments of the present application, the structure of the electronic device involved in the present application is introduced below with reference to the accompanying drawings.
[0183] For example, Figure 6 According to an embodiment of the present application, a schematic diagram of the structure of an electronic device 600 is shown. The electronic device 600 can be any electronic device with data calculation, processing and storage functions, and the electronic device 600 can be used to implement the hidden query method provided in the embodiment of the present application. For example, the electronic device 600 can be Figure 1 Server 200 is shown.
[0184] Specifically, if Figure 6As shown, electronic device 600 includes a central processing unit (such as a central processing unit (CPU), a graphics processing unit (GPU), and a field programmable gate array (FPGA)) 601, a system memory 604 including a random-access memory (RAM) 602 and a read-only memory (ROM) 603, and a system bus 605 connecting system memory 604 and central processing unit 601. The electronic device 600 also includes a basic input / output system (I / O system) 606 that helps transmit information between various components in the server, and a large-capacity storage device 607 for storing an operating system 613, application programs 614, and other program modules 615.
[0185] In some embodiments, the basic input / output system 606 includes a display 608 for displaying information and an input device 609, such as a mouse or keyboard, for user input. The display 608 and the input device 609 are both connected to the central processing unit 601 via an input / output controller 610 connected to the system bus 605. The basic input / output system 606 may also include an input / output controller 610 for receiving and processing input from a variety of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 610 also provides output to a display screen, printer, or other types of output devices.
[0186] The mass storage device 607 is connected to the central processing unit 601 through a mass storage controller (not shown) connected to the system bus 505. The mass storage device 607 and its associated computer-readable media provide non-volatile storage for the server 600. That is, the mass storage device 607 may include a computer-readable medium (not shown) such as a hard disk or a compact disc read-only memory (CD-ROM) drive.
[0187] Without loss of generality, computer-readable media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other solid-state storage technology, CD-ROM, high-density digital video disc (DVD) or other optical storage, tape cassettes, magnetic tape, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that computer storage media are not limited to the above-mentioned ones. The above-mentioned system memory 604 and mass storage device 607 can be collectively referred to as memory.
[0188] According to various embodiments of the present application, the electronic device 600 can also be connected to a remote computer on a network via a network such as the Internet. That is, the electronic device 600 can be connected to the network 612 via the network interface unit 611 connected to the system bus 605, or the network interface unit 611 can be used to connect to other types of networks or remote computer systems (not shown).
[0189] The memory further includes one or more computer programs, one or more computer programs stored in the memory, and one or more computer programs including instructions for performing the hidden query method provided in the embodiments of the present application. In some embodiments, when the computer program is executed by the processor, it implements the above-mentioned hidden query method.
[0190] Optionally, the computer-readable storage medium may include: ROM, RAM, solid state drives (SSD) or optical disks, etc. Among them, the random access memory may include resistance random access memory (ReRAM) and dynamic random access memory (DRAM).
[0191] In some embodiments, a computer program product or computer program is also provided. The computer program product or computer program includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the hidden query method provided in this application.
[0192] The various embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.
[0193] Program code can be applied to input instructions to perform the functions described herein and generate output information. The output information can be applied to one or more output devices in a known manner. For purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.
[0194] Program code can be implemented with a high-level programming language or an object-oriented programming language to communicate with the processing system. Where necessary, program code can also be implemented in assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any particular programming language. In either case, the language can be a compiled language or an interpreted language.
[0195] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or through other computer-readable media. Therefore, a machine-readable medium may include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, including but not limited to a floppy disk, an optical disk, an optical disk, a magneto-optical disk, a read-only memory (ROM), a random access memory (RAM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic card or an optical card, a flash memory, or a tangible machine-readable memory for transmitting information (e.g., a carrier wave, an infrared signal, a digital signal, etc.) using the Internet in an electrical, optical, acoustic, or other form of propagation signal. Accordingly, machine-readable media includes any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a form readable by a machine (eg, a computer).
[0196] In the accompanying drawings, some structural or method features may be shown in a particular arrangement and / or order. However, it should be understood that such a particular arrangement and / or order may not be required. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of a structural or method feature in a particular figure does not imply that such feature is required in all embodiments, and in some embodiments, such features may not be included or may be combined with other features.
[0197] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems raised by this application. In addition, in order to highlight the innovative part of this application, the above-mentioned device embodiments of this application do not introduce units / modules that are not closely related to solving the technical problems raised by this application. This does not mean that other units / modules do not exist in the above-mentioned device embodiments.
[0198] It should be noted that in the examples and description of this patent, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes 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 "including a" does not exclude the presence of other identical elements in the process, method, article or device that includes the element.
[0199] Although the present application has been shown and described with reference to certain preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the application.
Claims
1. A hidden query method, characterized in that: Applicable to a first electronic device, comprising: Obtaining a query request sent by the second electronic device, wherein the query request includes the first ciphertext; Determining a first homomorphic parameter corresponding to the first ciphertext, where the first homomorphic parameter includes a first ciphertext modulus; determining, in response to the first ciphertext modulus satisfying a switching condition, a second homomorphic parameter for modulus switching of the first ciphertext, wherein the second homomorphic parameter includes a second ciphertext modulus, and the number of modulus components of the second ciphertext modulus is less than the number of modulus components of the first ciphertext modulus; Switching the first ciphertext using the second ciphertext modulus to obtain a second ciphertext; Based on the second ciphertext, a result ciphertext corresponding to the query request is queried.
2. The method according to claim 1, characterized in that The first homomorphic parameter further includes at least one parameter of the following: The modulus component of the first ciphertext modulus, the plaintext modulus, and the ring dimension of the homomorphic computation.
3. The method according to any one of claims 1-2, characterized in that The switching conditions include: A first operation result obtained based on the second ciphertext and the second ciphertext modulus is the same as a second operation result obtained based on the first ciphertext and the first ciphertext modulus; and A decryption process corresponding to a calculation result of the second ciphertext and the second ciphertext modulus satisfies a preset condition.
4. The method according to claim 3, characterized in that The preset conditions include: The noise component in the decryption process is smaller than a noise threshold.
5. The method according to claim 1, wherein The querying, based on the second ciphertext, for a result ciphertext corresponding to the query request includes: Determining a first homomorphic polynomial and a second homomorphic polynomial corresponding to the query request, wherein the first homomorphic polynomial is used to determine whether data corresponding to the query request exists in the data set corresponding to the first electronic device, and the second homomorphic polynomial is used to determine data corresponding to the query request in the data set corresponding to the first electronic device; Performing homomorphic calculations on the first homomorphic polynomial and the second homomorphic polynomial respectively to obtain a first calculated value and a second calculated value; The first calculated value and the second calculated value are used as result ciphertext corresponding to the query request.
6. The method according to claim 5, characterized in that The determining of the first homomorphic polynomial and the second homomorphic polynomial corresponding to the query request includes: Acquire a data set corresponding to the first electronic device, wherein the data set includes a plurality of keywords and data corresponding to each of the keywords; Determining a first homomorphic polynomial corresponding to the first ciphertext based on the first ciphertext, the first ciphertext modulus, and the plurality of keywords; A first relational expression between the plurality of keywords and data corresponding to each of the keywords is determined, and a second homomorphic polynomial corresponding to the first ciphertext is determined based on the first homomorphic polynomial and the first relational expression.
7. The method according to claim 5, characterized in that The performing homomorphic calculation on the first homomorphic polynomial and the second homomorphic polynomial respectively to obtain a first calculated value and a second calculated value includes: determining a plurality of powers of the first ciphertext in the first homomorphic polynomial and the second homomorphic polynomial; Switching powers of the first ciphertext in the first homomorphic polynomial and the second homomorphic polynomial to powers of the second ciphertext, respectively; Obtaining a first calculated value based on the sum of products of each power of the second ciphertext and the corresponding coefficient in the first homomorphic polynomial; and A second calculated value is obtained based on the sum of products of each power of the second ciphertext and corresponding coefficients in the second homomorphic polynomial.
8. A readable medium, characterized in that The readable medium stores instructions, which, when executed on an electronic device, enable the electronic device to execute the method according to any one of claims 1 to 7.
9. An electronic device, characterized in that: include: a memory for storing instructions to be executed by one or more processors of the electronic device, and The processor is one of the processors of an electronic device, and is configured to execute the method according to any one of claims 1 to 7.
10. A program product, characterized in that The program product includes instructions, and when the instructions are executed on an electronic device, the electronic device implements the method according to any one of claims 1 to 7.