Data processing method and device, equipment, storage medium and program product
By splitting encrypted data into sub-data and processing them in parallel, the problem of low efficiency in ciphertext computation is solved, enabling fast and accurate homomorphic ciphertext computation and improving the efficiency of multi-party secure computation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WEBANK (CHINA)
- Filing Date
- 2020-12-18
- Publication Date
- 2026-06-12
AI Technical Summary
In existing technologies, the computation efficiency of encrypted data in multi-party secure computation is low, resulting in excessively long computation times and failing to meet the needs of efficient collaborative computing.
By splitting the encrypted data into multiple sub-data and using multiple threads to perform parallel homomorphic addition and/or semi-homomorphic multiplication operations, fast processing of encrypted data can be achieved.
By using multi-threaded parallel processing, the ciphertext processing time is significantly shortened, the processing efficiency is improved, and the processing requirements of homomorphic ciphertext operations are met.
Smart Images

Figure CN114647857B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a data processing method, apparatus, device, storage medium, and program product. Background Technology
[0002] Secure Multi-Party Computation (SMC) addresses the privacy-preserving collaborative computation problem among a group of mutually distrustful parties. Multiple parties can leverage SMC to perform collaborative computations on business data without disclosing their individual business data.
[0003] Secure multi-party computation is widely used in privacy-preserving machine learning. Privacy-preserving machine learning involves building a system that allows multiple parties possessing data to jointly train one or more models without disclosing any one party's data to others. This improves the performance of participants' local models while ensuring data privacy, breaking down data silos.
[0004] To ensure privacy protection, participants need to encrypt the data before interactive calculations. However, since the encrypted data involved in the calculations is large, the encrypted calculations take a long time and are inefficient. Summary of the Invention
[0005] The main objective of this invention is to provide a data processing method, apparatus, device, storage medium, and program product, which aims to improve the efficiency of encrypted computation.
[0006] To achieve the above objectives, the present invention provides a data processing method applied to a first participant among multiple parties performing multi-party secure computation, the method comprising:
[0007] Receive encrypted data sent by the second participant among the plurality of participants, and determine local data for performing operations with the encrypted data;
[0008] The encrypted data is split into multiple first sub-data, and the local data is split into multiple second sub-data;
[0009] By using multiple threads, homomorphic addition and / or semi-homomorphic multiplication operations are performed in parallel based on multiple first and second sub-data to obtain the encrypted operation result;
[0010] The encrypted computation result is output so that the participants who obtain the computation result can decrypt the computation result to obtain the plaintext result.
[0011] Optionally, the method further includes:
[0012] Determine the number of threads contained in each thread block;
[0013] The number of threads required for the encrypted data is determined based on the number of bits in the encrypted data and the number of bits that each thread can process.
[0014] The number of thread blocks required is determined based on the number of threads needed for the encrypted data and the number of threads contained in each thread block;
[0015] Accordingly, multiple threads are used to perform homomorphic addition and / or semi-homomorphic multiplication operations on multiple first and second sub-data in parallel, including:
[0016] As required by the number of thread blocks, call the corresponding number of thread blocks, and perform homomorphic addition and / or semi-homomorphic multiplication operations on multiple first and second sub-data in parallel through multiple threads in the called thread blocks.
[0017] Optionally, the local data is encrypted local data used for homomorphic addition with the encrypted data;
[0018] Accordingly, homomorphic addition operations are performed in parallel using multiple threads based on multiple first and second sub-data, including:
[0019] A thread is allocated for each first sub-data, and the thread is used to calculate the homomorphic addition result of the first sub-data and the corresponding second sub-data.
[0020] For each thread, the first sub-data and the second sub-data corresponding to the thread are multiplied in the Montgomery domain, and the modulo is taken by the square of the public key to obtain the homomorphic addition result of the first sub-data and the second sub-data.
[0021] Based on the homomorphic addition results of the first and second sub-data obtained by each thread, the homomorphic addition result of the encrypted data and the local data is determined.
[0022] Optionally, the local data is local data used to perform semi-homomorphic multiplication with the encrypted data; the encrypted data is split into a first number of first sub-data, and the local data is split into a second number of second sub-data;
[0023] Accordingly, semi-homomorphic multiplication operations are performed in parallel using multiple threads based on multiple first and second sub-data, including:
[0024] Traverse the first sub-data of the first quantity and the second sub-data of the second quantity to obtain the third quantity of data pairs. Each data pair includes a first sub-data and a second sub-data. The third quantity is the product of the first quantity and the second quantity.
[0025] Allocate one thread for each data pair;
[0026] For each thread, the Nth power of the first sub-data in the corresponding data pair is calculated and modulo the square of the public key to obtain the semi-homomorphic multiplication result of the first sub-data and the second sub-data; wherein, when the second sub-data is not greater than a preset value, N is the second sub-data, and when the second sub-data is greater than the preset value, N is the difference between the second sub-data and the public key;
[0027] Based on the semi-homomorphic multiplication results of the first and second sub-data obtained by each thread, the semi-homomorphic multiplication result of the encrypted data and the local data is determined.
[0028] Optionally, receiving encrypted data sent by a second participant among the plurality of participants includes:
[0029] If the first participant is the data processing party among the plurality of participants, then the encrypted data sent by the data provider among the plurality of participants is received;
[0030] The method further includes:
[0031] If the first participant is a data provider, the data to be computed stored locally will be split into multiple third sub-data.
[0032] The encryption operation of the multiple third sub-data is performed in parallel by multiple threads to obtain the encrypted data to be calculated.
[0033] The encrypted data to be computed is sent to other participants so that the other participants can perform homomorphic ciphertext operations based on the encrypted data to be computed to obtain the encrypted operation result.
[0034] The method further includes:
[0035] If the first participant is a participant who owns the private key, then the encrypted operation result is obtained from other participants, and the obtained encrypted operation result is split into multiple fourth sub-data.
[0036] Multiple threads are used to perform decryption operations on the multiple fourth sub-data in parallel to obtain the decrypted calculation results.
[0037] Optionally, the multiple third sub-data items can be encrypted in parallel using multiple threads to obtain encrypted data to be computed, including:
[0038] Allocate one thread for each third sub-data item;
[0039] By multiplying the corresponding third sub-data with the public key in each thread, and taking the modulo of the square of the public key after adding one to the multiplication result, the encryption result corresponding to the third sub-data is obtained.
[0040] Based on the encryption results corresponding to multiple third sub-data, the encrypted data to be calculated is obtained.
[0041] Optionally, the decryption operation on the multiple fourth sub-data can be performed in parallel using multiple threads to obtain the decrypted operation result, including:
[0042] Allocate one thread for each fourth sub-data item;
[0043] In each thread, the corresponding fourth sub-data is exponentialized based on the private key, and the decryption result corresponding to the fourth sub-data is calculated based on the exponential result and the public key.
[0044] Based on the decryption results corresponding to multiple fourth subroutines, the decrypted operation result is obtained.
[0045] Optionally, if the data to be calculated is floating-point data, the data to be calculated stored locally is split into multiple third sub-data, including:
[0046] Convert the floating-point data to integer data;
[0047] The encoded data is obtained by taking the modulo of the public key with the converted integer data.
[0048] The encoded data is split to obtain multiple third sub-data;
[0049] Accordingly, after obtaining the decrypted result, the method further includes:
[0050] The decrypted result is processed based on the attribute information of the floating-point data and the public key to obtain the decrypted floating-point result.
[0051] The present invention also provides a data processing apparatus for use by a first participant in a multi-party secure computation, the apparatus comprising:
[0052] A receiving module is configured to receive encrypted data sent by a second participant among the plurality of participants, and determine local data for performing operations with the encrypted data.
[0053] The splitting module is used to split the encrypted data into multiple first sub-data and the local data into multiple second sub-data;
[0054] The computation module is used to perform homomorphic addition and / or semi-homomorphic multiplication operations in parallel using multiple threads based on multiple first and second sub-data to obtain the encrypted computation result.
[0055] The output module is used to output the encrypted calculation result so that the participants who obtain the calculation result can decrypt the calculation result to obtain the plaintext result.
[0056] The present invention also provides a data processing apparatus, the data processing apparatus comprising: a memory, a processor, and a data processing program stored in the memory and executable on the processor, wherein the data processing program, when executed by the processor, implements the steps of the data processing method as described in any of the preceding claims.
[0057] The present invention also provides a computer-readable storage medium storing a data processing program, which, when executed by a processor, implements the steps of the data processing method as described in any of the preceding claims.
[0058] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the method described in any of the preceding claims.
[0059] In this invention, a first participant receives encrypted data sent by a second participant, determines local data for computation with the encrypted data, splits the encrypted data into multiple first sub-data, and splits the local data into multiple second sub-data. Multiple threads are used to perform homomorphic addition and / or semi-homomorphic multiplication operations in parallel based on the multiple first and second sub-data to obtain and output the encrypted computation result. This allows for parallel processing of ciphertext based on multiple threads, quickly and accurately determining the computation result of the homomorphic ciphertext, shortening the time spent on ciphertext computation, improving computational efficiency, and meeting the processing requirements of homomorphic ciphertext computation. Attached Figure Description
[0060] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of the present invention;
[0061] Figure 2 This is a schematic diagram illustrating another application scenario provided by an embodiment of the present invention;
[0062] Figure 3 A flowchart illustrating a data processing method provided in an embodiment of the present invention;
[0063] Figure 4 A schematic diagram of data splitting provided in an embodiment of the present invention;
[0064] Figure 5This is a schematic diagram of the hardware architecture corresponding to a data processing method provided in an embodiment of the present invention;
[0065] Figure 6 This is a schematic diagram of a ciphertext processing flow provided in an embodiment of the present invention;
[0066] Figure 7 This is a schematic diagram illustrating the interaction of multiple participating parties as provided in an embodiment of the present invention;
[0067] Figure 8 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present invention;
[0068] Figure 9 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present invention.
[0069] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0070] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0071] The technical solutions provided in this invention can be applied to any scenario of multi-party secure computation based on homomorphic encryption, including but not limited to model training.
[0072] The following presents two specific application scenarios for model training. It should be noted that the embodiments of this invention can also be applied to any other scenario requiring encrypted interactive computation, such as jointly computing an agreed-upon function or determining the numerical magnitude of business data among multiple participants while protecting privacy.
[0073] Figure 1 This is a schematic diagram illustrating an application scenario provided by an embodiment of the present invention. For example... Figure 1 As shown, participants A, B, and C can jointly train the model. Participant B has sample data, and participant A can train the model based on the encrypted sample data from participant B. Participant C has a public key and a private key, which can be used to decrypt the data.
[0074] First, participant C sends the public key to participants A and B, while participant C stores the private key and does not send it to other participants.
[0075] Then, participant B encrypts its own sample data or sample features using the public key and transmits the encrypted sample data or sample features to participant A. Participant A encrypts its own data, such as the target variable, using the public key, and trains the model based on the encrypted target variable and the encrypted sample data or sample features obtained from participant B, obtaining the corresponding training results. The training results may be the model's weight information, gradient information, or corresponding loss values, etc.
[0076] Participant A sends the training results to Participant C, who decrypts the training results using the public and private keys. Based on the decrypted results, Participant C determines whether the current model meets the convergence condition. If it does, the model obtained from the current training is taken as the final model. If it does not meet the condition, Participant C is notified to continue training the model until it converges.
[0077] Figure 2 This is a schematic diagram illustrating another application scenario provided by an embodiment of the present invention. For example... Figure 2 As shown, participant A and participant B jointly train the model. Participant B has a public key and a private key. Participant B sends its public key to participant A, and also has sample data.
[0078] Participant B can encrypt sample data or sample features using the public key and send the encrypted sample data or sample features to Participant A. Participant A can encrypt its own data, such as the target variable, using the public key, and train the model using the encrypted target variable and encrypted sample data. The training results are then fed back to Participant B. Participant B can decrypt the training results using the private and public keys to determine whether the model has converged. If it has not converged, Participant B will notify Participant A to further train the model until it converges.
[0079] The above presents two optional scenario architectures. Based on these, the number and functions of the participants can also be adjusted, as long as model training under privacy protection can be achieved through multiple participants.
[0080] The trained model can be of any type, including but not limited to neural network models, decision trees, random forests, etc. The trained model can be applied to any field.
[0081] In one example, the sample data may be medical image data, and the model trained using the sample data can be used to predict lesions based on the medical images.
[0082] In another example, the sample data can be user asset data held by the bank, and the model trained using the sample data can be used to predict the user's creditworthiness.
[0083] The encryption described in this embodiment of the invention can specifically refer to homomorphic encryption. After performing calculations on the homomorphically encrypted data, the calculation result is obtained, and then the calculation result is decrypted. The final plaintext result is the same as the result obtained by processing the unencrypted original data using the same calculation method.
[0084] In some technologies, homomorphic encryption can be implemented in the CPU based on the GMP large number arithmetic library. However, since the CPU can only process 32-bit or 64-bit data at a time, while the encrypted data is generally large, for example, the CPU needs to perform an iterative solution in a serial manner to process the addition of two 1024-bit ciphertext data, which is inefficient.
[0085] To address this issue, in this embodiment of the invention, after obtaining the encrypted data, the encrypted data can be split into multiple sub-data. Homomorphic addition or semi-homomorphic multiplication operations can be performed on the split sub-data in parallel through multiple threads, which can quickly obtain the operation results, shorten the task time, improve the operation efficiency, and meet the processing requirements of homomorphic ciphertext operation.
[0086] Figure 3 This is a flowchart illustrating a data processing method provided in an embodiment of the present invention. The executing entity of the method provided in this embodiment can be the first participant among multiple participants in a multi-party secure computation. For example... Figure 3 As shown, the method may include:
[0087] Step 301: Receive encrypted data sent by the second participant among the multiple participants, and determine the local data to be used for operations with the encrypted data.
[0088] The encrypted data sent by the second participant and the local data of the first participant can be data used for multi-party secure computation.
[0089] Optionally, the multi-party secure computation can be used to train the model. The encrypted data sent by the second participant can be encrypted sample data, and the local data of the first participant can include the target variable corresponding to the sample data and the model parameters such as weight values.
[0090] In one example, the model is used to predict whether a user will default on a payment. The sample data may include the user's transaction records, asset data, etc. The target variable can be used to indicate whether the user has defaulted, for example, 1 indicates default and 0 indicates no default. Thus, the user default prediction model can be trained using the data from the first participant and the second parameter.
[0091] Step 302: Split the encrypted data into multiple first sub-data, and split the local data into multiple second sub-data.
[0092] The number of bits in the first and second sub-data obtained from the split can be related to the processing capacity of the threads of the first participating party. Optionally, the first and second sub-data have the same number of bits, which is less than or equal to the number of bits that each thread can process.
[0093] For example, if each thread in the first participant can process 8-bit, 32-bit, or 64-bit data, then the first sub-data and the second sub-data can be 8-bit, 32-bit, or 64-bit. Alternatively, the number of bits in the first sub-data and the second sub-data can be less than 8-bit, 32-bit, or 64-bit.
[0094] Figure 4 This is a schematic diagram illustrating data splitting as provided in an embodiment of the present invention. Figure 4 As shown, the encrypted data / local data is 1100110001010101, which has 16 bits. Each thread can process 8 bits of data, so the data can be split into 2 sub-data, each with 8 bits, namely 11001100 and 01010101.
[0095] It should be noted that the splitting described in the embodiments of the present invention refers to dividing the data into multiple sub-data. There are many ways to implement the splitting. For example, after obtaining the encrypted data, the pointer position of the data can be determined. By adding pointers corresponding to multiple sub-data, the data can be split, and it is not necessary to store the multiple sub-data separately.
[0096] Step 303: Using multiple threads, perform homomorphic addition and / or semi-homomorphic multiplication operations in parallel based on multiple first and second sub-data to obtain the encrypted operation result.
[0097] Each thread can process at least one first sub-data and at least one second sub-data. The operations that each thread can perform may include homomorphic addition and / or semi-homomorphic multiplication. Each thread can perform at least one homomorphic addition operation and at least one semi-homomorphic multiplication operation. Each thread can perform homomorphic addition and / or semi-homomorphic multiplication operations on the first and second sub-data, and can also further perform addition and / or multiplication operations on the data obtained after the addition and / or multiplication operations.
[0098] In this embodiment, the local data used for operations with the encrypted data can be either the original local data or the encrypted local data.
[0099] Specifically, the homomorphic addition described in this embodiment of the invention can refer to the addition operation of two encrypted data; the semi-homomorphic multiplication can refer to the multiplication operation of one encrypted data and one plaintext data.
[0100] Accordingly, in this step, when homomorphic addition is required, the two data to be added can be two data encrypted with the same public key; when semi-homomorphic multiplication is required, one of the two data to be multiplied can be encrypted data and the other can be unencrypted plaintext data.
[0101] In one example, the second participant can use the public key to encrypt the user's transaction records and asset data, and send the encrypted data and the user's ID to the first participant. The first participant can use the public key to encrypt the target variable stored locally, and obtain the encrypted target variable. The encrypted target variable is used for homomorphic encryption operations. In addition, the first participant may also have locally stored model parameters and other data, which can be left unencrypted and used for semi-homomorphic multiplication operations with the encrypted data.
[0102] In this example, the first participant can train the model based on the above data. The specific calculation process can be found in the existing process of training any feasible model. The final calculation result can be determined by multiple homomorphic additions and / or semi-homomorphic multiplications.
[0103] Step 304: Output the encrypted calculation result so that the participants who obtain the calculation result can decrypt the calculation result to obtain the plaintext result.
[0104] Since the first participant does not possess the private key, it can only send the encrypted computation result to other participants for processing. These other participants can be those possessing the private key, such as the second participant, or other participants besides the first and second participants, such as collaborating parties holding the private key.
[0105] The parties who obtain the encrypted computation result can decrypt the result using the public and private keys to obtain the plaintext result, and further determine the result of the multi-party secure computation based on the result.
[0106] In the context of model training, the result of multi-party secure computation can be whether the currently trained model has converged. If it has not converged, the first participant repeats the above steps to continue training the model until it converges. The final converged model can be used to achieve functions such as prediction.
[0107] In other alternative implementations, the multi-party secure computation is used to achieve functions other than model training, such as solving the millionaire problem. Accordingly, the final result can be a comparison between the first and second participants.
[0108] The data processing method provided in this embodiment can receive encrypted data sent by a second participant from a first participant, determine local data for operation with the encrypted data, split the encrypted data into multiple first sub-data, split the local data into multiple second sub-data, and perform homomorphic addition and / or semi-homomorphic multiplication operations in parallel using multiple threads based on the multiple first and second sub-data to obtain and output the encrypted operation result. This allows for parallel processing of ciphertext based on multiple threads, quickly and accurately determining the operation result of homomorphic ciphertext, shortening the time spent on ciphertext operation, improving operation efficiency, and meeting the processing requirements of homomorphic ciphertext operation.
[0109] Based on the technical solutions provided in the above embodiments, optionally, the multiple threads can be multiple threads of a graphics processing unit (GPU). The GPU can obtain data from a central processing unit (CPU).
[0110] Figure 5 This is a schematic diagram of the hardware architecture corresponding to a data processing method provided in an embodiment of the present invention. Figure 5 As shown, each participant, such as the first participant and the second participant, can be equipped with a GPU and a CPU. The CPU can be used to realize data interaction, and the GPU can perform data calculations based on the data obtained from the CPU.
[0111] The hardware architecture described above enables efficient homomorphic computation operators based on GPU parallel computing. Optionally, multiple threads can operate in parallel by calling thread blocks within the GPU.
[0112] Optionally, the number of threads contained in each thread block can be determined first, and then the number of threads required for the encrypted data can be determined based on the number of bits in the encrypted data and the number of bits that each thread can process. Finally, the number of thread blocks required can be determined based on the number of threads required for the encrypted data and the number of threads contained in each thread block.
[0113] Correspondingly, performing homomorphic addition and / or semi-homomorphic multiplication on multiple first and second sub-data in parallel through multiple threads can include: calling a corresponding number of thread blocks as needed, and having multiple threads in the called thread blocks perform homomorphic addition and / or semi-homomorphic multiplication on multiple first and second sub-data in parallel.
[0114] For example, in a GPU, a thread can process 32-bit, 64-bit, or other bit-sized data. Taking 32-bit as an example, 32 threads can process 32 int32 (i.e., 1024 bits). To process count times 1024-bit data, 32 × count threads can be started.
[0115] Optionally, each thread block can include 512 threads. The number of bits in the first or second sub-data after splitting can be consistent with the number of bits that each thread can process. For example, if each thread can process 32 bits, then the split sub-data can also be 32 bits.
[0116] Based on the number of bits in the encrypted data and the number of bits that each thread can process, the number of threads required for the encrypted data can be determined. For example, if the encrypted data is 1024 bits, then each piece of data requires 1024 / 32 = 32 threads.
[0117] The required number of thread blocks can be determined based on the number of threads required for the encrypted data and the number of threads contained in each thread block.
[0118] Specifically, when there are multiple encrypted data sets, the number of encrypted data sets that each thread block can process can be determined first based on the number of threads required for each encrypted data set and the number of threads contained in each thread block. This number is denoted as teamPerBlock. For example, teamPerBlock = 512 / 32 = 16, which means that each thread block can process 16 encrypted data sets, that is, process 16 1024-bit data sets.
[0119] Add the total number of encrypted data to be processed (count) to the number of encrypted data that each thread block can process (teamPerBlock). Subtract one from the sum and divide it by teamPerBlock to get the required number of thread blocks.
[0120] For example, if you need to process 16 1024-bit data, you need (16+16-1) / 16 = 1 thread block. If you need to process 17 1024-bit data, you need (17+16-1) / 16 = 2 thread blocks.
[0121] Using the above method, the thread blocks required for data processing can be quickly and accurately determined. By calling the thread blocks, the parallel computing performance of the GPU can be used to quickly complete the processing of encrypted data. The steps are simple and effectively save development costs.
[0122] Figure 6 This is a schematic diagram of a ciphertext processing flow provided in an embodiment of the present invention. Figure 6 As shown, in order to achieve encrypted computation, the following processing steps can be performed in sequence: key generation, GPU floating-point encoding, GPU encryption operator, GPU addition operator, GPU multiplication operator, GPU decryption operator, GPU floating-point decoding, etc.
[0123] Optionally, besides using multiple threads for parallel processing during addition and multiplication operations, other processing steps such as encryption and decryption can also be implemented using multiple threads in parallel. For specific implementation methods on determining thread blocks and the number of threads, please refer to the aforementioned scheme; they will not be repeated here.
[0124] Optionally, each of the above processing steps can be executed by one participant or by multiple participants. For example, some participants may execute addition and multiplication operators, while other participants may execute decryption operators.
[0125] Figure 7 This is a schematic diagram illustrating the interaction of multiple participating parties as provided in an embodiment of the present invention. For example... Figure 7 As shown, multiple participants can include data providers, data processors, and collaborators.
[0126] The data provider can encrypt the data and then send the encrypted data to the data processing provider. During encryption, processes such as key generation, GPU floating-point encoding, and GPU encryption operators can be executed.
[0127] The data processing party can act as the first participant in the aforementioned embodiments, performing calculations based on the acquired encrypted data and sending the calculation results to the collaborating party. During the calculation, processing procedures such as GPU addition and GPU multiplication operators can be executed.
[0128] After obtaining the computation result, the collaborating party can decrypt it to obtain the plaintext result. This can be achieved by executing GPU decryption operators, GPU floating-point encoding, and other processing procedures.
[0129] Based on this, any participating party could act as a data provider, a data processor, or a collaborator. Therefore, the aforementioned encryption, computation, and decryption functions can be integrated into a single participating party.
[0130] During different model training processes, the same participant can have different roles. For example, when training the first model, the first participant provides the sample data for model training and can therefore act as a data provider, while the second participant can act as a data computation provider; when training the second model, the opposite is true, the second participant can act as a data provider and the first participant can act as a data computation provider.
[0131] Optionally, in the above embodiments, the first participant receiving encrypted data sent by the second participant among the plurality of participants may include: if the first participant is a data processor among the plurality of participants, then receiving encrypted data sent by the data provider among the plurality of participants. That is, when the first participant is a data processor, the operations of steps 301 to 304 above are performed.
[0132] If the first participant is the data provider, the data to be computed stored locally can be split into multiple third sub-data. Multiple threads can be used to encrypt these third sub-data in parallel to obtain encrypted data to be computed. This encrypted data is then sent to other participants, who can perform homomorphic ciphertext operations based on it to obtain the encrypted computation result. In other words, other participants perform parallel addition and multiplication operations based on the encrypted data sent by the first participant.
[0133] If the first participant is the participant who owns the private key, it can obtain the encrypted operation result from other participants and split the obtained encrypted operation result into multiple fourth sub-data; through multiple threads, the multiple fourth sub-data are decrypted in parallel to obtain the decrypted operation result.
[0134] The party possessing the private key can be the aforementioned collaborator or other parties such as the data provider. That is, the data provider can both encrypt the data and send it to the data processor, and decrypt the computation result to obtain the plaintext result.
[0135] By performing different operations when the first participant has different identities, the first participant can have both ciphertext computation capabilities and encryption and decryption capabilities, meeting the application needs in different scenarios.
[0136] The above processing steps are described in detail below through specific embodiments. Optionally, the solution in this embodiment can be implemented based on the CGBN parallel computing large number arithmetic library.
[0137] The key generation process will be explained below.
[0138] Optionally, the encryption in this embodiment of the invention may refer to encryption based on the Paillier algorithm. When generating the key, two 1024-bit large prime numbers p and q can be randomly selected. They are independent of each other and have the same length, i.e., they satisfy:
[0139] gcd(pq,(p-1)(q-1))=1
[0140] Then, calculate the public and private keys using the following formula:
[0141] n = pq
[0142] g = n + 1
[0143] λ = lcm(p-1, q-1)
[0144] μ=(L(g λ mod n 2 )) -1
[0145] Where gcd is the greatest common divisor, lcm is the least common multiple, L(x) = (x-1) / n, the public key is (n, g), and the private key is (λ, μ). Key generation only needs to be calculated once, so it can be completed in the CPU.
[0146] The above method can be used to generate Paillier keys. Paillier keys satisfy the characteristics of additive homomorphism and multiplicative semi-homomorphism, and can efficiently and accurately realize the encryption operation of multi-party secure computation.
[0147] The following explains GPU floating-point encoding.
[0148] Floating-point encoding is used to convert floating-point data into integer data. Optionally, if the data to be calculated is floating-point data, the data to be calculated stored locally is split into multiple third sub-data, which may include: converting the floating-point data into integer data; taking the modulo of the converted integer data with the public key to obtain encoded data; and splitting the encoded data to obtain multiple third sub-data.
[0149] Since GPUs can only perform calculations on unsigned integers in large number operations, floating-point data needs to be pre-encoded as unsigned integers. This can be done using the following formula:
[0150] encode(x) = x·base exp %n
[0151] Where x is the decimal part of the floating-point data, i.e., the mantissa, base is the conversion base, usually 2, and exp is the conversion exponent, usually the exponent part of the floating-point data. x·baseexp Used to obtain integer data, % indicates modulo n, where n is the public key. encode(x) is the encoded data.
[0152] The above method can convert floating-point data into integer data, allowing the data to be processed correctly by the GPU. The converted data does not exceed n, which can effectively improve the efficiency of data processing.
[0153] The GPU encryption operator is explained below.
[0154] The GPU encryption operator is used to implement data encryption operations. Optionally, multiple threads are used to perform encryption operations on the multiple third sub-data in parallel to obtain encrypted data to be calculated. This can include: allocating a thread for each third sub-data; multiplying the corresponding third sub-data with the public key using each thread, adding one to the multiplication result, and taking the modulo of the square of the public key to obtain the encryption result corresponding to the third sub-data; and obtaining the encrypted data to be calculated based on the encryption results corresponding to the multiple third sub-data.
[0155] During encryption, plaintext m is encrypted with the public key to obtain ciphertext c, which can be calculated using the following formula:
[0156] c = g m ·r n mod n 2
[0157] Where r is a random number. Here's a simplification: since g = n + 1, without considering the confusion of r, we can obtain:
[0158] c = (n+1) m mod n 2
[0159] According to the binomial expansion of Newton, we can obtain:
[0160] c = (m·n+1) mod n 2
[0161] Therefore, when it is necessary to encrypt the third sub-data, the third sub-data can be multiplied by the public key, and the result of the multiplication can be incremented by one and then modulo the square of the public key to obtain the encryption result corresponding to the third sub-data. Based on the encryption results corresponding to multiple third sub-data, the encryption results can be merged to obtain the encrypted data to be calculated.
[0162] Specifically, for each piece of plaintext to be encrypted, the plaintext can be multiplied by the public key n, the resulting ciphertext can be added by 1, and then the modulo of the square of n can be taken to obtain the final encryption result.
[0163] The above method allows for parallel data encryption operations using multiple threads, effectively improving encryption efficiency. Furthermore, without considering random number generation, encryption is achieved through direct multiplication of the plaintext and the public key, significantly simplifying computational complexity and further enhancing efficiency.
[0164] The GPU addition operator is explained below.
[0165] The addition operator is used to perform addition operations on the encrypted data. Optionally, the local data of the first participant can be encrypted local data used for homomorphic addition operations with the encrypted data.
[0166] Accordingly, performing homomorphic addition operations in parallel using multiple threads based on multiple first and second sub-data can include: allocating a thread for each first sub-data, wherein the thread is used to calculate the homomorphic addition result of the first sub-data and the corresponding second sub-data; multiplying the first and second sub-data corresponding to the thread in the Montgomery field by the square modulo of the public key to obtain the homomorphic addition result of the first and second sub-data; and determining the homomorphic addition result of the encrypted data and the local data based on the homomorphic addition results of the first and second sub-data obtained by each thread.
[0167] The corresponding bits can refer to the first and second sub-data being added being in the same position, for example, both being the high 32 bits of the data before splitting, or both being the low 32 bits of the data before splitting, thus ensuring the accuracy of the addition operation.
[0168] Optionally, when performing homomorphic addition, the multiplication of the two ciphertexts is modulo n. 2 After decryption, it equals the sum of the two corresponding plaintexts. The proof formula is as follows:
[0169]
[0170] Where D represents decryption, E represents encryption, m1 and m2 are two plaintexts with corresponding ciphertexts c1 and c2, r1 and r2 are two random numbers, and n is the public key. From the above formula, we know that adding the two ciphertexts is equal to calculating c1·c2 mod n. 2 That is, calculate the product of two ciphertexts modulo n. 2 .
[0171] To speed up the calculation, Montgomery modular multiplication can be used. Specifically, the `cgbn_bn2mont` function can be called first to convert `c1` and `c2` to numbers in Montgomery coordinates, and then the modulus of the multiplication result is calculated. 2 After the calculation is completed, the data is converted from the Montgomery domain to the normal domain.
[0172] After each thread obtains the homomorphic addition result of the first sub-data and the second sub-data, the homomorphic addition results can be merged to determine the homomorphic addition result of the encrypted data and the local data.
[0173] Specifically, each thread can determine whether there is corresponding carry information based on the broadcast information, and update and save the corresponding homomorphic addition result according to the carry information. The homomorphic addition results corresponding to the multiple threads form the homomorphic addition result of the encrypted data and the local data.
[0174] In a simple example, the two data to be added are both 64 bits. They can be split into high 32 bits and low 32 bits respectively. One thread processes the high 32 bits to obtain the homomorphic addition result of the two high 32-bit sub-data. Another thread processes the low 32 bits to obtain the homomorphic addition result of the two low 32-bit sub-data. Since there may be a carry after addition, the homomorphic addition result of the high 32 bits can be updated and saved according to the carry information.
[0175] Carry information can be sent via broadcast messages. The broadcast messages can contain carry information from each thread, and each thread can perform the corresponding carry operation after receiving the broadcast message.
[0176] Using the above method, homomorphic addition can be implemented quickly using multiple threads. Furthermore, when calculating the homomorphic addition result, the multiplication result of the two ciphertexts and the public key can be used to calculate the corresponding homomorphic addition result based on the Montgomery field, further improving the efficiency of homomorphic addition.
[0177] The GPU multiplication operator is explained below.
[0178] The multiplication operator is used to implement semi-homomorphic multiplication. Optionally, the local data of the first participant can be local data used to perform semi-homomorphic multiplication with the encrypted data. The local data can be unencrypted plaintext data to implement the semi-homomorphic multiplication operation.
[0179] The encrypted data is split into a first number of first sub-data, and the local data is split into a second number of second sub-data.
[0180] Accordingly, performing semi-homomorphic multiplication operations in parallel using multiple threads based on multiple first and second sub-data can include: traversing a first number of first sub-data and a second number of second sub-data to obtain a third number of data pairs, each data pair including a first sub-data and a second sub-data, the third number being the product of the first and second numbers; allocating a thread to each data pair; calculating the Nth power of the first sub-data in the corresponding data pair and taking the modulo of the square of the public key using each thread to obtain the semi-homomorphic multiplication result of the first and second sub-data; and determining the semi-homomorphic multiplication result of the encrypted data and the local data based on the semi-homomorphic multiplication results of the first and second sub-data obtained by each thread.
[0181] Wherein, when the second sub-data is not greater than a preset value, N is the second sub-data; when the second sub-data is greater than the preset value, N is the difference between the second sub-data and the public key.
[0182] Optionally, the preset value can be the boundary between positive and negative values of the data, generally one-third of the public key. Specifically, since the data used for calculation is obtained by encoding the original data as an integer, if the encoded data is not greater than the preset value, it indicates that the original data is a positive value and can be directly subjected to modulo exponentiation; if the encoded data is greater than the preset value, it indicates that the original data is a negative value and can be subtracted from the public key before performing modulo exponentiation. See the following proof for details.
[0183] When calculating the product of k and m, the ciphertext E(m,r1) is raised to the power of k before decryption, which gives the product m of the corresponding plaintext. The specific proof can be found in the following formula:
[0184]
[0185] Therefore, g can be calculated km mod n 2 To determine the corresponding semi-homomorphic multiplication result.
[0186] Optionally, in calculating g km mod n 2 When the plaintext of k is greater than When, it is equivalent to g (-1)(n-k)m mod n 2 It can perform inverse operations, thereby accelerating computation.
[0187] Specifically, since g = n + 1, the binomial expansion is due to In the case where nr≥2, n n-r For n 2 Multiples of n, modulo n 2 Since it is 0, we have:
[0188]
[0189]
[0190] g m(k-n) mod n 2 ≡g mk mod n 2
[0191] Therefore, g can be used m(k-n) mod n 2 To calculate the result of semi-homomorphic multiplication.
[0192] In actual calculations, assume cipher1 is the first sub-data, plain is the second sub-data, and n 2 The square of the public key n is directly calculated when the second sub-data plain is no greater than a preset value (one-third of n). That is, after calculating the second power of the first sub-data, we divide n... 2 Modulo operation yields the semi-homomorphic multiplication result of the first and second sub-data. When the second sub-data plain is greater than a preset value, the semi-homomorphic multiplication result of the first and second sub-data can be obtained based on the inverse operation.
[0193] Optionally, when performing semi-homomorphic multiplication, the data can be converted to the Montgomery domain for processing to further improve the processing efficiency of semi-homomorphic multiplication.
[0194] In this embodiment, in order to achieve multi-threaded parallel processing, a first number of first sub-data and a second number of second sub-data can be traversed to obtain a third number of data pairs, and threads can be allocated according to the data pairs.
[0195] In a simple example, when performing a semi-homomorphic multiplication of encrypted data and local data, both the encrypted data and the local data are 64 bits, which are then split into two first sub-data and two second sub-data, each of which is 32 bits.
[0196] Therefore, 2*2=4 threads are needed for parallel processing. Each thread processes one pair of data. The first thread processes the high 32 bits of the encrypted data and the high 32 bits of the local data. The second thread processes the high 32 bits of the encrypted data and the low 32 bits of the local data. The third thread processes the low 32 bits of the encrypted data and the high 32 bits of the local data. The fourth thread processes the low 32 bits of the encrypted data and the low 32 bits of the local data.
[0197] After each thread obtains the semi-homomorphic multiplication result of the corresponding sub-data, the semi-homomorphic multiplication result of the encrypted data and the local data can be determined based on the semi-homomorphic multiplication results obtained by each thread.
[0198] Optionally, the results from the four threads can be added together to obtain a semi-homomorphic multiplication result of the encrypted data and the local data. During addition, the multiplication result of the two high 32-bit sub-data can be left-shifted by 64 bits relative to the multiplication result of the two low 32-bit sub-data; the multiplication result of the high 32-bit sub-data and the low 32-bit sub-data can be left-shifted by 32 bits relative to the multiplication result of the two low 32-bit sub-data.
[0199] Using the above method, semi-homomorphic multiplication can be quickly implemented by multiple threads in parallel processing. Furthermore, different operations can be performed based on the size of the second sub-data during calculation, which can further improve the efficiency of semi-homomorphic multiplication.
[0200] The GPU decryption operator is explained below.
[0201] The decryption operator is used to decrypt the data. Optionally, multiple threads can be used to decrypt the multiple fourth sub-data in parallel to obtain the decrypted result. This can include: allocating a thread for each fourth sub-data; using each thread to perform an exponentiation operation on the corresponding fourth sub-data based on the private key, and calculating the decryption result corresponding to the fourth sub-data based on the exponentiation result and the public key; and obtaining the decrypted result based on the decryption results corresponding to the multiple fourth sub-data.
[0202] Specifically, the decryption can be referenced using the following formula:
[0203]
[0204] The meanings of each symbol can be found in the aforementioned formulas, and will not be repeated here. During decryption, an exponentiation operation is first performed, that is, the private key of the fourth sub-data is raised to the power of the exponentiation result, and then the corresponding plaintext is further calculated based on the result. Using this method, multiple threads can process the data in parallel, enabling rapid decryption.
[0205] The following section explains GPU floating-point decoding.
[0206] Floating-point decoding is used to convert integer data into floating-point data. After obtaining the decrypted result, the result can be processed according to the attribute information of the floating-point data and the public key to obtain the decrypted floating-point result. The attribute information of the floating-point data may include conversion exponent, conversion base, etc. See the following formula for details:
[0207]
[0208] Where x is the result of the decryption operation, decode(x) represents the floating-point data obtained after decoding, and the meaning of other symbols in the formula can be found in the aforementioned formula, which will not be repeated here.
[0209] The above method can convert the results of homomorphic addition and / or semi-homomorphic multiplication into floating-point data, so that the final data can meet the output requirements and improve the output adaptability of homomorphic operations.
[0210] Through the above-described sections, dense-state computation based on GPU parallel computing can be achieved, shortening task time. Furthermore, the embodiments of the present invention also provide actual experimental results obtained using the above scheme.
[0211] Specifically, tests were conducted using an Intel Xeon(R) Gold 6132 CPU @ 2.5GHz and a Tesla V100 GPU to compare the processing performance of the CPU serial computing scheme with the above scheme: In encryption operations, the CPU performed 15.3 kops (thousands of operations per second), while the above scheme performed 20 kops, a 1.3X improvement; in homomorphic addition operations, the CPU performed 114.20 kops, while the above scheme performed 2200 kops, a 20X improvement; in semi-homomorphic multiplication operations, the CPU performed 93.49 kops, while the above scheme performed 313 kops, a 3.3X improvement; in decryption operations, the CPU performed 56.6 kops, while the above scheme performed 58 kops, a 1X improvement.
[0212] The experimental results above show that the scheme disclosed in the embodiments of the present invention can effectively improve the efficiency of dense state operations, and has made significant progress.
[0213] Based on the technical solutions provided in the above embodiments, optionally, the above processing flow can be implemented based on Python. Specifically, each processing operation can be encapsulated into corresponding Python operators, such as encryption operators, addition operators, multiplication operators, decryption operators, etc. In actual use, the corresponding operators can be directly called. The interface is simple, supports secondary development, effectively reduces development difficulty, and improves development efficiency.
[0214] Figure 8 This is a schematic diagram of a data processing device provided in an embodiment of the present invention. The device can be applied to the first participant in a multi-party secure computation. For example... Figure 8 As shown, the data processing device may include:
[0215] The receiving module 801 is used to receive encrypted data sent by the second participant among the plurality of participants, and determine local data for performing operations with the encrypted data.
[0216] The splitting module 802 is used to split the encrypted data into multiple first sub-data and split the local data into multiple second sub-data;
[0217] Processing module 803 is used to perform homomorphic addition and / or semi-homomorphic multiplication operations in parallel using multiple threads based on multiple first sub-data and second sub-data to obtain the encrypted operation result;
[0218] The output module 804 is used to output the encrypted calculation result so that the participants who obtain the calculation result can decrypt the calculation result to obtain the plaintext result.
[0219] The data processing apparatus provided in this embodiment can receive encrypted data sent by a second participant through a first participant, determine local data for operation with the encrypted data, split the encrypted data into multiple first sub-data, split the local data into multiple second sub-data, and perform homomorphic addition and / or semi-homomorphic multiplication operations in parallel based on the multiple first and second sub-data through multiple threads to obtain and output the encrypted operation result. Thus, it can process ciphertext in parallel based on multiple threads, quickly and accurately determine the operation result of homomorphic ciphertext, shorten the time spent on ciphertext operation, improve the operation efficiency, and meet the processing requirements of homomorphic ciphertext operation.
[0220] In one possible implementation, the splitting module 802 is further configured to:
[0221] Determine the number of threads contained in each thread block;
[0222] The number of threads required for the encrypted data is determined based on the number of bits in the encrypted data and the number of bits that each thread can process.
[0223] The number of thread blocks required is determined based on the number of threads needed for the encrypted data and the number of threads contained in each thread block;
[0224] Accordingly, when the processing module 803 performs homomorphic addition and / or semi-homomorphic multiplication operations on multiple first sub-data and second sub-data in parallel through multiple threads, it is specifically used for:
[0225] As required by the number of thread blocks, call the corresponding number of thread blocks, and perform homomorphic addition and / or semi-homomorphic multiplication operations on multiple first and second sub-data in parallel through multiple threads in the called thread blocks.
[0226] In one possible implementation, the local data is encrypted local data used for homomorphic addition with the encrypted data;
[0227] Accordingly, when the processing module 803 performs homomorphic addition operations in parallel using multiple threads based on multiple first sub-data and second sub-data, it is specifically used for:
[0228] A thread is allocated for each first sub-data, and the thread is used to calculate the homomorphic addition result of the first sub-data and the corresponding second sub-data.
[0229] For each thread, the first sub-data and the second sub-data corresponding to the thread are multiplied in the Montgomery domain, and the modulo is taken by the square of the public key to obtain the homomorphic addition result of the first sub-data and the second sub-data.
[0230] Based on the homomorphic addition results of the first and second sub-data obtained by each thread, the homomorphic addition result of the encrypted data and the local data is determined.
[0231] In one possible implementation, the local data is local data used for performing semi-homomorphic multiplication with the encrypted data; the encrypted data is split into a first number of first sub-data, and the local data is split into a second number of second sub-data;
[0232] Accordingly, when the processing module 803 performs semi-homomorphic multiplication operations in parallel using multiple threads based on multiple first sub-data and second sub-data, it is specifically used for:
[0233] Traverse the first sub-data of the first quantity and the second sub-data of the second quantity to obtain the third quantity of data pairs. Each data pair includes a first sub-data and a second sub-data. The third quantity is the product of the first quantity and the second quantity.
[0234] Allocate one thread for each data pair;
[0235] For each thread, the Nth power of the first sub-data in the corresponding data pair is calculated and modulo the square of the public key to obtain the semi-homomorphic multiplication result of the first sub-data and the second sub-data; wherein, when the second sub-data is not greater than a preset value, N is the second sub-data, and when the second sub-data is greater than the preset value, N is the difference between the second sub-data and the public key;
[0236] Based on the semi-homomorphic multiplication results of the first and second sub-data obtained by each thread, the semi-homomorphic multiplication result of the encrypted data and the local data is determined.
[0237] In one possible implementation, when the receiving module 801 receives encrypted data sent by the second participant among the plurality of participants, it is specifically used for:
[0238] If the first participant is the data processing party among the plurality of participants, then the encrypted data sent by the data provider among the plurality of participants is received;
[0239] The processing module 803 is further configured to:
[0240] If the first participant is a data provider, the data to be computed stored locally will be split into multiple third sub-data.
[0241] The encryption operation of the multiple third sub-data is performed in parallel by multiple threads to obtain the encrypted data to be calculated.
[0242] The encrypted data to be computed is sent to other participants so that the other participants can perform homomorphic ciphertext operations based on the encrypted data to be computed to obtain the encrypted operation result.
[0243] The processing module 803 is further configured to:
[0244] If the first participant is a participant who owns the private key, then the encrypted operation result is obtained from other participants, and the obtained encrypted operation result is split into multiple fourth sub-data.
[0245] Multiple threads are used to perform decryption operations on the multiple fourth sub-data in parallel to obtain the decrypted calculation results.
[0246] In one possible implementation, when the processing module 803 performs encryption operations on the multiple third sub-data in parallel through multiple threads to obtain the encrypted data to be calculated, it is specifically used for:
[0247] Allocate one thread for each third sub-data item;
[0248] By multiplying the corresponding third sub-data with the public key in each thread, and taking the modulo of the square of the public key after adding one to the multiplication result, the encryption result corresponding to the third sub-data is obtained.
[0249] Based on the encryption results corresponding to multiple third sub-data, the encrypted data to be calculated is obtained.
[0250] In one possible implementation, when the processing module 803 performs decryption operations on the plurality of fourth sub-data in parallel through multiple threads to obtain the decrypted calculation result, it is specifically used for:
[0251] Allocate one thread for each fourth sub-data item;
[0252] In each thread, the corresponding fourth sub-data is exponentialized based on the private key, and the decryption result corresponding to the fourth sub-data is calculated based on the exponential result and the public key.
[0253] Based on the decryption results corresponding to multiple fourth subroutines, the decrypted operation result is obtained.
[0254] In one possible implementation, if the data to be calculated is floating-point data, then when the processing module 803 splits the locally stored data to be calculated into multiple third sub-data, it specifically performs the following:
[0255] Convert the floating-point data to integer data;
[0256] The encoded data is obtained by taking the modulo of the public key with the converted integer data.
[0257] The encoded data is split to obtain multiple third sub-data;
[0258] Accordingly, the processing module 803 is further configured to: after obtaining the decrypted operation result, process the decrypted operation result according to the attribute information of the floating-point data and the public key to obtain the decrypted floating-point operation result.
[0259] The data processing apparatus provided in any of the foregoing embodiments is used to execute the technical solutions of any of the foregoing method embodiments. Its implementation principle and technical effect are similar, and will not be repeated here.
[0260] Figure 9 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present invention. Figure 9 As shown, the device may include: a memory 901, a processor 902, and a data processing program stored in the memory 901 and executable on the processor 902. When the data processing program is executed by the processor 902, it implements the steps of the data processing method as described in any of the foregoing embodiments.
[0261] Alternatively, the memory 901 can be either standalone or integrated with the processor 902.
[0262] The implementation principle and technical effects of the device provided in this embodiment can be found in the foregoing embodiments, and will not be repeated here.
[0263] This invention also provides a computer-readable storage medium storing a data processing program, which, when executed by a processor, implements the steps of the data processing method as described in any of the foregoing embodiments.
[0264] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the methods described in any of the foregoing embodiments.
[0265] In the several embodiments provided by this invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed.
[0266] The integrated modules described above, implemented as software functional modules, can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of the present invention.
[0267] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly manifested as execution by a hardware processor, or execution by a combination of hardware and software modules within the processor.
[0268] The memory may include high-speed RAM, and may also include non-volatile storage (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk or optical disc, etc.
[0269] The aforementioned storage medium can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.
[0270] An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of the processor. Both the processor and the storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and storage medium can exist as discrete components in an electronic device or host device.
[0271] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0272] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0273] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0274] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A data processing method, characterized by, The method, applied to the first participant among multiple participants performing a multi-party secure computation, includes: Receive encrypted data sent by the second participant among the plurality of participants, and determine local data for performing operations with the encrypted data; The encrypted data is split into multiple first sub-data, and the local data is split into multiple second sub-data; By using multiple threads, homomorphic addition and / or semi-homomorphic multiplication operations are performed in parallel based on multiple first and second sub-data to obtain the encrypted operation result; The encrypted computation result is output so that the participating party that obtains the computation result can decrypt the computation result to obtain the plaintext result; Receiving encrypted data sent by the second participant among the plurality of participants includes: If the first participant is the data processing party among the plurality of participants, then the encrypted data sent by the data provider among the plurality of participants is received; The method further includes: If the first participant is a data provider, the data to be computed stored locally will be split into multiple third sub-data. The encryption operation of the multiple third sub-data is performed in parallel by multiple threads to obtain the encrypted data to be calculated. The encrypted data to be computed is sent to other participants so that the other participants can perform homomorphic ciphertext operations based on the encrypted data to be computed to obtain the encrypted operation result. If the first participant is a participant who owns the private key, then the encrypted operation result is obtained from other participants, and the obtained encrypted operation result is split into multiple fourth sub-data. The multiple fourth sub-data are decrypted in parallel using multiple threads to obtain the decrypted calculation results. By using multiple threads to perform encryption operations on the multiple third sub-data in parallel, the encrypted data to be calculated specifically includes: Assign a thread to each third sub-data; multiply the corresponding third sub-data with the public key through each thread, add one to the multiplication result, and take the modulo of the square of the public key to obtain the encryption result corresponding to the third sub-data; obtain the encrypted data to be calculated based on the encryption results corresponding to multiple third sub-data. During encryption, plaintext After encryption with the public key, the ciphertext c is obtained, which is calculated using the following formula: Without considering confusion r, Expanding the binomial formula using Newton's formula, we get: ; Where r is a random number and n is the public key.
2. The method according to claim 1, characterized in that, Also includes: Determine the number of threads contained in each thread block; The number of threads required for the encrypted data is determined based on the number of bits in the encrypted data and the number of bits that each thread can process. The number of thread blocks required is determined based on the number of threads needed for the encrypted data and the number of threads contained in each thread block; Accordingly, multiple threads are used to perform homomorphic addition and / or semi-homomorphic multiplication operations on multiple first and second sub-data in parallel, including: As required by the number of thread blocks, call the corresponding number of thread blocks, and perform homomorphic addition and / or semi-homomorphic multiplication operations on multiple first and second sub-data in parallel through multiple threads in the called thread blocks.
3. The method according to claim 1, characterized in that, The local data is the encrypted local data used for homomorphic addition with the encrypted data; Accordingly, homomorphic addition operations are performed in parallel using multiple threads based on multiple first and second sub-data, including: A thread is allocated for each first sub-data, and the thread is used to calculate the homomorphic addition result of the first sub-data and the corresponding second sub-data. For each thread, the first sub-data and the second sub-data corresponding to the thread are multiplied in the Montgomery domain, and the modulo is taken by the square of the public key to obtain the homomorphic addition result of the first sub-data and the second sub-data. Based on the homomorphic addition results of the first and second sub-data obtained by each thread, the homomorphic addition result of the encrypted data and the local data is determined.
4. The method according to claim 1, characterized in that, The local data is local data used for performing semi-homomorphic multiplication with the encrypted data; the encrypted data is split into a first number of first sub-data, and the local data is split into a second number of second sub-data; Accordingly, semi-homomorphic multiplication operations are performed in parallel using multiple threads based on multiple first and second sub-data, including: Traverse the first sub-data of the first quantity and the second sub-data of the second quantity to obtain the third quantity of data pairs. Each data pair includes a first sub-data and a second sub-data. The third quantity is the product of the first quantity and the second quantity. Allocate one thread for each data pair; For each thread, the Nth power of the first sub-data in the corresponding data pair is calculated and modulo the square of the public key to obtain the semi-homomorphic multiplication result of the first sub-data and the second sub-data; wherein, when the second sub-data is not greater than a preset value, N is the second sub-data, and when the second sub-data is greater than the preset value, N is the difference between the second sub-data and the public key; Based on the semi-homomorphic multiplication results of the first and second sub-data obtained by each thread, the semi-homomorphic multiplication result of the encrypted data and the local data is determined.
5. The method according to claim 1, characterized in that, The multiple third sub-data are encrypted in parallel using multiple threads to obtain the encrypted data to be computed, including: Allocate one thread for each third sub-data item; By multiplying the corresponding third sub-data with the public key in each thread, and taking the modulo of the square of the public key after adding one to the multiplication result, the encryption result corresponding to the third sub-data is obtained. Based on the encryption results corresponding to multiple third sub-data, the encrypted data to be calculated is obtained.
6. The method according to claim 1, characterized in that, Multiple threads are used to perform decryption operations on the multiple fourth sub-data in parallel to obtain the decrypted operation results, including: Allocate one thread for each fourth sub-data item; In each thread, the corresponding fourth sub-data is exponentialized based on the private key, and the decryption result corresponding to the fourth sub-data is calculated based on the exponential result and the public key. Based on the decryption results corresponding to multiple fourth subroutines, the decrypted operation result is obtained.
7. The method according to claim 1, characterized in that, If the data to be calculated is floating-point data, then the data to be calculated stored locally will be split into multiple third sub-data, including: Convert the floating-point data to integer data; The encoded data is obtained by taking the modulo of the public key with the converted integer data. The encoded data is split to obtain multiple third sub-data; Accordingly, after obtaining the decrypted result, the method further includes: The decrypted result is processed based on the attribute information of the floating-point data and the public key to obtain the decrypted floating-point result.
8. A data processing apparatus, characterized in that, The apparatus is applied to the first participant among multiple participants performing secure multi-party computation, and includes: A receiving module is configured to receive encrypted data sent by a second participant among the plurality of participants, and determine local data for performing operations with the encrypted data. The splitting module is used to split the encrypted data into multiple first sub-data and the local data into multiple second sub-data; The computation module is used to perform homomorphic addition and / or semi-homomorphic multiplication operations in parallel using multiple threads based on multiple first and second sub-data to obtain the encrypted computation result. The output module is used to output the encrypted calculation result so that the participants who obtain the calculation result can decrypt the calculation result to obtain the plaintext result; If the first participant is the data processing party among the plurality of participants, then the encrypted data sent by the data provider among the plurality of participants is received; The processing module is used to perform homomorphic addition and / or semi-homomorphic multiplication operations in parallel using multiple threads based on multiple first and second sub-data to obtain the encrypted operation result; The processing module is also used for: If the first participant is a data provider, the data to be computed stored locally will be split into multiple third sub-data. The encryption operation of the multiple third sub-data is performed in parallel by multiple threads to obtain the encrypted data to be calculated. The encrypted data to be computed is sent to other participants so that the other participants can perform homomorphic ciphertext operations based on the encrypted data to be computed to obtain the encrypted operation result. If the first participant is a participant who owns the private key, then the encrypted operation result is obtained from other participants, and the obtained encrypted operation result is split into multiple fourth sub-data. The multiple fourth sub-data are decrypted in parallel using multiple threads to obtain the decrypted calculation results. By using multiple threads to perform encryption operations on the multiple third sub-data in parallel, the encrypted data to be calculated specifically includes: Assign a thread to each third sub-data; multiply the corresponding third sub-data with the public key through each thread, add one to the multiplication result, and take the modulo of the square of the public key to obtain the encryption result corresponding to the third sub-data; obtain the encrypted data to be calculated based on the encryption results corresponding to multiple third sub-data. During encryption, plaintext After encryption with the public key, the ciphertext c is obtained, which is calculated using the following formula: Without considering confusion r, Expanding the binomial formula using Newton's formula, we get: ; Where r is a random number and n is the public key.
9. A data processing device, characterized in that, The data processing device includes: a memory, a processor, and a data processing program stored in the memory and executable on the processor, wherein the data processing program, when executed by the processor, implements the steps of the data processing method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a data processing program, which, when executed by a processor, implements the steps of the data processing method as described in any one of claims 1-7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1-7.