Compilation system for post quantum cryptography algorithm
Through a compilation system for the back quantum cryptography algorithm, the C/C++ program writing and optimization process is used to efficiently deploy the back quantum cryptography algorithm on different hardware architectures, solving the adaptation problem of diversified algorithms in hardware architecture, and achieving flexible hardware deployment and efficient execution.
Patent Information
- Application Number
- CN202510345062.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-07-08
AI Technical Summary
Existing compilation systems cannot effectively support the deployment of diverse and continuously evolving post-quantum cryptography algorithms on different hardware architectures.
It provides a compilation system for post-quantum cryptography algorithms, which realizes the deployment of multiple post-quantum cryptography algorithms on different hardware architectures through C/C++ program writing, software operator intermediate representation optimization, hardware operator intermediate representation mapping and target code generation.
With smaller modifications, programmers can deploy multiple post-quantum cryptographic algorithms to different hardware architectures, improving the scalability of the compilation system and hardware execution efficiency.
Smart Images

Figure CN120276737A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of post - quantum cryptography technology, and in particular, to a compilation system for post - quantum cryptographic algorithms. Background Art
[0002] In recent years, the continuous development of quantum computing has brought security issues to traditional cryptography, which has attracted wide attention. Researchers have made early arrangements and proposed post - quantum cryptographic algorithms to resist quantum computer attacks. Existing post - quantum cryptographic algorithms include Kyber, Dilithium, Falcon, Sphincs +, Classic McEliece, HQC, BIKE, etc. Among them, the first four have been selected by NIST as post - quantum cryptographic standard algorithms. In addition to foreign countries, many post - quantum cryptographic algorithms have also emerged in China, including LAC, Aigis, etc. Due to different underlying mathematical problems and security levels, these algorithms have significant differences in data structure, core operators, data flow, and memory access patterns.
[0003] To run post - quantum cryptographic algorithms more efficiently, researchers have proposed some high - performance libraries for deployment on existing chips such as CPUs and GPUs, such as PQMagic. And to provide higher hardware performance, dedicated post - quantum cryptographic chips have also emerged. Compared with dedicated chips, reconfigurable architectures can provide more flexibility and become one of the implementation methods for post - quantum cryptographic chips. However, in order to support evolving algorithms, there are still severe application deployment problems.
[0004] Diverse and continuously evolving post - quantum cryptographic algorithms and hardware architectures have made the importance of a compilation system for post - quantum cryptographic algorithms increase day by day, and the existing public technologies still have not solved this problem. Summary of the Invention
[0005] In view of the above - mentioned defects of the prior art, the technical problem to be solved by the present invention is how to deploy multiple post - quantum cryptographic algorithms to different hardware architectures.
[0006] To achieve the above object, the present invention provides a compilation system for post - quantum cryptographic algorithms, which relates to the field of quantum computing. The compilation system receives a C / C++ program written according to an algorithm library, generates an intermediate representation of software operators through a front - end compilation module, performs relevant optimizations through a machine - independent optimization module to reduce redundant code. Next, the intermediate representation of software operators is converted into an intermediate representation of hardware operators through a machine - dependent optimization module and optimized for a specific hardware architecture. Finally, the intermediate representation of hardware operators selects a corresponding target code generation module according to different target hardwares to generate a file that can be executed on the target hardware.
[0007] Further, the method involved in the compilation system includes the following steps:
[0008] Step 1: Receive the source program written by the programmer based on the algorithm library as input;
[0009] Step 2: Compile the source program through the front - end of the compilation system to obtain the intermediate representation of software operators;
[0010] Step 3: Use machine - independent optimization methods to optimize the intermediate representation of software operators;
[0011] Step 4: Map the optimized intermediate representation of software operators to the intermediate representation of hardware operators according to the characteristics of the hardware architecture;
[0012] Step 5: Generate the program that can be executed by the corresponding hardware based on the intermediate representation of hardware operators according to the target architecture instruction set.
[0013] Further, in Step 1, the front - end programming language of the compilation system of the present invention is based on C / C++, and a post - quantum algorithm library is provided for the programmer to use, and the writing process follows the C / C++ syntax.
[0014] Further, the algorithm library contains a variety of cryptographic primitives and common computational primitives for different data types, and the algorithm library can be added to and modified according to the development of post - quantum encryption algorithms.
[0015] Further, in the compilation process of Step 2, existing compilation frameworks can be used, or the compiler front - end can be rewritten to perform lexical analysis, syntax analysis, etc. of the program to achieve the conversion from the source program to the intermediate representation of software operators.
[0016] Further, the intermediate representation of software operators is a form between the source program and the target code, mainly reflecting the characteristics in the software source program; through the unified intermediate representation of software operators, different types of post - quantum cryptographic algorithms can be supported, and it has scalability at the application level.
[0017] Further, in Step 3, the machine - independent compilation optimization methods include common subexpression elimination, dead code elimination, constant folding, etc. These operations can reduce redundant operations and improve the execution efficiency of the hardware on the premise of ensuring correct functionality.
[0018] Further, in Step 4, according to different hardware back - ends, the intermediate representation of software operators will be mapped to different intermediate representations of hardware operators; the intermediate representation of hardware operators refers to the characteristics of the target hardware, including information such as the supported computational operations, communication operations, data storage types, etc.;
[0019] Further, through the intermediate representation of the hardware operators, the software program and the hardware can be decoupled, enabling similar front-end programs to be deployed to different hardware back-ends, thereby improving the scalability of the compilation system. During the mapping process, different optimization strategies can be adopted according to different target hardware architectures.
[0020] Further, in step five, according to the instruction sets of different hardware, these hardware operators will generate different instruction formats.
[0021] Through the compilation method and system proposed by the present invention, programmers can deploy a variety of post-quantum cryptographic algorithms to different hardware architectures with minor modifications to the source program.
[0022] The following will further illustrate the concept, specific structure, and technical effects of the present invention in conjunction with the accompanying drawings to fully understand the purpose, features, and effects of the present invention. Description of the Drawings
[0023] Figure 1 is a system diagram of a preferred embodiment of the present invention;
[0024] Figure 2 is a flowchart of a preferred embodiment of the present invention. Detailed Embodiments
[0025] The following introduces multiple preferred embodiments of the present invention with reference to the accompanying drawings of the specification to make its technical content clearer and easier to understand. The present invention can be embodied in many different forms of embodiments, and the protection scope of the present invention is not limited to the embodiments mentioned in the text.
[0026] In the drawings, components with the same structure are denoted by the same numerical labels, and components with similar structures or functions are denoted by similar numerical labels. The size and thickness of each component shown in the drawings are arbitrarily shown, and the present invention does not limit the size and thickness of each component. To make the illustration clearer, the thickness of some components in the drawings is appropriately exaggerated.
[0027] As Figure 1 shown, the compilation system receives a C / C++ program written according to an algorithm library, generates an intermediate representation of software operators through a front-end compilation module, performs relevant optimizations through a machine-independent optimization module to reduce redundant code. Next, the intermediate representation of software operators is transformed into an intermediate representation of hardware operators through a machine-dependent optimization module and optimized for a specific hardware architecture. Finally, the intermediate representation of hardware operators selects a corresponding target code generation module according to different target hardware, and finally generates a file that can be executed on the target hardware.
[0028] As Figure 2As shown in the figure, the flowchart of the compilation method for the post-quantum cryptography algorithm proposed by the present invention is as follows:
[0029] Step 1: Receive the source program written by the programmer based on the algorithm library as input;
[0030] Step 2: Compile the source program through the front end of the compilation system to obtain the intermediate representation of software operators;
[0031] Step 3: Use machine-independent optimization methods to optimize the intermediate representation of software operators;
[0032] Step 4: Map the optimized intermediate representation of software operators to the intermediate representation of hardware operators according to the characteristics of the hardware architecture;
[0033] Step 5: Generate the program that can be executed by the corresponding hardware according to the target architecture instruction set from the intermediate representation of hardware operators.
[0034] In Step 1, the front-end programming language of the compilation system of the present invention is based on C / C++, and a post-quantum algorithm library is provided for programmers to use, and the writing process complies with C / C++ syntax. The algorithm library contains a variety of cryptographic primitives, such as hash functions SHA2, SHA3, pseudo-random number generators, and common computational primitives for different data types, such as polynomial operations, matrix operations, vector operations, number-theoretic transforms, fast Fourier transforms, etc. This algorithm library can be added and modified according to the development of post-quantum encryption algorithms. The compilation system of the present invention supports control statements such as branches, loops, and function calls, thus supporting more diverse application programs. The algorithm library proposed by the present invention supports configurable parameters, thus supporting the requirements for different security strengths in different scenarios.
[0035] In addition to computing tasks, the compilation system of the present invention also provides two data layout methods to improve the algorithm deployment performance, namely the manual data address allocation and the automatic address allocation modes. Such data layout methods are mainly for the case where the on-chip storage of the target hardware architecture needs to be managed by software rather than using on-chip caches. If the manual data address allocation is selected, the #pragma instruction can be used to allocate the data address of variables on the target hardware. If no annotation is made, the data will be automatically allocated on-chip addresses in Step 4.
[0036] The compilation process in Step 2 can adopt existing compilation frameworks, such as LLVM, MLIR, etc., or the compiler front end can be rewritten to perform lexical analysis, syntax analysis, etc. of the program to realize the conversion from the source program to the intermediate representation of software operators.
[0037] The intermediate representation of software operators is a form between the source program and the target code, mainly reflecting the features in the software source program, such as control flow, data flow, etc. Taking MLIR as an example, the present invention defines a brand-new dialect for the post-quantum cryptography field. Its data structures include polynomials, vectors, matrices, etc., its operations include various cryptographic primitives and computational operations of different data types, and its additional attributes include data addresses identified from the front end, etc. Through the unified intermediate representation of software operators, different types of post-quantum cryptographic algorithms can be supported, and scalability at the application level can be achieved.
[0038] In step three, common machine-independent compilation optimization methods are included, such as common subexpression elimination, dead code elimination, constant folding, etc. These operations can reduce redundant operations and improve the execution efficiency of the hardware while ensuring the correct function.
[0039] In step four, according to different hardware backends, software operators will be mapped to the intermediate representation of different hardware operators. The intermediate representation of hardware operators represents the features of the target hardware, such as the computational operations, communication operations, data storage types, etc. that it supports. Through this intermediate representation of hardware operators, the software program and the hardware can be decoupled, and similar front-end programs can be deployed to different hardware backends to improve the scalability of the compilation system. For example, if the target hardware is a CPU without a vector operation unit, these operators will be mapped to low-level scalar operations. When the CPU contains vector extension units such as AVX, the hardware operators will be mapped to a mixture of scalar operators and vector operators. If the target hardware is a reconfigurable hardware chip, the compilation system will perform hardware abstraction on it and summarize the hardware operators of this architecture. Software operators will be mapped to corresponding hardware operator types according to different architecture designs.
[0040] During the mapping process, different optimization strategies can be adopted according to different target hardware architectures, such as pipelining between tasks, automatic address allocation of data, etc.
[0041] In step five, according to the instruction sets of different hardware, these hardware operators will generate different instruction formats. For example, for a CPU, the hardware operators will generate instructions, and for a reconfigurable chip, corresponding configuration words will be generated.
[0042] The preferred specific embodiments of the present invention have been described in detail above. It should be understood that those of ordinary skill in the art can make many modifications and variations based on the concept of the present invention without creative labor. Therefore, all technical solutions that can be obtained by those skilled in the art in the technical field based on the concept of the present invention through logical analysis, reasoning, or limited experiments on the basis of the prior art should be within the protection scope determined by the claims.
Claims
1. A compilation system for post - quantum cryptographic algorithms, which relates to the field of post - quantum cryptography. The compilation system receives a C / C++ program written based on an algorithm library, generates an intermediate representation of software operators through a front - end compilation module, performs relevant optimizations through a machine - independent optimization module to reduce redundant code. Next, the intermediate representation of software operators is transformed into an intermediate representation of hardware operators through a machine - dependent optimization module and optimized for a specific hardware architecture. Finally, the intermediate representation of hardware operators selects the corresponding target code generation module according to different target hardwares and generates a file that can be executed on the target hardware.
2. The compilation system for post-quantum cryptographic algorithms according to claim 1, characterized in that The method involved in the compilation system includes the following steps: Step 1: Receive the source program written by a programmer based on the algorithm library as input; Step 2: Compile the source program through the front - end of the compilation system to obtain the intermediate representation of software operators; Step 3: Use machine - independent optimization methods to optimize the intermediate representation of software operators; Step 4: Map the optimized intermediate representation of software operators to the intermediate representation of hardware operators according to the characteristics of the hardware architecture; Step 5: Generate a program that can be executed by the corresponding hardware according to the instruction set of the target architecture from the intermediate representation of hardware operators.
3. The compilation system for post-quantum cryptography algorithms according to claim 2, wherein In Step 1, the front - end programming language of the compilation system of the present invention is based on C / C++, and a post - quantum algorithm library is provided for programmers to use, and the writing process follows the C / C++ syntax.
4. The compilation system for post-quantum cryptographic algorithms according to claim 3, characterized in that, The algorithm library contains a variety of cryptographic primitives and common computational primitives for different data types. The algorithm library can be added to and modified according to the development of post - quantum encryption algorithms.
5. The compilation system for post-quantum cryptographic algorithms according to claim 4, wherein In the compilation process of Step 2, an existing compilation framework can be adopted, or the compiler front - end can be rewritten to perform lexical analysis, syntax analysis, etc. of the program to achieve the conversion from the source program to the intermediate representation of software operators.
6. The compilation system for post-quantum cryptographic algorithms according to claim 5, wherein The intermediate representation of software operators is a form between the source program and the target code, mainly reflecting the characteristics in the software source program; through the unified intermediate representation of software operators, different types of post - quantum cryptographic algorithms can be supported and scalability at the application level can be achieved.
7. The compilation system for post-quantum cryptographic algorithms according to claim 6, characterized in that, In Step 3, the machine - independent compilation optimization methods include common sub - expression elimination, dead - code elimination, constant folding, etc. These operations can reduce redundant operations and improve the execution efficiency of the hardware on the premise of ensuring correct functionality.
8. The compilation system for post-quantum cryptographic algorithms according to claim 7, characterized in that, In Step 4, according to different hardware back - ends, the intermediate representation of software operators will be mapped to different intermediate representations of hardware operators; the intermediate representation of hardware operators refers to the characteristics of the target hardware, including information such as supported computational operations, communication operations, and data storage types.
9. The compilation system for post-quantum cryptography algorithms according to claim 8, characterized in that Through the intermediate representation of hardware operators, the software program and the hardware can be decoupled, so that similar front - end programs can be deployed to different hardware back - ends to improve the scalability of the compilation system; during the mapping process, different optimization strategies can be adopted according to different target hardware architectures.
10. The compilation system for post-quantum cryptographic algorithms according to claim 9, characterized in that, In Step 5, according to the instruction sets of different hardwares, these hardware operators will generate different instruction formats.
Citation Information
Cited By
NPU instruction optimization system and optimization method for OpenCL heterogeneous computing
CN121541929A
An NPU instruction optimization system and method for OpenCL heterogeneous computing
CN121541929B