Homomorphic encrypted data identification method and device, electronic equipment and medium
By discrete the pre-trained neural network, the discrete neural network is obtained, which solves the problem of not being able to identify homomorphic encrypted data, and realizes the identification of encrypted data and the security of cloud data.
Patent Information
- Application Number
- CN202510174531.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-03-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, it is impossible to use neural networks to identify homomorphic encrypted data, which makes it difficult to solve the problem of cloud data security.
By discretizing the pre-trained neural network, a discrete neural network is obtained, and its input and network weight are integers [-1, 1], and homomorphic encrypted data are input into the discrete neural network for identification.
The identification of homomorphic encrypted data is realized, the problem of the inability to use neural networks for identification in the prior art is improved, and the security of cloud data is enhanced.
Smart Images

Figure CN119646458A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine learning technology, and in particular to a method, device, electronic device and medium for identifying homomorphic encrypted data. Background Art
[0002] With the widespread popularity of machine learning as a service and its implementation in various fields, the security of cloud data has become increasingly prominent. Homomorphic encryption is a cryptographic technology based on the computational complexity theory of mathematical problems. The output obtained by processing the homomorphically encrypted data is decrypted, and the result is the same as the output obtained by processing the unencrypted original data in the same way. After the data is homomorphically encrypted, basic addition, subtraction, multiplication and division operations can be performed, but neural network training cannot be performed, and neural networks cannot be used to identify encrypted data. In short, after the data is homomorphically encrypted, it cannot be used in neural networks. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a method, device, electronic device and medium for identifying homomorphically encrypted data, which improves the problem in the prior art that neural networks cannot be used to identify homomorphically encrypted data.
[0004] In order to achieve the above object, the technical solution adopted by the present invention is as follows: In a first aspect, the present invention provides a method for identifying homomorphically encrypted data, comprising: obtaining homomorphically encrypted data to be identified and a pre-trained neural network; wherein the pre-trained neural network is trained based on an unencrypted training data set; discretizing the pre-trained neural network to obtain a discrete neural network; wherein the input and network weights of the discrete neural network are integers in the range of [-1,1]; inputting the homomorphically encrypted data to be identified into the discrete neural network to obtain an identification result.
[0005] Optionally, the pre-trained neural network is discretized to obtain a discrete neural network, including: adjusting network parameters of the pre-trained neural network based on pre-set accuracy parameters to obtain network parameters of the discrete neural network; adjusting the activation function of the pre-trained neural network to obtain the discrete neural network.
[0006] Optionally, adjusting the network parameters of the pre-trained neural network based on the preset accuracy parameters includes: adjusting the network parameters of the neural network according to the following formula:
[0007] in, represents the precision parameter, represents the network parameters of the pre-trained neural network,processWeight Represents the network parameters of a discrete neural network.
[0008] Optionally, adjusting the activation function of the pre-trained neural network includes: updating the activation function of the pre-trained neural network to a sign function.
[0009] Optionally, before obtaining the homomorphically encrypted data to be identified and the pre-trained neural network, the method also includes: obtaining an unencrypted training data set; binarizing the training samples in the unencrypted training data set to obtain binarized training samples; and training the neural network based on the binarized training samples to obtain a trained neural network.
[0010] In a second aspect, the present invention provides a device for identifying homomorphically encrypted data, comprising: a data acquisition module, used to acquire homomorphically encrypted data to be identified and a pre-trained neural network; wherein the pre-trained neural network is trained based on an unencrypted training data set; a discretization module, used to discretize the pre-trained neural network to obtain a discrete neural network; wherein the input and network weights of the discrete neural network are integers of [-1,1]; and a prediction module, used to input the homomorphically encrypted data to be identified into the discrete neural network to obtain an identification result.
[0011] Optionally, the discretization module is specifically used to: adjust the network parameters of the pre-trained neural network based on a preset accuracy parameter to obtain the network parameters of the discrete neural network; adjust the activation function of the pre-trained neural network to obtain the discrete neural network.
[0012] Optionally, the discretization module is specifically used to adjust the network parameters of the pre-trained neural network according to the following formula:
[0013] in, represents the precision parameter, represents the network parameters of the pre-trained neural network, processWeight Represents the network parameters of a discrete neural network.
[0014] In a third aspect, the present invention provides an electronic device comprising a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the steps of any one of the methods provided in the first aspect above.
[0015] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any one of the methods provided in the first aspect are executed.
[0016] The present invention brings the following beneficial effects: The above-mentioned homomorphic encrypted data recognition method, device, electronic device and medium provided by the present invention first obtain the homomorphic encrypted data to be recognized and a pre-trained neural network; wherein the pre-trained neural network is trained based on an unencrypted training data set; then the pre-trained neural network is discretized to obtain a discrete neural network; wherein the input and network weight of the discrete neural network are integers of [-1,1]; finally, the homomorphic encrypted data to be recognized is input into the discrete neural network to obtain a recognition result. In the above-mentioned method, a discrete neural network can be obtained by discretizing the pre-trained neural network, and the discrete neural network can be used to recognize homomorphic encrypted data, thereby improving the problem in the prior art that a neural network cannot be used to recognize homomorphic encrypted data.
[0017] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0018] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the preferred embodiments are specifically mentioned below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 A flowchart of a method for identifying homomorphically encrypted data provided by an embodiment of the present invention; Figure 2 A neuron schematic diagram of a neural network after discrete processing provided by an embodiment of the present invention; Figure 3 A schematic diagram of the structure of a homomorphically encrypted data identification device provided by an embodiment of the present invention; Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. 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.
[0022] Currently, after data is homomorphically encrypted, basic addition, subtraction, multiplication and division operations can be performed, but neural networks cannot be trained, nor can neural networks be used to recognize encrypted data.
[0023] Based on this, the embodiments of the present invention provide a method, device, electronic device and medium for identifying homomorphically encrypted data, which can improve the problem in the prior art that neural networks cannot be used to identify homomorphically encrypted data.
[0024] To facilitate understanding of this embodiment, a method for identifying homomorphically encrypted data disclosed in an embodiment of the present invention is first introduced in detail. The method can be executed by an electronic device, such as a smart phone, a computer, a tablet computer, etc. Figure 1 The flowchart of a method for identifying homomorphically encrypted data is shown, indicating that the device mainly includes the following steps S101 to S103: Step S101: Obtain homomorphic encrypted data to be identified and a pre-trained neural network.
[0025] In one embodiment, the homomorphically encrypted data to be identified is data that cannot be made public, which is encrypted using a homomorphic encryption algorithm. For different application scenarios, the homomorphically encrypted data to be identified is also different, such as: for medical scenarios, the homomorphically encrypted data to be identified can be patient information after homomorphic encryption, etc.; for target detection scenarios, the homomorphically encrypted data to be identified can be a homomorphically encrypted image, and the detection target is obtained by identifying the encrypted image; for enterprise or government scenarios, the homomorphically encrypted data to be identified can be files, texts, data, images, etc. after homomorphic encryption.
[0026] The pre-trained neural network is trained based on an unencrypted training data set. Specifically, the neural network is trained based on the unencrypted data corresponding to the homomorphically encrypted data to be identified. For example, if sensitive photos cannot be disclosed to the outside, the unencrypted photos can be used to train the relevant image recognition model in a local environment without an Internet connection. The type of neural network used by the image recognition model can be determined based on actual needs. The neural network training process includes: first, obtaining an unencrypted training data set; then, binarizing the training samples in the unencrypted training data set to obtain binarized training samples; and finally, training the neural network based on the binarized training samples to obtain a trained neural network.
[0027] In the specific implementation, taking the recognition of handwritten digits as an example, first obtain the unencrypted handwritten digit recognition training data set (i.e., unencrypted training data set); then, in order to make the network input between [-1,1], the training samples are binarized, such as: setting the pixels of the training samples with pixel values greater than or equal to 128 to 1, and setting the pixels with pixel values less than 128 to -1; finally, use the binarized training samples to train the neural network. Taking the LetNet5 network as an example, the LetNet5 network consists of two convolutional and pooling layers and two fully connected layers. During training, according to the traditional neural network initialization method, the LeNet-5 network is initialized using maximum likelihood estimation, and the network is trained using binarized training samples until the network loss no longer decreases, the network parameters are saved, and a trained neural network is obtained.
[0028] Step S102: discretizing the pre-trained neural network to obtain a discrete neural network.
[0029] In one embodiment, the discrete neural network can be considered as a feedforward neural network, and its input and network weight are integers belonging to [-1, 1] respectively. For each neuron of the discrete neural network, the activation function of the network takes the inner product of the input I and the weight W as the output of the network layer. In an embodiment of the present invention, a discrete neural network can be obtained by adjusting the network parameters and activation function of a pre-trained neural network.
[0030] Step S103: Input the homomorphic encrypted data to be identified into a discrete neural network to obtain an identification result.
[0031] In one embodiment, after obtaining a discrete neural network, the homomorphic encrypted data to be identified is input into the discrete neural network to obtain the identification result. In a specific implementation, the discrete neural network has the same structure as the pre-trained neural network, including but not limited to convolutional layers, pooling layers, activation functions, fully connected layers, etc., but the network parameters and activation functions are different. The homomorphic encrypted data to be identified is input into the discrete neural network, and the identification result is finally output after calculation of the convolutional layer, pooling layer, activation function, and fully connected layer.
[0032] The above-mentioned method for identifying homomorphically encrypted data provided by the present invention can obtain a discrete neural network by discretizing a pre-trained neural network, and the discrete neural network can be used to identify homomorphically encrypted data, thereby improving the problem in the prior art that neural networks cannot be used to identify homomorphically encrypted data.
[0033] In one embodiment, for the aforementioned step S102, that is, when the pre-trained neural network is discretized to obtain a discrete neural network, the following methods may be used, including but not limited to: First, the network parameters of the pre-trained neural network are adjusted based on the pre-set accuracy parameters to obtain the network parameters of the discrete neural network.
[0034] In specific implementation, the network parameters of the pre-trained neural network can be adjusted according to the following formula:
[0035] in, represents the precision parameter, represents the network parameters of the pre-trained neural network, processWeight Represents the network parameters of a discrete neural network.
[0036] In the embodiment of the present invention, The choice of value will have a huge impact on the network accuracy. A value that is too large will result in no change in network parameters, which is insufficient to adapt to the expansion of the message space after homomorphic encryption. The value will cause the network parameters to be too discrete and the network fitting ability will decrease. Therefore, it is necessary to select efficient and accurate value, in the embodiment of the present invention, Set the value to 8.
[0037] See also Figure 2 A neuron diagram of a neural network after discrete processing is shown in FIG. , are the network parameters of the neural network, , is the input of the neuron, that is, the homomorphically encrypted data that needs to be recognized, y The network’s activation function combines the input and the weights W The inner product of is taken as the output of this layer of network.
[0038] After the above processing is performed on the network parameters of the neural network, the boundary of the network parameters can be reduced, so that the encrypted ciphertext data will not diverge excessively after calculation, causing the problem of difficulty in fitting the network.
[0039] Then, the activation function of the pre-trained neural network is adjusted to obtain a discrete neural network.
[0040] In specific implementation, the activation function of the pre-trained neural network can be updated to the sign function. Since the discrete neural network is used to identify homomorphic encrypted data, and the network weights are all integers, in order to better maintain the feature semantics between different layers and ensure that the input of each layer of the network is between [-1,1], the binarization method can be used as the activation function, and the sign function can be used to replace the sigmoid activation function in the neural network. After transforming the output of each layer, it is used as the input of the next layer. Among them, the expression of the sign function is as follows: .
[0041] For ease of understanding, the embodiment of the present invention takes handwritten digit recognition as an example to introduce in detail the recognition method of homomorphic encrypted data provided by the embodiment of the present invention. First, the LeNet5 network is trained using a written digit recognition data set. During training, the image of the written digit recognition data set is binarized, and the binarized image is used to train the LeNet5 network; then the trained LeNet5 network is discretized using the discretization method in the aforementioned embodiment to obtain a discrete convolutional neural network; then the written digit recognition data set is encrypted using the TFHE homomorphic encryption algorithm to obtain ciphertext data; finally, the ciphertext data is input into the discrete convolutional neural network to obtain the recognition result of the ciphertext data.
[0042] The above method provided by the embodiment of the present invention discretizes the traditional pre-trained convolutional neural network so that the transformed discrete neural network can process homomorphically encrypted data, thereby improving the problem in the prior art that neural networks cannot be used to identify homomorphically encrypted data.
[0043] For the method for identifying homomorphically encrypted data provided in the above embodiment, the present invention also provides a device for identifying homomorphically encrypted data, see Figure 3 The schematic diagram of the structure of a homomorphically encrypted data recognition device is shown, indicating that the device mainly includes the following parts: The data acquisition module 301 is used to acquire homomorphically encrypted data to be identified and a pre-trained neural network; wherein the pre-trained neural network is trained based on an unencrypted training data set; A discretization module 302 is used to discretize the pre-trained neural network to obtain a discrete neural network; wherein the input and network weight of the discrete neural network are integers of [-1, 1]; The prediction module 303 is used to input the homomorphically encrypted data to be identified into the discrete neural network to obtain the identification result.
[0044] The above-mentioned homomorphically encrypted data recognition device provided by the present invention can obtain a discrete neural network by discretizing a pre-trained neural network, and the discrete neural network can be used to recognize homomorphically encrypted data, thereby improving the problem in the prior art that neural networks cannot be used to recognize homomorphically encrypted data.
[0045] In one embodiment, the discretization module 302 is specifically used to: adjust the network parameters of the pre-trained neural network based on a preset accuracy parameter to obtain the network parameters of the discrete neural network; adjust the activation function of the pre-trained neural network to obtain the discrete neural network.
[0046] In one implementation, the discretization module 302 is specifically used to adjust the network parameters of the pre-trained neural network according to the following formula:
[0047] in, represents the precision parameter, represents the network parameters of the pre-trained neural network, processWeight Represents the network parameters of a discrete neural network.
[0048] In one implementation, the discretization module 302 updates the activation function of the pre-trained neural network to a sign function.
[0049] In one embodiment, the above-mentioned device also includes a neural network training module, which is used to: obtain an unencrypted training data set; binarize the training samples in the unencrypted training data set to obtain binarized training samples; and train the neural network based on the binarized training samples to obtain a trained neural network.
[0050] It should be noted that the implementation principle and technical effects of the device provided in the embodiment of the present invention are the same as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0051] An embodiment of the present invention further provides an electronic device. Specifically, the electronic device includes a processor and a storage device. The storage device stores a computer program, and when the computer program is executed by the processor, it executes the method described in any one of the above implementation methods.
[0052] Figure 4 A structural diagram of an electronic device provided in an embodiment of the present invention, the electronic device 100 includes: a processor 40, a memory 41, a bus 42 and a communication interface 43, wherein the processor 40, the communication interface 43 and the memory 41 are connected via the bus 42; the processor 40 is used to execute an executable module stored in the memory 41, such as a computer program.
[0053] The memory 41 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 43 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.
[0054] The bus 42 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0055] Among them, the memory 41 is used to store programs, and the processor 40 executes the program after receiving the execution instruction. The method executed by the device for flow process definition disclosed in any embodiment of the above-mentioned embodiment of the present invention can be applied to the processor 40 or implemented by the processor 40.
[0056] The processor 40 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 40. The above processor 40 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 41, and the processor 40 reads the information in the memory 41 and completes the steps of the above method in combination with its hardware.
[0057] The computer program product of the readable storage medium provided in the embodiment of the present invention includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be referred to the previous method embodiments, which will not be repeated here.
[0058] 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 computer-readable storage medium. Based on this understanding, the technical solution of the present invention, 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. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0059] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-mentioned 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-mentioned embodiments within the technical scope disclosed by the present invention, 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 invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for identifying homomorphically encrypted data, characterized in that: include: Obtain homomorphic encrypted data to be identified and a pre-trained neural network; wherein the pre-trained neural network is trained based on an unencrypted training data set; Discretizing the pre-trained neural network to obtain a discrete neural network; wherein the input and network weight of the discrete neural network are integers in the range [-1, 1]; The homomorphic encrypted data to be identified is input into the discrete neural network to obtain an identification result.
2. The method according to claim 1, characterized in that Discretizing the pre-trained neural network to obtain a discrete neural network includes: Adjusting the network parameters of the pre-trained neural network based on the preset accuracy parameters to obtain the network parameters of the discrete neural network; The activation function of the pre-trained neural network is adjusted to obtain a discrete neural network.
3. The method according to claim 2, characterized in that Adjusting the network parameters of the pre-trained neural network based on the preset accuracy parameters includes: The network parameters of the pre-trained neural network are adjusted according to the following formula: in, represents the precision parameter, represents the network parameters of the pre-trained neural network, processWeight Represents the network parameters of a discrete neural network.
4. The method according to claim 2, characterized in that: The activation function of the pre-trained neural network is adjusted, including: The activation function of the pre-trained product neural network is updated to a sign function.
5. The method according to claim 1, characterized in that Before obtaining the homomorphic encrypted data to be identified and the pre-trained neural network, it also includes: Get the unencrypted training dataset; Binarizing the training samples in the unencrypted training data set to obtain binary training samples; The neural network is trained based on the binarized training samples to obtain a trained neural network.
6. A homomorphically encrypted data recognition device, characterized in that: include: A data acquisition module, used to acquire homomorphically encrypted data to be identified and a pre-trained neural network; wherein the pre-trained neural network is trained based on an unencrypted training data set; A discretization module, used for discretizing the pre-trained neural network to obtain a discrete neural network; wherein the input and network weight of the discrete neural network are integers of [-1, 1]; The prediction module is used to input the homomorphic encrypted data to be identified into the discrete neural network to obtain a recognition result.
7. The device according to claim 6, characterized in that The discretization module is specifically used to: adjust the network parameters of the pre-trained neural network based on a preset accuracy parameter to obtain the network parameters of the discrete neural network; The activation function of the pre-trained neural network is adjusted to obtain a discrete neural network.
8. The device according to claim 7, characterized in that The discretization module is specifically used to adjust the network parameters of the pre-trained neural network according to the following formula: in, represents the precision parameter, represents the network parameters of the pre-trained neural network, processWeight Represents the network parameters of a discrete neural network.
9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the steps of the method according to any one of claims 1 to 5.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are executed.
Citation Information
Patent Citations
Neural network construction method under homomorphic encryption and image processing method and system
CN112734004A
Method and system for implementing binary convolutional neural network based on homomorphic encryption
CN115860094A
Ciphertext handwritten recognition neural network training method and system based on mode component homomorphism
CN118570815A
Privacy-preserving neural network model and privacy-preserving prediction using the privacy-preserving neural network model
WO2023163652A2