Homomorphic ciphertext-based maximum and minimum function processing method and system, and storage medium
By using an approximate calculation method based on homomorphic encryption algorithms, the security and plaintext cracking risks in the ciphertext size comparison process are resolved, and secure and efficient extremum function processing is achieved.
Patent Information
- Application Number
- CN202211352369.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-31
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2042-10-31
AI Technical Summary
Existing homomorphic encryption algorithms have security risks when comparing ciphertext sizes, such as the need for the computer to possess the key, and the possibility of adversaries being able to crack the plaintext through a squeeze attack.
An approximate calculation method is adopted, and the maximum and minimum value functions are processed by homomorphic encryption algorithm, including summation, division, square root approximation operation and division operation, to ensure that the calculation process does not require holding the key and to avoid squeezing attacks by approximating the result.
It enables the calculation of ciphertext size comparison results without holding the key, which improves security, and avoids plaintext reconstruction through approximate calculation, ensuring the accuracy and security of the results.
Smart Images

Figure CN115765962B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of data security, and particularly relates to a maximum and minimum function processing method and system based on homomorphic ciphertext and a storage medium. BACKGROUND
[0002] A homomorphic encryption algorithm is an algorithm supporting ciphertext operation, and the ciphertext operation algorithm supported by the homomorphic encryption algorithm includes homomorphic ciphertext addition operation and homomorphic ciphertext multiplication operation. However, only supporting multiplication and addition ciphertext operation is insufficient to meet the requirements of actual engineering application. From the perspective of actual application, data screening operation is often required in data application, and if the same operation is to be performed on ciphertext, the homomorphic encryption algorithm is required to support size comparison operation on ciphertext, that is, the calculation of min and max functions on two ciphertexts.
[0003] At present, there is a classical solution for the calculation of min and max functions, and the core process of the solution is to subtract two homomorphic ciphertexts to be compared, and then decrypt the result of subtraction to determine whether the result is greater than or less than 0.
[0004] However, the above method has two great disadvantages. The first disadvantage is that the private key needs to be given to the calculation party of the comparison operation, and the calculation party can decrypt the original data through the private key, so the method has high requirements for the selection of the calculation party.
[0005] The other disadvantage is that an accurate comparison result can be obtained. When the homomorphic encryption algorithm supports size comparison of ciphertext, a certain security risk is caused, that is, when the enemy can correctly and legally encrypt data, the enemy can generate new ciphertext and the ciphertext to be cracked for comparison operation, generate new ciphertext based on the comparison result, and finally squeeze out the original plaintext corresponding to the ciphertext to be cracked. Therefore, the security problem in the comparison process of the homomorphic ciphertext comparison algorithm also needs to be solved. SUMMARY
[0006] To solve the above two disadvantages, a maximum and minimum function processing method and system are provided, which are calculated by approximation and completely completed by homomorphic encryption, and a storage medium is also provided. The present application adopts the following technical solutions:
[0007] The application provides a homomorphic ciphertext-based extremum function processing method, characterized by comprising the following steps: step S1-1, a computing party obtains a maximum or minimum function sent by a requesting party and first and second ciphertexts to be compared; step S1-2, the first and second ciphertexts are summed based on a homomorphic encryption algorithm to obtain a first result; step S1-3, a second result obtained by dividing the first result by 2 is calculated based on a predetermined homomorphic division operation rule; step S1-4, an approximate third result obtained by taking the square root of the difference between the first and second ciphertexts is calculated based on a predetermined square root approximation operation rule; step S1-5, a fourth result obtained by dividing the third result by 2 is calculated based on the predetermined homomorphic division operation rule; step S1-6, the second and fourth results are subjected to corresponding homomorphic encryption processing to obtain a fifth result according to the type of the maximum or minimum function; and step S1-7, the computing party sends the fifth result to the requesting party for decryption to obtain a processing result of the maximum or minimum function.
[0008] The homomorphic ciphertext-based extremum function processing method provided by the application can further have the following technical features: the predetermined square root approximation operation rule is that a number x to be taken the square root of is standardized to obtain y=1 / x, a0=y and b0=y-1 are defined, and the following loop is calculated i∈[1,d], and finally a d As a result of approximate calculation, wherein d is a preset parameter for adjusting the precision of approximate calculation.
[0009] The homomorphic ciphertext-based extremum function processing method provided by the application can further have the following technical features: the predetermined homomorphic division operation rule is that the divisor and the dividend are stored as the numerator and the denominator respectively, and the numerator and the denominator are decrypted respectively when decryption is performed, and the numerator and the denominator of the decrypted plaintext are further divided to obtain a floating-point result.
[0010] The homomorphic ciphertext-based extremum function processing method provided by the application can further have the following technical features: when the extremum function is a maximum function, the corresponding homomorphic encryption processing is to calculate the sum of the second result and the fourth result.
[0011] The homomorphic ciphertext-based extremum function processing method provided by the application can further have the following technical features: the second result comprises the first result as the first numerator and 2 as the first denominator, the fourth result comprises the third result as the second numerator and 2 as the second denominator, and the calculation of the sum of the second result and the fourth result comprises: taking the sum of the product of the first numerator and the second denominator and the product of the second numerator and the first denominator as the homomorphic operation numerator, and taking the product of the first denominator and the second denominator as the homomorphic operation denominator, and the homomorphic operation numerator and the homomorphic operation denominator constitute the fifth result.
[0012] The homomorphic ciphertext-based extremum function processing method provided by the application can further have the following technical features: when the extremum function is a min function, the corresponding homomorphic encryption processing is to calculate the difference between the second result and the fourth result.
[0013] The homomorphic ciphertext-based extremum function processing method provided by the application can further have the following technical features: the second result comprises the first result as a first numerator and 2 as a first denominator, the fourth result comprises the third result as a second numerator and 2 as a second denominator, and the calculation of the difference between the second result and the fourth result comprises: taking the difference between the product of the first numerator and the second denominator and the product of the second numerator and the first denominator as a homomorphic operation result numerator and taking the product of the first denominator and the second denominator as a homomorphic operation result denominator, and the homomorphic operation result numerator and the homomorphic operation result denominator constitute the fifth result.
[0014] The application further provides a homomorphic ciphertext-based extremum function processing system, which comprises a requester configured to provide a calculation request of an extremum function and first ciphertext and second ciphertext to be compared, and a calculator configured to respond to the calculation request based on the method to complete homomorphic calculation of the extremum function of the first ciphertext and the second ciphertext.
[0015] The application further provides a computer readable storage medium, which stores computer executable instructions, and the computer executable instructions enable a processor to implement the method when the computer executable instructions are called and executed by the processor.
[0016] Inventive action and effect
[0017] The homomorphic ciphertext-based extremum function processing method, system and storage medium provided by the application can ensure that the encryption and decryption of the ciphertext and the result are only performed at the requester, and the security of the ciphertext size comparison operation is improved, because the ciphertext is subjected to homomorphic encryption operation based on the approximate calculation method of the min function and the max function, and the requester directly calculates the comparison result of the min function and the max function without holding the key.
[0018] In addition, the approximate algorithm is used to calculate the square root in the homomorphic encryption operation process, so that the final calculated comparison result is an approximate result, thereby avoiding the possibility that an enemy restores the original plaintext through the pinching method without affecting the calculation result of the min function and the max function.
[0019] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings. Attached Figure Description
[0020] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the accompanying drawings used in the description of the specific embodiments or the prior art will be briefly introduced below.
[0021] Figure 1 This is an architecture diagram of the extremum function processing system provided in an embodiment of the present invention;
[0022] Figure 2 This is one of the flowcharts for the extreme value function processing method provided in the embodiments of the present invention;
[0023] Figure 3 The second flowchart of the extreme value function processing method provided in the embodiments of the present invention;
[0024] Figure 4 A hardware structure diagram of a computer device provided for an embodiment of the present invention. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, such that a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or apparatus.
[0027] <Example>
[0028] Figure 1 This is an architecture diagram of the extremum function processing system in an embodiment of the present invention.
[0029] like Figure 1 As shown, the maximum / minimum function processing system based on homomorphic ciphertext specifically includes a requester 11 and a computer 12.
[0030] The requestor 11 is configured to provide a calculation request of a maximum or minimum function to the calculator 12, and a first ciphertext and a second ciphertext to be compared.
[0031] The calculator 12 is configured to respond to the calculation request to complete the homomorphic calculation of the maximum or minimum function of the first ciphertext and the second ciphertext, and feed back the calculated result to the requestor 11.
[0032] Specifically, the requestor 11 is deployed with an encryption and decryption algorithm, which can be used to encrypt two values to be compared to prepare for maximum or minimum comparison to form the first ciphertext and the second ciphertext, and decrypt the result fed back by the calculator 12 to obtain the comparison result. In the embodiment, the calculator 12 does not need to decrypt the ciphertext data throughout the process, and thus does not need to store the key of the requestor 11, which to some extent ensures the security of the key of the requestor 11.
[0033] In addition, in the embodiment, the encryption and decryption algorithm deployed by the requestor 11 is not limited, and can be any existing encryption and decryption algorithm for ciphertext encryption and decryption, which is not described herein.
[0034] Figure 2 is one of the flowcharts of the maximum or minimum function processing method in the embodiment; Figure 3 is another flowchart of the maximum or minimum function processing method in the embodiment.
[0035] Based on the above-mentioned maximum or minimum function processing system, the embodiment further provides a maximum or minimum function processing method. The execution process of the calculator 12 in the maximum or minimum function processing system to respond to the calculation request can refer to the flowchart of the maximum or minimum function processing method, and thus the system flowchart is not described herein. As shown in Figure 2 and Figure 3 The maximum or minimum function processing method specifically includes steps S1-1 to S1-7.
[0036] In step S1-1, the calculator 12 acquires the maximum or minimum function and the first ciphertext a and the second ciphertext b to be compared sent by the requestor 11.
[0037] In step S1-2, the first ciphertext a and the second ciphertext b are summed based on a homomorphic encryption algorithm to obtain a first result c.
[0038] In step S1-2 of the embodiment, the method of summing based on the homomorphic encryption algorithm can be any existing homomorphic encryption summing algorithm, and thus is not described herein.
[0039] In step S1-3, the first result c is divided by 2 based on a predetermined homomorphic division operation rule to obtain a second result d.
[0040] Since homomorphic encryption can only process integers, in this embodiment, the division operation is completed by predefining the homomorphic division operation rule, that is, the divisor and the dividend are stored as the numerator and the denominator, and subsequent operations related to the floating-point number are performed in the form of the fraction. After final decryption, the numerator and the denominator are decrypted, and then the numerator and the denominator are divided on the plaintext to obtain the floating-point number result.
[0041] Specifically, the second result d of this embodiment contains the first result as the first numerator and 2 as the first denominator, and participates in subsequent operations based on this data structure.
[0042] In step S1-4, the square of the difference between the first ciphertext a and the second ciphertext b is squared based on a predetermined square root approximation operation rule to obtain an approximate third result e.
[0043] In the above step S1-4, first, the difference between the first ciphertext a and the second ciphertext b, that is, a-b, is calculated. In this embodiment, the subtraction operation involved in the homomorphic calculation is also adjusted, that is, a field is added to the storage structure of the ciphertext as a sign bit for processing. When performing the four arithmetic operations, the sign bit is considered together. After decryption, if the sign bit displays the data as a positive number, the result is multiplied by -1, otherwise it is directly output.
[0044] Next, the square of a-b is calculated, which is (a-b)*(a-b), which belongs to the multiplication operation in homomorphic encryption. The method of this multiplication operation can be any existing homomorphic encryption multiplication algorithm, and therefore will not be described in detail.
[0045] Finally, the square of a-b needs to be calculated. In this embodiment, the square root operation uses an approximation algorithm, so that the third result and the final fifth result are approximate results, avoiding the enemy from restoring the original plaintext data through the pinching method.
[0046] The core process of the square root operation of this embodiment is as follows:
[0047] Input: x, d
[0048] Output: Approximate value of
[0049] (1) Standardize x, that is, calculate y = 1 / x
[0050] (2) Set a0 = y, b0 = y-1.
[0051] (3) Loop calculation
[0052] (4) Return a d , which is the result of the approximate calculation.
[0053] In the formula, d is related to the accuracy of the calculation result. The larger d is, the more accurate the result of the square root is. In this embodiment, d can be randomly adjusted within a preset range, thereby making limited random adjustment to the accuracy of the approximate calculation.
[0054] In step S1-5, the third result e is divided by 2 based on a predetermined homomorphic division operation rule to obtain a fourth result e.
[0055] In step S1-5 of this embodiment, the fourth result e contains the third result as the second numerator and 2 as the second denominator, and participates in subsequent operations based on this data structure.
[0056] In step S1-6, the second result d and the fourth result e are subjected to corresponding homomorphic encryption processing according to the type of the extremum function to obtain a fifth result. When the extremum function is a max function (i.e. Figure 3 when the function to be calculated is not a min function), the fifth result is d+e, and when the extremum function is a min function (i.e. Figure 3 when the function to be calculated is a min function), the fifth result is d-e.
[0057] When the extremum function is a max function, the corresponding homomorphic encryption processing is to calculate the sum d+e of the second result and the fourth result. The specific calculation process is as follows: the sum of the product of the first numerator and the second denominator and the product of the second numerator and the first denominator is taken as the homomorphic operation result of the numerator, and the product of the first denominator and the second denominator is taken as the homomorphic operation result of the denominator, and the homomorphic operation result of the numerator and the homomorphic operation result of the denominator constitute the fifth result.
[0058] When the extremum function is a min function, the corresponding homomorphic encryption processing is to calculate the difference d-e of the second result and the fourth result. The specific calculation process is as follows: the difference between the product of the first numerator and the second denominator and the product of the second numerator and the first denominator is taken as the homomorphic operation result of the numerator, and the product of the first denominator and the second denominator is taken as the homomorphic operation result of the denominator, and the homomorphic operation result of the numerator and the homomorphic operation result of the denominator constitute the fifth result.
[0059] In step S1-7, the calculation party 12 sends the fifth result to the request party 11 for decryption to obtain the processing result of the extremum function.
[0060] In this embodiment, after the request party 11 decrypts the fifth result, it also needs to divide the decrypted numerator and denominator to obtain a floating-point result, and the number value corresponding to the first ciphertext and the second ciphertext that is closest to the floating-point result is the comparison result of the min function or the max function.
[0061] This embodiment also provides a computer device, which can be specifically referred to Figure 4The computer device can include a processor, a memory, an input / output interface, a communication interface, and a bus. The processor, the memory, the input / output interface, and the communication interface are communicatively connected with each other through the bus. The processor is configured to execute executable code stored in the memory, so as to implement the maximum function processing method as shown in Figure 2 , 3
[0062] The processor can be implemented in the form of a general-purpose CPU (Central Processing Unit), a microprocessor, an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits, and is configured to execute a related program to implement the technical solutions provided by the embodiments of the present application.
[0063] The memory can be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, etc. The memory can store an operating system and other application programs. When the technical solutions provided by the embodiments of the present application are implemented by software or firmware, the related program codes are stored in the memory and executed by the processor.
[0064] The input / output interface is configured to connect input / output modules to implement information input and output. The input / output modules can be configured as components in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. The input device can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device can include a display, a speaker, a vibrator, an indicator, etc.
[0065] The communication interface is configured to connect a communication module (not shown in the figure) to implement communication interaction between the device and other devices. The communication module can realize communication through a wired manner (for example, a USB, a network cable, etc.) or a wireless manner (for example, a mobile network, WIFI, Bluetooth, etc.).
[0066] The bus includes a path for transmitting information between various components (for example, the processor, the memory, the input / output interface, and the communication interface) of the device.
[0067] It should be noted that although the above device only shows the processor, the memory, the input / output interface, the communication interface and the bus, in the specific implementation process, the device can also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device can also only contain the components necessary to implement the embodiments of the present application, and does not have to contain all the components shown in the figure.
[0068] Finally, it should be noted that the above embodiments are only specific implementations of the present application, which are used to illustrate the technical solutions of the present application, but not to limit them. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some technical features, within the technical range disclosed by the present application. The modifications, changes or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method for processing a maximum / minimum function based on homomorphic ciphertext, characterized by, The method comprises the following steps: Step S1-1, the computing party obtains the maximum function sent by the requesting party and the first and second ciphertexts to be compared; Step S1-2, the first and second ciphertexts are summed based on a homomorphic encryption algorithm to obtain a first result; Step S1-3, a second result obtained by dividing the first result by 2 is calculated based on a predetermined homomorphic division operation rule; Step S1-4, an approximate third result is obtained by taking the square root of the difference between the first and second ciphertexts based on a predetermined square root approximation operation rule; Step S1-5, a fourth result obtained by dividing the third result by 2 is calculated based on the predetermined homomorphic division operation rule; Step S1-6, the second and fourth results are subjected to corresponding homomorphic encryption processing according to the type of the maximum function to obtain a fifth result; Step S1-7, the computing party sends the fifth result to the requesting party for decryption to obtain the processing result of the maximum function, When the maximum function is a max function, the corresponding homomorphic encryption processing is to calculate the sum of the second and fourth results, The calculation of the sum of the second and fourth results comprises: the sum of the product of the first numerator and the second denominator and the product of the second numerator and the first denominator is taken as the homomorphic operation result, and the product of the first and second denominators is taken as the homomorphic operation result, and the homomorphic operation result constitutes the fifth result, When the maximum function is a min function, the corresponding homomorphic encryption processing is to calculate the difference between the second and fourth results, The calculation of the difference between the second and fourth results comprises: the difference between the product of the first numerator and the second denominator and the product of the second numerator and the first denominator is taken as the homomorphic operation result, and the product of the first and second denominators is taken as the homomorphic operation result, and the homomorphic operation result constitutes the fifth result.
2. The maximum function processing method based on homomorphic ciphertext according to claim 1, wherein: wherein, The predetermined square root approximation operation rule is: standardize the radicand x to obtain y = 1 / x, and set a0 = y, b0 = y-1, and calculate a0 and b0 in a loop The final a d As a result of the approximation calculation, in the formula, d is a preset parameter for adjusting the accuracy of the approximation calculation.
3. The maximum function processing method based on homomorphic ciphertext according to claim 1, wherein: wherein The predetermined homomorphic division operation rule is: the divisor and the dividend are stored as the numerator and the denominator respectively, and the numerator and the denominator are decrypted respectively when the decryption is performed, and the floating point result is obtained by dividing the decrypted plaintext numerator and denominator.
4. The maximum function processing method based on homomorphic ciphertext according to claim 1, wherein: wherein The second result comprises the first result as the first numerator and 2 as the first denominator, The fourth result comprises the third result as the second numerator and 2 as the second denominator.
5. The maximum function processing method based on homomorphic ciphertext according to claim 1, wherein: wherein, the second result includes the first result as the first numerator and 2 as the first denominator, the fourth result includes the third result as the second numerator and 2 as the second denominator.
6. A homomorphic ciphertext based extrema function processing system, characterized by comprising: comprising: a requester configured to provide a calculation request of an extreme value function and a first ciphertext and a second ciphertext to be compared; and a calculator configured to respond to the calculation request based on the method of any one of claims 1 to 5 to complete homomorphic calculation of the extreme value function of the first ciphertext and the second ciphertext.
7. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer executable instructions, and when the computer executable instructions are called and executed by the processor, the computer executable instructions cause the processor to implement the method of any one of claims 1 to 5.
Citation Information
Patent Citations
Application program running method and related product
CN113065124A
Floating-point number processing method and device, terminal and storage medium
CN114547645A