Sorting method and device based on Paillier homomorphic encryption, electronic equipment and medium
By introducing blinding coefficients and weighting coefficients into the Paillier homomorphic encryption algorithm, the weighted aggregation of the ciphertexts is solved, and the existing homomorphic encryption algorithms are achieved in terms of computational efficiency and data range, and efficient data sorting is achieved.
Patent Information
- Application Number
- CN202411433981.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-02-14
AI Technical Summary
Existing homomorphic encryption algorithms have shortcomings in terms of computing efficiency and data scope, and cannot efficiently handle large-scale data sorting tasks.
The Paillier homomorphic encryption algorithm is used to generate a public key to encrypt the plaintext, and the ciphertext is weighted aggregated by adding blinding coefficients and weighted coefficients to achieve comparison and sorting of the weighted ciphertext after weighted aggregation.
It greatly reduces the amount of computing during the decryption process, improves the processing efficiency of large-scale data, and supports a wider data range and application scenarios.
Smart Images

Figure CN119449263A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data encryption technology, and in particular to a sorting method, device, electronic device and medium based on Paillier homomorphic encryption. Background Art
[0002] In today's big data era, data has become a key resource to promote social development and economic growth. With the rapid development of information technology, data sharing between enterprises has become increasingly common. By integrating data from different sources, enterprises can gain deeper insights into market dynamics and improve service quality. However, this cooperation model also brings unprecedented security risks and privacy protection challenges. In the process of data sharing, enterprises must handle a large amount of sensitive information, such as customer data. Once this information is leaked, it may cause damage to corporate interests. In addition, with the surge in data volume, traditional data protection measures are facing tremendous pressure. Especially when dealing with large-scale data sets, how to ensure the security of privacy data during transmission, storage and processing has become an urgent problem to be solved.
[0003] Data encryption technology is one of the most commonly used methods to protect data privacy. However, when operations need to be performed on these data, the ciphertext of traditional encryption methods cannot conveniently support the corresponding operations. Enterprises urgently need to adopt advanced technical means to support data processing while protecting data privacy.
[0004] Taking the implementation of secure sorting in data sharing as an example, such schemes are mainly divided into two types: sorting schemes based on order-preserving encryption and privacy protection, and privacy protection sorting schemes based on homomorphic encryption. Although order-preserving encryption can solve the problem of secure data sorting, they still have security issues. In addition, they cannot support homomorphic operations on ciphertext, which makes them unsuitable for application scenarios that require ciphertext calculations. The use of fully homomorphic encryption to build a scheme is not only inefficient but also has a certain sorting error rate. Semi-homomorphic cryptography solves privacy comparison problems and mostly has problems such as low computational efficiency, limited data range, poor practicality, and narrow application range. Therefore, in order to solve the problem of how to achieve secure sorting in data sharing scenarios, a new method with unlimited data range, wide application scenarios, and high implementation efficiency is needed. Summary of the invention
[0005] The present invention provides a sorting method, device, electronic device and medium based on Paillier homomorphic encryption, which are used to solve the technical problems of low computational efficiency, limited data range and poor practicality of existing homomorphic encryption algorithms.
[0006] According to one aspect of the present invention, a sorting method based on Paillier homomorphic encryption is provided, comprising:
[0007] Obtain multiple ciphertexts sent by the data owner, where the ciphertexts are obtained by the data owner encrypting the plaintexts using a public key, and the public key and private key are generated by a preset Paillier homomorphic encryption algorithm;
[0008] Selecting a weighting coefficient of the ciphertext based on the public key and the length of the ciphertext; obtaining a blinding coefficient based on the public key;
[0009] Using the blinding coefficient and the weighting coefficient to perform weighted aggregation on the ciphertext, respectively obtaining weighted ciphertexts corresponding to the plurality of ciphertexts;
[0010] Sending a plurality of the weighted ciphertexts to a third party organization and requesting comparison and sorting of the plurality of the weighted ciphertexts;
[0011] Obtain a sorting result fed back by the third-party organization after comparing and sorting the plurality of weighted ciphertexts.
[0012] Optionally, the public key and the private key are generated as follows:
[0013] Get prime numbers p and q of preset data length. The two prime numbers are equal in length and satisfy:
[0014] gcd(pq,(p-1)(q-1))=1
[0015] Where gcd() means returning the greatest common divisor of two or more integers; then the first public key N is the product of two prime numbers p and q;
[0016] From the ring In the equation, an integer g is randomly selected as the second public key, and the order of g is αN, and satisfies gcd(L(g α ), N) = 1, where Z is an integer, Indicates that there are N integers in this set 2 elements;
[0017] The first private key α is a factor of the least common multiple λ of p-1 and q-1; the function L(x) is defined as:
[0018]
[0019] Then the public key includes a first public key N and a second public key g; the private key includes two prime numbers p, q and a first private key α.
[0020] Optionally, the method of using the public key to encrypt the plaintext to obtain the ciphertext includes:
[0021] Acquire multiple local plaintexts, each of which includes multiple plaintext segments;
[0022] Selecting a random integer equal to the number of plaintext segments based on the length of the first public key;
[0023] The plaintext is encrypted using the first public key, the second public key and a random integer to obtain the ciphertext corresponding to each plaintext, wherein the ciphertext includes a plurality of ciphertext segments having the same number as the plaintext segments.
[0024] Optionally, selecting a weighting coefficient of the ciphertext based on the public key and the length of the ciphertext; and obtaining a blinding coefficient based on the public key includes:
[0025] The number of the weighting coefficients of the ciphertext is the same as the number of the ciphertext segments, the length of each of the weighting coefficients is the same as the length of the plaintext segment, and the data size of each of the weighting coefficients is constrained by the first public key;
[0026] A blinding coefficient corresponding to each ciphertext is selected based on the constraints of the first public key and the second public key.
[0027] Optionally, the adopting the blinding coefficient and the weighting coefficient to perform weighted aggregation on the ciphertext to obtain weighted ciphertexts corresponding to a plurality of ciphertexts respectively includes:
[0028] The blinding coefficients include s, β, a, and the weighting coefficient is W=(w1,......,w E ), then for the ciphertext C=(c1,......,c E ) is weightedly aggregated to obtain the weighted ciphertext:
[0029]
[0030] Wherein, E represents the weight coefficient and the number of the ciphertext segments; Π represents a continuous product operation;
[0031] Then for ciphertexts C1, C2, ...C n The weighted ciphertexts obtained after weighted aggregation are CB1, CB2, ...CB n .
[0032] Optionally, the method for comparing and sorting any two weighted ciphertexts includes:
[0033]
[0034] In the formula, Decrypt() means decryption, Decrypt(CB i / CB j ) represents the i-th weighted ciphertext CB among the multiple weighted ciphertexts i And the jth weighted ciphertext CB jto compare; mod means calculating the remainder after dividing two numbers; V1, V2 means the result of weighted summation of plaintext after introducing weight information, that is δ(V i ,V j ) represents the result of modN; when δ(V1,V2)∈(0,N / 2), V1>V2; when δ(V1,V2)∈(N / 2,N), V1 <V2。
[0035] Optionally, it also includes:
[0036] A quick sorting algorithm is used to compare and sort the multiple weighted ciphertexts.
[0037] According to another aspect of the present invention, a sorting device based on Paillier homomorphic encryption is provided, comprising:
[0038] A ciphertext acquisition unit, used to acquire multiple ciphertexts sent by a data owner, wherein the ciphertexts are obtained by the data owner by encrypting the plaintexts using a public key, and the public key and private key are generated by a preset Paillier homomorphic encryption algorithm;
[0039] A coefficient selection unit, configured to select a weighted coefficient of the ciphertext based on the public key and the length of the ciphertext; and obtain a blinding coefficient based on the public key;
[0040] A weighted aggregation unit, configured to perform weighted aggregation on the ciphertext using the blinding coefficient and the weighting coefficient, to obtain weighted ciphertexts corresponding to the plurality of ciphertexts;
[0041] A comparison and sorting unit, used for sending a plurality of the weighted ciphertexts to a third party organization and requesting comparison and sorting of the plurality of the weighted ciphertexts;
[0042] A result acquisition unit is used to acquire a sorting result fed back by the third-party organization after comparing and sorting the plurality of weighted ciphertexts.
[0043] According to another aspect of the present invention, there is provided an electronic device, the electronic device comprising:
[0044] at least one processor; and
[0045] a memory communicatively connected to the at least one processor; wherein,
[0046] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the sorting based on Paillier homomorphic encryption described in any embodiment of the present invention.
[0047] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the sorting based on Paillier homomorphic encryption described in any embodiment of the present invention when executed.
[0048] The technical solution of the embodiment of the present invention adopts the Paillier homomorphic encryption algorithm to generate a public key to encrypt the plaintext, and weighted aggregates the encrypted ciphertext by adding a blinding coefficient and a weighting coefficient, and compares and sorts the weighted ciphertexts after weighted aggregation. Compared with the existing method that needs to convert the plaintext into a lengthy encoding form for calculation, this solution only needs to compare the weighted ciphertexts after weighted aggregation, thereby greatly reducing the amount of calculation in the decryption process, and can more efficiently process plaintext data in a larger data range.
[0049] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. 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 creative work.
[0051] Figure 1 is a flowchart of a sorting method based on Paillier homomorphic encryption provided according to Embodiment 1 of the present invention;
[0052] Figure 2 This is an architecture diagram of a system in which a sorting method based on Paillier homomorphic encryption is provided according to Embodiment 1 of the present invention;
[0053] Figure 3 A structural diagram of a sorting device based on Paillier homomorphic encryption provided according to Embodiment 2 of the present invention;
[0054] Figure 4 It is a structural diagram of an electronic device that implements a sorting method based on Paillier homomorphic encryption provided in Example 3 of the present invention. DETAILED DESCRIPTION
[0055] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0056] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0057] Homomorphic encryption used in the present invention is a special encryption method that allows users to perform calculations directly on encrypted data without decrypting the data first. After the calculation is completed, the result is still in an encrypted state, and only users with the decryption key can see the true value of the calculation result. The core idea of homomorphic encryption is that if certain operations are performed on encrypted data, the result after decryption is consistent with the result of direct operation on plaintext. This means that if a certain operation is performed on encrypted data, the result after decryption should be equivalent to the result of performing the same operation on unencrypted data.
[0058] Homomorphic encryption can be divided into three categories based on the types of operations it supports:
[0059] Partial Homomorphic Encryption (PHE): only supports a certain type of operation, such as addition or multiplication.
[0060] Fully Homomorphic Encryption (FHE): supports any combination of addition and multiplication, which means it can perform arbitrary arithmetic or logical operations.
[0061] Hybrid homomorphic encryption: supports a limited number of additions or multiplications.
[0062] Homomorphic encryption can be used for cloud computing and privacy protection, which allows users to calculate encrypted data in the cloud and protect the privacy of user data. However, the existing fully homomorphic encryption construction scheme is not only inefficient but also has a certain sorting error rate, while semi-homomorphic encryption has problems such as low computational efficiency, limited data range, poor practicality and narrow application range when solving privacy comparison problems. Therefore, the present invention provides a new sorting method based on Paillier homomorphic encryption to reduce the amount of calculation in the decryption process and can more efficiently process plaintext data with a larger data range.
[0063] Embodiment 1
[0064] Figure 1 A flowchart of a sorting method based on Paillier homomorphic encryption is provided for the first embodiment of the present invention. Figure 1 As shown, the method includes:
[0065] S101. Acquire multiple ciphertexts sent by a data owner, wherein the ciphertexts are obtained by the data owner by encrypting plaintexts using a public key, and the public key and private key are generated by a preset Paillier homomorphic encryption algorithm.
[0066] The data owner can be an enterprise with data encryption requirements, and the data owner can share data with other cooperating data owners. Before the data owner shares the data, the data owner can obtain the public key from the key distribution center to encrypt the local plaintext.
[0067] The key distribution center may be a service unit on a server device, and in this embodiment, the key distribution center may be a unit of a cloud server. The key distribution center may generate a public key and a private key according to a preset Paillier homomorphic encryption algorithm. Specifically, the generation of the public key and the private key may be based on an existing Paillier homomorphic encryption algorithm or an improved Paillier homomorphic encryption algorithm.
[0068] The data owner can send multiple ciphertexts to the policy owner, and the policy owner performs weighted aggregation on the ciphertext data according to the data owner's request. The policy owner can be a unit in the server, which is used to execute the weighted aggregation strategy of the ciphertext and request a third-party organization to compare and sort the weighted ciphertexts.
[0069] S102. Select a weighting coefficient of the ciphertext based on the public key and the length of the ciphertext; and obtain a blinding coefficient based on the public key.
[0070] Before performing weighted aggregation of ciphertext, the policy owner needs to select the weighting coefficient and blinding coefficient required for performing weighted aggregation operation. The weighting coefficient is the coefficient for weighted calculation of each ciphertext segment in each ciphertext. The number of coefficients in the weighting coefficient needs to correspond to the number of ciphertext segments, so that each ciphertext segment has a corresponding weighting coefficient. The selection of the weighting coefficient also needs to be subject to the value size of the public key.
[0071] The core of ciphertext blinding is to use random numbers to operate on the ciphertext without changing the decryption result. For example, in the Paillier encryption system, given a Paillier ciphertext c, by selecting a random number r1, the ciphertext is operated as follows: c' = c·r1 N modN 2 In this way, although the ciphertext value has changed, the decryption result is still the original plaintext. In this embodiment, the random number required for blinding the weight coefficient can be selected according to the value of the public key.
[0072] S103, using the blinding coefficient and the weighting coefficient to perform weighted aggregation on the ciphertext to obtain weighted ciphertexts corresponding to the plurality of ciphertexts.
[0073] In this embodiment, the blinding coefficient and the weighting coefficient can be brought into a preset weighted aggregation formula to perform weighted aggregation on the ciphertext to obtain a weighted ciphertext corresponding to the ciphertext.
[0074] S104: Send the plurality of weighted ciphertexts to a third party organization and request comparison and sorting of the plurality of weighted ciphertexts.
[0075] The third party organization may be a cloud service platform for calculating weighted ciphertexts to protect the privacy of user data. After the policy owner converts the ciphertext into weighted ciphertext, he may request a comparison sorting calculation from the third party organization to obtain sorting results corresponding to multiple weighted ciphertexts. In one embodiment, the weighted ciphertexts may be sorted using a merge sort method or a quick sort method.
[0076] S105: Obtain a sorting result fed back by the third-party organization after comparing and sorting the plurality of weighted ciphertexts.
[0077] After the third-party organization completes the aggregation of weighted ciphertext, it can feed back the sorting results to the data sharing party, thereby realizing data privacy protection. The sorting method based on Paillier homomorphic encryption in this embodiment is shown in the architecture diagram of the system. Figure 2 As shown, Figure 2The key distribution center can generate public keys and private keys based on the key initialization algorithm of Paillier homomorphic encryption, and distribute the public keys to multiple data owners and policy owners, and send the private keys to a third-party agency for decryption calculation of ciphertext; the data owner uses the public key to encrypt the plaintext, and sends the encrypted ciphertext to the policy owner. The policy owner completes the weighted aggregation of the ciphertext to generate a weighted ciphertext, and requests the third-party agency to sort the weighted ciphertext; after the third-party agency completes the sorting, it feeds back the sorting result to the data sharing party.
[0078] The technical solution of the embodiment of the present invention adopts the Paillier homomorphic encryption algorithm to generate a public key to encrypt the plaintext, and weighted aggregates the encrypted ciphertext by adding a blinding coefficient and a weighting coefficient, and compares and sorts the weighted ciphertexts after weighted aggregation. Compared with the existing method that needs to convert the plaintext into a lengthy encoding form for calculation, this solution only needs to compare the weighted ciphertexts after weighted aggregation, thereby greatly reducing the amount of calculation in the decryption process, and can more efficiently process plaintext data in a larger data range.
[0079] In one embodiment, the public key and the private key are generated by a preset Paillier homomorphic encryption algorithm, specifically:
[0080] Prime numbers p and q of preset data length can be obtained. The two prime numbers are equal in length and satisfy:
[0081] gcd(pq,(p-1)(q-1))=1
[0082] Among them, gcd() means returning the greatest common divisor of two or more integers; then the first public key N is the product of two prime numbers p and q; p and q can specifically be large prime numbers of 1024 bits, then the first public key N is 2048 bits.
[0083] From the ring In the equation, an integer g is randomly selected as the second public key, and the order of g is αN, and satisfies gcd(L(g α ), N) = 1, where Z is an integer, Indicates that there are N integers in this set 2 elements;
[0084] The first private key α is a factor of the least common multiple λ of p-1 and q-1, and α can be an integer with a length of 224 bits; the function L(x) is defined as:
[0085]
[0086] The initialized public key includes 2048-bit integers N and g; the private key is two large prime numbers p and q with a length of 1024 bits and a 224-bit integer α.
[0087] In one embodiment, the method of encrypting the plaintext using the public key to obtain the ciphertext includes:
[0088] Acquire multiple local plaintexts, each of which includes multiple plaintext segments;
[0089] Selecting a random integer equal to the number of plaintext segments based on the length of the first public key;
[0090] The plaintext is encrypted using the first public key, the second public key and a random integer to obtain the ciphertext corresponding to each plaintext, wherein the ciphertext includes a plurality of ciphertext segments having the same number as the plaintext segments.
[0091] Specifically, we can assume that there are multiple given plaintexts M1, M2M consisting of E plaintext segments. n .
[0092] , ...Each given plaintext contains E plaintext segments, that is, M=(m1,...,m E ), and the length of each plaintext segment can be set to 256 bits.
[0093] Randomly select E integers r from 0-N i , where 0 <i≤E,0≤r i ≤N, use the public key N and g to perform operations on plaintext M1, M2, ...M n Encryption is performed to obtain a ciphertext consisting of E ciphertext segments:
[0094]
[0095] Using the above steps, we can get the plaintext M1, M2, ...M n The corresponding encryption result is ciphertext C1, C2, ...C n , each ciphertext contains E ciphertext segments.
[0096] In one embodiment, selecting a weighting coefficient of the ciphertext based on the public key and the length of the ciphertext; and obtaining a blinding coefficient based on the public key include:
[0097] The number of the weighting coefficients of the ciphertext is the same as the number of the ciphertext segments, the length of each of the weighting coefficients is the same as the length of the plaintext segment, and the data size of each of the weighting coefficients is constrained by the first public key;
[0098] A blinding coefficient corresponding to each ciphertext is selected based on the constraints of the first public key and the second public key.
[0099] In this embodiment, the number of weight coefficients can be set to be the same as the number of plaintext segments. For example, the weight coefficient is set to W = (w1, ..., w E ), and it can be assumed that the length of each weight coefficient corresponds to the length of the plaintext segment, both of which are 256 bits, and satisfy
[0100] The strategy owner can randomly select three data s, β, a to blind the weight information. The three random numbers satisfy 0≤a <s; and Then for the ciphertext C=(c1,......,c E ) is weightedly aggregated to obtain the weighted ciphertext as follows:
[0101]
[0102] Where, E represents the weight coefficient and the number of ciphertext segments; ∏ represents a continuous product operation; then for ciphertexts C1, C2, ...C n The weighted ciphertexts obtained after weighted aggregation are CB1, CB2, ...CB n .
[0103] In one embodiment, a method for comparing and sorting any two weighted ciphertexts includes:
[0104]
[0105] In the formula, Decrypt() means decryption, Decrypt(CB i / CB j ) represents the i-th weighted ciphertext CB among the multiple weighted ciphertexts i And the jth weighted ciphertext CB j to compare; mod means calculating the remainder after dividing two numbers; V1, V2 means the result of weighted summation of plaintext after introducing weight information, that is δ(V i ,V j ) represents the result of modN; when δ(V1,V2)∈(0,N / 2), V1>V2; when δ(V1,V2)∈(N / 2,N), V1 <V2。
[0106] In one embodiment, a quick sorting algorithm is used to compare and sort the multiple weighted ciphertexts. Specifically, the quick sorting algorithm is used to compare the n weighted ciphertexts for multiple times to obtain the final sorting result.
[0107] The technical solution of the embodiment of the present invention performs weighted aggregation on the plaintext and then compares and sorts it, without the need to use a long and lengthy encoding to calculate it as in the prior art. Therefore, the amount of calculation of the present invention is lower and can be applied to a wider range of plaintext data. The security level of this implementation algorithm is O(2 112 ), the main operation loop Modular exponentiation operation, if other operations with relatively small computational overhead are ignored, a total of 122 operations are required in the embodiment. Modular exponentiation operation on the plaintext. Since modular exponentiation operation is mainly performed on multiple plaintext segments in the plaintext, and only two modular inverse operations, modular exponentiation operations and modular multiplication operations are required when comparing ciphertext, the overall efficiency of the present invention is better than that of the existing methods, and it is more suitable for large-scale data sorting.
[0108] Embodiment 2
[0109] Figure 3 This is a schematic diagram of the structure of a sorting device based on Paillier homomorphic encryption provided in the third embodiment of the present invention. Figure 3 As shown, the device comprises:
[0110] The ciphertext acquisition unit 201 is used to acquire multiple ciphertexts sent by the data owner, wherein the ciphertexts are obtained by the data owner by encrypting the plaintexts with a public key, and the public key and private key are generated by a preset Paillier homomorphic encryption algorithm;
[0111] A coefficient selection unit 202, configured to select a weighting coefficient of the ciphertext based on the public key and the length of the ciphertext; and obtain a blinding coefficient based on the public key;
[0112] A weighted aggregation unit 203, configured to perform weighted aggregation on the ciphertext using the blinding coefficient and the weighting coefficient, to obtain weighted ciphertexts corresponding to the plurality of ciphertexts;
[0113] A comparison and sorting unit 204, used for sending a plurality of the weighted ciphertexts to a third party organization and requesting comparison and sorting of the plurality of the weighted ciphertexts;
[0114] The result acquisition unit 205 is used to acquire the sorting result fed back by the third-party organization after comparing and sorting the plurality of weighted ciphertexts.
[0115] In one embodiment, the ciphertext acquisition unit 201 is specifically used to acquire a plurality of local plaintexts, each of which includes a plurality of plaintext segments;
[0116] Selecting a random integer equal to the number of plaintext segments based on the length of the first public key;
[0117] The plaintext is encrypted using the first public key, the second public key and a random integer to obtain the ciphertext corresponding to each plaintext, wherein the ciphertext includes a plurality of ciphertext segments having the same number as the plaintext segments.
[0118] In one embodiment, it further includes a sorting unit for comparing and sorting the plurality of weighted ciphertexts using a quick sorting algorithm.
[0119] The sorting device based on Paillier homomorphic encryption provided in an embodiment of the present invention can execute the sorting method based on Paillier homomorphic encryption provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0120] Embodiment 3
[0121] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0122] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0123] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0124] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a sorting based on Paillier homomorphic encryption.
[0125] In some embodiments, a sorting based on Paillier homomorphic encryption may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the sorting based on Paillier homomorphic encryption described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform a sorting based on Paillier homomorphic encryption in any other appropriate manner (e.g., by means of firmware).
[0126] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0127] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0128] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0129] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0130] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0131] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0132] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0133] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A sorting method based on Paillier homomorphic encryption, characterized in that: include: Obtain multiple ciphertexts sent by the data owner, where the ciphertexts are obtained by the data owner encrypting the plaintexts using a public key, and the public key and private key are generated by a preset Paillier homomorphic encryption algorithm; Selecting a weighting coefficient of the ciphertext based on the public key and the length of the ciphertext; Obtaining a blinding coefficient based on the public key; Using the blinding coefficient and the weighting coefficient to perform weighted aggregation on the ciphertext, respectively obtaining weighted ciphertexts corresponding to the plurality of ciphertexts; Sending a plurality of the weighted ciphertexts to a third party organization and requesting comparison and sorting of the plurality of the weighted ciphertexts; Obtain a sorting result fed back by the third-party organization after comparing and sorting the plurality of weighted ciphertexts.
2. The sorting method based on Paillier homomorphic encryption according to claim 1 is characterized in that: The public key and the private key are generated as follows: Get prime numbers p and q of preset data length. The two prime numbers are equal in length and satisfy: gcd(pq,(p-1)(q-1))=1 Where gcd() means returning the greatest common divisor of two or more integers; then the first public key N is the product of two prime numbers p and q; From the ring In the equation, an integer g is randomly selected as the second public key, and the order of g is αN, and satisfies gcd(L(g α ), N) = 1, where Z is an integer, Indicates that there are N integers in this set 2 elements; The first private key α is a factor of the least common multiple λ of p-1 and q-1; the function L(x) is defined as: Then the public key includes a first public key N and a second public key g; the private key includes two prime numbers p, q and a first private key α.
3. The sorting method based on Paillier homomorphic encryption according to claim 2 is characterized in that: The method of using the public key to encrypt the plaintext to obtain the ciphertext includes: Acquire multiple local plaintexts, each of which includes multiple plaintext segments; Selecting a random integer equal to the number of plaintext segments based on the length of the first public key; The plaintext is encrypted using the first public key, the second public key and a random integer to obtain the ciphertext corresponding to each plaintext, wherein the ciphertext includes a plurality of ciphertext segments having the same number as the plaintext segments.
4. The sorting method based on Paillier homomorphic encryption according to claim 3 is characterized in that: The step of selecting a weighting coefficient of the ciphertext based on the public key and the length of the ciphertext; Obtaining a blinded coefficient based on the public key includes: The number of the weighting coefficients of the ciphertext is the same as the number of the ciphertext segments, the length of each of the weighting coefficients is the same as the length of the plaintext segment, and the data size of each of the weighting coefficients is constrained by the first public key; A blinding coefficient corresponding to each ciphertext is selected based on the constraints of the first public key and the second public key.
5. The sorting method based on Paillier homomorphic encryption according to claim 4 is characterized in that: The step of using the blinding coefficient and the weighting coefficient to perform weighted aggregation on the ciphertext to obtain weighted ciphertexts corresponding to a plurality of ciphertexts includes: The blinding coefficients include s, β, a, and the weighting coefficient is W=(w1,......,w E ), then for the ciphertext C=(c1,......,c E ) is weightedly aggregated to obtain the weighted ciphertext: Wherein, E represents the weight coefficient and the number of the ciphertext segments; Π represents a continuous product operation; Then for ciphertexts C1, C2, ...C n The weighted ciphertexts obtained after weighted aggregation are CB1, CB2, ...CB n .
6. The sorting method based on Paillier homomorphic encryption according to claim 5 is characterized in that: The method for comparing and sorting any two weighted ciphertexts comprises: In the formula, Decrypt() means decryption, Decrypt(CB i / CB j ) represents the i-th weighted ciphertext CB among the multiple weighted ciphertexts i And the jth weighted ciphertext CB j to compare; mod means calculating the remainder after dividing two numbers; V1, V2 means the result of weighted summation of plaintext after introducing weight information, that is δ(V i ,V j ) represents the result of modN; when δ(V1,V2)∈(0,N / 2), V1>V2; when δ(V1,V2)∈(N / 2,N), V1 <V2。 7. The sorting method based on Paillier homomorphic encryption according to claim 4 is characterized in that: Also includes: A quick sorting algorithm is used to compare and sort the multiple weighted ciphertexts.
8. A sorting device based on Paillier homomorphic encryption, characterized in that: include: A ciphertext acquisition unit, used to acquire multiple ciphertexts sent by a data owner, wherein the ciphertexts are obtained by the data owner by encrypting the plaintexts using a public key, and the public key and private key are generated by a preset Paillier homomorphic encryption algorithm; A coefficient selection unit, configured to select a weighted coefficient of the ciphertext based on the public key and the length of the ciphertext; and obtain a blinding coefficient based on the public key; A weighted aggregation unit, configured to perform weighted aggregation on the ciphertext using the blinding coefficient and the weighting coefficient, to obtain weighted ciphertexts corresponding to the plurality of ciphertexts; A comparison and sorting unit, used for sending a plurality of the weighted ciphertexts to a third party organization and requesting comparison and sorting of the plurality of the weighted ciphertexts; A result acquisition unit is used to acquire a sorting result fed back by the third-party organization after comparing and sorting the plurality of weighted ciphertexts.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the sorting method based on Paillier homomorphic encryption described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the sorting method based on Paillier homomorphic encryption described in any one of claims 1 to 7 when executed.
Citation Information
Cited By
Encrypted data processing method and device, computer equipment and readable storage medium
CN121462192A
Cryptographic data processing method and apparatus, computer device, and readable storage medium
CN121462192B