Vector similarity judgment method under malicious adversary model and communication device
By using the Paillier encryption algorithm and stealth transmission technology, public and private key information is generated, and vector similarity is determined. This solves the problems of accuracy and confidentiality in vector similarity determination under the malicious adversary model, and realizes secure computation under the malicious adversary model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE COMM LTD RES INST
- Filing Date
- 2021-06-25
- Publication Date
- 2026-05-29
AI Technical Summary
Existing vector similarity assessment methods cannot be effectively applied to malicious adversary models, and they fail to truly calculate Euclidean distance, resulting in inaccurate detection results. Furthermore, the small data sample size limits their applicability.
By employing the Paillier encryption algorithm and stealth transmission technology, initial parameters are generated by producing public and private key information, and encryption and decryption verification of data vectors are performed to ensure the accuracy and confidentiality of vector similarity calculation under the malicious adversary model.
Secure vector similarity calculation was achieved under the malicious adversary model, ensuring the accuracy and confidentiality of the calculation results, preventing data tampering, and improving the credibility and wide applicability of the detection results.
Smart Images

Figure CN115525907B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of communication, in particular to a vector similarity judgment method under a malicious adversary model and a communication device. BACKGROUND
[0002] With the development of the data era, privacy leakage events occur frequently, and privacy leakage problems are attracting more and more attention. How to protect the privacy of data while using data has become the focus of security researchers. In order to solve this problem, secure multi-party computation technology is proposed. The Euclidean distance calculation between two points has important application value. For example, in some machine learning algorithms, the Euclidean distance between two points needs to be calculated to judge the similarity. In the federated learning scenario, multiple parties need to calculate the Euclidean distance between their own data and the data of other participants, while ensuring the privacy of the data of each party. Because the Euclidean distance is calculated between two points, this secure multi-party computation problem can be reduced to secure two-party Euclidean distance calculation. Under the premise of ensuring data privacy, how to perform secure two-party Euclidean distance calculation under a malicious adversary model, ensure the correctness of the result while obtaining the result, can judge the similarity between vectors based on the privacy protection of vector scaling transformation, efficiently judge the similarity between vectors without disclosing the value of each dimension of the vector, and the performance of the ciphertext comparison and the plaintext comparison is almost the same.
[0003] However, the above vector similarity judgment method under privacy protection is based on a semi-honest model and does not verify the calculation result. In the semi-honest model, the participants cannot tamper with or send false data. In the real scene, the two parties often do not trust each other and do not want the other party to get the real data, which has great limitations in actual application. Moreover, the above judgment method only compares the vector module length through homomorphic encryption to judge the similarity of the vector, and does not really calculate the Euclidean distance itself. If the module length is similar after comparison, the detection result will be incorrect, which has great limitations in actual application. Moreover, the standard vector to be compared in the above judgment method is only two, and the data sample is small, which does not have wide applicability. SUMMARY
[0004] The purpose of the embodiments of the present application is to provide a vector similarity judgment method under a malicious adversary model and a communication device to solve the problem of the existing vector similarity judgment method having great limitations and not having wide applicability.
[0005] In order to solve the above problems, the embodiments of the present application provide a vector similarity judgment method under a malicious adversary model, the malicious adversary model comprising a first communication device and a second communication device, and the method comprising:
[0006] The first communication device generates key information including a public key and a private key, and sends the public key to the second communication device;
[0007] The first communication device and the second communication device respectively generate initial parameters;
[0008] The first communication device and the second communication device perform calculations based on their own data vectors, key information, and initial parameters, and exchange the intermediate parameters obtained from the calculations.
[0009] The first communication device and the second communication device respectively verify the intermediate parameters to determine whether the first data vector of the first communication device and the second data vector of the second communication device are similar.
[0010] Wherein, the first communication device and the second communication device respectively generate initial parameters, including:
[0011] The first communication device inputs a second security parameter, generates initial parameters for the first communication device, and sends them to the second communication device. The initial parameters of the first communication device include: a first random number r. A The first hash function H() and the similarity threshold Δ;
[0012] The second communication device inputs a third security parameter to generate initial parameters for the second communication device. These initial parameters include a second random number r. B The third random number R and the random salt value salt.
[0013] The first communication device and the second communication device perform calculations based on their own data vectors, key information, and initial parameters, and exchange the intermediate parameters obtained from the calculations, including:
[0014] The first communication device uses the public key and the first random number r. A and the first data vector x i Perform the calculation to obtain the first intermediate parameter E(x) i +r A ) and the second intermediate parameter E(x) i And send it to the second communication device; where E() represents encryption processing;
[0015] The second communication device, based on the second intermediate parameter E(x) i ), public key, second data vector y i And perform calculations using the third random number R to obtain the third intermediate parameter E(Rx). i -Ry i And send it to the first communication device;
[0016] The first communication device uses its private key to decrypt the third intermediate parameter E(Rx). i -Ry i Then, the fourth intermediate parameter M is calculated and sent to the second communication device; where, M = ∑ i (Rx i -Ry i ) 2 .
[0017] The first communication device and the second communication device perform calculations based on their own data vectors, key information, and initial parameters, and exchange the intermediate parameters obtained from the calculations. The method also includes:
[0018] The second communication device, based on the first intermediate parameter E(x) i +r A ), public key, second data vector y i And the second random number r B Perform the calculation to obtain the first data set E(x) i +r A )·E(-y i ) and the second data set E(x) i +r A )·E(-y i +r B ), and the first data group E(x) i +r A )·E(-y i ) and the second data set E(x) i +r A )·E(-y i +r B After being randomly sorted, the data is sent to the first communication device;
[0019] The first communication device uses its private key to decrypt the first data group E(x). i +r A )·E(-y i After derandomization, s values are selected to calculate the fifth intermediate parameter τ = ∑ i∈[1,s] (x i -y i ) 2 And send it to the second communication device;
[0020] The first communication device uses its private key to decrypt the second data group E(x) i +r A )·E(-y i +r B After derandomization, the sixth intermediate parameter x is obtained. i -y i +r BSelect ns sixth intermediate parameters x i -y i +r B Send to the second communication device; where n is the number of the first data vector and the second data vector, and s is an integer greater than 0 and less than n;
[0021] The second communication device receives ns sixth intermediate parameters x i -y i +r B After derandomization, the seventh intermediate parameter τ′=∑ i∈[1,n-s] (x i -y i ) 2 ;
[0022] The second communication device sums the seventh intermediate parameter τ′ and the fifth intermediate parameter τ to obtain the eighth intermediate parameter z.
[0023] The method further includes:
[0024] The second communication device obtains the first hash value h based on the first hash function H(), the third random number R, and the random salt value salt, and sends the first hash value h to the first communication device.
[0025] The first communication device and the second communication device respectively verify the intermediate parameters to determine whether the first data vector of the first communication device and the second data vector of the second communication device are similar, including:
[0026] The second communication device determines whether the product of the third random number R and the eighth intermediate parameter z is equal to the fourth intermediate parameter M; if they are equal, it determines the first data vector x. i Second data vector y i The result of the Euclidean distance calculation is like Within the similarity judgment threshold Δ, the second communication device determines the first data vector x. i Second data vector y i resemblance;
[0027] The second communication device determines the first data vector x. i Second data vector y i After similarity is achieved, the second communication device sends the seventh intermediate parameter τ′, the third random number R, and the random salt value salt to the first communication device;
[0028] The first communication device obtains a second hash value h′ based on the first hash function H(), the third random number R, and the random salt value salt. If the second hash value h′ is the same as the first hash value h, the first communication device sums the seventh intermediate parameter τ′ and the fifth intermediate parameter τ to obtain the calculation parameter z′.
[0029] The first communication device determines whether the product of the third random number R and the calculation parameter z′ is equal to the fourth intermediate parameter M; if they are equal, it determines the first data vector x. i Second data vector y i The result of the Euclidean distance calculation is like Within the similarity judgment threshold Δ, the first communication device determines the first data vector x. i Second data vector y i resemblance.
[0030] The first communication device uses the public key and the first random number r A and the first data vector x i Perform the calculation to obtain the first intermediate parameter E(x) i +r A ),include:
[0031] The first communication device uses the homomorphism of the Paillier encryption algorithm to process the first random number r. A and the first data vector x i Perform the calculation to obtain the first intermediate parameter E(x) i +r A );
[0032] Wherein, E(x) i +r A )=E(x i )×E(r A ); E(x) i ) represents x encrypted using the public key. i E(r) A ) represents r encrypted using the public key. A The public key is the public key for the Paillier encryption algorithm.
[0033] The second communication device is based on the second intermediate parameter E(x) i ), public key, second data vector y i And perform calculations using the third random number R to obtain the third intermediate parameter E(Rx). i -Ry i ),include:
[0034] The second communication device determines the third intermediate parameter E(Rx) i -Ryi )=(E(x i )) R ·(E(-y i )) R .
[0035] The second communication device obtains the first hash value h based on the first hash function H(), the third random number R, and the random salt value salt, including:
[0036] The second communication device determines the first hash value h = H(salt||R).
[0037] The first communication device uses a first hash function H(), a third random number R, and a random salt value salt to obtain a second hash value h′, including:
[0038] The first communication device determines the second hash value h′=H(salt||R).
[0039] This invention also provides a communication device, which includes a first communication device and a second communication device in a malicious adversary model. The communication device includes a processor and a transceiver, wherein the transceiver receives and transmits data under the control of the processor. The processor of the first communication device is configured to perform the following operations:
[0040] Generate key information including a public key and a private key, and send the public key to the second communication device;
[0041] The processors of the first communication device and the second communication device are further configured to perform the following operations:
[0042] Generate initial parameters respectively;
[0043] Each component performs calculations based on its own data vector, key information, and initial parameters, and then exchanges the intermediate parameters obtained from the calculations.
[0044] The intermediate parameters are verified to determine whether the first data vector of the first communication device and the second data vector of the second communication device are similar.
[0045] The processor of the first communication device is further configured to perform the following operations:
[0046] Input a second security parameter, generate initial parameters for the first communication device, and send them to the second communication device. The initial parameters for the first communication device include: a first random number r. A The first hash function H() and the similarity threshold Δ;
[0047] The processor of the second communication device is also used to perform the following operations:
[0048] Input the third security parameter to generate the initial parameters of the second communication device. The initial parameters of the second communication device include: a second random number r. B The third random number R and the random salt value salt.
[0049] The processor of the first communication device is further configured to perform the following operations:
[0050] Based on the public key and the first random number r A and the first data vector x i Perform the calculation to obtain the first intermediate parameter E(x) i +r A ) and the second intermediate parameter E(x) i And send it to the second communication device; where E() represents encryption processing;
[0051] The processor of the second communication device is also used to perform the following operations:
[0052] According to the second intermediate parameter E(x) i ), public key, second data vector y i And perform calculations using the third random number R to obtain the third intermediate parameter E(Rx). i -Ry i And send it to the first communication device;
[0053] The processor of the first communication device is also configured to perform the following operations:
[0054] Decrypt the third intermediate parameter E(Rx) using the private key i -Ry i Then, the fourth intermediate parameter M is calculated and sent to the second communication device; where M = ∑ i (Rx i -Ry i ) 2 .
[0055] The processor of the second communication device is further configured to perform the following operations:
[0056] According to the first intermediate parameter E(x) i +r A ), public key, second data vector y i And the second random number r B Perform the calculation to obtain the first data set E(x) i +r A )·E(-y i ) and the second data set E(x) i +r A )·E(-y i +r B), and the first data group E(x) i +r A )·E(-y i ) and the second data set E(x) i +r A )·E(-y i +r B After being randomly sorted, the data is sent to the first communication device;
[0057] The processor of the first communication device is also configured to perform the following operations:
[0058] Decrypt the first data block E(x) using the private key i +r A )·E(-y i After derandomization, s values are selected to calculate the fifth intermediate parameter τ = ∑ i∈[1,s] (x i -y i ) 2 And send it to the second communication device;
[0059] Decrypt the second data block E(x) using the private key i +r A )·E(-y i +r B After derandomization, the sixth intermediate parameter x is obtained. i -y i +r B Select ns sixth intermediate parameters x i -y i +r B Send to the second communication device; where n is the number of the first data vector and the second data vector, and s is an integer greater than 0 and less than n;
[0060] The processor of the second communication device is also used to perform the following operations:
[0061] Received ns sixth intermediate parameters x i -y i +r B After derandomization, the seventh intermediate parameter τ′=∑ i∈[1,n-s] (x i -y i ) 2 ;
[0062] The seventh intermediate parameter τ′ and the fifth intermediate parameter τ are summed to obtain the eighth intermediate parameter z.
[0063] The processor of the second communication device is further configured to perform the following operations:
[0064] The first hash value h is obtained based on the first hash function H(), the third random number R, and the random salt value salt, and the first hash value h is sent to the first communication device.
[0065] The processor of the second communication device is further configured to perform the following operations:
[0066] Determine if the product of the third random number R and the eighth intermediate parameter z is equal to the fourth intermediate parameter M; if they are equal, determine the first data vector x. i Second data vector y i The result of the Euclidean distance calculation is like Within the similarity judgment threshold Δ, determine the first data vector x. i Second data vector y i resemblance;
[0067] Determine the first data vector x i Second data vector y i After similarity is achieved, the seventh intermediate parameter τ′, the third random number R, and the random salt value salt are sent to the first communication device.
[0068] The processor of the first communication device is also configured to perform the following operations:
[0069] The second hash value h′ is obtained based on the first hash function H(), the third random number R, and the random salt value salt. If the second hash value h′ is the same as the first hash value h, the seventh intermediate parameter τ′ and the fifth intermediate parameter τ′ are summed to obtain the calculation parameter z′.
[0070] Determine if the product of the third random number R and the calculated parameter z′ is equal to the fourth intermediate parameter M; if they are equal, determine the first data vector x. i Second data vector y i The result of the Euclidean distance calculation is like Within the similarity judgment threshold Δ, determine the first data vector x. i Second data vector y i resemblance.
[0071] The processor of the first communication device is further configured to perform the following operations:
[0072] Using the homomorphism of the Paillier encryption algorithm to calculate the first random number r A and the first data vector x i Perform the calculation to obtain the first intermediate parameter E(x) i +r A );
[0073] Wherein, E(x)i +r A )=E(x i )×E(r A ); E(x) i ) represents x encrypted using the public key. i E(r) A ) represents r encrypted using the public key. A The public key is the public key for the Paillier encryption algorithm.
[0074] The processor of the second communication device is further configured to perform the following operations:
[0075] Determine the third intermediate parameter E(Rx) i -Ry i )=(E(x i )) R ·(E(-y i )) R .
[0076] The processor of the second communication device is further configured to perform the following operations:
[0077] Determine the first hash value h = H(salt||R).
[0078] The processor of the first communication device is further configured to perform the following operations:
[0079] Determine the second hash value h′ = H(salt||R).
[0080] This invention also provides a communication device, including a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements the vector similarity judgment method under the malicious adversary model as described above.
[0081] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps in the vector similarity judgment method under the malicious adversary model as described above.
[0082] The above-described technical solution of the present invention has at least the following beneficial effects:
[0083] In the vector similarity judgment method and communication device under the malicious adversary model of this invention, during the initialization phase, the first communication device generates public and private keys and publishes the public key. At the same time, the first and second communication devices generate their respective initial parameters required for the interaction process. During the interaction phase, the first and second communication devices perform calculations based on their own data vectors, keys, and initial parameters, and exchange the calculated intermediate parameters to ensure that both parties can effectively calculate the final result. Furthermore, in the final verification phase, the intermediate parameters calculated by both parties are verified to ensure the accuracy and confidentiality of the calculation results. Attached Figure Description
[0084] Figure 1 This is a flowchart illustrating the steps of the vector similarity judgment method under the malicious adversary model provided in this embodiment of the invention.
[0085] Figure 2 This is a schematic diagram showing the structure of the communication device provided in an embodiment of the present invention. Detailed Implementation
[0086] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.
[0087] like Figure 1 As shown, this embodiment of the invention provides a vector similarity judgment method under a malicious adversary model, wherein the malicious adversary model includes a first communication device and a second communication device, and the method includes:
[0088] Step 101: The first communication device generates key information including a public key and a private key, and sends the public key to the second communication device;
[0089] Step 102: The first communication device and the second communication device respectively generate initial parameters;
[0090] Step 103: The first communication device and the second communication device perform calculations based on their own data vectors, key information and initial parameters, and exchange the intermediate parameters obtained from the calculations.
[0091] In this step, the key information of the first communication device includes a public key and a private key; while the key information of the second communication device only includes the public key.
[0092] Step 104: The first communication device and the second communication device respectively verify the intermediate parameters to determine whether the first data vector of the first communication device and the second data vector of the second communication device are similar.
[0093] It should be noted that the vector similarity judgment method provided in this embodiment of the invention is applied to a malicious adversary model. Under this model, both entities are malicious and may tamper with the transmitted content at each step of the interaction; that is, both parties are untrustworthy and can tamper with or maliciously send false data. Therefore, in order to obtain the true value, both parties in this solution not only need to protect the privacy of their own data vectors, but also need to perform verifiable calculations on the calculation results. Only when the verification is successful can it be proven that both parties have sent real data without exposing their privacy, thus making the calculation results valid.
[0094] For the malicious adversary model, the vector similarity judgment method provided in this embodiment of the invention, in the initialization stage, the first communication device generates public and private keys and publishes the public key, while the first and second communication devices respectively generate the initial parameters required for their interaction process; in the interaction stage, the first and second communication devices each perform calculations based on their own data vectors, keys and initial parameters, and exchange the calculated intermediate parameters, ensuring that both parties can effectively calculate the final result; and since this scheme is carried out under the malicious adversary model, both entities are malicious, and both parties may tamper with the transmitted content at each step of the interaction, therefore, in the final verification stage, the intermediate parameters calculated by both parties are verified to ensure the accuracy and confidentiality of the calculation results of both parties.
[0095] As an optional embodiment, in step 101, the first communication device generates key information, including:
[0096] The first communication device inputs the first security parameter and generates key information for the Paillier encryption algorithm. The key information includes a public key pk and a private key sk, and the public key pk is made public.
[0097] In the embodiments of the present invention, when performing two-party calculations, Paillier homomorphic encryption and OT (unintentional transmission) technology are used to perform distributed data transmission. While protecting the privacy of data vectors, the calculation results can be obtained even if neither party can obtain the other's real data during the interaction process.
[0098] In at least one optional embodiment of the present invention, step 102 includes:
[0099] The first communication device inputs a second security parameter, generates initial parameters for the first communication device, and sends them to the second communication device. The initial parameters of the first communication device include: a first random number r. A The first hash function H() and the similarity threshold Δ;
[0100] The second communication device inputs a third security parameter to generate initial parameters for the second communication device. These initial parameters include a second random number r. B The third random number R and the random salt value salt.
[0101] It should be noted that the second and third security parameters can be the same or different; no specific restrictions are imposed here. During node initialization, the first communication device will publish its generated initial parameters, while the initial parameters generated by the second communication device will not be published and will only be known to the second communication device.
[0102] In at least one optional embodiment of the present invention, step 103 includes:
[0103] The first communication device uses the public key and the first random number r. A and the first data vector x i Perform the calculation to obtain the first intermediate parameter E(x) i +r A ) and the second intermediate parameter E(x) i And send it to the second communication device; where E() represents encryption processing;
[0104] The second communication device, based on the second intermediate parameter E(x) i ), public key, second data vector y i And perform calculations using the third random number R to obtain the third intermediate parameter E(Rx). i -Ry i And send it to the first communication device;
[0105] The first communication device uses its private key to decrypt the third intermediate parameter E(Rx). i -Ry i Then, the fourth intermediate parameter M is calculated and sent to the second communication device; where M = ∑ i (Rx i -Ry i ) 2 .
[0106] Where i∈[1,n]. E(x) i +r A ) represents encrypted x i +r A E(x) i ) represents encrypted x i .
[0107] As an optional embodiment, the first communication device uses a public key and a first random number r to... A and the first data vector x i Perform the calculation to obtain the first intermediate parameter E(x) i +rA ),include:
[0108] The first communication device uses the homomorphism of the Paillier encryption algorithm to process the first random number r. A and the first data vector x i Perform the calculation to obtain the first intermediate parameter E(x) i +r A );
[0109] Wherein, E(x) i +r A )=E(x i )×E(r A ); E(x) i ) represents x encrypted using the public key. i E(r) A ) represents r encrypted using the public key. A The public key is the public key for the Paillier encryption algorithm.
[0110] In the embodiments of the present invention, when performing two-party calculations, Paillier homomorphic encryption and OT (unintentional transmission) technology are used to perform distributed data transmission. While protecting the privacy of data vectors, the calculation results can be obtained even if neither party can obtain the other's real data during the interaction process.
[0111] As another optional embodiment, the second communication device, based on the second intermediate parameter E(x) i ), public key, second data vector y i And perform calculations using the third random number R to obtain the third intermediate parameter E(Rx). i -Rt i ),include:
[0112] The second communication device determines the third intermediate parameter E(Rx) i -Ry i )=(E(x i )) R ·(E(-y i )) R .
[0113] In other words, the second communication device, based on the third random number R, for each i∈[1,n] and the second data vector y i The second communication device calculates the third intermediate parameter E(Rx) i -Ry i )=(E(x i )) R ·(E(-y i )) R Then, after shuffling the order, it is sent to the first communication device. Where, E(Rx)i -Ry i ) represents encrypted Rx i -Ry i .
[0114] Furthermore, in at least one optional embodiment of the present invention, step 103 further includes:
[0115] The second communication device is based on the first intermediate parameter E(x) i +r A ), public key, second data vector y i And the second random number r B Perform the calculation to obtain the first data set E(x) i +r A )·E(-y i ) and the second data set E(x) i +r A )·E(-y i +r B ), and the first data group E(x) i +r A )·E(-y i ) and the second data set E(x) i +r A )·E(-y i +r B After being randomly sorted, the data is sent to the first communication device;
[0116] The first communication device uses its private key to decrypt the first data group E(x). i +r A )·E(-y i After derandomization, s values are selected to calculate the fifth intermediate parameter τ = ∑ i∈[1,s] (x i -y i ) 2 And send it to the second communication device;
[0117] The first communication device uses its private key to decrypt the second data group E(x) i +r A )·E(-y i +r B After derandomization, the sixth intermediate parameter x is obtained. i -y i +r B Select ns sixth intermediate parameters x i -y i +r B Send to the second communication device; where n is the number of the first data vector and the second data vector, and s is an integer greater than 0 and less than n;
[0118] The second communication device receives ns sixth intermediate parameters x i -y i +r B After derandomization, the seventh intermediate parameter τ′=∑ i∈[1,n-s] (x i -y i ) 2 ;
[0119] The second communication device sums the seventh intermediate parameter τ′ and the fifth intermediate parameter τ to obtain the eighth intermediate parameter z. Wherein, the eighth intermediate parameter z = ∑ i∈[1,n] (x i -y i ) 2 .
[0120] In other words, the first communication device selects s values from the first data group and another ns values from the second data group. First, it decrypts the s values E(x) from the first data group using the private key sk. i +r A )·E(-y i Then, after derandomization, calculate τ = ∑ i∈[1,s] (x i -y i ) 2 And send it to the second communication device. Continue to decrypt the ns values E(x) of the second data group. i +r A )·E(-y i +r B And derandomize, taking ns x tj -y tj +r B Send to the second communication device. The second communication device receives ns bytes. After performing a derandomization operation, we can calculate τ′=∑ i∈[1,n-s] (x i -y i ) 2 Let it be related to τ=∑ i∈[1,s] (x i -y i ) 2 Summing them up will give z = ∑ i∈[1,n] (x i -y i ) 2 .
[0121] In another optional embodiment of the present invention, the method further includes:
[0122] The second communication device obtains the first hash value h based on the first hash function H(), the third random number R, and the random salt value salt, and sends the first hash value h to the first communication device.
[0123] The second communication device obtains the first hash value h based on the first hash function H(), the third random number R, and the random salt value salt, including:
[0124] The second communication device determines the first hash value h = H(salt||R). The third random number R and the random salt value salt are generated by the second communication device itself.
[0125] It should be noted that the first hash value represents the value of a one-way hash function and serves as a verification function. If it is the same as the second hash value, the verification is successful.
[0126] In at least one optional embodiment of the present invention, step 104 includes:
[0127] The second communication device determines whether the product of the third random number R and the eighth intermediate parameter z is equal to the fourth intermediate parameter M; if they are equal (then the second communication device considers that the first communication device has executed the protocol), it determines the first data vector x. i Second data vector y i The result of the Euclidean distance calculation is like Within the similarity judgment threshold Δ, the second communication device determines the first data vector x. i Second data vector y i resemblance;
[0128] The second communication device determines the first data vector x. i Second data vector y i After similarity is achieved, the second communication device sends the seventh intermediate parameter τ′, the third random number R, and the random salt value salt to the first communication device;
[0129] The first communication device obtains a second hash value h′ based on the first hash function H(), the third random number R, and the random salt value salt. If the second hash value h′ is the same as the first hash value h, the first communication device sums the seventh intermediate parameter τ′ and the fifth intermediate parameter τ to obtain the calculation parameter z′.
[0130] The first communication device determines whether the product of the third random number R and the calculated parameter z′ is equal to the fourth intermediate parameter M; if they are equal (then the first communication device considers that the second communication device has honestly executed the protocol), it determines the first data vector x. i Second data vector y i The result of the Euclidean distance calculation is like Within the similarity judgment threshold Δ, the first communication device determines the first data vector x. i Second data vector y i resemblance.
[0131] The first communication device uses a first hash function H(), a third random number R, and a random salt value salt to obtain a second hash value h′, including:
[0132] The first communication device determines the second hash value h′ = H(salt||R). The third random number R and the random salt value salt are sent to the first communication device after successful verification by the second communication device.
[0133] In this embodiment of the invention, the first data vector x i Second data vector y i European distance It is calculated by the first communication device based on the received intermediate parameters and its own initial parameters, and the first data vector x is obtained by the first communication device. i Second data vector y i European distance It is calculated by the second communication device based on the received intermediate parameters and its own initial parameters, ensuring the authenticity of the other party's data and its own data. If either party maliciously tampers with the data, neither party can obtain the correct data.
[0134] In summary, this invention achieves secure two-way vector similarity judgment under a malicious adversary model. Both parties perform verifiable calculations on the results. If either party transmits false data, neither party will obtain the correct result, which is more practical in real-world scenarios. Furthermore, by using Paillier encryption and unintentional transmission technology, calculating the similarity between vectors by calculating the Euclidean distance can more accurately calculate vector similarity, making the results more convincing.
[0135] like Figure 2 As shown, this embodiment of the invention also provides a communication device, which includes a first communication device and a second communication device in a malicious adversary model. The communication device includes a processor 200 and a transceiver 210. The transceiver 210 receives and transmits data under the control of the processor 200. The processor 200 of the first communication device is used to perform the following operations:
[0136] Generate key information including a public key and a private key, and send the public key to the second communication device;
[0137] The processors of the first communication device and the second communication device are further configured to perform the following operations:
[0138] Generate initial parameters respectively;
[0139] Each component performs calculations based on its own data vector, key information, and initial parameters, and then exchanges the intermediate parameters obtained from the calculations.
[0140] The intermediate parameters are verified to determine whether the first data vector of the first communication device and the second data vector of the second communication device are similar.
[0141] As an optional embodiment, the processor of the first communication device is further configured to perform the following operations:
[0142] Input a second security parameter, generate initial parameters for the first communication device, and send them to the second communication device. The initial parameters for the first communication device include: a first random number r. A The first hash function H() and the similarity threshold Δ;
[0143] The processor of the second communication device is also used to perform the following operations:
[0144] Input the third security parameter to generate the initial parameters of the second communication device. The initial parameters of the second communication device include: a second random number r. B The third random number R and the random salt value salt.
[0145] As an optional embodiment, the processor of the first communication device is further configured to perform the following operations:
[0146] Based on the public key and the first random number r A and the first data vector x i Perform the calculation to obtain the first intermediate parameter E(x) i +r A ) and the second intermediate parameter E(x) i And send it to the second communication device; where E() represents encryption processing;
[0147] The processor of the second communication device is also used to perform the following operations:
[0148] According to the second intermediate parameter E(x) i ), public key, second data vector y i And perform calculations using the third random number R to obtain the third intermediate parameter E(Rx). i -Ry i And send it to the first communication device;
[0149] The processor of the first communication device is also configured to perform the following operations:
[0150] Decrypt the third intermediate parameter E(Rx) using the private keyi -Ry i Then, the fourth intermediate parameter M is calculated and sent to the second communication device; where M = ∑ i (Rx i -Ry i ) 2 .
[0151] As an optional embodiment, the processor of the second communication device is further configured to perform the following operations:
[0152] According to the first intermediate parameter E(x) i +r A ), public key, second data vector y i And the second random number r B Perform the calculation to obtain the first data set E(x) i +r A )·E(-y i ) and the second data set E(x) i +r A )·E(-y i +r B ), and the first data group E(x) i +r A )·E(-y i ) and the second data set E(x) i +r A )·E(-y i +r B After being randomly sorted, the data is sent to the first communication device;
[0153] The processor of the first communication device is also configured to perform the following operations:
[0154] Decrypt the first data block E(x) using the private key i +r A )·E(-y i After derandomization, s values are selected to calculate the fifth intermediate parameter τ = ∑ i∈[1,s] (x i -y i ) 2 And send it to the second communication device;
[0155] Decrypt the second data block E(x) using the private key i +r A )·E(-y i +r B After derandomization, the sixth intermediate parameter x is obtained. i -y i +r B Select ns sixth intermediate parameters x i -y i +rB Send to the second communication device; where n is the number of the first data vector and the second data vector, and s is an integer greater than 0 and less than n;
[0156] The processor of the second communication device is also used to perform the following operations:
[0157] Received ns sixth intermediate parameters x i -y i +r B After derandomization, the seventh intermediate parameter τ′=∑ i∈[1,n-s] (x i -y i ) 2 ;
[0158] The seventh intermediate parameter τ′ and the fifth intermediate parameter τ are summed to obtain the eighth intermediate parameter z.
[0159] As an optional embodiment, the processor of the second communication device is further configured to perform the following operations:
[0160] The first hash value h is obtained based on the first hash function H(), the third random number R, and the random salt value salt, and the first hash value h is sent to the first communication device.
[0161] As an optional embodiment, the processor of the second communication device is further configured to perform the following operations:
[0162] Determine if the product of the third random number R and the eighth intermediate parameter z is equal to the fourth intermediate parameter M; if they are equal, determine the first data vector x. i Second data vector y i The result of the Euclidean distance calculation is like Within the similarity judgment threshold Δ, determine the first data vector x. i Second data vector y i resemblance;
[0163] Determine the first data vector x i Second data vector y i After similarity is achieved, the seventh intermediate parameter τ′, the third random number R, and the random salt value salt are sent to the first communication device.
[0164] The processor of the first communication device is also configured to perform the following operations:
[0165] The second hash value h′ is obtained based on the first hash function H(), the third random number R, and the random salt value salt. If the second hash value h′ is the same as the first hash value h, the seventh intermediate parameter τ′ and the fifth intermediate parameter τ′ are summed to obtain the calculation parameter z′.
[0166] Determine if the product of the third random number R and the calculated parameter z′ is equal to the fourth intermediate parameter M; if they are equal, determine the first data vector x. i Second data vector y i The result of the Euclidean distance calculation is like Within the similarity judgment threshold Δ, determine the first data vector x. i Second data vector y i resemblance.
[0167] As an optional embodiment, the processor of the first communication device is further configured to perform the following operations:
[0168] Using the homomorphism of the Paillier encryption algorithm to calculate the first random number r A and the first data vector x i Perform the calculation to obtain the first intermediate parameter E(x) i +r A );
[0169] Wherein, E(x) i +r A )=E(x i )×E(r A ); E(x) i ) represents x encrypted using the public key. i E(r) A ) represents r encrypted using the public key. A The public key is the public key for the Paillier encryption algorithm.
[0170] As an optional embodiment, the processor of the second communication device is further configured to perform the following operations:
[0171] Determine the third intermediate parameter E(Rx) i -Ry i )=(E(x i )) R ·(E(-y i )) R .
[0172] As an optional embodiment, the processor of the second communication device is further configured to perform the following operations:
[0173] Determine the first hash value h = H(salt||R).
[0174] As an optional embodiment, the processor of the first communication device is further configured to perform the following operations:
[0175] Determine the second hash value h′ = H(salt||R).
[0176] In this embodiment of the invention, during the initialization phase, the first communication device generates a public and private key and publishes the public key. Simultaneously, the first and second communication devices generate their respective initial parameters required for the interaction process. During the interaction phase, the first and second communication devices perform calculations based on their own data vectors, keys, and initial parameters, and exchange the calculated intermediate parameters, ensuring that both parties can effectively calculate the final result. Furthermore, in the final verification phase, the intermediate parameters calculated by both parties are verified, ensuring the accuracy and confidentiality of the calculation results. Because both parties perform verifiable calculations of the results, if one party transmits false data, neither party will obtain the correct result, which is more practical in real-world scenarios. Moreover, by using Paillier encryption and unintended transmission technology, calculating the similarity between vectors using the Euclidean distance allows for more accurate vector similarity calculations, making the results more convincing.
[0177] This invention also provides a communication device, which is either a first communication device or a second communication device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the various processes in the vector similarity judgment method embodiment under the malicious adversary model as described above, and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0178] This invention also provides a computer-readable storage medium storing a computer program. When executed by a processor, this program implements the various processes described above in the vector similarity judgment method embodiment under the malicious adversary model, and achieves the same technical effect. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0179] 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-readable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.
[0180] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will 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... Figure 1 A device for one or more processes and / or the functions specified in one or more boxes.
[0181] 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 a paper article including an instruction means, the instruction means being implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0182] These computer program instructions can also be loaded onto a computer or other programmable data processing equipment, causing the computer or other programmable equipment to perform a series of operational steps to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0183] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A vector similarity judgment method under a malicious adversary model, characterized in that, The malicious adversary model includes a first communication device and a second communication device, and the method includes: The first communication device generates key information including a public key and a private key, and sends the public key to the second communication device; The first communication device and the second communication device respectively generate initial parameters; The first communication device and the second communication device perform calculations based on their own data vectors, key information, and initial parameters, and exchange the intermediate parameters obtained from the calculations. The first communication device and the second communication device respectively verify the intermediate parameters to determine whether the first data vector of the first communication device and the second data vector of the second communication device are similar; Wherein, the first communication device and the second communication device respectively generate initial parameters, including: The first communication device inputs a second security parameter, generates initial parameters for the first communication device, and sends them to the second communication device. The initial parameters for the first communication device include: a first random number. First hash function And similarity judgment threshold ; The second communication device inputs a third security parameter to generate initial parameters for the second communication device. These initial parameters include a second random number. The third random number R and the random salt value salt; The first communication device and the second communication device perform calculations based on their own data vectors, key information, and initial parameters, and exchange the intermediate parameters obtained from the calculations, including: The first communication device uses the public key and the first random number. and the first data vector Perform the calculation to obtain the first intermediate parameter. Second intermediate parameter And send it to the second communication device; among which, Indicates encryption processing; The second communication device, based on the second intermediate parameter Public key, second data vector And perform calculations using a third random number R to obtain a third intermediate parameter. And send it to the first communication device; The first communication device uses its private key to decrypt the third intermediate parameter. Then, the fourth intermediate parameter M is calculated and sent to the second communication device; where, ; The first communication device and the second communication device perform calculations based on their own data vectors, key information, and initial parameters, and exchange the intermediate parameters obtained from the calculations. The method also includes: The second communication device, based on the first intermediate parameter Public key, second data vector and the second random number Perform the calculation to obtain the first data set. Second Data Group and the first data group Second Data Group After being randomly sorted, the data is sent to the first communication device. The first communication device uses its private key to decrypt the first data packet. After derandomization, s values are selected to calculate the fifth intermediate parameter. And send it to the second communication device; The first communication device decrypts the second data group using its private key. After derandomization, the sixth intermediate parameter is obtained. Select ns sixth intermediate parameters Send to the second communication device; where n is the number of the first data vector and the second data vector, and s is an integer greater than 0 and less than n; The second communication device receives ns sixth intermediate parameters After derandomization, the seventh intermediate parameter was calculated. ; The second communication device will transmit the seventh intermediate parameter and the fifth intermediate parameter Summing yields the eighth intermediate parameter z; The method further includes: The second communication device uses the first hash function. The first hash value h is obtained by using the third random number R and the random salt value salt, and the first hash value h is sent to the first communication device. The first communication device and the second communication device respectively verify the intermediate parameters to determine whether the first data vector of the first communication device and the second data vector of the second communication device are similar, including: The second communication device determines whether the product of the third random number R and the eighth intermediate parameter z is equal to the fourth intermediate parameter M; if they are equal, it determines the first data vector. Second data vector The result of the Euclidean distance calculation is ;like Similarity judgment threshold Within the range, the second communication device determines the first data vector. Second data vector resemblance; The second communication device determines the first data vector. Second data vector After similarity, the second communication device will send the seventh intermediate parameter. The third random number R and the random salt value salt are sent to the first communication device; The first communication device according to the first hash function The second hash value is obtained by using the third random number R and the random salt value salt. If the second hash value If the hash value is the same as the first hash value h, then the first communication device will use the seventh intermediate parameter. and the fifth intermediate parameter Summing yields the calculated parameters. ; The first communication device determines the third random number R and calculates the parameters. Is the product of these parameters equal to the fourth intermediate parameter M? If they are equal, determine the first data vector. Second data vector The result of the Euclidean distance calculation is ;like Similarity judgment threshold Within the range, the first communication device determines the first data vector. Second data vector resemblance.
2. The method according to claim 1, characterized in that, The first communication device uses the public key and the first random number. and the first data vector Perform the calculation to obtain the first intermediate parameter. ,include: The first communication device uses the homomorphism of the Paillier encryption algorithm to process the first random number. and the first data vector Perform the calculation to obtain the first intermediate parameter. ; in, ; This indicates that the encryption is done using the public key. ; This indicates that the encryption is done using the public key. The public key is the public key for the Paillier encryption algorithm.
3. The method according to claim 1, characterized in that, The second communication device according to the second intermediate parameter Public key, second data vector And perform calculations using a third random number R to obtain a third intermediate parameter. ,include: The second communication device determines the third intermediate parameter = .
4. The method according to claim 1, characterized in that, The second communication device uses the first hash function. The first hash value h is obtained from the third random number R and the random salt value salt, including: The second communication device determines the first hash value. .
5. The method according to claim 1, characterized in that, The first communication device first hash function The second hash value is obtained by using the third random number R and the random salt value salt. ,include: The first communication device determines the second hash value .
6. A communication device, said communication device comprising a first communication device and a second communication device in a malicious adversary model, characterized in that, The communication device includes a processor and a transceiver, wherein the transceiver receives and transmits data under the control of the processor, characterized in that the processor of the first communication device is configured to perform the following operations: Generate key information including a public key and a private key, and send the public key to the second communication device; The processors of the first communication device and the second communication device are further configured to perform the following operations: Generate initial parameters respectively; Each component performs calculations based on its own data vector, key information, and initial parameters, and then exchanges the intermediate parameters obtained from the calculations. The intermediate parameters are verified respectively to determine whether the first data vector of the first communication device and the second data vector of the second communication device are similar. The processor of the first communication device is further configured to perform the following operations: Input a second security parameter, generate initial parameters for the first communication device, and send them to the second communication device. The initial parameters for the first communication device include: a first random number. First hash function And similarity judgment threshold ; The processor of the second communication device is also used to perform the following operations: Input the third security parameter to generate the initial parameters of the second communication device. The initial parameters of the second communication device include: a second random number. The third random number R and the random salt value salt; The processor of the first communication device is also configured to perform the following operations: Based on the public key and the first random number and the first data vector Perform the calculation to obtain the first intermediate parameter. Second intermediate parameter And send it to the second communication device; among which, Indicates encryption processing; The processor of the second communication device is also used to perform the following operations: According to the second intermediate parameter Public key, second data vector And perform calculations using a third random number R to obtain a third intermediate parameter. And send it to the first communication device; The processor of the first communication device is also configured to perform the following operations: Decrypt the third intermediate parameter using the private key Then, the fourth intermediate parameter M is calculated and sent to the second communication device; where, ; The processor of the second communication device is also used to perform the following operations: According to the first intermediate parameter Public key, second data vector and the second random number Perform the calculation to obtain the first data set. Second Data Group and the first data group Second Data Group After being randomly sorted, the data is sent to the first communication device. The processor of the first communication device is also configured to perform the following operations: Decrypt the first data block using the private key After derandomization, s values are selected to calculate the fifth intermediate parameter. And send it to the second communication device; Decrypt the second data block using the private key After derandomization, the sixth intermediate parameter is obtained. Select ns sixth intermediate parameters Send to the second communication device; where n is the number of the first data vector and the second data vector, and s is an integer greater than 0 and less than n; The processor of the second communication device is also used to perform the following operations: Received ns sixth intermediate parameters After derandomization, the seventh intermediate parameter was calculated. ; The seventh intermediate parameter and the fifth intermediate parameter Summing yields the eighth intermediate parameter z; The processor of the second communication device is also used to perform the following operations: According to the first hash function The first hash value h is obtained by using the third random number R and the random salt value salt, and the first hash value h is sent to the first communication device. As an optional embodiment, the processor of the second communication device is further configured to perform the following operations: Determine if the product of the third random number R and the eighth intermediate parameter z is equal to the fourth intermediate parameter M; if they are equal, determine the first data vector. Second data vector The result of the Euclidean distance calculation is ;like Similarity judgment threshold Within the range, determine the first data vector. Second data vector resemblance; Determining the first data vector Second data vector After similarity, the seventh intermediate parameter The third random number R and the random salt value salt are sent to the first communication device; The processor of the first communication device is also configured to perform the following operations: According to the first hash function The second hash value is obtained by using the third random number R and the random salt value salt. If the second hash value If it is the same as the first hash value h, then the seventh intermediate parameter will be... and the fifth intermediate parameter Summing yields the calculated parameters. ; Determine the third random number R and calculate the parameters. Is the product equal to the fourth intermediate parameter M? If equal, determine the first data vector. Second data vector The result of the Euclidean distance calculation is ;like Similarity judgment threshold Within the range, determine the first data vector. Second data vector resemblance.
7. A communication device, comprising a memory, a processor, and a program stored in the memory and executable on the processor; characterized in that, When the processor executes the program, it implements the vector similarity judgment method under the malicious adversary model as described in any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the vector similarity determination method under the malicious adversary model as described in any one of claims 1 to 5.