Feature data encryption method and device, equipment and storage medium
By splitting and linearly transforming the embedded vector to generate the encryption result, the problem of insufficient security of the embedded vector is solved, and the data security is enhanced without affecting the retrieval function.
Patent Information
- Application Number
- CN202511224948.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-29
- Publication Date
- 2025-10-17
AI Technical Summary
Existing technologies are difficult to effectively enhance the security of embedded vectors while ensuring retrieval functions, and there is a risk of user privacy leakage.
The vector to be encrypted is split into the first and second sub-vectors through a preset embedding model, and is encrypted using a preset linear transformation method to generate encrypted sub-vectors that are then spliced together to form feature data encryption results that are stored in a database.
Without affecting the retrieval efficiency, the security of feature data is significantly enhanced and the risk of data leakage is reduced. At the same time, the geometric relationship between vectors is maintained, ensuring the effectiveness of similarity retrieval.
Smart Images

Figure CN120805162A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data security, and in particular to a feature data encryption method, device, equipment and storage medium. BACKGROUND
[0002] With the rapid development of artificial intelligence technology, especially the progress in the fields of machine learning and deep learning, embedding vectors as feature data of information have become increasingly important in applications. In many application scenarios, embedding vectors are widely used in tasks such as support vector retrieval, clustering, and recommendation systems. For example, in the field of natural language processing, retrieval-enhanced generation technology encodes input requests as query vectors and compares them with embedding vectors in a knowledge base to achieve the task of text generation. However, although embedding vectors are considered difficult to reverse to the original plaintext, there are still security risks in practice. Specifically, even without a specific embedding model, embedding vectors can be converted back to plaintext through Vec2Text, which may lead to user privacy leakage. Therefore, it is necessary to effectively protect the security of feature data. Existing solutions often focus on increasing algorithm complexity or adding additional security layers, but few can provide sufficient security protection without significantly affecting retrieval efficiency.
[0003] In summary, how to enhance the security of feature data while ensuring retrieval function is a technical problem to be solved at present. SUMMARY
[0004] Therefore, the purpose of the present application is to provide a feature data encryption method, device, equipment and storage medium, which can enhance the security of feature data while ensuring the retrieval function. The specific scheme is as follows:
[0005] In a first aspect, the present application provides a feature data encryption method, comprising:
[0006] determining a to-be-encrypted vector corresponding to to-be-encrypted data using a preset embedding model; the to-be-encrypted data includes image data or text data; correspondingly, the to-be-encrypted vector is a to-be-encrypted image vector or a to-be-encrypted text vector;
[0007] splitting the to-be-encrypted vector based on a preset vector splitting rule to obtain a first to-be-encrypted sub-vector and a second to-be-encrypted sub-vector;
[0008] linearly transforming the first to-be-encrypted sub-vector and the second to-be-encrypted sub-vector based on a preset linear transformation method to obtain corresponding first encrypted sub-vectors and second encrypted sub-vectors;
[0009] concatenate the first encrypted sub-vector and the second encrypted sub-vector to obtain a feature data encryption result corresponding to the image data or the text data, and store the feature data encryption result into a preset database.
[0010] Optionally, the feature data encryption method further comprises:
[0011] determining a dimension corresponding to the vector to be encrypted;
[0012] randomly generating a target segmentation random number of a corresponding dimension based on the dimension corresponding to the vector to be encrypted; a component corresponding to any dimension in the target segmentation random number is 0 or 1;
[0013] generating a target orthogonal matrix used for performing the linear transformation based on a preset random number and the dimension corresponding to the vector to be encrypted; wherein the target orthogonal matrix comprises a first orthogonal matrix and a second orthogonal matrix;
[0014] wherein the dimension of the target segmentation random number, the dimension corresponding to the first orthogonal matrix, and the dimension corresponding to the second orthogonal matrix are all the same as the dimension corresponding to the vector to be encrypted.
[0015] Optionally, the splitting the vector to be encrypted based on the preset vector splitting rule to obtain a first vector to be encrypted and a second vector to be encrypted comprises:
[0016] determining a first component corresponding to any dimension in the target segmentation random number;
[0017] determining a second component corresponding to the any dimension in the vector to be encrypted;
[0018] splitting the second component based on a target splitting rule corresponding to the first component and a preset multiple value to obtain a first splitting result and a second splitting result corresponding to the any dimension;
[0019] generating the first vector to be encrypted based on each first splitting result corresponding to each dimension, and generating the second vector to be encrypted based on each second splitting result corresponding to each dimension.
[0020] Optionally, the splitting the second component based on the target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to the any dimension comprises:
[0021] if the first component is 0, splitting the second component based on a first target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to the any dimension;
[0022] The first target splitting rule is used to control the numerical value corresponding to the first splitting result to be equal to the numerical value corresponding to the second splitting result, and the square sum between the numerical value corresponding to the first splitting result and the numerical value corresponding to the second splitting result is equal to the product between the square of the second component and the preset multiple value.
[0023] Optionally, the splitting of the second component based on the target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to the any dimension comprises:
[0024] If the first component is 1, the second component is split based on the second target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to the any dimension;
[0025] The second target splitting rule is used to control the sum of the numerical value corresponding to the first splitting result and the numerical value corresponding to the second splitting result to be equal to the second component, and the square sum between the numerical value corresponding to the first splitting result and the numerical value corresponding to the second splitting result is equal to the product between the square of the second component and the preset multiple value.
[0026] Optionally, the linear transformation of the first to-be-encrypted sub-vector and the second to-be-encrypted sub-vector based on the preset linear transformation method to obtain the corresponding first encrypted sub-vector and second encrypted sub-vector comprises:
[0027] The first to-be-encrypted sub-vector is orthogonally transformed based on the first orthogonal matrix to obtain the first encrypted sub-vector corresponding to the first to-be-encrypted sub-vector;
[0028] The second to-be-encrypted sub-vector is orthogonally transformed based on the second orthogonal matrix to obtain the second encrypted sub-vector corresponding to the second to-be-encrypted sub-vector.
[0029] Optionally, the feature data encryption method further comprises:
[0030] The preset embedding model is used to determine a to-be-retrieved vector corresponding to to-be-retrieved data; the to-be-retrieved data is image data or text data; correspondingly, the to-be-retrieved vector is a to-be-retrieved image vector or a to-be-retrieved text vector;
[0031] The to-be-retrieved vector is split to obtain a first to-be-retrieved sub-vector and a second to-be-retrieved sub-vector;
[0032] linearly transform the first to-be-retrieved sub-vector and the second to-be-retrieved sub-vector respectively to obtain a first encrypted to-be-retrieved sub-vector and a second encrypted to-be-retrieved sub-vector respectively;
[0033] splice the first encrypted to-be-retrieved sub-vector and the second encrypted to-be-retrieved sub-vector to obtain a to-be-retrieved vector encryption result corresponding to the to-be-retrieved data, and retrieve data in the preset database based on the to-be-retrieved vector encryption result.
[0034] In a second aspect, the present application provides a feature data encryption device, comprising:
[0035] a to-be-encrypted vector obtaining module configured to determine a to-be-encrypted vector corresponding to to-be-encrypted data by using a preset embedding model; the to-be-encrypted data comprises image data or text data; correspondingly, the to-be-encrypted vector is a to-be-encrypted image vector or a to-be-encrypted text vector;
[0036] a to-be-encrypted vector splitting module configured to split the to-be-encrypted vector based on a preset vector splitting rule to obtain a first to-be-encrypted sub-vector and a second to-be-encrypted sub-vector;
[0037] an encrypted sub-vector determining module configured to linearly transform the first to-be-encrypted sub-vector and the second to-be-encrypted sub-vector respectively based on a preset linear transformation method to obtain a first encrypted sub-vector and a second encrypted sub-vector respectively;
[0038] a feature data encryption result storage module configured to splice the first encrypted sub-vector and the second encrypted sub-vector to obtain a feature data encryption result corresponding to the image data or the text data, and store the feature data encryption result to a preset database.
[0039] In a third aspect, the present application provides an electronic device, comprising:
[0040] a memory configured to save a computer program;
[0041] a processor configured to execute the computer program to implement the feature data encryption method described above.
[0042] In a fourth aspect, the present application provides a computer readable storage medium configured to save a computer program; wherein the computer program is executed by a processor to implement the feature data encryption method described above.
[0043] In the present application, firstly, a preset embedding model is used to determine a to-be-encrypted vector corresponding to to-be-encrypted data; the to-be-encrypted data includes image data or text data; correspondingly, the to-be-encrypted vector is a to-be-encrypted image vector or a to-be-encrypted text vector; then, the to-be-encrypted vector is split based on a preset vector splitting rule to obtain a first to-be-encrypted sub-vector and a second to-be-encrypted sub-vector; subsequently, the first to-be-encrypted sub-vector and the second to-be-encrypted sub-vector are linearly transformed based on a preset linear transformation method to obtain corresponding first encrypted sub-vectors and second encrypted sub-vectors; finally, the first encrypted sub-vectors and the second encrypted sub-vectors are spliced to obtain a feature data encryption result corresponding to the image data or the text data, and the feature data encryption result is stored in a preset database. As can be seen from the above, in the present application, firstly, a preset embedding model is used to determine a to-be-encrypted vector corresponding to to-be-encrypted data, that is, to determine a to-be-encrypted image vector corresponding to image data or a to-be-encrypted text vector corresponding to text data; then, according to a preset vector splitting rule, the to-be-encrypted vector is split into a first to-be-encrypted sub-vector and a second to-be-encrypted sub-vector; then, a preset linear transformation method is used to linearly transform the two to-be-encrypted sub-vectors to obtain corresponding first encrypted sub-vectors and second encrypted sub-vectors; finally, the two encrypted sub-vectors are spliced to obtain a feature data encryption result corresponding to the image data or the text data, and the result is stored in a preset database. In this way, through the steps of vector conversion, splitting, linear transformation and splicing, the to-be-encrypted vector corresponding to the to-be-encrypted data can be encrypted, thereby enhancing the security of the feature data under the premise of ensuring the retrieval function. BRIEF DESCRIPTION OF DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor based on the provided drawings.
[0045] Figure 1 A feature data encryption method flowchart is provided for the present application;
[0046] Figure 2 A specific feature data retrieval flowchart is provided for the present application;
[0047] Figure 3 A feature data encryption device structure schematic diagram is provided for the present application;
[0048] Figure 4 A structure diagram of an electronic device is provided for the present application. DETAILED DESCRIPTION
[0049] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work are within the protection scope of the present application.
[0050] With the rapid development of artificial intelligence technology, especially the progress in the fields of machine learning and deep learning, embedding vectors, as feature data of information, have become increasingly important in applications. In many application scenarios, embedding vectors are widely used in tasks such as support vector retrieval, clustering, and recommendation systems. For example, in the field of natural language processing, retrieval-enhanced generation technology encodes input requests as query vectors and compares them with embedding vectors in a knowledge base to achieve the task of text generation. However, although embedding vectors are considered difficult to reverse into original plaintext, there are still security risks in practice. Specifically, even without a specific embedding model, embedding vectors can be converted back to plaintext through Vec2Text, which may lead to user privacy leakage. Therefore, it is necessary to effectively protect the security of feature data. Existing solutions often focus on increasing algorithm complexity or adding additional security layers, but few can provide sufficient security protection while not significantly affecting retrieval efficiency. To this end, the present application provides a feature data encryption scheme that can enhance the security of feature data while ensuring retrieval functionality.
[0051] Referring to Figure 1 The embodiments of the present application disclose a feature data encryption method, which can include:
[0052] Step S11, determining a to-be-encrypted vector corresponding to to-be-encrypted data by using a preset embedding model; the to-be-encrypted data includes image data or text data; correspondingly, the to-be-encrypted vector is a to-be-encrypted image vector or a to-be-encrypted text vector.
[0053] In the embodiment, first, a preset embedding model, such as Embedding Models, can be used to determine the to-be-encrypted image vector corresponding to the to-be-encrypted image data, or the to-be-encrypted text vector corresponding to the to-be-encrypted text data. In a specific implementation, the to-be-encrypted data is image data, such as medical image data. In the embodiment, first, a to-be-encrypted medical image vector corresponding to the medical image data can be generated, then a medical image feature data encryption result corresponding to the to-be-encrypted medical image vector is generated, and the medical image feature data encryption result is stored in a medical image database. In this way, the data in the medical image database can be searched according to the feature data encryption result corresponding to the to-be-searched medical image data. In another specific implementation, the to-be-encrypted data is text data, such as medical record text data. In the embodiment, first, a to-be-encrypted medical record text vector corresponding to the medical record text data can be generated, then a medical record feature data encryption result corresponding to the to-be-encrypted medical record text vector is generated, and the medical record feature data encryption result is stored in a medical record database. In this way, the data in the medical record database can be searched according to the feature data encryption result corresponding to the to-be-searched medical record text data.
[0054] Then, in the embodiment, it is necessary to determine the key material used to encrypt the to-be-encrypted vector. Specifically, first, the dimension corresponding to the to-be-encrypted vector V can be determined; then a target segmentation random number S of the corresponding dimension is randomly generated based on the dimension corresponding to the to-be-encrypted vector; the component corresponding to any dimension in the target segmentation random number is 0 or 1; then a target orthogonal matrix used to perform the linear transformation is generated based on the preset random number and the dimension corresponding to the to-be-encrypted vector; the target orthogonal matrix includes a first orthogonal matrix M1 and a second orthogonal matrix M2, and the product of the transpose matrix of the target orthogonal matrix and the target orthogonal matrix is a unit matrix. Wherein, the dimension of the target segmentation random number, the dimension corresponding to the first orthogonal matrix, and the dimension corresponding to the second orthogonal matrix are all the same as the dimension corresponding to the to-be-encrypted vector, so as to ensure that the subsequent linear transformation operation can be correctly performed. In this way, the key material composed of the target segmentation random number S, the first orthogonal matrix M1, and the second orthogonal matrix M2 can be obtained. In a specific implementation, for a 10-dimensional vector, the generated target segmentation random number S can be (0, 1, 0, 1, 1, 0, 0, 1, 1, 0).
[0055] In step S12, the to-be-encrypted vector is split based on a preset vector splitting rule to obtain a first to-be-encrypted sub-vector and a second to-be-encrypted sub-vector.
[0056] In this embodiment, the vector to be encrypted can be split according to a preset vector splitting rule corresponding to the target split random number to obtain a first sub-vector to be encrypted and a second sub-vector to be encrypted. Specifically, the first component corresponding to any dimension in the target split random number S can be first determined. Then, the second component corresponding to the any dimension in the vector to be encrypted V can be determined. The second component can then be split based on the target splitting rule corresponding to the first component and a preset multiplier value k to obtain a first split result and a second split result corresponding to any dimension. Finally, a first sub-vector to be encrypted is generated based on each first split result corresponding to each dimension, and a second sub-vector to be encrypted is generated based on each second split result corresponding to each dimension. Here, the first sub-vector to be encrypted V1 = (V11, V12, …, V1d), and the second sub-vector to be encrypted V2 = (V21, V22, …, V2d), where d is the dimension of the vector.
[0057] In a specific embodiment, the above-mentioned splitting of the second component based on the target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to any one dimension may include: if the first component is 0, then the second component is split based on the first target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to any one dimension; wherein the first target splitting rule is used to control the numerical value corresponding to the first splitting result to be equal to the numerical value corresponding to the second splitting result, and the sum of the squares between the numerical values corresponding to the first splitting result and the numerical values corresponding to the second splitting result is equal to the product between the square of the second component and the preset multiple value. Specifically, if the component corresponding to the current dimension i in the target splitting random number S is 0, that is, Si=0, then based on the first target splitting rule and the preset multiple value k, the component Vi corresponding to the current dimension i in the encrypted vector V is split to obtain the first splitting result V1i and the second splitting result V2i corresponding to the current dimension. At this time, the relationship between V1i, V2i and Vi is as follows:
[0058] .
[0059] In another specific embodiment, the splitting the second component based on the target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to any dimension includes: if the first component is 1, splitting the second component based on a second target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to any dimension; wherein the second target splitting rule is used to control the sum of the value corresponding to the first splitting result and the value corresponding to the second splitting result to be equal to the second component, and the square sum between the value corresponding to the first splitting result and the value corresponding to the second splitting result to be equal to the product between the square of the second component and the preset multiple value. Specifically, if the component corresponding to the current dimension i in the target partition random number S is 1, i.e. Si = 1, the component Vi corresponding to the current dimension i in the to-be-encrypted vector V is split based on the first target splitting rule and the preset multiple value k to obtain the first splitting result V1i and the second splitting result V2i corresponding to the current dimension. At this time, the relationship between V1i, V2i and Vi is as follows:
[0060] .
[0061] As can be seen from the above, when the to-be-encrypted vector V = (0.1, 0.2), S = (0, 1), and the preset multiple value k = 1: S1 = 0, the component corresponding to the first dimension in the to-be-encrypted vector can be split into ; S2 = 1, the component corresponding to the second dimension in the to-be-encrypted vector can be split into two values satisfying .
[0062] Step S13, linearly transforming the first to-be-encrypted sub-vector and the second to-be-encrypted sub-vector based on a preset linear transformation method to obtain a corresponding first encrypted sub-vector and a second encrypted sub-vector.
[0063] In the embodiment, the linearly transforming the first to-be-encrypted sub-vector and the second to-be-encrypted sub-vector based on the preset linear transformation method to obtain the corresponding first encrypted sub-vector and the second encrypted sub-vector can include: orthogonally transforming the first to-be-encrypted sub-vector based on the first orthogonal matrix to obtain the first encrypted sub-vector corresponding to the first to-be-encrypted sub-vector; orthogonally transforming the second to-be-encrypted sub-vector based on the second orthogonal matrix to obtain the second encrypted sub-vector corresponding to the second to-be-encrypted sub-vector. Specifically, multiplying the first to-be-encrypted sub-vector V1 and the transpose of the first orthogonal matrix M1 to obtain the first encrypted sub-vector VV1, i.e. ; and multiplying the second to-be-encrypted sub-vector V2 with the transpose of the second orthogonal matrix M2 to obtain a second encrypted sub-vector VV2, i.e. In a specific embodiment, for a 10-dimensional vector V1=(0.0707, 0.1414, 0.2121, 0.2828, 0.3536, 0.4243, 0.4950, 0.5657, 0.6364, 0.7071), after the orthogonal transformation corresponding to M1, it can become VV1=(0.120, 0.135, 0.150, 0.165, 0.180, 0.195, 0.210, 0.225, 0.240, 0.255).
[0064] Due to the properties of the orthogonal matrix, the above linear transformation can maintain the distance relationship between vectors, which is crucial for subsequent similarity retrieval.
[0065] In step S14, the first encrypted sub-vector and the second encrypted sub-vector are spliced to obtain a feature data encryption result corresponding to the image data or the text data, and the feature data encryption result is stored in a preset database.
[0066] In this embodiment, the first encrypted sub-vector VV1 and the second encrypted sub-vector VV2 can be spliced to obtain a feature data encryption result VV, i.e., a ciphertext vector corresponding to the to-be-encrypted vector. Then, the feature data encryption result can be sent to a server, and the server stores the feature data encryption result in a vector database for vector retrieval. This embodiment is applicable to all vector databases. This step completes the encryption storage process of the vector, and lays a foundation for subsequent secure retrieval. Since the server only needs to store the encrypted vector and does not need to know the original vector information and the encryption key, the risk of data leakage is greatly reduced. At the same time, since the encryption process maintains the geometric relationship between vectors, the server can still effectively perform a similarity retrieval operation.
[0067] Referring to Figure 2As shown, in order to retrieve data in the preset database according to the data to be retrieved, in the embodiment, firstly, the preset embedding model can be used to determine the to-be-retrieved vector corresponding to the data to be retrieved; the data to be retrieved is image data or text data; correspondingly, the to-be-retrieved vector is a to-be-retrieved image vector or a to-be-retrieved text vector; then the to-be-retrieved vector needs to be split to obtain a first to-be-retrieved sub-vector and a second to-be-retrieved sub-vector; then the first to-be-retrieved sub-vector and the second to-be-retrieved sub-vector are linearly transformed respectively to obtain a corresponding first encrypted to-be-retrieved sub-vector and a second encrypted to-be-retrieved sub-vector; finally, the first encrypted to-be-retrieved sub-vector and the second encrypted to-be-retrieved sub-vector are spliced to obtain the to-be-retrieved vector encryption result corresponding to the data to be retrieved, and data in the preset database is retrieved based on the to-be-retrieved vector encryption result. Specifically, firstly, the preset embedding model EmbeddingModels can be used to determine the to-be-retrieved vector W corresponding to the data to be retrieved. Then, the target segmentation random number S can be used to split the to-be-retrieved vector W to obtain a first to-be-retrieved sub-vector W1 and a second to-be-retrieved sub-vector W2. Wherein, the first to-be-retrieved sub-vector W1=(W11, W12, …, W1d), the second to-be-retrieved sub-vector W2=(W21, W22, …, W2d), and d is the dimension of the vector.
[0068] In one specific embodiment, when splitting the to-be-retrieved vector W, if the component corresponding to the current dimension i in the target segmentation random number S is 0, i.e. Si=0, then according to the third target splitting rule and the preset multiple value k, the component Wi corresponding to the current dimension i in the to-be-retrieved vector W is split to obtain the splitting results W1i and W2i corresponding to the current dimension. At this time, the relationship between W1i, W2i and Wi is as follows:
[0069] .
[0070] In another specific embodiment, when splitting the to-be-retrieved vector W, if the component corresponding to the current dimension i in the target segmentation random number S is 1, i.e. Si=1, then according to the fourth target splitting rule and the preset multiple value k, the component Wi corresponding to the current dimension i in the to-be-retrieved vector W is split to obtain the splitting results W1i and W2i corresponding to the current dimension. At this time, the relationship between W1i, W2i and Wi is as follows:
[0071] .
[0072] Afterwards, the inverse matrix corresponding to the target orthogonal matrix can be used to perform linear transformation on the first and second to-be-retrieved sub-vectors respectively. Specifically, the first to-be-retrieved sub-vector W1 is multiplied by the transpose of the inverse matrix corresponding to the first orthogonal matrix M1 to obtain a first encrypted to-be-retrieved sub-vector WW1; the second to-be-retrieved sub-vector W2 is multiplied by the transpose of the inverse matrix corresponding to the second orthogonal matrix M2 to obtain a second encrypted to-be-retrieved sub-vector WW2. Then, the first and second encrypted to-be-retrieved sub-vectors WW1 and WW2 can be spliced to obtain the to-be-retrieved vector encryption result WW corresponding to the to-be-retrieved data. In this way, since the inner product and norm relationship of the encrypted vector is preserved, the server can use ANN (Approximate Nearest Neighbor Search) algorithm, cosine similarity algorithm, Euclidean distance algorithm, etc. to efficiently retrieve the data in the preset database without decrypting the original data. This design not only ensures data security but also does not affect retrieval efficiency, achieving a balance between security and practicality.
[0073] As can be seen from the above, in the embodiment, first, a preset embedding model is used to determine a to-be-encrypted vector corresponding to to-be-encrypted data; the to-be-encrypted data includes image data or text data; correspondingly, the to-be-encrypted vector is a to-be-encrypted image vector or a to-be-encrypted text vector; then, the to-be-encrypted vector is split based on a preset vector splitting rule to obtain a first to-be-encrypted sub-vector and a second to-be-encrypted sub-vector; subsequently, the first to-be-encrypted sub-vector and the second to-be-encrypted sub-vector are linearly transformed based on a preset linear transformation method to obtain corresponding first and second encrypted sub-vectors; finally, the first and second encrypted sub-vectors are spliced to obtain a feature data encryption result corresponding to the image data or the text data, and the feature data encryption result is stored in a preset database. As can be seen from the above, in the embodiment, first, a preset embedding model is used to determine a to-be-encrypted vector corresponding to to-be-encrypted data, i.e., a to-be-encrypted image vector corresponding to image data or a to-be-encrypted text vector corresponding to text data; then, the to-be-encrypted vector is split into a first to-be-encrypted sub-vector and a second to-be-encrypted sub-vector according to a preset vector splitting rule; then, the two to-be-encrypted sub-vectors are linearly transformed using a preset linear transformation method to obtain corresponding first and second encrypted sub-vectors; finally, the two encrypted sub-vectors are spliced to obtain a feature data encryption result corresponding to the image data or the text data, and the result is stored in a preset database. In this way, in the embodiment, through steps such as vector conversion, splitting, linear transformation, and splicing, the to-be-encrypted vector corresponding to the to-be-encrypted data can be encrypted, thereby enhancing the security of the feature data while ensuring the retrieval function.
[0074] Correspondingly, referring toFigure 3 As shown, the embodiment of the present application also provides a feature data encryption device, which can include:
[0075] The to-be-encrypted vector acquisition module 11 is configured to determine a to-be-encrypted vector corresponding to to-be-encrypted data by using a preset embedding model; the to-be-encrypted data includes image data or text data; correspondingly, the to-be-encrypted vector is a to-be-encrypted image vector or a to-be-encrypted text vector;
[0076] The to-be-encrypted vector splitting module 12 is configured to split the to-be-encrypted vector based on a preset vector splitting rule to obtain a first to-be-encrypted sub-vector and a second to-be-encrypted sub-vector;
[0077] The encrypted sub-vector determination module 13 is configured to perform linear transformation on the first to-be-encrypted sub-vector and the second to-be-encrypted sub-vector respectively based on a preset linear transformation method to obtain a corresponding first encrypted sub-vector and a second encrypted sub-vector;
[0078] The feature data encryption result storage module 14 is configured to splice the first encrypted sub-vector and the second encrypted sub-vector to obtain a feature data encryption result corresponding to the image data or the text data, and store the feature data encryption result in a preset database.
[0079] In some specific embodiments, the feature data encryption device can further include:
[0080] The dimension determination module is configured to determine a dimension corresponding to the to-be-encrypted vector;
[0081] The target segmentation random number generation module is configured to randomly generate a target segmentation random number of a corresponding dimension based on the dimension corresponding to the to-be-encrypted vector; any dimension corresponding component in the target segmentation random number is 0 or 1;
[0082] The target orthogonal matrix generation module is configured to generate a target orthogonal matrix used for performing the linear transformation based on a preset random number and the dimension corresponding to the to-be-encrypted vector; wherein the target orthogonal matrix includes a first orthogonal matrix and a second orthogonal matrix; wherein the dimension of the target segmentation random number, the dimension corresponding to the first orthogonal matrix, and the dimension corresponding to the second orthogonal matrix are all the same as the dimension corresponding to the to-be-encrypted vector.
[0083] In some specific embodiments, the to-be-encrypted vector splitting module 12 can include:
[0084] The first component determination sub-module is configured to determine a first component corresponding to any dimension in the target segmentation random number;
[0085] a second component determination submodule configured to determine a second component corresponding to the any dimension in the to-be-encrypted vector;
[0086] a to-be-encrypted vector splitting submodule configured to split the second component based on a target splitting rule corresponding to the first component and a preset multiple value, to obtain a first splitting result and a second splitting result corresponding to the any dimension;
[0087] a to-be-encrypted sub-vector generation submodule configured to generate the first to-be-encrypted sub-vector based on the first splitting result corresponding to each dimension, and generate the second to-be-encrypted sub-vector based on the second splitting result corresponding to each dimension.
[0088] In some embodiments, the to-be-encrypted vector splitting submodule can include:
[0089] a first to-be-encrypted vector splitting unit configured to, if the first component is 0, split the second component based on a first target splitting rule corresponding to the first component and the preset multiple value, to obtain the first splitting result and the second splitting result corresponding to the any dimension; wherein the first target splitting rule is configured to control the value corresponding to the first splitting result to be equal to the value corresponding to the second splitting result, and the sum of squares between the value corresponding to the first splitting result and the value corresponding to the second splitting result to be equal to the product between the square of the second component and the preset multiple value.
[0090] In some embodiments, the to-be-encrypted vector splitting submodule can include:
[0091] a second to-be-encrypted vector splitting unit configured to, if the first component is 1, split the second component based on a second target splitting rule corresponding to the first component and the preset multiple value, to obtain the first splitting result and the second splitting result corresponding to the any dimension; wherein the second target splitting rule is configured to control the sum of the value corresponding to the first splitting result and the value corresponding to the second splitting result to be equal to the second component, and the sum of squares between the value corresponding to the first splitting result and the value corresponding to the second splitting result to be equal to the product between the square of the second component and the preset multiple value.
[0092] In some embodiments, the encrypted sub-vector determination module 13 can include:
[0093] a first encrypted sub-vector determination unit configured to perform orthogonal transformation on the first to-be-encrypted sub-vector based on the first orthogonal matrix, to obtain the first encrypted sub-vector corresponding to the first to-be-encrypted sub-vector;
[0094] A second encrypted sub-vector determination unit is configured to perform orthogonal transformation on the second to-be-encrypted sub-vector based on the second orthogonal matrix to obtain the second encrypted sub-vector corresponding to the second to-be-encrypted sub-vector.
[0095] In some embodiments, the feature data encryption apparatus can further include:
[0096] A to-be-retrieved vector determination module is configured to determine a to-be-retrieved vector corresponding to to-be-retrieved data by using the preset embedding model, wherein the to-be-retrieved data is image data or text data, and correspondingly, the to-be-retrieved vector is a to-be-retrieved image vector or a to-be-retrieved text vector;
[0097] A to-be-retrieved vector splitting module is configured to split the to-be-retrieved vector to obtain a first to-be-retrieved sub-vector and a second to-be-retrieved sub-vector.
[0098] A to-be-retrieved sub-vector determination module is configured to perform linear transformation on the first to-be-retrieved sub-vector and the second to-be-retrieved sub-vector respectively to obtain a first encrypted to-be-retrieved sub-vector and a second encrypted to-be-retrieved sub-vector respectively.
[0099] A data retrieval module is configured to splice the first encrypted to-be-retrieved sub-vector and the second encrypted to-be-retrieved sub-vector to obtain a to-be-retrieved vector encryption result corresponding to the to-be-retrieved data, and retrieve data in the preset database based on the to-be-retrieved vector encryption result.
[0100] Further, the embodiment of the present application further discloses an electronic device, Figure 4 is an electronic device 20 structure diagram shown according to an exemplary embodiment, the contents in the figure cannot be considered as any limitation on the use range of the present application. The electronic device 20, specifically can include: at least one processor 21, at least one memory 22, power supply 23, communication interface 24, input output interface 25 and communication bus 26. Wherein, the memory 22 is used to store computer program, the computer program is loaded and executed by the processor 21, to realize the related steps in the feature data encryption method disclosed by any preceding embodiment. In addition, the electronic device 20 in the embodiment specifically can be electronic computer.
[0101] In the embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create data transmission channel between the electronic device 20 and external device, and the communication protocol followed by the communication interface 24 can be any communication protocol applicable to the technical solution of the present application, which is not limited specifically herein; the input output interface 25 is used to obtain external input data or output data to the outside, and the specific interface type can be selected according to the specific application needs, which is not limited specifically herein.
[0102] In addition, the memory 22 can be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., as a carrier for storing resources, and the resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage mode can be temporary storage or permanent storage.
[0103] The operating system 221 is used to manage and control each hardware device on the electronic device 20 and the computer program 222, and can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program capable of completing the feature data encryption method executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 222 can further include a computer program capable of completing other specific work.
[0104] Further, the present application also discloses a computer readable storage medium for storing a computer program; wherein the computer program is executed by a processor to implement the feature data encryption method disclosed above. For the specific steps of the method, please refer to the corresponding content disclosed in the foregoing embodiments, which will not be described here.
[0105] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the difference from other embodiments. For the same or similar parts between the embodiments, please refer to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and please refer to the method part for the relevant part.
[0106] The skilled person can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized by electronic hardware, computer software or a combination of the two. In order to clearly show the interchangeability of hardware and software, the components and steps of each example have been described in the above description. Whether the functions are realized by hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0107] The steps of the method or algorithm described in combination with the embodiments disclosed herein can be directly implemented by hardware, a software module executed by a processor, or a combination of the two. The software module can be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0108] Finally, it needs to be pointed out that in this document, relational terms such as first and second and the like can only be intended to distinguish one entity or operation from another entity or operation without necessarily requiring or implying any actual such relationship or order between such entities or operations. Moreover, the terms "comprising", "including", or any other variant thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the statement "comprising a" does not exclude the existence of additional identical elements in the process, method, article, or apparatus including the stated element.
[0109] The above detailed description of the technical solutions provided by the present application has been provided, and the principles and implementation modes of the present application have been described by applying specific examples. The above description of the examples is only for the purpose of helping to understand the method of the present application and its core idea; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed, and the above description of the content of the specification should not be understood as a limitation of the present application.
Claims
1. A method for encrypting characteristic data, characterized in that: include: Determining a vector to be encrypted corresponding to the data to be encrypted using a preset embedding model; the data to be encrypted includes image data or text data; and correspondingly, the vector to be encrypted is an image vector to be encrypted or a text vector to be encrypted; Splitting the vector to be encrypted based on a preset vector splitting rule to obtain a first sub-vector to be encrypted and a second sub-vector to be encrypted; Performing linear transformation on the first to-be-encrypted subvector and the second to-be-encrypted subvector based on a preset linear transformation method to obtain a corresponding first encrypted subvector and a second encrypted subvector; The first encrypted sub-vector and the second encrypted sub-vector are concatenated to obtain an encrypted result of feature data corresponding to the image data or the text data, and the encrypted result of feature data is stored in a preset database.
2. The characteristic data encryption method according to claim 1, characterized in that: Also includes: Determining the dimension corresponding to the vector to be encrypted; Randomly generate a target segmentation random number of the corresponding dimension based on the dimension corresponding to the vector to be encrypted; The component corresponding to any dimension in the target segmentation random number is 0 or 1; Generate a target orthogonal matrix for performing the linear transformation based on a preset random number and a dimension corresponding to the vector to be encrypted; wherein the target orthogonal matrix includes a first orthogonal matrix and a second orthogonal matrix; The dimension of the target segmentation random number, the dimension corresponding to the first orthogonal matrix, and the dimension corresponding to the second orthogonal matrix are all the same as the dimension corresponding to the vector to be encrypted.
3. The characteristic data encryption method according to claim 2, characterized in that: The step of splitting the vector to be encrypted based on a preset vector splitting rule to obtain a first sub-vector to be encrypted and a second sub-vector to be encrypted includes: Determine a first component corresponding to any dimension in the target segmentation random number; Determining a second component corresponding to the any one dimension in the vector to be encrypted; Splitting the second component based on the target splitting rule corresponding to the first component and the preset multiple value, to obtain a first splitting result and a second splitting result corresponding to any one of the dimensions; The first sub-vector to be encrypted is generated based on each of the first splitting results corresponding to each dimension, and the second sub-vector to be encrypted is generated based on each of the second splitting results corresponding to each dimension.
4. The characteristic data encryption method according to claim 3, wherein: The splitting of the second component based on the target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to any one dimension includes: If the first component is 0, splitting the second component based on the first target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to any one dimension; Among them, the first target splitting rule is used to control the numerical value corresponding to the first splitting result to be equal to the numerical value corresponding to the second splitting result, and the sum of the squares of the numerical value corresponding to the first splitting result and the numerical value corresponding to the second splitting result is equal to the product of the square of the second component and the preset multiple value.
5. The characteristic data encryption method according to claim 3, characterized in that: The splitting of the second component based on the target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to any one dimension includes: If the first component is 1, split the second component based on the second target splitting rule corresponding to the first component and the preset multiple value to obtain the first splitting result and the second splitting result corresponding to any one dimension; Among them, the second target splitting rule is used to control the sum of the numerical values corresponding to the first splitting result and the numerical values corresponding to the second splitting result to be equal to the second component, and the sum of the squares of the numerical values corresponding to the first splitting result and the numerical values corresponding to the second splitting result is equal to the product of the square of the second component and the preset multiple value.
6. The characteristic data encryption method according to claim 2, characterized in that: The performing linear transformation on the first to-be-encrypted subvector and the second to-be-encrypted subvector based on a preset linear transformation method to obtain corresponding first encrypted subvector and second encrypted subvector includes: Performing an orthogonal transformation on the first sub-vector to be encrypted based on the first orthogonal matrix to obtain the first encrypted sub-vector corresponding to the first sub-vector to be encrypted; An orthogonal transformation is performed on the second sub-vector to be encrypted based on the second orthogonal matrix to obtain the second encrypted sub-vector corresponding to the second sub-vector to be encrypted.
7. The characteristic data encryption method according to any one of claims 1 to 6, characterized in that: Also includes: Determining a vector to be retrieved corresponding to the data to be retrieved using the preset embedding model; the data to be retrieved is image data or text data; and correspondingly, the vector to be retrieved is an image vector to be retrieved or a text vector to be retrieved; Splitting the vector to be searched to obtain a first sub-vector to be searched and a second sub-vector to be searched; Performing linear transformation on the first to-be-retrieved subvector and the second to-be-retrieved subvector respectively to obtain a corresponding first encrypted to-be-retrieved subvector and a second encrypted to-be-retrieved subvector; The first encrypted sub-vector to be searched and the second encrypted sub-vector to be searched are concatenated to obtain an encrypted result of the vector to be searched corresponding to the data to be searched, and data in the preset database is retrieved based on the encrypted result of the vector to be searched.
8. A characteristic data encryption device, characterized in that: include: A vector acquisition module for encryption, configured to determine a vector for encryption corresponding to the data for encryption using a preset embedding model; the data for encryption includes image data or text data; and correspondingly, the vector for encryption is an image vector for encryption or a text vector for encryption; a vector splitting module for splitting the vector to be encrypted based on a preset vector splitting rule to obtain a first sub-vector to be encrypted and a second sub-vector to be encrypted; an encrypted subvector determining module, configured to perform a linear transformation on the first subvector to be encrypted and the second subvector to be encrypted based on a preset linear transformation method, so as to obtain a corresponding first encrypted subvector and a second encrypted subvector; The feature data encryption result storage module is configured to concatenate the first encrypted sub-vector and the second encrypted sub-vector to obtain a feature data encryption result corresponding to the image data or the text data, and store the feature data encryption result in a preset database.
9. An electronic device, characterized in that: The electronic device includes a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the feature data encryption method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that Used to store a computer program, which, when executed by a processor, implements the characteristic data encryption method according to any one of claims 1 to 7.