CN117349868B - Fully homomorphic encryption and decryption method based on GPU, electronic equipment and storage medium - Google Patents

Fully homomorphic encryption and decryption method based on GPU, electronic equipment and storage medium Download PDF

Info

Publication number
CN117349868B
CN117349868B CN202311641868.5A CN202311641868A CN117349868B CN 117349868 B CN117349868 B CN 117349868B CN 202311641868 A CN202311641868 A CN 202311641868A CN 117349868 B CN117349868 B CN 117349868B
Authority
CN
China
Prior art keywords
video memory
gpu
data
ciphertext
task
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311641868.5A
Other languages
Chinese (zh)
Other versions
CN117349868A (en
Inventor
李其睿
幺宝刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
International Digital Economy Academy IDEA
Original Assignee
International Digital Economy Academy IDEA
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by International Digital Economy Academy IDEA filed Critical International Digital Economy Academy IDEA
Priority to CN202311641868.5A priority Critical patent/CN117349868B/en
Publication of CN117349868A publication Critical patent/CN117349868A/en
Application granted granted Critical
Publication of CN117349868B publication Critical patent/CN117349868B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • G06F21/6245Protecting personal data, e.g. for financial or medical purposes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/008Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols involving homomorphic encryption

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Security & Cryptography (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Medical Informatics (AREA)
  • Databases & Information Systems (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Storage Device Security (AREA)

Abstract

The application discloses a full homomorphic encryption and decryption method, electronic equipment and storage medium based on a GPU, wherein the full homomorphic encryption and decryption method based on the GPU comprises the following steps: acquiring algorithm parameters, and generating context parameters and a secret key through a preset generator; encoding and encrypting plaintext data to be processed based on a preset encoder, the algorithm parameter, the context parameter and the secret key to obtain ciphertext data; according to the user-defined calculation task, calculating the ciphertext data to obtain a ciphertext calculation result; and decrypting and anti-coding the ciphertext calculation result to obtain target plaintext data. According to the technical scheme, the GPU is combined to cover the full computing process of homomorphic encryption and decryption, and the execution efficiency of the privacy computing process is improved.

Description

Fully homomorphic encryption and decryption method based on GPU, electronic equipment and storage medium
Technical Field
The application relates to the technical field of data processing, in particular to a full homomorphic encryption and decryption method based on a Graphic Processing Unit (GPU), electronic equipment and a storage medium.
Background
With the continuous development and progress of digital technology, the importance of data in modern society is also increasing. The data volume corresponding to each of the enterprise, the organization, the user, and the like is increasing. Therefore, the requirement on privacy is also higher and higher, and the calculation paradigm of privacy calculation is to effectively process and analyze the data on the premise of ensuring the data privacy.
Homomorphic encryption (Fully Homomorphic Encryption, FHE) is an important encryption calculation means in privacy calculation, can directly calculate encrypted data without prior decryption, and can ensure the privacy and information security of the data needing calculation processing. However, since the arithmetic and logic operations involved in the calculation process are performed on the ciphertext, the calculation complexity of the homomorphic encryption method is far higher than that of the direct processing of plaintext data, and therefore, the calculation delay generated in the processes of large-scale data analysis and real-time data processing can affect the overall calculation efficiency and service experience.
The above information disclosed in this background section is only for the understanding of the background of the present application and, therefore, it may contain information that does not constitute prior art.
Disclosure of Invention
The main purpose of the application is to provide a full homomorphic encryption and decryption method, electronic equipment and a computer storage medium based on a GPU, aiming at improving the execution efficiency of a full homomorphic encryption and decryption calculation flow.
In order to achieve the above object, the present application provides a GPU-based isomorphic encryption and decryption method, which is applied to a GPU, and includes:
Acquiring algorithm parameters, and generating context parameters and a secret key through a preset generator;
encoding and encrypting plaintext data to be processed based on a preset encoder, the algorithm parameter, the context parameter and the secret key to obtain ciphertext data;
according to the user-defined calculation task, calculating the ciphertext data to obtain a ciphertext calculation result;
and decrypting and anti-coding the ciphertext calculation result to obtain target plaintext data.
Optionally, after the step of obtaining the algorithm parameter, the method further comprises:
calculating the first video memory space capacity according to the modular chain length in the algorithm parameters;
determining a pre-allocation video memory pool capacity according to the first video memory space capacity and the available video memory space capacity of the GPU;
and dividing a pre-allocation video memory pool from the available video memory space capacity based on the pre-allocation video memory capacity.
Optionally, the full homomorphic encryption and decryption method based on the GPU further comprises the following steps:
creating a video memory manager, and constructing a video memory management index in the video memory manager;
and updating a key value in the video memory management index when the video memory space of the pre-allocated video memory pool is allocated, wherein the key value of the video memory management index is used for representing the capacity of the allocated video memory space.
Optionally, the full homomorphic encryption and decryption method based on the GPU further comprises the following steps:
when the video memory manager receives a video memory allocation task, acquiring the required capacity corresponding to the video memory allocation task, and judging whether a first key value with the capacity consistent with the required capacity exists in the video memory management index;
if the first key value exists, inquiring whether a pointer array corresponding to the first key value is empty or not;
if the pointer array is not empty, allocating the video memory space corresponding to the pointer array to the video memory allocation task;
and if the first key value does not exist or the pointer array is empty, dividing the video memory space with the required capacity from the pre-allocation video memory pool, and allocating tasks to the video memory.
Optionally, the step of encoding and encrypting the plaintext data to be processed based on the preset encoder, the algorithm parameter, the context parameter and the key to obtain ciphertext data includes:
acquiring plaintext data to be processed from a host end, and calling a preset encoder to encode the plaintext data to be processed to obtain polynomial data;
and encrypting the polynomial data according to the algorithm parameters, the context parameters and the secret key to obtain ciphertext data.
Optionally, before the step of performing calculation processing on the ciphertext data according to the custom calculation task, the method further includes:
generating polynomial coefficients according to the ciphertext data;
combining the polynomial coefficients to obtain an overall polynomial;
decomposing the whole polynomial through an RNS layer to obtain a plurality of higher-order polynomials;
and combining the higher order polynomials to generate the password layer data.
Optionally, the step of performing calculation processing on the ciphertext data according to the custom calculation task to obtain a ciphertext calculation result includes:
acquiring a user-defined computing task input by a user, wherein the user-defined computing task comprises a plurality of subtasks;
setting a first subtask in the custom computing task as a current computing task and setting the ciphertext data as input data;
selecting an operator corresponding to the current calculation task, performing operation processing on the ciphertext data through the operator, and outputting a ciphertext calculation result;
if the current computing task is not the last subtask, setting the ciphertext computing result as input data, setting the next subtask as the current computing task, and returning to the executing step: selecting an operator corresponding to the current calculation task, and performing operation processing on the ciphertext data through the operator until all subtasks are executed.
Optionally, the operators at least comprise one of a base layer operator, an intermediate layer operator and an upper layer operator;
wherein the base layer operator is used for performing at least one operation of modular multiplication, modular division, modular and number theory transformation;
the middle layer operator is used for calling the base layer operator and executing at least one operation of FHE calculation and modulo and truncation of RNS decomposition;
the upper layer operator is used for calling the base layer operator and the middle layer operator and is used for executing at least one operation of adding, multiplying, rotating, re-linearizing and scaling of ciphertext.
The application also provides a full homomorphic encryption and decryption device based on the GPU, the full homomorphic encryption and decryption device based on the GPU comprises:
the parameter acquisition module is used for acquiring algorithm parameters and generating context parameters and keys through a preset generator;
the coding encryption module is used for coding and encrypting plaintext data to be processed based on a preset coder, the algorithm parameter, the context parameter and the secret key to obtain ciphertext data;
the data calculation module is used for carrying out calculation processing on the ciphertext data according to the user-defined calculation task to obtain a ciphertext calculation result;
And the data decryption module decrypts and de-encodes the ciphertext calculation result to obtain target plaintext data.
The application also provides an electronic device, which is an entity device, and includes: the system comprises a memory, a processor and a program of the full homomorphic encryption and decryption method based on the GPU, wherein the program of the full homomorphic encryption and decryption method based on the GPU is stored in the memory and can run on the processor, and the program of the full homomorphic encryption and decryption method based on the GPU can realize the steps of the full homomorphic encryption and decryption method based on the GPU when being executed by the processor.
The application also provides a computer readable storage medium, on which a program for implementing the GPU-based isohomomorphic encryption and decryption method is stored, where the program for implementing the GPU-based isomorphic encryption and decryption method is executed by a processor to implement the steps of the GPU-based isomorphic encryption and decryption method.
The present application also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the GPU-based isomorphic encryption and decryption method described above.
The application provides a full homomorphic encryption and decryption method, electronic equipment and a computer readable storage medium based on a GPU, wherein the full homomorphic encryption and decryption method based on the GPU is applied to the GPU, algorithm parameters are firstly obtained, context parameters and secret keys are generated through a preset generator, then plaintext data to be processed are encoded and encrypted based on a preset encoder, the algorithm parameters, the context parameters and the secret keys to obtain ciphertext data, then according to a user-defined calculation task, the ciphertext data is calculated and processed to obtain ciphertext calculation results, and finally the ciphertext calculation results are decrypted and de-encoded to obtain target plaintext data. In the technical scheme, the processes of encryption and decryption, encoding and decryption, logic calculation and the like of plaintext data are all executed by the GPU, and the homomorphic encryption calculation logic has a good acceleration effect due to the high parallelization characteristic of the GPU, so that the execution efficiency of the homomorphic encryption and decryption whole flow is greatly improved. In addition, the whole process of the technical scheme is executed on the GPU, and high time-consuming operations such as data copying and data transferring are not involved in the middle, so that the computing efficiency of the full process of full homomorphic encryption and decryption is further improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the technical solutions of the present embodiment or the prior art, the drawings used in the description of the embodiment or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a schematic flow chart of a first embodiment of a GPU-based isomorphic encryption and decryption method of the present application;
FIG. 2 is a schematic diagram of a GPU-based acceleration computation flow in a first embodiment of a full homomorphic encryption and decryption method of the present application;
FIG. 3 is a schematic diagram of GPU video memory management logic in a first embodiment of a GPU-based full-homomorphic encryption and decryption method;
fig. 4 is a schematic block diagram of a full homomorphic encryption and decryption device based on a GPU according to an embodiment of the present application;
fig. 5 is a schematic device structure diagram of a hardware operating environment related to the electronic device in this embodiment.
The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings in conjunction with the embodiments.
Detailed Description
In order to make the above objects, features and advantages of the present application more comprehensible, the following description will make the technical solutions of the embodiments of the present application clear and complete with reference to the accompanying drawings of the embodiments of the present application. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present application. All other embodiments, based on the embodiments herein, which are within the scope of the protection of the present application, will be within the purview of one of ordinary skill in the art without the exercise of inventive faculty.
Example 1
In the technical field, the fully homomorphic encryption calculation has higher security, so that the privacy and the security of data can be ensured, but the high security is at the expense of calculation efficiency. In particular, both the arithmetic and logical operations involved in the FHE computation process are performed on a ciphertext basis, which results in significantly more computational complexity than the direct processing of plaintext data. In many practical applications, such as large-scale data analysis and real-time data processing, this computational delay can become a significant bottleneck, affecting the overall service experience and efficiency. In order to overcome the above technical problems, it is important to accelerate the calculation by special hardware. Obviously, it is difficult for a conventional central processing unit (CPU, central Processing Unit) to meet the computational requirements of high parallelism in homomorphic encryption. In contrast, graphics processing units (GPUs, graphics processing unit) are ideal hardware environments for performing fully homomorphic encryption computational flows due to their highly parallel computing power and powerful floating point computing capabilities. The GPU can process a large amount of calculation tasks simultaneously, which is very consistent with the requirements of large-scale vector and polynomial operation in FHE, and can bring about remarkable performance improvement for FHE. Based on the above requirements, the technical scheme of the embodiment of the application optimizes the isomorphic encryption by combining the GPU acceleration technology so as to improve the execution efficiency of the FHE calculation flow, and provides better service experience for users in the scene with higher requirements on large-scale data analysis and real-time.
Referring to fig. 1, the present embodiment provides a GPU-based isomorphic encryption and decryption method, which is applied to a GPU, and includes:
step S10, acquiring algorithm parameters, and generating context parameters and a secret key through a preset generator;
in this embodiment of the present application, the algorithm parameters are set by the user in a user-defined manner according to the requirements, where the algorithm parameters include types of FHE algorithms, such as CKKS algorithm, BFV algorithm, or BGV algorithm, and in addition, the algorithm parameters further include a modular chain length. After the algorithm parameters set by the user are obtained, the required GPU video memory size can be predicted according to the algorithm parameters, so that space allocation is facilitated. In addition, the preset generator includes a preset Context generator and a key generator, both of which are stored in the GPU, and when executing step S10, the preset Context generator is called to generate a Context on the GPU display memory, and the key generator is called to generate a key on the GPU display memory, where the key may include a private key Sk, a public key Pk, and a re-linearization key Galois key. The method mainly comprises the steps of acquiring algorithm parameters input by a user before formally encoding and encrypting the plaintext data, generating Context parameters and keys in advance, preparing for the next calculation flow, and distributing exclusive video memories of the GPU for the Context parameters Context and various keys to store the data required by the Context parameters Context and various keys. It should be noted that, the whole execution process is executed in the GPU video memory, and data transmission, movement, copying or copying with other storage devices is not involved, so that the execution efficiency is further improved.
Step S20, coding and encrypting plaintext data to be processed based on a preset coder, the algorithm parameter, the context parameter and the secret key to obtain ciphertext data;
in this embodiment of the present application, it should be noted that, first, plaintext data prepared by a user needs to be acquired, for example, the user may input or call the plaintext data prepared in advance and needing to be processed by calculation at the host end, then call the encoder to encode the plaintext data to obtain a mapped polynomial, allocate a video memory space for the polynomial in the GPU, store the video memory space in the GPU, further call the encryption algorithm type, the context parameter and the secret key in the algorithm parameter, encrypt and calculate the polynomial, and output encrypted ciphertext data ce_input.
Step S30, calculating the ciphertext data according to a user-defined calculation task to obtain a ciphertext calculation result;
in this embodiment of the present application, the custom computing task is a computing task that is set by a user at a host side according to a requirement of the present data processing, where the custom computing task may include a plurality of subtasks, and the subtasks are all executed on a GPU video memory, and the plurality of subtasks in the custom computing task sequentially perform computing processing on the ciphertext data ce_input, so as to finally obtain a ciphertext computing result ce_output after the computing processing is completed. When executing each different subtask, a proper operator is required to be selected to operate the ciphertext according to different subtask types, wherein the mapping relation between the subtask and the operator can be determined through a mapping table preset by a user, and can also be manually set by the user, so that the calculation processing efficiency of ciphertext data is improved.
The method for computing and processing the ciphertext data Ce_input by selecting a proper operator comprises all operations supported by isomorphic encryption such as modulo addition, modulo subtraction, modulo formation, modulo lifting, modulo dropping, re-linearization, rotation, inversion and the like.
In the execution process of step S30, the subtask loop in the custom computing task performs an operation process on the ciphertext data, which specifically includes that firstly, the first subtask performs an operation on the input ciphertext data ce_input to obtain output data ce_output, then the output data ce_output is set as input data ce_input, the second subtask performs an operation on the input data to obtain output data, and the output data loop in turn until all the subtasks are executed, and finally the obtained output data is set as ciphertext computing result.
And S40, decrypting and anti-coding the ciphertext calculation result to obtain target plaintext data.
It can be understood that after the processed ciphertext calculation result is obtained, a decryption algorithm in the GPU is called to decrypt and de-encode the ciphertext calculation result, so as to obtain plaintext data for subsequent viewing and retrieval by a user. When the ciphertext calculation result is decrypted and reversely encoded, algorithm parameters, context parameters and keys used when the plaintext data is encoded and encrypted are still called, which are equivalent to the inverse process of encoding and encrypting, in addition, decoding algorithms corresponding to the algorithm types in the algorithm parameters are needed, and the decryption and reverse encoding methods applied to the GPU have the beneficial effect of accelerating the calculation efficiency of the decryption process.
Specifically, step S40 includes invoking a decryption algorithm on the GPU to decrypt the ciphertext ce_output1 finally obtained in S30 into a plaintext polynomial de_output1, and further invoking an inverse encoder to inverse-encode the result of the polynomial de_output1 into the target plaintext data. After the target plaintext data is obtained, the target plaintext data can be copied to the host end for viewing and subsequent use in response to a copy instruction input by a user, wherein the target plaintext data is the plaintext data required by the user after homomorphic encryption processing is performed on the plaintext data to be processed.
In the technical scheme of the embodiment of the application, unless the manual intervention is performed, all data flows in all calculation processes are performed in the video memory of the GPU, all calculation operations are performed on the GPU, and the process of copying data from the equipment end to the host end is not involved in the calculation processes.
For example, referring to fig. 2, the GPU-based full homomorphic encryption and decryption method in the embodiment of the application may include: firstly, setting parameters by a user, and generating a context in a GPU; encoding and encrypting plaintext data prepared by a user to obtain ciphertext data, further performing accelerated calculation through a GPU (graphics processing unit) to perform calculation processing on the ciphertext data, then performing data decryption and decoding to obtain target plaintext data, and finally copying the obtained target plaintext data from the GPU to a host end.
In a possible embodiment, after the step of obtaining the algorithm parameter, the method may further include:
step S11, calculating a first video memory space capacity according to the modular chain length in the algorithm parameters;
step S12, determining the capacity of a pre-allocation video memory pool according to the first video memory space capacity and the available video memory space capacity of the GPU;
and step S13, dividing a pre-allocation video memory pool from the available video memory space capacity based on the pre-allocation video memory capacity.
In the embodiment of the application, in order to make the running efficiency of the whole execution process of the full homomorphic encryption and decryption method in the GPU higher, the allocation of the video memory space is efficient and orderly, an effective video memory space allocation method is provided, the performance loss caused by memory allocation and release is greatly reduced, so that the video memory allocation speed and the use efficiency in the calculation process are improved, and the overall execution speed is improved.
Specifically, in step S11, the first video memory space capacity may be calculated by substituting the modulo-chain length into a preset space calculation function, where the preset space calculation function may be pool_size=f (L) =1024×1024×max (5, L), L is the modulo-chain length, pool_size is the first video memory space capacity, i.e. the expected required video memory space capacity, and the max function takes a larger value for both.
Further, in step S12, the capacity of the pre-allocated video memory pool is a space capacity corresponding to the pre-allocated video memory pool to be allocated, and the specific calculation function is: size_pool=min (pool_size, size_available) where the Min function is to take both smaller values and size_pool is the pre-allocated memory Pool capacity. That is, in step S12, the smaller space capacity of the first video memory space capacity and the available video memory space capacity is selected as the video memory space capacity corresponding to the pre-allocated video memory pool, so as to satisfy the video memory space required in the subsequent calculation process.
After the pre-allocation memory capacity is determined, a pre-allocation memory pool with the pre-allocation memory capacity can be divided from the remaining available memory space capacity of the current GPU, wherein the pre-allocation memory pool is used for allocating memory spaces for tasks corresponding to coding, encryption, calculation, decryption and anti-coding respectively, namely, memory tools required in the subsequent calculation process are all called from the pre-allocation memory pool.
In the embodiment of the application, the pre-allocation video memory pool with a certain space capacity is determined through the algorithm parameters, the available video memory space capacity and other parameters so as to be used for the video memory call in the subsequent calculation process, the use of the video memory in the GPU is effectively planned, and the time consumption overlength and the influence on the overall execution efficiency caused by the video memory allocation modes such as frequently allocating the video memory, unreasonably allocating the video memory and the like in the FHE execution process are avoided. According to the technical scheme, the available video memory space in the GPU is effectively utilized to divide a pre-allocation video memory pool special for FHE execution, the video memory space is reasonably allocated, the FHE execution efficiency is improved, the time delay is further reduced, and the real-time performance of the FHE is improved.
Further, the pre-allocation video memory pool in step S13 is used for allocating video memory space for tasks corresponding to encoding, encryption, calculation, decryption and anti-encoding respectively in the full homomorphic encryption and decryption method based on the GPU, and a video memory manager needs to be created to scientifically and reasonably allocate the video memory space in the pre-allocation video memory pool, so the full homomorphic encryption and decryption method based on the GPU may further include:
step S14, a video memory manager is established, and a video memory management index is established in the video memory manager;
and step S15, updating a key value in the video memory management index when the video memory space of the pre-allocation video memory pool is allocated, wherein the key value of the video memory management index is used for representing the capacity of the allocated video memory space.
It should be noted that, the creating step S14 of the video memory manager may be created in the process of step S10, or may be created in advance, and the method of performing video memory space allocation management through the video memory management index of the video memory manager in step S14 to step S15 may be executed in the whole flow of step S10 to step S40, so long as the various flows of encoding, encryption, calculation, decryption, and transcoding in step S10 to step S40 need to call the video memory space in the pre-allocation video memory pool of the GPU, the corresponding key value is updated in the video memory management index of the video memory manager, so as to monitor the video memory allocation situation in the pre-allocation video memory pool in real time, thereby facilitating to allocate the video memory space with a suitable capacity for a task more efficiently in allocation.
The video memory manager is a single-instance video memory manager, and is configured to manage allocation and release of video memory space, where a video memory management Index may be constructed by a Hash-Map (Hash table), where each Key in the Map is a number S, a Value corresponding to the number S is a pointer array, each pointer in the pointer array points to a video memory space with a size S, and the video memory space corresponding to each pointer array corresponds to a video memory space required by an operation task. For example, when a certain operation task needs a certain capacity of video memory space, a pointer array of a number S (equal to the size of the video memory space) is newly added in the video memory management index, and after the operation task is executed, the video memory space corresponding to the pointer array is released, and the value of the array pointed by the pointer indicates that the video memory space is released and can be called by other operation tasks.
Further, in the full homomorphic encryption and decryption method of the GPU, when the video memory manager receives the video memory allocation task, the step of reasonably allocating the video memory space of the pre-allocation video memory pool by the video memory manager may include:
step A10, when the video memory manager receives a video memory allocation task, acquiring the required capacity corresponding to the video memory allocation task, and judging whether a first key value with the capacity consistent with the required capacity exists in the video memory management index;
Step A20, if a first key value exists, inquiring whether a pointer array corresponding to the first key value is empty or not;
step S30, if the pointer array is not empty, allocating the video memory space corresponding to the pointer array to the video memory allocation task;
and S40, if the first key value does not exist or the pointer array is empty, dividing the video memory space with the required capacity from the pre-allocation video memory pool, and allocating tasks to the video memory.
The embodiment of the application specifically discloses a detailed step of allocating and dividing the video memory space in the pre-allocation video memory pool through the video memory manager, and specifically allocates the video memory space through the received required capacity corresponding to the video memory allocation task and the existing key value in the video memory management index, wherein the video memory allocation task is the video memory allocation requirement corresponding to the video memory space required by various operation processes involved in the execution process of the full-mode encryption and decryption method based on the GPU in the embodiment of the application, the first key value is the key value with the same directed video memory space capacity as the required capacity of the video memory allocation task, the first key value is created by the video memory manager because of the previous video memory allocation task with the same capacity requirement, and at the moment, the pointer array of the first key value may be empty or not empty, and the video memory space corresponding to the first key value is released, so that the video memory space corresponding to the first key value can be used for a new video memory allocation task, and if the video memory space occupied by the empty allocation task is released, the pointer cannot be used for the video memory space.
In the embodiment of the application, whether the first key value consistent with the demand capacity of the video memory allocation task exists is firstly inquired in the video memory management index, then the pointer array condition of the first key value is inquired, and the video memory space corresponding to the pointer array of the first key value can be directly allocated to the video memory allocation task under the condition that the first key value exists and the pointer array is not empty, so that the video memory allocation efficiency is improved, and the execution time of the video memory allocation task is reduced.
Illustratively, when receiving a video memory allocation task, the video memory manager searches whether a needed video memory Size size_need exists in all key values of a video memory management Index, if the key value exists, checks whether a value exists in a pointer array corresponding to the key value, and if the value exists, allocates a video memory space corresponding to the pointer to the video memory allocation task; if the key value of the video memory Size exists but the corresponding pointer array is empty, or if the key value of the video memory Size does not exist, acquiring the space usage with the Size of Size_seed from a pre-allocation video memory pool; and if the residual space in the pre-allocated video memory pool is insufficient, the space is used from the residual video memory space of the GPU.
In another possible embodiment, the video memory manager performs the video memory allocation step by the method except when the video memory is allocated, and when the video memory is released, all the video memory returning tasks are performed by the video memory manager, and the specific steps include: firstly, searching whether key values with the same size as the video memory to be restored exist in Index, and if so, storing the video memory space corresponding to the current pointer into a pointer array corresponding to the key values; if the full-homomorphic encryption execution mode does not exist, a new Key is built in the Index, the video memory space corresponding to the pointer is stored in the corresponding pointer array, and in addition, when all program execution of the full-homomorphic encryption execution mode in the GPU is finished, all the video memory space is released to the GPU.
In combination with the content of the embodiment of the application, in order to solve the technical defect that the allocation and release of the video memory which are required to be frequently used in homomorphic encryption GPU calculation can cause serious time consumption and greatly reduce the running efficiency of the whole program. The technical scheme of the embodiment of the application provides an effective GPU video memory management scheme, and the performance loss caused by memory allocation and release is greatly reduced. The logic structure of the video memory management scheme is shown in fig. 3, wherein the video memory comprises a non-reusable video memory and a reusable video memory, and the reusable video memory performs video memory space management of a pre-allocated video memory pool through a reusable video memory manager (single example), wherein a hash table mode is adopted to newly establish a plurality of video memory management indexes (s 1-s5, s11-s13, and the like) to perform video memory application management T1 and video memory return management T2, and priority of the video memory application management is that of the video memory management indexes, the pre-allocated video memory pool and the newly allocated space are sequentially executed. The GPU video memory management scheme efficiently utilizes video memory blocks with different scales, thereby greatly reducing the time consumption of frequently distributing video memory in the FHE execution process and further improving the overall execution efficiency.
In addition, in step S20, the step of encoding and encrypting the plaintext data to be processed based on the preset encoder, the algorithm parameter, the context parameter and the key to obtain ciphertext data may include:
step S21, acquiring plaintext data to be processed from a host end, and calling a preset encoder to encode the plaintext data to be processed to obtain polynomial data;
and step S22, encrypting the polynomial data according to the algorithm parameters, the context parameters and the secret key to obtain ciphertext data.
In this embodiment of the present application, it should be noted that the plaintext data to be processed is data to be processed, and the user may store the plaintext data to be processed to the host side in advance, and then obtain the plaintext data to be processed from the host side through the GPU when the plaintext data to be processed is required to be processed. In addition, the preset encoder, algorithm parameters, context parameters and secret keys are stored in the GPU, and are not required to be acquired from other equipment ends, so that the process of data transmission, copying or copying is omitted, the execution time is saved, and the efficiency of encoding and encrypting the to-be-processed plaintext data is improved.
Specifically, the steps of encoding and encrypting the plaintext data to be processed specifically include: firstly, the plaintext data to be processed is respectively assigned to a plurality of variables, a preset encoder is called to encode each variable, meanwhile, the encoded data (polynomial form) is stored for each variable in a video memory space corresponding to application, at the moment, the plaintext data to be processed is loaded into a GPU video memory in the encoded polynomial form, then encryption calculation is carried out on the encoded data according to the algorithm type, the context parameters, the secret key and the like in the determined algorithm parameters, and finally ciphertext data is obtained.
Before step S20, that is, before the step of performing calculation processing on the ciphertext data according to the custom calculation task, the method may further include:
step B10, generating polynomial coefficients according to the ciphertext data;
step B20, combining the polynomial coefficients to obtain a whole polynomial;
step B30, decomposing the whole polynomial through an RNS layer to obtain a plurality of higher-order polynomials;
and step B40, combining the high-order polynomials to generate the password layer data.
In the embodiment of the application, a method for arranging ciphertext data is provided, specifically, ciphertext data in an isomorphic encryption calculation process is divided into a plurality of levels: (1) Firstly, dividing ciphertext data into specific polynomial coefficients Coeff; (2) Then, the obtained polynomial coefficient Coeff is utilized to be combined into a polynomial Poly for representing an integer through a preset encryption method (such as Ring-LWE, ring Learning with Error); (3) Then decomposing the obtained polynomial Poly at an RNS layer, namely converting a large integer into a plurality of small integers at the RNS layer, thereby having the beneficial effect of accelerating the calculation flow, and further obtaining a plurality of high-order polynomials, wherein the high-order polynomials are the highest degree of the polynomials in the single formula of the polynomials and are more than 2; (4) Finally, a plurality of high-order polynomials are combined into a ciphertext to form a Cipher layer. According to the technical scheme, the ciphertext data can be effectively subjected to data recombination and continuous addressing through arrangement according to the hierarchical structure, so that access and memory structure use optimization during subsequent calculation in the GPU are facilitated, and GPU calculation efficiency is improved.
In addition, in step S30, the step of performing calculation processing on the ciphertext data according to the custom calculation task to obtain a ciphertext calculation result may include:
step S31, a user-defined computing task input by a user is obtained, wherein the user-defined computing task comprises a plurality of subtasks;
step S32, setting a first subtask in the custom computing task as a current computing task and setting the ciphertext data as input data;
step S33, selecting an operator corresponding to the current calculation task, performing operation processing on the ciphertext data through the operator, and outputting a ciphertext calculation result;
step S34, if the current computing task is not the last subtask, the ciphertext computing result is set as input data, the next subtask is set as the current computing task, and the execution step is returned: selecting an operator corresponding to the current calculation task, and performing operation processing on the ciphertext data through the operator until all subtasks are executed.
In this embodiment of the present application, a user-defined computing task output by a user according to a current data processing requirement may be obtained through a host side first, and it may be understood that the user-defined computing task may include a plurality of subtasks having a sequential execution sequence. And for each subtask, a proper operator is required to be selected to calculate and process ciphertext data Ce_input, so as to obtain a corresponding calculation result Ce_output. Specifically, in the whole process of calculating and processing the ciphertext data, each subtask is sequentially executed, input data of a next subtask is output data of a previous subtask, the execution is circulated until all the subtasks are executed, and finally an output ciphertext calculation result is obtained.
Illustratively, the executing steps of the custom computing task include: the user defines a computing task at a host end, and then the user-defined computing task processing comprises a plurality of sub-tasks which are sequentially executed, each sub-task can comprise a plurality of sub-tasks which are executed at the same time point, and the sub-tasks are executed on the GPU in parallel to improve the execution efficiency. For each calculation task, determining to select a proper operator to calculate ciphertext Ce_input to obtain a result Ce_output, and completing calculation on all calculation tasks to obtain Ce_output1; and when the next calculation task is carried out, the Ce_output in the previous step becomes a new Ce_input, a new Ce_output is obtained, an appropriate operator is selected to repeatedly carry out calculation processing on the ciphertext until all the tasks are calculated, and a final ciphertext calculation result Ce_output1 is obtained.
Further, in the technical solution of the embodiment of the present application, a plurality of layers of operators are provided for the operators of each computing task in step S33, because in the homomorphic encrypted GPU computing system, the efficient GPU operators are important links for improving the computing efficiency, in the technical solution of the embodiment of the present application, the operators may include a base layer operator, a middle layer operator and an upper layer operator.
It should be noted that, the basic layer operator is a general operator, and may include basic operations such as modular multiplication, modular division, modular addition, and number theory transformation, etc., and is used for calling all operators (including middle layer operators and upper layer operators) of the upper layer; secondly, an intermediate layer operator is supported by a basic operator, and FHE related theoretical calculation is assisted, wherein the intermediate layer operator comprises operations of modulus taking, cutting and the like under RNS decomposition; the uppermost layer is an upper layer operator used externally, and the upper layer operator realizes the functions of corresponding ciphertext by combining a basic operator and an intermediate layer operator and adding necessary operators: operations such as adding, multiplying, rotating, re-linearizing, scaling, etc. are directly invoked by the user.
Optionally, a multi-GPU stream computation optimization algorithm may be used in the partial operator design process to further increase the parallelism thereof.
Optionally, an operator fusion mode can be used in the design process of part of the upper layer operators to further reduce the dispatching overhead and improve the operation speed.
Optionally, the optimization mode of CUDA Graph (Compute Unified Device Architecture Graph) which can be used in the design process of part of the upper operator reduces the scheduling cost by utilizing the Graph compiling optimization mode.
Illustratively, in combination with the foregoing description of the embodiments of the present application, taking calculation expression 3 (2+4) as an example, specific implementation steps are described in detail, step 1: the user selects CKS algorithm as the type of the algorithm corresponding to FHE to be used, sets the modular chain length, the polynomial times, the dimension size and the like in algorithm parameters P, and generates context parameters according to a preset context generator; generating a random number generator and an intermediate variable which can be used in the calculation process through an algorithm parameter P, generating keys such as a public key Pk, a private key Sk, a reproduction key Gk and the like through a preset key generator, and copying the keys into a GPU video memory; and estimating the size of the required GPU video memory to be size=f (L) according to the length L of the modular chain in the parameter P, and constructing a video memory pool with the size of size, wherein the video memory pool comprises video memory management logic, video memory application and release logic. Step 2: plaintext data "3", "2" and "4" to be calculated are assigned to variables, e.g., a=3, b=2, c=4, respectively. The encoder is called to encode each variable, and meanwhile, a video memory space is applied for each variable for storing encoded data D (a), D (b) and D (c), and the encoded data are all loaded into the GPU video memory; and continuing the encryption operation on the encoded data in the GPU to obtain Ce (a), ce (b) and Ce (c), and recovering the video memory spaces of D (a), D (b) and D (c). Step 3: executing specific calculation logic in a GPU, firstly applying for a video memory space Ce (d), calling an addition operator Add in CKS, inputting Ce (b) and Ce (c), outputting and storing in Ce (d), recovering the video memory spaces of Ce (b) and Ce (c) after calculation is completed, then applying for a video memory space Ce (e), calling a multiplication operator Mul in CKS, inputting Ce (a) and Ce (d), outputting and storing in Ce (e), recovering the video memory spaces of Ce (a) and Ce (d) after calculation is completed, finally calling a reproducibility operator Relin of CKS, inputting as Ce (e), outputting as Ce (e), and reducing the data dimension by the operator. Step 4: decrypting and decoding the calculation result, applying for a video memory space D (e), calling a decryption algorithm of CKS to decrypt Ce (e), and storing the decryption result in D (e); and then the decoder of CKS is called to decode D (e), and the decrypted plaintext data 18 "is output. Step 5: copying data from the GPU video memory to the host end, and calling a data copying primitive of the GPU to copy plaintext data 18 from the GPU video memory to the host end for a user to review or execute other processes.
According to the full homomorphic encryption and decryption method based on the GPU, algorithm parameters are firstly obtained, context parameters and keys are generated through a preset generator, then plaintext data to be processed are encoded and encrypted based on a preset encoder, the algorithm parameters, the context parameters and the keys to obtain ciphertext data, then the ciphertext data are calculated according to a user-defined calculation task to obtain ciphertext calculation results, and finally the ciphertext calculation results are decrypted and reversely encoded to obtain target plaintext data. In the technical scheme of the embodiment of the application, the processes of encryption and decryption, encoding and decryption, logic calculation and the like of plaintext data are all executed by the GPU, and the homomorphic encryption calculation logic has a good acceleration effect due to the high parallelization characteristic of the GPU, so that the execution efficiency of the homomorphic encryption and decryption whole flow is greatly improved. In addition, the whole process of the technical scheme is executed on the GPU, and high time-consuming operations such as data copying and data transferring are not involved in the middle, so that the computing efficiency of the full process of full homomorphic encryption and decryption is further improved.
Example two
The embodiment of the application also provides a full homomorphic encryption and decryption device based on a GPU, please refer to fig. 4, the full homomorphic encryption and decryption device based on the GPU is applied to the GPU, and the full homomorphic encryption and decryption device based on the GPU includes:
The parameter acquisition module 10 is used for acquiring algorithm parameters and generating context parameters and keys through a preset generator;
the encoding and encrypting module 20 is configured to encode and encrypt plaintext data to be processed based on a preset encoder, the algorithm parameter, the context parameter and the key, so as to obtain ciphertext data;
the data calculation module 30 is configured to perform calculation processing on the ciphertext data according to a custom calculation task, so as to obtain a ciphertext calculation result;
the data decryption module 40 decrypts and de-encodes the ciphertext calculation result to obtain the target plaintext data.
Optionally, the parameter obtaining module 10 is further configured to:
calculating the first video memory space capacity according to the modular chain length in the algorithm parameters;
determining a pre-allocation video memory pool capacity according to the first video memory space capacity and the available video memory space capacity of the GPU;
and dividing a pre-allocation video memory pool from the available video memory space capacity based on the pre-allocation video memory capacity.
Optionally, the GPU-based isomorphic encryption and decryption device further includes a video memory allocation module, where the video memory allocation module is further configured to:
creating a video memory manager, and constructing a video memory management index in the video memory manager;
And updating a key value in the video memory management index when the video memory space of the pre-allocated video memory pool is allocated, wherein the key value of the video memory management index is used for representing the capacity of the allocated video memory space.
Optionally, the video memory allocation module is further configured to:
when the video memory manager receives a video memory allocation task, acquiring the required capacity corresponding to the video memory allocation task, and judging whether a first key value with the capacity consistent with the required capacity exists in the video memory management index;
if the first key value exists, inquiring whether a pointer array corresponding to the first key value is empty or not;
if the pointer array is not empty, allocating the video memory space corresponding to the pointer array to the video memory allocation task;
and if the first key value does not exist or the pointer array is empty, dividing the video memory space with the required capacity from the pre-allocation video memory pool, and allocating tasks to the video memory.
Optionally, the encoding encryption module 20 is further configured to:
acquiring plaintext data to be processed from a host end, and calling a preset encoder to encode the plaintext data to be processed to obtain polynomial data;
and encrypting the polynomial data according to the algorithm parameters, the context parameters and the secret key to obtain ciphertext data.
Optionally, the data calculation module 30 is further configured to:
generating polynomial coefficients according to the ciphertext data;
combining the polynomial coefficients to obtain an overall polynomial;
decomposing the whole polynomial through an RNS layer to obtain a plurality of higher-order polynomials;
and combining the higher order polynomials to generate the password layer data.
Optionally, the data calculation module 30 is further configured to:
acquiring a user-defined computing task input by a user, wherein the user-defined computing task comprises a plurality of subtasks;
setting a first subtask in the custom computing task as a current computing task and setting the ciphertext data as input data;
selecting an operator corresponding to the current calculation task, performing operation processing on the ciphertext data through the operator, and outputting a ciphertext calculation result;
if the current computing task is not the last subtask, setting the ciphertext computing result as input data, setting the next subtask as the current computing task, and returning to the executing step: selecting an operator corresponding to the current calculation task, and performing operation processing on the ciphertext data through the operator until all subtasks are executed.
The full homomorphic encryption and decryption device based on the GPU provided by the embodiment of the application adopts the full homomorphic encryption and decryption method based on the GPU in the first embodiment or the second embodiment, and can solve the technical problems of lower calculation efficiency and higher time delay of homomorphic encryption. Compared with the prior art, the full homomorphic encryption and decryption device based on the GPU has the same beneficial effects as the full homomorphic encryption and decryption method based on the GPU provided by the embodiment, and other technical features in the full homomorphic encryption and decryption device based on the GPU are the same as the features disclosed by the method of the embodiment, and are not repeated herein.
Example III
The embodiment of the application provides electronic equipment, the electronic equipment includes: at least one processor; and a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the GPU-based isomorphic encryption and decryption method in the first embodiment.
Referring now to fig. 5, a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure is shown. The electronic device in embodiments of the present disclosure includes, but is not limited to, mixed Reality (Mixed Reality) -MR devices (e.g., MR glasses or MR helmets), augmented Reality (Augmented Reality) -AR devices (e.g., AR glasses or AR helmets), virtual Reality (Virtual Reality) -VR devices (e.g., VR glasses or VR helmets), augmented Reality (Extended Reality) -XR devices, or some combination thereof, and the like electronic devices. The electronic device shown in fig. 5 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 5, the electronic device may include a processing means 1001 (e.g., a central processor, a graphics processor, etc.) which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM 1002) or a program loaded from a storage means into a random access memory (RAM 1004). In the RAM1004, various programs and data required for the operation of the electronic device are also stored. The processing device 1001, the ROM1002, and the RAM1004 are connected to each other by a bus 1005. An input/output (I/O) interface is also connected to bus 1005.
In general, the following systems may be connected to the I/O interface 1006: input devices 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, and the like; an output device 1008 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage device 1003 including, for example, a magnetic tape, a hard disk, and the like; and communication means 1009. The communication means 1009 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. While electronic devices having various systems are shown in the figures, it should be understood that not all of the illustrated systems are required to be implemented or provided. More or fewer systems may alternatively be implemented or provided.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network through a communication device, or installed from the storage device 1003, or installed from the ROM 1002. The above-described functions defined in the method of the embodiment of the present disclosure are performed when the computer program is executed by the processing device 1001.
The electronic equipment provided by the application adopts the full homomorphic encryption and decryption method based on the GPU in the embodiment, and can solve the technical problems of lower calculation efficiency and higher time delay of homomorphic encryption. Compared with the prior art, the electronic device provided by the embodiment of the present application has the same beneficial effects as the GPU-based isomorphic encryption and decryption method provided by the above embodiment, and other technical features in the electronic device are the same as the features disclosed in the method of the previous embodiment, and are not described in detail herein.
It should be understood that portions of the present disclosure may be implemented in hardware, software, firmware, or a combination thereof. In the description of the above embodiments, particular features, structures, materials, or characteristics may be combined in any suitable manner in any one or more embodiments or examples.
The foregoing is merely specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the present application, and the changes and substitutions are intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Example IV
The embodiment of the application provides a computer readable storage medium having computer readable program instructions stored thereon, the computer readable program instructions being configured to perform the GPU-based isomorphic encryption and decryption method in the above embodiment.
The computer readable storage medium provided by the embodiments of the present application may be, for example, a usb disk, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this embodiment, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, or device. Program code embodied on a computer readable storage medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The above-described computer-readable storage medium may be contained in an electronic device; or may exist alone without being assembled into an electronic device.
The computer-readable storage medium carries one or more programs that, when executed by an electronic device, cause the electronic device to: acquiring algorithm parameters, and generating context parameters and a secret key through a preset generator; encoding and encrypting plaintext data to be processed based on a preset encoder, the algorithm parameter, the context parameter and the secret key to obtain ciphertext data; according to the user-defined calculation task, calculating the ciphertext data to obtain a ciphertext calculation result; and decrypting and anti-coding the ciphertext calculation result to obtain target plaintext data.
Computer program code for carrying out operations of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, small talk, C++ and the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented in software or hardware. Wherein the name of the module does not constitute a limitation of the unit itself in some cases.
The computer readable storage medium is stored with the computer readable program instructions for executing the homomorphic encryption and decryption method based on the GPU, and can solve the technical problems of low calculation efficiency and high delay of homomorphic encryption. Compared with the prior art, the beneficial effects of the computer readable storage medium provided in the embodiment of the present application are the same as the beneficial effects of the full homomorphic encryption and decryption method based on the GPU provided in the first embodiment or the second embodiment, and are not described in detail herein.
Example five
The embodiment of the application also provides a computer program product, which comprises a computer program, wherein the computer program realizes the steps of the full homomorphic encryption and decryption method based on the GPU when being executed by a processor.
The computer program product provided by the application can solve the technical problems of low calculation efficiency and high time delay of homomorphic encryption. Compared with the prior art, the beneficial effects of the computer program product provided by the embodiment of the present application are the same as the beneficial effects of the full homomorphic encryption and decryption method based on the GPU provided by the first embodiment or the second embodiment, and are not described herein.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the scope of the claims, and all equivalent structures or equivalent processes using the descriptions and drawings of the present application, or direct or indirect application in other related technical fields are included in the scope of the claims.

Claims (8)

1. The full homomorphic encryption and decryption method based on the GPU is characterized by being applied to the GPU, and comprises the following steps of:
acquiring algorithm parameters, and generating context parameters and a secret key through a preset generator;
encoding and encrypting plaintext data to be processed based on a preset encoder, the algorithm parameter, the context parameter and the secret key to obtain ciphertext data;
according to the user-defined calculation task, calculating the ciphertext data to obtain a ciphertext calculation result;
decrypting and anti-coding the ciphertext calculation result to obtain target plaintext data;
wherein, after the step of obtaining the algorithm parameters, the method further comprises:
calculating the first video memory space capacity according to the modular chain length in the algorithm parameters;
determining a pre-allocation video memory pool capacity according to the first video memory space capacity and the available video memory space capacity of the GPU;
dividing a pre-allocation video memory pool from the available video memory space capacity based on the pre-allocation video memory pool capacity;
when a video memory manager receives a video memory allocation task, acquiring the required capacity corresponding to the video memory allocation task, and judging whether a first key value with the capacity consistent with the required capacity exists in a video memory management index;
If the first key value exists, inquiring whether a pointer array corresponding to the first key value is empty or not;
if the pointer array is not empty, allocating the video memory space corresponding to the pointer array to the video memory allocation task;
and if the first key value does not exist or the pointer array is empty, dividing the video memory space with the required capacity from the pre-allocation video memory pool, and allocating tasks to the video memory.
2. The GPU-based isomorphic encryption and decryption method of claim 1, further comprising:
creating a video memory manager, and constructing a video memory management index in the video memory manager;
and updating a key value in the video memory management index when the video memory space of the pre-allocated video memory pool is allocated, wherein the key value of the video memory management index is used for representing the capacity of the allocated video memory space.
3. The GPU-based homomorphic encryption and decryption method of claim 1, wherein the step of encoding and encrypting plaintext data to be processed based on a preset encoder, the algorithm parameters, the context parameters, and the key to obtain ciphertext data comprises:
Acquiring plaintext data to be processed from a host end, and calling a preset encoder to encode the plaintext data to be processed to obtain polynomial data;
and encrypting the polynomial data according to the algorithm parameters, the context parameters and the secret key to obtain ciphertext data.
4. The GPU-based isomorphic encryption and decryption method of claim 1, further comprising, prior to the step of computing the ciphertext data according to a custom computing task:
generating polynomial coefficients according to the ciphertext data;
combining the polynomial coefficients to obtain an overall polynomial;
decomposing the whole polynomial through an RNS layer to obtain a plurality of higher-order polynomials;
and combining the higher order polynomials to generate the password layer data.
5. The method for fully homomorphic encryption and decryption based on GPU according to any one of claims 1-4, wherein the step of computing the ciphertext data according to the custom computing task to obtain the ciphertext computing result comprises:
acquiring a user-defined computing task input by a user, wherein the user-defined computing task comprises a plurality of subtasks;
setting a first subtask in the custom computing task as a current computing task and setting the ciphertext data as input data;
Selecting an operator corresponding to the current calculation task, performing operation processing on the ciphertext data through the operator, and outputting a ciphertext calculation result;
if the current computing task is not the last subtask, setting the ciphertext computing result as input data, setting the next subtask as the current computing task, and returning to the executing step: selecting an operator corresponding to the current calculation task, and performing operation processing on the ciphertext data through the operator until all subtasks are executed.
6. The GPU-based isomorphic encryption and decryption method of claim 5, wherein the operators comprise at least one of a base layer operator, an intermediate layer operator, and an upper layer operator;
wherein the base layer operator is used for performing at least one operation of modular multiplication, modular division, modular and number theory transformation;
the middle layer operator is used for calling the base layer operator and executing at least one operation of FHE calculation and modulo and truncation of RNS decomposition;
the upper layer operator is used for calling the base layer operator and the middle layer operator and is used for executing at least one operation of adding, multiplying, rotating, re-linearizing and scaling of ciphertext.
7. An electronic device, the electronic device comprising:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the steps of the GPU-based isomorphic encryption and decryption method of any one of claims 1 to 6.
8. A computer-readable storage medium, wherein a program for implementing the GPU-based isomorphic encryption and decryption method is stored on the computer-readable storage medium, and the program for implementing the GPU-based isomorphic encryption and decryption method is executed by a processor to implement the steps of the GPU-based isomorphic encryption and decryption method according to any one of claims 1 to 6.
CN202311641868.5A 2023-12-04 2023-12-04 Fully homomorphic encryption and decryption method based on GPU, electronic equipment and storage medium Active CN117349868B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311641868.5A CN117349868B (en) 2023-12-04 2023-12-04 Fully homomorphic encryption and decryption method based on GPU, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311641868.5A CN117349868B (en) 2023-12-04 2023-12-04 Fully homomorphic encryption and decryption method based on GPU, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117349868A CN117349868A (en) 2024-01-05
CN117349868B true CN117349868B (en) 2024-04-12

Family

ID=89363518

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311641868.5A Active CN117349868B (en) 2023-12-04 2023-12-04 Fully homomorphic encryption and decryption method based on GPU, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117349868B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10075288B1 (en) * 2014-02-28 2018-09-11 The Governing Council Of The University Of Toronto Systems, devices, and processes for homomorphic encryption
CN115622684A (en) * 2022-11-16 2023-01-17 哈尔滨工业大学(深圳)(哈尔滨工业大学深圳科技创新研究院) Privacy computation heterogeneous acceleration method and device based on fully homomorphic encryption
CN116150795A (en) * 2023-04-17 2023-05-23 粤港澳大湾区数字经济研究院(福田) Homomorphic encryption-based data processing method, system and related equipment
WO2023124677A1 (en) * 2021-12-30 2023-07-06 华为技术有限公司 Data processing method and computing platform
CN116633526A (en) * 2023-07-21 2023-08-22 北京数牍科技有限公司 Data processing method, device, equipment and medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10075288B1 (en) * 2014-02-28 2018-09-11 The Governing Council Of The University Of Toronto Systems, devices, and processes for homomorphic encryption
WO2023124677A1 (en) * 2021-12-30 2023-07-06 华为技术有限公司 Data processing method and computing platform
CN115622684A (en) * 2022-11-16 2023-01-17 哈尔滨工业大学(深圳)(哈尔滨工业大学深圳科技创新研究院) Privacy computation heterogeneous acceleration method and device based on fully homomorphic encryption
CN116150795A (en) * 2023-04-17 2023-05-23 粤港澳大湾区数字经济研究院(福田) Homomorphic encryption-based data processing method, system and related equipment
CN116633526A (en) * 2023-07-21 2023-08-22 北京数牍科技有限公司 Data processing method, device, equipment and medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Optimizing Layerwise Polynomial approximation for efficient private inference on fully homomorphic encrption:a dynamic programming approach;Junghyun Lee et al.;《arXiv:2310.10349v1》;第1-17页 *

Also Published As

Publication number Publication date
CN117349868A (en) 2024-01-05

Similar Documents

Publication Publication Date Title
CN107251474A (en) Use the Cryptographic AES for the finite subregions look-up table in masked operation
JP6697478B2 (en) Method and computer program for runtime instantiation of a broadcast cipher
CN103631660A (en) Method and device for distributing storage resources in GPU in big integer calculating process
WO2023004007A1 (en) Hybrid public-key and private-key cryptographic systems based on iso-rsa encryption scheme
Drucker et al. BLEACH: cleaning errors in discrete computations over CKKS
CN117349868B (en) Fully homomorphic encryption and decryption method based on GPU, electronic equipment and storage medium
CN114003924A (en) Integrated fully homomorphic encryption implementation method, device and system
KR102424856B1 (en) Compression and indeterminate expansion of RLWE ciphertexts
EP4182851A1 (en) Private inference in deep neural network
WO2021124520A1 (en) Secret random number generation system, secret calculation device, secret random number generation method, and program
CN110034918A (en) A kind of SM4 acceleration method and device
US11728984B2 (en) Hybrid public-key and private-key encryption system
JP7449911B2 (en) Device that performs non-polynomial operations on isomorphic ciphertext
KR102522708B1 (en) Apparatus and method for performing statistical calculation on homomorphic ciphertext
CN113204502A (en) Heterogeneous accelerated computing optimization method, device and equipment and readable storage medium
So-In et al. Performance evaluation of parallel AES implementations over CUDA-GPU framework
Lou et al. A programming api implementation for secure data analytics applications with homomorphic encryption on gpus
CN116382696B (en) Engineering attribute dynamic analysis and submission method based on factory object position number
CN116846535A (en) Universal privacy computing method, device, equipment and medium based on homomorphic encryption
KR20240120241A (en) Method and apparatus for reducing operations in generation of hierarchical galois key set for homomorphic rotation operations
Xia et al. Parallel Computing Mode in Homomorphic Encryption Using GPUs Acceleration in Cloud.
CN118364478A (en) Data processing method, system and equipment
CN117573074A (en) Constant modulus multiplication arithmetic unit, decryption method, and medium
CN117592521A (en) Batch coding method for full homomorphic CNN reasoning
Lourenço Information Systems and Computer Engineering

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant