WO2025214366A1 - 执行层次同态加密运算的方法及装置 - Google Patents
执行层次同态加密运算的方法及装置Info
- Publication number
- WO2025214366A1 WO2025214366A1 PCT/CN2025/087845 CN2025087845W WO2025214366A1 WO 2025214366 A1 WO2025214366 A1 WO 2025214366A1 CN 2025087845 W CN2025087845 W CN 2025087845W WO 2025214366 A1 WO2025214366 A1 WO 2025214366A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- target
- gpu
- current layer
- homomorphic
- memory
- 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.)
- Pending
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/008—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols involving homomorphic encryption
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L2209/00—Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
- H04L2209/12—Details relating to cryptographic hardware or logic circuitry
- H04L2209/122—Hardware reduction or efficient architectures
Definitions
- One or more embodiments of this specification relate to the field of data security technology, and in particular, to a method and apparatus for performing hierarchical homomorphic encryption operations.
- Hierarchical homomorphic encryption is one of the primary technologies currently used to protect data privacy.
- HIE Hierarchical homomorphic encryption
- GPUs Graphics processing units
- GPUs within heterogeneous frameworks possess abundant computing resources and can be used to accelerate many graphics processing algorithms. Therefore, leveraging GPUs to accelerate HHE is a leading industry initiative.
- One or more embodiments of this specification describe a method and apparatus for performing hierarchical homomorphic encryption operations, which can improve the efficiency of hierarchical homomorphic encryption operations.
- a method for performing a hierarchical homomorphic encryption operation is provided, the method being performed by a graphics processing unit (GPU), the GPU having multiple storage structures, the multiple storage structures including at least global memory and constant memory, the method comprising:
- the intermediate results are stored in a corresponding storage structure among the multiple storage structures.
- a device for performing hierarchical homomorphic encryption operations is provided, which is provided on a graphics processing unit (GPU), wherein the GPU has multiple storage structures, the multiple storage structures including at least global memory and constant memory, and the device includes:
- An acquisition unit configured to acquire target data to be processed in the current layer using a target homomorphic operation function
- a reading unit configured to read first-category pre-calculated parameters corresponding to the current layer from the global memory, and read second-category pre-calculated parameters corresponding to the current layer from the constant memory, wherein the second-category pre-calculated parameters are used by multiple threads and the amount of data is less than a predetermined threshold;
- An execution unit configured to perform current layer processing on the target data based on at least the first type of pre-calculation parameters and the second type of pre-calculation parameters to obtain an intermediate result
- the storage unit is used to store the intermediate result in a corresponding storage structure among the multiple storage structures according to the usage requirements of the intermediate result between threads.
- a computer-readable storage medium on which a computer program is stored.
- the computer program is executed in a computer, the computer is caused to execute the method according to the first aspect.
- a computing device comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method of the first aspect is implemented.
- the method and apparatus for performing hierarchical homomorphic encryption operations provided in one or more embodiments of this specification can fully utilize the performance advantages of different storage structures by storing the pre-calculated parameters of the homomorphic operation function in different storage structures of the GPU according to categories, and storing the intermediate results obtained during the execution of the homomorphic operation function in different storage structures of the GPU according to the usage requirements between threads. This can thereby improve the efficiency of hierarchical homomorphic encryption operations.
- Figure 1 shows a schematic diagram of a heterogeneous framework
- FIG2 is a schematic diagram showing a method for performing hierarchical homomorphic encryption operations based on a heterogeneous framework
- FIG3 shows a schematic diagram of hierarchical pre-calculation parameters
- FIG4 shows a schematic diagram of modular deployment of operators in an example
- FIG5 shows a schematic diagram of resource pooling management
- FIG6 shows a flow chart of a method for performing a hierarchical homomorphic encryption operation according to one embodiment
- FIG7 shows a schematic diagram of a device for performing hierarchical homomorphic encryption operations according to one embodiment.
- FIG. 1 shows a schematic diagram of a heterogeneous framework.
- the heterogeneous framework includes a CPU (also called a host) and a GPU (also called a device), and the CPU and the GPU are connected together via a PCle bus to work together.
- the GPU is usually used to perform computationally intensive tasks, such as large matrix operations.
- the CPU can be used to perform complex logical operations, so it is suitable for control-intensive tasks.
- the threads running on the CPU are heavyweight and the context switching overhead is large, but the threads running on the GPU are lightweight. Therefore, the heterogeneous framework based on the CPU and GPU can complement each other's strengths.
- the CPU is responsible for processing logically complex serial programs, while the GPU focuses on processing data-intensive parallel computing programs, thereby maximizing its effectiveness.
- the GPU can include multiple storage structures: shared memory, constant memory, registers, and global memory (also known as video memory).
- shared memory can be accessed by all threads in a thread block and its lifecycle is consistent with the thread block.
- Constant memory is a read-only storage that is used to store data that does not change during kernel execution. It should be understood that after a thread reads content from constant memory, it can broadcast it to other threads in the corresponding warp. Therefore, when all threads in a warp read data from the same address in the constant cache, the reading speed is comparable to reading from a register. Registers are only accessed by a single thread. Global memory can be accessed by all threads and can also be accessed by the CPU.
- Figure 2 illustrates a method for executing hierarchical homomorphic encryption operations based on a heterogeneous framework.
- the user first configures the basic parameters (also known as algorithm parameters) of each homomorphic operation function in the hierarchical homomorphic encryption operation to be executed through the CPU.
- the basic parameters may include: the polynomial length N, the number of residue number system (RNS) decompositions pnum, the plaintext modulus t, and the ciphertext modulus Q (the product of pnum times qi).
- the CPU calculates precomputed parameters based on the user-configured basic parameters and synchronizes these parameters to the GPU.
- precomputed parameters may include: the pnum moduli in the RNS decomposition, the number theoretic transform (NTT) coefficients with a pnum group length of N, and the CRT transform coefficients.
- NTT number theoretic transform
- the CPU can organize some precomputed parameters into hierarchies. For example, the pnum moduli described above can be organized into pnum levels. Precomputed parameters maintained hierarchically by the CPU are also maintained hierarchically on the GPU.
- the application includes a host code portion running on the CPU side and a device code portion running on the GPU side.
- a portion of the homomorphic operations in the hierarchical homomorphic encryption operation can be executed on the CPU side, and by executing the device code portion, another portion of the homomorphic operations can be executed on the GPU side.
- a portion of the homomorphic operations in the hierarchical homomorphic encryption operation is executed on the CPU side, and another portion of the homomorphic operations is executed on the GPU side.
- all homomorphic operations in the hierarchical homomorphic encryption operation can be executed on the GPU side, and this specification does not limit this.
- precomputed parameters are stored in different GPU memory structures according to their categories. Specifically, precomputed parameters with data sizes greater than a predetermined threshold or that will not be accessed by multiple threads at the same address (hereinafter referred to as first-category precomputed parameters) are stored in global memory. Precomputed parameters that will be used by multiple threads within a thread block and have data sizes less than a predetermined threshold (i.e., second-category precomputed parameters) are stored in constant memory.
- the intermediate results obtained during the execution of the homomorphic operation function are stored in different storage structures of the GPU according to their usage requirements between threads. This will be explained in detail later.
- the CPU and GPU maintain the same layer identifier for the same layer.
- Figure 3 shows a schematic diagram of hierarchical pre-calculation parameters.
- the L-layer pre-calculation parameters maintained by the CPU for the homomorphic operation function are the same as the L-layer pre-calculation parameters maintained by the GPU.
- the L-th layer on the CPU and the L-th layer on the GPU have the same layer identifier, the L-1th layer on the CPU and the L-1th layer on the CPU have the same layer identifier, and so on.
- the precomputed parameters for each layer are stored in different storage structures according to their categories. For example, some of the precomputed parameters for layer L are stored in global memory, while others are stored in constant memory.
- the communication efficiency between the CPU and GPU can be accelerated, thereby accelerating the homomorphic operations performed on the GPU side.
- Target operators include any of the following: modular operators, NTT operators, basis conversion operators, and Galois operators.
- Figure 4 shows a schematic diagram of the modular deployment of operators in an example.
- the NTT operator and the modular operator each correspond to three implementation modules, and each implementation module processes a different modulus bit width.
- the modulus bit width processed by the three corresponding implementation modules can be no less than the pre-configured modulus bit width (i.e., the bit width of qi), and the implementation module with the best performance under the current hardware environment is selected as the target implementation module.
- this solution also implements resource pooling management, as shown in Figure 5.
- a stream pool, a random number pool, and a video memory pool are constructed in the GPU, where multiple streams are initialized in the stream pool: Stream0-StreamN.
- the streams here can be regarded as a series of tasks executed sequentially (possibly issued by different host threads). Multiple tasks in the same stream are executed serially, and tasks between different streams can be executed in parallel.
- one or more streams in the stream pool can be used to improve computational parallelism (that is, the GPU manages concurrent tasks through streams).
- the multiple streams in the stream pool can be uniformly initialized before the hierarchical homomorphic encryption operation begins, and uniformly released after the hierarchical homomorphic encryption operation ends, thereby avoiding the performance impact caused by stream initialization and stream release during the homomorphic operation.
- the random number pool described above can be thought of as a fixed-size space allocated in global memory, filled with random numbers for use in subsequent computations. Once all random numbers have been used, the pool is refilled with new ones. The random number pool is released after the homomorphic computation completes, thus avoiding the performance impact of frequent random number generation during computations.
- the above-mentioned video memory pool can be regarded as a large space allocated in the global memory for use in subsequent calculation processes. Specifically, during the calculation process, a small area (hereinafter referred to as the video memory block) can be requested from the video memory pool and allocated to a certain variable. After the declaration cycle of this variable ends, the corresponding video memory block is recovered and marked as available, and continues to be allocated to a certain variable in the subsequent calculation process. When the video memory pool space is insufficient, an area will be initialized again until the video memory on the entire GPU is used and an insufficient video memory error occurs. The video memory pool will not be released during the homomorphic calculation process, but will be released after the homomorphic calculation is completed, thereby avoiding the performance impact caused by frequent initialization and release of video memory during the calculation process.
- a memory block in the memory pool can also be allocated to a stream in the stream pool and exclusively occupied by that stream. Access by other streams requires stream synchronization (see the dotted arrows in FIG5 ) to prevent data read and write errors.
- Figure 6 shows a flow chart of a method for performing hierarchical homomorphic encryption operations according to one embodiment, which is performed by a GPU in a heterogeneous framework. It should be noted that the method includes multiple rounds of iterations, and Figure 6 shows the method steps included in any one of the rounds of iterations. It should be understood that by repeatedly executing the method steps shown therein, all homomorphic operations on the GPU side can be completed. As shown in Figure 6, the method may include the following steps:
- Step S602 Obtain target data to be processed at the current layer using the target homomorphic operation function.
- the target homomorphic operation function mentioned above refers to the homomorphic operation function executed on the GPU side among the multiple homomorphic operation functions included in the hierarchical homomorphic encryption operation to be executed.
- the target data may be the plaintext or ciphertext calculation result provided by the CPU after completing the homomorphic operation function on its side, or user input data forwarded by the CPU.
- the target data may be the plaintext or ciphertext calculation result obtained in the previous iteration.
- variable structure eg, class
- the variable structure corresponding to the target data may further include a target layer identifier so that the GPU can determine the current layer based on the target layer identifier.
- the GPU can determine the target layer identifier corresponding to the plaintext or ciphertext calculation result (for details, please refer to the method for determining the layer identifier corresponding to the final result below) and determine the current layer based on it.
- the GPU can use it as a variable and apply for a memory block from the memory pool to store the target data.
- Step S604 reading the first type of pre-calculation parameters corresponding to the current layer from the global memory, and reading the second type of pre-calculation parameters corresponding to the current layer from the constant memory.
- the first type of pre-computed parameters has a data size greater than a predetermined threshold or will not be accessed by multiple threads using the same address.
- the second type of pre-computed parameters will be used by multiple threads within a thread block and have a data size less than a predetermined threshold.
- the first type of pre-computed parameters may be, for example, CRT transform coefficients
- the second type of pre-computed parameters may be, for example, pnum moduli and NTT coefficients under RNS decomposition.
- the GPU reads the first type of pre-calculated parameters corresponding to the current layer from the global memory and reads the second type of pre-calculated parameters corresponding to the current layer from the constant memory according to the above target layer identifier.
- the first type of pre-calculated parameters of the Lth layer can be read from the global memory, and the second type of pre-calculated parameters of the Lth layer can be read from the constant memory.
- basic parameters related to the target homomorphic operation function are also read from global memory. These basic parameters can be, for example, the polynomial length N, the number of residue number system (RNS) decompositions pnum, the plaintext modulus t, and the ciphertext modulus Q.
- N polynomial length
- RMS residue number system
- Step S606 performing current layer processing on the target data based on at least the first type of pre-calculation parameters and the second type of pre-calculation parameters to obtain an intermediate result.
- the above-mentioned current layer processing of the target data includes: reading a certain number of random numbers from the random number pool, and performing current layer processing on the target data based on the read random numbers, as well as the first type of pre-calculation parameters and the second type of pre-calculation parameters.
- this solution reads random numbers from a random number pool, which can avoid the performance impact caused by frequent random number generation during the calculation process.
- the target homomorphic operation function may include several target operators, where the GPU maintains multiple implementation modules for these operators.
- These target operators may include at least one of the following: a modular arithmetic operator, a number theoretic transformation (NTT) operator, a basis conversion operator, and a Galois operator.
- performing the current layer processing on the target data includes executing each pre-selected target implementation module for the multiple target operators.
- Each target implementation module is an implementation module that processes a modulus bit width that is not less than the pre-configured modulus bit width (i.e., the bit width of qi) among the multiple implementation modules corresponding to the multiple target operators and has the best performance under the current hardware environment.
- step S606 current layer processing may be performed on the target data based on the basic parameters read from the global memory, the first type of pre-calculation parameters, and the second type of pre-calculation parameters.
- the basic parameters read may include: polynomial length N, RNS decomposition modulus qi, and number of moduli pnum
- the first type of pre-calculation parameters read may include: pnum NTT coefficients.
- Performing current layer processing on the target data includes: dividing the target data into pnum independent computing tasks according to the RNS decomposition modulus qi. Each independent computing task is assigned to a stream requested from the above-mentioned stream pool, so as to utilize multi-threaded parallelism to perform an NTT transformation of the length of the polynomial length N on the pnum independent computing tasks based on the pnum NTT coefficients.
- Step S608 storing the intermediate result in a corresponding storage structure among the plurality of storage structures according to the usage requirements of the intermediate result between threads.
- the intermediate result when the intermediate result is the input or final output of the kernel function, the intermediate result can be stored in the global memory.
- the intermediate result is an intermediate output of the kernel function
- the intermediate result is stored in a corresponding storage structure among the multiple storage structures according to the usage requirements of the intermediate result between threads.
- the intermediate results are stored in shared memory; if a demand indication is used within a single thread, the intermediate results are stored in registers to make the best use of register resources; if a demand indication is used to synchronize or be used across thread blocks, the intermediate results are stored in global memory.
- the GPU can also obtain a final result corresponding to the target homomorphic operation function. For this final result, the GPU can determine the layer identifier corresponding to the final result based on the number of modulus losses corresponding to the target homomorphic operation function.
- the GPU can use the number of modulo losses corresponding to the target homomorphic operation function as the number of loss layers, n. It can then determine the update layer based on the difference between the current layer and the number of loss layers. For example, if the current layer is layer L, the update layer is layer L-n. Finally, the layer identifier corresponding to layer L-n is used as the layer identifier corresponding to the final result.
- the GPU obtains the above calculation result and its corresponding layer identifier, if the iteration end condition has not been met at this time (for example, there are still unexecuted homomorphic operation functions, etc.), then the calculation result is used as the target data, and the updated layer is used as the current layer to perform the next round of iteration until the iteration end condition is met. If the iteration end condition is met, the GPU can provide the final result and its corresponding layer identifier to the CPU, allowing the CPU to determine the result of the hierarchical homomorphic encryption operation.
- this solution has made the following improvements to the algorithm framework executed on the GPU side; 1.
- the pre-calculated parameters and intermediate results are classified and stored in different storage structures on the GPU to give full play to the performance advantages of storage at different levels, and the important resources required in the calculation process (random numbers, streams and memory) are efficiently pooled and managed to avoid the performance impact caused by temporary allocation and release.
- 2. In order to avoid the frequent transmission of context parameters between devices, a layer identifier mechanism is constructed, so that the pre-calculated parameters of the corresponding layer can be selected within the device (i.e. within the GPU) through the layer identifier, and the devices (i.e.
- the algorithm implementation is highly modularized. Each operator contains one or more implementations. The optimal implementation combination can be adaptively selected according to different basic parameters. Different GPU hardware can be quickly matched and tested to improve performance and development efficiency.
- one embodiment of this specification also provides a device for performing hierarchical homomorphic encryption operations, which is provided on a graphics processing unit (GPU).
- the GPU has multiple storage structures, which include at least global memory and constant memory.
- the device may include:
- the acquisition unit 702 is used to acquire target data to be processed in the current layer using the target homomorphic operation function.
- the reading unit 704 is used to read the first type of pre-calculation parameters corresponding to the current layer from the global memory, and read the second type of pre-calculation parameters corresponding to the current layer from the constant memory, wherein the second type of pre-calculation parameters are used by multiple threads and the data volume is less than a predetermined threshold.
- the execution unit 706 is configured to perform current layer processing on the target data based on at least the first type of pre-calculation parameters and the second type of pre-calculation parameters to obtain an intermediate result.
- the storage unit 708 is configured to store the intermediate result in a corresponding storage structure among the plurality of storage structures according to usage requirements of the intermediate result between threads.
- the plurality of storage structures further include: a shared memory and registers;
- the storage unit 708 is specifically used for:
- the intermediate results are stored in shared memory
- the intermediate results are stored in global memory.
- the GPU is included in a heterogeneous framework, the heterogeneous framework also including a CPU, the GPU and the CPU both maintain a plurality of levels of first-category pre-computed parameters and second-category pre-computed parameters for a target homomorphic operation function, and the CPU and the GPU each maintain a same layer identifier for the same layer;
- the acquisition unit 702 is specifically used for:
- the reading unit 704 is specifically used for:
- the first type of pre-calculated parameters corresponding to the current layer are read from the global memory, and the second type of pre-calculated parameters corresponding to the current layer are read from the constant memory.
- the target homomorphic operation function includes a plurality of target operators, and a plurality of implementation modules corresponding to each of the plurality of target operators are maintained in the GPU;
- the execution unit 706 is specifically configured to:
- the current layer processing is performed on the target data using target implementation modules pre-selected for several target operators; the target implementation module corresponding to any target operator is selected based on the current hardware environment and the pre-configured modulus bit width.
- the aforementioned target operators include at least one of the following: a modular operation operator, a number theoretic transformation (NTT) operator, a basis conversion operator, and a Galois operator.
- a stream pool is initialized in the GPU, and the target homomorphic operation function includes: a number theoretic transformation NTT operator;
- the execution unit 706 includes:
- the allocation submodule 7064 is used to allocate each independent computing task to a certain stream requested from the stream pool, so as to perform NTT transformation on each independent computing task in parallel by using multiple threads.
- a random number pool is initialized in the GPU, and the target homomorphic operation function is an encryption function or a decryption function;
- the execution unit 706 is specifically configured to:
- the apparatus further includes: a determining unit 710 and a sending unit 712;
- the acquisition unit 702 is further configured to acquire a final result corresponding to the target homomorphic operation function
- a determining unit 710 for using the number of modulus losses corresponding to the target homomorphic operation function as the number of loss layers, and determining an update layer based on a difference between the current layer and the number of loss layers;
- the sending unit 712 is used to provide the layer identifier and final result corresponding to the updated layer to the CPU, so that the CPU determines the operation result of the hierarchical homomorphic encryption operation.
- An embodiment of this specification provides a device for performing hierarchical homomorphic encryption operations, which can improve the efficiency of hierarchical homomorphic encryption operations.
- a computer-readable storage medium on which a computer program is stored.
- the computer program is executed in a computer, the computer is caused to execute the method described in conjunction with FIG. 6 .
- a computing device including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in conjunction with FIG. 6 is implemented.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Storage Device Security (AREA)
Abstract
本说明书实施例提供一种执行层次同态加密运算的方法及装置,其中的方法通过GPU执行,包括:获取有待利用目标同态操作函数执行当前层处理的目标数据。从全局内存读取当前层对应的第一类预计算参数,从常量内存读取当前层对应的第二类预计算参数,其中,第二类预计算参数被多个线程使用,且数据量小于预定阈值。至少基于第一类预计算参数和第二类预计算参数,对目标数据执行当前层处理,得到中间结果。根据中间结果在线程间的使用需求,将中间结果存储在多个存储结构中对应的存储结构中。
Description
本申请要求于2024年04月09日提交中国国家知识产权局、申请号为202410425396.8、申请名称为“执行层次同态加密运算的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本说明书一个或多个实施例涉及数据安全技术领域,尤其涉及一种执行层次同态加密运算的方法及装置。
层次同态加密运算是目前用来解决数据隐私保护的主要技术手段之一,然而由于其运算效率的问题,基于异构框架实现对层次同态加密运算的加速是产品化和商业化的必经之路。异构框架中的图像处理器(graphics processing unit,GPU)具有丰富的计算资源,可以用来加速很多图形处理算法,因此,利用GPU加速层次同态加密运算是目前业界的主流探索方案之一。
本说明书一个或多个实施例描述了一种执行层次同态加密运算的方法及装置,可以提升层次同态加密运算的效率。
第一方面,提供了一种执行层次同态加密运算的方法,通过图像处理器GPU执行,所述GPU具有多个存储结构,所述多个存储结构至少包括:全局内存和常量内存,所述方法包括:
获取有待利用目标同态操作函数执行当前层处理的目标数据;
从所述全局内存读取当前层对应的第一类预计算参数,从所述常量内存读取当前层对应的第二类预计算参数,其中,所述第二类预计算参数被多个线程使用,且数据量小于预定阈值;
至少基于所述第一类预计算参数和第二类预计算参数,对所述目标数据执行当前层处理,得到中间结果;
根据所述中间结果在线程间的使用需求,将所述中间结果存储在所述多个存储结构中对应的存储结构中。
第二方面,提供了一种执行层次同态加密运算的装置,设置于图像处理器GPU,所述GPU具有多个存储结构,所述多个存储结构至少包括:全局内存和常量内存,所述装置包括:
获取单元,用于获取有待利用目标同态操作函数执行当前层处理的目标数据;
读取单元,用于从所述全局内存读取当前层对应的第一类预计算参数,从所述常量内存读取当前层对应的第二类预计算参数,其中,所述第二类预计算参数被多个线程使用,且数据量小于预定阈值;
执行单元,用于至少基于所述第一类预计算参数和第二类预计算参数,对所述目标数据执行当前层处理,得到中间结果;
存储单元,用于根据所述中间结果在线程间的使用需求,将所述中间结果存储在所述多个存储结构中对应的存储结构中。
第三方面,提供了一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行第一方面的方法。
第四方面,提供了一种计算设备,包括存储器和处理器,所述存储器中存储有可执行代码,该处理器执行所述可执行代码时,实现第一方面的方法。
本说明书一个或多个实施例提供的执行层次同态加密运算的方法及装置,通过将同态操作函数的预计算参数,按照类别分别存储在GPU的不同存储结构中,以及将在执行同态操作函数的过程中得到的中间结果,按照线程间的使用需求存储在GPU的不同存储结构中,可以充分利用不同存储结构的性能优势,进而提升层次同态加密运算的效率。
为了更清楚地说明本说明书实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。
图1示出异构框架示意图;
图2示出基于异构框架执行层次同态加密运算的方法示意图;
图3示出层次化的预计算参数示意图;
图4示出在一个示例中算子的模块化部署示意图;
图5示出资源池化管理示意图;
图6示出根据一个实施例的执行层次同态加密运算的方法流程图;
图7示出根据一个实施例的执行层次同态加密运算的装置示意图。
下面结合附图,对本说明书提供的方案进行描述。
以下先对前述提到的异构框架进行说明。
图1示出异构框架示意图。图1中,异构框架包括CPU(也称主机)和GPU(也称设备),CPU和GPU之间通过PCle总线连接在一起来协同工作。具体地,GPU通常用于执行计算密集型任务,比如,大型矩阵运算。CPU可以用于执行复杂的逻辑运算,因此其适合控制密集型任务。另外,运行在CPU上的线程是重量级的,上下文切换开销大,但是运行在GPU上的线程是轻量级的。因此,基于CPU和GPU的异构框架可以优势互补,CPU负责处理逻辑复杂的串行程序,而GPU重点处理数据密集型的并行计算程序,从而发挥最大功效。
图1中,GPU可以包括多个存储结构:共享内存、常量内存、寄存器和全局内存(也称显存)。其中,共享内存可以被一个线程块内的所有线程访问,其生命周期与线程块一致。常量内存是一种只读存储,其用于存储在内核执行过程中不会更改的数据。应理解,线程从常量内存中读取到内容后可以广播到所属线程束(warps)中的其它线程。因此,当线程束中的所有线程从常量缓存中的相同地址读取数据时,读取速度和从寄存器中读取相当。寄存器仅被单个线程访问。全局内存可以被所有线程访问,且可以被CPU访问。
应理解,GPU中不同的存储结构具有不同的性能优势,比如,全局内存的存储空间大,常量内存的读取速度快等等。本方案将充分利用GPU的不同存储结构的性能优势,以加速层次同态加密运算,后续对此进行详细说明。
图2示出基于异构框架执行层次同态加密运算的方法示意图。图2中,首先,用户通过CPU配置待执行的层次同态加密运算中各同态操作函数的基础参数(也称算法参数)。以层次同态加密运算为CKKS、BFV或TFHE为例来说,这里的基础参数可以包括:多项式长度N、剩余数系统(Residue Number System,RNS)分解个数pnum、明文模数t和密文模数Q(pnum个qi的乘积)等。之后,CPU基于用户配置的基础参数计算预计算参数,并将基础参数和预计算参数同步至GPU。这里的预计算参数可以包括:RNS分解下的pnum个模数、pnum组长度为N的数论变换(Number Theoretic Transform,NTT)系数以及CRT变换系数等。应理解,CPU端的基础参数和预计算参数可以构成CPU端的上下文参数,GPU端的基础参数和预计算参数可以构成GPU端的上下文参数。
需要说明,对于部分预计算参数,CPU可以按照层级进行组织。比如,对于上述pnum个模数,可以组织为pnum个层级。对于CPU按照层级维护的预计算参数,在GPU端同样按照层级进行维护。
在将预计算参数同步至GPU后,用户可以针对待执行的层次同态加密运算搭建对应的应用,该应用包括在CPU端运行的Host代码部分和在GPU端运行的device代码部分,其中,通过执行Host代码部分,可以实现在CPU端执行层次同态加密运算中的一部分同态操作,通过执行device代码部分,可以实现在GPU端执行另一部分同态操作,也就是说,层次同态加密运算中的一部分同态操作在CPU端执行,另一部分同态操作在GPU端执行。当然,在实际应用,层次同态加密运算中的全部同态操作均可以在GPU端执行,本说明书对此不作限定。
应理解,在执行上述的应用之后,就可以得到层次同态加密运算的运算结果。
需要说明,为了提升层次同态加密运算的效率,本方案针对在GPU端执行的同态操作进行加速,具体地,对在GPU端执行的算法框架作出如下几点改进:
第一,层次化使用GPU的不同存储结构。
首先,将预计算参数按照类别分别存储在GPU的不同存储结构中。具体地,将数据量大于预定阈值或者不会被多个线程取相同地址的预计算参数(以下称第一类预计算参数)存储在全局内存中。将会被一个线程块内的多个线程使用,且数据量小于预定阈值的预计算参数(即第二类预计算参数)存储在常量内存中。
如前所述,由于线程从常量内存中读取到内容后可以广播到所属线程束中的其它线程,因此,将上述第二类预计算参数存储在常量内存中,可以提升读取效率。而对于不会被多个线程取相同地址的预计算参数,由于在将其存入常量内存时,无法发挥常量内存的优势,从而将其存储在全局内存中。
其次,将在执行同态操作函数的过程中得到的中间结果,按照其在线程间的使用需求分别存储在GPU的不同存储结构中,后续对此进行详细说明。
基于上述第一个改进点,可以实现充分利用不同存储结构的性能优势,进而可以加速在GPU端执行的同态操作。
第二,对于按照层级组织的预计算参数,CPU和GPU针对同一个层级维护相同的层标识符。
图3示出层次化的预计算参数示意图。图3中,CPU端针对同态操作函数维护的L层预计算参数与GPU端维护的L层预计算参数相同,且CPU端的第L层与GPU端的第L层具有相同的层标识符,CPU端的第L-1层与CPU端的第L-1层具有相同的层标识符,依次类推。
图3中,每一层预计算参数按照类别会被存储到不同存储结构中。比如,第L层预计算参数中的一部分会被存储到全局内存中,另一部分会被存储到常量内存中。
基于上述第二个改进点,可以加速CPU和GPU之间的通信效率,进而可以加速在GPU端执行的同态操作。
第三,将同态操作函数所含算子进行解耦,并且针对其中的目标算子维护多个实现模块。在用户配置基础参数后,GPU自适应地根据配置的基础参数,为该目标算子选定对应的目标实现模块。这里的目标算子包括以下中的任一项:模运算算子、NTT算子、基转换算子以及伽罗瓦算子等。
图4示出在一个示例中算子的模块化部署示意图。图4中,NTT算子和模运算算子各自分别与三个实现模块相对应,且各个实现模块处理的模数位宽不同。之后在用户配置pnum个qi后,针对该每个算子,可以将其对应的三个实现模块中,所处理的模数位宽不小于预先配置的模数位宽(即qi的位宽),且在当前硬件环境下,性能最优的实现模块选定为目标实现模块。
此外,本方案还进行了资源池化管理,具体可以参见图5所示。图5中,在GPU中构建了流池、随机数池和显存池等,其中,流池中初始化有多个流:Stream0-StreamN,这里的流可以看作是顺序执行的一系列任务(可能由不同的主机线程发出),位于同一个流中的多个任务串行执行,不同流之间的任务可以并行执行。在同态运算过程中,可以使用流池中的一个或多个流来提升计算并行性(也即GPU通过流来管理并发任务)。需要说明,该流池中的多个流可以在层次同态加密运算开始前统一初始化,以及在层次同态加密运算结束后统一释放,由此可以避免同态运算过程中,流初始化与流释放带来的性能影响。
上述的随机数池可以看作是在全局内存中分配的一块固定大小的空间,其中填充满随机数,供后续运算过程中使用。当所有随机数都被使用过后,将重新填充满新的随机数。随机数池将在同态运算结束后释放,由此可以避免运算过程中频繁生成随机数带来的性能影响。
上述的显存池可以看作是在全局内存中分配的一块较大的空间,供后续运算过程中使用。具体地,在运算过程中,可以从显存池中申请一小块区域(以下称显存块)分配给某个变量,在这个变量的声明周期结束后,回收并标识对应的显存块为可用,继续分配给后续运算过程中的某个变量。当显存池空间不够时,将再次初始化一块区域,直到整个GPU上的显存均被使用后出现显存不够的错误。显存池在同态运算过程中不会被释放,在同态运算结束后进行释放,由此可以避免运算过程中频繁初始化和释放显存带来的性能影响。
需要说明,在实际中,也可以将显存池中的显存块分配给流池中的某个流,并由该流唯一占用,其它流访问需要先进行流同步(参见图5中虚线箭头),防止出现数据读写错误。
以下对基于上述几点改进,在GPU端执行同态操作的过程进行说明。
图6示出根据一个实施例的执行层次同态加密运算的方法流程图,该方法通过异构框架中的GPU执行。需要说明,该方法包括多轮迭代,图6示出其中任一轮迭代包括的方法步骤。应理解,通过重复执行其中示出的方法步骤,可以完成在GPU端的所有同态操作。如图6所示,该方法可以包括如下步骤:
步骤S602,获取有待利用目标同态操作函数执行当前层处理的目标数据。
上述的目标同态操作函数,是指待执行的层次同态加密运算所包括的多个同态操作函数中在GPU端执行的同态操作函数。
此外,在上述任一轮迭代为首轮迭代时,上述的目标数据可以是由CPU在执行完成本侧的同态操作函数后提供的明文或密文计算结果,或者由CPU转发的用户输入数据。而在上述任一轮迭代为非首轮迭代时,上述的目标数据为在上一轮迭代得到的明文或密文计算结果。
在目标数据由CPU提供给GPU的情况下,在目标数据对应的变量结构(比如,类)中还可以包含目标层标识符,以供GPU基于目标层标识符确定当前层。
在目标数据为在上一轮迭代得到的明文或密文计算结果的情况下,GPU可以确定对应于明文或密文计算结果的目标层标识符(具体可以参照下文中最终结果对应的层标识符的确定方法),并基于其确定当前层。
需要说明,对于上述的目标数据,GPU可以将其作为一个变量,并从显存池申请显存块来存储该目标数据。
步骤S604,从全局内存读取当前层对应的第一类预计算参数,从常量内存读取当前层对应的第二类预计算参数。
其中,第一类预计算参数的数据量大于预定阈值或者其不会被多个线程取相同地址。第二类预计算参数会被一个线程块内的多个线程使用,且数据量小于预定阈值。在一个示例中,这里的第一类预计算参数例如可以CRT变换系数等,第二类预计算参数例如可以为,RNS分解下的pnum个模数以及NTT系数等。
由于线程从常量内存中读取到内容后可以广播到所属线程束中的其它线程,因此,将上述第二类预计算参数存储在常量内存中,可以提升读取效率。
具体地,GPU根据上述目标层标识符,从全局内存读取当前层对应的第一类预计算参数,从常量内存读取当前层对应的第二类预计算参数。
举例来说,假设上述目标层标识符为图3中第L层对应的层标识符,那么可以根据该目标层标识符,从全局内存读取第L层的第一类预计算参数,以及从常量内存读取第L层的第二类预计算参数。
当然,在实际中,还从全局内存中读取与目标同态操作函数相关的基础参数。这里的基础参数例如可以为多项式长度N、剩余数系统(Residue Number System,RNS)分解个数pnum、明文模数t和密文模数Q等。
步骤S606,至少基于第一类预计算参数和第二类预计算参数,对目标数据执行当前层处理,得到中间结果。
其中,在目标同态操作函数为加密函数或解密函数的情况下,上述对目标数据执行当前层处理,包括:从随机数池中读取一定数量的随机数,基于读取的随机数,以及第一类预计算参数和第二类预计算参数,对目标数据执行当前层处理。
需要说明,本方案从随机数池中读取随机数,可以避免运算过程中频繁生成随机数带来的性能影响。
在实际中,上述目标同态操作函数可以包括若干目标算子,这里的目标算子是指GPU针对其维护有多个实现模块的算子。该若干目标算子包括以下中的至少一项:模运算算子、数论变换NTT算子、基转换算子以及伽罗瓦算子等。
在目标同态操作函数包括若干目标算子的情况下,上述对目标数据执行当前层处理包括:执行针对该若干目标算子预先选定的各目标实现模块。各目标实现模块为,上述若干目标算子各自对应的多个实现模块中,所处理的模数位宽不小于预先配置的模数位宽(即qi的位宽),且在当前硬件环境下,性能最优的实现模块。
需要说明,本方案针对目标算子进行模块化设计,不仅增强了目标算子执行的灵活性,还方便于对目标算子进行性能测试。
此外,步骤是S606中,可以是同时基于在从全局内存中读取的基础参数,以及第一类预计算参数和第二类预计算参数,对目标数据执行当前层处理。
以目标同态操作函数包括NTT算子为例来说,读取的基础参数可以包括:多项式长度N、RNS分解的模数qi以及模数个数pnum,以及读取的第一类预计算参数可以包括:pnum个NTT系数,对目标数据执行当前层处理包括:根据RNS分解的模数qi,将目标数据分成pnum个独立计算任务。将每个独立计算任务分配至从上述流池中申请的某个流中,以利用多线程并行地基于pnum个NTT系数,对pnum个独立计算任务执行长度为多项式长度N的NTT变换。
应理解,在将每个独立计算任务分配至从上述流池中申请的某个流后,可以加快pnum个独立计算任务计算速度。此外,由于流池在层次同态加密运算开始前统一初始化,以及在层次同态加密运算结束后统一释放,由此可以避免同态运算过程中,流初始化与流释放带来的性能影响。
步骤S608,根据中间结果在线程间的使用需求,将中间结果存储在多个存储结构中对应的存储结构中。
需要说明,上述的中间结果可以分为两类:核函数的输入或最终产出,以及核函数的中间产出。
其中,在上述中间结果为核函数的输入或最终产出的情况下,可以将该中间结果存储在全局内存中。
在上述中间结果为核函数的中间产出的情况下,根据中间结果在线程间的使用需求,将中间结果存储在多个存储结构中对应的存储结构中。
具体地,若使用需求指示在线程块内线程之间同步或跨线程使用,则将中间结果存储在共享内存中;若使用需求指示在单线程内使用,则将中间结果存储在寄存器中,以尽可能地使用寄存器资源;若使用需求指示跨线程块进行同步或使用,则将中间结果存储在全局内存中。
当然,在实际中,除了上述中间结果外,GPU还可以得到与目标同态操作函数对应的最终结果。对于该最终结果,GPU可以根据与目标同态操作函数对应的模数损失数目,确定该最终结果对应的层标识符。
具体地,GPU可以将与目标同态操作函数相对应的模数损失数目作为损失层数n。之后,可以根据当前层与损失层数的差值,确定更新层。比如,在当前层为第L层时,更新层为第L-n层。最后,将第L-n层对应的层标识符作为最终结果对应的层标识符。
需要说明,在GPU得到上述计算结果及其对应的层标识符后,若此时还未达到迭代结束条件(比如,还存在未执行的同态操作函数等),那么将该计算结果作为目标数据,并将更新层作为当前层执行下一轮迭代,直至达到迭代结束条件。而若达到迭代结束条件,则GPU可以将最终结果及其对应的层标识符提供给CPU,使得CPU确定层次同态加密运算的运算结果。
总之,本方案对在GPU端执行的算法框架作出了如下几点改进;1.对预计算参数和中间结果进行了分类,并存储在GPU上不同的存储结构中,以发挥不同层次储存的性能优势,以及对运算过程中所需的重要资源(随机数、流和内存)进行了高效的池化管理,避免了临时分配与释放带来的性能影响。2.为了避免设备间上下文参数的频繁传输,构建了层标识符机制,从而在设备内(即GPU内)可以通过层标识符选定对应层的预计算参数,设备间(即CPU与GPU间)可以通过层标识符进行快速同步,显著提升了设备间上下文的通信效率。3.对算法实现进行了高度模块化处理,每一个算子包含一种或多种实现,根据不同的基础参数可以自适应选择最优的实现搭配,对不同的GPU硬件可以实现快速搭配测试,提升性能和开发效率。
与上述执行层次同态加密运算的方法对应地,本说明书一个实施例还提供的一种执行层次同态加密运算的装置,设置于图像处理器GPU,该GPU具有多个存储结构,该多个存储结构至少包括:全局内存和常量内存。如图7所示,该装置可以包括:
获取单元702,用于获取有待利用目标同态操作函数执行当前层处理的目标数据。
读取单元704,用于从全局内存读取当前层对应的第一类预计算参数,从常量内存读取当前层对应的第二类预计算参数,其中,第二类预计算参数被多个线程使用,且数据量小于预定阈值。
执行单元706,用于至少基于第一类预计算参数和第二类预计算参数,对目标数据执行当前层处理,得到中间结果。
存储单元708,用于根据中间结果在线程间的使用需求,将中间结果存储在多个存储结构中对应的存储结构中。
在一个实施例中,上述多个存储结构还包括:共享内存和寄存器;
存储单元708具体用于:
若上述使用需求指示在线程块内线程之间同步或跨线程使用,则将中间结果存储在共享内存中;
若上述使用需求指示在单线程内使用,则将中间结果存储在寄存器中;
若上述使用需求指示跨线程块进行同步或使用,则将中间结果存储在全局内存中。
在一个实施例中,GPU包括在异构框架中,该异构框架还包括CPU,GPU和CPU均针对目标同态操作函数维护有多个层级的第一类预计算参数和第二类预计算参数,且CPU和GPU各自针对同一层级维护相同的层标识符;
获取单元702具体用于:
从CPU接收目标数据以及当前层对应的目标层标识符;
读取单元704具体用于:
根据目标层标识符,从全局内存读取当前层对应的第一类预计算参数,从常量内存读取当前层对应的第二类预计算参数。
在一个实施例中,目标同态操作函数包括若干目标算子,GPU中维护有若干目标算子各自对应的多个实现模块;
执行单元706具体用于:
利用针对若干目标算子预先选定的各目标实现模块,对目标数据执行当前层处理;其中任一目标算子对应的目标实现模块,基于当前硬件环境以及预配置的模数位宽选择得到。
在一个实施例中,上述若干目标算子包括以下中的至少一项:模运算算子、数论变换NTT算子、基转换算子以及伽罗瓦算子等。
在一个实施例中,GPU中初始化有流池,目标同态操作函数包括:数论变换NTT算子;
执行单元706包括:
拆分子模块7062,用于将目标数据分成若干独立计算任务;
分配子模块7064,用于将每个独立计算任务分配至从流池中申请的某个流中,以利用多线程并行地对各个独立计算任务执行NTT变换。
在一个实施例中,GPU中初始化有随机数池,目标同态操作函数为加密函数或解密函数;
执行单元706具体用于:
从随机数池中读取一定数量的随机数,基于读取的随机数,以及第一类预计算参数和第二类预计算参数,对目标数据执行当前层处理。
在一个实施例中,该装置还包括:确定单元710和发送单元712;
获取单元702,还用于获取与目标同态操作函数对应的最终结果;
确定单元710,用于将与目标同态操作函数相对应的模数损失数目作为损失层数,并根据当前层与损失层数的差值,确定更新层;
发送单元712,用于将更新层对应的层标识符和最终结果提供给CPU,使得CPU确定层次同态加密运算的运算结果。
本说明书上述实施例装置的各功能模块的功能,可以通过上述方法实施例的各步骤来实现,因此,本说明书一个实施例提供的装置的具体工作过程,在此不复赘述。
本说明书一个实施例提供的执行层次同态加密运算的装置,可以提升层次同态加密运算的效率。
根据另一方面的实施例,还提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行结合图6所描述的方法。
根据再一方面的实施例,还提供一种计算设备,包括存储器和处理器,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现结合图6所描述的方法。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于介质或设备实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。
以上所述的具体实施方式,对本说明书的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本说明书的具体实施方式而已,并不用于限定本说明书的保护范围,凡在本说明书的技术方案的基础之上,所做的任何修改、等同替换、改进等,均应包括在本说明书的保护范围之内。
Claims (18)
- 一种执行层次同态加密运算的方法,通过图像处理器GPU执行,所述GPU具有多个存储结构,所述多个存储结构至少包括:全局内存和常量内存,所述方法包括:获取有待利用目标同态操作函数执行当前层处理的目标数据;从所述全局内存读取当前层对应的第一类预计算参数,从所述常量内存读取当前层对应的第二类预计算参数,其中,所述第二类预计算参数被多个线程使用,且数据量小于预定阈值;至少基于所述第一类预计算参数和第二类预计算参数,对所述目标数据执行当前层处理,得到中间结果;根据所述中间结果在线程间的使用需求,将所述中间结果存储在所述多个存储结构中对应的存储结构中。
- 根据权利要求1所述的方法,其中,所述多个存储结构还包括:共享内存和寄存器;所述将所述中间结果存储在所述多个存储结构中对应的存储结构中,包括:若所述使用需求指示在线程块内线程之间同步或跨线程使用,则将所述中间结果存储在所述共享内存中;若所述使用需求指示在单线程内使用,则将所述中间结果存储在所述寄存器中;若所述使用需求指示跨线程块进行同步或使用,则将所述中间结果存储在所述全局内存中。
- 根据权利要求1所述的方法,其中,所述GPU包括在异构框架中,所述异构框架还包括CPU,所述GPU和CPU均针对所述目标同态操作函数维护有多个层级的第一类预计算参数和第二类预计算参数,且所述CPU和GPU各自针对同一层级维护相同的层标识符;所述获取有待利用目标同态操作函数执行当前层处理的目标数据,包括:从所述CPU接收所述目标数据以及当前层对应的目标层标识符;所述从所述全局内存读取当前层对应的第一类预计算参数,从所述常量内存读取当前层对应的第二类预计算参数,包括:根据所述目标层标识符,从所述全局内存读取当前层对应的第一类预计算参数,从所述常量内存读取当前层对应的第二类预计算参数。
- 根据权利要求1所述的方法,其中,所述目标同态操作函数包括若干目标算子;所述GPU中维护有所述若干目标算子各自对应的多个实现模块;所述对所述目标数据执行当前层处理,包括:利用针对所述若干目标算子预先选定的各目标实现模块,对所述目标数据执行当前层处理;其中任一目标算子对应的目标实现模块,基于当前硬件环境以及预配置的模数位宽选择得到。
- 根据权利要求4所述的方法,其中,所述若干目标算子包括以下中的至少一项:模运算算子、数论变换NTT算子、基转换算子以及伽罗瓦算子。
- 根据权利要求1所述的方法,其中,所述GPU中初始化有流池;所述目标同态操作函数包括:数论变换NTT算子;所述对所述目标数据执行当前层处理,包括:将所述目标数据分成若干独立计算任务;将每个独立计算任务分配至从所述流池中申请的某个流中,以利用多线程并行地对各个独立计算任务执行NTT变换。
- 根据权利要求1所述的方法,其中,所述GPU中初始化有随机数池;所述目标同态操作函数为加密函数或解密函数;所述对所述目标数据执行当前层处理,包括:从所述随机数池中读取一定数量的随机数,基于所述随机数,以及所述第一类预计算参数和第二类预计算参数,对所述目标数据执行当前层处理。
- 根据权利要求1所述的方法,还包括:获取与所述目标同态操作函数对应的最终结果;将与所述目标同态操作函数相对应的模数损失数目作为损失层数,并根据当前层与所述损失层数的差值,确定更新层;将所述更新层对应的层标识符和所述最终结果提供给所述CPU,使得所述CPU确定所述层次同态加密运算的运算结果。
- 一种执行层次同态加密运算的装置,设置于图像处理器GPU,所述GPU具有多个存储结构,所述多个存储结构至少包括:全局内存和常量内存,所述装置包括:获取单元,用于获取有待利用目标同态操作函数执行当前层处理的目标数据;读取单元,用于从所述全局内存读取当前层对应的第一类预计算参数,从所述常量内存读取当前层对应的第二类预计算参数,其中,所述第二类预计算参数被多个线程使用,且数据量小于预定阈值;执行单元,用于至少基于所述第一类预计算参数和第二类预计算参数,对所述目标数据执行当前层处理,得到中间结果;存储单元,用于根据所述中间结果在线程间的使用需求,将所述中间结果存储在所述多个存储结构中对应的存储结构中。
- 根据权利要求9所述的装置,其中,所述多个存储结构还包括:共享内存和寄存器;所述存储单元具体用于:若所述使用需求指示在线程块内线程之间同步或跨线程使用,则将所述中间结果存储在所述共享内存中;若所述使用需求指示在单线程内使用,则将所述中间结果存储在所述寄存器中;若所述使用需求指示跨线程块进行同步或使用,则将所述中间结果存储在所述全局内存中。
- 根据权利要求9所述的装置,其中,所述GPU包括在异构框架中,所述异构框架还包括CPU,所述GPU和CPU均针对所述目标同态操作函数维护有多个层级的第一类预计算参数和第二类预计算参数,且所述CPU和GPU各自针对同一层级维护相同的层标识符;所述获取单元具体用于:从所述CPU接收所述目标数据以及当前层对应的目标层标识符;所述读取单元具体用于:根据所述目标层标识符,从所述全局内存读取当前层对应的第一类预计算参数,从所述常量内存读取当前层对应的第二类预计算参数。
- 根据权利要求9所述的装置,其中,所述目标同态操作函数包括若干目标算子;所述GPU中维护有所述若干目标算子各自对应的多个实现模块;所述执行单元具体用于:利用针对所述若干目标算子预先选定的各目标实现模块,对所述目标数据执行当前层处理;其中任一目标算子对应的目标实现模块,基于当前硬件环境以及预配置的模数位宽选择得到。
- 根据权利要求12所述的装置,其中,所述若干目标算子包括以下中的至少一项:模运算算子、数论变换NTT算子、基转换算子以及伽罗瓦算子。
- 根据权利要求9所述的装置,其中,所述GPU中初始化有流池;所述目标同态操作函数包括:数论变换NTT算子;所述执行单元包括:拆分子模块,用于将所述目标数据分成若干独立计算任务;分配子模块,用于将每个独立计算任务分配至从所述流池中申请的某个流中,以利用多线程并行地对各个独立计算任务执行NTT变换。
- 根据权利要求9所述的装置,其中,所述GPU中初始化有随机数池;所述目标同态操作函数为加密函数或解密函数;所述执行单元具体用于:从所述随机数池中读取一定数量的随机数,基于所述随机数,以及所述第一类预计算参数和第二类预计算参数,对所述目标数据执行当前层处理。
- 根据权利要求9所述的装置,还包括:确定单元和发送单元;所述获取单元,还用于获取与所述目标同态操作函数对应的最终结果;所述确定单元,用于将与所述目标同态操作函数相对应的模数损失数目作为损失层数,并根据当前层与所述损失层数的差值,确定更新层;所述发送单元,用于将所述更新层对应的层标识符和所述最终结果提供给所述CPU,使得所述CPU确定所述层次同态加密运算的运算结果。
- 一种计算机可读存储介质,其上存储有计算机程序,其中,当所述计算机程序在计算机中执行时,令计算机执行权利要求1-8中任一项所述的方法。
- 一种计算设备,包括存储器和处理器,其中,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现权利要求1-8中任一项所述的方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410425396.8 | 2024-04-09 | ||
| CN202410425396.8A CN118199848A (zh) | 2024-04-09 | 2024-04-09 | 执行层次同态加密运算的方法及装置 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2025214366A1 true WO2025214366A1 (zh) | 2025-10-16 |
Family
ID=91402486
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2025/087845 Pending WO2025214366A1 (zh) | 2024-04-09 | 2025-04-08 | 执行层次同态加密运算的方法及装置 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN118199848A (zh) |
| WO (1) | WO2025214366A1 (zh) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118199848A (zh) * | 2024-04-09 | 2024-06-14 | 支付宝(杭州)信息技术有限公司 | 执行层次同态加密运算的方法及装置 |
| CN118466898B (zh) * | 2024-07-09 | 2024-10-29 | 南京邮电大学 | 一种全同态乘法的gpu加速方法 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115102688A (zh) * | 2022-08-24 | 2022-09-23 | 北京信安世纪科技股份有限公司 | 数据处理方法、多项式计算方法及电子设备 |
| CN115622684A (zh) * | 2022-11-16 | 2023-01-17 | 哈尔滨工业大学(深圳)(哈尔滨工业大学深圳科技创新研究院) | 基于全同态加密的隐私计算异构加速方法及装置 |
| US20230171084A1 (en) * | 2021-11-26 | 2023-06-01 | Samsung Electronics Co., Ltd. | Appratus and method with homomorphic encryption |
| CN116488788A (zh) * | 2023-04-11 | 2023-07-25 | 胡雅婷 | 全同态加密算法的硬件加速器、同态加密方法及电子设备 |
| CN116795542A (zh) * | 2023-06-05 | 2023-09-22 | 杭州后量子密码科技有限公司 | 一种基于GPU的后量子密码Kyber并行加速方法 |
| CN118199848A (zh) * | 2024-04-09 | 2024-06-14 | 支付宝(杭州)信息技术有限公司 | 执行层次同态加密运算的方法及装置 |
-
2024
- 2024-04-09 CN CN202410425396.8A patent/CN118199848A/zh active Pending
-
2025
- 2025-04-08 WO PCT/CN2025/087845 patent/WO2025214366A1/zh active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20230171084A1 (en) * | 2021-11-26 | 2023-06-01 | Samsung Electronics Co., Ltd. | Appratus and method with homomorphic encryption |
| CN115102688A (zh) * | 2022-08-24 | 2022-09-23 | 北京信安世纪科技股份有限公司 | 数据处理方法、多项式计算方法及电子设备 |
| CN115622684A (zh) * | 2022-11-16 | 2023-01-17 | 哈尔滨工业大学(深圳)(哈尔滨工业大学深圳科技创新研究院) | 基于全同态加密的隐私计算异构加速方法及装置 |
| CN116488788A (zh) * | 2023-04-11 | 2023-07-25 | 胡雅婷 | 全同态加密算法的硬件加速器、同态加密方法及电子设备 |
| CN116795542A (zh) * | 2023-06-05 | 2023-09-22 | 杭州后量子密码科技有限公司 | 一种基于GPU的后量子密码Kyber并行加速方法 |
| CN118199848A (zh) * | 2024-04-09 | 2024-06-14 | 支付宝(杭州)信息技术有限公司 | 执行层次同态加密运算的方法及装置 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN118199848A (zh) | 2024-06-14 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2025214366A1 (zh) | 执行层次同态加密运算的方法及装置 | |
| Wang et al. | HE-Booster: an efficient polynomial arithmetic acceleration on GPUs for fully homomorphic encryption | |
| US4101960A (en) | Scientific processor | |
| Shen et al. | High-throughput GPU implementation of Dilithium post-quantum digital signature | |
| Salmon et al. | Parallel random numbers: as easy as 1, 2, 3 | |
| US5323489A (en) | Method and apparatus employing lookahead to reduce memory bank contention for decoupled operand references | |
| US4972314A (en) | Data flow signal processor method and apparatus | |
| US8776077B2 (en) | Method for multithreading an application using partitioning to allocate work to threads | |
| US8447954B2 (en) | Parallel pipelined vector reduction in a data processing system | |
| Daga et al. | Structural agnostic SpMV: Adapting CSR-adaptive for irregular matrices | |
| US12079137B2 (en) | Banked memory architecture for multiple parallel datapath channels in an accelerator | |
| Xu et al. | vtensor: Flexible virtual tensor management for efficient llm serving | |
| KR20000076636A (ko) | 메모리 관리를 위한 방법 및 장치 | |
| Marenzoni et al. | Analysis of large GSPN models: a distributed solution tool | |
| US11609785B2 (en) | Matrix data broadcast architecture | |
| US20250343693A1 (en) | Method, device, and medium for improving latency | |
| Li et al. | ORCHES: Orchestrated Test-Time-Compute-based LLM Reasoning on Collaborative GPU-PIM HEterogeneous System | |
| Hutchinson et al. | Duality between prefetching and queued writing with parallel disks | |
| US20110125805A1 (en) | Grouping mechanism for multiple processor core execution | |
| Walter et al. | LION: real-time I/O transfer control for massively parallel processor arrays | |
| EP0313787A2 (en) | A hardware mechanism for the dynamic customization of permutation using bit-matrix multiplication | |
| Li et al. | High-speed implementation of rainbow table method on heterogeneous multi-device architecture | |
| Polok et al. | Fast radix sort for sparse linear algebra on GPU. | |
| Neves et al. | Efficient data-stream management for shared-memory many-core systems | |
| Singhania et al. | LLM Inference Beyond a Single Node: From Bottlenecks to Mitigations with Fast All-Reduce Communication |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 25785892 Country of ref document: EP Kind code of ref document: A1 |