A method and device for calculating ciphertext and a device for calculating ciphertext

By using the properties of logarithmic functions and clear ciphertext calculation operations in machine learning model training, only one ciphertext multiplication and one ciphertext subtraction are required, efficient ciphertext logarithmic calculation is achieved, solving the ciphertext data calculation efficiency Low problem protects data privacy.

CN115085912BActive Publication Date: 2024-11-15HUAKONG TSINGJIAO INFORMATION SCI BEIJING LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210568260.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-24
Publication Date
2024-11-15
Estimated Expiration
2042-05-24

AI Technical Summary

Technical Problem

In machine learning model training, when calculating log loss functions based on ciphertext data, a large number of addition and multiplication operations are required, resulting in low computational efficiency.

Method used

Through a series of clear ciphertext calculation operations, using the properties of the logarithmic function, the logarithm of the target ciphertext array based on ciphertext is calculated based on ciphertext. Only one ciphertext multiplication operation and one ciphertext subtraction operation are required, and the result is Password, and no information about the target ciphertext array is exposed.

Benefits of technology

It improves the efficiency of calculating logarithmic functions based on ciphertext data, thereby improving the training efficiency of machine learning models, and protecting data privacy and security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115085912B_ABST
    Figure CN115085912B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a ciphertext calculation method, device and device for ciphertext calculation. The method includes: generating a first plaintext array whose elements are plaintext random numbers; calculating the logarithm of the first plaintext array with a as the base to obtain a second plaintext array; encrypting the first plaintext array and the second plaintext data to obtain the first ciphertext array and the second ciphertext array; rearranging the first ciphertext array and the second ciphertext array according to a random sequence to obtain a third ciphertext array and a fourth ciphertext array; calculating the product of the third ciphertext array and the target ciphertext array to obtain a fifth ciphertext array, decrypting the fifth ciphertext array to obtain a third plaintext array; calculating the logarithm of the third plaintext array with a as the base to obtain a fourth plaintext array, encrypting the fourth plaintext array to obtain a sixth ciphertext array; calculating the difference between the sixth ciphertext array and the fourth ciphertext array to obtain the logarithm of the target ciphertext array with a as the base. The present invention can improve the efficiency of the ciphertext calculation logarithm function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of multi-party secure computing, and in particular to a ciphertext computing method, device and a device for ciphertext computing. Background Art

[0002] Machine learning is one of the most important breakthroughs in the field of artificial intelligence in the past decade. It has achieved great success in many fields such as speech recognition, natural language processing, computer vision, image and video analysis, and multimedia.

[0003] In the process of training a machine learning model, it is necessary to monitor the training effect of the model in real time. The commonly used monitoring indicator is the loss function. The loss function is a non-negative real-valued function that is used to estimate the degree of inconsistency between the predicted value and the true value of the machine learning model. The smaller the loss function value, the better the robustness of the machine learning model.

[0004] To protect the privacy and security of data, machine learning models can be trained based on ciphertext data. However, if the logarithmic loss function is calculated based on ciphertext data, Taylor expansion is needed to approximate the logarithmic function, converting the logarithmic function calculation based on ciphertext data into dozens of column addition and multiplication operations based on ciphertext data. The large number of addition and multiplication operations on ciphertext data consumes a lot of computing time and communication time, resulting in low training efficiency of machine learning models based on ciphertext data. Summary of the invention

[0005] The embodiments of the present invention provide a ciphertext calculation method, device and device for ciphertext calculation, which can improve the efficiency of calculating logarithmic functions based on ciphertext data, and further improve the efficiency of training machine learning models based on ciphertext data.

[0006] In order to solve the above problem, an embodiment of the present invention discloses a ciphertext calculation method, which is used to calculate the logarithm of a target ciphertext array with a as the base based on the ciphertext, where the elements in the target ciphertext array are ciphertexts, and a is an arbitrary constant. The method includes:

[0007] Generate a first plaintext array, where elements in the first plaintext array are plaintext random numbers;

[0008] Calculate the logarithm of the first plaintext array with base a to obtain a second plaintext array;

[0009] Encrypting the first plaintext array to obtain a first ciphertext array, and encrypting the second plaintext array to obtain a second ciphertext array;

[0010] Rearranging the first ciphertext array according to a random sequence based on the ciphertext to obtain a third ciphertext array, and rearranging the second ciphertext array according to the same random sequence based on the ciphertext to obtain a fourth ciphertext array;

[0011] Calculating the product of the third ciphertext array and the target ciphertext array based on the ciphertext to obtain a fifth ciphertext array, and decrypting the fifth ciphertext array to obtain a third plaintext array;

[0012] Calculate the logarithm of the third plaintext array with base a based on the plaintext to obtain a fourth plaintext array, and encrypt the fourth plaintext array to obtain a sixth ciphertext array;

[0013] The difference between the sixth ciphertext array and the fourth ciphertext array is calculated based on the ciphertext to obtain the logarithm of the target ciphertext array with base a as the ciphertext, and the logarithm of the target ciphertext array with base a as the ciphertext.

[0014] On the other hand, an embodiment of the present invention discloses a ciphertext calculation device, the device is used to calculate the logarithm of a target ciphertext array with a as the base based on the ciphertext, the elements in the target ciphertext array are ciphertexts, and a is an arbitrary constant, the device comprising:

[0015] A first plaintext array generating module, used to generate a first plaintext array, wherein the elements in the first plaintext array are plaintext random numbers;

[0016] A second plaintext array generating module, used for calculating the logarithm of the first plaintext array with base a to obtain a second plaintext array;

[0017] A second ciphertext array generating module, configured to encrypt the first plaintext array to obtain a first ciphertext array, and to encrypt the second plaintext array to obtain a second ciphertext array;

[0018] A third and fourth ciphertext array generation module, configured to rearrange the first ciphertext array according to a random sequence based on the ciphertext to obtain a third ciphertext array; and to rearrange the second ciphertext array according to the same random sequence based on the ciphertext to obtain a fourth ciphertext array;

[0019] a fifth ciphertext array generating module, configured to calculate the product of the third ciphertext array and the target ciphertext array based on the ciphertext to obtain a fifth ciphertext array;

[0020] A third plaintext array generating module, used for decrypting the fifth ciphertext array to obtain a third plaintext array;

[0021] a sixth ciphertext array generating module, configured to calculate the logarithm of the third plaintext array with base a based on the plaintext to obtain a fourth plaintext array, and encrypt the fourth plaintext array to obtain a sixth ciphertext array;

[0022] A result calculation module is used to calculate the difference between the sixth ciphertext array and the fourth ciphertext array based on the ciphertext, and obtain the logarithm of the target ciphertext array with a as the base, and the logarithm of the target ciphertext array with a as the base is the ciphertext.

[0023] On the other hand, an embodiment of the present invention discloses a device for ciphertext calculation, wherein the device is used to calculate the logarithm of a target ciphertext array with base a based on the ciphertext, wherein the elements in the target ciphertext array are ciphertexts, and a is an arbitrary constant. The device includes a memory, and one or more programs, wherein one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include instructions for performing the ciphertext calculation method as described above.

[0024] On the other hand, an embodiment of the present invention discloses a machine-readable medium having instructions stored thereon, which, when executed by one or more processors of a device, enables the device to perform one or more of the ciphertext calculation methods described above.

[0025] The embodiments of the present invention include the following advantages:

[0026] The embodiment of the present invention proposes a ciphertext calculation method, which utilizes the properties of the logarithmic function, and through a series of plaintext calculation operations, calculates the logarithm of a target ciphertext array with a as the base based on the ciphertext, and the result obtained is the ciphertext, and no information of the target ciphertext array is exposed during the calculation process, which can protect the privacy and security of the data. In addition, the embodiment of the present invention can realize the calculation of the logarithm of the target ciphertext array with a as the base based on the ciphertext through only one ciphertext multiplication operation and one ciphertext subtraction operation, which can greatly improve the efficiency of calculating the logarithmic function based on the ciphertext, and further improve the efficiency of training the machine learning model based on the ciphertext data. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0028] Figure 1 is a flowchart of a method for calculating ciphertext according to an embodiment of the present invention;

[0029] Figure 2 It is a structural block diagram of an embodiment of a ciphertext computing device of the present invention;

[0030] Figure 3is a block diagram of an apparatus 800 for ciphertext calculation according to the present invention;

[0031] Figure 4 It is a schematic diagram of the structure of the server in some embodiments of the present invention. DETAILED DESCRIPTION

[0032] 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 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.

[0033] The terms "first", "second", etc. in the specification and claims of the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable when appropriate, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In the embodiments of the present invention, the term "multiple" refers to two or more, and other quantifiers are similar.

[0034] Reference Figure 1 , shows a flowchart of a ciphertext calculation method embodiment of the present invention, the method is used to calculate the logarithm of a target ciphertext array with a as the base based on the ciphertext, the elements in the target ciphertext array are ciphertexts, a is an arbitrary constant, and the method may include the following steps:

[0035] Step 101: Generate a first plaintext array, where the elements in the first plaintext array are plaintext random numbers;

[0036] Step 102: Calculate the logarithm of the first plaintext array with base a to obtain a second plaintext array;

[0037] Step 103: encrypt the first plaintext array to obtain a first ciphertext array, and encrypt the second plaintext array to obtain a second ciphertext array;

[0038] Step 104: rearrange the first ciphertext array according to a random sequence based on the ciphertext to obtain a third ciphertext array, and rearrange the second ciphertext array according to the same random sequence based on the ciphertext to obtain a fourth ciphertext array;

[0039] Step 105: Calculate the product of the third ciphertext array and the target ciphertext array based on the ciphertext to obtain a fifth ciphertext array, and decrypt the fifth ciphertext array to obtain a third plaintext array;

[0040] Step 106: Calculate the logarithm of the third plaintext array with base a based on the plaintext to obtain a fourth plaintext array, and encrypt the fourth plaintext array to obtain a sixth ciphertext array;

[0041] Step 107: Calculate the difference between the sixth ciphertext array and the fourth ciphertext array based on the ciphertext to obtain the logarithm of the target ciphertext array with base a as the ciphertext. The logarithm of the target ciphertext array with base a as the ciphertext.

[0042] The ciphertext calculation method provided in the embodiment of the present invention can be used to calculate the logarithm of a target ciphertext array with base a based on the ciphertext, wherein the elements in the target ciphertext array are ciphertexts, and the base a can be any constant. For ease of description, the target ciphertext array is recorded as x in the embodiment of the present invention. The dimension of the target ciphertext array x is not limited in the embodiment of the present invention. The target ciphertext array x can be of any dimension. For ease of description, the target ciphertext array x is taken as a one-dimensional array as an example in the embodiment of the present invention. The calculation processes of other dimensions are similar and can be referenced to each other. In addition, the embodiment of the present invention does not limit the array length of the target ciphertext array x. The embodiment of the present invention calculates the logarithm of the target ciphertext array with base a based on the ciphertext, that is, calculates log based on the ciphertext. a The result of x, x is a ciphertext array, each element in the array is a ciphertext, and the calculated log a The result of x is also ciphertext, and the information of x will not be exposed during the calculation process.

[0043] Specifically, first generate a first plaintext array, the elements of which are plaintext random numbers. For ease of description, the first plaintext array is recorded as b in the embodiment of the present invention, and each element in the first plaintext array b is randomly generated, and each element is plaintext. Calculate the logarithm of the first plaintext array with a as the base to obtain a second plaintext array. For ease of description, the second plaintext array is recorded as c in the embodiment of the present invention, that is, c=log based on the plaintext calculation a b. Each element in the second plaintext array c is plaintext.

[0044] Furthermore, the first plaintext array, the second plaintext array, and the target ciphertext array have the same array length, that is, array x, array b, and array c have the same array length.

[0045] Then, the first plaintext array is encrypted to obtain a first ciphertext array, and the second plaintext array is encrypted to obtain a second ciphertext array. For example, the first plaintext array b is encrypted to obtain a first ciphertext array, such as b1. The second plaintext array c is encrypted to obtain a second ciphertext array, such as c1.

[0046] It should be noted that the embodiments of the present invention do not limit the encryption algorithm used for data encryption. For example, the ciphertext calculation method provided in the embodiments of the present invention can be applied to a multi-party secure computing platform, and the multi-party secure computing platform can use a secret sharing encryption algorithm. Of course, the embodiments of the present invention can use any encryption algorithm, such as a homomorphic encryption algorithm.

[0047] Next, the first ciphertext array is rearranged in a random sequence based on the ciphertext to obtain a third ciphertext array. For example, the first ciphertext array b1 is rearranged in a random sequence based on the ciphertext to obtain a third ciphertext array, such as b2. The random sequence is used to randomly disrupt the order of elements in the first ciphertext array b1, and the random sequence can be a randomly generated ciphertext sequence.

[0048] Exemplarily, assume that the first ciphertext array b1 is b1=[1,2,3]. In this example, the first ciphertext array b1 contains 3 elements, namely 1, 2, and 3. It can be understood that elements 1, 2, and 3 are all ciphertexts, which are shown in plain text here for ease of explanation. Assume that the random sequence is permutation=[2,0,1], and the elements in the random sequence are also ciphertexts, which are shown in plain text here for ease of explanation. The elements in the random sequence are used to represent the order of elements in the reordered array. In the random sequence, the first element is 2, indicating that the subscript of the first element in the reordered array is 2. The first ciphertext array b1 is reordered according to the random sequence. Since the element with subscript 2 in the first ciphertext array b1 is element 3, after reordering, element 3 becomes the first element. In the random sequence, the second element is 0, indicating that the subscript of the second element in the reordered array is 0. The first ciphertext array b1 is reordered according to the random sequence. Since the element with subscript 0 in the first ciphertext array b1 is element 1, after reordering, element 1 becomes the second element. In the random sequence, the third element is 1, indicating that the subscript of the third element in the reordered array is 1. The first ciphertext array b1 is reordered according to the random sequence. Since the element with subscript 1 in the first ciphertext array b1 is element 2, after reordering, element 2 becomes the third element. That is, in this example, the first ciphertext array b1 = [1,2,3] is reordered according to the random sequence permutation = [2,0,1], and the third ciphertext array is b2 = [3,1,2].

[0049] Based on the ciphertext, the second ciphertext array is rearranged according to the same random sequence to obtain a fourth ciphertext array. For example, based on the ciphertext, the second ciphertext array c1 is rearranged according to the same random sequence to obtain a fourth ciphertext array, such as c2. In this embodiment of the present invention, the first ciphertext array b1 and the second ciphertext array c1 are rearranged according to the same random sequence. In this example, the second ciphertext array c1 can also be reordered according to the random sequence permutation=[2,0,1].

[0050] Next, the product of the third ciphertext array and the target ciphertext array is calculated based on the ciphertext to obtain a fifth ciphertext array, and the fifth ciphertext array is decrypted to obtain a third plaintext array. For example, the product of the third ciphertext array b2 and the target ciphertext array x is calculated based on the ciphertext to obtain a fifth ciphertext array, such as x1, and the fifth ciphertext array x1 is decrypted to obtain a third plaintext array, such as x2. Since the elements in the first plaintext array b are random numbers, the elements in the fifth ciphertext array x1 are also random numbers. Without knowing the third ciphertext array b2, it is impossible to obtain any information about the target ciphertext array x.

[0051] Next, the logarithm of the third plaintext array with base a is calculated based on the plaintext to obtain a fourth plaintext array, and the fourth plaintext array is encrypted to obtain a sixth ciphertext array. For ease of description, the fourth plaintext array is recorded as x3 in the embodiment of the present invention, then x3=log a x2, and encrypt the fourth plaintext array x3 to obtain a sixth ciphertext array, such as x4.

[0052] Finally, the difference between the sixth ciphertext array and the fourth ciphertext array is calculated based on the ciphertext to obtain the logarithm of the target ciphertext array with base a. For example, the difference between the sixth ciphertext array x4 and the fourth ciphertext array c2 is calculated based on the ciphertext to obtain log a The result of x is recorded as res, then res = x4-c2. res is the ciphertext.

[0053] The logarithmic function has the following properties: a b*x=log a b+log a x, that is: log a x=log a b*x-log a b. The ciphertext calculation method provided in the embodiment of the present invention utilizes the above-mentioned properties of the logarithmic function to realize the calculation of log based on the ciphertext. a The result of x is ciphertext, and the information of x will not be exposed during the calculation process.

[0054] In the embodiment of the present invention, the first ciphertext array b1 and the second ciphertext array c1 are actually an array and the encrypted result of the log value of the array, that is, c1[i]=log(b1[i]). The third ciphertext array b2 is obtained by rearranging the first ciphertext array b1 according to a random sequence, and the fourth ciphertext array c2 is obtained by rearranging the second ciphertext array c1 according to the same random sequence. Since they correspond to the same random sequence, the third ciphertext array b2 and the fourth ciphertext array c2 are actually also an array and the encrypted result of the log value of the array, that is, c2[i]=log(b2[i]).

[0055] Essentially, x4=log a x*b2=log a x+log a b2, due to log a b2=c2,therefore,x4=log a x*b2=log a x+log a b2=log a x+c2, then x4–c2=log a Therefore, the embodiment of the present invention can realize the calculation of log based on ciphertext through the above steps 101 to 107. a The result of x is ciphertext, and the information of x will not be exposed during the calculation process.

[0056] In an optional embodiment of the present invention, the step 104 of rearranging the first ciphertext array in a random order based on the ciphertext to obtain a third ciphertext array, and rearranging the second ciphertext array in the same random order based on the ciphertext to obtain a fourth ciphertext array may include:

[0057] Step S11, generating a random sequence according to the array length, wherein the elements in the random sequence are ciphertexts;

[0058] Step S12, calling an oblivious shuffle function, wherein the input of the oblivious shuffle function is the first ciphertext array and the random sequence, and the output of the oblivious shuffle function is a third ciphertext array; and calling an oblivious shuffle function, wherein the input of the oblivious shuffle function is the second ciphertext array and the random sequence, and the output of the oblivious shuffle function is a fourth ciphertext array.

[0059] In the embodiment of the present invention, the first plaintext array b, the second plaintext array c, and the target ciphertext array x have the same array length. According to the array length, a random sequence can be generated, and the elements in the random sequence are ciphertexts.

[0060] Exemplarily, a sequence with the same array length as the target ciphertext array x can be generated first, and the elements of the sequence sequence increase from 0, which can be understood as the elements in the sequence sequence used to describe the subscripts of the array elements. For example, the sequence is p = [0, 1, 2, 3, 4], and the elements in the sequence p respectively describe the subscripts 0, 1, 2, 3, and 4 of the array elements. The elements in the sequence p can be ciphertexts, which are shown in plain text here for ease of description. Then, a random function, such as the oblivious_random_shuffle function, can be used to randomly shuffle the sequence p to obtain a random sequence. Exemplarily, the random sequence obtained is permutation = oblivious_random_shuffle (p) = [4, 2, 1, 3, 0], and the elements in the random sequence are ciphertexts, which are shown in plain text here for ease of description. Random functions can be used to reorder a sequence of elements (the result of the reordering is random and not unique).

[0061] After the random sequence is generated, an oblivious shuffle function such as the oblivious_shuffle function may be called. The oblivious shuffle function may reorder the ciphertext array in a random sequence based on the ciphertext.

[0062] For example, the first ciphertext array and the random sequence are used as input parameters to call the oblivious shuffle function, and the output of the oblivious shuffle function is a third ciphertext array obtained by rearranging the first ciphertext array according to the random sequence based on the ciphertext. For another example, the second ciphertext array and the random sequence are used as input parameters to call the oblivious shuffle function, and the output of the oblivious shuffle function is a fourth ciphertext array obtained by rearranging the second ciphertext array according to the random sequence based on the ciphertext.

[0063] Exemplarily, assuming that the first ciphertext array b1 = [0.538, 0.979, 0.213, 0.124, 0.802] and the random sequence permutation = [4, 2, 1, 3, 0], then calling the obligatory_shuffle function with b1 and permutation as input parameters can obtain the third ciphertext array b2 = obligatory_shuffle (b1, permutation) = [0.802, 0.213, 0.979, 0.124, 0.538]. Assuming that the second ciphertext array c1 = [-0.61989672, -0.02122364, -1.54646311, -2.08747371, -0.22064667], the obligatory_shuffle function is called with c1 and permutation as input parameters to obtain the fourth ciphertext array c2 = obligatory_shuffle (c1, permutation) = [-0.22064667, -1.54646311, -0.02122364, -2.08747371, -0.61989672].

[0064] It should be noted that the above-mentioned use of an inadvertent shuffling function to reorder the ciphertext array in a random sequence based on the ciphertext is only an optional implementation of the present invention, and the embodiment of the present invention does not limit the specific manner in which the first ciphertext array and the second ciphertext array are respectively rearranged in the same random order.

[0065] The following is a specific example to illustrate the specific process of calculating the logarithm of the target ciphertext array with base a based on the ciphertext. Assume that the target ciphertext array x = [1.2, 2.3, 3.4, 4.5, 5.6], base a = e, and the logarithm with base e is called the natural logarithm. This example needs to calculate the logarithm based on the ciphertext. e x, which can also be expressed as Inx. It can be understood that each element in the target ciphertext array x is a ciphertext, and for ease of description, the embodiment of the present invention shows it in plain text.

[0066] First, generate a first plaintext array, and calculate the logarithm of the first plaintext array with base a to obtain a second plaintext array, where the elements in the first plaintext array are plaintext random numbers. In this example, assume that the first plaintext array b = [0.538, 0.979, 0.213, 0.124, 0.802] is generated, and the second plaintext array c = loglog eb=[-0.61989672,-0.02122364,-1.54646311,-2.08747371,-0.22064667]. Each element in the first plaintext array b and the second plaintext array c is plaintext. It should be noted that the elements in the first plaintext array b are randomly generated, and the values ​​of each element in the first plaintext array b in this example are only used as an example and are not limited to this value.

[0067] The first plaintext array b is encrypted to obtain a first ciphertext array b1, and the second plaintext array c is encrypted to obtain a second ciphertext array c1.

[0068] In this example, the first ciphertext array b1 = [0.538, 0.979, 0.213, 0.124, 0.802], and the second ciphertext array c1 = [-0.61989672, -0.02122364, -1.54646311, -2.08747371, -0.22064667]. It should be noted that each element in the first ciphertext array b1 and the second ciphertext array c1 is ciphertext, which is shown in plain text here for the convenience of description.

[0069] Based on the ciphertext, the first ciphertext array b1 is rearranged according to a random sequence permutation to obtain a third ciphertext array b2, and based on the ciphertext, the second ciphertext array c1 is rearranged according to the same random sequence permutation to obtain a fourth ciphertext array c2.

[0070] In this example, assuming permutation = [4, 2, 1, 3, 0], the third ciphertext array b2 = [0.802, 0.213, 0.979, 0.124, 0.538] and the fourth ciphertext array c2 = [-0.22064667, -1.54646311, -0.02122364, -2.08747371, -0.61989672].

[0071] The product of the third ciphertext array b2 and the target ciphertext array x is calculated based on the ciphertext to obtain a fifth ciphertext array x1, and the fifth ciphertext array x1 is decrypted to obtain a third plaintext array x2.

[0072] In this example, x1=b2*x=[0.9624, 0.4899, 3.3286, 0.558, 3.0128], that is, the elements in the third ciphertext array b2 are bitwise multiplied with the elements in the target ciphertext array x, and the elements in the fifth ciphertext array x1 are ciphertexts, which are shown here in plaintext for ease of description. The fifth ciphertext array x1 is decrypted to obtain the third plaintext array x2=[0.9624, 0.4899, 3.3286, 0.558, 3.0128], and the elements in the third plaintext array x2 are plaintexts.

[0073] The logarithm of the third plaintext array x2 with base a is calculated based on the plaintext to obtain a fourth plaintext array x3, and the fourth plaintext array x3 is encrypted to obtain a sixth ciphertext array x4.

[0074] In this example, the fourth plaintext array x3 is calculated based on the plaintext, x3=log e x2=[-0.03832511,-0.71355399,1.2025518,-0.58339632,1.10286988]. The elements in the fourth plaintext array x3 are plaintext. The fourth plaintext array x3 is encrypted to obtain the sixth ciphertext array x4=[-0.03832511,-0.71355399,1.2025518,-0.58339632,1.10286988]. The elements in the sixth ciphertext array x4 are ciphertexts, which are shown here in plaintext for ease of description.

[0075] Finally, based on the ciphertext, the difference between the sixth ciphertext array x4 and the fourth ciphertext array c2 is calculated to obtain log e The result res of x. In this example, res=x4-c2=[0.18232156, 0.83290912, 1.22377544, 1.50407739, 1.7227666] is calculated based on the ciphertext. Each element in res is the ciphertext.

[0076] In an optional embodiment of the present invention, the calculation of the logarithm of the target ciphertext array with base a based on the ciphertext may include: calculating the logarithmic loss function during the training of the machine learning model, and calculating the logarithm of the target ciphertext array with base a based on the ciphertext during the calculation of the logarithmic loss function.

[0077] It should be noted that the embodiments of the present invention are applicable to any scenario where the logarithm of a target ciphertext array with base a needs to be calculated based on the ciphertext. Furthermore, the embodiments of the present invention are applicable to the scenario where a logarithmic loss function is calculated during the training of a machine learning model, and in the process of calculating the logarithmic loss function, the logarithm of a target ciphertext array with base a is calculated based on the ciphertext.

[0078] log a x is called the logarithmic function. As a general mathematical function, the logarithmic function is widely used in various fields, especially in machine learning. When training a machine learning model, the calculation formula of the logarithmic loss function is usually as follows:

[0079]

[0080] Among them, Y is the output variable, X is the input variable, and L is the loss function. N is the input sample size, M is the number of possible categories, and y ij is a binary indicator indicating whether category j is the input instance x i The true category of p ij For the model or classifier to predict the input instance x i The probability of belonging to category j. If there are only two categories {0,1}, the formula of the logarithmic loss function shown in equation (1) above is simplified to:

[0081]

[0082] At this time, y i For the input instance x i The true category, p i Input instance x for prediction i The probability of belonging to class 1. The log loss for all samples is the average of the log losses for each sample.

[0083] It should be noted that when the base of log in the above formulas (1) and (2) is not specified, the base is e.

[0084] In an optional embodiment of the present invention, the target ciphertext array may include input parameters of the logarithmic loss function in the process of training the machine learning model.

[0085] In the scenario of training a machine learning model based on ciphertext, when calculating the logarithmic loss function shown in formula (2), it is necessary to calculate the log based on the ciphertext. e p i The value of and log calculation based on the ciphertext e (1-p i ) value, these two steps will consume a lot of computing time and communication time. Through the ciphertext calculation method provided by the embodiment of the present invention, the input parameter p of the logarithmic loss function is i As the target ciphertext array, log can be calculated based on the ciphertext e p i The value of , and the input parameter of the logarithmic loss function (1-p i ) as the target ciphertext array, log can be calculated based on the ciphertext e (1-pi ), thereby improving the computational efficiency of these two steps.

[0086] In an optional embodiment of the present invention, the training of the machine learning model may include: multiple participants jointly training the machine learning model based on their respective privacy data using a multi-party secure computing platform.

[0087] It should be noted that the embodiment of the present invention does not limit the number of participants involved in training the machine learning model. The number of participants may be greater than or equal to 1. Furthermore, when the number of participants is greater than 1, through the embodiment of the present invention, each participant can jointly train the machine learning model under the premise of protecting the privacy and security of their respective data. Among them, the participant may be the data owner and may provide training data for training the machine learning model. The training data held by each participant may be a private data, such as environmental monitoring data, user credit data, user account data, personal health data, etc.

[0088] In summary, the embodiment of the present invention proposes a ciphertext calculation method, which utilizes the properties of the logarithmic function, and through a series of plaintext calculation operations, calculates the logarithm of the target ciphertext array with a as the base based on the ciphertext, and the result obtained is the ciphertext, and no information of the target ciphertext array is exposed during the calculation process, which can protect the privacy and security of the data. In addition, the embodiment of the present invention can realize the calculation of the logarithm of the target ciphertext array with a as the base based on the ciphertext only through one ciphertext multiplication operation and one ciphertext subtraction operation, which can greatly improve the efficiency of calculating the logarithmic function based on the ciphertext, and further improve the training efficiency of the machine learning model based on the ciphertext data.

[0089] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0090] Reference Figure 2 , shows a structural block diagram of an embodiment of a ciphertext calculation device of the present invention, the device is used to calculate the logarithm of a target ciphertext array with a as the base based on the ciphertext, the elements in the target ciphertext array are ciphertexts, a is an arbitrary constant, and the device may include:

[0091] A first plaintext array generating module 201 is used to generate a first plaintext array, wherein the elements in the first plaintext array are plaintext random numbers;

[0092] A second plaintext array generating module 202, configured to calculate the logarithm of the first plaintext array with base a to obtain a second plaintext array;

[0093] A second ciphertext array generating module 203, configured to encrypt the first plaintext array to obtain a first ciphertext array, and to encrypt the second plaintext array to obtain a second ciphertext array;

[0094] The third and fourth ciphertext array generation module 204 is configured to rearrange the first ciphertext array according to a random sequence based on the ciphertext to obtain a third ciphertext array; and rearrange the second ciphertext array according to the same random sequence based on the ciphertext to obtain a fourth ciphertext array;

[0095] A fifth ciphertext array generating module 205 is used to calculate the product of the third ciphertext array and the target ciphertext array based on the ciphertext to obtain a fifth ciphertext array;

[0096] A third plaintext array generating module 206, configured to decrypt the fifth ciphertext array to obtain a third plaintext array;

[0097] A sixth ciphertext array generating module 207 is used to calculate the logarithm of the third plaintext array with base a based on the plaintext to obtain a fourth plaintext array, and encrypt the fourth plaintext array to obtain a sixth ciphertext array;

[0098] The result calculation module 208 is used to calculate the difference between the sixth ciphertext array and the fourth ciphertext array based on the ciphertext to obtain the logarithm of the target ciphertext array with base a, and the logarithm of the target ciphertext array with base a is the ciphertext.

[0099] Optionally, the first plaintext array, the second plaintext array, and the target ciphertext array have the same array length.

[0100] Optionally, the third and fourth ciphertext array generation modules are specifically used to generate a random sequence according to the array length, the elements in the random sequence are ciphertexts; call an oblivious shuffle function, the input of the oblivious shuffle function is the first ciphertext array and the random sequence, and the output of the oblivious shuffle function is the third ciphertext array; and call an oblivious shuffle function, the input of the oblivious shuffle function is the second ciphertext array and the random sequence, and the output of the oblivious shuffle function is the fourth ciphertext array.

[0101] Optionally, the device is specifically used to calculate a logarithmic loss function during the process of training a machine learning model, and in the process of calculating the logarithmic loss function, calculate the logarithm of a target ciphertext array with base a based on the ciphertext.

[0102] Optionally, the target ciphertext array includes input parameters of the logarithmic loss function in the process of training the machine learning model.

[0103] Optionally, the training of the machine learning model may include: multiple parties jointly training the machine learning model based on their respective privacy data using a multi-party secure computing platform.

[0104] The embodiment of the present invention proposes a ciphertext calculation device, which uses the properties of the logarithmic function, and through a series of plaintext calculation operations, calculates the logarithm of the target ciphertext array with a as the base based on the ciphertext, and the result obtained is the ciphertext, and no information of the target ciphertext array is exposed during the calculation process, which can protect the privacy and security of the data. In addition, the embodiment of the present invention can realize the calculation of the logarithm of the target ciphertext array with a as the base based on the ciphertext through only one ciphertext multiplication operation and one ciphertext subtraction operation, which can greatly improve the efficiency of calculating the logarithmic function based on the ciphertext, and further improve the training efficiency of the machine learning model based on the ciphertext data.

[0105] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0106] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0107] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0108] An embodiment of the present invention provides a device for ciphertext calculation, including a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, wherein the one or more programs include instructions for performing the ciphertext calculation method described in the aforementioned embodiment.

[0109] Figure 3 8 is a block diagram of an apparatus 800 for ciphertext calculation according to an exemplary embodiment. For example, the apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0110] Reference Figure 3, the device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .

[0111] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0112] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0113] The power supply component 806 provides power to the various components of the device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.

[0114] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0115] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the device 800 is in an operating mode, such as a call mode, a recording mode, and a voice information processing mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.

[0116] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0117] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, and the sensor assembly 814 can also search for changes in the position of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0118] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency information processing (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0119] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.

[0120] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0121] Figure 4 1 is a schematic diagram of the structure of the server in some embodiments of the present invention. The server 1900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1922 (for example, one or more processors) and memory 1932, and one or more storage media 1930 (for example, one or more mass storage devices) storing application programs 1942 or data 1944. Among them, the memory 1932 and the storage medium 1930 can be short-term storage or permanent storage. The program stored in the storage medium 1930 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the server. Furthermore, the central processing unit 1922 can be configured to communicate with the storage medium 1930 and execute a series of instruction operations in the storage medium 1930 on the server 1900.

[0122] The server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input and output interfaces 1958, one or more keyboards 1956, and / or, one or more operating systems 1941, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0123] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a device (server or terminal), enables the device to perform Figure 1 The ciphertext calculation method shown.

[0124] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a device (server or terminal), enables the device to perform the above Figure 1 The description of the ciphertext calculation method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated. For technical details not disclosed in the computer program product or computer program embodiment involved in this application, please refer to the description of the method embodiment of this application.

[0125] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art not disclosed by the present invention. The description and examples are to be regarded as exemplary only, and the true scope and spirit of the present invention is indicated by the following claims.

[0126] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

[0127] 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.

[0128] The above is a detailed introduction to a ciphertext calculation method, a ciphertext calculation device and a device for ciphertext calculation provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A ciphertext calculation method, characterized in that: The method is used to calculate the logarithm of a target ciphertext array with a as the base based on the ciphertext, where the elements in the target ciphertext array are the ciphertexts, and a is an arbitrary constant, and the method includes: Generate a first plaintext array, where elements in the first plaintext array are plaintext random numbers; Calculate the logarithm of the first plaintext array with base a to obtain a second plaintext array; Encrypting the first plaintext array to obtain a first ciphertext array, and encrypting the second plaintext array to obtain a second ciphertext array; Rearranging the first ciphertext array according to a random sequence based on the ciphertext to obtain a third ciphertext array, and rearranging the second ciphertext array according to the same random sequence based on the ciphertext to obtain a fourth ciphertext array; Calculating the product of the third ciphertext array and the target ciphertext array based on the ciphertext to obtain a fifth ciphertext array, and decrypting the fifth ciphertext array to obtain a third plaintext array; Calculate the logarithm of the third plaintext array with base a based on the plaintext to obtain a fourth plaintext array, and encrypt the fourth plaintext array to obtain a sixth ciphertext array; The difference between the sixth ciphertext array and the fourth ciphertext array is calculated based on the ciphertext to obtain the logarithm of the target ciphertext array with base a as the ciphertext, and the logarithm of the target ciphertext array with base a as the ciphertext.

2. The method according to claim 1, characterized in that The first plaintext array, the second plaintext array, and the target ciphertext array have the same array length.

3. The method according to claim 2, characterized in that The step of rearranging the first ciphertext array in a random order based on the ciphertext to obtain a third ciphertext array, and rearranging the second ciphertext array in the same random order based on the ciphertext to obtain a fourth ciphertext array includes: Generate a random sequence according to the length of the array, where the elements in the random sequence are ciphertexts; Calling an oblivious shuffle function, wherein the input of the oblivious shuffle function is the first ciphertext array and the random sequence, and the output of the oblivious shuffle function is a third ciphertext array; An oblivious shuffle function is called, wherein the input of the oblivious shuffle function is the second ciphertext array and the random sequence, and the output of the oblivious shuffle function is a fourth ciphertext array.

4. The method according to any one of claims 1 to 3, characterized in that: The step of calculating the logarithm of a target ciphertext array with base a based on the ciphertext includes: A logarithmic loss function is calculated during the training of the machine learning model, and in the process of calculating the logarithmic loss function, the logarithm of the target ciphertext array with base a is calculated based on the ciphertext.

5. The method according to claim 4, characterized in that The target ciphertext array includes input parameters of the logarithmic loss function during the training of the machine learning model.

6. The method according to claim 4, characterized in that The training of the machine learning model includes: multiple participants jointly train the machine learning model based on their respective privacy data using a multi-party secure computing platform.

7. A ciphertext computing device, characterized in that: The device is used to calculate the logarithm of a target ciphertext array with a as the base based on the ciphertext, where the elements in the target ciphertext array are the ciphertexts, and a is an arbitrary constant, and the device includes: A first plaintext array generating module, used to generate a first plaintext array, wherein the elements in the first plaintext array are plaintext random numbers; A second plaintext array generating module, used for calculating the logarithm of the first plaintext array with base a to obtain a second plaintext array; A second ciphertext array generating module, configured to encrypt the first plaintext array to obtain a first ciphertext array, and to encrypt the second plaintext array to obtain a second ciphertext array; A third and fourth ciphertext array generation module, configured to rearrange the first ciphertext array according to a random sequence based on the ciphertext to obtain a third ciphertext array; and to rearrange the second ciphertext array according to the same random sequence based on the ciphertext to obtain a fourth ciphertext array; a fifth ciphertext array generating module, configured to calculate the product of the third ciphertext array and the target ciphertext array based on the ciphertext to obtain a fifth ciphertext array; A third plaintext array generating module, used for decrypting the fifth ciphertext array to obtain a third plaintext array; a sixth ciphertext array generating module, configured to calculate the logarithm of the third plaintext array with base a based on the plaintext to obtain a fourth plaintext array, and encrypt the fourth plaintext array to obtain a sixth ciphertext array; A result calculation module is used to calculate the difference between the sixth ciphertext array and the fourth ciphertext array based on the ciphertext, and obtain the logarithm of the target ciphertext array with a as the base, and the logarithm of the target ciphertext array with a as the base is the ciphertext.

8. The device according to claim 7, characterized in that The first plaintext array, the second plaintext array, and the target ciphertext array have the same array length.

9. The device according to claim 8, characterized in that The third and fourth ciphertext array generation modules are specifically used to generate a random sequence according to the array length, wherein the elements in the random sequence are ciphertexts; call an oblivious shuffle function, wherein the input of the oblivious shuffle function is the first ciphertext array and the random sequence, and the output of the oblivious shuffle function is the third ciphertext array; And calling an inadvertent shuffle function, the input of the inadvertent shuffle function is the second ciphertext array and the random sequence, and the output of the inadvertent shuffle function is a fourth ciphertext array.

10. The device according to any one of claims 7 to 9, characterized in that: The device is specifically used to calculate the logarithmic loss function during the training of the machine learning model, and in the process of calculating the logarithmic loss function, calculate the logarithm of the target ciphertext array with base a based on the ciphertext.

11. The device according to claim 10, characterized in that The target ciphertext array includes input parameters of the logarithmic loss function during the training of the machine learning model.

12. The device according to claim 10, characterized in that The training of the machine learning model includes: multiple participants jointly train the machine learning model based on their respective privacy data using a multi-party secure computing platform.

13. A device for ciphertext calculation, characterized in that: The device is used to calculate the logarithm of a target ciphertext array with base a based on a ciphertext, wherein the elements in the target ciphertext array are ciphertexts, and a is an arbitrary constant. The device includes a memory, and one or more programs, wherein one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include instructions for performing the ciphertext calculation method as described in any one of claims 1 to 6.

14. A machine-readable medium having instructions stored thereon, which, when executed by one or more processors of a device, causes the device to execute the ciphertext calculation method as claimed in any one of claims 1 to 6.