Data encoding method and device applied to homomorphic encryption system

By encoding and combining the original data in the homomorphic encryption system, target data with homomorphic operation attributes are generated and homomorphic encryption is solved, and the calculation overhead and ciphertext size expansion in homomorphic encryption technology is solved, and encryption efficiency is improved.

CN115765966BActive Publication Date: 2025-02-28DOUYIN VISION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211403579.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-10
Publication Date
2025-02-28
Estimated Expiration
2042-11-10

AI Technical Summary

Technical Problem

Homomorphic encryption technology has problems such as large computing overhead and expansion of ciphertext size, resulting in low encryption efficiency.

Method used

By obtaining multiple sets of original data to be homomorphic, determining their encoding range and scaling ratio, and encoding the original data, combining the target data with homomorphic operation attributes, and finally homomorphic encryption of the target data to generate ciphertext data.

Benefits of technology

It reduces the expansion of encrypted text, improves the efficiency of encryption and decryption, and ensures that data validity is not affected.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115765966B_ABST
    Figure CN115765966B_ABST
Patent Text Reader

Abstract

The present disclosure provides a data encoding method, device, electronic device and storage medium applied to a homomorphic encryption system, wherein the method comprises: obtaining multiple groups of original data to be subjected to homomorphic operation, and determining, for each group of the original data, the encoding range and scaling ratio corresponding to the original data; encoding the original data based on the encoding range and scaling ratio corresponding to the original data to obtain encoded data corresponding to the original data; the value of the encoded data is less than or equal to the maximum value of the encoding range; for the encoded data corresponding to each group of the original data, merging the encoded data corresponding to the group of original data to obtain target data corresponding to the group of original data; the target data supports homomorphic operation properties; homomorphically encrypting the target data corresponding to each of the multiple groups of original data to obtain ciphertext data, and the ciphertext data is used to perform homomorphic operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a data encoding method and device applied to a homomorphic encryption system. Background Art

[0002] Homomorphic encryption is a privacy-preserving data processing technology that supports arithmetic operations on data in the form of ciphertext without leaking the original data. The homomorphic encrypted data is processed to obtain an output, which is then decrypted. The result is the same as the output obtained by processing the unencrypted original data in the same way.

[0003] However, current homomorphic encryption technology has problems such as high computational overhead and ciphertext size expansion, resulting in low encryption efficiency. Summary of the invention

[0004] The embodiments of the present disclosure at least provide a data encoding method, device and system applied to a homomorphic encryption system.

[0005] In a first aspect, an embodiment of the present disclosure provides a data encoding method applied to a homomorphic encryption system, comprising:

[0006] Acquire multiple groups of original data to be homomorphically operated, and determine, for each group of the original data, a coding range and a scaling ratio corresponding to the original data; the coding range matches an input data range corresponding to the original data and an expected output data range after the coding process, and the scaling ratio matches an encryption parameter used in homomorphic encryption;

[0007] Based on the coding range and the scaling ratio corresponding to the original data, the original data is coded to obtain coded data corresponding to the original data; the value of the coded data is less than or equal to the maximum value of the coding range;

[0008] For each group of encoded data corresponding to the original data, the encoded data corresponding to the group of original data are merged to obtain target data corresponding to the group of original data; the target data supports homomorphic operation properties;

[0009] Homomorphic encryption is performed on the target data corresponding to each of the multiple groups of original data to obtain ciphertext data, and the ciphertext data is used to perform homomorphic operations.

[0010] In an optional implementation manner, determining the encoding range and scaling ratio corresponding to the original data includes:

[0011] Determining the encoding range based on a maximum value of an input data range corresponding to the original data and an expected output data range of the encoding process; and

[0012] The scaling ratio is determined based on a minimum encryption parameter used in the homomorphic encryption.

[0013] In an optional implementation manner, encoding the original data based on the encoding range and scaling ratio corresponding to the original data to obtain the encoded data corresponding to the original data includes:

[0014] Determine a scaling reference value based on the original data and a minimum value of the encoding range;

[0015] Determining a scaling weight based on the scaling ratio and a maximum value of the encoding range;

[0016] Determining an initial scaling value based on the scaling weight and the scaling reference value;

[0017] Based on the scaling factor, determining a correction value;

[0018] The encoded data corresponding to the original data is determined based on the initial scaling value, the correction value, and an encryption parameter of the original data used in the homomorphic encryption.

[0019] In an optional implementation manner, the step of performing homomorphic encryption on the target data corresponding to each of the multiple groups of original data to obtain ciphertext data includes:

[0020] Performing polynomial transformation on the target data corresponding to the multiple groups of original data respectively to obtain plaintext polynomials corresponding to the multiple groups of original data;

[0021] Performing homomorphic encryption on the plaintext polynomial to obtain ciphertext polynomials corresponding to the multiple groups of original data;

[0022] The ciphertext polynomials corresponding to the multiple groups of original data are used as the ciphertext data corresponding to the multiple groups of original data.

[0023] In an optional implementation manner, the method further includes:

[0024] Sending the ciphertext data to a data processing end so that the data processing end performs a preset calculation on the ciphertext data to obtain a ciphertext calculation result corresponding to the ciphertext data;

[0025] The ciphertext calculation result fed back by the data processing end is decrypted to obtain a target calculation result of performing the preset calculation on the multiple groups of original data.

[0026] In an optional implementation manner, decrypting the ciphertext calculation result fed back by the data processing end to obtain a target calculation result of performing the preset calculation on the multiple groups of original data includes:

[0027] Performing homomorphic decryption on the ciphertext calculation result to obtain a plaintext calculation result corresponding to the ciphertext calculation result;

[0028] Based on the encoding range and the scaling ratio, the plaintext calculation result is restored to obtain a target calculation result of performing the preset calculation on the multiple groups of original data.

[0029] In an optional implementation, the plaintext calculation result is restored based on the encoding range and the scaling ratio to obtain a target calculation result of performing the preset calculation on the multiple groups of original data, including:

[0030] For each piece of data to be processed in the plaintext calculation result, respectively perform a modulo operation on the data to be processed and each encryption parameter used in the homomorphic encryption to obtain an initial restoration result corresponding to the data to be processed;

[0031] Determine a target restoration result corresponding to each initial restoration result based on a value range corresponding to each initial restoration result and an encryption parameter corresponding to the initial restoration result;

[0032] Each target restoration result is used as a target calculation result of performing the preset calculation on the multiple groups of original data.

[0033] In a second aspect, the present disclosure also provides a data encoding device applied to a homomorphic encryption system, including:

[0034] An acquisition module, used to acquire multiple groups of original data to be homomorphically operated, and for each group of the original data, determine a coding range and a scaling ratio corresponding to the original data; the coding range matches an input data range corresponding to the original data and an expected output data range after encoding processing, and the scaling ratio matches an encryption parameter used in homomorphic encryption;

[0035] A scaling module, configured to encode the original data based on the encoding range and scaling ratio corresponding to the original data to obtain encoded data corresponding to the original data; the value of the encoded data is less than or equal to the maximum value of the encoding range;

[0036] A merging module, for merging the coded data corresponding to each group of the original data to obtain target data corresponding to the group of original data; the target data supports homomorphic operation properties;

[0037] The encryption module is used to perform homomorphic encryption on the target data corresponding to each of the multiple groups of original data to obtain ciphertext data, and the ciphertext data is used to perform homomorphic operations.

[0038] In an optional implementation manner, when determining the encoding range and scaling ratio corresponding to each of the original data, the acquisition module is used to:

[0039] Determining the encoding range based on a maximum value of an input data range corresponding to the original data and an expected output data range of the encoding process; and

[0040] The scaling ratio is determined based on a minimum encryption parameter used in the homomorphic encryption.

[0041] In an optional implementation manner, the scaling module is specifically used for:

[0042] Determine a scaling reference value based on the original data and a minimum value of the encoding range;

[0043] Determining a scaling weight based on the scaling ratio and a maximum value of the encoding range;

[0044] Determining an initial scaling value based on the scaling weight and the scaling reference value;

[0045] Based on the scaling factor, determining a correction value;

[0046] The encoded data corresponding to the original data is determined based on the initial scaling value, the correction value, and an encryption parameter of the original data used in the homomorphic encryption.

[0047] In an optional implementation manner, the encryption module is specifically used for:

[0048] Performing polynomial transformation on the target data corresponding to the multiple groups of original data respectively to obtain plaintext polynomials corresponding to the multiple groups of original data;

[0049] Performing homomorphic encryption on the plaintext polynomial to obtain ciphertext polynomials corresponding to the multiple groups of original data;

[0050] The ciphertext polynomials corresponding to the multiple groups of original data are used as the ciphertext data corresponding to the multiple groups of original data.

[0051] In an optional implementation manner, the device further includes a decryption module, configured to:

[0052] Sending the ciphertext data to a data processing end so that the data processing end performs a preset calculation on the ciphertext data to obtain a ciphertext calculation result corresponding to the ciphertext data;

[0053] The ciphertext calculation result fed back by the data processing end is decrypted to obtain a target calculation result of performing the preset calculation on the multiple groups of original data.

[0054] In an optional implementation manner, when the decryption module decrypts the ciphertext calculation result fed back by the data processing end to obtain the target calculation result of performing the preset calculation on the multiple groups of original data, it includes:

[0055] Performing homomorphic decryption on the ciphertext calculation result to obtain a plaintext calculation result corresponding to the ciphertext calculation result;

[0056] Based on the encoding range and the scaling ratio, the plaintext calculation result is restored to obtain a target calculation result of performing the preset calculation on the multiple groups of original data.

[0057] In an optional implementation manner, when the decryption module restores the plaintext calculation result based on the encoding range and the scaling ratio to obtain the target calculation result of performing the preset calculation on the multiple groups of original data, it is used to:

[0058] For each piece of data to be processed in the plaintext calculation result, respectively perform a modulo operation on the data to be processed and each encryption parameter used in the homomorphic encryption to obtain an initial restoration result corresponding to the data to be processed;

[0059] Determine a target restoration result corresponding to each initial restoration result based on a value range corresponding to each initial restoration result and an encryption parameter corresponding to the initial restoration result;

[0060] Each target restoration result is used as a target calculation result of performing the preset calculation on the multiple groups of original data.

[0061] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are performed.

[0062] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned first aspect or any possible implementation of the first aspect are executed.

[0063] The data encoding method, device, electronic device and storage medium provided in the embodiments of the present disclosure for application in a homomorphic encryption system use a coding range and a scaling ratio to scale the original data to obtain encoded data, then merge the encoded data to obtain target data with homomorphic operation properties, and finally homomorphically encrypt the target data to obtain ciphertext data corresponding to the original data, so that a group of ciphertext data can contain more original data, reducing the expansion of the encrypted text, thereby improving the encryption efficiency while ensuring that the validity of the data is not affected, and correspondingly, the decryption efficiency will also be improved simultaneously.

[0064] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.

[0066] Figure 1 A flow chart of a data encoding method applied to a homomorphic encryption system provided by an embodiment of the present disclosure is shown;

[0067] Figure 2 A flowchart of another data encoding method applied to a homomorphic encryption system provided by an embodiment of the present disclosure is shown;

[0068] Figure 3 A schematic diagram of a data encoding device applied to a homomorphic encryption system provided by an embodiment of the present disclosure is shown;

[0069] Figure 4 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0070] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0071] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0072] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.

[0073] Homomorphic encryption is a privacy-preserving data processing technology. The ciphertext obtained after homomorphic encryption of data can be subjected to homomorphic calculations. The calculation result obtained after decryption is consistent with the result of the same calculation on the original data. This feature can effectively protect data security. For example, when the data provider needs to send data to the data processor for calculation, the data provider can first homomorphically encrypt the data. The data processing method uses the encrypted data for calculation and returns it to the data provider. The data provider only needs to decrypt the returned data to obtain the result of the data before encryption after the data processor calculates it, and the original data is not leaked to the data calculator. However, the homomorphic encryption method usually requires a large computational overhead. Due to the characteristics of homomorphic encryption, the size of the ciphertext obtained after encryption will also expand a lot, occupying more storage space, and more computing resources are required for its calculation.

[0074] Based on the above research, the present disclosure provides a data encoding method applied to a homomorphic encryption system, which uses a coding range and a scaling ratio to scale the original data to obtain encoded data, and then merges the encoded data to obtain target data with homomorphic operation properties. Finally, the target data is homomorphically encrypted to obtain ciphertext data corresponding to the original data, so that a set of ciphertext data can contain more original data, reduce the expansion of the encrypted text, and improve the efficiency of encryption and decryption.

[0075] To facilitate understanding of this embodiment, a data encoding method for a homomorphic encryption system disclosed in an embodiment of the present disclosure is first introduced in detail. The execution subject of the data encoding method for a homomorphic encryption system provided in an embodiment of the present disclosure is generally a computer device with certain computing capabilities. In some possible implementations, the data encoding method for a homomorphic encryption system can be implemented by a processor calling a computer-readable instruction stored in a memory.

[0076] See also Figure 1 As shown, it is a flowchart of a data encoding method applied to a homomorphic encryption system provided by an embodiment of the present disclosure, the method includes steps S101 to S104, wherein:

[0077] S101. Obtain multiple groups of original data to be subjected to homomorphic operations, and for each group of the original data, determine the encoding range and scaling ratio corresponding to the original data; the encoding range matches the input data range corresponding to the original data and the expected output data range after encoding processing, and the scaling ratio matches the encryption parameters used in homomorphic encryption.

[0078] In this step, the data to be encrypted can be obtained first, and the data to be encrypted can be grouped to obtain multiple groups of original data. Each group of original data can contain multiple bytes, and one byte can be regarded as one original data. After obtaining multiple groups of original data, the encoding range and scaling ratio corresponding to each original data can be determined, wherein the encoding range refers to the range of the original data after scaling, and the scaling ratio can be the weight for scaling the original data, which can be a ratio. The encoding range matches the input data range corresponding to the original data and the expected output data range after encoding processing, and the scaling ratio matches the encryption parameters used in homomorphic encryption.

[0079] Exemplarily, for each original data, the encoding range can be determined based on the maximum value of the input data range corresponding to the original data and the expected output data range of the encoding processing; the sum of the maximum value of the encoding range and the minimum value of the encoding range is equal to 0; and the scaling ratio is determined based on the minimum encryption parameter used in homomorphic encryption.

[0080] The raw data may be normalized in advance so that the input data range of the raw data is within a fixed interval, such as [-1,1]. The encoding ranges of the raw data in the same group may be the same or different. Setting different encoding ranges for different raw data can make the encoding process more accurate.

[0081] In actual application scenarios, the number of bytes in each set of original data may be m, and m mutually prime integers {p1, p2, …p m}, as the encryption parameter used in homomorphic encryption, and set the plaintext modulus of homomorphic encryption to p = ∏ i∈{1,…,m} p i , for each p i , you can take a floating point number (i.e. real number) x i Encode to a preset encoding range and a scaling factor (i.e., encoded to {0,1,…,p i -1}), where x i For the original data that needs to be scaled, you can set the encoding range to [-z i ,z i ], with a scaling factor of Δ i .

[0082] Among them, when the device is encoded, the range of the original data and the final result needs to be the same as the encoding range. For example, when the input data range is [-a i ,a i ], the expected output data range of the encoding process is [-b i ,b i ], you can set z i =max(a i ,b i ).

[0083] When setting the zoom ratio Δ i When Δ i <p i , for example, it can be set for all p i All choose the same scaling ratio Δ1=…=Δ m =min(p1, ..., p m )-1, so that the cost of subsequent modulus calculation can be saved when encoding multiple identical original data.

[0084] S102. Based on the coding range and scaling ratio corresponding to the original data, encode the original data to obtain coded data corresponding to the original data; the value of the coded data is less than or equal to the maximum value of the coding range.

[0085] In this step, for any original data in each group, the original data can be encoded using its corresponding encoding range, i.e., the scaling ratio, to obtain the encoded data corresponding to the original data. Specifically, the scaling reference value can be determined based on the original data and the minimum value of the encoding range, and then the scaling weight can be determined based on the scaling ratio and the maximum value of the encoding range. Then, the initial scaling value can be determined based on the scaling weight and the scaling reference value, and then the encoded data corresponding to the original data can be determined based on the initial scaling value, the correction value, and the encryption parameters used by the original data in the homomorphic encryption.

[0086] Exemplarily, the original data may be encoded based on the following formula:

[0087]

[0088] Among them, mod p i Indicates the use of p i As a modulus, the modulus operation is performed and the output is {0,1,…,p i -1}, p i This is the encryption parameter mentioned above. That is, the encoded data obtained after the encoding process is obtained by subtracting the original data and the minimum value of the encoding range to obtain the scaling reference value (x i -(-z i ))=(x i +z i ), then determine the scaling ratio and double the maximum value of the encoding range to get the scaling weight Then multiply the scaling weight and the scaling reference value to get the initial scaling value Then use the scale factor divided by 2 as the correction value Finally, the initial scaling value is subtracted from the correction value and a modulo operation is performed to obtain the encoded data.

[0089] S103. For each group of the encoded data corresponding to the original data, the encoded data corresponding to the group of original data are merged to obtain target data corresponding to the group of original data; the target data supports homomorphic operation properties.

[0090] Through the above encoding process, the original data is transformed into integers that meet the requirements of the Chinese remainder theorem. After that, the Chinese remainder theorem can be used to merge the groups of original data. The Chinese remainder theorem is also called the Chinese remainder theorem or the Sun Tzu theorem, which is used to solve the problem of congruence equations. pi The data in {x i |1≤i≤m} into a large integer domain Z p Integer X in the domain of large integers Z pThe addition and multiplication operations performed in the decimal field Z are equivalent to pi The data of Z are added and multiplied respectively, which conforms to the characteristics of homomorphic operation. p After homomorphic encryption, homomorphic operation is performed, which is equivalent to Z pi Perform homomorphic operations on each data in.

[0091] The above Z pi With Z p Together they form a remainder number system consisting of a certain number of mutually prime moduli {x i |1≤i≤m}, and corresponds to a larger modulus p=∏ i∈{1,…,m} p i , by two operations, forward and reverse, where the forward operation is Z p Integers X in the range can be converted to the decimal domain by modulo operation The data in x i =X mod p i , and the inverse operation is the above operation through the Chinese remainder theorem.

[0092] Among them, the target data obtained by the operation of the Chinese remainder theorem supports the homomorphic operation property, that is, the result obtained by the operation of the transformed data, after inverse transformation, is consistent with the result of the same operation on the data before transformation.

[0093] In this way, each raw data in a set of raw data is encoded as an integer, reducing the amount of data required for input for homomorphic encryption and facilitating subsequent homomorphic encryption.

[0094] S104. Perform homomorphic encryption on the target data corresponding to each of the multiple groups of original data to obtain ciphertext data, and the ciphertext data is used for performing homomorphic operations.

[0095] In this step, the obtained multiple target data can be homomorphically encrypted. Exemplarily, the homomorphic encryption method can use a modular encryption system, such as the BGV cryptographic system, to identify the plaintext and the ciphertext as N-order polynomials, the plaintext polynomial coefficients are modulo p, and the ciphertext polynomial is modulo another modulus q. Usually, q>>p. An n-order plaintext / ciphertext polynomial can encode n integer data and support homomorphic operations such as addition, multiplication, and step size transformation. Since the embodiment of the present disclosure has pre-encoded multiple original data into one target data, the actual encrypted data amount in the homomorphic encryption result of the target data is m*n, and the encrypted ciphertext data amount of the same amount of original data is less.

[0096] Exemplarily, polynomial transformation can be performed on the target data corresponding to multiple groups of original data respectively, and the encryption rules of homomorphic encryption can be used to obtain plaintext polynomials corresponding to the multiple groups of original data, wherein one plaintext polynomial can correspond to multiple groups of original data, and according to the rules of polynomial transformation, one or more plaintext polynomials can be obtained. Then, the plaintext polynomials are homomorphically encrypted according to the encryption rules to obtain ciphertext polynomials corresponding to the multiple groups of original data. Finally, the ciphertext polynomials corresponding to the original data can be used as ciphertext data corresponding to the multiple groups of original data.

[0097] After obtaining the ciphertext data, the ciphertext data can be used. For example, the ciphertext data can be sent to the data processing end, and the data processing end performs preset calculations using preset calculation rules or neural network models to obtain ciphertext calculation results corresponding to the ciphertext data. Then, by decrypting the ciphertext calculation results fed back by the data processing end, the target calculation results of the preset calculations on multiple groups of original data can be obtained, which is equivalent to directly performing the above-mentioned preset calculations on the original data.

[0098] Similar to the encryption process, the decryption process of the ciphertext calculation result requires the inverse operation of the encoding process on the data. For example, the decryption method corresponding to the homomorphic encryption can be used to perform homomorphic decryption on the ciphertext calculation result to obtain the plaintext calculation result corresponding to the ciphertext calculation result. Then, the plaintext calculation result can be restored using the encoding range, that is, the scaling ratio, to obtain the target calculation result.

[0099] For the homomorphic decryption process, the inverse operation of encryption can be performed first to obtain the plaintext polynomial, and then decrypted to obtain the corresponding data to be processed in the plaintext polynomial.

[0100] Furthermore, for each data to be processed in the plaintext calculation result, a modulo operation can be performed on the data to be processed and each encryption parameter used in homomorphic encryption to obtain an initial restoration result corresponding to the data to be processed; then, based on the value range corresponding to each initial restoration result and the encryption parameter corresponding to the initial restoration result, the target restoration result corresponding to the initial restoration result is determined; finally, each target restoration result is used as a target calculation result for a preset calculation of multiple groups of original data.

[0101] Exemplarily, a modulo operation may be performed on the plain text calculation result according to the following formula:

[0102]

[0103] Among them, Y is the data to be processed in the plain text calculation result, p i is the modulus on the decimal field corresponding to the above Y, that is, the encryption parameter, and the forward calculation of the residual number system is used to obtain each That is, the calculation result before encoding processing.

[0104] After that, you can pass the above encoding range [-z i ,z i ] and the scaling factor is Δ i , use the following formula to restore the calculation result and get the target calculation result y i :

[0105]

[0106] The data encoding method, device, electronic device and storage medium provided in the embodiments of the present disclosure for application in a homomorphic encryption system use a coding range and a scaling ratio to scale the original data to obtain encoded data, then merge the encoded data to obtain target data that can be homomorphically operated, and finally homomorphically encrypt the target data to obtain ciphertext data corresponding to the original data, so that a group of ciphertext data can contain more original data, reducing the expansion of the encrypted text, thereby improving the encryption efficiency while ensuring that the validity of the data is not affected. Correspondingly, the decryption efficiency will also be improved simultaneously.

[0107] See also Figure 2 FIG. 1 is a flowchart of another data encoding method applied to a homomorphic encryption system provided by an embodiment of the present disclosure. The method first determines the original data x i The corresponding encoding range [-z i ,z i ] and the scaling factor is Δ i , and use the encryption parameter p i Encoding processing to obtain encoded data Then use the Chinese remainder theorem to merge and get the target integer X k Then, the integer X is encoded by homomorphic encryption. k Encode into the plaintext polynomial and encrypt to obtain the ciphertext polynomial. In a homomorphic encryption system, a plaintext polynomial can encode n integers, and in the ciphertext polynomial, there are n data slots {slot 1,…,slot n} corresponding to the n encoded integers {X1,…,X n In this way, a set of original data is encoded into a target data, multiple target data are merged into a plaintext polynomial, and multiple plaintext polynomials are encrypted into multiple ciphertext polynomials. Compared with other encryption methods, the same ciphertext polynomial in the embodiment of the present disclosure can contain more original data.

[0108] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0109] Based on the same inventive concept, the embodiments of the present disclosure also provide a data encoding device applied to a homomorphic encryption system corresponding to the data encoding method applied to the homomorphic encryption system. Since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to the data encoding method applied to the homomorphic encryption system in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0110] Reference Figure 3 FIG. 1 is a schematic diagram of a data encoding device applied to a homomorphic encryption system provided by an embodiment of the present disclosure, wherein the device comprises:

[0111] An acquisition module 310 is used to acquire multiple groups of original data to be homomorphically operated, and for each group of the original data, determine a coding range and a scaling ratio corresponding to the original data; the coding range matches an input data range corresponding to the original data and an expected output data range after encoding processing, and the scaling ratio matches an encryption parameter used in homomorphic encryption;

[0112] The scaling module 320 is used to encode the original data based on the coding range and scaling ratio corresponding to the original data to obtain coded data corresponding to the original data; the value of the coded data is less than or equal to the maximum value of the coding range;

[0113] A merging module 330 is used to merge the coded data corresponding to each group of the original data to obtain target data corresponding to the group of original data; the target data supports homomorphic operation properties;

[0114] The encryption module 340 is used to perform homomorphic encryption on the target data corresponding to each of the multiple groups of original data to obtain ciphertext data, and the ciphertext data is used to perform homomorphic operations.

[0115] In an optional implementation manner, when determining the encoding range and scaling ratio corresponding to each of the original data, the acquisition module 310 is used to:

[0116] Determining the encoding range based on a maximum value of an input data range corresponding to the original data and an expected output data range of the encoding process; and

[0117] The scaling ratio is determined based on a minimum encryption parameter used in the homomorphic encryption.

[0118] In an optional implementation manner, the scaling module 320 is specifically configured to:

[0119] Determine a scaling reference value based on the original data and a minimum value of the encoding range;

[0120] Determining a scaling weight based on the scaling ratio and a maximum value of the encoding range;

[0121] Determining an initial scaling value based on the scaling weight and the scaling reference value;

[0122] Based on the scaling factor, determining a correction value;

[0123] The encoded data corresponding to the original data is determined based on the initial scaling value, the correction value, and an encryption parameter of the original data used in the homomorphic encryption.

[0124] In an optional implementation manner, the encryption module 340 is specifically used for:

[0125] Performing polynomial transformation on the target data corresponding to the multiple groups of original data respectively to obtain plaintext polynomials corresponding to the multiple groups of original data;

[0126] Performing homomorphic encryption on the plaintext polynomial to obtain ciphertext polynomials corresponding to the multiple groups of original data;

[0127] The ciphertext polynomials corresponding to the multiple groups of original data are used as the ciphertext data corresponding to the multiple groups of original data.

[0128] In an optional implementation manner, the device further includes a decryption module 350, configured to:

[0129] Sending the ciphertext data to a data processing end so that the data processing end performs a preset calculation on the ciphertext data to obtain a ciphertext calculation result corresponding to the ciphertext data;

[0130] The ciphertext calculation result fed back by the data processing end is decrypted to obtain a target calculation result of performing the preset calculation on the multiple groups of original data.

[0131] In an optional implementation manner, when the decryption module 350 decrypts the ciphertext calculation result fed back by the data processing end to obtain the target calculation result of performing the preset calculation on the multiple groups of original data, it includes:

[0132] Performing homomorphic decryption on the ciphertext calculation result to obtain a plaintext calculation result corresponding to the ciphertext calculation result;

[0133] Based on the encoding range and the scaling ratio, the plaintext calculation result is restored to obtain a target calculation result of performing the preset calculation on the multiple groups of original data.

[0134] In an optional implementation, when the decryption module 350 restores the plaintext calculation result based on the encoding range and the scaling ratio to obtain the target calculation result of performing the preset calculation on the multiple groups of original data, it is used to:

[0135] For each piece of data to be processed in the plaintext calculation result, respectively perform a modulo operation on the data to be processed and each encryption parameter used in the homomorphic encryption to obtain an initial restoration result corresponding to the data to be processed;

[0136] Determine a target restoration result corresponding to each initial restoration result based on a value range corresponding to each initial restoration result and an encryption parameter corresponding to the initial restoration result;

[0137] Each target restoration result is used as a target calculation result of performing the preset calculation on the multiple groups of original data.

[0138] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0139] Corresponds to Figure 1 The data encoding method applied to the homomorphic encryption system in the present disclosure embodiment also provides an electronic device 400, such as Figure 4 FIG. 4 is a schematic diagram of the structure of an electronic device 400 provided in an embodiment of the present disclosure, including:

[0140] Processor 41, memory 42, and bus 43; memory 42 is used to store execution instructions, including internal memory 421 and external memory 422; the internal memory 421 is also called internal memory, which is used to temporarily store the operation data in the processor 41 and the data exchanged with the external memory 422 such as a hard disk. The processor 41 exchanges data with the external memory 422 through the internal memory 421. When the electronic device 400 is running, the processor 41 communicates with the memory 42 through the bus 43, so that the processor 41 executes the following instructions:

[0141] Acquire multiple groups of original data to be homomorphically operated, and determine, for each group of the original data, a coding range and a scaling ratio corresponding to the original data; the coding range matches an input data range corresponding to the original data and an expected output data range after the coding process, and the scaling ratio matches an encryption parameter used in homomorphic encryption;

[0142] Based on the coding range and the scaling ratio corresponding to the original data, the original data is coded to obtain coded data corresponding to the original data; the value of the coded data is less than or equal to the maximum value of the coding range;

[0143] For each group of encoded data corresponding to the original data, the encoded data corresponding to the group of original data are merged to obtain target data corresponding to the group of original data; the target data supports homomorphic operation properties;

[0144] Homomorphic encryption is performed on the target data corresponding to each of the multiple groups of original data to obtain ciphertext data, and the ciphertext data is used to perform homomorphic operations.

[0145] In an optional implementation manner, in the instruction executed by the processor 41, determining the encoding range and scaling ratio corresponding to each of the original data includes:

[0146] Determining the encoding range based on a maximum value of an input data range corresponding to the original data and an expected output data range of the encoding process; and

[0147] The scaling ratio is determined based on a minimum encryption parameter used in the homomorphic encryption.

[0148] In an optional implementation manner, in the instructions executed by the processor 41, encoding the original data based on the encoding range and scaling ratio corresponding to the original data to obtain the encoded data corresponding to the original data includes:

[0149] Determine a scaling reference value based on the original data and a minimum value of the encoding range;

[0150] Determining a scaling weight based on the scaling ratio and a maximum value of the encoding range;

[0151] Determining an initial scaling value based on the scaling weight and the scaling reference value;

[0152] Based on the scaling factor, determining a correction value;

[0153] The encoded data corresponding to the original data is determined based on the initial scaling value, the correction value, and an encryption parameter of the original data used in the homomorphic encryption.

[0154] In an optional implementation manner, in the instructions executed by the processor 41, the step of performing homomorphic encryption on the target data corresponding to each of the multiple groups of original data to obtain ciphertext data includes:

[0155] Performing polynomial transformation on the target data corresponding to the multiple groups of original data to obtain plaintext polynomials corresponding to the multiple groups of original data;

[0156] Performing homomorphic encryption on each of the plaintext polynomials to obtain ciphertext polynomials corresponding to the multiple groups of original data;

[0157] The ciphertext polynomial corresponding to the original data is used as the ciphertext data corresponding to the original data.

[0158] In an optional implementation manner, the instructions executed by the processor 41 further include:

[0159] Sending the ciphertext data to a data processing end so that the data processing end performs a preset calculation on the ciphertext data to obtain a ciphertext calculation result corresponding to the ciphertext data;

[0160] The ciphertext calculation result fed back by the data processing end is decrypted to obtain a target calculation result of performing the preset calculation on the multiple groups of original data.

[0161] In an optional implementation manner, in the instructions executed by the processor 41, decrypting the ciphertext calculation result fed back by the data processing end to obtain the target calculation result of performing the preset calculation on the multiple groups of original data includes:

[0162] Performing homomorphic decryption on the ciphertext calculation result to obtain a plaintext calculation result corresponding to the ciphertext calculation result;

[0163] Based on the encoding range and the scaling ratio, the plaintext calculation result is restored to obtain a target calculation result of performing the preset calculation on the multiple groups of original data.

[0164] In an optional implementation manner, in the instructions executed by the processor 41, the plaintext calculation result is restored based on the encoding range and the scaling ratio to obtain a target calculation result of performing the preset calculation on the multiple groups of original data, including:

[0165] For each piece of data to be processed in the plaintext calculation result, respectively perform a modulo operation on the data to be processed and each encryption parameter used in the homomorphic encryption to obtain an initial restoration result corresponding to the data to be processed;

[0166] Determine a target restoration result corresponding to each initial restoration result based on a value range corresponding to each initial restoration result and an encryption parameter corresponding to the initial restoration result;

[0167] Each target restoration result is used as a target calculation result of performing the preset calculation on the multiple groups of original data.

[0168] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the data encoding method applied to the homomorphic encryption system described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.

[0169] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the steps of the data encoding method applied to the homomorphic encryption system described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.

[0170] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0171] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

[0172] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0173] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0174] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0175] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A data encoding method applied to a homomorphic encryption system, characterized in that: include: Acquire multiple groups of original data to be homomorphically operated, and determine, for each group of the original data, a coding range and a scaling ratio corresponding to the original data; the coding range matches an input data range corresponding to the original data and an expected output data range after the coding process, and the scaling ratio matches an encryption parameter used in homomorphic encryption; Based on the coding range and the scaling ratio corresponding to the original data, the original data is coded to obtain coded data corresponding to the original data; the value of the coded data is less than or equal to the maximum value of the coding range; For each set of coded data corresponding to the original data, merging the coded data corresponding to the set of original data to obtain target data corresponding to the set of original data; The target data supports homomorphic operation properties; Homomorphically encrypt the target data corresponding to each of the multiple sets of original data to obtain ciphertext data, where the ciphertext data is used to perform homomorphic operations. Among them, the encoding range matches the input data range corresponding to the original data and the expected output data range after encoding processing, and the scaling ratio matches the encryption parameter used in homomorphic encryption, including: the encoding range is determined based on the maximum value of the input data range corresponding to the original data and the expected output data range of encoding processing; the scaling ratio is determined based on the minimum encryption parameter used in homomorphic encryption.

2. The method according to claim 1, characterized in that The determining of the encoding range and scaling ratio corresponding to the original data includes: Determining the encoding range based on a maximum value of an input data range corresponding to the original data and an expected output data range of the encoding process; and The scaling ratio is determined based on a minimum encryption parameter used in the homomorphic encryption.

3. The method according to claim 1, characterized in that: The encoding process is performed on the original data based on the encoding range and the scaling ratio corresponding to the original data to obtain the encoded data corresponding to the original data, including: Determine a scaling reference value based on the original data and a minimum value of the encoding range; Determining a scaling weight based on the scaling ratio and a maximum value of the encoding range; Determining an initial scaling value based on the scaling weight and the scaling reference value; Based on the scaling factor, determining a correction value; The encoded data corresponding to the original data is determined based on the initial scaling value, the correction value, and an encryption parameter of the original data used in the homomorphic encryption.

4. The method according to claim 1, characterized in that: The step of homomorphically encrypting the target data corresponding to each of the multiple groups of original data to obtain ciphertext data includes: Performing polynomial transformation on the target data corresponding to the multiple groups of original data respectively to obtain plaintext polynomials corresponding to the multiple groups of original data; Performing homomorphic encryption on the plaintext polynomial to obtain ciphertext polynomials corresponding to the multiple groups of original data; The ciphertext polynomials corresponding to the multiple groups of original data are used as the ciphertext data corresponding to the multiple groups of original data.

5. The method according to claim 1, characterized in that The method further comprises: Sending the ciphertext data to a data processing end so that the data processing end performs a preset calculation on the ciphertext data to obtain a ciphertext calculation result corresponding to the ciphertext data; The ciphertext calculation result fed back by the data processing end is decrypted to obtain a target calculation result of performing the preset calculation on the multiple groups of original data.

6. The method according to claim 5, characterized in that The decrypting the ciphertext calculation result fed back by the data processing end to obtain the target calculation result of performing the preset calculation on the multiple groups of original data includes: Performing homomorphic decryption on the ciphertext calculation result to obtain a plaintext calculation result corresponding to the ciphertext calculation result; Based on the encoding range and the scaling ratio, the plaintext calculation result is restored to obtain a target calculation result of performing the preset calculation on the multiple groups of original data.

7. The method according to claim 6, characterized in that The method of restoring the plaintext calculation result based on the encoding range and the scaling ratio to obtain a target calculation result of performing the preset calculation on the multiple groups of original data includes: For each piece of data to be processed in the plaintext calculation result, respectively perform a modulo operation on the data to be processed and each encryption parameter used in the homomorphic encryption to obtain an initial restoration result corresponding to the data to be processed; Determine a target restoration result corresponding to each initial restoration result based on a value range corresponding to each initial restoration result and an encryption parameter corresponding to the initial restoration result; Each target restoration result is used as a target calculation result of performing the preset calculation on the multiple groups of original data.

8. A data encoding device applied to a homomorphic encryption system, characterized in that: include: An acquisition module, used to acquire multiple groups of original data to be homomorphically operated, and for each group of the original data, determine a coding range and a scaling ratio corresponding to the original data; the coding range matches an input data range corresponding to the original data and an expected output data range after encoding processing, and the scaling ratio matches an encryption parameter used in homomorphic encryption; A scaling module, configured to encode the original data based on the encoding range and scaling ratio corresponding to the original data to obtain encoded data corresponding to the original data; the value of the encoded data is less than or equal to the maximum value of the encoding range; A merging module, for merging the coded data corresponding to each group of the original data to obtain target data corresponding to the group of original data; The target data supports homomorphic operation properties; An encryption module is used to perform homomorphic encryption on the target data corresponding to each of the multiple groups of original data to obtain ciphertext data, and the ciphertext data is used to perform homomorphic operations. Among them, the encoding range matches the input data range corresponding to the original data and the expected output data range after encoding processing, and the scaling ratio matches the encryption parameter used in homomorphic encryption, including: the encoding range is determined based on the maximum value of the input data range corresponding to the original data and the expected output data range of encoding processing; the scaling ratio is determined based on the minimum encryption parameter used in homomorphic encryption.

9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the data encoding method applied to a homomorphic encryption system as described in any one of claims 1 to 7 are performed.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the data encoding method applied to a homomorphic encryption system as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Terminal device performing homomorphic encryption, server device processing ciphertext and methods thereof

    US20190363871A1

  • A calculation device for encoded addition

    US20200097256A1