A secure approximate pattern matching method and system
By using secure approximate pattern matching methods of encryption and homomorphic operations in pattern matching, the problem that traditional pattern matching methods cannot protect privacy is solved, and efficient matching and privacy protection of text and patterns is achieved.
Patent Information
- Application Number
- CN202111087088.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-16
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2041-09-16
AI Technical Summary
When performing pattern matching, especially in scenarios involving private data, traditional pattern matching methods cannot effectively protect privacy, resulting in the leakage of privacy data.
Using a secure approximate pattern matching method, by generating public keys and decrypting keys, text and pattern are encrypted, and matched through homomorphic operations, ensuring that the pattern holder can obtain the position where the pattern appears in the text, and Text holders cannot obtain relevant information about the pattern.
It effectively avoids the leakage of privacy data, ensures the privacy protection of patterns and text, and achieves efficient matching of patterns and text.
Smart Images

Figure CN113901510B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of approximate pattern matching, and in particular to a safe approximate pattern matching method and system. Background Art
[0002] The statements in this section merely mention background art related to the present invention and do not necessarily constitute prior art.
[0003] Approximate pattern matching technology is widely used. For example, in the human gene matching system, the gene sequences of different patients held by the hospital may contain errors and omissions, so wildcards are used to replace the wrong sequence in the pattern to achieve pattern matching containing repeated wildcards and compound wildcards. The gene sequence in the national gene bank is matched with the gene sequence of the patient, and similar gene sequences are screened from them. The higher the matching degree of the screened gene sequence, the more accurate the diagnosis of the patient's condition and the higher the efficiency.
[0004] However, the human gene sequences held by the National Gene Bank and the patient gene sequences held by the hospital are private data, and neither party wants to make their data public to avoid leaking their privacy. When the entity performing pattern matching has privacy protection requirements, the traditional pattern matching method will not be able to meet them. Summary of the invention
[0005] In order to address the deficiencies of the prior art, the present invention provides a secure approximate pattern matching method and system, whereby a party holding pattern information can obtain the location where the pattern appears in the text, but a party holding the text will not obtain any relevant information about the pattern, thereby effectively avoiding privacy leakage.
[0006] In a first aspect, the present invention provides a secure approximate pattern matching method;
[0007] A secure approximate pattern matching method comprises the following steps:
[0008] The key generator generates a public key and a decryption key, and transmits the public key to the text holder and the pattern holder;
[0009] The text holder obtains the encrypted text based on the public key and the text he holds;
[0010] The pattern holder obtains the encrypted pattern based on the public key and the pattern held;
[0011] The two third parties perform homomorphic operations on the encrypted text and the encryption pattern, match each sub-pattern in the encryption pattern with the encrypted text, and send the matching results to the key generator;
[0012] The key generator uses the decryption key to decrypt the matching result and multiply it by a random number before sending it to the pattern holder.
[0013] Furthermore, the specific steps of obtaining the encrypted text are:
[0014] Use the polynomial packing method to pack the held text into a polynomial;
[0015] The coefficients of the polynomial are encrypted into encrypted text using a public key.
[0016] Furthermore, the specific steps of obtaining the encryption mode are:
[0017] Split the held pattern using repeated wildcards as split points to obtain sub-patterns;
[0018] Use the polynomial packing method to pack all subpatterns into polynomials;
[0019] The coefficients of the polynomial are encrypted into an encrypted pattern using a public key.
[0020] Furthermore, the sub-pattern is a sub-pattern without wildcards or a sub-pattern containing only compound wildcards.
[0021] Furthermore, the specific steps of matching are:
[0022] If the sub-pattern is the sub-pattern without wildcard, directly use the squared Euclidean distance to match each sub-pattern with the encrypted text;
[0023] If the sub-pattern is the sub-pattern containing only compound wildcards, a double query method is used to match each sub-pattern with the encrypted text.
[0024] Furthermore, the dual query method is specifically as follows:
[0025] Constructing a subpattern containing only compound wildcards into two subpattern strings to obtain a first subpattern string and a second subpattern string;
[0026] Calculate the matching result between the first sub-pattern string and the encrypted text, and store the position where the coefficient in the matching result is the set value into the first set;
[0027] Calculate the matching result between the second sub-pattern string and the encrypted text, and store the position where the coefficient in the matching result is the set value into the second set;
[0028] Take the difference between the first set and the second set. If the difference is empty, the subpattern containing only compound wildcards successfully matches the encrypted text. Otherwise, the match fails.
[0029] Furthermore, the two third parties both have computing capabilities and are semi-honest and trustworthy.
[0030] In a second aspect, the present invention also provides a secure approximate pattern matching system;
[0031] A secure approximate pattern matching system includes a text holder, a pattern holder, a key generator and two third parties;
[0032] The key generator is configured to: generate a public key and a decryption key, and transmit the public key to the text holder and the pattern holder;
[0033] The text holder is configured to: obtain an encrypted text based on a public key and the held text;
[0034] The pattern holder is configured to: obtain an encrypted pattern based on a public key and the held pattern;
[0035] The two third parties are both configured to: perform homomorphic operations on the encrypted text and the encryption pattern, match each sub-pattern in the encryption pattern with the encrypted text, and send the matching results to the key generator;
[0036] The key generator is further configured to: use the decryption key to decrypt the matching result and multiply it by a random number, and then send it to the pattern holder.
[0037] Compared with the prior art, the present invention has the following beneficial effects:
[0038] A secure approximate pattern matching method of the present invention allows patterns containing both repeated wildcards and compound wildcards to be matched with text. After calculating the Euclidean distance, the participant holding the pattern information can obtain the position where its pattern appears in the text, but the participant holding the text will not obtain any relevant information about the pattern, effectively avoiding privacy leakage. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The drawings in the specification, which constitute a part of the present application, are used to provide further understanding of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application.
[0040] Figure 1 A flowchart of a method according to one or more embodiments is provided. DETAILED DESCRIPTION
[0041] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.
[0042] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0043] Terminology explanation section:
[0044] Homomorphic encryption (HE) methods include:
[0045] (1) Key generation: decryption key sk = s, s∈R, integer t, random variable a1∈R q , error variable e∈R, generate public key pk=(a0,a1), a0=a1s+te
[0046] (2) Encryption: u,f,g∈R, plaintext m∈R t ,pk=(a0,a1)
[0047] Enc=(m,sk)=(as+te+m,-a)=(c0,c1)=ct
[0048] (3) Homomorphic operation:
[0049]
[0050] (4) Decryption: ct∈(R q ) 2 ,t∈R t ,
[0051]
[0052] Embodiment 1, as Figure 1 As shown, this embodiment provides a secure approximate pattern matching method, which allows patterns containing both repeated wildcards and compound wildcards to be matched with text. After calculating the Euclidean distance, the participant holding the pattern information can obtain the position where its pattern appears in the text, but the participant holding the text will not obtain any relevant information about the pattern, and the participant holding the pattern information cannot know other data information of the participant holding the text.
[0053] A secure approximate pattern matching method is provided, wherein: the text holder is P0, which holds the text T; the pattern holder is P1, which holds the pattern P; two semi-honest and trusted third parties with strong computing power include T0 and T1; the key generator C generates a key pair (pk, sk); the input of the text holder P0 is (T, pk), and the input of the pattern holder P1 is (P, sk); after the method runs, if T and P match successfully, P1 outputs 0, otherwise P1 outputs non-zero.
[0054] The secure approximate pattern matching method includes the following steps:
[0055] ①. The key generator generates a public key and a decryption key, and transmits the public key to the text holder and the pattern holder.
[0056] The key generator C uses homomorphic encryption to generate a key pair (pk, sk), where pk is the public key and sk is the decryption key. The public key pk is sent to the text holder P0 and the pattern holder P1 through a secure channel.
[0057] ② The text holder obtains the encrypted text based on the public key and the text in his possession. Specifically: the text in his possession is packaged into a polynomial using the polynomial packaging method; the coefficients of the polynomial are encrypted into the encrypted text using the public key.
[0058] The text holder P0 uses the polynomial packing method (PPM) to pack the text T it holds into a polynomial Poly1(T), and encrypts the coefficients of the polynomial into an encrypted text Enc(T) using the public key pk using the homomorphic encryption method, and sends it to the trusted third parties T0 and T1.
[0059] ③. The pattern holder obtains an encrypted pattern based on the public key and the held pattern. Specifically: split the held pattern with repeated wildcards as splitting points to obtain sub-patterns, where the sub-patterns are sub-patterns without wildcards or sub-patterns containing only compound wildcards; use the polynomial packing method to pack all sub-patterns into polynomials; encrypt the coefficients of the polynomials into an encrypted pattern using the public key.
[0060] The pattern holder P1 uses the * repeated wildcard as the split point to split the pattern P held by it = (b0b1*b2b3b4*...$b i ! (c i+1 ……c i+j )b i+j+1 ...$b v-1), specifically, if the pattern P contains multiple wildcards *, the position of the repeated wildcards * is used as the split point to split the pattern, and the sub-patterns without wildcards and the sub-patterns containing only compound wildcards are obtained. The split pattern P is recorded as p1, p2...p n ,p1,p2……p n is a subpattern without wildcards and a subpattern containing only compound wildcards, where p i is a sub-pattern without wildcards or a sub-pattern string containing only compound wildcards. All sub-patterns are packaged into a polynomial Poly2(P) using the polynomial packaging method (PPM), and the polynomial coefficients are encrypted using the homomorphic encryption method using pk to obtain the encryption mode Enc(P), which is sent to the trusted third party T0, T1.
[0061] Among them, polynomial packing is to pack multiple vectors into a polynomial. In the packing method, T is the text, P is the pattern, and T∈Z l , Z represents the integer ring, |T|=l, |P y |=p y , P=(p1,p2……p n ) The yth substring Poly1(T), Poly2(P) in the ring R=Z [x] / (x n +1),
[0062]
[0063] Here, x is a prime number in the ring.
[0064] ④. The two third parties perform homomorphic operations on the encrypted text and the encryption pattern, match each sub-pattern in the encryption pattern with the encrypted text, and send the matching results to the key generator.
[0065] Two third parties T0 and T1 receive the encrypted text Enc(T) and the encryption mode Enc(P), perform homomorphic operations on the ciphertext, and use the squared euclid distance (SED) to calculate the distance between each sub-mode and the text.
[0066] For sub-patterns without wildcards, the squared Euclidean distance (SED) is directly used to match each sub-pattern with the encrypted text. If the squared Euclidean distance DES between the sub-pattern and the text is 0, the match is successful. If the squared Euclidean distance DES between the sub-pattern and the text is not 0, the match fails.
[0067] Among them, the squared Euclidean distance is used to calculate the distance between two non-binary vectors, T, P i are two non-binary vectors, |Pi |=u, the calculation formula is as follows:
[0068]
[0069] At position dE d =0, then sub-mode P i Appears at (d+1) in the text T. Where h is the position count representation of the pattern string, starting from 0 and ending at u-1.
[0070] For example: ∑={A,C,C,T} is encoded as {1,2,3,4}, T={AGC}={123}, P={GC}={23}, T0=(12), P0=(2,3), E 0,0 =<(1,4),(1,1)>+<(4,9),(1,1)>-2·<(1,2),(2,3)>=2. Similarly, E 1,0 =0, that is, the match is successful, and the matching calculation result is represented by the polynomial R1(·).
[0071] Double-query (DQ) technology requires users to send two patterns for querying to complete compound wildcard matching:
[0072] Text T = (a0a1...a l-1 )∈Z l ,|T|=l,V |T| =(1,1……1),|V |T| |=|T|, mode P=(b0……$b i ! (c i+1 … i+j )b i+j+1 ...$b v-1 )), for a subpattern P containing a composite wildcard i =$b i ! (c i+1 ……c i+j )b b+j+1 ...$b v-1 , use the double query method for each sub-pattern P i Match against encrypted text:
[0073] P x =$b i $……$b i+j+1 ...$b v-1
[0074] P y =$b i c i+1 ……c i+j b i+j+1 ...$bv-1 ,
[0075] ΔP x =Poly1(V |T| )·Poly2(P x 3 )+Poly1(T 2 )·Poly2(P x )-2·Poly1(T)
[0076] Poly2(P x 2 )
[0077] ΔP y =Poly1(V |T| )·Poly2(P y 3 )+Poly1(T 2 )·Poly2(P y )-2·Poly1(T)
[0078] Poly2(P y 2 )
[0079] Calculate separately Set the value to 0. Medium l+d The position d with coefficient 0 is stored in the first set Similarly, Medium l+d The position d with coefficient 0 is stored in the second set ! () wildcard can match any string except the sub-pattern string that appears in (), so take the set With Collection The difference between If R2≠{}, the match succeeds, otherwise the match fails.
[0080] Among them, the double query method is specifically as follows: constructing a sub-pattern containing only compound wildcards into two sub-pattern strings to obtain a first sub-pattern string and a second sub-pattern string; calculating the matching result of the first sub-pattern string and the encrypted text, and storing the position where the coefficient in the matching result is a set value in the first set; calculating the matching result of the second sub-pattern string and the encrypted text, and storing the position where the coefficient in the matching result is a set value in the second set; taking the difference between the first set and the second set, if the difference is empty, the sub-pattern containing only compound wildcards successfully matches the encrypted text, otherwise, the match fails.
[0081] ⑤. The key generator uses the decryption key to decrypt the matching result and multiply it by a random number, and then sends it to the pattern holder.
[0082] Specifically, two third parties T0 and T1 share the calculation results. The third parties T0 and T1 send the matching calculation result polynomial R(·)′ of all sub-pattern strings and text to the key generator C. The key generator C uses the homomorphic encryption method to use the decryption key sk to decrypt the result polynomial R(·)′ to obtain the decrypted polynomial r(·), and multiply it by the random number k, and send r(·)×k to the pattern holder P1. Among them, R(·)′ includes the matching calculation result R1(·) of the sub-pattern string without wildcards and the matching calculation result R2(·) of the sub-pattern string containing only compound wildcards. In other words, R(·)′ represents the matching calculation result of all sub-patterns and texts.
[0083] ⑥ After the pattern holder P1 obtains r(·)×k, it only knows that it is a string that can be successfully matched, that is, the matching result with a Euclidean distance of 0, and no other additional information is leaked.
[0084] This application enables a participant holding pattern information to obtain the location where its pattern appears in the text, but cannot obtain other relevant information about the text. At the same time, a participant holding the text cannot obtain any other relevant information about the pattern.
[0085] Embodiment 2: This embodiment provides a secure approximate pattern matching method, which is applied to gene sequence matching. The specific steps are as follows:
[0086] The hospital client is P0, which holds the text T; the national gene bank is P1, which holds the pattern P; two semi-honest and trusted third parties with powerful computing power include T0 and T1; the key generator C generates a key pair (pk, sk); the input of the text holder P0 is (T, pk), and the input of the pattern holder P1 is (P, sk); after the method runs, if T and P match successfully, P1 outputs 0, otherwise P1 outputs non-zero.
[0087] As an implementation mode, the two third parties T0 and T1 are two cloud servers (a first cloud server and a second cloud server), and the key generator C is a cloud server (a third cloud server).
[0088] The secure approximate pattern matching method includes the following steps:
[0089] ①. The key generator C uses homomorphic encryption to generate a key pair (pk, sk), where pk is the public key and sk is the decryption key. The public key pk is sent to the hospital client P0 and the national gene bank P1 through a secure channel.
[0090] ②. The hospital client P0 uses the polynomial packaging method to package the text T it holds into a polynomial, and uses the public key pk to encrypt the coefficients of the polynomial into an encrypted text Enc(T) using the homomorphic encryption method, and sends it to the trusted third parties T0 and T1.
[0091] ③. The national gene bank P1 splits the pattern P it holds using the * wildcard as the split point to obtain multiple sub-patterns P i , where a sub-pattern is a sub-pattern without wildcards or a sub-pattern containing only compound wildcards. All sub-patterns are packaged into polynomials using the polynomial packaging method, and the polynomial coefficients are encrypted using the homomorphic encryption method using the public key pk to obtain the encryption pattern Enc(P), which is sent to the trusted third party T0, T1.
[0092] ④. The third party T0, T1 receives the encrypted text Enc(T) and encryption mode Enc(P), performs homomorphic operations on the ciphertext, and calculates the distance between each sub-mode in each encryption mode and the text.
[0093] For a sub-pattern without wildcards, the squared Euclidean distance is directly used to calculate and obtain the matching result; for a sub-pattern containing compound wildcards, a double query method is used to calculate and obtain the matching result.
[0094] ⑤. The third parties R0 and R1 share the matching results. The third parties T0 and T1 send the matching results to the key generator C. The key generator C uses the homomorphic encryption method to decrypt the matching results using the decryption key sk to obtain the decrypted matching results, and multiplies them by the random number to obtain the processed matching results and send them to the hospital client P1.
[0095] ⑥. Hospital client P1 obtains the processed matching results.
[0096] Hospitals that hold pattern information can obtain the location of their patterns in the National Gene Bank. Through homomorphic encryption, repeated wildcards, and composite wildcard secure pattern matching protocols, the National Gene Bank cannot know the hospital's pattern information, and the hospital cannot know other data information in the National Gene Bank.
[0097] Embodiment 3, this embodiment provides a secure approximate pattern matching system;
[0098] A secure approximate pattern matching system includes: a text holder, a pattern holder, a key generator and two third parties.
[0099] As an implementation method, the text holder is the first client, the pattern holder is the second client, the two third parties are two cloud servers (the first cloud server and the second cloud server), the key generator is a cloud server (the third cloud server), the first cloud server and the second cloud server have powerful computing power and are semi-honest and trustworthy.
[0100] The pattern holder is connected to the key generator and two third parties; the text holder is connected to the key generator and two third parties; the two third parties are connected to each other; both third parties are connected to the key generator; the text holder and the pattern holder are not connected.
[0101] The key generator is configured to: generate a public key and a decryption key, and transmit the public key to the text holder and the pattern holder;
[0102] The text holder is configured to: obtain an encrypted text based on a public key and the held text;
[0103] The pattern holder is configured to: obtain an encrypted pattern based on a public key and the held pattern;
[0104] The two third parties are both configured to: perform homomorphic operations on the encrypted text and the encryption pattern, match each sub-pattern in the encryption pattern with the encrypted text, and send the matching results to the key generator;
[0105] The key generator is further configured to: use the decryption key to decrypt the matching result and multiply it by a random number to obtain a processed matching result, and send it to the pattern holder.
[0106] The pattern holder is further configured to receive and display the processed matching results.
[0107] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A secure approximate pattern matching method, characterized in that: The steps include: The key generator generates a public key and a decryption key, and transmits the public key to the text holder and the pattern holder; The text holder obtains the encrypted text based on the public key and the text he holds; The pattern holder obtains the encrypted pattern based on the public key and the pattern held; The two third parties perform homomorphic operations on the encrypted text and the encryption pattern, match each sub-pattern in the encryption pattern with the encrypted text, and send the matching results to the key generator; The key generator uses the decryption key to decrypt the matching result and multiply it by a random number before sending it to the pattern holder; The sub-pattern is a sub-pattern without wildcards or a sub-pattern containing only compound wildcards; The specific steps of matching are: if the sub-pattern is the sub-pattern without wildcards, directly use the squared Euclidean distance to match each sub-pattern with the encrypted text; if the sub-pattern is the sub-pattern containing only compound wildcards, use the double query method to match each sub-pattern with the encrypted text; The dual query method specifically comprises: constructing a sub-pattern containing only compound wildcards into two sub-pattern strings to obtain a first sub-pattern string and a second sub-pattern string; calculating a matching result between the first sub-pattern string and the encrypted text, and storing the position where the coefficient in the matching result is a set value into a first set; Calculate the matching result between the second sub-pattern string and the encrypted text, and store the position where the coefficient in the matching result is the set value into the second set; take the difference between the first set and the second set. If the difference is empty, the sub-pattern containing only the compound wildcard successfully matches the encrypted text, otherwise, the match fails.
2. A secure approximate pattern matching method as claimed in claim 1, characterized in that: The specific steps of obtaining the encrypted text are: Use the polynomial packing method to pack the held text into a polynomial; The coefficients of the polynomial are encrypted into encrypted text using a public key.
3. A secure approximate pattern matching method as claimed in claim 1, characterized in that: The specific steps of obtaining the encryption mode are: Split the held pattern using repeated wildcards as split points to obtain sub-patterns; Use the polynomial packing method to pack all subpatterns into polynomials; The coefficients of the polynomial are encrypted into an encrypted pattern using a public key.
4. A secure approximate pattern matching method as claimed in claim 1, characterized in that: The two third parties both have computing capabilities and are semi-honest and trustworthy.
5. A secure approximate pattern matching system, characterized in that: Including the text holder, the pattern holder, the key generator and two third parties; The key generator is configured to: generate a public key and a decryption key, and transmit the public key to the text holder and the pattern holder; The text holder is configured to: obtain an encrypted text based on a public key and the held text; The pattern holder is configured to: obtain an encrypted pattern based on a public key and the held pattern; The two third parties are both configured to: perform homomorphic operations on the encrypted text and the encryption pattern, match each sub-pattern in the encryption pattern with the encrypted text, and send the matching results to the key generator; The key generator is further configured to: use the decryption key to decrypt the matching result and multiply it by a random number, and then send it to the pattern holder; The sub-pattern is a sub-pattern without wildcards or a sub-pattern containing only compound wildcards; The specific steps of matching are: if the sub-pattern is the sub-pattern without wildcards, directly use the squared Euclidean distance to match each sub-pattern with the encrypted text; if the sub-pattern is the sub-pattern containing only compound wildcards, use the double query method to match each sub-pattern with the encrypted text; The dual query method specifically comprises: constructing a sub-pattern containing only compound wildcards into two sub-pattern strings to obtain a first sub-pattern string and a second sub-pattern string; calculating a matching result between the first sub-pattern string and the encrypted text, and storing the position where the coefficient in the matching result is a set value into a first set; Calculate the matching result between the second sub-pattern string and the encrypted text, and store the position where the coefficient in the matching result is the set value into the second set; take the difference between the first set and the second set. If the difference is empty, the sub-pattern containing only the compound wildcard successfully matches the encrypted text, otherwise, the match fails.
6. A secure approximate pattern matching system as claimed in claim 5, characterized in that: The two third parties both have computing capabilities and are semi-honest and trustworthy.
Citation Information
Patent Citations
Computer-implemented systems and methods for performing computational tasks across a group operating in a trust-less or dealer-free manner
CN111566988A
Multi-candidate anonymous electronic voting method based on fully homomorphic encryption
CN113037461A