Homomorphic ciphertext coding method supporting floating point operation
By representing the target data as the product of the exponential power of 2 and the floating point number and performing homomorphic encryption, the problem that existing homomorphic encryption schemes cannot support floating point number calculations is solved, and the approximate value calculation of functions such as logarithmic functions, trigonometric functions and x-power of e is realized, which expands the ability of ciphertext operations.
Patent Information
- Application Number
- CN202411914402.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-18
AI Technical Summary
Existing homomorphic encryption schemes cannot support the calculation of floating-point numbers, especially the calculation of functions such as logarithmic functions, trigonometric functions and x-power of e, and cannot be implemented through scaling methods.
More ciphertext operations are supported by representing the target data as the product of the exponential power of 2 and the floating point number, and homomorphic encryption is performed using the first and second partial codes to obtain the encoding in the form of an integer.
It realizes storing floating-point numbers in the form of integers, supporting homomorphic encryption schemes based on integer ranges for more ciphertext operations, including approximate calculations of functions such as logarithmic functions, trigonometric functions and x-power of e.
Smart Images

Figure CN119848892A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a homomorphic ciphertext encoding method supporting floating-point operations. Background Art
[0002] Homomorphic encryption is closely related to the confidentiality protection of data in cloud environments and is a key technology for solving privacy protection problems in cloud environments. Homomorphic encryption is different from previous encryption methods of "data security storage". The key feature of homomorphic encryption is that its focus is on "data security processing". It can ensure that ciphertext is calculated without decryption, so that the decrypted result is the same as the result obtained by performing the same calculation on the plaintext.
[0003] Currently, homomorphic encryption schemes for integer ranges do not support floating-point numbers when performing ciphertext calculations. Although it can be supported by scaling to support the four arithmetic operations of floating-point numbers, it is unable to calculate logarithmic functions, trigonometric functions, e to the power of x, etc. Therefore, an encoding method is needed to allow the ciphertext after homomorphic encryption to support functions similar to the ln function that can be calculated using approximate values. Summary of the invention
[0004] In order to solve the problems existing in the prior art, the present invention provides a homomorphic ciphertext encoding method supporting floating-point operations. The scheme includes: using a set binary group to convert the target message data into an encoded form; the binary group includes a first subcode and a second subcode, and the second subcode is a floating point number; the target data is represented as the product of the exponential power of 2 and the second subcode, wherein the first subcode is an exponent; the first rounding parameter is obtained according to the order of the second subcode, and the first rounding parameter converts the second subcode into an integer form; the second subcode and the first rounding parameter are homomorphically encrypted respectively to obtain the corresponding first encryption state value and the second encryption state value; the encoding form of the target message is obtained according to the first subcode, the second subcode, the first rounding parameter, the first encryption state value and the second encryption state value. The encoding method proposed by the present invention supports the storage of floating-point numbers in the form of integers, so that the homomorphic encryption scheme based on the integer range can perform more ciphertext operations through the encoding.
[0005] The present invention adopts the following technical solution, a homomorphic ciphertext encoding method supporting floating-point operations, comprising:
[0006] Get target message data;
[0007] The target message data is converted into a coded form by setting a binary group; the binary group includes a first code segment and a second code segment, and the second code segment is a floating point number; the specific steps are:
[0008] Representing the target data as a product of an exponential power of 2 and the second code segment, wherein the first code segment is an exponential;
[0009] Acquire a first rounding parameter according to the order of the second code segment, where the first rounding parameter is used to convert the second code segment into an integer form;
[0010] Performing homomorphic encryption on the second code segment and the first rounding parameter respectively to obtain a first encryption state value corresponding to the second code segment and a second encryption state value corresponding to the first rounding parameter;
[0011] The encoding form of the target message is obtained according to the first sub-code, the second sub-code, the first rounding parameter, the first encryption state value and the second encryption state value.
[0012] Further, the target data is represented as a product of an exponential power of 2 and the second code segment, wherein the first code segment is an exponential, including:
[0013] Assume the target message data is m, and the tuple is (k, f), where the first code is k and the second code is f;
[0014] After finding the absolute value of the target message data m, set m = 2 k f, the first and second sub-codes are obtained as:
[0015] r=log2|m|
[0016]
[0017] f=2 r-k
[0018] in, Indicates rounding down; f∈[1,2).
[0019] Further, obtaining a first rounding parameter according to the order of the second code segment, where the first rounding parameter is used to convert the second code segment into an integer form, includes:
[0020] Assuming the order of the second code segment is s, the first rounding parameter is: d = 10 s ;
[0021] The second code is converted into an integer form according to the first rounding parameter, that is, f=f×10 s ;
[0022] Set m=2 k f is converted to
[0023] Furthermore, the encoding form of the target message is expressed as:
[0024] (k,f,d,c f ,c d )
[0025] Among them, k is the first code, f is the second code, d is the first rounding parameter, c is f is the first encryption state value, c d is the second encryption state value;
[0026] Further, the first encryption state value and the second encryption state value include:
[0027] The first encryption state value and the second encryption state value are 0 or 1;
[0028] When the value is 0, it means that the corresponding second code segment or first rounding parameter is not encrypted;
[0029] When the value is 1, it indicates that the corresponding second code segment or first rounding parameter is in the ciphertext state.
[0030] Furthermore, after obtaining the encoding form of the target message, the method further includes: performing four arithmetic operations according to the encoding form of the target message.
[0031] The beneficial effect of the present invention is that the encoding method proposed in the present invention can support encoding conversion of target data through floating-point numbers, and at the same time, the floating-point numbers are further stored in the form of integers through the encoding method, and the encoding is applied in homomorphic encryption, so that the homomorphic encryption scheme based on the integer range can support more ciphertext operations through the encoding. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0033] Figure 1 A schematic flow chart of a homomorphic ciphertext encoding method supporting floating-point operations according to an embodiment of the present invention;
[0034] Figure 2 The figure is a schematic diagram of a coding process flow of an embodiment of the present invention. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0036] A flow chart of a homomorphic ciphertext encoding method supporting floating-point operations according to an embodiment of the present invention is shown in FIG. Figure 1 As shown, including:
[0037] Get target message data;
[0038] The target message data is converted into a coded form by setting a binary group; the binary group includes a first code segment and a second code segment, and the second code segment is a floating point number;
[0039] Specific steps are as follows Figure 2 As shown, including:
[0040] The target data is expressed as the product of an exponential power of 2 and the second code segment, wherein the first code segment is an exponent; specifically:
[0041] Assume the target message data is m, and the tuple is (k, f), where the first code is k and the second code is f;
[0042] After finding the absolute value of the target message data m, set m = 2 k f, the first and second sub-codes are obtained as:
[0043] r=log2|m|
[0044]
[0045] f=2 r-k
[0046] in, Indicates rounding down; f∈[1,2).
[0047] A first rounding parameter is obtained according to the order of the second code segment, and the first rounding parameter is used to convert the second code segment into an integer form; specifically:
[0048] Assume that the order of the second code segment is s, and the first rounding parameter is: d = 10 s ; Convert the second code into an integer form according to the first rounding parameter, that is: f = f × 10 s ; Set m=2 k f is converted to
[0049] Performing homomorphic encryption on the second code segment and the first rounding parameter respectively to obtain a first encryption state value corresponding to the second code segment and a second encryption state value corresponding to the first rounding parameter;
[0050] The first encryption state value and the second encryption state value include:
[0051] The first encryption state value and the second encryption state value are 0 or 1; when the value is 0, it indicates that the corresponding second code segment or the first rounding parameter is in an unencrypted state; when the value is 1, it indicates that the corresponding second code segment or the first rounding parameter is in a ciphertext state.
[0052] The encoded form of the target message is obtained according to the first sub-code, the second sub-code, the first rounding parameter, the first encryption state value and the second encryption state value.
[0053] The encoding form of the target message is expressed as: (k,f,d,c f ,c d );
[0054] Among them, k is the first code, f is the second code, d is the first rounding parameter, c is f is the first encryption state value, c d It is the second encryption state value.
[0055] After the encoding form of the target message is obtained, four arithmetic operations are performed according to the encoding form of the target message.
[0056] In another specific embodiment of the present invention:
[0057] Obtain target message data, and convert the target message data into a coded form by using a set binary group. The specific steps are as follows:
[0058] In the embodiment of the present invention, data conversion first considers converting the message data m into the form of (k, f), and m=2 k f, thereby facilitating the development of dense state computing. Since in this situation, f-1 can be converted into the form of the encoding scheme in math.h, the encoding scheme of the present invention does not specifically perform a subtraction operation on f.
[0059] For a given message data m, first calculate its absolute value, and then convert the message after the absolute value into 2 using the following method k The form of f is:
[0060] r=log2|m|
[0061]
[0062] in, It means rounding down, so r is rounded down to complete the extraction of k.
[0063] Meanwhile, in the data extraction scheme of the embodiment of the present invention, (f+1) is not used, but f is directly used. In this case, the form of data extraction is m=2 k f, we can get: f = 2 r-k ; Thus, the given message data m is converted into 2k f, and at this time, a (k, f) is initially used to represent a message data m.
[0064] Since the converted f is a floating point number and f∈[1,2), it needs to be converted into an integer before encryption. The conversion method in the embodiment of the present invention is: select a fixed number of decimal places s according to the order of the floating point number, and directly remove the decimal point, which is expressed as: f=f×10 s ;
[0065] After the transformation, f is an integer. If the original message m<0, f is negative, and d=10 is introduced. s Make Keep the original value of message m, m=2 when calculating ciphertext k The form of f cannot support division, so it uses Just enough to allow division to be expressed in fractional form.
[0066] Thus, in the embodiment of the present invention, the encoding conversion of the message data m is completed, using (k, f, d, c f ,c d ) to record the converted code of data m, and the newly added c in the code f ,c d Represents the plaintext and ciphertext status of f and d.
[0067] After data conversion, a message m is converted into (k,f,d,c f ,c d ) in the form of f represents the plaintext and ciphertext state of f, c d Indicates the plaintext and ciphertext state of d. The plaintext and ciphertext state identifier has only two values: 0 and 1, 0 represents plaintext and 1 represents ciphertext, and
[0068] Before performing secret calculations, the data needs to be encrypted. Obviously, (k,f,d,c f ,c d ) When calculating data in the form of , it is necessary to align the data, that is, adjust the size of k. The adjustment process requires comparison operations, and the encrypted data has certain difficulties in comparison operations. Therefore, k is not encrypted, only f is encrypted and c is adjusted. f =1, d will change when performing division calculation, d = 10 when encrypting m s , c d =0.
[0069] During encryption, the plaintext and ciphertext states of f and d are marked. The encryption process is as follows:
[0070] Determine whether f is positive or negative. If it is negative, then f = p1-f; where p1 is a parameter in the homomorphic key. For details, refer to the homomorphic encryption algorithm, which is an existing encryption algorithm and is not limited in this application; the ciphertext identifier c of f after normal encryption of f f =1 means f is ciphertext; the denominator d defaults to 10 s , d's ciphertext identifier c d =0 means d is plain text, and the final ciphertext code (k,f,d,c f ,c d ).
[0071] In the embodiment of the present invention, the decrypted data (k, f, d, c f ,c d ), The process is described as follows:
[0072] According to c f ,c d Determine whether f and d are ciphertexts. If they are ciphertexts, decrypt them, so as to calculate The plain text result can be obtained.
[0073] After obtaining the encoding form of the target message, four arithmetic operations are performed according to the encoding form of the target message;
[0074] In the embodiment of the present invention, (k, f, d, c f ,c d ) How to perform arithmetic operations on data in coded form? Take m1 and m2 as examples. The four arithmetic operators (+, -, ×, ÷) are used to calculate m3. The encoding of m1 is (k1, f1, d1, c f1 ,c d1 ); the encoding of m2 is (k2,f2,d2,c f2 ,c d2 ); the code of m3 is (k3,f3,d3,c f3 ,c d3 ).
[0075] Addition operation: Let m3 = m1 + m2, that is:
[0076] In the embodiment of the present invention, the above formula is converted into In the form of, the encoding of m3 is obtained. In plain text, the method of aligning the order is to align the small order with the large order. When aligning the order, the mantissa is shifted right and the high bit is retained to ensure accuracy. In the encrypted state calculation, since the calculation corresponding to the left shift is divided by 2, the ciphertext calculation does not support it. Therefore, the method of aligning with the small order is adopted in the encrypted state calculation. The embodiment of the present invention processes the addition calculation according to the size of k1 and k2:
[0077] When k1=k2=k, we can get:
[0078]
[0079] Right now:
[0080]
[0081] We can get:
[0082] k3=k, f3=f1d2+f2d1, d3=d1d2
[0083] Calculate c f3 The method is: c f1 ,c d1 ,c f2 ,c d2 As long as one of them is 1, then c f3 =1, otherwise c f3 =0.
[0084] Calculate c d3 The method is: c d1 ,c d2 As long as one of them is 1, then c d3 =1, otherwise c d3 =0.
[0085] When k1>k2, we can get the following order by taking k2:
[0086]
[0087] Right now:
[0088]
[0089] We can get:
[0090]
[0091] Calculate c f3 The method is: c f1 ,c d1 ,c f2 ,c d2 As long as one of them is 1, then c f3 =1, otherwise c f3 =0.
[0092] Calculate c d3 The method is: c d1 ,c d2 As long as one of them is 1, then c d3 =1, otherwise c d3 =0.
[0093] When k1 < k2, aligning to k1 gives:
[0094]
[0095] That is:
[0096]
[0097] It can be obtained that:
[0098]
[0099] The method for calculating c f3 is: among c f1 , c d1 , c f2 , c d2 , as long as one of them is 1, then c f3 = 1, otherwise c f3 = 0.
[0100] The method for calculating c d3 is: among c d1 , c d2 , as long as one of them is 1, then c d3 = 1, otherwise c d3 = 0.
[0101] In the embodiment of the present invention, specific numerical examples are further given. Let Then:
[0102]
[0103] Subtraction operation: Let m3 = m1 - m2; that is:
[0104]
[0105] Convert the above formula into the form of to obtain the encoding of m3. Similarly to addition, handle the subtraction calculation according to the magnitude relationship between k1 and k2.
[0106] When k1 = k2 = k, it can be obtained that:
[0107]
[0108] That is:
[0109]
[0110] It can be obtained that:
[0111] k3 = k, f3 = f1d2 - f2d1, d3 = d1d2
[0112] The method for calculating c f3The method is: c f1 , c d1 , c f2 , c d2 If any one of them is 1, then c f3 = 1, otherwise c f3 = 0.
[0113] The method for calculating c d3 is: c d1 , c d2 If any one of them is 1, then c d3 = 1, otherwise c d3 = 0.
[0114] When k1 > k2, the alignment with k2 gives:
[0115]
[0116] That is:
[0117]
[0118] It can be obtained that
[0119] The method for calculating c f3 is: c f1 , c d1 , c f2 , c d2 If any one of them is 1, then c f3 = 1, otherwise c f3 = 0.
[0120] The method for calculating c d3 is: c d1 , c d2 If any one of them is 1, then c d3 = 1, otherwise c d3 = 0.
[0121] When k1 < k2, the alignment with k1 gives:
[0122]
[0123] That is:
[0124]
[0125] It can be obtained that:
[0126]
[0127] The method for calculating c f3 is: c f1 , c d1 , c f2,c d2 As long as one of them is 1, then c f3 =1, otherwise c f3 =0.
[0128] Calculate c d3 The method is: c d1 ,c d2 As long as one of them is 1, then c d3 =1, otherwise c d3 =0.
[0129] In the actual calculation process of subtraction, the embodiment of the present invention converts the form of the complement of the subtrahend into an addition operation by publicizing the parameter modulo pp, which is expressed as:
[0130] u3=u1-u2
[0131] u 2补 =pp-u2
[0132] u3=u1+u 2补
[0133] Specific numerical examples are further given in the embodiments of the present invention:
[0134]
[0135] Multiplication operation: Let m3 = m1 × m2, and we get:
[0136]
[0137] Right now:
[0138]
[0139] We can get:
[0140] k3=k1+k2, f3=f1f2, d3=d1d2
[0141] Calculate c f3 The method is: c f1 ,c f2 As long as one of them is 1, then c f3 =1, otherwise c f3 =0.
[0142] Calculate c d3 The method is: c d1 ,c d2 As long as one of them is 1, then c d3 =1, otherwise c d3 =0.
[0143] The specific numerical examples of multiplication operations given in the embodiments of the present invention are:
[0144]
[0145] Division operation: Let m3 = m1 ÷ m2, and we get:
[0146]
[0147] Right now:
[0148]
[0149] We can get:
[0150] k3=k1-k2, f3=f1d2, d3=d1f2
[0151] Calculate c f3 The method is: c f1 ,c d2 As long as one of them is 1, then c f3 =1, otherwise c f3 =0.
[0152] Calculate c d3 The method is: c d1 ,c f2 As long as one of them is 1, then c f3 =1, otherwise c f3 =0.
[0153] The specific numerical examples of the division operation given in the embodiment of the present invention are as follows:
[0154]
[0155] In another specific embodiment of the present invention, the encoding method proposed by the present invention can also be applied to approximate value calculation, taking logarithmic calculation as an example:
[0156] Known Calculate log a m:
[0157]
[0158] Transformed to:
[0159]
[0160]
[0161] because make have:
[0162]
[0163] because Closer to 1, we have:
[0164]
[0165] for Using Taylor's formula, this is expanded:
[0166] make but:
[0167]
[0168] Will Substituting into the above formula, we can get Continue to substitute We can get ln m
[0169]
[0170] The embodiment of the present invention further provides a specific numerical example of logarithmic operation:
[0171]
[0172] In this way, the logarithmic operation of floating-point numbers can be completed based on the homomorphic encryption scheme of the integer range. At the same time, the approximate value operations it supports also include: e to the power of x, trigonometric functions, etc.
[0173] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A homomorphic ciphertext encoding method supporting floating-point operations, characterized in that: include: Get target message data; The target message data is converted into a coded form by setting a binary group; the binary group includes a first code segment and a second code segment, and the second code segment is a floating point number; the specific steps are: Representing the target data as a product of an exponential power of 2 and the second code segment, wherein the first code segment is an exponential; acquiring a first rounding parameter according to the order of the second code segment, where the first rounding parameter is used to convert the second code segment into an integer form; Performing homomorphic encryption on the second code segment and the first rounding parameter respectively to obtain a first encryption state value corresponding to the second code segment and a second encryption state value corresponding to the first rounding parameter; The encoding form of the target message is obtained according to the first sub-code, the second sub-code, the first rounding parameter, the first encryption state value and the second encryption state value.
2. The homomorphic ciphertext encoding method supporting floating-point operations according to claim 1, characterized in that: Representing the target data as a product of an exponential power of 2 and the second code segment, wherein the first code segment is an exponential, comprises: Assume the target message data is m, and the tuple is (k, f), where the first code is k and the second code is f; After finding the absolute value of the target message data m, set m = 2 k f, the first and second sub-codes are obtained as: r=log2|m| f=2 r-k in, Indicates rounding down; f∈[1,2).
3. The homomorphic ciphertext encoding method supporting floating-point operations according to claim 2, characterized in that: Acquiring a first rounding parameter according to the order of the second code segment, where the first rounding parameter is used to convert the second code segment into an integer form, includes: Assuming the order of the second code segment is s, the first rounding parameter is: d = 10 s ; The second code is converted into an integer form according to the first rounding parameter, that is, f=f×10 s ; Set m=2 k f is converted to 4. The homomorphic ciphertext encoding method supporting floating-point operations according to claim 1, characterized in that: The encoding form of the target message is expressed as: (k,f,d,c f ,c d ) Among them, k is the first code, f is the second code, d is the first rounding parameter, c is f is the first encryption state value, c d is the second encryption state value.
5. The homomorphic ciphertext encoding method supporting floating-point operations according to claim 1, characterized in that: The first encryption state value and the second encryption state value include: The first encryption state value and the second encryption state value are 0 or 1; When the value is 0, it means that the corresponding second code segment or first rounding parameter is not encrypted; When the value is 1, it indicates that the corresponding second code segment or first rounding parameter is in the ciphertext state.
6. The homomorphic ciphertext encoding method supporting floating-point operations according to claim 1, characterized in that: After obtaining the coding form of the target message, the method further includes: performing four arithmetic operations according to the coding form of the target message.