Vector retrieval method and apparatus for protecting data privacy
By performing rotation operations and homomorphic encryption on the query vector and candidate vectors, the problem of high computational and communication volume in privacy vector retrieval is solved, achieving efficient data privacy protection and result acquisition.
Patent Information
- Application Number
- CN202311008506.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-10
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2043-08-10
AI Technical Summary
Existing privacy vector retrieval technologies struggle to effectively reduce computational and communication loads while satisfying the privacy requirements of both parties, resulting in low retrieval efficiency.
By performing rotation operations and homomorphic encryption on the query vector and candidate vectors, a ciphertext set is generated. Homomorphic operations are then performed to calculate the similarity, and finally, decryption is performed to obtain the similarity information, thus avoiding the direct transmission of plaintext information.
It significantly improves computing and communication efficiency, protects the data privacy of both the querying party and the queried party, and ensures that the querying party only obtains information related to the query results.
Smart Images

Figure CN117093621B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] One or more embodiments of the present specification relate to the technical field of data security, and in particular to a vector retrieval method and device for protecting data privacy, a computer-readable storage medium, and a computing device. BACKGROUND
[0002] Privacy vector retrieval assumes that a querying party has a query vector, and a queried party holds a vector database composed of multiple vectors. The purpose of privacy vector retrieval is to enable the querying party to obtain the retrieval result of the query vector in the vector database under the premise of meeting the privacy requirements of both parties. The privacy requirements of both parties are as follows: the queried party cannot perceive the content and result of the query; the querying party cannot perceive information irrelevant to the query result.
[0003] Privacy vector retrieval is widely used in business scenarios such as biological authentication and multi-party risk control. For example, in the biological authentication scenario, the client queries the server whether the biological characteristics such as the collected face and fingerprint belong to a certain person. For another example, in the multi-party risk control scenario, the bank queries whether the face and certificate number information of the user in other banks are consistent, or whether the user is on the blacklist of other banks.
[0004] However, the current implementation of privacy vector retrieval is difficult to meet the higher requirements in actual applications. Therefore, the embodiments of the present specification propose a privacy vector retrieval scheme, which can effectively reduce the amount of calculation and communication while protecting data privacy, and significantly improve the calculation and communication efficiency. SUMMARY
[0005] The embodiments of the present specification describe a vector retrieval method and device for protecting data privacy, which can effectively improve the calculation and communication efficiency.
[0006] According to a first aspect, a vector retrieval method for protecting data privacy is provided, comprising:
[0007] The first party performs a plurality of rotation operations based on a target vector to be searched to obtain a plurality of first rotated vectors, and performs homomorphic encryption on vectors composed of elements at the same position in the plurality of first rotated vectors respectively to obtain a first ciphertext set; the homomorphic encryption includes encoding processing and encryption processing based on the encoding result. The first party sends the first ciphertext set and a similarity threshold to a second party, and the second party performs rotation operations based on a plurality of candidate vectors respectively in advance to obtain a plurality of second rotated vectors corresponding to the candidate vectors, and performs the encoding processing on vectors composed of elements at the same position in the plurality of second rotated vectors respectively to obtain a second encoding set. The second party performs homomorphic operations based on the first ciphertext set, the similarity threshold and the second encoding set to obtain a search result ciphertext. The first party performs homomorphic decryption on the received search result ciphertext to obtain a search result plaintext indicating whether the similarity between each candidate vector and the target vector is greater than the similarity threshold.
[0008] In one embodiment, the second party performs homomorphic operations based on the first ciphertext set, the similarity threshold and the second encoding set to obtain a search result ciphertext, including: performing first homomorphic operations on the first ciphertext set and the second encoding set to obtain a similarity vector ciphertext; performing second homomorphic operations based on the similarity vector ciphertext and the similarity threshold to obtain the search result ciphertext.
[0009] Further, in a specific embodiment, the first homomorphic operations include: for each first ciphertext in the first ciphertext set, performing homomorphic plaintext-ciphertext multiplication operations on the first ciphertext with a second encoding corresponding to the first ciphertext in the second encoding set to obtain a corresponding product ciphertext; performing homomorphic ciphertext addition operations on all product ciphertexts to obtain the similarity vector ciphertext.
[0010] On the other hand, in a specific embodiment, the second homomorphic operations include: performing the encoding processing on the inverse of the similarity threshold to obtain a threshold encoding; determining the search result ciphertext based on a sum ciphertext obtained by performing homomorphic ciphertext addition operations on the similarity vector ciphertext and the threshold encoding.
[0011] In one example, determining the search result ciphertext includes: generating a random vector composed of positive real elements; performing the encoding processing on the random vector to obtain a random vector encoding; performing homomorphic plaintext-ciphertext multiplication operations on the sum ciphertext and the random vector encoding to obtain the search result ciphertext.
[0012] In an embodiment, the first party performs a plurality of rotation operations on a target vector to be retrieved to obtain a plurality of first rotated vectors, including: converting the target vector into a low-dimensional first complex vector, and performing a plurality of rotation operations on the first complex vector to obtain the plurality of first rotated vectors. Wherein the second party performs a rotation operation on a plurality of candidate vectors in advance to obtain a plurality of corresponding second rotated vectors, including: converting the plurality of candidate vectors into a plurality of low-dimensional second complex vectors, and performing a rotation operation on each of the second complex vectors to obtain the plurality of second rotated vectors. Wherein the method further includes: extracting a plurality of real parts from the retrieval result plaintext, and determining whether the similarity between each candidate vector and the target vector is greater than the similarity threshold based on the sign of each real part.
[0013] In an embodiment, the second encoding set is a plurality, and the second party obtains a plurality of second encoding sets in advance, including: dividing the plurality of candidate vectors into a plurality of groups, performing a rotation operation on each vector in each group to obtain a group of rotated vectors corresponding to the candidate vectors in the group, and performing the encoding processing on vectors composed of elements at the same position in the group of rotated vectors to obtain a second encoding set corresponding to the candidate vectors in the group. Wherein the second party performs homomorphic operations on the first ciphertext set, the similarity threshold, and the second encoding set to obtain retrieval result ciphertext, including: the second party performs homomorphic operations on each of the plurality of second encoding sets based on the first ciphertext set and the similarity threshold to obtain a plurality of retrieval result ciphertexts.
[0014] In an embodiment, the first party performs homomorphic decryption on the received retrieval result ciphertext to obtain retrieval result plaintext, including: performing decryption processing corresponding to the encryption processing on the retrieval result ciphertext to obtain retrieval result encoding; and performing decoding processing corresponding to the encoding processing on the retrieval result encoding to obtain the retrieval result plaintext.
[0015] In an embodiment, the target vector is a biological feature vector of a target user, and the plurality of candidate vectors are a plurality of biological feature vectors of a plurality of candidate users.
[0016] According to a second aspect, a vector retrieval method for protecting data privacy is provided, applied to a first party, including:
[0017] Performing a plurality of rotation operations based on the target vector to be searched to obtain a plurality of first rotation vectors, and performing homomorphic encryption on vectors composed of elements at the same position in the plurality of first rotation vectors respectively to obtain a first ciphertext set; the homomorphic encryption includes encoding processing and encryption processing based on the encoding result. The first ciphertext set and a similarity threshold value are sent to a second party, the second party performs a rotation operation on a plurality of candidate vectors respectively in advance to obtain a plurality of second rotation vectors corresponding thereto, and performs the encoding processing on vectors composed of elements at the same position in the plurality of second rotation vectors respectively to obtain a second encoding set. A search result ciphertext is received from the second party, the search result ciphertext is obtained based on homomorphic operation of the first ciphertext set, the similarity threshold value and the second encoding set. The search result ciphertext is homomorphically decrypted to obtain a search result plaintext, which indicates whether the similarity between each candidate vector and the target vector is greater than the similarity threshold value.
[0018] According to a third aspect, a vector search method for protecting data privacy is provided, applied to a second party, comprising:
[0019] A first ciphertext set and a similarity threshold value are received from a first party, the first ciphertext set is obtained by performing a plurality of rotation operations based on a target vector to be searched to obtain a plurality of first rotation vectors, and then performing homomorphic encryption on vectors composed of elements at the same position in the plurality of first rotation vectors respectively; the homomorphic encryption includes encoding processing and encryption processing based on the encoding result. A second encoding set is read, which is determined in advance based on the following steps: performing a rotation operation on a plurality of candidate vectors respectively to obtain a plurality of second rotation vectors corresponding thereto, and performing the encoding processing on vectors composed of elements at the same position in the plurality of second rotation vectors respectively to obtain the second encoding set. Homomorphic operation is performed based on the first ciphertext set, the similarity threshold value and the second encoding set to obtain a search result ciphertext. The search result ciphertext is sent to the first party, so that the first party homomorphically decrypts the search result ciphertext to obtain a search result plaintext, which indicates whether the similarity between each candidate vector and the target vector is greater than the similarity threshold value.
[0020] According to a fourth aspect, there is provided a vector retrieval system for protecting data privacy, comprising a first party and a second party. The first party is configured to perform a plurality of rotation operations based on a target vector to be retrieved to obtain a plurality of first rotated vectors, and perform homomorphic encryption on vectors composed of elements at the same position in the plurality of first rotated vectors respectively to obtain a first ciphertext set. The homomorphic encryption comprises encoding processing and encryption processing based on an encoding result. The first party is further configured to send the first ciphertext set and a similarity threshold to the second party. The second party is configured to perform rotation operations on a plurality of candidate vectors respectively in advance to obtain a plurality of second rotated vectors corresponding to the plurality of candidate vectors respectively, and perform the encoding processing on vectors composed of elements at the same position in the plurality of second rotated vectors respectively to obtain a second encoding set. The second party is configured to perform homomorphic operations based on the first ciphertext set, the similarity threshold and the second encoding set to obtain a retrieval result ciphertext. The first party is further configured to perform homomorphic decryption on the received retrieval result ciphertext to obtain a retrieval result plaintext, which indicates whether a similarity between each candidate vector and the target vector is greater than the similarity threshold.
[0021] According to a fifth aspect, there is provided a vector retrieval apparatus for protecting data privacy, integrated in a first party, comprising: a rotation module configured to perform a plurality of rotation operations based on a target vector to be retrieved to obtain a plurality of first rotated vectors; an encryption module configured to perform homomorphic encryption on vectors composed of elements at the same position in the plurality of first rotated vectors respectively to obtain a first ciphertext set. The homomorphic encryption comprises encoding processing and encryption processing based on an encoding result; a sending module configured to send the first ciphertext set and a similarity threshold to a second party. The second party is configured to perform rotation operations on a plurality of candidate vectors respectively in advance to obtain a plurality of second rotated vectors corresponding to the plurality of candidate vectors respectively, and perform the encoding processing on vectors composed of elements at the same position in the plurality of second rotated vectors respectively to obtain a second encoding set; a receiving module configured to receive a retrieval result ciphertext from the second party. The retrieval result ciphertext is obtained based on homomorphic operations on the first ciphertext set, the similarity threshold and the second encoding set; and a decryption module configured to perform homomorphic decryption on the retrieval result ciphertext to obtain a retrieval result plaintext, which indicates whether a similarity between each candidate vector and the target vector is greater than the similarity threshold.
[0022] According to a sixth aspect, there is provided a vector retrieval apparatus for protecting data privacy, integrated in a second party, comprising:
[0023] The receiving module is configured to receive a first ciphertext set and a similarity threshold from a first party, the first ciphertext set being obtained by performing homomorphic encryption on vectors composed of elements at the same positions in a plurality of first rotated vectors obtained by performing a plurality of rotation operations on a target vector to be searched, the homomorphic encryption including encoding processing and encryption processing based on an encoding result. The reading module is configured to read a second encoding set, which is determined in advance based on the following steps: performing rotation operations on a plurality of candidate vectors to obtain a plurality of second rotated vectors corresponding to the candidate vectors, and performing the encoding processing on vectors composed of elements at the same positions in the plurality of second rotated vectors to obtain the second encoding set. The operation module is configured to perform homomorphic operations based on the first ciphertext set, the similarity threshold, and the second encoding set to obtain a search result ciphertext. The sending module is configured to send the search result ciphertext to the first party, so that the first party performs homomorphic decryption on the search result ciphertext to obtain a search result plaintext indicating whether the similarity between each candidate vector and the target vector is greater than the similarity threshold.
[0024] According to a seventh aspect, a computer readable storage medium is provided, having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method according to the first aspect or the second aspect or the third aspect.
[0025] According to an eighth aspect, a computing device is provided, comprising a memory and a processor, the memory having stored thereon executable code which, when executed by the processor, implements the method according to the first aspect or the second aspect or the third aspect.
[0026] In summary, by using the above-mentioned method or device disclosed in the embodiments of the present specification, 1) a mechanism of pre-encoding of a vector database and pre-rotation of a query vector is designed, which effectively improves the time efficiency of ciphertext vector similarity calculation and effectively reduces the communication amount. Further, a complex encoding is also designed, which greatly improves the calculation efficiency and greatly reduces the communication amount. 2) By introducing a homomorphic encryption mechanism, the queried party cannot perceive the content and result of the query, so that the querying party can only perceive information related to the query result. Further, by introducing a mechanism of random scaling of a result ciphertext, the querying party can only obtain information about whether the similarity between the target vector and all vectors in the database exceeds a threshold value, and cannot obtain the specific similarity value or other information, which fully meets the privacy requirements of the queried party. In this way, the data privacy protection of the querying party and the queried party is effectively realized. BRIEF DESCRIPTION OF DRAWINGS
[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description are briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort on the basis of these drawings.
[0028] Figure 1 The schematic diagram of communication interaction of the privacy vector retrieval scheme disclosed by the embodiments of the present application;
[0029] Figure 2 The schematic diagram of communication interaction of the vector retrieval method for protecting data privacy disclosed by the embodiments of the present application;
[0030] Figure 3 The schematic diagram of the structure of the vector retrieval device integrated in the first party for protecting data privacy disclosed by the embodiments of the present application;
[0031] Figure 4 The schematic diagram of the structure of the vector retrieval device integrated in the second party for protecting data privacy disclosed by the embodiments of the present application. DETAILED DESCRIPTION
[0032] The scheme provided by the present application is described below with reference to the drawings.
[0033] As described above, the privacy vector retrieval is widely used in business scenarios such as biological authentication and multi-party risk control. In one implementation algorithm of the privacy vector retrieval, it is proposed that the query vector is homomorphically encrypted, and then the vector in the database is directly subjected to inner product similarity calculation to obtain an encrypted similarity result, which is finally returned to the query party for decryption. However, in this algorithm, the vector inner product similarity calculation based on homomorphic encryption often needs to perform a large number of ciphertext rotation operations, and the time complexity of this operation is high, resulting in low retrieval efficiency.
[0034] Based on the above observation and analysis, the embodiments of the present application propose a privacy vector retrieval scheme, which can batch calculate the inner product similarity between vectors without ciphertext rotation operation, thereby realizing efficient retrieval. For ease of understanding, the homomorphic encryption algorithm based on which the privacy vector retrieval scheme disclosed by the embodiments of the present application is introduced below by taking the CKKS algorithm as an example.
[0035] CKKS (Cheon-Kim-Kim-Song) is a full homomorphic encryption algorithm based on a polynomial ring, which can encrypt a complex vector x into ciphertext It can be understood that the complex vector includes a real number vector. The encryption process is divided into two steps:
[0036] 1. Encoding: encode the original vector into a plaintext polynomial, denoted as [x] = encode(x). This step does not require the participation of the key and can be completed in the case of known public parameters.
[0037] 2. Encryption: encrypt the plaintext polynomial [x], denoted as where sk represents the key of homomorphic encryption.
[0038] Similarly, the decryption process is also divided into two steps:
[0039] 1. Decryption: When symmetric encryption is used, the key of homomorphic decryption is also sk.
[0040] 2. Decoding: x = decode([x]).
[0041] In addition, CKKS supports the following operations:
[0042] 1. ciphertext and ciphertext addition, multiplication:
[0043] (where * denotes element multiplication);
[0044] 2. ciphertext and plaintext polynomial addition, multiplication:
[0045]
[0046] 3. ciphertext rotation:
[0047] where ρ(x, k) represents rotating x to the right by k bits.
[0048] It should be understood that the above takes CKKS as an example to introduce the homomorphic encryption algorithm used in the embodiments of the present specification. In fact, other homomorphic encryption algorithms such as BGV, BFV, etc. can also be used, and the commonality is to support full homomorphic operations between ciphertexts and between plaintexts and ciphertexts (including homomorphic addition and homomorphic multiplication), and the homomorphic encryption process includes encoding processing and encryption processing, and the homomorphic decryption process includes decryption processing and decoding processing.
[0049] Figure 1 The two-party communication interaction diagram of the privacy vector retrieval scheme disclosed in the embodiments of the present specification is as follows: Figure 1As shown, the scheme involves an offline phase and an online phase. In the offline phase, the queried party pre-processes the database vectors (not limited to stored in the database), including pre-rotation and pre-encoding of the database vectors, and the pre-processing is only performed once when the vector database is initialized, for example. In the online phase, the querying party sends the pre-processed and encrypted ciphertext query vector to the queried party, and the queried party determines the ciphertext query result by calculating the similarity between the encoded vectors in the database and the ciphertext query vector, and sends the ciphertext query result to the querying party. Then, the querying party can decrypt the ciphertext query result to obtain the plaintext query result.
[0050] The specific implementation steps of the above privacy vector retrieval scheme in the offline phase and the online phase will be introduced respectively in combination with more embodiments. First of all, it should be pointed out that the querying party and the queried party will be replaced by the first party and the second party respectively in this paper.
[0051] In the offline phase, the second party pre-processes the candidate vectors (such as the above database vectors) held by it, and the pre-processing includes:
[0052] I. Based on a plurality of candidate vectors {y i} i∈[N] Respectively perform rotation operation to obtain corresponding plurality of second rotation vectors. It should be understood that the subscript i∈[N] is a simple notation, which means taking all integers in the interval [1, N] for i; or, {y i} i∈[N] Can be written as {y i |i∈[1,N]}.
[0053] First of all, it should be pointed out that in the business scenario of biological authentication, the plurality of candidate vectors are a plurality of biological feature vectors of a plurality of users, wherein the biological feature vector can be a fingerprint feature vector, an iris feature vector or a face feature vector, etc. For example, the second party uses a biological feature model pre-trained based on machine learning technology to process a plurality of user biological information respectively, and obtains a plurality of biological feature vectors correspondingly. In the multi-party risk control scenario, the plurality of candidate vectors can be a plurality of face feature vectors in the face blacklist. In other text, picture or audio retrieval scenarios, the content represented by the candidate vector changes adaptively. In addition, the user information mentioned in this paper is collected and used after the user confirms and authorizes.
[0054] In embodiment A, any i-th candidate vector y i Can be encoded into an i-th complex vector y And then the rotation operation is performed to reduce the subsequent calculation amount. For example, y Denotes the j-th dimensional element in the candidate vector y , the candidate vector y i Can be encoded into a complex vector y
[0055]
[0056] It should be understood that the encoding of the complex vector Not limited to formula (1), but also can use the variant of formula (1) and so on, for example,
[0057] In embodiment B, the candidate vector y i The rotation operation is implemented.
[0058] It should be noted that the following mainly introduces the rotation operation of the complex vector The rotation operation is implemented, and the vector rotation operation under embodiment B can be simply known and referred to.
[0059] Embodiment A can be further divided into embodiment A1 and embodiment A2. In embodiment A1, considering that the data amount of the complex vector is large, in order to further reduce the subsequent calculation amount, a plurality of complex vectors can be grouped for processing, specifically, a plurality of complex vectors are divided into groups, and then the rotation operation is performed on each vector in each group to obtain a group of rotated vectors corresponding to the complex vector of the group.
[0060] Suppose the number of complex vectors in each group is n, then N complex vectors can be divided into groups. It should be understood that n is assumed to be divisible by N here, if it cannot be divided, a number of (herein refers to one or more) zero vectors can be added in the N candidate vectors, so that n can be divisible by N.
[0061] Exemplarily, for the kth complex vector in the ith group It can be rotated to the right by k-1 bits to obtain the corresponding second rotated vector It should be understood that when the rotation operation (or called circular shift operation) is performed on each complex vector, the direction and number of bits of rotation can be flexibly designed as needed, for example, in addition to rotating to the right, it can also rotate to the left; the number of bits of rotation is not limited to k-1, but also can be k or k+1 and so on. Thus, the group of complex vectors corresponds to group of second rotated vectors.
[0062] In embodiment A2, the N complex vectors can not be grouped, but the rotation operation is directly performed. Exemplarily, for the ith complex vector It can be rotated to the left by i bits to obtain the corresponding second rotated vector
[0063] From the above, the N candidate vectors {y i}i∈[N] corresponding N second rotation vectors.
[0064] II. The vectors formed by the same position elements in the above N second rotation vectors are respectively encoded to obtain a second encoding set.
[0065] It should be noted that the following mainly introduces the second encoding set obtained based on the above embodiment A1 After the second rotation vectors are grouped, the encoding processing is performed to obtain the second encoding set. The way to determine the second encoding set for the N second rotation vectors obtained in other embodiments can be inferred with reference.
[0066] Intuitively, the matrix formed by stacking the n second rotation vectors in any ith group is denoted as and the jth column in M i is denoted as Based on this, the encoding operation of the homomorphic encryption algorithm (such as CKKS) can be used to process the d column vectors in M i respectively corresponding to obtain d second encodings to form a second encoding set [M i ]. In this way, the second encoding set can be obtained or written as:
[0067]
[0068] The above introduces the offline phase, and the second party performs pre-rotation and pre-encoding on the multiple candidate vectors it holds respectively to obtain multiple second encodings to form one or more second encoding sets.
[0069] Next, the process of the first party using the second party's private vector retrieval service in the online phase is introduced. Figure 2 The communication interaction diagram of the vector retrieval method disclosed in the embodiments of the present specification for protecting data privacy. It should be understood that Figure 2 The "first" in "first party" and the "second" in "second party" and similar terms in the text are used to distinguish the same things and do not have other limiting functions such as ordering. In addition, the first party and the second party can be implemented as any device, platform, server or device cluster with computing and processing capabilities. For example, the first party and the second party are the client and the server respectively.
[0070] As shown in Figure 2 , the method comprises the following steps:
[0071] In step S201, the first party performs multiple rotation operations based on the target vector x to be retrieved, obtaining multiple first rotated vectors. It should be understood that the terms "retrieval" and "query" are used interchangeably in this text; the target vector can refer to any vector to be retrieved.
[0072] In biometric authentication scenarios, the target vector can be a user's biometric representation vector. For example, the first party is a client, which receives fingerprint information input by the user and processes this fingerprint information using a pre-trained fingerprint representation model deployed on the client, employing machine learning techniques, to obtain the corresponding fingerprint representation vector, which serves as the target vector.
[0073] In multi-party risk control scenarios, multiple parties share a facial blacklist. In this case, the target vector can be a facial representation vector. For example, the first party is a bank. After cooperating with other banks and institutions, the bank determines the corresponding facial representation vector based on the facial images pre-registered by its users, and uses this vector as the target vector.
[0074] Additionally, it should be understood that the execution of this step is related to the second party based on the candidate vector y. i The pre-rotation method is adapted to enable subsequent vector alignment and correct calculation of vector similarity.
[0075] In accordance with the aforementioned implementation method A, implementation method C is adopted in this step, in which the target vector x is first encoded into a low-dimensional complex vector. Then perform multiple rotation operations to reduce subsequent computational load. For example, using x... j Represents the target vector The j-th element in the vector can be used to encode the target vector x into a complex vector using the following equation (2).
[0076]
[0077] It needs to be understood that encoding is done as a complex vector. Not limited to using formula (2), variations of formula (2) can also be used, for example, It is only necessary to make the complex vector and The real part of the inner product between the two vectors x and y i The inner product results must be equal. A simple proof shows that the complex vectors encoded using formulas (1) and (2) are equal. and This requirement is met.
[0078] In accordance with the aforementioned implementation method B, implementation method D is adopted in this step, in which multiple rotation operations are directly performed on the target vector x.
[0079] It should be noted that the following mainly introduces the implementation of the plurality of first rotation vectors for the complex vector The rotation operation is implemented, and the vector rotation operation under the implementation D can be simply inferred and executed with reference. The implementation C can be further divided into implementation C1 and implementation C2, which are adapted to the aforementioned implementation A1 and implementation A2 respectively.
[0080] In the implementation C1, the complex vector The rotation operation is performed n times, and it is noted that n is also the number of vectors of each group of second rotation vectors obtained in the aforementioned implementation A1. For example, when the complex vector is rotated for the kth time, the complex vector is rotated to the right by k-1 positions to obtain the kth first rotation vector Thus, n first rotation vectors can be obtained.
[0081] In the implementation C2, the complex vector is rotated for N times, and it is noted that N is the total number of second rotation vectors obtained in the aforementioned implementation A2.
[0082] From the above, the first party can obtain a plurality of first rotation vectors for the target vector x.
[0083] In step S202, the first party homomorphically encrypts the vectors composed of elements at the same position in the plurality of first rotation vectors respectively to obtain a first ciphertext set; the homomorphic encryption includes encoding processing and encryption processing based on the encoding result.
[0084] It should be noted that the following mainly introduces the implementation of the plurality of first rotation vectors for the complex vector
[0085] Intuitively, the matrix formed by stacking the n first rotation vectors is denoted as And the jth column in Q is denoted as Based on this, in the implementation D, the encoding operation of the homomorphic encryption algorithm (such as CKKS) can be used to process the d column vectors {q j} j∈[d] Correspondingly, d first encodings {[q j} j∈[d] are obtained, forming a first encoding set [Q].
[0086] Further, using the key generated based on the homomorphic encryption algorithm, each first encoding [q j ] is encrypted into a first ciphertext Thus, d first ciphertexts Forming the first ciphertext set It can be understood that the generated key can be a symmetric key or a private key in an asymmetric key, and no limitation is made thereto.
[0087] From the above, the first ciphertext set can be obtained. In addition, it should be noted that the following introduction to the subsequent steps is based on the obtained first ciphertext set being the first ciphertext set in the embodiment D. For other implementation cases, reference can be made to the inference.
[0088] Step S203, the first party sends the first ciphertext set to the second party and the similarity threshold τ. It can be understood that the threshold τ indicates that when the vector similarity is greater than τ, it can be considered as the same object.
[0089] Step S204, the second party performs homomorphic operation on the first ciphertext set based on the similarity threshold τ and the second encoding set to obtain the retrieval result ciphertext.
[0090] It can be understood that when the first ciphertext set is the first ciphertext set in the embodiment D, the second encoding set is the plurality of second encoding sets in the embodiment C Therefore, in this step, the second party performs homomorphic operation on the first ciphertext set and the similarity threshold τ with each second encoding set [M i ] respectively to obtain a plurality of retrieval result ciphertexts
[0091] The determination process of an arbitrary ith retrieval result ciphertext is introduced below.
[0092] 1) Perform the first homomorphic operation on the first ciphertext set and the second encoding set [M i ] to obtain the similarity vector ciphertext
[0093] It is known that the first homomorphic operation includes: first, for each first ciphertext in the first ciphertext set , perform homomorphic plaintext multiplication operation with the second encoding in the second encoding set [M i ] corresponding thereto and the value to obtain the corresponding product ciphertext, and then perform homomorphic ciphertext addition operation on the d product ciphertexts to obtain the similarity vector ciphertext This can be denoted as the following formula:
[0094]
[0095] In formula (3), With homomorphic plaintext-ciphertext multiplication, Σ is summed up by addition between ciphertexts. The corresponding plaintext vector z i is equivalent to the plaintext matrix Q and the plaintext matrix M i The elements are multiplied by the corresponding plaintext matrix Z i , and the plaintext matrix Z i is obtained by summing the elements of the same row in the plaintext matrix Q and the plaintext matrix M i The inner product between the row vectors is calculated to obtain the plaintext column vector z i .
[0096] Further, the k-th row of the plaintext matrix Q M i is the k-th row of the plaintext matrix M The k-th row element of the plaintext column vector z i is obtained as follows:
[0097]
[0098] The real part of is taken, because the real part Therefore, the real part of the k-th row element of z i is the inner product of the target vector x and the candidate vector y (i-1)n+k , and thus the real part of z i is the inner product of the target vector x and the i-th set of candidate vectors {y (i-1)n+k |k=1,…,n}.
[0099] It should be understood that the target vector x and the candidate vector y i are both unit vectors, so their inner product is the cosine similarity. In addition, if the implementation of the scheme does not involve converting the real number vectors x and y i into complex number vectors, then the similarity plaintext corresponding to the similarity vector ciphertext calculated in this step is the similarity itself, and no real part extraction is required after decryption.
[0100] From the above, the similarity vector ciphertext
[0101] 2) Based on the similarity vector ciphertext and the similarity threshold τ, the second homomorphic operation is performed to obtain the retrieval result ciphertext
[0102] Specifically, the inverse of the similarity threshold τ is first processed by the encoding process in the homomorphic encryption algorithm to obtain the threshold encoding [-τ], and then the sum ciphertext obtained by performing homomorphic ciphertext addition operation on the similarity vector ciphertext and the threshold encoding [-τ] is determined as the retrieval result ciphertext
[0103] In one embodiment, the above-mentioned added ciphertext is directly taken as the retrieval result ciphertext, which can be denoted as:
[0104]
[0105] wherein, homomorphic plaintext ciphertext addition is used.
[0106] In another embodiment, in order to further protect the privacy of the queried party, the above-mentioned added ciphertext is subjected to random scaling calculation and then taken as the retrieval result ciphertext, which can be denoted as:
[0107]
[0108] wherein, u ot is a random vector with positive real number as the constituent element, and [u ot ] is a random vector code obtained by performing encoding processing on u ot in the homomorphic encryption algorithm, homomorphic plaintext ciphertext multiplication is used.
[0109] From the above, the i-th retrieval result ciphertext It can be understood that it corresponds to the retrieval result plaintext obtained by querying the i-th group of candidate vectors {y (i-1)n+k |k=1,…,n} with the target vector x and the similarity threshold τ.
[0110] Then, in step S205, the second party sends the retrieval result ciphertext to the first party.
[0111] Illustratively, the second party feeds back multiple retrieval result ciphertexts to the first party.
[0112] Then, in step S206, the first party homomorphically decrypts the retrieval result ciphertext to obtain the retrieval result plaintext, which indicates whether the similarity between each candidate vector and the target vector is greater than the similarity threshold.
[0113] Illustratively, the first party decrypts each retrieval result ciphertext to obtain the retrieval result code [r i ], and then decodes the retrieval result code to obtain the retrieval result plaintext r i , so multiple retrieval result plaintexts or can be written as:
[0114]
[0115] Further, take the real part of each element in r, and for example, count the number of elements greater than 0, which is the number of candidate vectors indicating the same object (e.g., different facial representations of the same person, etc.) as the target vector.
[0116] In summary, the vector retrieval method disclosed in the embodiments of the present specification has the following advantages: 1) The vector database pre-encoding and query vector pre-rotation mechanism is designed, which effectively improves the time efficiency of the ciphertext vector similarity calculation and effectively reduces the communication amount. Further, the complex encoding is also designed, which greatly improves the calculation efficiency and greatly reduces the communication amount. 2) By introducing the homomorphic encryption mechanism, the queried party cannot perceive the content and result of the query, and the querying party can only perceive the information related to the query result. Further, by introducing the result ciphertext random scaling mechanism, the querying party can only obtain the information whether the similarity between the target vector and all vectors in the database exceeds a threshold value, and cannot obtain the specific similarity value or other information, which fully meets the privacy requirements of the queried party. In this way, the data privacy protection of the querying party and the queried party is effectively realized.
[0117] Corresponding to the above-mentioned vector retrieval method, the embodiments of the present specification also disclose a vector retrieval device. Figure 3 The structure diagram of the vector retrieval device integrated with the first party for protecting data privacy disclosed in the embodiments of the present specification is shown in FIG. 3. Figure 3 As shown in FIG. 3, the device 300 includes:
[0118] The rotation module 310 is configured to perform multiple rotation operations based on the target vector to be retrieved to obtain a plurality of first rotated vectors. The encryption module 320 is configured to perform homomorphic encryption on the vectors composed of elements at the same position in the plurality of first rotated vectors respectively to obtain a first ciphertext set; the homomorphic encryption includes encoding processing and encryption processing based on the encoding result. The sending module 330 is configured to send the first ciphertext set and a similarity threshold value to the second party, and the second party performs rotation operations on a plurality of candidate vectors respectively in advance to obtain a plurality of corresponding second rotated vectors, and performs the encoding processing on the vectors composed of elements at the same position in the plurality of second rotated vectors respectively to obtain a second encoding set. The receiving module 340 is configured to receive a retrieval result ciphertext from the second party, and the retrieval result ciphertext is obtained based on homomorphic operation of the first ciphertext set, the similarity threshold value and the second encoding set. The decryption module 350 is configured to perform homomorphic decryption on the retrieval result ciphertext to obtain a retrieval result plaintext, which indicates whether the similarity between each candidate vector and the target vector is greater than the similarity threshold value.
[0119] Figure 4 The structure diagram of the vector retrieval device integrated with the second party for protecting data privacy disclosed in the embodiments of the present specification is shown in FIG. 4. Figure 4As shown, the apparatus 400 includes:
[0120] The receiving module 410 is configured to receive a first ciphertext set and a similarity threshold from a first party, the first ciphertext set being obtained by homomorphically encrypting vectors composed of elements at the same positions in a plurality of first rotated vectors obtained by performing a plurality of rotation operations on a target vector to be searched, the homomorphic encryption including encoding processing and encryption processing based on an encoding result. The reading module 420 is configured to read a second encoding set, which is determined in advance based on the following steps: performing a rotation operation on a plurality of candidate vectors to obtain a plurality of second rotated vectors corresponding to the plurality of candidate vectors, and performing the encoding processing on vectors composed of elements at the same positions in the plurality of second rotated vectors to obtain the second encoding set. The operation module 430 is configured to perform homomorphic operations based on the first ciphertext set, the similarity threshold, and the second encoding set to obtain a search result ciphertext. The sending module 440 is configured to send the search result ciphertext to the first party, so that the first party homomorphically decrypts the search result ciphertext to obtain a search result plaintext indicating whether the similarity between each candidate vector and the target vector is greater than the similarity threshold.
[0121] According to another aspect, an embodiment also provides a computer readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method described above. Figure 2 According to another aspect, an embodiment also provides a computer readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method described above.
[0122] According to another aspect, an embodiment also provides a computer readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method described above. Figure 2 According to another aspect, an embodiment also provides a computer readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method described above.
[0123] Those skilled in the art should be aware that the functions described in the above one or more examples can be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, the functions can be stored in a computer readable medium or transmitted as one or more instructions or code on a computer readable medium.
[0124] The above detailed description sets forth the purpose, technical solutions, and beneficial effects of the present application. It should be understood that the above detailed description is only a specific implementation of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made on the basis of the technical solutions of the present application shall be included in the protection scope of the present application.
Claims
1. A method for vector search with privacy protection, comprising: a first party performing a plurality of rotation operations on a target vector to be searched to obtain a plurality of first rotated vectors, and performing homomorphic encryption on vectors composed of elements at the same position in the plurality of first rotated vectors to obtain a first ciphertext set, wherein the homomorphic encryption comprises encoding and encryption based on the encoding result; the first party sending the first ciphertext set and a similarity threshold to a second party, wherein the second party performs rotation operations on a plurality of candidate vectors in advance to obtain a plurality of second rotated vectors corresponding to the candidate vectors, and performs the encoding on vectors composed of elements at the same position in the plurality of second rotated vectors to obtain a second encoding set; the second party performing homomorphic operations based on the first ciphertext set, the similarity threshold and the second encoding set to obtain a search result ciphertext; the first party performing homomorphic decryption on the received search result ciphertext to obtain a search result plaintext indicating whether the similarity between each candidate vector and the target vector is greater than the similarity threshold.
2. The method of claim 1, wherein, the second party performing homomorphic operations based on the first ciphertext set, the similarity threshold and the second encoding set to obtain a search result ciphertext, comprising: performing first homomorphic operations on the first ciphertext set and the second encoding set to obtain a similarity vector ciphertext; performing second homomorphic operations based on the similarity vector ciphertext and the similarity threshold to obtain the search result ciphertext.
3. The method of claim 2, wherein, the first homomorphic operations comprising: for each first ciphertext in the first ciphertext set, performing homomorphic plaintext-ciphertext multiplication operations on the first ciphertext and a second encoding corresponding to the first ciphertext in the second encoding set to obtain a corresponding product ciphertext; performing homomorphic ciphertext addition operations on all product ciphertexts to obtain the similarity vector ciphertext.
4. The method of claim 2, wherein, the second homomorphic operations comprising: performing the encoding on the inverse of the similarity threshold to obtain a threshold encoding; determining the search result ciphertext based on a sum ciphertext obtained by performing homomorphic ciphertext addition operations on the similarity vector ciphertext and the threshold encoding.
5. The method of claim 4, wherein, determining the search result ciphertext, comprising: generating a random vector composed of positive real numbers; performing the encoding on the random vector to obtain a random vector encoding; performing homomorphic plaintext-ciphertext multiplication operations on the sum ciphertext and the random vector encoding to obtain the search result ciphertext. 6.The method of claim 1, wherein the first party performing a plurality of rotation operations on a target vector to be searched to obtain a plurality of first rotated vectors, comprising: converting the target vector into a first complex vector of low dimension, and performing a plurality of rotation operations on the first complex vector to obtain the plurality of first rotated vectors; wherein the second party performing rotation operations on a plurality of candidate vectors in advance to obtain a plurality of second rotated vectors corresponding to the candidate vectors, comprising: converting the plurality of candidate vectors into a plurality of second complex vectors of low dimension corresponding to the candidate vectors, and performing rotation operations on the second complex vectors to obtain the plurality of second rotated vectors corresponding to the candidate vectors; wherein the method further comprises: extracting real parts from the search result plaintext, and determining whether a similarity between each candidate vector and the target vector is greater than the similarity threshold based on signs of the real parts.
7. The method of claim 1, wherein the second encoding set is a plurality of second encoding sets, and the second party obtains the plurality of second encoding sets in advance by dividing the plurality of candidate vectors into a plurality of groups, performing a rotation operation on each vector in each group respectively to obtain a group of rotated vectors corresponding to the candidate vectors in the group, and performing the encoding processing on vectors composed of elements at the same positions in the group of rotated vectors respectively to obtain a second encoding set corresponding to the candidate vectors in the group; wherein the second party performs homomorphic operations based on the first ciphertext set, the similarity threshold, and the second encoding set to obtain search result ciphertext, including that the second party performs homomorphic operations on each of the plurality of second encoding sets based on the first ciphertext set and the similarity threshold respectively to obtain a plurality of search result ciphertexts.
8. The method of claim 1, wherein, the first party performs homomorphic decryption on the received search result ciphertext to obtain search result plaintext, including: performing decryption processing corresponding to the encryption processing on the search result ciphertext to obtain search result encoding; performing decoding processing corresponding to the encoding processing on the search result encoding to obtain the search result plaintext.
9. The method of claim 1, wherein, the target vector is a biological feature vector of a target user, and the plurality of candidate vectors are a plurality of biological feature vectors of a plurality of candidate users.
10. A vector search method for protecting data privacy, applied to a first party, comprising: performing a plurality of rotation operations based on a target vector to be searched to obtain a plurality of first rotated vectors, and performing homomorphic encryption on vectors composed of elements at the same positions in the plurality of first rotated vectors respectively to obtain a first ciphertext set; the homomorphic encryption includes encoding processing and encryption processing based on the encoding result; sending the first ciphertext set and a similarity threshold to a second party, the second party performing rotation operations on a plurality of candidate vectors respectively in advance to obtain a plurality of second rotated vectors corresponding thereto, and performing the encoding processing on vectors composed of elements at the same positions in the plurality of second rotated vectors respectively to obtain a second encoding set; receiving search result ciphertext from the second party, the search result ciphertext being obtained by performing homomorphic operations based on the first ciphertext set, the similarity threshold, and the second encoding set; performing homomorphic decryption on the search result ciphertext to obtain search result plaintext, which indicates whether a similarity between each candidate vector and the target vector is greater than the similarity threshold.
11. A vector search method for protecting data privacy, applied to a second party, comprising: receiving a first ciphertext set and a similarity threshold from a first party, the first ciphertext set being obtained by performing homomorphic encryption on vectors composed of elements at the same positions in a plurality of first rotated vectors after performing a plurality of rotation operations based on a target vector to be searched; the homomorphic encryption includes encoding processing and encryption processing based on the encoding result; reading a second encoding set, which is determined in advance based on the following steps: performing a rotation operation on each of a plurality of candidate vectors to obtain a corresponding plurality of second rotated vectors, and performing the encoding process on vectors composed of elements at the same position in the plurality of second rotated vectors to obtain the second encoding set; performing a homomorphic operation based on the first ciphertext set, the similarity threshold, and the second encoding set to obtain a search result ciphertext; sending the search result ciphertext to the first party, so that the first party homomorphically decrypts the search result ciphertext to obtain a search result plaintext, which indicates whether the similarity between each candidate vector and the target vector is greater than the similarity threshold.
12. A vector search system for protecting data privacy, comprising a first party and a second party: the first party is configured to perform a rotation operation multiple times based on a target vector to be searched to obtain a plurality of first rotated vectors, and perform a homomorphic encryption on vectors composed of elements at the same position in the plurality of first rotated vectors to obtain a first ciphertext set; the homomorphic encryption comprises an encoding process and an encryption process based on the encoding result; the first party is further configured to send the first ciphertext set and a similarity threshold to the second party, and the second party is configured to perform a rotation operation on each of a plurality of candidate vectors in advance to obtain a corresponding plurality of second rotated vectors, and perform the encoding process on vectors composed of elements at the same position in the plurality of second rotated vectors to obtain a second encoding set; the second party is configured to perform a homomorphic operation based on the first ciphertext set, the similarity threshold, and the second encoding set to obtain a search result ciphertext; the first party is further configured to homomorphically decrypt the received search result ciphertext to obtain a search result plaintext, which indicates whether the similarity between each candidate vector and the target vector is greater than the similarity threshold.
13. A vector search device for protecting data privacy, integrated in a first party, comprising: a rotation module configured to perform a rotation operation multiple times based on a target vector to be searched to obtain a plurality of first rotated vectors; an encryption module configured to perform a homomorphic encryption on vectors composed of elements at the same position in the plurality of first rotated vectors to obtain a first ciphertext set; the homomorphic encryption comprises an encoding process and an encryption process based on the encoding result; a sending module configured to send the first ciphertext set and a similarity threshold to a second party, and the second party is configured to perform a rotation operation on each of a plurality of candidate vectors in advance to obtain a corresponding plurality of second rotated vectors, and perform the encoding process on vectors composed of elements at the same position in the plurality of second rotated vectors to obtain a second encoding set; a receiving module configured to receive a search result ciphertext from the second party, the search result ciphertext being obtained by performing a homomorphic operation based on the first ciphertext set, the similarity threshold, and the second encoding set; a decryption module configured to homomorphically decrypt the search result ciphertext to obtain a search result plaintext, which indicates whether the similarity between each candidate vector and the target vector is greater than the similarity threshold.
14. A vector search device for protecting data privacy, integrated in a second party, comprising: The receiving module is configured to receive a first ciphertext set and a similarity threshold from a first party, the first ciphertext set being obtained by performing homomorphic encryption on vectors composed of elements at the same positions in a plurality of first rotated vectors obtained by performing a plurality of rotation operations on a target vector to be searched, the homomorphic encryption including encoding processing and encryption processing based on an encoding result; The reading module is configured to read a second encoding set, which is determined in advance based on the following steps: performing a rotation operation on a plurality of candidate vectors to obtain a plurality of second rotated vectors corresponding to the plurality of candidate vectors, and performing the encoding processing on vectors composed of elements at the same positions in the plurality of second rotated vectors to obtain the second encoding set; The operation module is configured to perform homomorphic operation based on the first ciphertext set, the similarity threshold, and the second encoding set to obtain a search result ciphertext. The sending module is configured to send the search result ciphertext to the first party, so that the first party homomorphically decrypts the search result ciphertext to obtain a search result plaintext indicating whether the similarity between each candidate vector and the target vector is greater than the similarity threshold.
15. A computer readable storage medium having stored thereon a computer program, wherein, When the computer program is executed in the computer, the computer is caused to perform the method of any one of claims 1-11.
16. A computing device comprising a memory and a processor, wherein, The memory stores executable code, and the processor executes the executable code to implement the method of any one of claims 1-11.
Citation Information
Patent Citations
Privacy set intersection method and device with conditional retrieval and computer equipment
CN114065252A
Secure computing method based on privacy data and related equipment
CN116484395A