Verifiable neural network security reasoning method, system and device based on homomorphic encryption and block chain, and storage medium

By using a combination of homomorphic encryption and blockchain technology in MLaaS services, a verifiable neural network security inference method is designed, which solves the problems of user privacy and transparency of the inference process, and achieves efficient and accurate model inference and results. verify.

CN118677597AActive Publication Date: 2024-09-20NORTH CHINA ELECTRIC POWER UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410933812.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-09-20
Estimated Expiration
2044-07-12

AI Technical Summary

Technical Problem

When using MLaaS services, it is difficult to guarantee user privacy and security. Traditional encryption methods cannot protect data privacy during the calculation process, and the reasoning process lacks transparency and credibility.

Method used

Adopt a verifiable neural network security reasoning method based on homomorphic encryption and blockchain, improve the efficiency and accuracy of model reasoning through the CKKS encryption scheme and ciphertext packaging algorithm, and design verification functions to ensure the authenticity and credibility of the reasoning results .

Benefits of technology

While protecting user privacy and security, it improves the accuracy and efficiency of model reasoning, provides transparency and verifiability of the reasoning process and results, and ensures the authenticity and credibility of the results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118677597A
    Figure CN118677597A
Patent Text Reader

Abstract

The invention discloses an auditable neural network security reasoning method, system and device based on homomorphic encryption and a block chain and a storage medium, and the method comprises the steps: 1, carrying out the initialization; step 2, data processing and ciphertext packaging; 3, performing model safety reasoning; 4, uploading a model reasoning result; 5, the service demander obtains a service result; and 6, verifying a result. The block chain and multiple homomorphic encryption technologies are combined, a new ciphertext packaging algorithm is provided for reasoning efficiency optimization, the polynomial approximation problem of an activation function is avoided by using a conversion method, and the accuracy of model reasoning is improved. And meanwhile, a verification function is provided for the user, the authenticity and reliability of a reasoning result are guaranteed, and the accuracy of model reasoning is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to an auditable neural network security reasoning method, system, device and storage medium based on homomorphic encryption and blockchain, and belongs to the field of privacy protection machine learning and data security technology. Background Art

[0002] In recent years, with the rapid development of big data and computing power, the reasoning effect of neural network models has been significantly improved. This progress has made complex artificial intelligence tasks more feasible and efficient. In order to meet the needs of enterprises and individuals with limited resources, Machine Learning as a Service (MLaaS) came into being. This service model enables enterprises and individual users to easily use powerful machine learning models without building and maintaining complex machine learning infrastructure. However, in the process of using MLaaS services, users send raw data to service providers, which is prone to privacy leakage. At the same time, due to the lack of transparency and verifiability, users cannot be sure whether the MLaaS provider actually performs reasoning operations or whether its reasoning process is as expected.

[0003] In the process of using MLaaS services, how to protect the privacy and security of users while ensuring the transparency and credibility of the reasoning process has become an important issue in the field of research and practice, and a large number of solutions have emerged. Among them, blockchain technology provides a potential solution to ensure the transparency and credibility of the reasoning process. The distributed ledger technology of blockchain ensures the transparency and immutability of data and operations. By recording the model parameters, reasoning process and results on the blockchain, users can verify the authenticity of each step of the operation. However, traditional encryption methods can only ensure the security of data storage and circulation. When performing calculations, the data is still in plain text, and the privacy security of the data calculation process cannot be guaranteed.

[0004] In terms of data privacy and security, homomorphic encryption technology is widely recognized for its high security and ability to perform operations directly on ciphertext. However, homomorphic encryption schemes based on message encryption can only perform addition and multiplication operations, and polynomial approximation is often used for nonlinear functions such as activation functions, which affects the accuracy of model reasoning. Although homomorphic encryption schemes based on bit encryption can perform any form of operation, they are difficult to apply to actual scenarios due to the huge computational overhead.

[0005] Therefore, there is an urgent need to propose a verifiable neural network security reasoning scheme that can improve reasoning efficiency while protecting user privacy and ensuring the authenticity and credibility of the reasoning process and reasoning results. Summary of the invention

[0006] The present invention provides a verifiable neural network security reasoning method and system based on homomorphic encryption and blockchain. Aiming at the reasoning characteristics of each network layer of the neural network model, we use a variety of homomorphic encryption schemes, and design corresponding conversion methods and ciphertext packaging algorithms to improve the efficiency and accuracy of the model. At the same time, the present invention also provides a verifiable function for users or enterprises to verify the reasoning results and ensure the authenticity of the results.

[0007] In order to solve the above technical problems, the technical solutions adopted by the present invention are as follows:

[0008] A verifiable neural network security reasoning method based on homomorphic encryption and blockchain includes the following steps:

[0009] Step 1: Initialization: The service demander (such as user, enterprise, etc.) and the model service provider generate the public key and private key of the CKKS encryption scheme locally; the public key and private key of the service demander are recorded as PK c , S.K. c , the model server is recorded as PK s , S.K. s ;

[0010] Step 2: Data processing and ciphertext packaging: The service demander pre-processes the collected image and other data, such as resizing, noise reduction, normalization, etc., and converts the image into matrix data. CKKS has the SIMD feature, which can package multiple (more than two) data into one ciphertext for operation. We have designed a ciphertext packaging algorithm to improve the operation efficiency by arranging the data before encryption, thereby accelerating the model reasoning, and then use the private key SK c Encrypt the rearranged data into ciphertext data and send it to the blockchain for storage;

[0011] Step 3: Model security reasoning: including convolutional layer reasoning, RLWE ciphertext to LWE ciphertext conversion, activation function layer reasoning, LWE ciphertext to RLWE ciphertext conversion and fully connected layer reasoning;

[0012] Step 4: Upload model inference results: The model service provider uploads the encrypted inference results to the blockchain;

[0013] Step 5: The service demander obtains the service result: The service demander obtains the encrypted inference result from the blockchain and decrypts it using its own private key to obtain the inference result;

[0014] Step 6: Result verification: When the service demander (user or enterprise) has doubts about the inference results of the model service provider, the service demander can send a verification request to the authority, and the authority will send a request to obtain the private key to the service demander and the model service provider; when the authority obtains the private keys of both parties, it obtains the ciphertext model parameters and ciphertext data from the blockchain for decryption, performs plaintext model inference operations locally, and obtains the intermediate results and inference results from the blockchain for comparison to generate a verification report for verification by the service demander.

[0015] The above step 3: Model security reasoning includes:

[0016] Step 3.1: Convolutional layer reasoning: After receiving the reasoning request, the model service provider obtains the ciphertext data to be reasoned from the blockchain node and converts the model parameters into Figure 3 The ciphertext packing algorithm is used to pack the data. At the same time, the model service provider encodes its own model parameters using the public key of the service demander, and then performs a convolution operation. The convolution operation can be seen as the process of applying a set of filters to the input data. Each filter slides on the input data and calculates the weighted sum of the local area. We have arranged the ciphertext in this form in the ciphertext packing. This process can be seen as multiple multiplications and additions of the ciphertext. Assuming ct m It represents the ciphertext of an inference image after ciphertext packaging. It means there are M filters arranged in a specific order, means there are M biases arranged in a specific order, represents the operation result, and finally obtains M ciphertext calculation results; the following formula shows the convolution process of the i-th filter, where Roate represents the ciphertext rotation operation. After multiplication, multiple rotation accumulations will be performed, and the variable represents the number of rotation accumulations, according to 1, 2, 4... until log K*K :

[0017]

[0018] Step 3.2: Convert RLWE ciphertext to LWE ciphertext: Although the RLWE ciphertext based on CKKS encryption can encrypt multiple data in one ciphertext to improve the operation efficiency, it cannot perform logical comparison operations. Therefore, we split the RLWE ciphertext, extract the ciphertext encoded in the polynomial, and obtain a set of LWE ciphertexts in FHEW encrypted form to perform activation function operations;

[0019] LWE encryption is defined as: in, represents the ring of integers modulo q, the key represents a vector of dimension n, each component in Inside, message a is a random vector, e is an error term randomly selected from the error distribution χ, n is the vector dimension, b is the inner product result, m is the message, and T is the mathematical matrix transpose, which is decrypted to b+a T s≈m;

[0020] RLWE encryption is defined as: in The coefficient is In the range and the polynomial modulus X n +1 ring, The coefficient is In the range and the polynomial modulus X n +1 for the ring, key represents the polynomial key, represents the error polynomial with coefficients independently drawn from the error distribution x, is a random polynomial;

[0021] We encrypt an RLWE ciphertext of CKKS as Where Δ refers to the scaling factor in CKKS encryption, v represents the encryption vector, and Symbol n, represents the dimension of the grid, and Representing the keys in different dimensions, each coding element in the ciphertext ct is extracted to obtain a set of LWE ciphertexts in FHEW encrypted form: Where l represents the encryption level, i∈ <l>It means that the index i is in a certain range, specifically, all values ​​in the range l. Then the lookup table T(x) of each LWE ciphertext is evaluated:

[0022] Step 3.3: Activation function layer reasoning: We construct a binary comparison circuit for the obtained LWE ciphertext to implement the operation process of the activation function RELU, and finally we get the ciphertext operation result of the activation function;

[0023] Step 3.4: Convert LWE ciphertext to RLWE ciphertext: After the activation function operation, when operating the next linear layer, the ciphertext type needs to be converted, a group of LWE ciphertexts are repackaged into a single RLWE ciphertext, and the encoding vector T(v) is encrypted:

[0024] Step 3.5: Fully connected layer reasoning: The fully connected layer can be regarded as a special convolutional layer operation. We use a packing algorithm similar to the convolutional layer operation to perform the fully connected layer operation.

[0025] A verifiable neural network security reasoning system based on homomorphic encryption and blockchain, including:

[0026] Initialization module: used by service demanders (such as users, enterprises, etc.) and model service providers to generate the public key and private key of the CKKS encryption scheme locally; the public key and private key of the service demander are recorded as PK c , S.K. c , the model server is recorded as PK s , S.K. s ;

[0027] Data processing and ciphertext packaging module: used for data processing and ciphertext packaging, and for service demanders to pre-process the collected images and other data, such as resizing, noise reduction, normalization, etc., and convert the images into matrix data. In view of the SIMD characteristics of CKKS, multiple data can be packaged into one ciphertext for calculation. We designed a ciphertext packaging algorithm to improve the calculation efficiency by arranging the data before encryption, thereby accelerating the model reasoning, and then use the private key SK c Encrypt the rearranged data into ciphertext and send it to the blockchain for storage;

[0028] Model security reasoning module: used for model security reasoning, including convolutional layer reasoning, RLWE ciphertext to LWE ciphertext conversion, activation function layer reasoning, LWE ciphertext to RLWE ciphertext conversion and fully connected layer reasoning;

[0029] Upload model inference result module: used by the model service provider to upload the encrypted inference results to the blockchain;

[0030] Obtaining service results module: used by service demanders to obtain service results. Service demanders obtain the encrypted inference results from the blockchain and use their own private keys to decrypt them to obtain the inference results.

[0031] Result verification module: used for result verification. When the service demander (user or enterprise) has doubts about the inference results of the model service provider, the service demander can send a verification request to the authority, and the authority will send a request to obtain the private key to the service demander and the model service provider. After the authority obtains the private keys of both parties, it obtains the ciphertext model parameters and ciphertext data from the blockchain for decryption, performs plaintext model inference operations locally, and obtains the intermediate results and inference results from the blockchain for comparison to generate a verification report for verification by the service demander.

[0032] The above model security reasoning module includes the following steps when performing model security reasoning:

[0033] Convolutional layer reasoning: After receiving the reasoning request, the model service provider obtains the ciphertext data required for reasoning from the blockchain node and converts the model parameters into Figure 3 The ciphertext packing algorithm is used to pack the data. At the same time, the model service provider encodes its own model parameters using the public key of the service demander, and then performs a convolution operation. The convolution operation can be seen as the process of applying a set of filters to the input data. Each filter slides on the input data and calculates the weighted sum of the local area. We have arranged the ciphertext in this form in the ciphertext packing. This process can be seen as multiple multiplications and additions of the ciphertext. Assuming ct m It represents the ciphertext of an inference image after ciphertext packaging. It means there are M filters arranged in a specific order, means there are M biases arranged in a specific order, represents the operation result, and finally obtains M ciphertext calculation results; the following formula shows the convolution process of the i-th filter, where Roate represents the ciphertext rotation operation. After multiplication, multiple rotation accumulations will be performed, and the variable represents the number of rotation accumulations, according to 1, 2, 4... until log K*K :

[0034]

[0035] Conversion of RLWE ciphertext to LWE ciphertext: Although the RLWE ciphertext based on CKKS encryption can encrypt multiple data in one ciphertext to improve the operation efficiency, it cannot perform logical comparison operations. Therefore, we split the RLWE ciphertext, extract the ciphertext encoded in the polynomial, and obtain a set of LWE ciphertexts in FHEW encrypted form to perform activation function operations;

[0036] LWE encryption is defined as: in, represents the ring of integers modulo q, the key represents a vector of dimension n, each component in Inside, message a is a random vector, e is an error term randomly selected from the error distribution χ, n is the vector dimension, b is the inner product result, m is the message, T is the mathematical transpose, and its decryption is b+a T s≈m;

[0037] RLWE encryption is defined as: in The coefficient is In the range and the polynomial modulus X n +1 ring, The coefficient is In the range and the polynomial modulus X n +1 for the ring, key represents the polynomial key, represents the error polynomial with coefficients independently drawn from the error distribution χ, is a random polynomial;

[0038] We encrypt an RLWE ciphertext of CKKS as Where Δ refers to the scaling factor in CKKS encryption, v represents the encryption vector, and Symbol n, represents the dimension of the grid, and s, Representing the keys in different dimensions, each coding element in the ciphertext ct is extracted to obtain a set of LWE ciphertexts in FHEW encrypted form: Where l represents the encryption level, i∈ <l>It means that the index i is in a certain range, specifically, all values ​​in the range l. Then the lookup table T(x) of each LWE ciphertext is evaluated:

[0039] Activation function layer reasoning: We construct a binary comparison circuit for the obtained LWE ciphertext to implement the operation process of the activation function RELU, and finally we get the ciphertext operation result of the activation function;

[0040] Conversion from LWE ciphertext to RLWE ciphertext: After the activation function operation, when operating the next linear layer, the ciphertext type needs to be converted, a group of LWE ciphertexts are repackaged into a single RLWE ciphertext, and the encoding vector T(v) is encrypted:

[0041] Fully connected layer reasoning: The fully connected layer can be viewed as a special convolutional layer operation. We use a packing algorithm similar to the convolutional layer operation to perform fully connected layer operations.

[0042] Our system consists of the following entities:

[0043] 1. Service demanders: Service demanders refer to enterprises or individuals who have neural network reasoning needs and are responsible for data collection and preprocessing. Afterwards, the data is encrypted using the CKKS scheme and the ciphertext data is uploaded to the blockchain. The service demander is also responsible for receiving and decrypting the reasoning results.

[0044] 2. Model service providers: Model service providers own neural network models and computing resources and provide inference services. They obtain ciphertext data from the blockchain and upload model parameters, inference intermediate processes, and inference results to the blockchain in ciphertext during model inference.

[0045] 3. Blockchain nodes: Blockchain nodes are responsible for storing and managing information such as encrypted data, model parameters, and inference results, ensuring the integrity and immutability of all data and providing transparent and verifiable records.

[0046] 4. Authoritative institution: The authoritative institution is an honest entity. It is responsible for auditing and verifying the inference results. The authoritative institution holds the private keys of both parties, can decrypt the data and model parameters, re-execute the inference process, and feedback the audit results to the service demander to ensure the authenticity and credibility of the inference results.

[0047] A verifiable neural network security reasoning device based on homomorphic encryption and blockchain includes a processor and a memory, the memory stores a computer program, and when the computer program is executed by the processor, the verifiable neural network security reasoning method based on homomorphic encryption and blockchain is implemented.

[0048] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the above-mentioned verifiable neural network security reasoning method based on homomorphic encryption and blockchain.

[0049] The technologies not mentioned in the present invention are all referred to the prior art.

[0050] The present invention provides a verifiable neural network security reasoning method. In view of the problem that the existing homomorphic encryption scheme uses polynomial approximation when processing activation functions, resulting in reduced model accuracy and inability to verify the reasoning results, a solution based on blockchain technology and multiple homomorphic encryption schemes is proposed. The present invention ensures the reliability of the reasoning results while protecting the privacy and security of users. We improve the accuracy of model reasoning by using the mutual conversion method between RLWE (Ring Learning with Errors) ciphertext and LWE (Learning with Errors) ciphertext.

[0051] The present invention is based on a verifiable neural network security reasoning method based on homomorphic encryption and blockchain. It combines blockchain and multiple homomorphic encryption technologies, proposes a new ciphertext packaging algorithm to optimize reasoning efficiency, and uses a conversion method to avoid the polynomial approximation problem of the activation function, thereby improving the accuracy of model reasoning. At the same time, it protects user privacy and security, provides users with a verification function, and ensures the authenticity of the reasoning process and results. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 The overall flow chart of the invention for neural network security reasoning;

[0053] Figure 2 It is an overall flow chart of the verifiable function of the present invention;

[0054] Figure 3 The convolutional layer ciphertext packing method of the present invention; DETAILED DESCRIPTION

[0055] In order to better understand the present invention, the content of the present invention is further explained below in conjunction with the embodiments, but the content of the present invention is not limited to the following embodiments.

[0056] Example 1

[0057] In this example, we use the MNIST handwritten digit set as a dataset and build a three-layer neural network architecture, including a convolutional layer, an activation function layer, and a fully connected layer. The model has been trained using plain text. Figure 1 The entire security reasoning process is described. The neural network security reasoning method based on homomorphic encryption and blockchain includes the following steps:

[0058] Step 1: Initialization: Set the CKKS encryption parameters, where the degree of the polynomial module is set to 8192, and the modulus of the polynomial ring is set to {60, 40, 40, 60}. The scaling factor Δ is 40, and the user and the model service provider generate their own corresponding public and private keys.

[0059] Step 2: Data preprocessing and ciphertext packaging: For MNIST data, the corresponding size is 28*28 grayscale images. The image is standardized and normalized so that each pixel becomes a floating point number in the range of [0, 255]. We use the ciphertext packaging algorithm to reorganize the image arrangement order. Figure 3 Our ciphertext packing process is demonstrated. The specific process is: a 28*28 floating point matrix, we follow the pre-set convolution layer parameters, such as convolution kernel size, sliding step size, etc. The image is segmented according to the convolution kernel scanning order, and finally an image can obtain a set of matrices with the size of the convolution kernel and arranged in the sliding order of the convolution kernel. In the CKKS parameter setting, the degree of the polynomial module is 8192. CKKS will encode multiple data on the polynomial coefficients before encryption. Each polynomial coefficient that stores data is called a ciphertext slot. Due to the characteristics of CKKS, the degree of the polynomial module is 8192, which means that a ciphertext has 4096 ciphertext slots, and a ciphertext can encrypt 4096 plaintexts. For the matrix group obtained by segmentation, each matrix is ​​flattened, and the length of each matrix is ​​determined. If it does not meet 2 n Use 0 for padding, n is a positive integer. Finally, we get a set of tiled vectors arranged in the order of convolution kernel scanning. We encode these vectors into the ciphertext slot corresponding to a ciphertext. The ciphertext is packed. Finally, the ciphertext is stored in the blockchain node.

[0060] Step 3: Model Security Reasoning

[0061] Step 3.1: Convolutional layer reasoning: After receiving the reasoning request, the model server encodes its own model parameters using the user's public key. The encoding operation is to change the arrangement of model parameters so that it can better adapt to the ciphertext data that has been arranged and optimized by the ciphertext packing algorithm. For each convolution kernel parameter, match it according to the ciphertext length. According to the parameter setting, there are 4096 data in a ciphertext. Flatten the convolution kernel parameters to obtain a one-dimensional vector and fill its length with 0 to 2 n , and then copy and arrange the vector as a whole until the length is 4096. When performing the convolution layer reasoning operation, you only need to perform the multiplication operation of the data ciphertext and the encoded convolution kernel parameters, and then perform multiple rotation accumulation operations to get the convolution result. In Table 1, we show the reasoning time of ordinary security reasoning and using the ciphertext packing algorithm under the same CKKS encryption parameters using an MNIST image. This experiment was conducted under the same computer environment, using the SEAL4.0 homomorphic encryption library, with a convolution kernel size of 7*7 and a step size of (2, 2).

[0062] Table 1: Comparison of inference time using the ciphertext packing algorithm and the normal inference time

[0063]

[0064] Step 3.2: Convert RLWE ciphertext to LWE ciphertext: After the convolutional layer inference is completed, in an RLWE ciphertext, since the ciphertext slots in the ciphertext undergo a series of rotation and accumulation operations, only the elements at the specific ciphertext slot positions are the convolution results. We split an RLWE ciphertext to obtain a set of LWE ciphertexts, and extract the elements of the correct convolution results according to their specific positions. Some miscellaneous items are discarded, and finally a set of LWE ciphertexts are formed in the order of the convolution results.

[0065] LWE encryption is defined as: in, represents the ring of integers modulo q, the key represents a vector of dimension n, each component in Inside, message a is a random vector, e is an error term randomly selected from the error distribution χ, n is the vector dimension, b is the inner product result, m is the message, T is the mathematical transpose, and its decryption is b+a T s≈m;

[0066] RLWE encryption is defined as: in The coefficient is In the range and the polynomial modulus X n +1 ring, The coefficient is In the range and the polynomial modulus X n +1 for the ring, key represents the polynomial key, represents the error polynomial with coefficients independently drawn from the error distribution χ, is a random polynomial;

[0067] We encrypt an RLWE ciphertext of CKKS as Where Δ refers to the scaling factor in CKKS encryption, v represents the encryption vector, and Symbol n, represents the dimension of the grid, and Representing the keys in different dimensions, each coding element in the ciphertext ct is extracted to obtain a set of LWE ciphertexts in FHEW encrypted form: Where l represents the encryption level, i∈ <l>It means that the index i is in a certain range, specifically, all values ​​in the range l. Then the lookup table T(x) of each LWE ciphertext is evaluated:

[0068] Step 3.3: Activation function layer reasoning: We use the Relu function as the activation function. After converting the RLWE type ciphertext of CKKS to the LWE type ciphertext of FHEW. According to the characteristics of the Relu function: F(x) = Max(0, x). Using the FHEW Boolean circuit function to implement the size comparison operation, the real Relu activation function operation can be realized in the encryption environment to avoid polynomial approximation.

[0069] Step 3.4: Convert LWE ciphertext to RLWE ciphertext: After the activation function operation, when operating the next linear layer, the ciphertext type needs to be converted, a group of LWE ciphertexts are repackaged into a single RLWE ciphertext, and the encoding vector T(v) is encrypted:

[0070] Step 3.5: Fully connected layer reasoning: In the fully connected layer, we can regard it as a special convolution operation. After the activation function operation, the reorganized RLWE ciphertext is a ciphertext vector flattened in the order of the results. The model holder only needs to encode the fully connected parameters, and can obtain the fully connected layer reasoning results through one multiplication and multiple rotations. Table 2 shows the plaintext reasoning accuracy of our neural network structure on the MNIST dataset, the reasoning accuracy of the CKKS encryption scheme, and the reasoning accuracy of the hybrid homomorphic encryption scheme we proposed.

[0071] Table 2 Comparison of inference accuracy

[0072] Dataset Plaintext reasoning CKKS Program Hybrid Homomorphic Encryption Scheme MNIST 98.96% 98.59% 98.92%

[0073] Step 4: Upload model inference results: The model service provider sends the inference results to the blockchain for storage.

[0074] Step 5: The user obtains the service result. The user obtains the ciphertext result from the blockchain and decrypts it using his own private key to obtain the inference result.

[0075] Step 6: Result verification. Figure 2 As shown in the figure, when the user has doubts about the inference result, he can send a verification request to the authority. The authority will request the private keys of both the user and the model service provider, and obtain the ciphertext data, model parameters, and inference intermediate result record information and inference results from the blockchain. Then, the authority uses the corresponding private key to decrypt the ciphertext data and model parameters. The model parameters are inherited locally for plaintext inference, and the intermediate results are recorded for comparison. At the same time, an inference information report is generated to verify whether the intermediate process and results of the inference are true and valid. After the inference is completed, the authority organizes the report and sends it to the user.

[0076] Example 2

[0077] A verifiable neural network security reasoning system based on homomorphic encryption and blockchain, including:

[0078] Initialization module: used by the service demander and the model service provider to generate the public key and private key of the CKKS encryption scheme locally; the public key and private key of the service demander are recorded as PK c , S.K. c , the model server is recorded as PK s , S.K. s ;

[0079] Data processing and ciphertext packaging module: used for data processing and ciphertext packaging. The service demander pre-processes the collected images and converts them into matrix data. In view of the SIMD characteristics of CKKS, multiple data are packaged into one ciphertext for operation. By arranging the data before encryption, the operation efficiency is improved and the model reasoning is accelerated. Then the private key SK is used. c Encrypt the rearranged data into ciphertext and send it to the blockchain for storage;

[0080] Model security reasoning module: used for model security reasoning, including convolutional layer reasoning, RLWE ciphertext to LWE ciphertext conversion, activation function layer reasoning, LWE ciphertext to RLWE ciphertext conversion and fully connected layer reasoning;

[0081] Convolutional layer reasoning: After receiving the reasoning request, the model service provider obtains the ciphertext data to be inferred from the blockchain node and ciphertext-packs the model parameters. At the same time, the model service provider encodes its own model parameters using the public key of the service demander, and then performs a convolution operation. The convolution operation is the process of applying a set of filters to the input data. Each filter slides on the input data and calculates the weighted sum of the local area. The ciphertext has been arranged in this form in the ciphertext packing. This process can be regarded as multiple multiplications and additions of the ciphertext. Assuming ct m It represents the ciphertext of an inference image after ciphertext packaging. It means there are M filters arranged in a specific order, means there are M biases arranged in a specific order, represents the operation result, and finally obtains M ciphertext calculation results; the following formula shows the convolution process of the i-th filter, where Roate represents the ciphertext rotation operation. After multiplication, multiple rotation accumulations are performed, and the variable represents the number of rotation accumulations, according to 1, 2, 4... until log K*K :

[0082]

[0083] RLWE ciphertext to LWE ciphertext conversion: split the RLWE ciphertext, extract the ciphertext encoded in the polynomial, and obtain a set of LWE ciphertexts in FHEW encrypted form to perform activation function operations;

[0084] LWE encryption is defined as: in, represents the ring of integers modulo q, the key represents a vector of dimension n, each component in Inside, message a is a random vector, e is an error term randomly selected from the error distribution χ, n is the vector dimension, b is the inner product result, m is the message, T is the mathematical transpose, and its decryption is b+a T s≈m;

[0085] RLWE encryption is defined as: in Indicates that the coefficients are within the range Z and the polynomial modulus X n +1 ring, The coefficient is In the range and the polynomial modulus X n +1 for the ring, key represents the polynomial key, represents the error polynomial with coefficients independently drawn from the error distribution χ, is a random polynomial;

[0086] An RLWE ciphertext encrypted by CKKS is denoted as Where Δ refers to the scaling factor in CKKS encryption, v represents the encryption vector, and Symbol n, represents the dimension of the grid, and s, Representing the keys in different dimensions, each coding element in the ciphertext ct is extracted to obtain a set of LWE ciphertexts in FHEW encrypted form: Where l represents the level of encryption; then the lookup table T(x) of each LWE ciphertext is evaluated:

[0087]

[0088] Activation function layer reasoning: construct a binary comparison circuit for the obtained LWE ciphertext to implement the operation process of the activation function RELU, and finally obtain the ciphertext operation result of the activation function;

[0089] Conversion from LWE ciphertext to RLWE ciphertext: After the activation function operation, when operating the next linear layer, the ciphertext type needs to be converted, a group of LWE ciphertexts are repackaged into a single RLWE ciphertext, and the encoding vector T(v) is encrypted:

[0090] Fully connected layer reasoning: The fully connected layer is a special convolutional layer operation, which uses a packing algorithm similar to the convolutional layer operation to perform the fully connected layer operation.

[0091] Upload model inference result module: used by the model service provider to upload the encrypted inference results to the blockchain;

[0092] Obtaining service results module: used by service demanders to obtain service results. Service demanders obtain the encrypted inference results from the blockchain and use their own private keys to decrypt them to obtain the inference results.

[0093] Result verification module: used for result verification. When the service demander has doubts about the inference results of the model service provider, the service demander sends a verification request to the authority, and the authority sends a request to obtain the private key to the service demander and the model service provider. After the authority obtains the private keys of both parties, it obtains the ciphertext model parameters and ciphertext data from the blockchain for decryption, performs plaintext model inference operations locally, and obtains the intermediate results and inference results from the blockchain for comparison to generate a verification report for verification by the service demander.

[0094] The present invention ensures the reliability of the inference results while protecting the privacy of users. We avoid the problem of polynomial approximation of activation functions by using the mutual conversion method between RLWE (Ring Learning with Errors) ciphertext and LWE (Learning with Errors) ciphertext, and improve the accuracy and efficiency of model inference. At the same time, it protects the privacy of users, provides users with verification functions, and ensures the authenticity of the inference process and results.< / l> < / l> < / l>

Claims

1. A verifiable neural network security reasoning method based on homomorphic encryption and blockchain, characterized by: The steps include: Step 1: Initialization: The service demander and the model service provider generate the public key and private key of the CKKS encryption scheme locally; the public key and private key of the service demander are recorded as PK c , S.K. c , the model server is recorded as PK s , S.K. s ; Step 2: Data processing and ciphertext packaging: The service demander pre-processes the collected images and converts them into matrix data. In view of the SIMD feature of CKKS, multiple data are packaged into one ciphertext for operation. By arranging the data before encryption, the operation efficiency is improved and the model reasoning is accelerated. Then the private key SK is used. c Encrypt the rearranged data into ciphertext data and send it to the blockchain for storage; Step 3: Model security reasoning: including convolutional layer reasoning, RLWE ciphertext to LWE ciphertext conversion, activation function layer reasoning, LWE ciphertext to RLWE ciphertext conversion and fully connected layer reasoning; Step 4: Upload model inference results: The model service provider uploads the encrypted inference results to the blockchain; Step 5: The service demander obtains the service result: The service demander obtains the encrypted inference result from the blockchain and decrypts it using its own private key to obtain the inference result; Step 6: Result verification: When the service demander has doubts about the inference results of the model service provider, the service demander sends a verification request to the authority, and the authority sends a request to obtain the private key to the service demander and the model service provider; when the authority obtains the private keys of both parties, it obtains the ciphertext model parameters and ciphertext data from the blockchain for decryption, performs plaintext model inference operations locally, and obtains the intermediate results and inference results from the blockchain for comparison to generate a verification report for verification by the service demander.

2. The verifiable neural network security reasoning method based on homomorphic encryption and blockchain as claimed in claim 1, characterized in that: Step 3: Model security reasoning includes: Step 3.1: Convolutional layer reasoning: After receiving the reasoning request, the model service provider obtains the ciphertext data to be inferred from the blockchain node and ciphertext packages the model parameters. At the same time, the model service provider encodes its own model parameters using the public key of the service demander, and then performs a convolution operation. The convolution operation is the process of applying a set of filters to the input data. Each filter slides on the input data and calculates the weighted sum of the local area. The ciphertext has been arranged in this form in the ciphertext packaging. This process can be regarded as multiple multiplications and additions of the ciphertext. Assuming ct m It represents the ciphertext of an inference image after ciphertext packaging. It means there are M filters arranged in a specific order, means there are M biases arranged in a specific order, represents the operation result, and finally obtains M ciphertext calculation results; the following formula shows the convolution process of the i-th filter, where Roate represents the ciphertext rotation operation. After multiplication, multiple rotation accumulations are performed, and the variable represents the number of rotation accumulations, according to 1, 2, 4... until log K*K : Step 3.2: Convert RLWE ciphertext to LWE ciphertext: split the RLWE ciphertext, extract the ciphertext encoded in the polynomial, and obtain a set of LWE ciphertexts in FHEW encrypted form to perform activation function operations; LWE encryption is defined as: in, represents the ring of integers modulo q, the key represents a vector of dimension n, each component in Inside, message a is a random vector, e is an error term randomly selected from the error distribution / , n is the vector dimension, b is the inner product result, m is the message, T is the mathematical transpose, and its decryption is b+a T s≈m; RLWE encryption is defined as: in The coefficient is In the range and the polynomial modulus X n +1 ring, The coefficient is In the range and the polynomial modulus X n +1 for the ring, key represents the polynomial key, represents the error polynomial with coefficients independently drawn from the error distribution x, is a random polynomial; An RLWE ciphertext encrypted by CKKS is recorded as Where Δ refers to the scaling factor in CKKS encryption, v represents the encryption vector, and Symbol n, represents the dimension of the grid, and s, Representing the keys in different dimensions, each coding element in the ciphertext ct is extracted to obtain a set of LWE ciphertexts in FHEW encrypted form: Where l represents the level of encryption; then the lookup table T(x) of each LWE ciphertext is evaluated: Step 3.3: Activation function layer reasoning: construct a binary comparison circuit for the obtained LWE ciphertext to implement the operation process of the activation function RELU, and finally obtain the ciphertext operation result of the activation function; Step 3.4: Convert LWE ciphertext to RLWE ciphertext: After the activation function operation, when operating the next linear layer, the ciphertext type needs to be converted, a group of LWE ciphertexts are repackaged into a single RLWE ciphertext, and the encoding vector T(v) is encrypted: Step 3.5: Fully connected layer reasoning: The fully connected layer is a special convolutional layer operation, and a packing algorithm similar to the convolutional layer operation is used for the fully connected layer operation.

3. A verifiable neural network security reasoning system based on homomorphic encryption and blockchain, characterized by: include: Initialization module: used by the service demander and the model service provider to generate the public key and private key of the CKKS encryption scheme locally; the public key and private key of the service demander are recorded as PK c , S.K. c , the model server is recorded as PK s , S.K. s ; Data processing and ciphertext packaging module: used for data processing and ciphertext packaging. The service demander pre-processes the collected images and converts them into matrix data. In view of the SIMD characteristics of CKKS, multiple data are packaged into one ciphertext for operation. By arranging the data before encryption, the operation efficiency is improved and the model reasoning is accelerated. Then the private key SK is used. e , encrypt the rearranged data into ciphertext and send it to the blockchain for storage; Model security reasoning module: used for model security reasoning, including convolutional layer reasoning, RLWE ciphertext to LWE ciphertext conversion, activation function layer reasoning, LWE ciphertext to RLWE ciphertext conversion and fully connected layer reasoning; Upload model inference result module: used by the model service provider to upload the encrypted inference results to the blockchain; Obtaining service results module: used by service demanders to obtain service results. Service demanders obtain the encrypted inference results from the blockchain and use their own private keys to decrypt them to obtain the inference results. Result verification module: used for result verification. When the service demander has doubts about the inference results of the model service provider, the service demander sends a verification request to the authority, and the authority sends a request to obtain the private key to the service demander and the model service provider. After the authority obtains the private keys of both parties, it obtains the ciphertext model parameters and ciphertext data from the blockchain for decryption, performs plaintext model inference operations locally, and obtains the intermediate results and inference results from the blockchain for comparison to generate a verification report for verification by the service demander.

4. The verifiable neural network security reasoning system based on homomorphic encryption and blockchain as claimed in claim 3, characterized in that: The model security reasoning module includes the following steps when performing model security reasoning: Convolutional layer reasoning: After receiving the reasoning request, the model service provider obtains the ciphertext data to be inferred from the blockchain node and ciphertext packages the model parameters. At the same time, the model service provider encodes its own model parameters using the public key of the service demander, and then performs a convolution operation. The convolution operation is the process of applying a set of filters to the input data. Each filter slides on the input data and calculates the weighted sum of the local area. The ciphertext has been arranged in this form in the ciphertext packaging. This process can be regarded as multiple multiplications and additions of the ciphertext. Assuming ct m It represents the ciphertext of an inference image after ciphertext packaging. It means there are M filters arranged in a specific order, means there are M biases arranged in a specific order, represents the operation result, and finally obtains M ciphertext calculation results; the following formula shows the convolution process of the i-th filter, where Roate represents the ciphertext rotation operation. After multiplication, multiple rotation accumulations are performed, and the variable represents the number of rotation accumulations, according to 1, 2, 4... until log K*K : RLWE ciphertext to LWE ciphertext conversion: split the RLWE ciphertext, extract the ciphertext encoded in the polynomial, and obtain a set of LWE ciphertexts in FHEW encrypted form to perform activation function operations; LWE encryption is defined as: in, represents the ring of integers modulo q, the key represents a vector of dimension n, each component in Inside, message a is a random vector, e is an error term randomly selected from the error distribution / , n is the vector dimension, b is the inner product result, m is the message, T is the mathematical transpose, and its decryption is b+a T s≈m; RLWE encryption is defined as: in The coefficient is In the range and the polynomial modulus X n +1 ring, The coefficient is In the range and the polynomial modulus X n +1 for the ring, key represents the polynomial key, represents the error polynomial with coefficients independently drawn from the error distribution χ, is a random polynomial; An RLWE ciphertext encrypted by CKKS is denoted as Where Δ refers to the scaling factor in CKKS encryption, v represents the encryption vector, and Symbol n, represents the dimension of the grid, and s, Representing the keys in different dimensions, each coding element in the ciphertext ct is extracted to obtain a set of LWE ciphertexts in FHEW encrypted form: Where l represents the level of encryption; then the lookup table T(x) of each LWE ciphertext is evaluated: Activation function layer reasoning: construct a binary comparison circuit for the obtained LWE ciphertext to implement the operation process of the activation function RELU, and finally obtain the ciphertext operation result of the activation function; Conversion from LWE ciphertext to RLWE ciphertext: After the activation function operation, when operating the next linear layer, the ciphertext type needs to be converted, a group of LWE ciphertexts are repackaged into a single RLWE ciphertext, and the encoding vector T(v) is encrypted: Fully connected layer reasoning: The fully connected layer is a special convolutional layer operation, which uses a packing algorithm similar to the convolutional layer operation to perform the fully connected layer operation.

5. A verifiable neural network security reasoning device based on homomorphic encryption and blockchain, characterized in that: The method comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the method according to claim 1 or 2 is implemented.

6. A computer-readable storage medium, characterized in that: A computer program is stored, and when the computer program is executed by a processor, the method according to claim 1 or 2 is implemented.

Citation Information

Patent Citations

  • High-performance fully homomorphic encryption processor circuit based on RLWE encryption scheme

    CN114172629A

  • Universal privacy calculation method and device based on fully homomorphic encryption, equipment and medium

    CN116846535A

  • Secure multi-party computing fusion method and system based on block chain

    CN117370927A

  • Public verifiable privacy protection SVM classification method

    CN118074942A