A method and device for sorting data
By using preset homomorphic encryption algorithms and blockchain technology based on random numbers in the financial industry to anonymously sort user data, it solves the problem of unprotected user plaintext data and achieves data privacy protection and secure sorting results. transmission.
Patent Information
- Application Number
- CN202011174485.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-28
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-10-28
AI Technical Summary
In the existing data sorting method in the financial industry, users' plaintext data and sorting results are not protected by privacy. Centralized institutions can see users' plaintext data and sorting results, which violates privacy protection requirements.
User data is encrypted using a preset homomorphic encryption algorithm based on random numbers, and anonymous user data is compared and sorted through the blockchain to ensure that only the user himself can know his ranking, while the plaintext data and identity of other users cannot be disclosed. learned.
Without revealing the user's plain text data and actual identity, the privacy protection of data sorting is achieved, ensuring the privacy and security of users, and increasing the credibility and transmission security of data through the blockchain.
Smart Images

Figure CN112182660B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology in the field of financial technology (Fintech), and in particular to a data sorting method and device. Background Art
[0002] With the development of computer technology, more and more technologies are being applied in the financial field. Traditional finance is gradually transforming to Fintech. However, due to the security and real-time requirements of the financial industry, higher requirements are also put forward for technology (blockchain, big data, distribution, etc.). Financial institutions have many users, and in some scenarios, user data needs to be sorted.
[0003] The current sorting method is that users submit plaintext data, and the centralized organization sorts the plaintext, such as the sorting results of the user's account balance. However, after the plaintext is sorted, the centralized organization can see the user's plaintext data and sorting results. Therefore, in this process, the user's plaintext data and sorting results are not protected from privacy, which is an urgent problem to be solved. Summary of the invention
[0004] The present invention provides a data sorting method and device, which solves the problem in the prior art that the user's plain text data and sorting results are not protected from privacy during the sorting process.
[0005] In a first aspect, the present invention provides a data sorting method, including: a first privacy computing end encrypts plaintext data of a local user through a preset homomorphic encryption algorithm based on random numbers to obtain first encrypted data; the first privacy computing end obtains second encrypted data of each anonymous user; the second encrypted data are all encrypted through the preset homomorphic encryption algorithm; the preset homomorphic encryption algorithm satisfies the homomorphic property of size relationship; the first privacy computing end compares the size of the first encrypted data with the second encrypted data according to a preset homomorphic comparison algorithm corresponding to the preset homomorphic encryption algorithm to obtain encryption comparison results; the first privacy computing end decrypts the encryption comparison results according to a preset homomorphic decryption algorithm corresponding to the preset homomorphic encryption algorithm to obtain decryption comparison results; the first privacy computing end determines the ranking of the local user according to the decryption comparison results.
[0006] In the above manner, the first privacy computing end only knows the corresponding relationship between the first encrypted data and the local user, and is not aware of the actual users corresponding to each second encrypted data. Moreover, the first encrypted data and each second encrypted data are encrypted by a preset homomorphic encryption algorithm, and the preset homomorphic encryption algorithm satisfies the homomorphic characteristics of the size relationship. Therefore, the first encrypted data and each second encrypted data can hide the original plaintext data. Since the preset homomorphic encryption algorithm contains random numbers, the original plaintext data cannot be reversed, and the homomorphic characteristics of the size relationship of the original plaintext data can be retained. Therefore, without leaking the original plaintext data and the actual identity, each encryption comparison result can be obtained according to the preset homomorphic comparison algorithm, and each decryption comparison result can be obtained by decryption. Then, each decryption comparison result can only represent whether an anonymous encrypted data is larger or smaller than the first encrypted data. Therefore, the first privacy computing end can only know the ranking of the local user, and cannot know the plaintext data and actual identity of other anonymous users, thereby protecting privacy.
[0007] Optionally, for any encrypted data among the first encrypted data and the second encrypted data, the encrypted data is encrypted by the preset homomorphic encryption algorithm in the following manner: the plaintext data of the encrypted data is converted into binary plaintext data; for each bit plaintext of the binary plaintext data, the bit plaintext is encrypting according to the preset homomorphic encryption algorithm to obtain the bit ciphertext of the bit plaintext, thereby obtaining the encrypted data.
[0008] In the above method, the plaintext data of the encrypted data is converted into binary plaintext data and encrypted bit by bit, thereby encrypting in a more fine-grained manner and further protecting the privacy of the user.
[0009] Optionally, the bit ciphertext is encrypted by the preset homomorphic encryption algorithm in the following manner:
[0010]
[0011] c k is the bit ciphertext, b k is the bit plaintext, r k For b k The generated random number, k is the serial number of the bit plaintext in the binary plaintext data, mod is the modulus operation, w is the public key, and w=p*q, p, q are prime numbers, and p and q are private keys.
[0012] In the above method, random numbers and modulo operations are used to make it more difficult for the bit plaintext to be deduced from the bit ciphertext, thereby further increasing the privacy protection of the user.
[0013] Optionally, for any second encrypted data among the second encrypted data, the first privacy computing end obtains an encryption comparison result between the first encrypted data and the second encrypted data by using the following formula:
[0014]
[0015] F is the encryption comparison result of the first encrypted data and the second encrypted data, n is the maximum value of the binary digits in the first encrypted data and the second encrypted data, C 1,j The j-th bit ciphertext when the first encrypted data is padded to n bits, C 2,j The j-th bit ciphertext when the second encrypted data is padded to n bits, C 1,i The ciphertext of the i-th bit when the first encrypted data is padded to n bits, C 2,i The ciphertext of the i-th bit when the second encrypted data is padded to n bits, is a logical negation operation, ∨ is a logical or operation, ∏ represents a continuous product operation, Enc is the preset homomorphic encryption algorithm, Enc AND It is the homomorphic AND operation in the preset comparison algorithm.
[0016] Optionally, for any second encrypted data among the second encrypted data, the first privacy computing end decrypts the encryption comparison result of the first encrypted data and the second encrypted data by specifically using the following formula to obtain the decryption comparison result of the first encrypted data and the second encrypted data:
[0017]
[0018] d t is the t-th bit result in the decryption comparison result of the first encrypted data and the second encrypted data, F t is the t-th bit ciphertext in the encrypted comparison result of the first encrypted data and the second encrypted data; if for any t, d t are all 0, it means that the second encrypted data is less than or equal to the first encrypted data; if there is any t such that d t If it is 1, it means that the second encrypted data is greater than the first encrypted data.
[0019] Optionally, the second encrypted data are stored in the blockchain by the second privacy computing terminals of the second anonymous users; the first privacy computing terminal obtains the second encrypted data of the anonymous users, including: the first privacy computing terminal obtains the second encrypted data from the blockchain.
[0020] In the above manner, by using blockchain as a medium for sharing each second encrypted data, the second encrypted data can be prevented from being tampered with, thereby increasing the credibility of each second encrypted data.
[0021] Optionally, the first privacy computing end obtains a query request from the local user; the first privacy computing end sends the local user's ranking to the local user via a secure channel constructed using the Hypertext Transfer Protocol (HTTPS).
[0022] In the above manner, the first privacy computing end sends the name of the local user to the local user through a secure channel constructed by HTTPS, which can increase the transmission privacy of the name of the local user.
[0023] In a second aspect, the present invention provides a data sorting device, comprising: a processing module, used to encrypt the plaintext data of a local user through a preset homomorphic encryption algorithm based on random numbers to obtain first encrypted data; an acquisition module, used to obtain second encrypted data of each anonymous user; the second encrypted data are all encrypted through the preset homomorphic encryption algorithm; the preset homomorphic encryption algorithm satisfies the homomorphic characteristics of size relationship; the processing module is also used to compare the size of the first encrypted data with the second encrypted data according to a preset homomorphic comparison algorithm corresponding to the preset homomorphic encryption algorithm to obtain each encryption comparison result; decrypt the encryption comparison results according to a preset homomorphic decryption algorithm corresponding to the preset homomorphic encryption algorithm to obtain each decryption comparison result; determine the ranking of the local user according to the decryption comparison results.
[0024] Optionally, for any encrypted data among the first encrypted data and the second encrypted data, the encrypted data is encrypted by the preset homomorphic encryption algorithm in the following manner: the plaintext data of the encrypted data is converted into binary plaintext data; for each bit plaintext of the binary plaintext data, the bit plaintext is encrypting according to the preset homomorphic encryption algorithm to obtain the bit ciphertext of the bit plaintext, thereby obtaining the encrypted data.
[0025] Optionally, the bit ciphertext is encrypted by the preset homomorphic encryption algorithm in the following manner: c k is the bit ciphertext, b k is the bit plaintext, r k For b k The generated random number, k is the serial number of the bit plaintext in the binary plaintext data, mod is the modulus operation, w is the public key, and w=p*q, p, q are prime numbers, and p and q are private keys.
[0026] Optionally, for any second encrypted data among the second encrypted data, the first privacy computing end obtains an encryption comparison result between the first encrypted data and the second encrypted data by using the following formula:
[0027]
[0028] F is the encryption comparison result of the first encrypted data and the second encrypted data, n is the maximum value of the binary digits in the first encrypted data and the second encrypted data, C 1,j The j-th bit ciphertext when the first encrypted data is padded to n bits, C 2,j The j-th bit ciphertext when the second encrypted data is padded to n bits, C 1,i The ciphertext of the i-th bit when the first encrypted data is padded to n bits, C 2,i The ciphertext of the i-th bit when the second encrypted data is padded to n bits, is a logical negation operation, ∨ is a logical or operation, ∏ represents a continuous product operation, Enc is the preset homomorphic encryption algorithm, Enc AND It is the homomorphic AND operation in the preset comparison algorithm.
[0029] Optionally, for any second encrypted data among the second encrypted data, the first privacy computing end decrypts the encryption comparison result of the first encrypted data and the second encrypted data by specifically using the following formula to obtain the decryption comparison result of the first encrypted data and the second encrypted data:
[0030]
[0031] d t is the t-th bit result in the decryption comparison result of the first encrypted data and the second encrypted data, F t is the t-th bit ciphertext in the encrypted comparison result of the first encrypted data and the second encrypted data; if for any t, d t are all 0, it means that the second encrypted data is less than or equal to the first encrypted data; if there is any t such that d t If it is 1, it means that the second encrypted data is greater than the first encrypted data.
[0032] Optionally, the second encrypted data are stored in the blockchain by the second privacy computing terminals of the second anonymous users, and the acquisition module is specifically used to obtain the second encrypted data from the blockchain.
[0033] Optionally, the processing module is further used to: obtain a query request from the local user; and send the local user's ranking to the local user via a secure channel constructed using the Hypertext Transfer Protocol Secure HTTPS.
[0034] The beneficial effects of the above-mentioned second aspect and each optional device of the second aspect can refer to the beneficial effects of the above-mentioned first aspect and each optional method of the first aspect, and will not be repeated here.
[0035] In a third aspect, the present invention provides a computer device, including a program or an instruction, which, when executed, is used to execute the above-mentioned first aspect and each optional method of the first aspect.
[0036] In a fourth aspect, the present invention provides a storage medium, comprising a program or an instruction, which, when executed, is used to execute the above-mentioned first aspect and each optional method of the first aspect.
[0037] These and other aspects of the present invention will become more apparent from the following description of the embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0039] Figure 1 A schematic diagram of a flow chart corresponding to a data sorting method provided in an embodiment of the present invention;
[0040] Figure 2 A schematic diagram of the system architecture of a data sorting system provided by an embodiment of the present invention;
[0041] Figure 3 A schematic diagram of the structure of a data sorting device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] First, the nouns and their definitions that appear in this application are listed.
[0044] Sorting: refers to arranging a series of numbers from large to small, and calculating the rank of each number in the series of numbers. For example, if [5,1,8] is provided, the sorting result is: 8 is the first, 5 is the second, and 1 is the third.
[0045] CA: Certificate Authority (CA) is an institution that issues digital certificates. It is a centralized institution that is responsible for issuing and managing digital certificates and is responsible for verifying the legitimacy of public keys in the public key system.
[0046] HTTPS: Hyper Text Transfer Protocol over Secure Socket Layer, is an HTTP channel with security as its goal. It ensures the security of the transmission process through transmission encryption and identity authentication based on HTTP.
[0047] In the process of operating a business (such as a bank's loan business, deposit business, etc.) of a financial institution (banking institution, insurance institution or securities institution), the financial institution has many users. In some scenarios, the user's data needs to be sorted. The current sorting method is that the user submits plaintext data, and the centralized institution performs plaintext sorting, such as the sorting result of the user's account balance. However, after the plaintext sorting, the centralized institution can see the user's plaintext data and sorting results. This situation will result in the user's plaintext data and sorting results not being protected from privacy. This situation does not meet the needs of banks and other financial institutions, and cannot guarantee the efficient operation of various businesses of financial institutions. For this reason, Figure 1 As shown, the present application provides a data sorting method.
[0048] Step 101: The first privacy computing end encrypts the plaintext data of the user on the end through a preset homomorphic encryption algorithm based on random numbers to obtain first encrypted data.
[0049] Step 102: The first privacy computing end obtains the second encrypted data of each anonymous user.
[0050] Step 103: The first privacy computing end compares the sizes of the first encrypted data and the second encrypted data according to a preset homomorphic comparison algorithm corresponding to the preset homomorphic encryption algorithm to obtain encryption comparison results.
[0051] Step 104: The first privacy computing end decrypts the encryption comparison results according to the preset homomorphic decryption algorithm corresponding to the preset homomorphic encryption algorithm to obtain decryption comparison results.
[0052] Step 105: The first privacy computing end determines the ranking of the local user according to the decryption comparison results.
[0053] In step 101 to step 105, each of the second encrypted data is encrypted by the preset homomorphic encryption algorithm; the preset homomorphic encryption algorithm satisfies the homomorphic property of size relationship.
[0054] In the method of steps 101 to 105, the first privacy computing end only knows the corresponding relationship between the first encrypted data and the local user, and is not aware of the actual user corresponding to each second encrypted data, and the first encrypted data and the second encrypted data are encrypted by a preset homomorphic encryption algorithm, and the preset homomorphic encryption algorithm satisfies the homomorphic property of size relationship, so the first encrypted data and the second encrypted data can hide the original plaintext data, and because the preset homomorphic encryption algorithm contains random numbers, the original plaintext data cannot be reversed, and the homomorphic property of the size relationship of the original plaintext data can be retained, then, without leaking the original plaintext data and the actual identity, according to the preset homomorphic comparison algorithm, each encryption comparison result can be obtained, and each decryption comparison result can be obtained by decryption, then each decryption comparison result can only represent whether an anonymous encrypted data is larger or smaller than the first encrypted data, so the first privacy computing end can only know the ranking of the local user, and cannot know the plaintext data and actual identity of other anonymous users, thereby protecting privacy.
[0055] In an optional implementation (binary implementation), for any encrypted data of the first encrypted data and each of the second encrypted data, the encrypted data can be encrypted by the preset homomorphic encryption algorithm in the following manner:
[0056] Converting the plaintext data of the encrypted data into binary plaintext data;
[0057] For each bit of plaintext in the binary plaintext data, the bit plaintext is encrypted according to the preset homomorphic encryption algorithm to obtain the bit ciphertext of the bit plaintext, thereby obtaining the encrypted data.
[0058] For example, the plaintext data of the encrypted data is b1b2…b n , each bit of plaintext b i are encrypted into bit ciphertext c i .
[0059] In a binary implementation, in one possible scenario, the bit ciphertext is encrypted by the preset homomorphic encryption algorithm in the following manner:
[0060]
[0061] c k is the bit ciphertext, b k is the bit plaintext, rk For b k The generated random number, k is the serial number of the bit plaintext in the binary plaintext data, mod is the modulus operation, w is the public key, and w=p*q, p, q are prime numbers, and p and q are private keys.
[0062] It should be noted that p and q in the above process can specifically be large prime numbers, that is, prime numbers greater than 2^128.
[0063] More specifically, based on the above scenario, for any second encrypted data among the second encrypted data, the first privacy computing end may obtain the encryption comparison result of the first encrypted data and the second encrypted data by the following formula:
[0064]
[0065] F is the encryption comparison result of the first encrypted data and the second encrypted data, n is the maximum value of the binary digits in the first encrypted data and the second encrypted data, C 1,j The j-th bit ciphertext when the first encrypted data is padded to n bits, C 2,j The j-th bit ciphertext when the second encrypted data is padded to n bits, C 1,i The ciphertext of the i-th bit when the first encrypted data is padded to n bits, C 2,i The ciphertext of the i-th bit when the second encrypted data is padded to n bits, is a logical negation operation, ∨ is a logical or operation, ∏ represents a continuous product operation, Enc is the preset homomorphic encryption algorithm, Enc AND It is the homomorphic AND operation in the preset comparison algorithm.
[0066] Furthermore, based on the above situation, the comparison can be made in the following way:
[0067] For any second encrypted data among the second encrypted data, the first privacy computing end decrypts the encryption comparison result of the first encrypted data and the second encrypted data by using the following formula to obtain the decryption comparison result of the first encrypted data and the second encrypted data:
[0068]
[0069] d t is the t-th bit result in the decryption comparison result of the first encrypted data and the second encrypted data, F t is the t-th bit ciphertext in the encrypted comparison result of the first encrypted data and the second encrypted data; if for any t, d tare all 0, it means that the second encrypted data is less than or equal to the first encrypted data; if there is any t such that d t If it is 1, it means that the second encrypted data is greater than the first encrypted data.
[0070] For example, if the obtained F1 is 00000000, it means that the second encrypted data is less than or equal to the first encrypted data, and if the obtained F1 is 00010000, it means that the second encrypted data is greater than the first encrypted data.
[0071] In an optional implementation manner, each second encrypted data is stored in the blockchain by each second privacy computing terminal of each second anonymous user, and step 102 may specifically be:
[0072] The first privacy computing end obtains the second encrypted data from the blockchain.
[0073] In the above manner, by using blockchain as a medium for sharing each second encrypted data, the second encrypted data can be prevented from being tampered with, thereby increasing the credibility of each second encrypted data.
[0074] It should be noted that after step 105, an optional implementation is as follows:
[0075] The first privacy computing end obtains the query request of the local user; the first privacy computing end sends the local user's ranking to the local user through a secure channel constructed via the Hypertext Transfer Protocol (HTTPS).
[0076] For example, the first privacy computing end obtains the query request of local user 1 and only returns the ranking of local user 1.
[0077] Combine the following Figure 2 , detailed description Figure 1 The data sorting method shown is as follows. It should be noted that Figure 2 This is just one possible scenario, not a comprehensive Figure 1 limitation.
[0078] Figure 2 The architecture shown includes: client, privacy computing node (privacy computing end) and blockchain. It should be noted that the privacy computing node does not belong to the blockchain.
[0079] Client: It is used for users to submit plaintext data for sorting. The client and the privacy computing node transmit data through a secure encrypted channel. As a lightweight terminal, the client does not perform ciphertext processing of the sorting algorithm. The ciphertext calculation of the sorting algorithm is handed over to the privacy computing node of the client's organization for processing.
[0080] Privacy computing node: A privacy computing node is a privacy computing server within the organization to which the client (user) belongs. Users within the organization will only submit data to the privacy computing node of the organization through the client. For example, client A1 will only submit data to privacy computing node A, and will not submit data to privacy computing nodes B, C, and D of other organizations. Figure 2 There is no centralized server in the architecture shown. Privacy computing nodes A, B, C, and D will perform distributed collaborative computing to calculate the ranking results of users within their respective organizations.
[0081] Blockchain: Blockchain is a platform for collaborative computing of privacy computing nodes. Each privacy computing node will be connected to a blockchain node. The privacy computing node will upload the generated ciphertext data to the blockchain platform, and other privacy computing nodes can obtain the ciphertext data on the blockchain through the blockchain. The calculated ciphertext data results are also sent point-to-point through the blockchain.
[0082] Specifically, Figure 2 The process shown is as follows:
[0083] In the first step, the user submits plaintext data and encrypts the transmitted data:
[0084] The user submits plaintext data m to the privacy computing node, and the secure channel built by HTTPS is used between the client and the privacy computing node to encrypt and transmit data. The confidentiality of the process of the client sending data to the privacy computing node is ensured, and only the privacy computing node can decrypt the ciphertext data submitted by the user.
[0085] In the second step, the privacy computing node generates ciphertext data and uploads it to the chain:
[0086] The privacy computing node obtains the plaintext data m submitted by the user, and then encrypts the data to generate ciphertext. Its preset homomorphic encryption algorithm is designed as follows:
[0087] 1) The privacy computing node generates two large prime numbers p and q as the private key sk, and the public key pk is w=p*q.
[0088] 2) Convert m into binary plaintext data b1b2…bn, where n is the number of bits of the binary plaintext data. Then select a random number ri for each bit bi, and then encrypt each bit bi to generate ciphertext:
[0089] (w is the public key);
[0090] 3) Concatenate the bit ciphertext ci of each bit of plaintext bi to form a ciphertext string C=c1…cn, and upload C and the anonymous user ID as ciphertext data to the blockchain. Privacy computing nodes upload the ciphertext of users within their respective organizations to the blockchain.
[0091] The third step is to compare the ciphertext and transmit the ciphertext comparison results point-to-point:
[0092] The privacy computing node queries the ciphertext data (encrypted data) of all users through the blockchain, then compares the ciphertext and generates an encrypted comparison result. The algorithm is designed as follows:
[0093] For plaintext data, the plaintext comparison algorithm is:
[0094]
[0095] The above formula means: For the jth bit of plaintext mb and plaintext ma, if all bits greater than j are equal and m b If the jth bit is greater, F returns 1, indicating that m b >m a The truth value representation example is as follows:
[0096] mb ma Comparison results 0 0 0 0 1 0 1 0 1 1 1 0
[0097] Since the privacy computing node obtains ciphertext data instead of plaintext data, it needs to be compared based on the ciphertext data. Therefore, the comparison of plaintext data needs to be mapped to ciphertext comparison through homomorphic properties.
[0098] The homomorphic mapping rules are as follows:
[0099] Non-homomorphic nature of encryption:
[0100] XOR homomorphic properties of encryption:
[0101] Encrypted and Homomorphic Properties: Enc AND (b1) Enc AND (b2) = Enc AND (b1∧b2).
[0102] Among them, Enc AND (b) = g0 g1…gn, where where y i is a random bit, 0 or 1, and m is the plaintext data.
[0103] The privacy computing node queries the ciphertext data Ci of all users participating in the sorting on the chain.
[0104] Therefore, the comparison algorithm under ciphertext is:
[0105]
[0106] The privacy computing node compares the ciphertext sizes of each user through a ciphertext comparison algorithm. Its F value is the comparison result in the ciphertext state. Decryption is required for each bit. The decryption algorithm is:
[0107] The privacy computing node decrypts the comparison results of each user through the decryption algorithm, and finally obtains the final result of the comparison through OR operation. From the properties of OR operation, we can know that:
[0108] If the decryption result of each bit of ciphertext in F is 0, it means that the data of other users is less than or equal to the data of this user.
[0109] If the decryption result of each bit of ciphertext in F is 1, it means that the data of other users is greater than the data of this user.
[0110] Finally, the user ranking is sorted. The specific design is as follows: initially set a user's ranking to 1. When a user's ciphertext is greater than that of the user, the user's ranking is increased by 1, otherwise it remains unchanged. After the comparison with all other users is completed, the privacy computing node determines the user's ranking. An example is as follows:
[0111] For example, the data of three users U1, U2 and U3 are m1=5, m2=1, m3=8 respectively. The privacy computing node generates the corresponding ciphertext data, U1:C1, U:C2 and U2:C3, and then uploads the ciphertext data to the chain. The privacy node compares the ciphertexts of the three users in turn through the ciphertext comparison algorithm and decrypts them to obtain the final comparison results as follows:
[0112] U1 comparison process (vs means comparison):
[0113] U2 vs U1 = C2 vs C1, the result is 0, m2 is less than or equal to m1, and the ranking R1 = 1.
[0114] U3 vs U1=C3 vs C1, the result is 1, m3 is greater than m1, ranking R1=1+1=2, and U1’s final ranking is 2.
[0115] U2 comparison process (vs means comparison):
[0116] U1 vs U2 = C1 vs C2, the result is 1, m1 is greater than m2, and the ranking R2 = 1+1 = 2.
[0117] U3 vs U2=C3 vs C2, the result is 1, m3 is greater than m2, ranking R2=2+1=3, and U2’s final ranking is 3.
[0118] U3 comparison process (vs means comparison):
[0119] U1 vs U3 = C1 vs C3, the result is 0, m1 is less than or equal to m3, and the ranking R3 = 1.
[0120] U2 vs U3 = C2 vs C3, the result is 0, m2 is less than or equal to m3, ranking R3 = 1, and U3's final ranking is 1.
[0121] Step 4: The privacy computing node transmits the sorting results:
[0122] The user sends a query request to the privacy computing node through the client to obtain the user's noun. The privacy computing node uses HTTPS to build a secure channel for encrypted transmission of the sorting results. The confidentiality of the data sent by the privacy computing node to the client is ensured, and other users and third-party organizations cannot obtain the user's sorting results, ensuring privacy security.
[0123] U1, U2 and U3 all know their own rankings, but do not know the rankings of other users.
[0124] like Figure 3 As shown, the present invention provides a data sorting device, including: a processing module 301, used to encrypt the plaintext data of the local user through a preset homomorphic encryption algorithm based on random numbers to obtain first encrypted data; an acquisition module 302, used to obtain the second encrypted data of each anonymous user; the second encrypted data are all encrypted by the preset homomorphic encryption algorithm; the preset homomorphic encryption algorithm satisfies the homomorphic property of size relationship; the processing module 301 is also used to compare the size of the first encrypted data with the second encrypted data according to a preset homomorphic comparison algorithm corresponding to the preset homomorphic encryption algorithm to obtain each encryption comparison result; according to a preset homomorphic decryption algorithm corresponding to the preset homomorphic encryption algorithm, decrypt the encryption comparison results to obtain each decryption comparison result; according to the each decryption comparison result, determine the ranking of the local user.
[0125] Optionally, for any encrypted data among the first encrypted data and the second encrypted data, the encrypted data is encrypted by the preset homomorphic encryption algorithm in the following manner: the plaintext data of the encrypted data is converted into binary plaintext data; for each bit plaintext of the binary plaintext data, the bit plaintext is encrypting according to the preset homomorphic encryption algorithm to obtain the bit ciphertext of the bit plaintext, thereby obtaining the encrypted data.
[0126] Optionally, the bit ciphertext is encrypted by the preset homomorphic encryption algorithm in the following manner: c k is the bit ciphertext, b k is the bit plaintext, r k For b kThe generated random number, k is the serial number of the bit plaintext in the binary plaintext data, mod is the modulus operation, w is the public key, and w=p*q, p, q are prime numbers, and p and q are private keys.
[0127] Optionally, for any second encrypted data among the second encrypted data, the first privacy computing end obtains an encryption comparison result between the first encrypted data and the second encrypted data by using the following formula:
[0128]
[0129] F is the encryption comparison result of the first encrypted data and the second encrypted data, n is the maximum value of the binary digits in the first encrypted data and the second encrypted data, C 1,j The j-th bit ciphertext when the first encrypted data is padded to n bits, C 2,j The j-th bit ciphertext when the second encrypted data is padded to n bits, C 1,i The ciphertext of the i-th bit when the first encrypted data is padded to n bits, C 2,i The ciphertext of the i-th bit when the second encrypted data is padded to n bits, is a logical negation operation, ∨ is a logical or operation, ∏ represents a continuous product operation, Enc is the preset homomorphic encryption algorithm, Enc AND It is the homomorphic AND operation in the preset comparison algorithm.
[0130] Optionally, for any second encrypted data among the second encrypted data, the first privacy computing end decrypts the encryption comparison result of the first encrypted data and the second encrypted data by specifically using the following formula to obtain the decryption comparison result of the first encrypted data and the second encrypted data:
[0131]
[0132] d t is the t-th bit result in the decryption comparison result of the first encrypted data and the second encrypted data, F t is the t-th bit ciphertext in the encrypted comparison result of the first encrypted data and the second encrypted data; if for any t, d t are all 0, it means that the second encrypted data is less than or equal to the first encrypted data; if there is any t such that d t If it is 1, it means that the second encrypted data is greater than the first encrypted data.
[0133] Optionally, the second encrypted data are stored in the blockchain by the second privacy computing terminals of the second anonymous users, and the acquisition module 302 is specifically used to: obtain the second encrypted data from the blockchain.
[0134] Optionally, the processing module 301 is further used to: obtain a query request from the local user; and send the local user's ranking to the local user via a secure channel constructed using the Hypertext Transfer Protocol Secure HTTPS.
[0135] Based on the same inventive concept, an embodiment of the present invention further provides a computer device, including a program or instructions. When the program or instructions are executed, the data sorting method provided in the embodiment of the present invention and any optional method are executed.
[0136] Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable storage medium, including a program or instructions. When the program or instructions are executed, the data sorting method provided in the embodiment of the present invention and any optional method are executed.
[0137] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0138] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A data sorting method, characterized in that: include: The first privacy computing end encrypts the plaintext data of the local user through a preset homomorphic encryption algorithm based on random numbers to obtain first encrypted data; The first privacy computing end obtains each second encrypted data of each anonymous user; each second encrypted data is encrypted by the preset homomorphic encryption algorithm; The preset homomorphic encryption algorithm satisfies the homomorphic property of size relationship; The first privacy computing end compares the sizes of the first encrypted data and the second encrypted data according to a preset homomorphic comparison algorithm corresponding to the preset homomorphic encryption algorithm to obtain encryption comparison results; The first privacy computing end decrypts each of the encryption comparison results according to a preset homomorphic decryption algorithm corresponding to the preset homomorphic encryption algorithm to obtain each decryption comparison result; The first privacy computing end determines the ranking of the local user according to the decryption comparison results; For any encrypted data among the first encrypted data and each of the second encrypted data, the encrypted data is encrypted by the preset homomorphic encryption algorithm in the following manner: converting the plaintext data of the encrypted data into binary plaintext data; For each bit of the binary plaintext data, the bit plaintext is encrypted according to the preset homomorphic encryption algorithm to obtain the bit ciphertext of the bit plaintext, thereby obtaining the encrypted data; wherein the bit ciphertext is encrypted by the preset homomorphic encryption algorithm in the following manner: c k is the bit ciphertext, b k is the bit plaintext, r k For b k The generated random number, k is the serial number of the bit plaintext in the binary plaintext data, mod is the modulus operation, w is the public key, and w=p*q, p, q are prime numbers, and p and q are private keys.
2. The method according to claim 1, characterized in that For any second encrypted data among the second encrypted data, the first privacy computing end obtains an encryption comparison result between the first encrypted data and the second encrypted data by using the following formula: F is the encryption comparison result of the first encrypted data and the second encrypted data, n is the maximum value of the binary digits in the first encrypted data and the second encrypted data, C 1,j The j-th bit ciphertext when the first encrypted data is padded to n bits, C 2,j The j-th bit ciphertext when the second encrypted data is padded to n bits, C 1,i The ciphertext of the i-th bit when the first encrypted data is padded to n bits, C 2,i The ciphertext of the i-th bit when the second encrypted data is padded to n bits, is a logical negation operation, ∨ is a logical or operation, ∏ represents a continuous product operation, Enc is the preset homomorphic encryption algorithm, Enc AND It is the homomorphic AND operation in the preset homomorphic comparison algorithm.
3. The method according to claim 2, characterized in that For any second encrypted data among the second encrypted data, the first privacy computing end decrypts the encryption comparison result of the first encrypted data and the second encrypted data by using the following formula to obtain the decryption comparison result of the first encrypted data and the second encrypted data: d t is the t-th bit result in the decryption comparison result of the first encrypted data and the second encrypted data, F t is the t-th bit ciphertext in the encrypted comparison result of the first encrypted data and the second encrypted data; if for any t, d t are all 0, it means that the second encrypted data is less than or equal to the first encrypted data; if there is any t such that d t If it is 1, it means that the second encrypted data is greater than the first encrypted data.
4. The method according to any one of claims 1 to 3, characterized in that The second encrypted data are stored in the blockchain by the second privacy computing terminals of the second anonymous users; The first privacy computing end obtains the second encrypted data of each anonymous user, including: The first privacy computing end obtains the second encrypted data from the blockchain.
5. The method according to any one of claims 1 to 3, characterized in that: Also includes: The first privacy computing end obtains a query request from the local user; The first privacy computing end sends the local user's name to the local user through a secure channel constructed via the Hypertext Transfer Protocol (HTTPS).
6. A data sorting device, characterized in that: include: A processing module, used to encrypt the plaintext data of the local user by a preset homomorphic encryption algorithm based on random numbers to obtain first encrypted data; An acquisition module, used to acquire each second encrypted data of each anonymous user; each second encrypted data is encrypted by the preset homomorphic encryption algorithm; the preset homomorphic encryption algorithm satisfies the homomorphic property of size relationship; The processing module is further configured to compare the sizes of the first encrypted data and the second encrypted data according to a preset homomorphic comparison algorithm corresponding to the preset homomorphic encryption algorithm to obtain encryption comparison results; decrypt the encryption comparison results according to a preset homomorphic decryption algorithm corresponding to the preset homomorphic encryption algorithm to obtain decryption comparison results; and determine the ranking of the local user according to the decryption comparison results; The acquisition module is further used for encrypting any one of the first encrypted data and the second encrypted data by the preset homomorphic encryption algorithm in the following manner: converting the plaintext data of the encrypted data into binary plaintext data; For each bit of the binary plaintext data, the bit plaintext is encrypted according to the preset homomorphic encryption algorithm to obtain a bit ciphertext of the bit plaintext, thereby obtaining the encrypted data, wherein the bit ciphertext is encrypted by the preset homomorphic encryption algorithm in the following manner: c k is the bit ciphertext, b k is the bit plaintext, r k For b k The generated random number, k is the serial number of the bit plaintext in the binary plaintext data, mod is the modulus operation, w is the public key, and w=p*q, p, q are prime numbers, and p and q are private keys.
7. A computer device, characterized in that: The method comprises a program or an instruction. When the program or the instruction is executed, the method according to any one of claims 1 to 5 is performed.
8. A computer-readable storage medium, characterized in that: The method comprises a program or an instruction. When the program or the instruction is executed, the method according to any one of claims 1 to 5 is performed.
Citation Information
Cited By
Ciphertext-based numerical value security sorting method and system
CN114168977A
A numerical security sorting method and system based on ciphertext
CN114168977B
