A data matching method, device, apparatus and medium

By using a vector transformation model and homomorphic encryption technology, the problem that existing secure intersection algorithms only match when the data is completely identical is solved. This enables fuzzy matching and secure intersection, broadening the application scenarios and ensuring data security.

CN114817943BActive Publication Date: 2026-01-13CHINA UNIONPAY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210191650.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-28
Publication Date
2026-01-13
Estimated Expiration
2042-02-28

AI Technical Summary

Technical Problem

Existing secure intersection algorithms can only match when both sides' data are completely identical, which limits the use cases and affects the business scope of data matching.

Method used

By inputting the data to be matched into a pre-trained vector transformation model, encrypted vectors are generated. Homomorphic encryption technology is used to determine the vector distance. Based on the distance and a preset threshold, data matching is judged to achieve fuzzy matching.

Benefits of technology

It can achieve matching even when the data is not completely identical, which broadens the application scenarios and ensures data security during the matching process, as the original data is not taken out of the database, thus improving the security of the matching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114817943B_ABST
    Figure CN114817943B_ABST
Patent Text Reader

Abstract

The application discloses a data matching method and device, equipment and medium, the method is input into the vector conversion model which is trained in advance to obtain the corresponding first vector and second vector, and the distance of the first vector and the second vector encrypted by the first target public key is obtained, and the target distance of the first vector and the second vector is determined based on the encrypted distance and the first target private key, whether the two data match is determined based on the target distance, the fuzzy matching of data can also be realized when the two data are not completely the same, the use scene is widened, and the first target public and private key pair is introduced for homomorphic encryption and decryption in the fuzzy matching process, safe intersection is realized, the safety of the matching process is ensured, and in the whole matching process, the data has never left the corresponding equipment in the form of original data, the fuzzy matching can be realized without the original data leaving the library, and the safety of the matching process is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, and particularly relates to a data matching method and device, equipment and a medium. BACKGROUND

[0002] Current privacy computing technology is mainly applied to secure intersection and federated learning. The so-called secure intersection refers to identifying the intersection of data of two parties, that is, identifying the common users of institution A and institution B. The secure intersection is also the first step of vertical federated learning, that is, first performing secure intersection on key information such as mobile phone numbers, ID card numbers and business license numbers, and then performing the next step of joint modeling.

[0003] In related technologies, in order to identify the intersection of data of two parties or realize the matching of data of two parties, common secure intersection algorithms include a secure intersection algorithm based on an RSA encryption algorithm and a secure intersection algorithm based on an Oblivious Transfer (OT) protocol, and the like. However, the current secure intersection algorithm can only be matched successfully when the data of two parties are completely the same, that is, when the data types and the number of characters contained in the data of two parties are completely the same. However, in actual business, there are often many use scenarios of data to be matched which are not completely the same. Therefore, the secure intersection algorithm in the prior art greatly limits the use scenarios and affects the business range of data matching. SUMMARY

[0004] The present application provides a data matching method, device, equipment and medium, to solve the problem that the secure intersection algorithm in the prior art can only perform secure intersection when the data of two parties are completely the same, the use scenarios are limited, and the business range of data matching is affected.

[0005] The present application provides a data matching method applied to a first device, the method comprising:

[0006] inputting first data to be matched into a pre-trained vector conversion model to obtain a first vector corresponding to the first data;

[0007] performing homomorphic encryption on the first vector by using a first target public key generated by itself to obtain a first encrypted vector, and sending the first target public key to a second device;

[0008] obtaining a distance between the first encrypted vector and a second vector after encryption, which is determined based on the first encrypted vector and the second encrypted vector, wherein the second encrypted vector is obtained by performing homomorphic encryption on the second vector by using the first target public key; and the second vector is obtained by inputting second data into a pre-trained vector conversion model in the second device;

[0009] determine a target distance of the first vector and the second vector based on the distance of the encrypted first vector and second vector and a first target private key corresponding to the first target public key, and determine whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0010] The application provides a data matching method applied to a second device, and the method comprises the following steps:

[0011] inputting second data to be matched into a vector conversion model that has been pre-trained, to obtain a second vector corresponding to the second data;

[0012] receiving a first target public key sent by a first device, and homomorphically encrypting the second vector by using the first target public key to generate a second encrypted vector;

[0013] obtaining a target distance of a first vector and the second vector determined based on a first encrypted vector and the second encrypted vector, wherein the first encrypted vector is obtained by encrypting the first vector by using the first target public key, and the first vector is obtained by inputting first data into a vector conversion model that has been pre-trained in the first device;

[0014] determining whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0015] The application further provides a data matching device, which comprises the following modules:

[0016] a first obtaining module, configured to input first data to be matched into a vector conversion model that has been pre-trained, to obtain a first vector corresponding to the first data;

[0017] a first processing module, configured to homomorphically encrypt the first vector by using a first target public key generated by itself to generate a first encrypted vector, and send the first target public key to a second device;

[0018] The first obtaining module is further configured to obtain a distance of the first vector and the second vector after encryption, which is determined based on the first encrypted vector and a second encrypted vector, wherein the second encrypted vector is obtained by homomorphically encrypting the second vector by using the first target public key, and the second vector is obtained by inputting second data into a vector conversion model that has been pre-trained in the second device;

[0019] The first determining module is configured to determine a target distance between the first vector and the second vector based on the distance between the first vector and the second vector after encryption and a first target private key corresponding to the first target public key, and determine whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0020] The application further provides a data matching device, which comprises:

[0021] The second obtaining module is configured to input second data to be matched into a pre-trained vector conversion model to obtain a second vector corresponding to the second data.

[0022] The second processing module is configured to receive a first target public key sent by a first device, and perform homomorphic encryption on the second vector by using the first target public key to generate a second encrypted vector.

[0023] The second obtaining module is further configured to obtain a target distance between a first vector and the second vector, which is determined based on a first encrypted vector and the second encrypted vector, wherein the first encrypted vector is obtained by encrypting the first vector by using the first target public key, and the first vector is obtained by inputting first data into a pre-trained vector conversion model in the first device.

[0024] The second determining module is configured to determine whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0025] The application further provides an electronic device, which comprises a processor configured to implement the steps of any of the above data matching methods when executing a computer program stored in a memory.

[0026] The application further provides a computer readable storage medium, which stores a computer program executable by a terminal, and when the program is executed on the terminal, the terminal executes the steps of any of the above data matching methods.

[0027] The application further provides an electronic device, which comprises a processor configured to implement the steps of any of the above data matching methods when executing a computer program stored in a memory.

[0028] The application further provides a computer readable storage medium, which stores a computer program executable by a terminal, and when the program is executed on the terminal, the terminal executes the steps of any of the above data matching methods.

[0029] In the present application, the first data to be matched is input into the pre-trained vector conversion model to obtain a first vector corresponding to the first data, the first vector is homomorphically encrypted using the first target public key generated by itself to generate a first encrypted vector, and the first target public key is sent to the second device to obtain the distance between the first encrypted vector and a second vector determined based on the first encrypted vector and the second encrypted vector, wherein the second encrypted vector is obtained by homomorphically encrypting the second vector using the first target public key, and the second vector is obtained by inputting the second data into the pre-trained vector conversion model in the second device. Based on the distance between the first encrypted vector and the second vector and the first target private key corresponding to the first target public key, the target distance between the first vector and the second vector is determined, and based on the target distance and the preset first distance threshold, it is determined whether the first data and the second data match. In the present application, the first data and the second data to be matched are input into the pre-trained vector conversion model to obtain the first vector corresponding to the first data and the second vector corresponding to the second data, and the first encrypted vector encrypted based on the first vector and the second encrypted vector encrypted based on the second vector are obtained, the distance between the first encrypted vector and the second vector is determined, and the target distance between the first vector and the second vector is determined based on the distance between the first encrypted vector and the second vector and the first target private key generated by itself. Based on the target distance and the preset first distance threshold, it is determined whether the first data and the second data match. That is, when the first data and the second data are not exactly the same, fuzzy matching of the first data and the second data can also be realized, the use scenario is widened, and the first target public key and the first target private key are introduced for homomorphic encryption and decryption respectively in the fuzzy matching process, secure intersection is realized, the security of the matching process is ensured, and in the entire matching process, the first data and the second data have never left the corresponding first device and second device in the form of original data, realizing fuzzy matching without original data leaving the library, and further ensuring the security of the matching process. BRIEF DESCRIPTION OF DRAWINGS

[0030] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.

[0031] Figure 1 A data matching process schematic diagram provided for the embodiments of the present application;

[0032] Figure 2a A target sub-distance display schematic diagram provided for some embodiments of the present application;

[0033] Figure 2b A display diagram of a target sub-distance matrix provided for some embodiments of the present application;

[0034] Figure 3a Another display diagram of a target sub-distance provided for some embodiments of the present application;

[0035] Figure 3b Another display diagram of a target sub-distance matrix provided for some embodiments of the present application;

[0036] Figure 4 A process diagram of a data matching method provided for an embodiment of the present application;

[0037] Figure 5a A process diagram of obtaining a vector corresponding to text type data provided for some embodiments of the present application;

[0038] Figure 5b A process diagram of obtaining a vector corresponding to digital type data provided for some embodiments of the present application;

[0039] Figure 6 A whole process diagram of fuzzy matching of two-party data provided for some embodiments of the present application;

[0040] Figure 7 A specific process diagram of fuzzy matching of two-party data provided for some embodiments of the present application;

[0041] Figure 8 A structure diagram of a data matching device provided for some embodiments of the present application;

[0042] Figure 9 A structure diagram of a data matching device provided for some embodiments of the present application;

[0043] Figure 10 A structure diagram of an electronic device provided for some embodiments of the present application;

[0044] Figure 11 A structure diagram of an electronic device provided for some embodiments of the present application. DETAILED DESCRIPTION

[0045] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0046] In order to ensure that the data of the two parties can be matched when the data is not completely the same, and to broaden the business scope of data matching, the embodiment of the application provides a data matching method, device, equipment and medium.

[0047] In the application, the first data to be matched is input into a pre-trained vector conversion model to obtain a first vector corresponding to the first data, the first vector is homomorphically encrypted by using a first target public key generated by itself to generate a first encrypted vector, the first target public key is sent to a second device, a distance between the first encrypted vector and a second encrypted vector determined based on the first encrypted vector and the second encrypted vector is obtained, the second encrypted vector is obtained by homomorphically encrypting a second vector by using the first target public key, and the second vector is obtained by inputting second data into the pre-trained vector conversion model in the second device, a target distance between the first vector and the second vector is determined based on the distance between the first encrypted vector and the second encrypted vector and a first target private key corresponding to the first target public key, and whether the first data and the second data match is determined based on the target distance and a preset first distance threshold.

[0048] Embodiment 1

[0049] Figure 1 A data matching process provided in the embodiment of the application is shown in a schematic diagram, and the process includes the following steps:

[0050] S101: Input first data to be matched into a pre-trained vector conversion model to obtain a first vector corresponding to the first data.

[0051] The data matching method provided in the embodiment of the application is applied to a first device, which can be a smart terminal, a PC or a server, etc.

[0052] In order to ensure that the data of the two parties can be matched when the data is not completely the same, and to broaden the business scope of data matching, the embodiment of the application provides a data matching method, device, equipment and medium.

[0053] In order to obtain a first vector corresponding to first data to be matched, the first data is input into a pre-trained vector conversion model, the pre-trained vector conversion model outputs the first vector corresponding to the first data, and each component in the first vector is a number, that is, the first data is quantized by the pre-trained vector conversion model.

[0054] S102: Homomorphically encrypt the first vector by using a first target public key generated by itself to generate a first encrypted vector, and send the first target public key to a second device.

[0055] In the embodiment of the present application, in order to improve security, the first device generates a first target public-private key pair, wherein the first target public-private key pair includes a first target public key and a first target private key, and generates a first encrypted vector by encrypting the first vector according to the first target public key generated by itself. The first target public-private key pair can be a symmetric public-private key pair or an asymmetric public-private key pair, and the specific target public-private key pair can be set according to requirements.

[0056] The process of generating the first target public-private key pair is a prior art, and will not be described here.

[0057] Since the second data to be matched with the first data is obtained by the second device, in order to facilitate subsequent determination of the target distance between the first vector corresponding to the first data and the second vector corresponding to the second data, in the embodiment of the present application, the first device also sends the first target public key to the second device, so that the second device can homomorphically encrypt the second vector corresponding to the second data to generate a second encrypted vector according to the first target public key. Specifically, in the embodiment of the present application, when homomorphically encrypting the first vector and the second vector, the first target public key is used to homomorphically encrypt each component in the first vector and each component in the second vector, respectively, to obtain the first encrypted vector and the second encrypted vector.

[0058] S103: Obtain the distance between the first encrypted vector and the second encrypted vector determined based on the first encrypted vector and the second encrypted vector, wherein the second encrypted vector is obtained by homomorphically encrypting the second vector using the first target public key, and the second vector is obtained by inputting the second data into the pre-trained vector conversion model in the second device.

[0059] In order to realize fuzzy matching of the first data and the second data, the pre-trained vector conversion model is also deployed in the second device to obtain the second vector corresponding to the second data to be matched, that is, the second data is input into the pre-trained vector conversion model, and the pre-trained vector conversion model outputs the second vector corresponding to the second data. The second device homomorphically encrypts the second vector based on the first target public key received from the first device to obtain the second encrypted vector.

[0060] Since the first vector and the second vector are respectively encrypted by the first target public key generated by the first device, in order to determine the target distance of the first vector and the second vector, in the embodiment of the present application, the first device can first receive the second encrypted vector sent by the second device, and decrypt the second encrypted vector based on the first target private key in the first target public-private key pair generated by the first device itself to obtain the second vector, and determine the target distance of the first vector and the second vector based on the first vector and the second vector.

[0061] In order to improve security, in the embodiment of the present application, in order to determine the target distance of the first vector and the second vector, the distance of the encrypted first vector and the second vector determined based on the first encrypted vector and the second encrypted vector can be obtained first. The distance of the encrypted first vector and the second vector is not a certain value, but a certain expression that needs to be decrypted to obtain the target distance of the first vector and the second vector. The distance of the encrypted first vector and the second vector can be determined by the first device, or can be determined by the second device and sent to the first device.

[0062] S104: Determine the target distance of the first vector and the second vector based on the distance of the encrypted first vector and the second vector and the first target private key corresponding to the first target public key, and determine whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0063] In the embodiment of the present application, in order to determine whether the first data and the second data match, after determining the distance of the encrypted first vector and the second vector, the distance of the encrypted first vector and the second vector is decrypted first to determine the target distance of the first vector and the second vector. Since the first encrypted vector and the second encrypted vector are both encrypted by the first target public key generated by the first device, in order to determine the target distance of the first vector and the second vector, in the embodiment of the present application, the distance of the encrypted first vector and the second vector can be decrypted based on the first target private key in the first target public-private key pair generated by the first device to determine the target distance of the first vector and the second vector.

[0064] In order to determine whether the first data and the second data match, in the embodiment of the present application, the target distance of the first vector and the second vector is compared with the preset first distance threshold, and whether the first data and the second data match is determined according to the comparison result. The smaller the target distance is, the more matched the first data and the second data are.

[0065] In the embodiment of the present application, the first data to be matched and the second data to be matched are respectively input into the pre-trained vector conversion model, the first vector corresponding to the first data and the second vector corresponding to the second data are obtained, the first encrypted vector based on the first vector is obtained, and the second encrypted vector based on the second vector is obtained. The distance between the first encrypted vector and the second encrypted vector is determined, and the target distance between the first vector and the second vector is determined based on the distance between the first encrypted vector and the second encrypted vector and the first target private key generated by itself. Whether the first data and the second data match is determined based on the target distance and the first distance threshold. That is, even if the first data and the second data are not exactly the same, fuzzy matching of the first data and the second data can also be achieved, which widens the use scenario. In the fuzzy matching process, the first target public key and the first target private key are introduced for homomorphic encryption and decryption, respectively, to achieve secure intersection and ensure the security of the matching process. In the entire matching process, the first data and the second data have never left the corresponding first device and second device in the form of original data, which realizes fuzzy matching without original data leaving the library and further ensures the security of the matching process.

[0066] Embodiment 2

[0067] In order to determine the first vector corresponding to the first data, on the basis of the above embodiment, in the embodiment of the present application, the first data to be matched is input into the pre-trained vector conversion model to obtain the first vector corresponding to the first data, which includes:

[0068] Determining the first target data type corresponding to the first data to be matched;

[0069] According to the correspondence relationship between the first target data type and the pre-stored data type and the pre-trained vector conversion model, the pre-trained first target vector conversion model corresponding to the first data is determined;

[0070] The first data is input into the pre-trained first target vector conversion model to obtain the first vector corresponding to the first data.

[0071] In the embodiment of the present application, the first data to be matched can be text data, such as name, gender, address, etc. It can also be numerical data, such as ID number, bank card number, and admission ticket number, etc. Therefore, in order to obtain the pre-trained vector conversion model corresponding to the first vector of different data types of the first data, the pre-trained vector conversion model is also different.

[0072] Specifically, the first device can store a correspondence between data types and a pre-trained vector conversion model, and obtain a first vector corresponding to the first data according to a first target data type of the first data to be matched, using a corresponding pre-trained vector conversion model, where the corresponding pre-trained vector conversion model is a pre-trained first target vector conversion model.

[0073] To accurately determine the vector conversion model for converting the first data into the first vector, on the basis of the above embodiments, in the embodiments of the present application, if the first target data type is a text type, the corresponding pre-trained first target vector conversion model is a word vector model or a sentence vector model; if the first target data type is a numerical type, the corresponding pre-trained first target vector conversion model is a One-Hot encoding model.

[0074] Specifically, if the first data is text data, i.e., the first target data type of the first data is a text type, a pre-stored correspondence between data types and pre-trained vector conversion models is used to determine a pre-trained first target vector conversion model corresponding to the first target data type, which is a word vector model or a sentence vector model, and a first vector corresponding to the first data is obtained based on the pre-trained word vector model or sentence vector model; if the first data is numerical data, i.e., the first target data type of the first data is a numerical type, a pre-stored correspondence between data types and pre-trained vector conversion models is used to determine a pre-trained first target vector conversion model corresponding to the first target data type, which is a pre-trained One-Hot encoding model, and a first vector corresponding to the first data is obtained based on the pre-trained One-Hot encoding model.

[0075] Taking a pre-trained vector conversion model with a dimension of 5 and a pre-trained word vector model as an example, if the first data is text data and the first data is "Shanghai Pudong New Area Sunny Small Shop", the "Shanghai Pudong New Area Sunny Small Shop" is input into the pre-trained word vector model, and the first vector corresponding to the "Shanghai Pudong New Area Sunny Small Shop" output by the pre-trained word vector model is (1.0, 2.0, 1.5, 2.0, 3.5).

[0076] If the pre-trained vector conversion model is a One-Hot encoding model, the corresponding One-Hot encoding can be set for each number in advance. For example, if the numbers include 0-9, the One-Hot encoding corresponding to 0 is 0000000001, the One-Hot encoding corresponding to 1 is 0000000010, the One-Hot encoding corresponding to 2 is 0000000100, the One-Hot encoding corresponding to 3 is 0000001000, the One-Hot encoding corresponding to 4 is 0000010000, the One-Hot encoding corresponding to 5 is 0000100000, the One-Hot encoding corresponding to 6 is 0001000000, the One-Hot encoding corresponding to 7 is 0010000000, the One-Hot encoding corresponding to 8 is 0100000000, and the One-Hot encoding corresponding to 9 is 1000000000. The number data is input into the One-Hot encoding model, and each first component in the first vector output by the One-Hot encoding model is the One-Hot encoding of each number in the first data.

[0077] If the first data is number data, the number data is "12345", and the number "12345" is input into the pre-trained word vector model, the first vector corresponding to the number "12345" output by the pre-trained word vector model is (0000000010, 0000000100, 0000001000, 0000010000, 0000100000).

[0078] In the training of the vector conversion model, each data and the label vector corresponding to the data can be labeled in advance, each data and the corresponding label vector are input into the original vector conversion model, the parameters of the original vector conversion model are adjusted according to the predicted vector output by the original vector conversion model and the corresponding label vector, and when the convergence condition is met, it is determined that the training of the vector conversion model is completed.

[0079] In the embodiments of the present application, fuzzy matching can be realized regardless of whether the first data and the second data are number data or text data, and the scene application is further widened.

[0080] Embodiment 3:

[0081] In order to determine the distance between the encrypted first vector and the encrypted second vector, on the basis of the above embodiments, in the embodiments of the present application, the distance between the encrypted first vector and the encrypted second vector determined based on the first encrypted vector and the second encrypted vector includes:

[0082] The second encrypted vector sent by the second device is received, wherein the second encrypted vector is obtained by homomorphically encrypting the second vector based on the first target public key by the second device;

[0083] determine a distance between the first encrypted vector and the second encrypted vector based on the first encrypted vector and the second encrypted vector.

[0084] In the embodiments of the present application, the distance between the first encrypted vector and the second encrypted vector determined by the first device based on the first encrypted vector and the second encrypted vector can be determined by the first device, and can also be determined by the second device and sent to the first device.

[0085] If the distance between the first encrypted vector and the second encrypted vector is determined by the first device, in order to determine the distance between the first encrypted vector and the second encrypted vector, the first device needs to obtain the second encrypted vector sent by the second device. Specifically, in order to obtain the second encrypted vector, after the first device sends the first target public key to the second device, the second device receives the first target public key sent by the first device, encrypts the second vector based on the first target public key to obtain the second encrypted vector and sends it to the first device, wherein the second vector is a vector obtained by inputting the second data to be matched into the vector conversion model pre-trained by the second device.

[0086] The first device receives the second encrypted vector sent by the second device, and determines the distance between the first encrypted vector and the second encrypted vector locally based on the received second encrypted vector and the first encrypted vector determined by the first device.

[0087] If the first encrypted vector and the second encrypted vector are obtained by homomorphic encryption of each component in the first vector and each component in the second vector based on the first target public key, in order to determine the distance between the first encrypted vector and the second encrypted vector, in a possible implementation, the first device determines the distance between the first encrypted vector and the second encrypted vector based on the first encrypted vector and the second encrypted vector and the Euclidean distance formula. Specifically, according to determine the distance between the first encrypted vector and the second encrypted vector, wherein the E pka (x i ) is the i-th component in the first encrypted vector, E pka (x y ) is the i-th component in the second encrypted vector, the E pka (d) is the distance between the first encrypted vector and the second encrypted vector, N is the number of components contained in the first encrypted vector or the second encrypted vector, and the number of components contained in the first encrypted vector is the same as the number of components contained in the second encrypted component, that is, the length of the first encrypted vector is equal to the length of the second encrypted vector.

[0088] In another possible implementation, the first device can further determine the distance between the encrypted first vector and the encrypted second vector according to the first encrypted vector and the second encrypted vector and a cosine distance formula or a Hamming distance formula.

[0089] It should be noted that since each component in the first encrypted vector and the second encrypted vector is homomorphically encrypted by the first target public key, the determined distance between the encrypted first vector and the second vector is not an actual numerical value, but a determined expression.

[0090] Since in the embodiments of the present application, none of the second data leaves the second device in the form of original data, the original data can be matched without leaving the database, and the security of the matching process is further ensured.

[0091] Embodiment 4:

[0092] In order to determine the distance between the encrypted first vector and the second vector, in the embodiments of the present application, the sending of the first target public key to the second device includes:

[0093] sending the first encrypted vector and the first target public key to the second device;

[0094] The obtaining of the distance between the encrypted first vector and the second vector determined based on the first encrypted vector and the second encrypted vector includes:

[0095] receiving the distance between the encrypted first vector and the second vector determined by the second device based on the first encrypted vector and the second encrypted vector, wherein the second encrypted vector is obtained by homomorphically encrypting the second vector based on the first target public key by the second device.

[0096] In order to determine the distance between the encrypted first vector and the second vector, in the embodiments of the present application, the distance between the encrypted first vector and the second vector obtained by the first device can also be determined by the second device and sent to the first device.

[0097] Specifically, in order to ensure that the second device can generate the distance between the encrypted first vector and the encrypted second vector, in the embodiment of the present application, the first device can also send the first encryption vector to the second device when sending the generated first target public key to the second device. After receiving the first target public key and the first encryption vector sent by the first device, the second device generates a second encryption vector by homomorphically encrypting the second vector based on the first target public key. The second device determines the distance between the encrypted first vector and the encrypted second vector based on the second encryption vector and the first encryption vector received from the first device, and sends the distance between the encrypted first vector and the encrypted second vector to the first device. The first device obtains the distance between the encrypted first vector and the encrypted second vector sent by the second device.

[0098] If the first vector and the second vector are homomorphically encrypted based on the first target public key respectively, and the first encryption vector and the second encryption vector are obtained, in order to determine the distance between the encrypted first vector and the encrypted second vector, in a possible implementation, the second device determines the distance between the encrypted first vector and the encrypted second vector based on the first encryption vector, the second encryption vector and the Euclidean distance formula. Specifically, according to determining the distance between the encrypted first vector and the encrypted second vector, wherein the E pka (x i ) is the i-th component of the first encryption vector, the E pka (x y ) is the i-th component of the second encryption vector, the E pka (d) is the distance between the encrypted first vector and the encrypted second vector, N is the number of components contained in the first encryption vector or the second encryption vector, and the number of components contained in the first encryption vector is the same as the number of components contained in the second encryption vector, that is, the length of the first encryption vector is equal to the length of the second encryption vector.

[0099] In another possible implementation, the second device can also determine the distance between the encrypted first vector and the encrypted second vector according to the first encryption vector, the second encryption vector and the cosine distance formula or the Hamming distance formula.

[0100] It should be noted that since each component in the first encryption vector and the second encryption vector is homomorphically encrypted by the first target public key, the determined distance between the encrypted first vector and the encrypted second vector is not an actual value, but a determination expression.

[0101] Since in the embodiment of the present application, the first data does not leave the first device in the form of original data, the original data can also realize fuzzy matching without leaving the database, and the security of the matching process is further ensured.

[0102] Embodiment 5

[0103] In order to enable the second device to also determine whether the first data and the second data match, on the basis of the above embodiments, the method further comprises:

[0104] receiving a third encryption vector sent by the second device and a second target public key generated by the second device; wherein the third encryption vector is obtained by homomorphic encryption of the second vector by the second device using the second target public key;

[0105] generating a fourth encryption vector by homomorphic encryption of the first vector based on the second target public key;

[0106] determining the distance between the encrypted second vector and the first vector based on the third encryption vector and the fourth encryption vector, and sending the distance between the encrypted second vector and the first vector to the second device, so that the second device decrypts the distance between the encrypted second vector and the first vector according to the distance between the encrypted second vector and the first vector and a second target private key corresponding to the second target public key, determines the target distance between the second vector and the first vector, and determines whether the first data and the second data match according to the target distance between the second vector and the first vector and a preset first distance threshold.

[0107] In order to enable the first device and the second device to both determine whether the first data and the second data match, in the embodiments of the present application, the second device also needs to obtain the target distance between the first vector and the second vector, that is, the first device needs to realize data synchronization with the second device. The target distance between the first vector and the second vector can be determined by the second device itself, or can be sent to the second device after the first device determines the target distance.

[0108] If the target distance of the first vector and the second vector is determined by the second device itself, specifically, the first device can receive a second target public key sent by the second device and a third encrypted vector sent by the second device, where the second target public key is generated by the second device itself, and the third encrypted vector is obtained by homomorphic encryption of the second vector by the second device using the second target public key. After receiving the second target public key sent by the second device, the first device homomorphically encrypts the first vector based on the second target public key to generate a fourth encrypted vector. In order to determine the distance between the encrypted first vector and the second vector, in the embodiments of the present application, the first device determines the distance between the encrypted first vector and the second vector based on the third encrypted vector sent by the second device and the fourth encrypted vector generated by the first device itself, and sends the determined distance between the encrypted first vector and the second vector to the second device, so that the second device decrypts the distance between the encrypted first vector and the second vector according to the received distance between the encrypted first vector and the second vector and the second target private key corresponding to the second target public key generated by the second device itself, determines the target distance between the second vector and the first vector, and determines whether the first data and the second data match according to the target distance between the second vector and the first vector and the preset first distance threshold.

[0109] The following will be described in conjunction with a specific example:

[0110] The first device inputs the first data to be matched into the pre-trained vector conversion model deployed in the first device to obtain the first vector corresponding to the first data, and the second device inputs the second data to be matched into the pre-trained vector conversion model deployed in the second device to obtain the second vector corresponding to the second data. If the first vector corresponding to the first data U1 is (x1, x2, x3, …, xm), and the second vector corresponding to the second data U2 is (y1, y2, y3, …, ym).

[0111] The first device generates a first target public-private key pair A (pka1, ska1), where pka1 is the first target public key and ska1 is the first target private key. The first vector is homomorphically encrypted based on the first target public key to generate a first encrypted vector, and the first encrypted vector corresponding to the first vector (x1, x2, x3, …, xm) is (E pka1 (x1), E pka1 (x2), E pka1 (x3) …, E pka1 (xm)), and sends the first encrypted vector and the first target public key to the second device.

[0112] The second device receives the first target public key and the first encrypted vector sent by the first device, and homomorphically encrypts the second vector based on the first target public key to obtain a second encrypted vector. Specifically, the second encrypted vector corresponding to the second vector (y1, y2, y3, …, ym) is (E pka1 (y1), E pka1 (y2), E pka1 (y3), …, E pka1 (ym)), and the second device determines the distance between the encrypted first vector and the encrypted second vector based on the second encrypted vector and the received first encrypted vector, and sends the distance to the first device.

[0113] The second device generates a second target public-private key pair B (pka2, ska2), where pka2 is the second target public key and ska2 is the second target private key. The second device homomorphically encrypts the second vector based on the second target public key to generate a third encrypted vector. Specifically, the third encrypted vector corresponding to the second vector (y1, y2, y3, …, ym) is (E pka2 (y1), E pka2 (y2), E pka2 (y3), …, E pka2 (ym)), and the second device sends the second target public key and the third encrypted vector to the first device.

[0114] After receiving the second target public key and the third encrypted vector sent by the second device, the first device homomorphically encrypts the first vector based on the second target public key to obtain a fourth encrypted vector. Specifically, the fourth encrypted vector corresponding to the first vector (x1, x2, x3, …, xm) is (E pka2 (x1), E pka2 (x2), E pka2 (x3), …, E pka2 (xm)). The first device determines the distance between the encrypted first vector and the encrypted second vector based on the fourth encrypted vector and the third encrypted vector, and sends the distance between the encrypted first vector and the encrypted second vector to the second device.

[0115] After receiving the distance between the encrypted first vector and the encrypted second vector, the first device decrypts the distance between the encrypted first vector and the encrypted second vector based on the first target private key corresponding to the first target public key generated by the first device to determine the target distance between the first vector and the second vector. The first device determines whether the first data and the second data match based on the target distance between the second vector and the first vector and the preset first distance threshold.

[0116] After the second device receives the encrypted distance between the first vector and the second vector, the second device decrypts the encrypted distance between the first vector and the second vector according to the second target private key corresponding to the second target public key generated by the second device, determines the target distance between the first vector and the second vector, and then determines whether the first data and the second data match according to the target distance between the second vector and the first vector and the preset first distance threshold.

[0117] Embodiment 6

[0118] To enable the second device to also determine whether the first data and the second data match, in the embodiments of the present application, after determining the target distance between the first vector and the second vector, the method further includes:

[0119] sending the target distance between the first vector and the second vector to the second device, so that the second device determines whether the first data and the second data match based on the target distance and the preset first distance threshold.

[0120] To enable the second device to also determine whether the first data and the second data match, in the embodiments of the present application, the second device also needs to obtain the target distance between the first vector and the second vector. Specifically, the target distance between the first vector and the second vector obtained by the second device can be the target distance between the first vector and the second vector sent by the first device to the second device after being obtained by the first device. After receiving the target distance between the first vector and the second vector sent by the first device, the second device determines whether the first data and the second data match based on the target distance and the preset first distance threshold.

[0121] The following is described with a specific example:

[0122] The first device inputs the first data to be matched into the pre-trained vector conversion model deployed in the first device, obtains the first vector corresponding to the first data, and the second device inputs the second data to be matched into the pre-trained vector conversion model deployed in the second device, obtains the second vector corresponding to the second data. If the first vector corresponding to the first data U1 is (x1, x2, x3, …, xm) and the second vector corresponding to the second data U2 is (y1, y2, y3, …, ym).

[0123] The first device generates a first target public-private key pair A (pka1, ska1), where pka1 is the first target public key and ska1 is the first target private key. The first vector is homomorphically encrypted based on the first target public key to generate a first encrypted vector. The first encrypted vector corresponding to the first vector (x1, x2, x3, …, xm) is (E pka1 (x1), E pka1 (x2), Epka1 (x3) …, E pka1 (xm)) and sends the first encrypted vector and the first target public key to the second device.

[0124] After the second device receives the first target public key and the first encrypted vector sent by the first device, the second device homomorphically encrypts the second vector based on the first target public key to obtain a second encrypted vector. Specifically, the second encrypted vector corresponding to the second vector (y1, y2, y3, …, ym) is (E pka1 (y1), E pka1 (y2), E pka1 (y3) …, E pka1 (ym)), and the second device determines the encrypted distance between the first vector and the second vector based on the second encrypted vector and the received first encrypted vector and sends the encrypted distance to the first device.

[0125] After the first device receives the encrypted distance between the first vector and the second vector, the first device decrypts the encrypted distance between the first vector and the second vector based on the first target private key corresponding to the first target public key generated by the first device to determine the target distance between the first vector and the second vector. The first device can determine whether the first data and the second data match based on the target distance and a preset first distance threshold, and the first device sends the target distance between the first vector and the second vector to the second device. The second device determines whether the first data and the second data match based on the target distance between the second vector and the first vector and the preset first distance threshold.

[0126] Embodiment 7:

[0127] To determine the target distance between the first vector and the second vector, on the basis of the above embodiments, in the embodiments of the present application, the determination of the target distance between the first vector and the second vector based on the encrypted distance between the first vector and the second vector and the first target private key corresponding to the first target public key comprises:

[0128] The first target private key corresponding to the first target public key generated by the first device is used to decrypt the encrypted distance between the first vector and the second vector to determine the target distance between the first vector and the second vector.

[0129] In the embodiments of the present application, since the distance between the encrypted first vector and the encrypted second vector obtained by the first device is determined based on the first encrypted vector and the second encrypted vector, and the first encrypted vector and the second encrypted vector are determined according to the first target public key generated by the first device, in order to determine the target distance between the first vector and the second vector, after obtaining the distance between the encrypted first vector and the encrypted second vector, the first device decrypts the distance between the encrypted first vector and the encrypted second vector by using the first target private key corresponding to the first target public key generated by the first device, to determine the target distance between the first vector and the second vector.

[0130] Embodiment 8

[0131] In order to determine the first encrypted vector, on the basis of the above-mentioned embodiments, in the embodiments of the present application, the first data to be matched is input into the vector conversion model pre-trained to obtain the first vector corresponding to the first data.

[0132] For each first sub-data in the first data, the first sub-data is input into the vector conversion model pre-trained to obtain a first sub-vector corresponding to the first sub-data, and the length of the first sub-vector corresponding to each first sub-data is a first preset length.

[0133] The first sub-vectors corresponding to each first sub-data are spliced to obtain the first vector corresponding to the first data.

[0134] In the embodiments of the present application, one first data may contain one first sub-data, or may contain multiple first sub-data. For example, the first data contains one first sub-data "Shanghai Pudong New Area Sunny Small Shop", and the first data may also contain three first sub-data, such as "Shanghai Pudong New Area Sunny Small Shop", "Shanghai Every Day Catering Shop", and "Gaoke Road Yang Guofu Spicy Hot Pot".

[0135] In order to determine the first vector corresponding to the first data, each first sub-data in the first data can be input into the vector conversion model pre-trained to obtain a first sub-vector corresponding to the first sub-data, wherein the length of the text or number or character contained in each first sub-data can be different, but the length of the first sub-vector corresponding to each first sub-data is a first preset length, and the first preset length can be 3, 4, 6, etc. Specifically, the first preset length can be set according to requirements.

[0136] The dimension of the vector output by the pre-trained vector conversion model is 5, and the pre-trained vector conversion model is a word vector model. If the first data includes three first sub-data, each of which is text data, the three first sub-data are "Shanghai Pudong New Area Sunny Small Shop", "Shanghai Tian Tian Restaurant", and "Gaoke Road Yang Guofu Spicy Hot Pot", respectively, then "Shanghai Pudong New Area Sunny Small Shop" is input into the pre-trained word vector model, and the first sub-vector corresponding to "Shanghai Pudong New Area Sunny Small Shop" output by the pre-trained word vector model is (1.0, 2.0, 1.5, 2.0, 3.5). "Shanghai Tian Tian Restaurant" is input into the pre-trained word vector model, and the first sub-vector corresponding to "Shanghai Tian Tian Restaurant" output by the pre-trained word vector model is (3.0, 4.0, 2.5, 2.5, 1.5). "Gaoke Road Yang Guofu Spicy Hot Pot" is input into the pre-trained word vector model, and the first sub-vector corresponding to "Gaoke Road Yang Guofu Spicy Hot Pot" output by the pre-trained word vector model is (4.5, 5.5, 7.5, 1.5, 0.5).

[0137] If the first data includes three first sub-data, each of which is numerical data, the three numerical data are "12345", "11111", and "22233", respectively, then "12345" is input into the pre-trained word vector model, and the first sub-vector corresponding to "12345" output by the pre-trained word vector model is (0000000010, 0000000100, 0000001000, 0000010000, 0000100000). "11111" is input into the pre-trained word vector model, and the first sub-vector corresponding to "11111" output by the pre-trained word vector model is (0000000010, 0000000010, 0000000010, 0000000010, 0000000010). "22233" is input into the pre-trained word vector model, and the first sub-vector corresponding to "22233" output by the pre-trained word vector model is (0000000100, 0000000100, 0000000100, 0000000010, 0000000010).

[0138] To determine the first vector corresponding to the first data, in the embodiments of the present application, after obtaining the first sub-vector corresponding to each first sub-data in the first data, the first sub-vector corresponding to each first sub-data is spliced, and the spliced result is determined as the first vector corresponding to the first data. Specifically, each first sub-data included in the first data can be sorted randomly first, and the first sub-vector corresponding to the first sub-data is sorted and spliced according to the sorting result of the first sub-data to obtain the first vector.

[0139] For example, when the first data contains three first sub-data of "Shanghai Pudong New Area, Sunshine Small Shop", "Shanghai City, Every Day Restaurant", and "Gaoke Road, Yang Guofu Spicy Hot Pot", the first sub-vector corresponding to "Shanghai Pudong New Area, Sunshine Small Shop" is (1.0, 2.0, 1.5), the first sub-vector corresponding to "Shanghai City, Every Day Restaurant" is (3.0, 4.0, 2.5), and the first sub-vector corresponding to "Gaoke Road, Yang Guofu Spicy Hot Pot" is (4.5, 5.5, 7.5). The sorting result obtained by randomly sorting each first sub-data in the first data is "Shanghai Pudong New Area, Sunshine Small Shop", "Gaoke Road, Yang Guofu Spicy Hot Pot", and "Shanghai City, Every Day Restaurant". The first vector corresponding to the first data is obtained by concatenating the first sub-vectors corresponding to the three first sub-data according to the sorting result, and is (1.0, 2.0, 1.5, 4.5, 5.5, 7.5, 1.0, 2.0, 1.5).

[0140] To achieve fuzzy matching of the first data and the second data, in the embodiments of the present application, the length of the first vector and the length of the second vector are both the second preset length based on the above-mentioned embodiments.

[0141] In the embodiments of the present application, to achieve fuzzy matching of the first data and the second data, the length of the first vector corresponding to the first data and the length of the second vector corresponding to the second data must be the same, and both are the second preset length, wherein the second preset length is not less than the first preset length, the second preset length is an integer multiple of the first preset length, and if the first data contains only one first sub-data, the first preset length is equal to the second preset length.

[0142] Since the length of the first vector corresponding to the first data and the length of the second vector corresponding to the second data are both the second preset length, even if the first data and the second data are not the same, fuzzy matching can be achieved, which widens the use scenario.

[0143] Embodiment 9:

[0144] To determine the first encrypted vector, in the embodiments of the present application, the first vector is homomorphically encrypted by using the first target public key generated by itself to generate the first encrypted vector based on the above-mentioned embodiments, which includes:

[0145] For each first component in the first vector, a first square component corresponding to the first component is determined;

[0146] Each first square component corresponding to the first component is inserted into the first vector according to a preset insertion rule, and the vector obtained after inserting the first square component is updated as the first vector;

[0147] encrypt each first component and each first square component in the first vector based on the first target public key respectively to generate the first encrypted vector.

[0148] To generate the first encrypted vector, in the embodiments of the present application, the first vector can be homomorphically encrypted based on the first target public key directly to obtain the first encrypted vector after encryption. To ensure that the distance between the first vector and the second vector after encryption can be determined based on the first encrypted vector and the second encrypted vector without decryption of the first encrypted vector and the second encrypted vector, in the embodiments of the present application, the first square component corresponding to each first component in the first vector can be determined first.

[0149] For example, if the first vector is (1, 2, 4, 5, 3), the first square component corresponding to the first component 1 in the first vector is 1, the first square component corresponding to the first component 2 in the first vector is 4, the first square component corresponding to the first component 4 in the first vector is 16, the first square component corresponding to the first component 5 in the first vector is 25, and the first square component corresponding to the first component 3 in the first vector is 9.

[0150] In the embodiments of the present application, after each first component in the first vector is determined, the first square component corresponding to each first component can be inserted into the first vector according to a preset rule, and the vector obtained after the first square component is inserted is updated as the first vector. Specifically, for the first square component corresponding to each first component, the first square component corresponding to the first component can be inserted into any position in the first vector, such as being inserted in front of the first component in the first vector, or being inserted behind the first component in the first vector, or being inserted behind the first component in sequence, as long as the first device and the second device can identify the first component and the first square component in each vector.

[0151] For example, if the first vector is (1, 2, 4, 5, 3), after the first square component of each first component in the first vector is determined, the first square component is inserted into the first vector to obtain the updated first vector (1, 9, 2, 16, 4, 4, 5, 25, 1, 3).

[0152] In order to facilitate subsequent determination of the distance between the encrypted first vector and the second vector based on the inserted first square component, in the embodiments of the present application, for each first component in the first vector, after determining the first square component corresponding to the first component, the first square component corresponding to each first component can be inserted into the first vector according to a preset insertion rule, and the vector obtained after inserting the first square component is updated as the first vector. Specifically, the first square component corresponding to the first component can be inserted into the first vector at a position adjacent to the first component after the first component.

[0153] For example, if the first vector is (1, 2, 4, 5, 3), after determining the first square component of each first component in the first vector, the updated first vector obtained after inserting the first square component into the first vector is (1, 1, 2, 4, 4, 16, 5, 25, 3, 9).

[0154] After determining the updated first vector, in order to determine the first encrypted vector, in the embodiments of the present application, each first component and each first square component in the first vector can be homomorphically encrypted based on the first target public key to generate the first encrypted vector.

[0155] For example, if the updated first vector is (2, 4, 3, 9), the first encrypted vector is (E pka (2), E pka (4), E pka (3), E pka (9)), wherein the E pka (2) represents the result of homomorphic encryption of the first component with a value of 2 in the first vector based on the target public key, the E pka (4) represents the result of homomorphic encryption of the first component with a value of 4 in the first vector based on the target public key, the E pka (3) represents the result of homomorphic encryption of the first component with a value of 3 in the first vector based on the target public key, and the E pka (9) represents the result of homomorphic encryption of the first component with a value of 9 in the first vector based on the target public key.

[0156] In order to determine the distance between the encrypted first vector and the second vector, on the basis of the above embodiments, in the embodiments of the present application, the obtaining of the distance between the encrypted first vector and the second vector based on the first encrypted vector and the second encrypted vector comprises:

[0157] According to the preset insertion rule and each first component in the first encrypted vector, each group of first encrypted components and first encrypted square components is obtained; and according to the preset insertion rule and each second component in the second encrypted vector, each group of second encrypted components and second encrypted square components is obtained;

[0158] According to the preset insertion rule, each group of the first encrypted component, the first encrypted square component, the second encrypted component and the second encrypted square component is determined;

[0159] According to each group of the first encrypted component, the first encrypted square component, the second encrypted component and the second encrypted square component, each sub-distance after encryption is determined;

[0160] According to the sum value of each sub-distance, the distance between the first vector and the second vector after encryption is determined.

[0161] In the embodiments of the present application, in order to determine the distance between the first vector and the second vector after encryption, the first device can obtain each group of the first encrypted component and the first encrypted square component according to the preset insertion rule and each first component in the first encrypted vector, wherein a group of the first encrypted component and the first encrypted square component is obtained by homomorphic encryption of the same component itself and the square component of the component. That is, in each group of the first encrypted component and the first encrypted square component, the first encrypted square component is obtained by homomorphic encryption of the first square component corresponding to the first component corresponding to the first encrypted component before encryption.

[0162] Specifically, if the preset insertion rule is to insert the first square component corresponding to the first component into the position adjacent to the first component after the first component in the first vector. When determining each group of the first encrypted component and the first encrypted component, the component to be determined can be directly divided from the first component of the first vector, and the next component of the determined group in the first vector and the component of the determined group are determined as a group, and the division is sequentially performed until the first encrypted component and the first encrypted square component corresponding to all groups are determined.

[0163] For example, the first encrypted vector is (E pka (2), E pka (4), E pka (3), E pka (9)), two groups of the first encrypted component and the first encrypted square component can be obtained, wherein the first group is E pka (2), E pka (4), and the second group is E pka (3), E pka (9). Among them, E pka (2) in the first group is the first encrypted component in the first group, E pka (4) is the first encrypted square component in the first group, E pka (3) in the second group is the first encrypted component in the second group, and E pka (9) is the first encrypted square component in the second group.

[0164] In the embodiments of the present application, after obtaining the second encryption vector sent by the second device, the first device can also obtain each group of second encryption components and second encryption square components according to the preset insertion rule and each second component in the second encryption vector, wherein the preset insertion rule corresponding to the obtaining of the first vector is the same as the preset insertion rule corresponding to the obtaining of the second vector, and the process of obtaining each group of second encryption components and second encryption square components is the same as the process of obtaining each group of first encryption components and first encryption square components, which will not be repeated here.

[0165] In order to determine the distance between the encrypted first vector and the second vector, in the embodiments of the present application, each encrypted sub-distance can be determined according to each group of first encryption components, first encryption square components, second encryption components and second encryption square components. Specifically, for each group, the target sum of the first encryption square component and the second encryption square component in the group can be determined first, and then the target product of the first encryption component, the second encryption component and the preset numerical value in the group can be determined, wherein the preset numerical value is 2 in the embodiments of the present application. Finally, the target difference value of the target sum and the target product is determined as the encrypted sub-distance of the group.

[0166] After determining each encrypted sub-distance, the distance between the encrypted first vector and the second vector can be determined according to the sum value of each sub-distance.

[0167] For example, if it is determined that the first vector corresponding to the first data is (1, 5) and the second vector corresponding to the second data is (2, 3), after determining the first square components of each first component in the first vector, the first square components are inserted into the first vector to obtain the updated first vector (1, 1, 5, 25), and it is determined that the first encryption vector is (E pka (1), E pka (1), E pka (5), E pka (25), after determining the second square components of each second component in the second vector, the second square components are inserted into the second vector to obtain the updated second vector (2, 4, 3, 9), and it is determined that the second encryption vector is (E pka (2), E pka (4), E pka (3), E pka (9), then the distance between the encrypted first vector and the second vector is determined as [E pka (1) + E pka (4) - 2E pka (1) * E pka (2)] + [E pka (25) + Epka (9)-2E pka (5)*E pka (3)].

[0168] Since the first data to be matched can contain a plurality of first sub-data, and the second data to be matched can also contain a plurality of second sub-data, for each first sub-data and each second sub-data, the distance between the first sub-vector of the encrypted first sub-data and the second sub-vector of the second sub-data can also be determined, and then it is determined whether each first sub-data and each second sub-data match. Therefore, for convenience, the encrypted distance matrix can be determined according to the distance between each encrypted first sub-vector and second sub-vector, wherein each element in the encrypted distance matrix is the distance between the corresponding encrypted first sub-vector and second sub-vector. After the encrypted distance matrix is decrypted based on the target private key, the target sub-distance matrix is determined, wherein each element in the target sub-distance matrix is the target sub-distance between the corresponding first sub-vector and second sub-vector.

[0169] After determining the target sub-distance of each first sub-vector and each second sub-vector, the target distance of the first vector and the second vector can also be determined according to the sum of each target sub-distance, and it can also be determined whether each first sub-data and each second sub-data match. Specifically, a sub-distance threshold can be set in advance, and for each first sub-vector and each second sub-vector, it is determined whether the target sub-distance between the first sub-vector and the second sub-vector is less than the pre-set sub-distance threshold. If yes, it is determined that the first sub-data corresponding to the first sub-vector matches the second sub-data corresponding to the second sub-vector.

[0170] Figure 2a A display diagram of a target sub-distance provided by some embodiments of the present application, Figure 2b A display diagram of a target sub-distance matrix provided by some embodiments of the present application, Figure 3a Another display diagram of a target sub-distance provided by some embodiments of the present application, Figure 3b Another display diagram of a target sub-distance matrix provided by some embodiments of the present application, which will be described in detail below. Figure 2a 、 Figure 2b 、 Figure 3a and Figure 3b

[0171] ​D(x, y) represents a target sub-distance, x represents a first vector, y represents a second vector, if there are three first sub-data in the first data, there are also three second sub-data in the second data, and the first sub-vectors corresponding to the three first sub-data are respectively represented as A1, A2 and A3, the second sub-vectors corresponding to the three second sub-data are respectively represented as B1, B2 and B3, the target sub-distance corresponding to A1 and B1 is 1, the target sub-distance corresponding to A1 and B2 is 3.64, the target sub-distance corresponding to A1 and B3 is 7.66, the target sub-distance corresponding to A2 and B1 is 3.9, the target sub-distance corresponding to A2 and B2 is 0, the target sub-distance corresponding to A2 and B3 is 5.7, the target sub-distance corresponding to A3 and B1 is 8.35, the target sub-distance corresponding to A3 and B2 is 5.16, and the target sub-distance corresponding to A3 and B3 is 8.18, as shown in Figure 2a , the corresponding target sub-distance matrix is as shown in Figure 2b .

[0172] If there are three first sub-data in the first data, there are also three second sub-data in the second data, and the first sub-vectors corresponding to the three first sub-data are respectively represented as A1, A2 and A3, the second sub-vectors corresponding to the three second sub-data are respectively represented as B1, B2 and B3, the target sub-distance corresponding to A1 and B1 is 2.82, the target sub-distance corresponding to A1 and B2 is 1, the target sub-distance corresponding to A1 and B3 is 3.16, the target sub-distance corresponding to A2 and B1 is 3, the target sub-distance corresponding to A2 and B2 is 1.73, the target sub-distance corresponding to A2 and B3 is 3, the target sub-distance corresponding to A3 and B1 is 0, the target sub-distance corresponding to A3 and B2 is 2.83, and the target sub-distance corresponding to A3 and B3 is 3, as shown in Figure 3a , the corresponding target sub-distance matrix is as shown in Figure 3b .

[0173] Embodiment 10

[0174] In order to determine the second vector corresponding to the second data, on the basis of each of the above embodiments, in the embodiment of the present application, the determination of whether the first data and the second data match based on the target distance and the preset first distance threshold comprises:

[0175] determining whether the target distance is less than the preset first distance threshold;

[0176] if yes, determining that the first data and the second data match;

[0177] otherwise, determining that the first data and the second data do not match.

[0178] To determine whether the first data and the second data match, in the embodiments of the present application, the target distance is compared with a preset distance threshold, if the target distance is less than a preset first distance threshold, it is determined that the first data and the second data match, if the target distance is not less than the preset first distance threshold, it is determined that the first data and the second data do not match. Wherein, the preset first distance threshold can be 1, can be 1.5, etc., specifically, the preset first distance threshold can be set according to the demand. Wherein, the smaller the target distance, the more matched the first vector and the second vector.

[0179] To determine whether the second data and the first data match completely, on the basis of the above embodiments, in the embodiments of the present application, after determining that the first data and the second data match, the method further comprises:

[0180] Determining whether the target distance is equal to a preset second distance threshold, if yes, it is determined that the first data and the second data are the same.

[0181] In the embodiments of the present application, if the target distance is equal to the preset second distance threshold, it means that the first data and the second data are the same, that is, the first data and the second data match completely, wherein, the preset second distance threshold is less than the preset first distance threshold, and the preset second distance threshold is equal to 0.

[0182] Embodiment 11:

[0183] To ensure that the data of both parties can be matched when they are not completely the same, and to broaden the business scope of data matching, the embodiments of the present application provide a data matching method, device, equipment and medium.

[0184] Figure 4 A process schematic diagram of a data matching method provided in the embodiments of the present application, the process includes the following steps:

[0185] S401: input the second data to be matched into the vector conversion model pre-trained, and obtain the second vector corresponding to the second data.

[0186] The data matching method provided in the embodiments of the present application is applied to a second device, which can be a smart terminal, a PC or a server, etc. The second device and the first device in the present application are different devices.

[0187] In the embodiment of the present application, in order to ensure that the data of the two parties are not completely the same, and also achieve fuzzy matching, a pre-trained vector conversion model is deployed in the second device, which is used to obtain the vector corresponding to the to-be-matched data, and the dimensions of the vectors output by the pre-trained vector conversion model are the same for different data.

[0188] In order to obtain the second vector corresponding to the second data to be matched, the second data is input into the pre-trained vector conversion model, and the pre-trained vector conversion model outputs the second vector corresponding to the second data.

[0189] In the embodiment of the present application, the first data and the second data are generally data of the same type, such as text data or digital data.

[0190] S402: receiving the first target public key sent by the first device, and homomorphically encrypting the second vector by using the first target public key to generate a second encrypted vector.

[0191] In the embodiment of the present application, in order to determine the second encrypted vector, after the second device receives the first target public key sent by the first device, the second vector is homomorphically encrypted by using the first target public key to generate a second encrypted vector.

[0192] S403: obtaining a target distance of the first vector and the second vector determined based on the first encrypted vector and the second encrypted vector, wherein the first encrypted vector is obtained by encrypting the first vector by using the first target public key, and the first vector is obtained by inputting the first data into the pre-trained vector conversion model in the first device.

[0193] In the embodiment of the present application, in order to enable the second device to also determine whether the first data and the second data match, the second device also obtains the target distance of the first vector and the second vector determined based on the first encrypted vector and the second encrypted vector, wherein the target distance can be determined by the first device and then sent to the second device, or can be determined by the second device.

[0194] The first encrypted vector is obtained by encrypting the first vector by using the first target public key generated by the first device, and the first vector is obtained by inputting the first data into the pre-trained vector conversion model in the first device.

[0195] S404: determining whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0196] In order to determine whether the first data and the second data match, in the embodiments of the present application, the target distance and the preset first distance threshold are compared, and according to the comparison result, it is determined whether the first data and the second data match.

[0197] In the embodiments of the present application, the first data and the second data to be matched are respectively input into the pre-trained vector conversion model, the first vector corresponding to the first data and the second vector corresponding to the second data are obtained, the first encrypted vector based on the first vector and the second encrypted vector based on the second vector are obtained, the distance of the encrypted first vector and the second vector is determined, the target distance of the first vector and the second vector is determined based on the distance of the encrypted first vector and the second vector and the first target private key generated by itself, and whether the first data and the second data match is determined based on the target distance and the preset first distance threshold. That is, even when the first data and the second data are not exactly the same, fuzzy matching of the first data and the second data can also be achieved, which widens the use scenario. In the fuzzy matching process, the first target public key and the first target private key are introduced for homomorphic encryption and decryption respectively, secure intersection is achieved, the security of the matching process is ensured, and in the entire matching process, the first data and the second data are not in the form of original data leaving the corresponding first device and second device, fuzzy matching can be achieved without original data leaving the library, and the security of the matching process is further ensured.

[0198] Embodiment 12:

[0199] In order to determine the second vector corresponding to the second data, on the basis of each of the above embodiments, in the embodiments of the present application, the step of inputting the obtained second data to be matched into the pre-trained vector conversion model to obtain the second vector corresponding to the second data comprises:

[0200] determining a second target data type corresponding to the second data to be matched;

[0201] determining a pre-trained second target vector conversion model corresponding to the second data according to the second target data type and a correspondence relationship between a pre-stored data type and the pre-trained vector conversion model;

[0202] inputting the second data into the pre-trained second target vector conversion model to obtain the second vector corresponding to the second data.

[0203] In the embodiments of the present application, since the second data to be matched can be text data, for example, the first data can be name, gender, address, etc., or can be numerical data, for example, the second data can be an ID number, a bank card number, and an examination card number, etc., therefore, in order to obtain the pre-trained vector conversion model corresponding to the second vector for different types of second data, the pre-trained vector conversion model is also different.

[0204] Specifically, the second device can store a correspondence between a data type and a pre-trained vector conversion model, and obtain a second vector corresponding to the second data according to a second target data type corresponding to the second data to be matched, by using a corresponding pre-trained vector conversion model, wherein the corresponding pre-trained vector conversion model is a pre-trained second target vector conversion model.

[0205] Figure 5a A process diagram for obtaining a vector corresponding to text type data provided by some embodiments of the present application is shown in FIG. 1, Figure 5b A process diagram for obtaining a vector corresponding to numerical type data provided by some embodiments of the present application is shown in FIG. 2, which will be described in detail. Figure 5a and Figure 5b

[0206] If the data to be matched is text data, the data to be matched can be first data or second data, and the pre-trained vector conversion model is a word vector model. The text data is input into the pre-trained word vector model, and the word vector model outputs a vector corresponding to the text data.

[0207] If the data to be matched is numerical data, the data to be matched can be first data or second data, and the pre-trained vector conversion model is a One-Hot encoding model. The numerical data is input into the pre-trained One-Hot encoding model, and the One-Hot encoding model outputs a vector corresponding to the numerical data.

[0208] In order to accurately determine the model for converting the second data into the second vector, on the basis of the above embodiments, if the second target data type is a text type, the corresponding pre-trained second target vector conversion model is a word vector model or a sentence vector model; if the second target data type is a numerical type, the corresponding pre-trained second target vector conversion model is a One-Hot encoding model.

[0209] ​In the embodiments of the present application, if the second data is text data, in order to obtain the second vector corresponding to the text data, the pre-trained vector conversion model deployed in the second device can be a word vector model or a sentence vector model, and if the second data is numerical data, in order to determine the second vector corresponding to the numerical data, the pre-trained vector conversion model deployed in the second device can be a One-Hot coding model.

[0210] Specifically, if the second data is text data, according to the correspondence between the pre-stored data type and the pre-trained vector conversion model, it is determined that the pre-completed second target vector conversion model corresponding to the second data is a word vector model, and based on the pre-trained word vector model, the second vector corresponding to the second data is obtained; if the second data is numerical data, according to the correspondence between the pre-stored data type and the pre-trained vector conversion model, it is determined that the pre-completed second target vector conversion model corresponding to the second data is a One-Hot coding model, and based on the pre-trained One-Hot coding model, the second vector corresponding to the second data is obtained.

[0211] Wherein, when training the vector conversion model, each data and the corresponding labeled vector of the data can be pre-labeled, each data and the corresponding labeled vector are input into the original vector conversion model, the parameters of the original vector conversion model are adjusted according to the predicted vector output by the original vector conversion model and the corresponding labeled vector, and when the convergence condition is met, it is determined that the vector conversion model is trained.

[0212] Embodiment 13:

[0213] In order to obtain the target distance of the first vector and the second vector determined based on the first encrypted vector and the second encrypted vector, on the basis of the above embodiments, the receiving of the target public key sent by the first device comprises:

[0214] Receiving the first target public key and the first encrypted vector sent by the first device, wherein the first encrypted vector is obtained by homomorphically encrypting the first vector using the first target public key;

[0215] The obtaining of the target distance of the first vector and the second vector based on the first encrypted vector and the second encrypted vector comprises:

[0216] According to the first encrypted vector and the second encrypted vector, the distance between the first encrypted vector and the second encrypted vector is determined;

[0217] The distance between the first encrypted vector and the second encrypted vector is sent to the first device;

[0218] receive the target distance sent by the first device, wherein the target distance is obtained by the first device decrypting the distance between the first vector and the second vector after homomorphic encryption of the first vector and the second vector by the first target public key generated by the first device.

[0219] In the embodiments of the present application, the target distance of the first vector and the second vector determined based on the first encrypted vector and the second encrypted vector obtained by the second device can be determined by the first device and sent to the second device, and can also be determined by the second device.

[0220] Since the first encrypted vector and the second encrypted vector are generated by homomorphic encryption of the first vector and the second vector based on the first target public key generated by the first device, after determining the distance between the first vector and the second vector after encryption, the distance between the first vector and the second vector after encryption also needs to be decrypted based on the first target private key generated by the first device. If the target distance of the first vector and the second vector is determined by the second device, the second device needs to receive the first target private key sent by the first device. If there is a loophole or attack in the sending process, the security of the information will be affected, and the security is not high.

[0221] In order to improve the security, in the embodiments of the present application, the target distance can be determined by the first device and sent to the second device. Specifically, the second device can receive the first encrypted vector determined by the first device when receiving the first target public key sent by the first device, wherein the first encrypted vector is obtained by homomorphic encryption of the first vector by the first target public key.

[0222] After receiving the first encrypted vector and the first target public key sent by the first device, the second device can first homomorphic encrypt the second vector based on the first target public key to determine the second encrypted vector, and then determine the distance between the first vector and the second vector after encryption based on the first encrypted vector and the second encrypted vector. Since the first encrypted vector and the second encrypted vector are both encrypted based on the first target public key in the first target public-private key pair generated by the first device, in the embodiments of the present application, in order to determine the target distance of the first vector and the second vector, the second device can send the determined distance between the first vector and the second vector after encryption to the first device, so that the first device decrypts the distance between the first vector and the second vector after encryption based on the first target private key in the first target public-private key pair generated by the first device to generate the target distance, and sends the target distance to the second device. The second device receives the target distance sent by the first device.

[0223] Since in the embodiments of the present application, the first data does not leave the first device in the form of original data, the original data can also be matched without leaving the library, and the security of the matching process is further ensured.

[0224] Embodiment 14

[0225] In order to obtain the target distance of the first vector and the second vector determined based on the first encryption vector and the second encryption vector, on the basis of the above embodiments, the obtaining of the target distance of the first vector and the second vector determined based on the first encryption vector and the second encryption vector comprises the following steps.

[0226] sending the second encryption vector to the first device, so that the first device determines the distance between the first encryption vector after homomorphic encryption of the first vector based on the second encryption vector and the first encryption vector generated based on the first target public key generated by itself.

[0227] receiving the target distance of the first vector and the second vector sent by the first device, wherein the target distance is obtained by decrypting the distance between the first encryption vector and the second encryption vector after encryption based on the target private key corresponding to the first target public key generated by itself.

[0228] In the embodiments of the present application, in order to obtain the target distance of the first vector and the second vector determined based on the first encryption vector and the second encryption vector, in addition to sending the first target public key and the first encryption vector to the second device, so that the second device determines the distance between the first encryption vector and the second encryption vector after encryption based on the first encryption vector and the second encryption vector generated based on the first target public key, the first device can also only send the first target public key to the second device.

[0229] After receiving the first target public key sent by the first device, the second device homomorphically encrypts the second vector based on the first target public key, generates the second encryption vector, and then sends the second encryption vector to the first device, so that the first device determines the distance between the first encryption vector and the second encryption vector after encryption based on the second encryption vector and the first encryption vector, and decrypts the distance between the first encryption vector and the second encryption vector after encryption based on the first target private key in the first target public and private key generated by itself, determines the target distance of the first vector and the second vector and sends it to the second device, and the second device receives the target distance of the first vector and the second vector sent by the first device, and can determine whether the first data and the second data match based on the target distance.

[0230] Figure 6 For the overall process schematic diagram of the fuzzy matching of the data of the two parties provided by some embodiments of the present application, the following will be described. Figure 6

[0231] ​The first data and the second data to be matched are input into the pre-trained vector conversion model, and a first vector corresponding to the first data to be matched and a second vector corresponding to the second data to be matched are output. The first vector and the second vector are homomorphically encrypted based on the first target public key, and a first encrypted vector and a second encrypted vector are obtained. The distance between the encrypted first vector and the second vector is determined according to the first encrypted vector and the second encrypted vector. The distance between the encrypted first vector and the second vector is decrypted based on the first target private key to determine a target distance between the first vector and the second vector. The target distance is compared with a preset first distance threshold to determine a matching result.

[0232] Figure 7 A specific process diagram for two-way data fuzzy matching is provided for some embodiments of the present application. Now, the specific process diagram will be described with reference to Figure 7 .

[0233] The first device inputs the first data to be matched into the pre-trained vector conversion model deployed in the first device, and obtains a first vector corresponding to the first data. The second device inputs the second data to be matched into the pre-trained vector conversion model deployed in the second device, and obtains a second vector corresponding to the second data. As Figure 7 indicated above, the first data includes four first sub-data, namely U1, U2, U3, and U4, and the first sub-vector corresponding to U1 is (x11, x12, x13, …, x1m), the first sub-vector corresponding to U2 is (x21, x22, x23, …, x2m), the first sub-vector corresponding to U3 is (x31, x32, x33, …, x3m), and the first sub-vector corresponding to U4 is (x41, x42, x43, …, x4m). The first vector corresponding to the first data is (x11, x12, x13, …, x1m, x21, x22, x23, …, x2m, x31, x32, x33, …, x3m, x41, x42, x43, …, x4m). The second data includes four second sub-data, namely U5, U6, U7, and U8, and the second sub-vector corresponding to U5 is (y11, y12, y13, …, y1m), the second sub-vector corresponding to U6 is (y21, y22, y23, …, y2m), the second sub-vector corresponding to U7 is (y31, y32, y33, …, y3m), and the second sub-vector corresponding to U8 is (y41, y42, y43, …, y4m). The second vector corresponding to the second data is (y11, y12, y13, …, y1m, y21, y22, y23, …, y2m, y31, y32, y33, …, y3m, y41, y42, y43, …, y4m).

[0234] The first device generates a first target public-private key pair A (pka, ska), wherein the pka is a first target public key and the ska is a first target private key, and the first target public-private key pair is a homomorphic encryption target public-private key pair. A first vector is homomorphic encrypted based on the first target public key to generate a first encrypted vector, and the first encrypted vector corresponding to (x11, x12, x13, …, x1m, x21, x22, x23, …, x2m, x31, x32, x33, …, x3m, x41, x42, x43, …, x4m) is (E pka (x11), E pka (x12), E pka (x13), …, E pka (x1m), E pka (x21), E pka (x22), E pka (x23), …, E pka (x2m), E pka (x31), E pka (x32), E pka (x33), …, E pka (x3m), E pka (x41), E pka (x42), E pka (x43), …, E pka (x4m). The first encrypted vector includes m / 2 groups of encrypted first encrypted components and first encrypted square components.

[0235] The first device sends the first target public key and the first encrypted vector to a second device. After receiving the first target public key and the first encrypted vector, the second device homomorphic encrypts a second vector based on the first target public key to generate a second encrypted vector, and the second encrypted vector corresponding to (y11, y12, y13, …, y1m, y21, y22, y23, …, y2m, y31, y32, y33, …, y3m, y41, y42, y43, …, y4m) is (E pka (y11), E pka (y12), E pka (y13), …, E pka (y1m), E pka (y21), E pka (y22), E pka (y23), …, E pka (y2m), E pka (y31), E pka (y32), E pka (y33), …, E pka (y3m), E pka(y41), E pka (y42), E pka (y43) …, E pka (y4m))}. Wherein the second encryption vector contains m / 2 groups of encrypted second encryption components and second encryption square components.

[0236] For each encrypted first sub-vector and the corresponding each encrypted second sub-vector, the second device determines the distance between the encrypted first sub-vector and the second sub-vector, determines the encrypted distance matrix based on the distance between each encrypted first sub-vector and the second sub-vector, and sends the encrypted distance matrix to the first device.

[0237] After receiving the encrypted distance matrix sent by the second device, the first device decrypts the encrypted distance matrix based on the first target private key generated by the first device, that is, decrypts the distance between each encrypted first sub-vector and the second sub-vector to obtain a target sub-distance matrix. The first device determines whether the first sub-data and the second sub-data match based on the target sub-distance matrix, wherein each element in the target sub-distance matrix is a corresponding target sub-distance. The first device sends the target sub-distance matrix to the second device, and the second device also obtains the target sub-distance matrix. The second device determines whether the first sub-data and the second sub-data match based on the target sub-distance matrix.

[0238] Embodiment 15:

[0239] In order to obtain the target distance of the first vector and the second vector determined based on the first encryption vector and the second encryption vector, on the basis of the above embodiments, the target distance of the first vector and the second vector determined based on the first encryption vector and the second encryption vector comprises:

[0240] Homomorphically encrypt the second vector with the second target public key generated by itself to obtain a third encryption vector, and send the second target public key and the third encryption vector to the first device;

[0241] Receive the distance between the encrypted second vector and the first vector based on the third encryption vector and the fourth encryption vector sent by the first device, wherein the fourth encryption vector is generated by homomorphically encrypting the first vector with the second target public key;

[0242] Determine the target distance of the first vector and the second vector based on the encrypted distance of the first vector and the second vector and the second target private key corresponding to the second target public key, and determine whether the first data and the second data match based on the target distance and the preset first distance threshold.

[0243] In order to enable the first device and the second device to determine whether the first data and the second data match, in the embodiments of the present application, the second device can also obtain the target distance of the first vector and the second vector, where the target distance of the first vector and the second vector can be obtained by the second device after decrypting the distance between the encrypted first vector and the encrypted second vector sent by the first device.

[0244] Specifically, the second device can homomorphically encrypt the second vector by using a second target public key generated by itself to obtain a third encrypted vector, and send the third encrypted vector and the second target public key to the first device. After receiving the third encrypted vector and the second target public key, the first device homomorphically encrypts the first vector based on the second target public key to obtain a fourth encrypted vector. The first device can determine the distance between the encrypted first vector and the encrypted second vector according to the third encrypted vector and the fourth encrypted vector, and send the distance between the encrypted first vector and the encrypted second vector to the second device. After receiving the distance between the encrypted first vector and the encrypted second vector, the second device decrypts the distance between the encrypted first vector and the encrypted second vector by using a second target private key corresponding to the second target public key generated by itself to obtain the target distance of the first vector and the second vector, and determines whether the first data and the second data match according to the target distance of the first vector and the second vector and a preset first distance threshold.

[0245] The process of determining whether the first data and the second data match according to the target distance of the first vector and the second vector and the preset first distance threshold by the second device is the same as the process of determining whether the first data and the second data match according to the target distance of the first vector and the second vector and the preset first distance threshold by the first device, and will not be described here.

[0246] In the embodiments of the present application, the second data does not leave the second device in the form of original data, which realizes fuzzy matching without original data leaving the library and further guarantees the security of the matching process.

[0247] Embodiment 16

[0248] In order to obtain the target distance of the first vector and the second vector determined based on the first encrypted vector and the second encrypted vector, on the basis of the above embodiments, the inputting of the second data to be matched into the vector conversion model pre-trained to obtain the second vector corresponding to the second data comprises:

[0249] For each second sub-data in the second data, the second sub-data is input into the vector conversion model pre-trained to obtain a second sub-vector corresponding to the second sub-data, and the length of the second sub-vector corresponding to each second sub-data is the first preset length.

[0250] The second vectors corresponding to each of the second sub-data are spliced to obtain the second vector corresponding to the second data.

[0251] In the embodiments of the present application, one second data can contain one second sub-data, or can contain multiple second sub-data. For example, the second data contains one second sub-data "Shanghai Pudong New Area, Sunny Small Shop", and the second data can also contain three second sub-data, such as "Shanghai Pudong New Area, Sunny Small Shop", "Shanghai City, Every Day Restaurant", and "Gaoke Road, Yang Guofu Spicy Hot Pot".

[0252] In order to determine the second vector corresponding to the second data, the second data in each second sub-data can be input into the pre-trained vector conversion model to obtain the second sub-vector corresponding to the second sub-data, wherein the length of the text or number or character contained in each second sub-data can be different, but the length of the second sub-vector corresponding to each second sub-data is the first preset length, wherein the first preset length can be 3, or 4 or 6, etc. Specifically, the first preset length can be set according to the requirement.

[0253] For example, when the second data contains "Shanghai Pudong New Area, Sunny Small Shop", "Shanghai City, Every Day Restaurant", and "Gaoke Road, Yang Guofu Spicy Hot Pot", "Shanghai Pudong New Area, Sunny Small Shop" is input into the pre-trained word vector model, and the output second sub-vector corresponding to "Shanghai Pudong New Area, Sunny Small Shop" is (2.0, 3.0, 2.5, 1.0, 1.5). "Shanghai City, Every Day Restaurant" is input into the pre-trained word vector model, and the output second sub-vector corresponding to "Shanghai City, Every Day Restaurant" is (2.3, 4.4, 3.5, 4.5, 2.5). "Gaoke Road, Yang Guofu Spicy Hot Pot" is input into the pre-trained word vector model, and the output second sub-vector corresponding to "Gaoke Road, Yang Guofu Spicy Hot Pot" is (2.5, 2.7, 8.3, 4.5, 1.5).

[0254] If the second data contains three second sub-data, each of which is numerical data, the three numerical data are "54321", "00001", and "33322" respectively, then "54321" is input into the word vector model pre-trained, and the output second sub-vector corresponding to "54321" is (0000100000, 0000010000, 0000001000, 0000000100, 0000000010), "00001" is input into the word vector model pre-trained, and the output second sub-vector corresponding to "000011" is (0000000000, 0000000000, 0000000000, 0000000010, 0000000010), and "33322" is input into the word vector model pre-trained, and the output second sub-vector corresponding to "22233" is (0000000010, 0000000010, 0000000010, 0000000100, 0000000100).

[0255] To determine the second vector corresponding to the second data, in the embodiments of the present application, after obtaining the second sub-vector corresponding to each second sub-data in the second data, the second sub-vector corresponding to each second sub-data is spliced, and the spliced result is determined as the second vector corresponding to the second data. Specifically, each second sub-data contained in the second data can be sorted randomly first, and the second sub-vector corresponding to the second sub-data is sorted and spliced according to the sorting result of the second sub-data, to obtain the second vector.

[0256] For example, when the second data contains "Shanghai Pudong New Area Sunny Small Shop", "Shanghai City Daily Catering Shop", and "Gaoke Road Yang Guofu Spicy Hot Pot", the second sub-vector corresponding to "Shanghai Pudong New Area Sunny Small Shop" is (1.0, 2.0, 1.5), the second sub-vector corresponding to "Shanghai City Daily Catering Shop" is (3.0, 4.0, 2.5), and the second sub-vector corresponding to "Gaoke Road Yang Guofu Spicy Hot Pot" is (4.5, 5.5, 7.5). After each second sub-data contained in the second data is sorted randomly, the obtained sorting result is "Shanghai Pudong New Area Sunny Small Shop", "Gaoke Road Yang Guofu Spicy Hot Pot", and "Shanghai City Daily Catering Shop". Then, the second vector corresponding to the second data is obtained by splicing the second sub-vectors corresponding to the three second sub-data according to the sorting result, and the second vector is (1.0, 2.0, 1.5, 4.5, 5.5, 7.5, 1.0, 2.0, 1.5).

[0257] To realize the fuzzy matching of the first data and the second data, on the basis of the above embodiments, the lengths of the first vector and the second vector are both the second preset length.

[0258] In the embodiments of the present application, in order to realize the fuzzy matching of the first data and the second data, the length of the first vector corresponding to the obtained first data and the length of the second vector corresponding to the second data must be the same, and both are the second preset length, wherein the second preset length is not less than the first preset length, the second preset length is an integer multiple of the first preset length, and if the second data only contains one second sub-data, the first preset length is equal to the second preset length.

[0259] Since the length of the first vector corresponding to the first data and the length of the second vector corresponding to the second data are both the second preset length, even if the first data and the second data are not the same, fuzzy matching can be realized, which widens the use scenario.

[0260] Embodiment 17:

[0261] In order to determine the second encrypted vector, on the basis of the above-mentioned embodiments, the step of generating the second encrypted vector by homomorphically encrypting the second vector by using the first target public key comprises:

[0262] For each second component in the second vector, determining a second square component corresponding to the second component;

[0263] Inserting the second square component corresponding to each second component into the second vector according to a preset insertion rule, and updating the vector obtained after inserting the second square component as the second vector;

[0264] Homomorphically encrypting each second component and each second square component in the second vector based on the first target public key to generate the second encrypted vector.

[0265] In order to generate the second encrypted vector, in the embodiments of the present application, the second vector can be directly homomorphically encrypted based on the first target public key to obtain the encrypted second encrypted vector. In order to ensure that the distance between the encrypted first vector and the second vector can be determined based on the first encrypted vector and the second encrypted vector without decrypting the second encrypted vector and the second encrypted vector, in the embodiments of the present application, the second square component corresponding to each second component in the second vector can also be determined first.

[0266] For example, if the second vector is (1, 2, 4, 5, 3), the second square component corresponding to the second component 1 in the second vector is 1, the second square component corresponding to the second component 2 in the second vector is 4, the second square component corresponding to the second component 4 in the second vector is 16, the second square component corresponding to the second component 5 in the second vector is 25, and the second square component corresponding to the second component 3 in the second vector is 9.

[0267] In the embodiment of the present application, after each second component in the second vector is determined, the second square component corresponding to the second component is determined, and then the second square component corresponding to each second component is inserted into the second vector according to a preset rule, and the vector obtained after the second square component is inserted is updated as the second vector. Specifically, for the second square component corresponding to each second component, the second square component corresponding to the second component can be inserted into any position in the second vector, such as being inserted in front of the second component in the second vector, or being inserted behind the second component in the second vector, or being sequentially inserted behind the second component, as long as the first device and the second device can identify the second component and the second square component in each vector.

[0268] For example, if the second vector is (1, 2, 4, 5, 3), after the second square component of each second component in the second vector is determined, the second square component is inserted into the second vector, and the updated second vector obtained after the second square component is inserted is (1, 9, 2, 16, 4, 4, 5, 25, 1, 3).

[0269] In order to facilitate subsequent determination of the distance between the encrypted first vector and the second vector based on the second vector into which the second square component is inserted, in the embodiment of the present application, after each second component in the second vector is determined, the second square component corresponding to the second component is determined, and then the second square component corresponding to each second component is inserted into the second vector according to a preset insertion rule, and the vector obtained after the second square component is inserted is updated as the second vector. Specifically, the second square component corresponding to the second component can be inserted into a position behind the second component and adjacent to the second component in the second vector.

[0270] For example, if the second vector is (1, 2, 4, 5, 3), after the second square component of each second component in the second vector is determined, the second square component is inserted into the second vector, and the updated second vector obtained after the second square component is inserted is (1, 1, 2, 4, 4, 16, 5, 25, 3, 9).

[0271] After the updated second vector is determined, in order to determine the second encrypted vector, in the embodiment of the present application, each second component and each second square component in the second vector can be homomorphically encrypted based on the first target public key to generate the second encrypted vector.

[0272] For example, if the updated second vector is (2, 4, 3, 9), then the second encrypted vector is (E pka (2), E pka (4), E pka (3), Epka (9)), wherein the E pka (2) representing a result of homomorphic encryption of a second component of the second vector that is 2 based on the target public key, the E pka (4) representing a result of homomorphic encryption of a second component of the second vector that is 4 based on the target public key, the E pka (3) representing a result of homomorphic encryption of a second component of the second vector that is 3 based on the target public key, the E pka (9) representing a result of homomorphic encryption of a second component of the second vector that is 9 based on the target public key.

[0273] Embodiment 18:

[0274] In order to obtain the target distance of the first vector and the second vector determined based on the first encrypted vector and the second encrypted vector, on the basis of each of the above embodiments, the distance of the first vector and the second vector after encryption is determined according to the first encrypted vector and the second encrypted vector, and includes:

[0275] According to the preset insertion rule and each second component in the second encrypted vector, each group of second encrypted components and second encrypted square components is obtained; and according to the preset insertion rule and each first component in the first encrypted vector, each group of first encrypted components and first encrypted square components is obtained;

[0276] According to the preset insertion rule, each group of corresponding first encrypted components, first encrypted square components, second encrypted components and second encrypted square components is determined;

[0277] According to each group of first encrypted components, first encrypted square components, second encrypted components and second encrypted square components, each sub-distance after encryption is determined;

[0278] According to the sum value of each sub-distance, the distance of the first vector and the second vector after encryption is determined.

[0279] In the embodiments of the present application, in order to determine the distance of the first vector and the second vector after encryption, the second device can obtain each group of second encrypted components and second encrypted square components according to the preset insertion rule and each second component in the second encrypted vector, wherein a group of second encrypted components and second encrypted square components are homomorphic encryption of the same component itself and the square component of the component. That is, in each group of second encrypted components and second encrypted square components, the second encrypted square component is obtained by homomorphic encryption of the second square component corresponding to the second component corresponding to the second encrypted component before encryption.

[0280] Specifically, if the preset insertion rule is to insert the second square component corresponding to the second component into the position behind the second component and adjacent to the second component in the second vector. When determining each group of second encrypted components and second encrypted square components, the component of the group to be determined can be directly started from the first component of the second vector, the next component of the group to be determined in the second vector and the component of the group to be determined are determined as a group, and the division is sequentially performed until all groups of second encrypted components and second encrypted square components are determined.

[0281] For example, the second encrypted vector is (E pka (2), E pka (4), E pka (3), E pka (9)), two groups of second encrypted components and second encrypted square components can be obtained, wherein the second group is E pka (2), E pka (4), and the second group is E pka (3), E pka (9). Wherein, E pka (2) in the second group is the second encrypted component in the second group, E pka (4) is the second encrypted square component in the second group, E pka (3) in the second group is the second encrypted component in the second group, and E pka (9) is the second encrypted square component in the second group.

[0282] In the embodiment of the application, after obtaining the first encrypted vector sent by the first device, the second device can also obtain each group of first encrypted components and first encrypted square components according to the preset insertion rule and each first component in the first encrypted vector, wherein the preset insertion rule corresponding to the second vector is the same as the preset insertion rule corresponding to the first vector, and the process of obtaining each group of second encrypted components and second encrypted square components is the same as the process of obtaining each group of first encrypted components and first encrypted square components, which will not be repeated here.

[0283] In order to determine the distance between the encrypted first vector and the second vector, in the embodiment of the application, each encrypted sub-distance can be determined according to each group of first encrypted components, first encrypted square components, second encrypted components and second encrypted square components. Specifically, for each group, the target sum of the first encrypted horizontal component and the second encrypted square component in the group can be determined first, and then the target product of the first encrypted component, the second encrypted component and the preset numerical value in the group can be determined, wherein the preset numerical value is 2 in the embodiment of the application. Finally, the target difference value of the target sum and the target product is determined as the encrypted sub-distance determined by the group.

[0284] After the encrypted sub-distances of each group are determined, the distance between the first encrypted vector and the second encrypted vector can be determined according to the sum value of each sub-distance.

[0285] Embodiment 19

[0286] In order to obtain a target distance between the first vector and the second vector determined based on the first encrypted vector and the second encrypted vector, on the basis of the above embodiments, the method for determining whether the first data and the second data match based on the target distance and a preset first distance threshold value comprises the following steps of:

[0287] determining whether the target distance is less than the preset first distance threshold value;

[0288] if yes, determining that the first data and the second data match;

[0289] otherwise, determining that the first data and the second data do not match.

[0290] In order to determine whether the first data and the second data match, in the embodiments of the present application, the target distance and the preset distance threshold value are compared. If the target distance is less than the preset first distance threshold value, it is determined that the first data and the second data match. If the target distance is not less than the preset first distance threshold value, it is determined that the first data and the second data do not match. The preset first distance threshold value can be 1, 1.5, etc. Specifically, the preset first distance threshold value can be set according to requirements. The smaller the target distance, the more matched the first vector and the second vector.

[0291] In order to obtain a target distance between the first vector and the second vector determined based on the first encrypted vector and the second encrypted vector, on the basis of the above embodiments, after the first data and the second data are determined to match, the method further comprises the following steps of:

[0292] determining whether the target distance is equal to a preset second distance threshold value, and if yes, determining that the first data and the second data are the same.

[0293] In the embodiments of the present application, if the target distance is equal to the preset second distance threshold value, it means that the first data and the second data are the same, that is, the first data and the second data are completely matched. The preset second distance threshold value is less than the preset first distance threshold value, and the preset second distance threshold value is equal to 0.

[0294] Embodiment 20

[0295] Figure 8 A data matching device structure schematic diagram is provided for some embodiments of the present application. The device comprises:

[0296] The first obtaining module 801 is configured to input first data to be matched into a pre-trained vector conversion model to obtain a first vector corresponding to the first data.

[0297] The first processing module 802 is configured to perform homomorphic encryption on the first vector by using a first target public key generated by itself to obtain a first encrypted vector, and send the first target public key to a second device.

[0298] The first obtaining module 801 is further configured to obtain a distance between the first vector and a second vector after encryption, which is determined based on the first encrypted vector and a second encrypted vector, wherein the second encrypted vector is obtained by performing homomorphic encryption on the second vector by using the first target public key, and the second vector is obtained by inputting second data into the pre-trained vector conversion model in the second device.

[0299] The first determining module 803 is configured to determine a target distance between the first vector and the second vector based on the distance between the first vector and the second vector after encryption and a first target private key corresponding to the first target public key, and determine whether the first data and the second data are matched based on the target distance and a pre-set first distance threshold.

[0300] In a possible implementation, the first obtaining module 801 is specifically configured to determine a first target data type corresponding to the first data, determine a pre-trained first target vector conversion model corresponding to the first data according to the first target data type and a pre-stored correspondence between data types and pre-trained vector conversion models, and input the first data into the pre-trained first target vector conversion model to obtain the first vector corresponding to the first data.

[0301] In a possible implementation, the first processing module 802 is specifically configured to send the first encrypted vector and the first target public key to the second device.

[0302] The first obtaining module 801 is specifically configured to receive a distance between the first vector and the second vector after encryption, which is sent by the second device and determined based on the first encrypted vector and a second encrypted vector, wherein the second encrypted vector is obtained by the second device based on homomorphic encryption on the second vector by using the first target public key.

[0303] In a possible implementation, the first processing module 802 is further configured to receive a third encryption vector sent by the second device and a second target public key generated by the second device; the third encryption vector is obtained by homomorphic encryption of the second vector by the second device using the second target public key; generate a fourth encryption vector by homomorphic encryption of the first vector based on the second target public key; determine the distance between the encrypted second vector and the first vector based on the third encryption vector and the fourth encryption vector, and send the distance between the encrypted second vector and the first vector to the second device, so that the second device decrypts the distance between the encrypted second vector and the first vector according to the distance between the encrypted second vector and the first vector and a second target private key corresponding to the second target public key, determines the target distance between the second vector and the first vector, and determines whether the first data and the second data match according to the target distance between the second vector and the first vector and a preset first distance threshold.

[0304] In a possible implementation, the first processing module 801 is further configured to send the target distance between the first vector and the second vector to the second device, so that the second device determines whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0305] In a possible implementation, the first obtaining module 801 is specifically configured to decrypt the distance between the encrypted first vector and second vector using a first target private key corresponding to the first target public key generated by the first device itself, to determine the target distance between the first vector and the second vector.

[0306] In a possible implementation, the first obtaining module 801 is specifically configured to, for each first sub-data in the first data, input the first sub-data into a pre-trained vector conversion model to obtain a first sub-vector corresponding to the first sub-data; the length of the first sub-vector corresponding to each first sub-data is a first preset length; and concatenate the first sub-vector corresponding to each first sub-data to obtain the first vector corresponding to the first data.

[0307] In a possible implementation, the first processing module 802 is specifically configured to determine, for each first component in the first vector, a first square component corresponding to the first component; insert the first square component corresponding to each first component into the first vector according to a preset insertion rule, and update the vector obtained after inserting the first square component as the first vector; and perform homomorphic encryption on each first component and each first square component in the first vector based on the first target public key, to generate the first encrypted vector.

[0308] In a possible implementation, the first obtaining module 801 is specifically configured to obtain each group of first encrypted components and first encrypted square components according to the preset insertion rule and each first component in the first encrypted vector; and obtain each group of second encrypted components and second encrypted square components according to the preset insertion rule and each second component in the second encrypted vector; determine, according to the preset insertion rule, each group of corresponding first encrypted components, first encrypted square components, second encrypted components and second encrypted square components; determine each sub-encrypted distance according to each group of first encrypted components, first encrypted square components, second encrypted components and second encrypted square components; and determine the distance between the first encrypted vector and the second encrypted vector according to the sum of each sub-encrypted distance.

[0309] In a possible implementation, the first determining module 803 is specifically configured to determine whether the target distance is less than a preset first distance threshold; if yes, determine that the first data and the second data match; otherwise, determine that the first data and the second data do not match.

[0310] In a possible implementation, the first determining module 803 is further configured to determine whether the target distance is equal to a preset second distance threshold; if yes, determine that the first data and the second data are the same.

[0311] Embodiment 21

[0312] Figure 9 A structural schematic diagram of a data matching device provided by some embodiments of the present application is shown in FIG. 1. The device includes:

[0313] The second obtaining module 901 is configured to input the second data to be matched into a pre-trained vector conversion model, to obtain a second vector corresponding to the second data.

[0314] The second processing module 902 is configured to receive a first target public key sent by a first device, and perform homomorphic encryption on the second vector based on the first target public key to generate a second encrypted vector.

[0315] The second acquisition module 901 is further configured to acquire the target distance between the first vector and the second vector determined based on the first encryption vector and the second encryption vector, wherein the first encryption vector is obtained by encrypting the first vector using the first target public key, and the first vector is obtained by inputting the first data into a pre-trained vector transformation model in the first device;

[0316] The second determining module 903 is used to determine whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0317] In one possible implementation, the second acquisition module 901 is specifically used to determine the second target data type corresponding to the second data; determine the pre-trained second target vector conversion model corresponding to the second data based on the correspondence between the second target data type and the pre-saved data type and the pre-trained vector conversion model; and input the second data into the pre-trained second target vector conversion model to obtain the second vector corresponding to the second data.

[0318] In one possible implementation, the second processing module 902 is specifically used to receive the first target public key and the first encryption vector sent by the first device, wherein the first encryption vector is obtained by homomorphically encrypting the first vector using the first target public key;

[0319] The second acquisition module 901 is specifically used to determine the distance between the encrypted first vector and the second vector based on the first encryption vector and the second encryption vector; send the distance between the encrypted first vector and the second vector to the first device; and receive the target distance sent by the first device, wherein the target distance is obtained by the first device decrypting the distance between the encrypted first vector and the second vector using the first target private key corresponding to the first target public key it generates.

[0320] In one possible implementation, the second acquisition module 901 is specifically configured to send the second encryption vector to the first device, so that the first device determines the distance between the encrypted first encryption vector and the second encryption vector based on the second encryption vector and the first encryption vector; and receive the target distance between the first vector and the second vector sent by the first device, wherein the target distance is obtained by the first device decrypting the distance between the encrypted first encryption vector and the second encryption vector based on the first target private key corresponding to the first target public key generated by itself.

[0321] In one possible implementation, the second acquisition module 901 is specifically configured to perform homomorphic encryption on the second vector using a second target public key generated by itself to obtain a third encrypted vector, and send the second target public key and the third encrypted vector to the first device; receive data from the first device based on the third encrypted vector and a fourth encrypted vector, and determine the distance between the encrypted second vector and the first vector, wherein the fourth encrypted vector is generated by homomorphically encrypting the first vector using the second target public key; determine the target distance between the first vector and the second vector based on the distance between the encrypted first vector and the second vector and the second target private key corresponding to the second target public key; and determine whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0322] In one possible implementation, the second acquisition module 901 is specifically used to input each second sub-data in the second data into a pre-trained vector transformation model to obtain the second sub-vector corresponding to the second sub-data; wherein the length of the second sub-vector corresponding to each second sub-data is a first preset length; and the second sub-vectors corresponding to each second sub-data are concatenated to obtain the second vector corresponding to the second data.

[0323] In one possible implementation, the second processing module 902 is specifically configured to: determine the second square component corresponding to each second component in the second vector; insert the second square component corresponding to each second component into the second vector according to a preset insertion rule; update the vector obtained after inserting the second square component to the second vector; and perform homomorphic encryption on each second component and each second square component in the second vector based on the first target public key to generate the second encrypted vector.

[0324] In one possible implementation, the second acquisition module 901 is specifically configured to: acquire each group of second encrypted components and second encrypted squared components according to the preset insertion rules and each second component in the second encryption vector; acquire each group of first encrypted components and first encrypted squared components according to the preset insertion rules and each first component in the first encryption vector; determine each corresponding group of first encrypted components, first encrypted squared components, second encrypted components and second encrypted squared components according to the preset insertion rules; determine each encrypted sub-distance according to each group of first encrypted components, first encrypted squared components, second encrypted components and second encrypted squared components; and determine the distance between the encrypted first vector and the second vector according to the sum of each sub-distance.

[0325] In one possible implementation, the second determining module 903 is specifically used to determine whether the target distance is less than a preset first distance threshold; if so, it is determined that the first data and the second data match; otherwise, it is determined that the first data and the second data do not match.

[0326] In one possible implementation, the second determining module 903 is further configured to determine whether the target distance is equal to a preset second distance threshold; if so, it is determined that the first data and the second data are the same.

[0327] Example 22:

[0328] Based on the above embodiments, some embodiments of this application also provide an electronic device, such as... Figure 10 As shown, it includes: processor 1001, communication interface 1002, memory 1003 and communication bus 1004, wherein processor 1001, communication interface 1002 and memory 1003 communicate with each other through communication bus 1004.

[0329] The memory 1003 stores a computer program, which, when executed by the processor 1001, causes the processor 1001 to perform the following steps:

[0330] The first data to be matched is input into a pre-trained vector transformation model to obtain the first vector corresponding to the first data.

[0331] The first target public key generated by itself is used to homomorphically encrypt the first vector to generate a first encrypted vector, and the first target public key is sent to the second device;

[0332] Obtain the distance between the encrypted first vector and the second vector determined based on the first encryption vector and the second encryption vector, wherein the second encryption vector is obtained by homomorphically encrypting the second vector using the first target public key; the second vector is obtained by inputting the second data into a pre-trained vector transformation model in the second device;

[0333] Based on the distance between the encrypted first vector and the second vector and the first target private key corresponding to the first target public key, the target distance between the first vector and the second vector is determined. Based on the target distance and a preset first distance threshold, it is determined whether the first data and the second data match.

[0334] Furthermore, the processor 1001 is also configured to determine the first target data type corresponding to the first data; determine the pre-trained first target vector conversion model corresponding to the first data based on the correspondence between the first target data type and the pre-saved data type and the pre-trained vector conversion model; and input the first data into the pre-trained first target vector conversion model to obtain the first vector corresponding to the first data.

[0335] Furthermore, the processor 1001 is also configured to receive the second encryption vector sent by the second device, wherein the second encryption vector is obtained by the second device performing homomorphic encryption on the second vector based on the first target public key; and to determine the distance between the encrypted first vector and the second vector based on the first encryption vector and the second encryption vector.

[0336] Furthermore, the processor 1001 is also configured to send the first encryption vector and the first target public key to the second device; and receive the distance between the encrypted first vector and the second vector determined based on the first encryption vector and the second encryption vector sent by the second device, wherein the second encryption vector is obtained by the second device performing homomorphic encryption on the second vector based on the first target public key.

[0337] Further, the processor 1001 is also configured to receive a third encryption vector sent by the second device and a second target public key generated by the second device; wherein, the third encryption vector is obtained by the second device using the second target public key to perform homomorphic encryption on the second vector; generate a fourth encryption vector by homomorphically encrypting the first vector based on the second target public key; determine the distance between the encrypted second vector and the first vector based on the third encryption vector and the fourth encryption vector, and send the distance between the encrypted second vector and the first vector to the second device, so that the second device decrypts the distance between the encrypted second vector and the first vector according to the distance between the encrypted second vector and the first vector and the second target private key corresponding to the second target public key, determines the target distance between the second vector and the first vector, and determines whether the first data and the second data match according to the target distance between the second vector and the first vector and a preset first distance threshold.

[0338] Furthermore, the processor 1001 is also configured to send the target distance between the first vector and the second vector to the second device, so that the second device determines whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0339] Furthermore, the processor 1001 is also configured to use a first target private key corresponding to the first target public key generated by the first device itself to decrypt the distance between the encrypted first vector and the second vector, and determine the target distance between the first vector and the second vector.

[0340] Furthermore, the processor 1001 is also configured to input each first sub-data in the first data into a pre-trained vector transformation model to obtain a first sub-vector corresponding to the first sub-data; wherein the length of the first sub-vector corresponding to each first sub-data is a first preset length; and to concatenate the first sub-vectors corresponding to each first sub-data to obtain the first vector corresponding to the first data.

[0341] Furthermore, the processor 1001 is also configured to determine the first square component corresponding to each first component in the first vector; insert the first square component corresponding to each first component into the first vector according to a preset insertion rule, and update the vector obtained after inserting the first square component to the first vector; and perform homomorphic encryption on each first component and each first square component in the first vector based on the first target public key to generate the first encrypted vector.

[0342] Furthermore, the processor 1001 is also configured to: obtain each group of first encrypted components and first encrypted squared components according to the preset insertion rules and each first component in the first encrypted vector; and obtain each group of second encrypted components and second encrypted squared components according to the preset insertion rules and each second component in the second encrypted vector; determine each corresponding group of first encrypted components, first encrypted squared components, second encrypted components and second encrypted squared components according to the preset insertion rules; determine each encrypted sub-distance according to each group of first encrypted components, first encrypted squared components, second encrypted components and second encrypted squared components; and determine the distance between the encrypted first vector and the second vector according to the sum of each sub-distance.

[0343] Furthermore, the processor 1001 is also configured to determine whether the target distance is less than a preset first distance threshold; if so, it is determined that the first data matches the second data; otherwise, it is determined that the first data does not match the second data.

[0344] Furthermore, the processor 1001 is also configured to determine whether the target distance is equal to a preset second distance threshold, and if so, to determine that the first data and the second data are the same.

[0345] The communication bus mentioned in the above server can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0346] The communication interface 1002 is used for communication between the above-mentioned electronic device and other devices.

[0347] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0348] The processors mentioned above can be general-purpose processors, including central processing units, network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits, field-programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0349] Example 23:

[0350] Based on the above embodiments, some embodiments of this application also provide an electronic device, such as... Figure 11 As shown, it includes: processor 1101, communication interface 1102, memory 1103 and communication bus 1104, wherein processor 1101, communication interface 1102 and memory 1103 communicate with each other through communication bus 1104.

[0351] The memory 1103 stores a computer program, which, when executed by the processor 1101, causes the processor 1101 to perform the following steps:

[0352] The second data to be matched is input into a pre-trained vector transformation model to obtain the second vector corresponding to the second data;

[0353] Receive a first target public key sent by a first device, and use the first target public key to perform homomorphic encryption on the second vector to generate a second encrypted vector;

[0354] Obtain the target distance between the first vector and the second vector determined based on the first encryption vector and the second encryption vector, wherein the first encryption vector is obtained by encrypting the first vector using the first target public key, and the first vector is obtained by inputting the first data into a pre-trained vector transformation model in the first device;

[0355] Based on the target distance and a preset first distance threshold, it is determined whether the first data and the second data match.

[0356] Furthermore, the processor 1101 is also configured to determine the second target data type corresponding to the second data; determine the pre-trained second target vector conversion model corresponding to the second data based on the correspondence between the second target data type and the pre-saved data type and the pre-trained vector conversion model; and input the second data into the pre-trained second target vector conversion model to obtain the second vector corresponding to the second data.

[0357] Furthermore, the processor 1101 is also configured to receive the first target public key and the first encryption vector sent by the first device, wherein the first encryption vector is obtained by homomorphically encrypting the first vector using the first target public key; determine the distance between the encrypted first vector and the second vector based on the first encryption vector and the second encryption vector; send the distance between the encrypted first vector and the second vector to the first device; and receive the target distance sent by the first device, wherein the target distance is obtained by the first device decrypting the distance between the encrypted first vector and the second vector using the first target private key corresponding to the first target public key it generates.

[0358] Furthermore, the processor 1101 is also configured to send the second encryption vector to the first device, so that the first device determines the distance between the encrypted first encryption vector and the second encryption vector based on the second encryption vector and the first encryption vector; and receive the target distance between the first vector and the second vector sent by the first device, wherein the target distance is obtained by the first device decrypting the distance between the encrypted first encryption vector and the second encryption vector based on the first target private key corresponding to the first target public key generated by itself.

[0359] Furthermore, the processor 1101 is also configured to perform homomorphic encryption on the second vector using a second target public key generated by itself to obtain a third encryption vector, and send the second target public key and the third encryption vector to the first device; receive data from the first device based on the third encryption vector and a fourth encryption vector, and determine the distance between the encrypted second vector and the first vector, wherein the fourth encryption vector is generated by homomorphically encrypting the first vector using the second target public key; determine the target distance between the first vector and the second vector based on the distance between the encrypted first vector and the second vector and the second target private key corresponding to the second target public key; and determine whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0360] Furthermore, the processor 1101 is also configured to input each second sub-data in the second data into a pre-trained vector transformation model to obtain a second sub-vector corresponding to the second sub-data; wherein the length of the second sub-vector corresponding to each second sub-data is a first preset length; and to concatenate the second sub-vectors corresponding to each second sub-data to obtain the second vector corresponding to the second data.

[0361] Furthermore, the processor 1101 is also configured to determine the second square component corresponding to each second component in the second vector; insert the second square component corresponding to each second component into the second vector according to a preset insertion rule, and update the vector obtained after inserting the second square component to the second vector; and perform homomorphic encryption on each second component and each second square component in the second vector based on the first target public key to generate the second encrypted vector.

[0362] Furthermore, the processor 1101 is also configured to: obtain each group of second encrypted components and second encrypted squared components according to the preset insertion rules and each second component in the second encrypted vector; obtain each group of first encrypted components and first encrypted squared components according to the preset insertion rules and each first component in the first encrypted vector; determine each corresponding group of first encrypted components, first encrypted squared components, second encrypted components and second encrypted squared components according to the preset insertion rules; determine each encrypted sub-distance according to each group of first encrypted components, first encrypted squared components, second encrypted components and second encrypted squared components; and determine the distance between the encrypted first vector and the second vector according to the sum of each sub-distance.

[0363] Furthermore, the processor 1101 is also configured to determine whether the target distance is less than a preset first distance threshold; if so, it is determined that the first data and the second data match; otherwise, it is determined that the first data and the second data do not match.

[0364] Furthermore, the processor 1101 is also configured to determine whether the target distance is equal to a preset second distance threshold, and if so, to determine that the first data and the second data are the same.

[0365] The communication bus mentioned in the above server can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0366] Communication interface 1102 is used for communication between the above-mentioned electronic device and other devices.

[0367] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0368] The processors mentioned above can be general-purpose processors, including central processing units, network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits, field-programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0369] Example 24:

[0370] Based on the above embodiments, this application also provides a computer-readable storage medium storing a computer program executable by an electronic device. When the program is run on the electronic device, the electronic device performs the following steps:

[0371] The first data to be matched is input into a pre-trained vector transformation model to obtain the first vector corresponding to the first data.

[0372] The first target public key generated by itself is used to homomorphically encrypt the first vector to generate a first encrypted vector, and the first target public key is sent to the second device;

[0373] Obtain the distance between the encrypted first vector and the second vector determined based on the first encryption vector and the second encryption vector, wherein the second encryption vector is obtained by homomorphically encrypting the second vector using the first target public key; the second vector is obtained by inputting the second data into a pre-trained vector transformation model in the second device;

[0374] Based on the distance between the encrypted first vector and the second vector and the first target private key corresponding to the first target public key, the target distance between the first vector and the second vector is determined. Based on the target distance and a preset first distance threshold, it is determined whether the first data and the second data match.

[0375] Further, the step of inputting the first data to be matched into a pre-trained vector transformation model to obtain the first vector corresponding to the first data includes:

[0376] Determine the first target data type corresponding to the first data;

[0377] Based on the first target data type and the correspondence between the pre-saved data types and the pre-trained vector transformation model, determine the pre-trained first target vector transformation model corresponding to the first data;

[0378] The first data is input into the pre-trained first target vector transformation model to obtain the first vector corresponding to the first data.

[0379] Furthermore, the first target data type is either text or numeric.

[0380] Furthermore, if the first target data type is text, the corresponding pre-trained first target vector conversion model is a word vector model or a sentence vector model; if the first target data type is numeric, the corresponding pre-trained first target vector conversion model is a one-hot encoding model.

[0381] Further, obtaining the distance between the encrypted first vector and the second vector determined based on the first encryption vector and the second encryption vector includes:

[0382] The device receives the second encryption vector sent by the second device, wherein the second encryption vector is obtained by the second device performing homomorphic encryption on the second vector based on the first target public key; and determines the distance between the encrypted first vector and the second vector based on the first encryption vector and the second encryption vector.

[0383] Further, sending the first target public key to the second device includes:

[0384] Send the first encryption vector and the first target public key to the second device;

[0385] The step of obtaining the distance between the encrypted first vector and the second encrypted vector, determined based on the first encryption vector and the second encryption vector, includes:

[0386] The device receives the distance between the encrypted first vector and the second vector, determined based on the first encryption vector and the second encryption vector, sent by the second device. The second encryption vector is obtained by the second device performing homomorphic encryption on the second vector based on the first target public key.

[0387] Furthermore, the method also includes:

[0388] The device receives a third encryption vector sent by the second device and a second target public key generated by the second device; wherein the third encryption vector is obtained by the second device homomorphically encrypting the second vector using the second target public key;

[0389] Based on the second target public key, the first vector is homomorphically encrypted to generate a fourth encrypted vector;

[0390] Based on the third and fourth encryption vectors, the distance between the encrypted second vector and the first vector is determined, and the distance between the encrypted second vector and the first vector is sent to the second device. This allows the second device to decrypt the distance between the encrypted second vector and the first vector based on the distance between the encrypted second vector and the first vector and the second target private key corresponding to the second target public key, determine the target distance between the second vector and the first vector, and determine whether the first data and the second data match based on the target distance between the second vector and the first vector and a preset first distance threshold.

[0391] Furthermore, after determining the target distance between the first vector and the second vector, the method further includes:

[0392] The target distance between the first vector and the second vector is sent to the second device, so that the second device determines whether the first data and the second data match based on the target distance and a preset first distance threshold.

[0393] Further, determining the target distance between the first vector and the second vector based on the distance between the encrypted first vector and the second vector and the first target private key corresponding to the first target public key includes:

[0394] The first target private key, corresponding to the first target public key generated by the first device itself, is used to decrypt the distance between the encrypted first vector and the second vector to determine the target distance between the first vector and the second vector.

[0395] Further, the step of inputting the first data to be matched into a pre-trained vector transformation model to obtain the first vector corresponding to the first data includes:

[0396] For each first sub-data in the first data, the first sub-data is input into a pre-trained vector transformation model to obtain the first sub-vector corresponding to the first sub-data; wherein, the length of the first sub-vector corresponding to each first sub-data is a first preset length;

[0397] The first sub-vectors corresponding to each first sub-data are concatenated to obtain the first vector corresponding to the first data.

[0398] Furthermore, the lengths of both the first vector and the second vector are second preset lengths.

[0399] Furthermore, the step of using a self-generated first target public key to homomorphically encrypt the first vector to generate a first encrypted vector includes:

[0400] For each first component in the first vector, determine the first squared component corresponding to that first component;

[0401] The first square component corresponding to each first component is inserted into the first vector according to a preset insertion rule, and the vector obtained after inserting the first square component is updated to the first vector;

[0402] Based on the first target public key, each first component and each first square component in the first vector are homomorphically encrypted to generate the first encrypted vector.

[0403] Further, obtaining the distance between the encrypted first vector and the second vector determined based on the first encryption vector and the second encryption vector includes:

[0404] According to the preset insertion rules and each first component in the first encryption vector, obtain each group of first encryption components and first encryption square components; and according to the preset insertion rules and each second component in the second encryption vector, obtain each group of second encryption components and second encryption square components.

[0405] According to the preset insertion rules, determine the corresponding first encrypted component, first encrypted squared component, second encrypted component and second encrypted squared component for each group;

[0406] Based on each group of first encrypted components, first encrypted squared components, second encrypted components, and second encrypted squared components, determine each encrypted sub-distance;

[0407] The distance between the encrypted first vector and the second vector is determined based on the sum of each sub-distance.

[0408] Further, determining whether the first data and the second data match based on the target distance and a preset first distance threshold includes:

[0409] Determine whether the target distance is less than a preset first distance threshold;

[0410] If so, then the first data and the second data are determined to match;

[0411] Otherwise, it is determined that the first data and the second data do not match.

[0412] Furthermore, after determining that the first data matches the second data, the method further includes:

[0413] Determine whether the target distance is equal to a preset second distance threshold. If so, determine that the first data and the second data are the same.

[0414] Example 25:

[0415] Based on the above embodiments, this application also provides a computer-readable storage medium storing a computer program executable by an electronic device. When the program is run on the electronic device, the electronic device performs the following steps:

[0416] The second data to be matched is input into a pre-trained vector transformation model to obtain the second vector corresponding to the second data;

[0417] Receive a first target public key sent by a first device, and use the first target public key to perform homomorphic encryption on the second vector to generate a second encrypted vector;

[0418] Obtain the target distance between the first vector and the second vector determined based on the first encryption vector and the second encryption vector, wherein the first encryption vector is obtained by encrypting the first vector using the first target public key, and the first vector is obtained by inputting the first data into a pre-trained vector transformation model in the first device;

[0419] Based on the target distance and a preset first distance threshold, it is determined whether the first data and the second data match.

[0420] Further, the step of inputting the second data to be matched into a pre-trained vector transformation model to obtain the second vector corresponding to the second data includes:

[0421] Determine the second target data type corresponding to the second data;

[0422] Based on the second target data type and the correspondence between the pre-saved data type and the pre-trained vector transformation model, determine the pre-trained second target vector transformation model corresponding to the second data;

[0423] The second data is input into the pre-trained second target vector transformation model to obtain the second vector corresponding to the second data.

[0424] Furthermore, the second target data type is either text or number.

[0425] Furthermore, if the second target data type is text, the corresponding pre-trained second target vector conversion model is a word vector model or a sentence vector model; if the second target data type is numeric, the corresponding pre-trained second target vector conversion model is a one-hot encoding model.

[0426] Furthermore, the first target public key sent by the first device includes:

[0427] The device receives the first target public key and the first encryption vector sent by the first device, wherein the first encryption vector is obtained by homomorphically encrypting the first vector using the first target public key;

[0428] The step of obtaining the target distance between the first vector and the second vector determined based on the first encryption vector and the second encryption vector includes:

[0429] Based on the first encryption vector and the second encryption vector, determine the distance between the encrypted first vector and the second vector;

[0430] Send the distance between the encrypted first vector and the second vector to the first device;

[0431] The first device receives the target distance sent by the first device, wherein the target distance is obtained by the first device decrypting the distance between the encrypted first vector and the second vector using the first target private key corresponding to the first target public key it generates.

[0432] Further, obtaining the target distance between the first vector and the second vector determined based on the first encryption vector and the second encryption vector includes:

[0433] The second encryption vector is sent to the first device so that the first device can determine the distance between the encrypted first encryption vector and the second encryption vector based on the second encryption vector and the first encryption vector;

[0434] The device receives the target distance between the first vector and the second vector sent by the first device, wherein the target distance is obtained by the first device decrypting the distance between the encrypted first vector and the second encrypted vector based on the first target private key corresponding to the first target public key it generates.

[0435] Further, obtaining the target distance between the first vector and the second vector determined based on the first encryption vector and the second encryption vector includes:

[0436] The second vector is homomorphically encrypted using a self-generated second target public key to obtain a third encrypted vector, and the second target public key and the third encrypted vector are sent to the first device.

[0437] The distance between the encrypted second vector and the first vector is determined by receiving the third encryption vector and the fourth encryption vector sent by the first device, wherein the fourth encryption vector is generated by homomorphically encrypting the first vector using the second target public key;

[0438] Based on the distance between the encrypted first vector and the second vector and the second target private key corresponding to the second target public key, the target distance between the first vector and the second vector is determined. Based on the target distance and a preset first distance threshold, it is determined whether the first data and the second data match.

[0439] Further, the step of inputting the second data to be matched into a pre-trained vector transformation model to obtain the second vector corresponding to the second data includes:

[0440] For each second sub-data in the second data, the second sub-data is input into a pre-trained vector transformation model to obtain the second sub-vector corresponding to the second sub-data; wherein, the length of the second sub-vector corresponding to each second sub-data is a first preset length;

[0441] The second sub-vectors corresponding to each second sub-data are concatenated to obtain the second vector corresponding to the second data.

[0442] Furthermore, the lengths of both the first vector and the second vector are second preset lengths.

[0443] Further, the step of using the first target public key to homomorphically encrypt the second vector to generate the second encrypted vector includes:

[0444] For each second component in the second vector, determine the corresponding second square component;

[0445] The second square component corresponding to each second component is inserted into the second vector according to the preset insertion rules, and the vector obtained after inserting the second square component is updated to the second vector;

[0446] Based on the first target public key, each second component and each second square component in the second vector are homomorphically encrypted to generate the second encrypted vector.

[0447] Further, determining the distance between the encrypted first vector and the second encrypted vector based on the first encryption vector and the second encryption vector includes:

[0448] According to the preset insertion rules and each second component in the second encryption vector, obtain each group of second encryption components and second encryption square components; and according to the preset insertion rules and each first component in the first encryption vector, obtain each group of first encryption components and first encryption square components.

[0449] According to the preset insertion rules, determine the corresponding first encrypted component, first encrypted squared component, second encrypted component and second encrypted squared component for each group;

[0450] Based on each group of first encrypted components, first encrypted squared components, second encrypted components, and second encrypted squared components, determine each encrypted sub-distance;

[0451] The distance between the encrypted first vector and the second vector is determined based on the sum of each sub-distance.

[0452] Further, determining whether the first data and the second data match based on the target distance and a preset first distance threshold includes:

[0453] Determine whether the target distance is less than a preset first distance threshold;

[0454] If so, then the first data and the second data are determined to match;

[0455] Otherwise, it is determined that the first data and the second data do not match.

[0456] Furthermore, after determining that the first data matches the second data, the method further includes:

[0457] Determine whether the target distance is equal to a preset second distance threshold. If so, determine that the first data and the second data are the same.

[0458] In this embodiment, the first and second data to be matched are input into a pre-trained vector transformation model to obtain the first vector corresponding to the first data and the second vector corresponding to the second data. The first encrypted vector and the second encrypted vector are obtained based on the first target public key. The distance between the encrypted first and second vectors is determined, and the target distance between the first and second vectors is determined based on the distance and the first target private key generated by the model. The matching of the first and second data is determined based on the target distance and a preset first distance threshold. This achieves fuzzy matching even when the first and second data are not completely identical, broadening the application scenarios. Furthermore, the introduction of homomorphic encryption and decryption using the first target public key and first target private key during fuzzy matching ensures secure intersection and guarantees the security of the matching process. Throughout the matching process, neither the first nor the second data leaves the corresponding first or second device in its original form, ensuring fuzzy matching even without the original data leaving the database, further guaranteeing the security of the matching process.

[0459] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0460] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure One One or more processes and / or boxes Figure One A device that provides the functions specified in one or more boxes.

[0461] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure One One or more processes and / or boxes Figure One The function specified in one or more boxes.

[0462] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure One One or more processes and / or boxes Figure One Figure One The steps of the function specified in one or more boxes.

[0463] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A data matching method, characterized in that, Applied to a first device, the method includes: The first data to be matched is input into a pre-trained vector transformation model to obtain the first vector corresponding to the first data. The first target public key generated by itself is used to homomorphically encrypt the first vector to generate a first encrypted vector, and the first target public key is sent to the second device; Obtain the distance between the encrypted first vector and the second vector determined based on the first encryption vector and the second encryption vector, wherein the second encryption vector is obtained by homomorphically encrypting the second vector using the first target public key; the second vector is obtained by inputting the second data into a pre-trained vector transformation model in the second device; Based on the distance between the encrypted first vector and the second vector and the first target private key corresponding to the first target public key, the target distance between the first vector and the second vector is determined. Based on the target distance and a preset first distance threshold, it is determined whether the first data and the second data match. The step of inputting the first data to be matched into a pre-trained vector transformation model to obtain the first vector corresponding to the first data includes: Determine the first target data type corresponding to the first data; Based on the first target data type and the correspondence between the pre-saved data types and the pre-trained vector transformation model, determine the pre-trained first target vector transformation model corresponding to the first data; The first data is input into the pre-trained first target vector transformation model to obtain the first vector corresponding to the first data.

2. The method according to claim 1, characterized in that, The first target data type is either text or number.

3. The method according to claim 2, characterized in that, If the first target data type is text, the corresponding pre-trained first target vector conversion model is a word vector model or a sentence vector model; if the first target data type is numeric, the corresponding pre-trained first target vector conversion model is a one-hot encoding model.

4. The method according to claim 1, characterized in that, The step of obtaining the distance between the encrypted first vector and the second encrypted vector, determined based on the first encryption vector and the second encryption vector, includes: The device receives the second encryption vector sent by the second device, wherein the second encryption vector is obtained by the second device performing homomorphic encryption on the second vector based on the first target public key; Based on the first encryption vector and the second encryption vector, the distance between the encrypted first vector and the second vector is determined.

5. The method according to claim 1, characterized in that, Sending the first target public key to the second device includes: Send the first encryption vector and the first target public key to the second device; The step of obtaining the distance between the encrypted first vector and the second encrypted vector, determined based on the first encryption vector and the second encryption vector, includes: The device receives the distance between the encrypted first vector and the second vector, determined based on the first encryption vector and the second encryption vector, sent by the second device. The second encryption vector is obtained by the second device performing homomorphic encryption on the second vector based on the first target public key.

6. The method according to claim 5, characterized in that, The method further includes: The device receives a third encryption vector sent by the second device and a second target public key generated by the second device; wherein the third encryption vector is obtained by the second device homomorphically encrypting the second vector using the second target public key; Based on the second target public key, the first vector is homomorphically encrypted to generate a fourth encrypted vector; Based on the third and fourth encryption vectors, the distance between the encrypted second vector and the first vector is determined, and the distance between the encrypted second vector and the first vector is sent to the second device. This allows the second device to decrypt the distance between the encrypted second vector and the first vector based on the distance between the encrypted second vector and the first vector and the second target private key corresponding to the second target public key, determine the target distance between the second vector and the first vector, and determine whether the first data and the second data match based on the target distance between the second vector and the first vector and a preset first distance threshold.

7. The method according to claim 1, 4, or 5, characterized in that, After determining the target distance between the first vector and the second vector, the method further includes: The target distance between the first vector and the second vector is sent to the second device, so that the second device determines whether the first data and the second data match based on the target distance and a preset first distance threshold.

8. The method according to claim 1, 4, or 5, characterized in that, Determining the target distance between the first vector and the second vector based on the distance between the encrypted first vector and the second vector and the first target private key corresponding to the first target public key includes: The first target private key corresponding to the first target public key generated by the first device itself is used to decrypt the distance between the encrypted first vector and the second vector to determine the target distance between the first vector and the second vector.

9. The method according to claim 1, characterized in that, The step of inputting the first data to be matched into a pre-trained vector transformation model to obtain the first vector corresponding to the first data includes: For each first sub-data in the first data, the first sub-data is input into a pre-trained vector transformation model to obtain the first sub-vector corresponding to the first sub-data; wherein, the length of the first sub-vector corresponding to each first sub-data is a first preset length; The first sub-vectors corresponding to each first sub-data are concatenated to obtain the first vector corresponding to the first data.

10. The method according to claim 1 or 9, characterized in that, The lengths of both the first vector and the second vector are second preset lengths.

11. The method according to claim 1, characterized in that, The step of using a self-generated first target public key to homomorphically encrypt the first vector to generate the first encrypted vector includes: For each first component in the first vector, determine the first squared component corresponding to that first component; The first square component corresponding to each first component is inserted into the first vector according to a preset insertion rule, and the vector obtained after inserting the first square component is updated to the first vector; Based on the first target public key, each first component and each first square component in the first vector are homomorphically encrypted to generate the first encrypted vector.

12. The method according to claim 11, characterized in that, The step of obtaining the distance between the encrypted first vector and the second encrypted vector, determined based on the first encryption vector and the second encryption vector, includes: According to the preset insertion rules and each first component in the first encryption vector, obtain each group of first encryption components and first encryption square components; and according to the preset insertion rules and each second component in the second encryption vector, obtain each group of second encryption components and second encryption square components. According to the preset insertion rules, determine the corresponding first encrypted component, first encrypted squared component, second encrypted component and second encrypted squared component for each group; Based on each group of first encrypted components, first encrypted squared components, second encrypted components, and second encrypted squared components, determine each encrypted sub-distance; The distance between the encrypted first vector and the second vector is determined based on the sum of each sub-distance.

13. The method according to claim 1, characterized in that, The step of determining whether the first data and the second data match based on the target distance and a preset first distance threshold includes: Determine whether the target distance is less than a preset first distance threshold; If so, then the first data and the second data are determined to match; Otherwise, it is determined that the first data and the second data do not match.

14. The method according to claim 13, characterized in that, After determining that the first data matches the second data, the method further includes: Determine whether the target distance is equal to a preset second distance threshold. If so, determine that the first data and the second data are the same.

15. A data matching method, characterized in that, Applied to a second device, the method includes: The second data to be matched is input into a pre-trained vector transformation model to obtain the second vector corresponding to the second data; Receive a first target public key sent by a first device, and use the first target public key to perform homomorphic encryption on the second vector to generate a second encrypted vector; Obtain the target distance between the first vector and the second vector determined based on the first encryption vector and the second encryption vector, wherein the first encryption vector is obtained by homomorphically encrypting the first vector using the first target public key, and the first vector is obtained by inputting the first data into a pre-trained vector transformation model in the first device; Based on the target distance and a preset first distance threshold, it is determined whether the first data and the second data match; The step of inputting the second data to be matched into a pre-trained vector transformation model to obtain the second vector corresponding to the second data includes: Determine the second target data type corresponding to the second data; Based on the second target data type and the correspondence between the pre-saved data type and the pre-trained vector transformation model, determine the pre-trained second target vector transformation model corresponding to the second data; The second data is input into the pre-trained second target vector transformation model to obtain the second vector corresponding to the second data.

16. The method according to claim 15, characterized in that, The second target data type is either text or number.

17. The method according to claim 16, characterized in that, If the second target data type is text, the corresponding pre-trained second target vector conversion model is a word vector model or a sentence vector model; if the second target data type is numeric, the corresponding pre-trained second target vector conversion model is a one-hot encoding model.

18. The method according to claim 15, characterized in that, The first target public key sent by the first device includes: The first target public key and the first encryption vector sent by the first device are received, wherein the first encryption vector is obtained by homomorphically encrypting the first vector using the first target public key; The step of obtaining the target distance between the first vector and the second vector determined based on the first encryption vector and the second encryption vector includes: Based on the first encryption vector and the second encryption vector, determine the distance between the encrypted first vector and the second vector; Send the distance between the encrypted first vector and the second vector to the first device; The first device receives the target distance sent by the first device, wherein the target distance is obtained by the first device decrypting the distance between the encrypted first vector and the second vector using the first target private key corresponding to the first target public key it generates.

19. The method according to claim 15, characterized in that, The step of obtaining the target distance between the first vector and the second vector determined based on the first encryption vector and the second encryption vector includes: The second encryption vector is sent to the first device so that the first device can determine the distance between the encrypted first encryption vector and the second encryption vector based on the second encryption vector and the first encryption vector; The device receives the target distance between the first vector and the second vector sent by the first device, wherein the target distance is obtained by the first device decrypting the distance between the encrypted first vector and the second encrypted vector based on the first target private key corresponding to the first target public key it generates.

20. The method according to claim 15, characterized in that, The step of obtaining the target distance between the first vector and the second vector determined based on the first encryption vector and the second encryption vector includes: The second vector is homomorphically encrypted using a self-generated second target public key to obtain a third encrypted vector, and the second target public key and the third encrypted vector are sent to the first device. The distance between the encrypted second vector and the first vector is determined by receiving the third encryption vector and the fourth encryption vector sent by the first device, wherein the fourth encryption vector is generated by homomorphically encrypting the first vector using the second target public key; Based on the distance between the encrypted first vector and the second vector and the second target private key corresponding to the second target public key, the target distance between the first vector and the second vector is determined. Based on the target distance and a preset first distance threshold, it is determined whether the first data and the second data match.

21. The method according to claim 15, characterized in that, The step of inputting the second data to be matched into a pre-trained vector transformation model to obtain the second vector corresponding to the second data includes: For each second sub-data in the second data, the second sub-data is input into a pre-trained vector transformation model to obtain the second sub-vector corresponding to the second sub-data; wherein, the length of the second sub-vector corresponding to each second sub-data is a first preset length; The second sub-vectors corresponding to each second sub-data are concatenated to obtain the second vector corresponding to the second data.

22. The method according to claim 15 or 21, characterized in that, The lengths of both the first vector and the second vector are second preset lengths.

23. The method according to claim 15, characterized in that, The step of using the first target public key to perform homomorphic encryption on the second vector to generate the second encrypted vector includes: For each second component in the second vector, determine the corresponding second square component; The second square component corresponding to each second component is inserted into the second vector according to the preset insertion rules, and the vector obtained after inserting the second square component is updated to the second vector; Based on the first target public key, each second component and each second square component in the second vector are homomorphically encrypted to generate the second encrypted vector.

24. The method according to claim 18 or 23, characterized in that, Determining the distance between the encrypted first vector and the second encrypted vector based on the first encryption vector and the second encryption vector includes: According to the preset insertion rules and each second component in the second encryption vector, obtain each group of second encryption components and second encryption square components; and according to the preset insertion rules and each first component in the first encryption vector, obtain each group of first encryption components and first encryption square components. According to the preset insertion rules, determine the corresponding first encrypted component, first encrypted squared component, second encrypted component and second encrypted squared component for each group; Based on each group of first encrypted components, first encrypted squared components, second encrypted components, and second encrypted squared components, determine each encrypted sub-distance; The distance between the encrypted first vector and the second vector is determined based on the sum of each sub-distance.

25. The method according to claim 15, characterized in that, The step of determining whether the first data and the second data match based on the target distance and a preset first distance threshold includes: Determine whether the target distance is less than a preset first distance threshold; If so, then the first data and the second data are determined to match; Otherwise, it is determined that the first data and the second data do not match.

26. The method according to claim 25, characterized in that, After determining that the first data matches the second data, the method further includes: Determine whether the target distance is equal to a preset second distance threshold. If so, determine that the first data and the second data are the same.

27. A data matching device, characterized in that, Applied to a first device, the device includes: The first acquisition module is used to input the first data to be matched into a pre-trained vector transformation model to obtain the first vector corresponding to the first data; The first processing module is configured to use its own generated first target public key to perform homomorphic encryption on the first vector to generate a first encrypted vector, and send the first target public key to the second device; The first acquisition module is further configured to acquire the distance between the encrypted first vector and the second vector determined based on the first encryption vector and the second encryption vector, wherein the second encryption vector is obtained by homomorphically encrypting the second vector using the first target public key; the second vector is obtained by inputting the second data into a pre-trained vector transformation model in the second device; The first determining module is used to determine the target distance between the first vector and the second vector based on the distance between the encrypted first vector and the second vector and the first target private key corresponding to the first target public key, and to determine whether the first data and the second data match based on the target distance and a preset first distance threshold. The first acquisition module is used to determine the first target data type corresponding to the first data; determine the pre-trained first target vector conversion model corresponding to the first data based on the correspondence between the first target data type and the pre-saved data type and the pre-trained vector conversion model; and input the first data into the pre-trained first target vector conversion model to obtain the first vector corresponding to the first data.

28. A data matching device, characterized in that, Applied to a second device, the device includes: The second acquisition module is used to input the second data to be matched into a pre-trained vector conversion model to obtain the second vector corresponding to the second data; The second processing module is used to receive the first target public key sent by the first device, and use the first target public key to perform homomorphic encryption on the second vector to generate a second encrypted vector. The second acquisition module is further configured to acquire the target distance between the first vector and the second vector determined based on the first encryption vector and the second encryption vector, wherein the first encryption vector is obtained by encrypting the first vector using the first target public key, and the first vector is obtained by inputting the first data into a pre-trained vector transformation model in the first device; The second determining module is used to determine whether the first data and the second data match based on the target distance and a preset first distance threshold. The second acquisition module is used to determine the second target data type corresponding to the second data; determine the pre-trained second target vector conversion model corresponding to the second data based on the correspondence between the second target data type and the pre-saved data type and the pre-trained vector conversion model; and input the second data into the pre-trained second target vector conversion model to obtain the second vector corresponding to the second data.

29. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory being used to store program instructions, and the processor being used to execute the computer program stored in the memory to implement the steps of any of the data matching methods of claims 1-14 or any of the data matching methods of claims 15-26.

30. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the steps of any of the data matching methods described in claims 1-14 or 15-26.

Citation Information

Patent Citations

  • Lattice-supported fully homomorphic short ciphertext attribute-based encryption method and system

    CN111970106A

  • Compact fuzzy private matching using a fully-homomorphic encryption scheme

    US20160119119A1