A privacy protection method for retrieval-augmented generation based on bilinear similarity
By leveraging the collaborative work of intelligent agent terminals, retrieval servers, and auxiliary servers, and utilizing bilinear similarity and ElGamal vector encryption technology, the problems of privacy leakage and computational accuracy in privacy-enhanced retrieval generation are solved. This achieves highly secure and accurate retrieval enhancement generation, suitable for intelligent question answering and knowledge base retrieval scenarios.
Patent Information
- Application Number
- CN202611336695.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-11-27
Smart Images

Figure CN123179448A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of privacy-preserving retrieval enhancement generation technology, specifically relating to a privacy-preserving retrieval enhancement generation method based on bilinear similarity. Background Technology
[0002] With the rapid development of large language model technology, Retrieval Augmentation (RAG) technology is widely used in intelligent question answering and knowledge base retrieval scenarios. This technology relies on external knowledge bases to make up for the knowledge lag of large models and improve the reliability of question answering results. However, the basic scheme directly transmits plaintext vectors and query text, and cloud servers can obtain sensitive information from user queries and knowledge bases, which poses a significant risk of privacy leakage. Existing technologies mostly use homomorphic encryption and vector encryption to achieve privacy retrieval, and can carry out similarity matching in the ciphertext domain to initially achieve data isolation and protection.
[0003] However, existing privacy-enhancing retrieval generation schemes still have many shortcomings: most encrypted retrieval operations are computationally expensive and cannot support concurrent retrieval of large-scale knowledge bases; ciphertext similarity calculations generally suffer from precision loss, affecting retrieval matching results; there is a lack of a collaborative architecture where intelligent agent terminals, retrieval servers, and auxiliary servers do not collude with each other, and key distribution and vector masking mechanisms are imperfect, posing a risk that the retrieval server may steal intermediate computation information; at the same time, there is a lack of a knowledge base version control system and no complete security auditing capabilities, making it impossible to effectively identify abnormal requests and trace unauthorized access behavior. To address these issues, we propose a privacy-preserving retrieval enhancement generation method based on bilinear similarity. Summary of the Invention
[0004] To address the aforementioned problems in the existing technology, this invention provides a retrieval enhancement and privacy protection method based on bilinear similarity.
[0005] The technical problem to be solved by this invention is achieved through the following technical solution: The method is executed collaboratively by intelligent agent terminal A, retrieval server S1, and auxiliary server S2, with S1 and S2 not colluding with each other, including: Construct bilinear group parameters, initialize vector ElGamal encryption and function hidden inner product encryption IPFE, A generates its own public and private key pair, S2 generates IPFE master key and keeps it, generates random vectors a and b and encrypts them and sends them to A, A decrypts them to get random vectors a and b, and establishes version management and security audit mechanism. A encodes knowledge documents into knowledge vectors through an embedding model, samples random scalars, masks the knowledge vectors with random vector a, generates knowledge side vector ElGamal ciphertext and IPFE auxiliary ciphertext, and sends them to S1; S2 generates function keys K1 and K2 based on the bilinear parameter matrix F and random vectors a and b, and sends them to S1. A uses the same embedding model to encode the query to obtain the query vector, samples a random scalar, masks the query vector with a random vector b, generates the query side vector ElGamal ciphertext and IPFE auxiliary ciphertext, and sends them to S1; S1 uses the bilinear parameter matrix F to perform bilinear mapping on the ElGamal ciphertext of the knowledge-side and query-side vectors. The IPFE auxiliary ciphertext of the knowledge-side and query-side vectors is decrypted using function keys K1 and K2 respectively to obtain two types of mask redundancy terms. After canceling all redundancy terms, the cipher-state bilinear similarity is obtained. S1 sorts the documents in descending order based on dense bilinear similarity, selects the top k document identifiers and sends them back to A. A recovers the corresponding knowledge content, constructs a prompt template based on the original query, and calls the large language model to generate question-and-answer results.
[0006] Preferably, the construction of the bilinear group parameters includes: establishing asymmetric bilinear group parameters (G1, G2, G...). T Given a cyclic group G1 and G2 of prime order, where P1 and P2 are generators, and e: G1 × G2 → G T It is a bilinear mapping, and the elements in the group are denoted by [x]1=xP1, [x]2=xP2, where x is a finite field Z. p Any scalar in the middle; The vector ElGamal encryption is based on the DDH assumption, and the function-hidden IPFE is based on the SXDH assumption.
[0007] Preferably, A generates a public-private key pair (pk A ,sk A ); S2 generates a, b∈Z according to the knowledge base version or retrieval period. p l PK using A's public key A Encrypt a and b, and send them to A. A uses the private key sk. A Decryption yields random vectors a and b; Random vector a is used for the knowledge-side mask, and random vector b is used for the query-side mask. S1 does not participate in the generation and distribution of random vectors a and b, and does not obtain the plaintext of random vectors a and b.
[0008] Preferably, A uses an embedding model to encode knowledge documents and user queries into l-dimensional vectors d of the same dimension. i and q; The bilinear parameter matrix F is obtained by training on labeled query-document pairs or derived from an existing retrieval model. F is an l×l matrix or low-rank decomposition is used to reduce storage and computational overhead. Floating-point vectors and matrix parameters are quantized into a finite field Z according to a preset ratio. pThe integers in the similarity scale are recorded, and the similarity relationship remains unchanged without modulus wrap-around.
[0009] Preferably, A samples a random scalar r i ∈Z p The knowledge vector d is obtained by random vector a. i Masking, generating knowledge side vectors ElGamal ciphertext ct i =([r i ]1,[d i +a·r i ]1); Among them, [d i +a·r i ]1 indicates that each component of the vector is encoded into group G1, and the random term a·r i In hidden d i At the same time, it preserves the algebraic structure required for bilinear mapping; A synchronously generates the authorized output as d. i ^TFb·s Knowledge Side IPFE Auxiliary Ciphertext C i ¹, the C i ¹An auxiliary ciphertext pool can be generated online or pre-generated offline. A will ct i C i ¹ The document identifier, knowledge base version, and integrity summary are sent to S1. After verification by S1, an index is created, but the plaintext knowledge vector is not saved.
[0010] Preferably, S2 generates K1=IPFE.KeyGen(Fb) and K2=IPFE.KeyGen(Fb) based on the bilinear parameter matrix F, random vectors a and b. T a,a T Fb), K1 is used to obtain the knowledge-side redundant inner product d. i T Fb·s, K2 is used to obtain the query-side redundant inner product (a·r) i ) T Fq+(a·r i ) T Fb·s; K1 and K2 only support outputting authorized redundant inner product results and do not have the ability to recover the original vectors and function matrix parameters. K1 and K2 are bound to the knowledge base version, parameter version and expiration date before sending to S1.
[0011] Preferably, A samples a random s ∈ Z. p The query vector q is masked by a random vector b and encoded into group G2 using the ElGamal method corresponding to the knowledge side, generating the ElGamal ciphertext of the query side vector. A synchronously generates the authorized output as (a·r) i) TFq +(a·r i ) TFb ·s query side IPFE auxiliary ciphertext C i 2 Multi-document r i Related auxiliary quantities can be generated using batch processing or vector packaging; A will query the ciphertext, C i 2 Send S1 with the session identifier, knowledge base version, and expected return quantity k.
[0012] Preferably, S1 performs a bilinear mapping on each knowledge document i with respect to the two side vectors ElGamal ciphertext using F, expanding it into Raw. i =(d i +a·r i ) T F(q+b·s)=d i T Fq+d i T Fb·s+ (a·r i ) T Fq+(a·r i ) T Fb·s, where the first term is the bilinear similarity of the target and the other three terms are mask redundancy terms; S1 uses K1 against C i ¹Calculation yields D1 i =d i T Fb·s, with K2 versus C i 2 D2 was calculated i =(a·r i ) T Fq+(a·r i ) T Fb·s, and calculate Sim i =Raw i D1 i D2 i =d i T Fq, S1 does not obtain d i q, a, b, r i ,s plaintext.
[0013] Preferably, S1 sorts the encrypted bilinear similarity of all valid knowledge documents in descending order and returns the top k document identifiers, encrypted document content, or controlled access addresses. When the knowledge document body is encrypted with a symmetric key, S1 only returns the ciphertext and access credentials, and A decrypts it locally; A combines the user's original question, Top-k knowledge fragments, knowledge source identifiers, and prompt templates into a large language model input, and calls a local or controlled large language model to generate an answer.
[0014] Preferably, the version management and security audit mechanism includes: when adding or modifying a document, A encrypts the new knowledge vector and submits the new version ciphertext and integrity digest; when deleting a document, A submits a signed deletion instruction; after verification by S1, the corresponding ciphertext index is deleted; the knowledge base version and the bilinear parameter matrix version are identified and isolated from each other. When S1 detects a mismatch in knowledge base version, an expired function key, inconsistent ciphertext dimensions, an invalid message signature, an excessive timestamp, or a duplicate query session, it refuses to execute the retrieval operation and records the corresponding security event. S1 and S2 respectively store audit logs that do not contain query plaintext and knowledge plaintext, recording session identifier, knowledge base version, parameter version, query time, number of returns, execution status and message digest.
[0015] Beneficial effects of this invention: This invention constructs a encrypted retrieval architecture based on bilinear pairing combined with IPFE functional encryption and ElGamal vector encryption. Similarity calculation can be completed without decrypting the original vectors. The three parties involved do not collude, preventing the leakage of knowledge base vectors and user query plaintext, effectively solving the data privacy leakage problem of traditional solutions. This invention relies on bilinear similarity operations to achieve accurate matching of encrypted domains, reducing the loss of similarity accuracy caused by encryption operations, balancing privacy protection and retrieval matching accuracy. It can stably support retrieval enhancement generation tasks and improve the quality of intelligent question answering output. This invention uses an auxiliary server to uniformly generate functional keys and distribute mask parameters, forming a complete key isolation and vector masking mechanism. The retrieval server cannot obtain core privacy parameters such as random vectors, preventing the theft of intermediate calculation information and improving the overall system security level. This invention incorporates version management and security auditing mechanisms to achieve full lifecycle control of knowledge base document addition, modification, and deletion. It can intercept abnormal retrieval requests and retain audit logs without plaintext, facilitating the tracing of abnormal behavior and meeting the regulatory requirements of high-security business scenarios.
[0016] The present invention will now be described in further detail with reference to the accompanying drawings. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of the method steps of the present invention; Figure 2 This is a diagram of the privacy-preserving system architecture for enhanced retrieval based on bilinear similarity according to the present invention. Figure 3 This is a flowchart of the overall privacy retrieval process based on bilinear similarity in this invention. Figure 4 This is a schematic diagram of the dense-state bilinear similarity calculation and redundant term elimination of the present invention; Figure 5 This is the encrypted submission relationship between the knowledge vector and the query vector of this invention; Figure 6 This is a flowchart of the privacy protection retrieval enhancement generation business process of the present invention. Detailed Implementation
[0018] The present invention will be further described in detail below with reference to specific embodiments, but the implementation of the present invention is not limited thereto.
[0019] To ensure data privacy during the retrieval enhancement generation process, this invention provides a privacy protection method for retrieval enhancement generation based on bilinear similarity, including: The method is executed collaboratively by intelligent agent terminal A, retrieval server S1, and auxiliary server S2, with S1 and S2 not colluding with each other. The system comprises three entities: Agent A, an honest entity, is responsible for receiving user queries, encoding the queries and knowledge documents into vectors, performing ElGamal vector encryption and IPFE-assisted ciphertext generation, recovering the Top-k documents, and calling the large language model to generate results. It does not send the query vectors and knowledge vectors in plaintext to external servers. Retrieval Server S1, an honest but curious entity, is responsible for storing encrypted knowledge vectors, receiving encrypted query vectors and function keys, performing bilinear mapping, IPFE authorization calculation, redundancy elimination, similarity ranking, and Top-k selection. However, it does not possess the complete plaintext of random vectors a and b, nor does it obtain the query vector q and knowledge vector d. i The plaintext; the auxiliary server S2 is also an honest but curious entity, responsible for generating random vectors a and b and function-hidden IPFE parameters, generating function keys K1 and K2 and distributing them to S1, but it does not store the knowledge ciphertext and query ciphertext, does not participate in the final similarity ranking, and does not obtain q and d. i ; S1 and S2 do not collude with each other and do not exchange internal states, random vectors, or observation information not specified in the protocol. Under these conditions, the information held by any single server is insufficient to independently recover the query vector or knowledge vector. Network attackers may eavesdrop, tamper with, or replay protocol messages. Entities use authenticated and encrypted channels and bind system identifiers, knowledge base versions, query session identifiers, timestamps, random numbers, and digital signatures to messages.
[0020] Construct bilinear group parameters, initialize vector ElGamal encryption, and implement IPFE encryption with hidden inner product functionality.
[0021] The construction of bilinear group parameters includes: establishing asymmetric bilinear group parameters (G1,G2,GT,p,P1,P2,e), where G1 and G2 are prime-order cyclic groups, P1 and P2 are generators, e:G1×G2→GT is a bilinear mapping, and the elements in the group are represented by [x]1=xP1, [x]2=xP2, where x is any scalar in the finite field Zp; The vector ElGamal encryption is based on the DDH assumption, and the function-hidden IPFE is based on the SXDH assumption.
[0022] A uses an embedding model to encode knowledge documents and user queries into l-dimensional vectors di and q, respectively. The bilinear parameter matrix F is obtained by training on labeled query-document pairs or derived from an existing retrieval model. F is an l×l matrix or low-rank decomposition is used to reduce storage and computational overhead. The floating-point vector and matrix parameters are quantized into integers in the finite field Zp according to a preset ratio and the quantization scale is recorded. The similarity relationship remains unchanged under the condition that no mode wrap-around occurs.
[0023] Specifically, the bilinear mapping e satisfies bilinearity, nondegeneracy, and computability; the vector ElGamal encryption guarantees the semantic security of the ciphertext based on the DDH hard assumption, and the function hiding IPFE guarantees that neither the function vector nor the input vector is leaked based on the SXDH hard assumption.
[0024] The embedding model encodes knowledge documents into l-dimensional vectors after dividing them into blocks of fixed length or semantic boundaries. User queries are encoded into vectors of the same dimension using the same embedding model, ensuring that d i q and q reside in the same vector space; the bilinear parameter matrix F is used to describe the cross-correlation relationship between the query feature dimension and the knowledge feature dimension. Compared with cosine similarity and ordinary dot product, which only compare features of the same dimension, F can model the combined relationship between different semantic dimensions; F can be obtained by training labeled query-document pairs, or it can be derived from existing retrieval models or re-ranking models; when l is large, F adopts a low-rank decomposition F=UV T Since the number of columns r of U and V is less than l, the storage complexity is reduced from O(l²) to O(lr), and the bilinear computation is transformed into a two-stage multiplication in a low-dimensional space; the experiment in the original paper uses a low-rank bilinear model with a rank of 32. Floating-point vectors and matrix parameters are scaled and rounded according to a preset ratio and mapped to the finite field Z before cryptographic operations. p Simultaneously, the quantization scale is recorded; after the retrieval is completed, as long as the quantization value does not undergo finite field modulus wrap-around, the similarity relationship between documents will remain consistent with the plaintext calculation result.
[0025] A generates its own public and private key pair, S2 generates and stores the IPFE master key, generates random vectors a and b and encrypts them before sending them to A, and A decrypts them to obtain random vectors a and b.
[0026] A generates a public / private key pair (pk) A ,sk A ); S2 generates a, b∈Z according to the knowledge base version or retrieval period. p l PK using A's public key A Encrypt a and b, and send them to A. A uses the private key sk. A Decryption yields random vectors a and b; Random vector a is used for the knowledge-side mask, and random vector b is used for the query-side mask. S1 does not participate in the generation and distribution of random vectors a and b, and does not obtain the plaintext of random vectors a and b.
[0027] S2 regenerates a and b in each knowledge base version or each preset retrieval cycle to achieve periodic rotation of the mask vector. The retrieval cycle is set according to the knowledge base size, query frequency, and security level, and can be triggered at fixed time intervals (e.g., hourly, daily) or based on the cumulative number of queries (e.g., every 100 queries), with the earlier triggering condition taking precedence. After the cycle arrives, S2 regenerates a, b, and the corresponding function keys K1 and K2, which are then encrypted with the public key A and sent. After A decrypts the encryption, it replaces the old mask vector stored locally, and S1 simultaneously replaces the function key. The mask vector and key of the previous cycle then become invalid. Periodic rotation ensures that even if the mask vector or key of a certain cycle is leaked due to abnormal circumstances, its impact is limited to the ciphertext generated within that cycle and will not affect the knowledge ciphertext and query ciphertext of other cycles. S2 uses A's public key pk A After encrypting a and b, they are sent through an authenticated encrypted channel. A uses the private key sk. A After decryption, the data is securely stored locally. Random vector 'a' is specifically used for the knowledge-side vector mask, and random vector 'b' is specifically used for the query-side vector mask. The two mask vectors are different, and S1 does not know the plaintext of either mask vector. Although S2 generates 'a' and 'b', it does not obtain the knowledge ciphertext and query ciphertext stored by S1. Although S1 performs encrypted computation, it does not hold 'a' and 'b' or the IPFE master key. This separation of mask generation and ciphertext computation makes it impossible for a single server to recover the original vector by combining the information.
[0028] A encodes knowledge documents into knowledge vectors through an embedding model, samples random scalars, masks the knowledge vectors with random vector a, generates knowledge side vector ElGamal ciphertext and IPFE auxiliary ciphertext, and sends them to S1; A sample random scalar r i ∈Z pThe knowledge vector d is obtained by random vector a. i Masking, generating knowledge side vectors ElGamal ciphertext ct i =([r i ]1,[d i +a·r i ]1); Among them, [d i +a·r i ]1 indicates that each component of the vector is encoded into group G1, and the random term a·r i In hidden d i At the same time, it preserves the algebraic structure required for bilinear mapping; A synchronously generates the authorized output as d. i ^TFb·s Knowledge Side IPFE Auxiliary Ciphertext C i ¹, the C i ¹An auxiliary ciphertext pool can be generated online or pre-generated offline. A will ct i C i ¹ The document identifier, knowledge base version, and integrity summary are sent to S1. After verification by S1, an index is created, but the plaintext knowledge vector is not saved.
[0029] Each knowledge document uses an independent random scalar r i To prevent the leakage of related information between documents due to mask correlation; ct i It contains two items: [r i ]1 represents the random factor commitment, [d i +a·r i ]1 is a·r i The knowledge vector group elements after one-time masking; a·r i In hidden d i At the same time, the masked vector still retains the linear algebraic structure on group G1, and S1 can then perform a bilinear mapping on it. C i ¹This function hides the IPFE auxiliary ciphertext, and its authorized output is fixed as d. i ^TFb·s means only releasing the inner product value required for subsequent redundant term elimination, without leaking d. i itself; C i ¹It can be generated online by a trusted terminal that still holds the knowledge vector during each query, or multiple auxiliary ciphertext pools corresponding to query sessions can be pre-generated offline during the knowledge base initialization phase. After the knowledge base is uploaded, only the protected auxiliary data is retained, thereby reducing the latency of password operations during the online phase; A. A document identifier DocID is attached when uploaded. i The knowledge base version number and integrity summary are used. After verifying the integrity of the message, S1 establishes an index relationship between the ciphertext and the document identifier, and does not save the plaintext of the knowledge vector.
[0030] S2 generates function keys K1 and K2 based on the bilinear parameter matrix F and random vectors a and b, and sends them to S1. S2 generates K1=IPFE.KeyGen(Fb) and K2=IPFE.KeyGen(Fb) based on the bilinear parameter matrix F, random vectors a and b. T a,a T Fb), K1 is used to obtain the knowledge-side redundant inner product d. i T Fb·s, K2 is used to obtain the query-side redundant inner product (a·r) i ) T Fq+(a·r i ) T Fb·s; K1 and K2 only support outputting authorized redundant inner product results and do not have the ability to recover the original vectors and function matrix parameters. K1 and K2 are bound to the knowledge base version, parameter version and expiration date before sending to S1.
[0031] K1 targets the knowledge-side IPFE auxiliary ciphertext C i ¹Use, S1 with K1 against C i ¹After performing IPFE calculation, D1 is obtained. i =d i T Fb·s, i.e., Raw i The second term in the expansion; K2 refers to the auxiliary ciphertext C for the query-side IPFE. i 2 Using S1 with K2 against C i 2 D2 was obtained after calculation. i These correspond to the third and fourth terms in the Rawi expansion; both function keys can only output the redundant inner product value authorized by the protocol and cannot recover the original vector d. i And q, cannot restore the parameters of the function matrix F; K1 and K2 are bound to the knowledge base version, parameter matrix version and validity period. After the version is updated or the key expires, the old key will automatically become invalid. S1 refuses to use the expired key to perform the retrieval.
[0032] A uses the same embedding model to encode the query to obtain the query vector, samples a random scalar, masks the query vector with a random vector b, generates the query side vector ElGamal ciphertext and IPFE auxiliary ciphertext, and sends them to S1; A sample query for a random s ∈ Z p The query vector q is masked by a random vector b and encoded into group G2 using the ElGamal method corresponding to the knowledge side, generating the ElGamal ciphertext of the query side vector. A synchronously generates the authorized output as (a·r) i ) TFq+(a·r i ) TFb ·s query side IPFE auxiliary ciphertext C i 2 Multi-document r i Related auxiliary quantities can be generated using batch processing or vector packaging; A will query the ciphertext, C i 2 Send S1 with the session identifier, knowledge base version, and expected return quantity k.
[0033] The query vector q is encoded using the exact same embedding model as the knowledge document, ensuring that they reside in the same vector space. The query random scalar s is sampled independently for each query, and after applying a one-time mask to q using b·s, it is encoded into group G2 to form ct. q = ([s]2, [q+b·s]2); The knowledge side is encrypted to G1, and the query side is encrypted to G2. This asymmetric group design makes the bilinear mapping e:G1×G2→G T It can be executed on both sides of the ciphertext, and the plaintext vector cannot be recovered from either side of the ciphertext alone; C i 2 The authorized output includes (a·r i ) TFq and (a·r) i ) TFb ·s two items, where r i Let r be a random scalar of the i-th knowledge document; when the knowledge base is large, the r corresponding to multiple documents... i Related auxiliary quantities can be generated all at once through batch processing or vector packaging, reducing the computational overhead per document; when submitting a query, A includes the query session identifier, knowledge base version number (ensuring consistency with the current index version of S1), and the expected number of returns k.
[0034] S1 uses the bilinear parameter matrix F to perform a bilinear mapping on the ElGamal ciphertext of the knowledge-side and query-side vectors. The IPFE auxiliary ciphertext of the knowledge-side and query-side vectors is decrypted using function keys K1 and K2 respectively to obtain two types of mask redundancy terms. After canceling all redundancy terms, the ciphertext bilinear similarity is obtained.
[0035] S1 performs a bilinear mapping on each knowledge document i using F on both sides of the ElGamal ciphertext, expanding it into Raw. i =(d i +a·r i ) T F(q+b·s)=d i T Fq+d i T Fb·s+ (a·r i) T Fq+(a·r i ) T Fb·s, where the first term is the bilinear similarity of the target and the other three terms are mask redundancy terms; S1 uses K1 against C i ¹Calculation yields D1 i =d i T Fb·s, with K2 versus C i 2 D2 was calculated i =(a·r i ) T Fq+(a·r i ) T Fb·s, and calculate Sim i =Raw i D1 i D2 i =d i T Fq, S1 does not obtain d i q, a, b, r i ,s plaintext.
[0036] Bilinear mapping applies only to ElGamal ciphertexts with two bilateral vectors, not to IPFE auxiliary ciphertexts; Raw i In the four-term expansion, the first term d i T Fq is the bilinear similarity between the target and plaintext, and the second term d i T Fb·s is introduced by the knowledge-side mask a and the query randomness s, the third term (a·r) i ) T Fq is determined by the knowledge random quantity r i Introduced with the query-side mask b, the fourth term (a·r) i ) T Fb·s is the intersection of the two-sided mask and the random quantity; S1 is K1 paired with C i ¹D1 is calculated i Precisely eliminate the second term; use K2 against C i 2 D2 was calculated i The third and fourth terms are precisely eliminated; after eliminating the three redundant terms, Sim... i Equal to d i T Fq, and the random scalar r i , s, and the mask vectors a and b are independent; This scheme does not use approximate calculations or random perturbations to obtain similarity, but rather precisely recovers the calculation results that are completely consistent with the plaintext bilinear model within the cryptographic domain. Under the condition that vector quantization does not cause overflow or finite-field module wrapping, the cryptographic similarity relationships of each knowledge document are strictly consistent with the plaintext calculation results, and the selection and ranking of Top-k documents remain unchanged due to the privacy protection process. S1 only accesses the ciphertext and authorized inner product values throughout the entire calculation process, without obtaining d... i q, a, b, r i The plaintext of s.
[0037] S1 sorts the documents in descending order based on dense bilinear similarity, selects the top k document identifiers and sends them back to A. A recovers the corresponding knowledge content, constructs prompt words based on the original query, and calls the large language model to generate question-and-answer results.
[0038] S1 sorts all valid knowledge documents in descending order by their encrypted bilinear similarity and returns the top k document identifiers, encrypted document content, or controlled access addresses. When the knowledge document body is encrypted with a symmetric key, S1 only returns the ciphertext and access credentials, and A decrypts it locally; A combines the user's original question, Top-k knowledge fragments, knowledge source identifiers, and prompt templates into a large language model input, and calls a local or controlled large language model to generate an answer.
[0039] S1 Sim for all valid knowledge documents i Perform descending sorting and select the top k documents with the highest similarity; the return format includes three types: document identifier (A finds the plaintext in the local knowledge base), encrypted document content (A decrypts locally using a symmetric key), and controlled access address (A accesses according to permissions); when the knowledge document text itself needs to be kept confidential, the text is encrypted and stored in S1 using a symmetric key, and S1 only returns the ciphertext and access credentials. A decrypts it locally and constructs a large language model input. S1 never touches the knowledge document text. A combines the user's original question, Top-k knowledge fragments, knowledge source identifiers, and prompt templates into the input of the large language model. The prompt templates specify how the large language model uses the retrieved knowledge, how to cite sources, and the rejection strategy when knowledge is insufficient. The large language model is deployed locally on A or in a controlled environment. The user's query and retrieval content do not leave A. The large language model generates answers based on external knowledge to avoid factual errors caused by untimely updates of model parameters or insufficient coverage of professional fields.
[0040] Establish version control and security audit mechanisms.
[0041] The version management and security audit mechanism includes: when adding or modifying a document, A encrypts the new knowledge vector and submits the new version ciphertext and integrity digest; when deleting a document, A submits a signed deletion instruction; after verification by S1, the corresponding ciphertext index is deleted; the knowledge base version and the bilinear parameter matrix version are identified and isolated from each other. When S1 detects a mismatch in knowledge base version, an expired function key, inconsistent ciphertext dimensions, an invalid message signature, an excessive timestamp, or a duplicate query session, it refuses to execute the retrieval operation and records the corresponding security event. S1 and S2 respectively store audit logs that do not contain query plaintext and knowledge plaintext, recording session identifier, knowledge base version, parameter version, query time, number of returns, execution status and message digest.
[0042] When adding or modifying documents in the knowledge base, A performs the same encryption process as knowledge encryption upload on the new knowledge vector, submits the new version of ciphertext and integrity digest, and updates the index after verification by S1; when deleting documents, A submits a digitally signed deletion command, and deletes the corresponding ciphertext index after verifying the validity of the signature; the knowledge base version and the version of the bilinear parameter matrix F are identified and isolated from each other, and updating F does not affect the existing ciphertext, and updating the ciphertext does not affect F; S1 performs six security checks before executing a search: whether the knowledge base version is consistent with the query submission version, whether the function key is within its validity period, whether the encrypted dimension matches the parameter matrix dimension, whether the message signature is valid, whether the timestamp exceeds the preset window, and whether the query session identifier is duplicated; if any check fails, the search operation will be refused and a security event will be recorded. S1 and S2 store audit logs respectively; the S1 log records the session identifier, knowledge base version, parameter version, query time, number of returns, execution status, and message digest; the S2 log records key generation and distribution records, and version changes; neither type of log contains query plaintext or knowledge plaintext. After the query is completed, A and S1 clear the query random variable s, temporary IPFE auxiliary data, and intermediate bilinear mapping results according to the security policy; in high-risk scenarios such as medical, power, and financial industries, the output of the large language model is only used as an auxiliary result, and a manual review process is set up.
[0043] To meet the online retrieval needs of large-scale knowledge bases, the present invention can employ the following efficiency optimization methods, which can be combined.
[0044] The parameter matrix F is decomposed into a low-rank factorization F=UV T The bilinear similarity calculation is transformed into a two-stage multiplication in a lower-dimensional space, reducing storage and computational overhead from O(l²) to O(lr). Encrypted clustering of knowledge vectors is performed; during querying, candidate clusters are first selected from the encrypted cluster centers, and then precise bilinear matching is performed within the candidate clusters, reducing the linear scan complexity from O(n) to approximately O(k).c +n / k c ), where k c The number of clusters is determined by the number of clusters. Knowledge side vector encoding, random masking, ciphertext generation, and IPFE-assisted ciphertext pool pre-generation are all performed offline preprocessing, executed only during knowledge base initialization or updates, and are not repeated during online querying. Bilinear mapping and IPFE computation between different documents are independent and can be executed in parallel using batch processing, multithreading, GPU, or SIMD methods. S1 sets version caching for function keys and public parameters, reusing verified parameters when F is not updated to avoid duplicate acquisition. The system adaptively adjusts the embedding dimension l, bilinear rank r, return quantity k, and group parameter security level according to the knowledge base size, latency requirements, and security strength.
[0045] Example 1: Enterprise Internal Knowledge Base Question and Answer System A company has built a private knowledge base containing product technical documents, business policies, fault logs, project materials, and internal operation manuals, and provides internal question-and-answer services through a large language model intelligent agent. The knowledge base is deployed on the cloud S1, but the company does not allow the cloud service provider to obtain document vectors and employee query intents.
[0046] Enterprise A divides documents into chunks based on fixed lengths or semantic boundaries, and encodes each document chunk into a 512-dimensional knowledge vector d using the same embedding model. i And quantized to Z p F is decomposed into a low-rank factorization of rank 32, obtained by training on relevant documents from enterprise history queries; S2 generates random vectors a and b and sends them encrypted using the public key A; A samples r for each knowledge vector. i Generate ct i =([r i ]1,[d i +a·r i ]1) and C i ¹, Upload S1 along with the document identifier, and store the document body after symmetric encryption using the enterprise data key.
[0047] After the employee inputs the question, A encodes the question as q, samples s, and generates ct. q = ([s]2, [q+b·s]2) and C i 2 Send S1; S1 performs a bilinear mapping on each knowledge ciphertext, using K1 and K2 to eliminate redundant terms to obtain Sim. i =d i TFq returns the top 5 document blocks with the highest similarity; A decrypts the document blocks locally, combines the employee's question, the top 5 knowledge fragments, and the source of the reference into a prompt template, and calls the enterprise's large language model to generate an answer; the audit log only records the query session identifier, knowledge base version, returned document identifier, and execution status, and does not record the question in plaintext.
[0048] Example 2: Medical Knowledge and Case-Based Question and Answer System The hospital has constructed a knowledge base from clinical guidelines, drug instructions, desensitized case summaries, and internal treatment pathways. Doctors' queries may include patient conditions, test results, and treatment plans; the knowledge vectors may also reflect case details. The system performs a dense-state bilinear retrieval on both the query vectors and the knowledge vectors. S1 is deployed in the hospital's private cloud, while S2 is deployed in an independent key management area or a supervised trusted service node, ensuring separation of management domains and permissions between S1 and S2. The returned Top-k documents are only decrypted at the doctor's workstation, and access control tags and knowledge source identifiers are added when generating answers. The system does not allow search results to automatically replace doctor diagnoses; manual review is required for high-risk scenarios. Example 3: Power Operation and Maintenance Knowledge Retrieval Power companies build an operation and maintenance knowledge base by compiling operating procedures, maintenance procedures, equipment manuals, historical defect records, and accident cases; operation and maintenance personnel input equipment numbers, alarm phenomena, and operating conditions, and the intelligent agent retrieves relevant procedures and historical cases; The knowledge vector and query vector contain sensitive information about equipment and production operations, and relevance calculations are completed through privacy retrieval on dual servers; F is trained by the relevant labeled data between equipment type, alarm keywords and fault causes to model the interaction between different semantic dimensions; the retrieval results are used to generate inspection suggestions, fault cause ranking and relevant procedure references, and do not directly issue control commands; suggestions involving equipment isolation, protection settings and unit operation must be reviewed by authorized personnel.
[0049] Example of parameter selection The knowledge vector dimension l can be 256, 512, 768, or 1024, consistent with the output dimension of the embedding model; F is a full matrix or a low-rank matrix with a rank of 16 to 64, representing a trade-off between expressive power, storage, and computational overhead; the number of returned documents k ranges from 3 to 20, selected based on the prompt template length and question-answering task requirements; the password security strength is at least 128 bits, selected based on the business sensitivity level and password compliance requirements; the knowledge base size n ranges from 10³ to 10⁻⁶. 6 Individual document blocks, large-scale scenarios combined with clustering or partition retrieval; S1 is deployed in the cloud retrieval area, and S2 is deployed in an independent key area to ensure separation of management domain and permissions.
[0050] Replaceable implementation The ElGamal vector can be replaced by other public-key encryption schemes that meet the requirements of random linear masking and bilinear compatibility; the function hiding IPFE can be replaced by other functional encryption schemes that can output only the specified inner product and hide the input vector and function vector; S2 can be an independent physical server, hardware security module, key management center, or a distributed key service jointly operated by multiple parties, as long as S2 does not share the internal secret state with S1 and does not obtain knowledge or query ciphertext, it is an equivalent implementation of the present invention; the bilinear parameter matrix F can be generated by offline training, or it can be derived from rules, domain weights, or existing re-ranking models; different F can be configured for different knowledge domains and isolated using parameter version identifiers; the embedding model can be replaced by BERT, Word2Vec, or a domain-specific embedding model; the large language model can be replaced by models with different parameter scales or from different vendors, and the deployment method can be local inference or controlled API calls.
[0051] Figure 1 This is a schematic diagram of the method steps of the present invention; Figure 2 This is a diagram of the privacy protection system architecture for enhanced retrieval based on bilinear similarity of the present invention, showing the functional division of A, S1 and S2, message flow and non-collusion trust boundary; no single server can simultaneously obtain the knowledge ciphertext, query ciphertext, random encoding and all auxiliary parameters; Figure 3 This is a flowchart of the overall privacy retrieval process based on bilinear similarity of the present invention. It is divided into offline and online stages, and shows the execution sequence of key distribution, knowledge uploading, parameter provision, query submission, result return, and retrieval enhancement output generation in sequence. The offline stage completes knowledge vector encoding, encryption, and uploading, while the online stage completes query encryption, cryptographic similarity calculation, sorting, and response generation. Figure 4 This is a schematic diagram of the dense-state bilinear similarity calculation and redundancy elimination of the present invention. It shows the process of inputting ciphertext on the knowledge side and ciphertext on the query side, expanding the calculation through bilinear mapping, and combining the IPFE authorization output to eliminate the redundancy introduced by the mask, so as to obtain the final similarity calculation process. The server S1 can only obtain the similarity value obtained by authorization and cannot recover the plaintext of the query vector and knowledge vector. Figure 5 This is a diagram showing the encrypted submission relationship between the knowledge vector and the query vector of the present invention, illustrating the vector encoding, random mask, ElGamal ciphertext, IPFE auxiliary ciphertext, and S1 input on the knowledge side and the query side; Figure 6 This invention provides a privacy-preserving retrieval enhancement generation business process diagram, illustrating the relationship between user query, agent encryption, dual-server encrypted retrieval, Top-k knowledge return, and large language model generation; it is applicable to sensitive RAG scenarios such as enterprise knowledge bases, medical Q&A, financial analysis, government affairs retrieval, and power operation and maintenance.
[0052] The above description, in conjunction with specific preferred embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such modifications and substitutions should be considered within the scope of protection of the present invention.
Claims
1. A privacy-preserving method for enhanced retrieval generation based on bilinear similarity, wherein the method is collaboratively executed by an intelligent agent terminal A, a retrieval server S1, and an auxiliary server S2, with S1 and S2 not colluding with each other, characterized in that, include: Construct bilinear group parameters, initialize vector ElGamal encryption and function hidden inner product encryption IPFE, A generates its own public and private key pair, S2 generates IPFE master key and keeps it, generates random vectors a and b and encrypts them and sends them to A, A decrypts them to get random vectors a and b, and establishes version management and security audit mechanism. A encodes knowledge documents into knowledge vectors through an embedding model, samples random scalars, masks the knowledge vectors with random vector a, generates knowledge side vector ElGamal ciphertext and IPFE auxiliary ciphertext, and sends them to S1; S2 generates function keys K1 and K2 based on the bilinear parameter matrix F and random vectors a and b, and sends them to S1. A uses the same embedding model to encode the query to obtain the query vector, samples a random scalar, masks the query vector with a random vector b, generates the query side vector ElGamal ciphertext and IPFE auxiliary ciphertext, and sends them to S1; S1 uses the bilinear parameter matrix F to perform bilinear mapping on the ElGamal ciphertext of the knowledge-side and query-side vectors. The IPFE auxiliary ciphertext of the knowledge-side and query-side vectors is decrypted using function keys K1 and K2 respectively to obtain two types of mask redundancy terms. After canceling all redundancy terms, the cipher-state bilinear similarity is obtained. S1 sorts the documents in descending order based on dense bilinear similarity, selects the top k document identifiers and sends them back to A. A recovers the corresponding knowledge content, constructs a prompt template based on the original query, and calls the large language model to generate question-and-answer results.
2. The privacy-preserving retrieval enhancement method based on bilinear similarity according to claim 1, characterized in that, The construction of the bilinear group parameters includes: establishing asymmetric bilinear group parameters (G1, G2, G...). T Given a cyclic group G1 and G2 of prime order, where P1 and P2 are generators, and e: G1 × G2 → G T It is a bilinear mapping, and the elements in the group are denoted by [x]1=xP1, [x]2=xP2, where x is a finite field Z. p Any scalar in the middle; The vector ElGamal encryption is based on the DDH assumption, and the function-hidden IPFE is based on the SXDH assumption.
3. The privacy-preserving retrieval enhancement method based on bilinear similarity according to claim 1, characterized in that, A generates a public / private key pair (pk) A ,sk A ); S2 generates a, b∈Z according to the knowledge base version or retrieval period. p l PK using A's public key A Encrypt a and b, and send them to A. A uses the private key sk. A Decryption yields random vectors a and b; Random vector a is used for the knowledge-side mask, and random vector b is used for the query-side mask. S1 does not participate in the generation and distribution of random vectors a and b, and does not obtain the plaintext of random vectors a and b.
4. The privacy-preserving retrieval enhancement method based on bilinear similarity according to claim 1, characterized in that, A uses an embedding model to encode knowledge documents and user queries into l-dimensional vectors of the same dimension, d. i and q; The bilinear parameter matrix F is obtained by training on labeled query-document pairs or derived from an existing retrieval model. F is an l×l matrix or low-rank decomposition is used to reduce storage and computational overhead. Floating-point vectors and matrix parameters are quantized into a finite field Z according to a preset ratio. p The integers in the similarity scale are recorded, and the similarity relationship remains unchanged without modulus wrap-around.
5. The privacy-preserving retrieval enhancement method based on bilinear similarity according to claim 1, characterized in that, A sample random scalar r i ∈Z p The knowledge vector d is obtained by random vector a. i Masking, generating knowledge side vectors ElGamal ciphertext ct i =([r i ]1,[d i +a·r i ]1); Among them, [d i +a·r i ]1 indicates that each component of the vector is encoded into group G1, and the random term a·r i In hidden d i At the same time, it preserves the algebraic structure required for bilinear mapping; A synchronously generates the authorized output as d. i ^TFb·s Knowledge Side IPFE Auxiliary Ciphertext C i ¹, the C i ¹An auxiliary ciphertext pool can be generated online or pre-generated offline. A will ct i C i ¹ The document identifier, knowledge base version, and integrity summary are sent to S1. After verification by S1, an index is created, but the plaintext knowledge vector is not saved.
6. The privacy-preserving retrieval enhancement method based on bilinear similarity according to claim 1, characterized in that, S2 generates K1=IPFE.KeyGen(Fb) and K2=IPFE.KeyGen(Fb) based on the bilinear parameter matrix F, random vectors a and b. T a,a T Fb), K1 is used to obtain the knowledge-side redundant inner product d. i T Fb·s, K2 is used to obtain the query-side redundant inner product (a·r) i ) T Fq+(a·r i ) T Fb·s; K1 and K2 only support outputting authorized redundant inner product results and do not have the ability to recover the original vectors and function matrix parameters. K1 and K2 are bound to the knowledge base version, parameter version and expiration date before sending to S1.
7. The privacy-preserving retrieval enhancement method based on bilinear similarity according to claim 1, characterized in that, A sample query for a random s ∈ Z p The query vector q is masked by a random vector b and encoded into group G2 using the ElGamal method corresponding to the knowledge side, generating the ElGamal ciphertext of the query side vector. A synchronously generates the authorized output as (a·r) i ) TFq +(a·r i ) TFb ·s query side IPFE auxiliary ciphertext C i 2 Multi-document r i Related auxiliary quantities can be generated using batch processing or vector packaging; A will query the ciphertext, C i 2 Send S1 with the session identifier, knowledge base version, and expected return quantity k.
8. The privacy-preserving retrieval enhancement method based on bilinear similarity according to claim 1, characterized in that, S1 performs a bilinear mapping on each knowledge document i using F on both sides of the ElGamal ciphertext, expanding it into Raw. i =(d i +a·r i ) T F(q+b·s)=d i T Fq+d i T Fb·s+ (a·r i ) T Fq+(a·r i ) T Fb·s, where the first term is the bilinear similarity of the target and the other three terms are mask redundancy terms; S1 uses K1 against C i ¹Calculation yields D1 i =d i T Fb·s, with K2 versus C i 2 D2 was calculated i =(a·r i ) T Fq+(a·r i ) T Fb·s, and calculate Sim i =Raw i D1 i D2 i =d i T Fq, S1 does not obtain d i q, a, b, r i ,s plaintext.
9. The privacy-preserving retrieval enhancement method based on bilinear similarity according to claim 1, characterized in that, S1 sorts all valid knowledge documents in descending order by their encrypted bilinear similarity and returns the top k document identifiers, encrypted document content, or controlled access addresses. When the knowledge document body is encrypted with a symmetric key, S1 only returns the ciphertext and access credentials, and A decrypts it locally; A combines the user's original question, Top-k knowledge fragments, knowledge source identifiers, and prompt templates into a large language model input, and calls a local or controlled large language model to generate an answer.
10. The privacy-preserving retrieval enhancement method based on bilinear similarity according to claim 1, characterized in that, The version management and security audit mechanism includes: when adding or modifying a document, A encrypts the new knowledge vector and submits the new version ciphertext and integrity digest; when deleting a document, A submits a signed deletion instruction; after verification by S1, the corresponding ciphertext index is deleted; the knowledge base version and the bilinear parameter matrix version are identified and isolated from each other. When S1 detects a mismatch in knowledge base version, an expired function key, inconsistent ciphertext dimensions, an invalid message signature, an excessive timestamp, or a duplicate query session, it refuses to execute the retrieval operation and records the corresponding security event. S1 and S2 respectively store audit logs that do not contain query plaintext and knowledge plaintext, recording session identifier, knowledge base version, parameter version, query time, number of returns, execution status and message digest.
