Method for accurately and safely calculating Jaccard coefficient

The Paillier homomorphic encryption method accurately and securely calculates the Jaccard coefficient by encrypting frequency sets and using Paillier addition homomorphism, ensuring accurate and private set similarity measurement without revealing sensitive information.

CN119109565APending Publication Date: 2024-12-10XI'AN POLYTECHNIC UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410991479.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

Existing methods for securely calculating the Jaccard coefficient introduce systematic errors and compromise the accuracy and privacy of the calculation results.

Method used

Utilizing Paillier homomorphic encryption, two parties encrypt their frequency sets and perform calculations using Paillier addition homomorphism to ensure accurate and secure determination of the Jaccard coefficient without revealing any information about their private sets.

Benefits of technology

The method ensures 100% accurate calculation of the Jaccard coefficient while maintaining data privacy, as no information related to the private sets is disclosed during the process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119109565A_ABST
    Figure CN119109565A_ABST
Patent Text Reader

Abstract

The invention discloses a method for accurately and safely calculating a Jaccard coefficient, and the method specifically comprises the following steps: 1, obtaining a public key and a private key through employing a Paillier homomorphic encryption algorithm, enabling Alice to have a private key of a public key encryption scheme, and enabling Bob to understand a public key of the public key encryption scheme; step 2, Alice and Bob generate respective frequency sets FA and FB according to SA and SB, and calculate random number sets Ra and Rb through a cloud server; step 3, the Alice encrypts the frequency set by using a private key and sends all ciphertexts to the Bob, and meanwhile, the Bob encrypts the frequency set by using a public key of the Alice; step 4, after Bob receives all ciphertexts, calculating a ciphertext two-tuple by using the homomorphic property of Paillier addition, and sending a calculation result to Alice; and step 5, after the Alice receives the two-tuple of the ciphertext, calculating a maximum selection vector and a minimum selection vector, calculating the ciphertext of the intersection of SA and SA union of SB, and finally calculating the Jaccard coefficients of SA and SB through specific value decryption. The problem that an existing Jaccard coefficient calculation method is poor in safety and accuracy is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of information security, and in particular relates to a method for calculating a Jaccard coefficient accurately and safely. Background Art

[0002] The Jaccard coefficient is an effective method to measure the similarity between two sets, and is of great significance in fields such as text similarity calculation, recommendation systems, and social network analysis. The Jaccard coefficient measures the similarity between two sets by calculating the ratio of the number of elements in the intersection and union of the two sets. Since the user's privacy data is involved in practical applications, it is required that the participants cannot obtain any other private data related to the parties except the final calculation result during the calculation of the Jaccard coefficient, that is, the secure calculation of the Jaccard coefficient.

[0003] The existing Jaccard coefficient security calculation method first reduces the problem of securely calculating the Jaccard coefficient to the problem of securely calculating the number of elements in the intersection of two sets. Then the two parties calculate a random share respectively, and the number of elements in the intersection of the two sets is obtained by adding them together. The Jaccard coefficient is finally calculated through the number of elements in the intersection. In the process of calculating the random shares by the two parties, an approximate value method is used to improve the efficiency of the scheme, but it also introduces systematic errors, making it difficult to guarantee the correctness of the final result. Summary of the invention

[0004] The purpose of the present invention is to provide a method for calculating the Jaccard coefficient accurately and safely, thereby solving the problems of poor safety and accuracy in the existing Jaccard coefficient calculation methods.

[0005] The technical solution adopted by the present invention is a method for accurately and securely calculating the Jaccard coefficient. The two parties Alice and Bob each have a set S A With S B , specifically follow the steps below:

[0006] Step 1: Use the Paillier homomorphic encryption algorithm to obtain the public and private keys. Alice has the private key of the public key encryption scheme, and Bob knows the public key of the public key encryption scheme.

[0007] Step 2: Alice and Bob agree on S A , S B Generate their respective frequency sets F A 、F B , and calculate the random number set R through the cloud server a , R b ;

[0008] Step 3: Alice encrypts the frequency set with her private key and sends all the ciphertexts to Bob. At the same time, Bob encrypts the frequency set with Alice’s public key.

[0009] Step 4: After receiving all the ciphertexts, Bob uses the Paillier addition homomorphism to calculate a ciphertext binary and sends the calculation result to Alice.

[0010] Step 5: After receiving the ciphertext binary, Alice calculates a maximum selection vector and a minimum selection vector, and then calculates |S A ∩S B | and |S A ∪S B |Then, we can calculate S by decrypting their ratios. A , S B The Jaccard coefficient of

[0011] The present invention is also characterized in that:

[0012] In step 1, Alice runs the key generation algorithm of the Paillier homomorphic encryption scheme to obtain a public-private key pair (Pk, Sk).

[0013] Step 2 is as follows: Alice and Bob first generate their own private sets based on

[0014]

[0015] Alice or Bob chooses l a (l b ) And the cloud server calculates the random number set R a , R b .

[0016] Step 3 is as follows: Alice selects a Randomly select a subset and calculate the random number r using the elements in the subset ai (i∈{1,2,...,m}), and then use the private key to A Encrypt and send ciphertext to Bob; at the same time, Bob from the set R b Randomly select a subset and calculate the random number r using the elements in the subset di (i∈{1,2,...,m}), select a random number Calculate the ciphertext using Alice's public key and random number and

[0017] Step 4 is as follows: After Bob receives all the ciphertexts, he uses the set R b Calculate three random

[0018] ”'

[0019] Number of machines bi , r ti , r di , calculate the ciphertext Select 2-tuple

[0020]

[0021] And perform scrambling operations, and finally convert the binary and ciphertext to Alice. Step 5 is as follows: After Alice receives all ciphertexts, for 1≤i≤m, Alice is

[0022] Get a minimum selection vector and a maximum selection vector use calculate use calculate Finally, calculate the Jaccard coefficient of both parties

[0023] The beneficial effects of the present invention are:

[0024] The method for calculating the Jaccard coefficient accurately and safely in the present invention solves the problem of security and accuracy of the Jaccard coefficient calculation. The two parties involved each have a private set S A , S B , after executing the Jaccard coefficient accurate and secure calculation method, it is achieved that: the Jaccard coefficient is securely calculated with 100% accuracy, which solves the error problem existing in the existing calculation process; after the Jaccard coefficient is securely calculated, the participating parties do not disclose any information related to their respective private sets, that is, after the participating parties execute the Jaccard coefficient accurate and secure calculation method, in addition to obtaining two sets S A , S B Except for the Jaccard coefficient, no information related to the other party's private set can be obtained. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 It is a schematic diagram of the method for calculating the Jaccard coefficient accurately and safely according to the present invention;

[0026] Figure 2 The participant Alice in the present invention calculates flow chart;

[0027] Figure 3 It is a schematic diagram of embodiment 2 of the present invention. DETAILED DESCRIPTION

[0028] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.

[0029] The method of the present invention for calculating the Jaccard coefficient accurately and safely, the two parties Alice and Bob each have a set S A With S B ,like Figure 1 As shown, the specific implementation steps are as follows:

[0030] Step 1: Use the Paillier homomorphic encryption algorithm to obtain the public and private keys. Alice has the private key of the public key encryption scheme, and Bob knows the public key of the public key encryption scheme.

[0031] In step 1, Alice runs the key generation algorithm of the Paillier homomorphic encryption scheme to obtain a public-private key pair (Pk, Sk);

[0032] Step 2: Alice and Bob agree on S A , S B Generate their respective frequency sets F A 、F B , and calculate the random number set R through the cloud server a , R b ;

[0033] Step 2 is as follows: Alice and Bob first generate their own private sets based on

[0034]

[0035] Alice or Bob chooses l a (l b ) And the cloud server calculates the random number set R a , R b , l is the maximum number of repetitions of each element in the set S;

[0036] Step 3: Alice encrypts the frequency set with her private key and sends all the ciphertexts to Bob. At the same time, Bob encrypts the frequency set with Alice’s public key.

[0037] Step 3 is as follows: Alice selects a Randomly select a subset and calculate the random number r using the elements in the subsetai (i∈{1,2,...,m}), m is the cardinality of the set S, and then use the private key to the frequency set F A Encrypt and send ciphertext to Bob; at the same time, Bob from the set R b Randomly select a subset and calculate the random number r using the elements in the subset di (i∈{1,2,...,m}), select a random number Calculate the ciphertext using Alice's public key and random number and

[0038] Step 4: After receiving all the ciphertexts, Bob uses the Paillier addition homomorphism to calculate a ciphertext binary and sends the calculation result to Alice.

[0039] Step 4 is as follows: After Bob receives all the ciphertexts, he uses the set R b Calculate three random numbers r' bi , r' ti , r' di , calculate the ciphertext Select 2-tuple

[0040]

[0041] And perform scrambling operations, and finally convert the binary And the ciphertext is sent to Alice;

[0042] Step 5, such as Figure 2 As shown, after Alice receives the ciphertext binary, she calculates a maximum selection vector and a minimum selection vector, and then calculates |S A ∩S B | and |S A ∪S B |Then, we can calculate S by decrypting their ratios. A , S B Jaccard coefficient;

[0043] Step 5 is as follows: After Alice receives all the ciphertexts, for 1≤i≤m, Alice is Get a minimum selection vector and a maximum selection vector use calculate use calculate Finally, calculate the Jaccard coefficient of both parties

[0044] Example 1

[0045] The method for accurately and securely calculating the Jaccard coefficient in the present invention, where the Paillier encryption scheme has the additive homomorphism property, that is, after performing an addition operation on the encrypted data, the decrypted result is the same as the result of the addition operation on the plaintext data, and no information about the plaintext is leaked during the whole process. The Paillier encryption scheme mainly includes the following three algorithms:

[0046] Key Generation

[0047] 1. Select two large prime numbers p and q, p, q ∈ Z N ;

[0048] 2. Calculate n = p·q;

[0049] 3. Calculate λ = lcm(p - 1, q - 1);

[0050] 4. Select an integer g that satisfies (L(g λ mod n 2 ), n) = 1

[0051] pk = (n, g), sk = (p, q).

[0052] Encryption

[0053] For any plaintext M < n, select a random number Ciphertext C = E pk (M) = g M r n mod n 2 .

[0054] Decryption

[0055] For any ciphertext C < n 2 , plaintext

[0056] The homomorphism property of Paillier encryption: For any ciphertexts C1, C2:

[0057] D sk (C1·C2) = M1 + M2.

[0058] Preparation steps:

[0059] E1: Alice (Bob) first generates their respective frequency sets F A (S B ) according to S A (F B );

[0060] E2: Alice runs the key generation algorithm of the Paillier encryption scheme to generate a key pair (pk, sk), making pk public but ensuring the privacy of sk, where pk = 1 + n, sk = lcm (p-1, q-1), n ​​= pq, p, q are two large prime numbers of the same length;

[0061] E3: Alice (Bob) chooses l a (l b ) And the untrusted cloud server calculates a random number set R a (R b ).

[0062] All the steps involved in the SJCM scheme are as follows:

[0063] Step 1: Alice uses her private key to encrypt F as follows: A :

[0064] Through the random number set R a Calculate a random number r ai :

[0065] Calculate ciphertext

[0066] At the same time, Bob uses Alice's public key to encrypt F as follows: B :

[0067] (1) Through the random number set R b Calculate a random number r di :

[0068] (2) Select a random number Calculate ciphertext

[0069] (3) Randomly select l according to step (1) b 'Small integer Calculate r bi ;

[0070] (4) Select two random numbers Calculate ciphertext

[0071] Step 2: Alice sends all ciphertexts To Bob.

[0072] Step 3: Bob receives all ciphertexts Then, do the following:

[0073] Follow the steps Calculate three random numbers r' bi , r' ti , r' di ;

[0074] calculate

[0075] Randomly select a pair

[0076] right Perform a random permutation on the binary elements in .

[0077] Step 4: Bob sends all ciphertexts to Alice.

[0078] Step 5: After receiving the ciphertext, Alice performs the following operations:

[0079] For 1≤i≤m, Alice is Get a minimum selection vector and a maximum selection vector use calculate use calculate

[0080] Calculate the set S A , S B Jaccard coefficient

[0081] Example 2

[0082] like Figure 3 As shown, first, financial institution A and institution B respectively store the sensitive account information and the data in the sensitive behavior database in two private sets S A , S B Indicates that the set includes attribute elements such as account name, transaction amount, transaction destination, and transaction time. Then A and B calculate the set S separately. A , S B The frequency set F of each element in A , F B Financial institution A sets the attribute set F A Encryption, Computation (k Ai F A elements in ) and send it to B. B selects a random number ω i And calculate in BSend and to A, where

[0083] A calculates the set S A , S B Jaccard coefficient In getting Afterwards, according to The value of is used to measure the matching degree between the behavior attributes of the account and the behavior attributes in the sensitive behavior database, and then determine whether the account is a behavior-sensitive account.

[0084] Through this method, financial institutions can determine whether an account has sensitive behavior without leaking the account's privacy information. This method can also be applied to scenarios in the medical, biological and other fields that require data similarity measurement, such as patient disease association analysis, gene sequence comparison and other scenarios.

[0085] Example 3

[0086] The invention discloses a method for accurately and securely calculating the Jaccard coefficient. The method adopts Paillier homomorphic encryption and the Jaccard coefficient calculation method. Aiming at the problem of accurately and securely calculating the Jaccard coefficient, the problem that the existing secure Jaccard coefficient calculation scheme cannot accurately calculate is analyzed. A method for accurately and securely calculating the Jaccard coefficient is proposed. The method can securely calculate the Jaccard coefficient of a private set owned by two parties under the premise of ensuring the accuracy of the calculation result.

[0087] Privacy protection: The present invention uses confidential computing technology to calculate the Jaccard coefficient of the private sets of two participants. This process not only achieves an effective measurement of the similarity of the sets, but also strictly protects the data privacy of the participants and avoids the leakage of sensitive information. The two parties obtain the Jaccard coefficient of the private sets of both parties through confidential calculation of the private sets, and no information related to the private sets will be leaked in the process.

[0088] By calculating a minimum selection vector and a maximum selection vector To calculate and In the selection in the ciphertext and When , the set S is retained by calculating the maximum vector and the minimum vector. A and S B The ciphertext of the elements with larger and smaller frequencies, due to the homomorphism of Paillier encryption, and For S A and S BThe dense state of the sum of the maximum frequency and the minimum frequency in |S A ∩S B | and |S A ∪S B |The ciphertext. Finally, through the decryption operation Calculate In this process |S A ∩S B | and |S A ∪S B | is absolutely confidential, and there is no approximate calculation in the entire calculation process, so the calculation result of this method is 100% equal to Solve the problem that the previous method cannot be accurately calculated.

Claims

1. Accurate and secure method for calculating the Jaccard coefficient. The two parties involved, Alice and Bob, each have a set S A With S B , characterized in that, Follow the steps below to implement it: Step 1: Use the Paillier homomorphic encryption algorithm to obtain the public and private keys. Alice has the private key of the public key encryption scheme, and Bob knows the public key of the public key encryption scheme. Step 2: Alice and Bob agree on S A , S B Generate their respective frequency sets F A 、F B , and calculate the random number set R through the cloud server a , R b ; Step 3: Alice encrypts the frequency set with her private key and sends all the ciphertexts to Bob. At the same time, Bob encrypts the frequency set with Alice’s public key. Step 4: After receiving all the ciphertexts, Bob uses the Paillier addition homomorphism to calculate a ciphertext binary and sends the calculation result to Alice. Step 5: After receiving the ciphertext binary, Alice calculates a maximum selection vector and a minimum selection vector, and then calculates |S A ∩S B | and |S A ∪S B |Then, we can calculate S by decrypting their ratios. A , S B The Jaccard coefficient of 2. The method for calculating the Jaccard coefficient accurately and safely according to claim 1, characterized in that: In step 1, Alice runs the key generation algorithm of the Paillier homomorphic encryption scheme to obtain a public-private key pair (Pk, Sk).

3. The method for calculating the Jaccard coefficient accurately and safely according to claim 1, characterized in that: The specific step 2 is as follows: Alice and Bob first generate their own private sets according to Alice or Bob chooses l a (l b ) And the cloud server calculates the random number set R a , R b .

4. The method for calculating the Jaccard coefficient accurately and safely according to claim 1, characterized in that: The specific step 3 is: Alice selects from the set R a Randomly select a subset and calculate the random number r using the elements in the subset ai (i∈{1,2,...,m}), and then use the private key to A Encrypt and send ciphertext to Bob; at the same time, Bob from the set R b Randomly select a subset and calculate the random number r using the elements in the subset di (i∈{1,2,...,m}), select a random number Calculate the ciphertext using Alice's public key and random number and 5. The method for calculating the Jaccard coefficient accurately and safely according to claim 1, characterized in that: The specific step 4 is as follows: After Bob receives all the ciphertexts, he uses the set R b Calculate three random numbers r' bi , r' ti , r' di , calculate the ciphertext Select 2-tuple And perform scrambling operations, and finally convert the binary And the ciphertext is sent to Alice.

6. The method for calculating the Jaccard coefficient accurately and safely according to claim 1, characterized in that: The specific step 5 is: After Alice receives all the ciphertexts, for 1≤i≤m, Alice is Get a minimum selection vector and a maximum selection vector use calculate use calculate Finally, calculate the Jaccard coefficient of both parties