LLM4PQC - Accurate and Efficient Synthesis of PQC Cores by Feedback-Driven LLMs

Buddhi Perera, Zeng Wang, Weihua Xiao, Mohammed Nabeel, Ozgur Sinanoglu, Johann Knechtel, Ramesh KarriarXiv 2026

TL;DR

LLM4PQC is an automated, feedback-driven framework that uses Large Language Models (LLMs) to refactor standard C reference code of post-quantum cryptography (PQC) algorithms into hardware-synthesizable HLS-C. By coupling LLM generation with an iterative compile-simulate-synthesize feedback loop, the framework successfully produces highly area-efficient hardware accelerators while drastically reducing manual engineering effort.

What Problem Does This Paper Address?

The impending arrival of quantum computers threatens classical cryptographic standards like RSA and ECC. In response, the National Institute of Standards and Technology (NIST) has been standardizing Post-Quantum Cryptography (PQC) algorithms (such as Kyber, Dilithium, and Falcon). However, deploying PQC across diverse platforms—from high-performance servers to embedded devices—requires dedicated hardware acceleration to handle their complex mathematical subroutines.

Traditionally, hardware development relies on writing low-level Register-Transfer Level (RTL) code, which is slow and demands deep domain expertise. High-Level Synthesis (HLS) offers a shortcut by compiling C/C++ code directly into hardware. Unfortunately, official PQC reference implementations are written for software portability and clarity, not hardware synthesis. They contain numerous "synthesis blockers" like dynamic memory allocation (malloc), complex pointer structures, unsupported math libraries, and runtime constant table initializations. Manually refactoring this code for HLS is a tedious, error-prone bottleneck.

Methods

The authors introduce LLM4PQC, a framework that automates this refactoring pipeline using LLMs (specifically ChatGPT o3-mini) combined with hardware synthesis tools.

The workflow consists of four distinct phases:

Fig. 1: The four phases of LLM4PQC: (i) PQC subroutine extraction, (ii) HLS preprocessing, (iii) HLS-C generation and DSE (based on integrating C2HLSC with Catapult), and (iv) synthesis and verification. Figure generated using NotebookLM.
  1. PQC Subroutine Extraction: The LLM analyzes the PQC codebase to isolate performance-critical kernels (like the Number Theoretic Transform (NTT) or Gaussian samplers) and generates a standalone C verification harness using Known-Answer Tests (KATs).
  2. HLS Preprocessing: An LLM-aided pipeline automatically strips away synthesis blockers. It maps dynamic memory allocations to static arrays and replaces runtime initialization routines with precomputed compile-time constant arrays.
  3. HLS-C Generation & Design Space Exploration (DSE): The preprocessed code is fed into the C2HLSC framework. If the HLS tool (Catapult) throws compilation errors, the error logs are fed back to the LLM as corrective prompts. The LLM also injects HLS pragmas (like loop unrolling and pipelining) to optimize performance based on area and latency feedback.
  4. Synthesis & Verification: The final HLS-C code is synthesized into RTL (for FPGAs or ASICs) and verified against the original C-level test cases using ModelSim to guarantee functional correctness.

Datasets

The framework was evaluated using the official NIST reference implementations and well-structured implementations from the open-source PQC-clean repository. The benchmark suite consisted of five core computational primitives:

  • Kyber-NTT
  • Dilithium-NTT
  • Falcon-NTT
  • Falcon-Sampler
  • Falcon-FFT

Key Insights and Ideas

  • Feedback is Mandatory: Naive, single-shot LLM translation fails for complex hardware design. An automated, closed-loop system that treats synthesis tool errors as corrective prompts is essential for achieving valid hardware.
  • The "Sampler" Stress Test: Primitives like the Falcon Sampler are notoriously difficult for HLS tools due to heavy pointer manipulation and complex data structures. LLM4PQC overcomes this by using structure-aware prompting to flatten complex struct fields into primitive data types.
  • The Area-Latency Trade-off: Without explicit optimization constraints, LLMs naturally favor compact, sequential loop structures. This results in highly area-efficient hardware that often beats manual baselines in size, but at the cost of higher latency (slower execution times) because it lacks aggressive parallelization.

Key Results

  • High Success Rates: The framework achieved a 100% synthesis success rate for Kyber-NTT, Dilithium-NTT, and Falcon-FFT. The highly complex Falcon-Sampler achieved a 40% success rate across independent non-deterministic LLM runs.
  • ASIC Compactness: When targeting a Nangate 45nm ASIC library, Kyber-NTT produced exceptionally compact designs, averaging an area of just 2,957.54 µm².
  • FPGA Resource Savings: Compared to hand-optimized manual RTL baselines on Xilinx Artix-7 FPGAs, LLM4PQC drastically reduced area. For Dilithium-NTT, it used only 370 LUTs (compared to 7,451 in prior manual work), though latency increased from 0.71 µs to 95.20 µs.
  • Outperforming Prior AI Art: For the Falcon-Sampler on a Xilinx Zynq UltraScale+ MPSoC, LLM4PQC outperformed a recent LLM-to-HLS baseline, achieving both lower latency (0.39 µs vs 0.73 µs) and better flip-flop utilization.

Limitations and Future Work

Despite its success, LLM4PQC faces a few limitations:

  • The Latency Penalty: Because the LLM defaults to compact, sequential structures, the generated cores are significantly slower than highly parallelized, hand-crafted manual designs.
  • Floating-Point Hurdles: General-purpose LLMs still lack the deep domain knowledge required to seamlessly translate heavy floating-point operations (like those in Falcon-FFT) into hardware-friendly fixed-point logic without extensive upfront preprocessing.

To address these, the authors propose future work involving closer agentic integration, fine-tuning LLMs directly on HLS datasets, utilizing Retrieval-Augmented Generation (RAG) to inject verified hardware design patterns, and incorporating fast, pre-synthesis machine learning models to predict area and timing before running the full synthesis toolchain.

Summary updated

BibTeX
@misc{perera2026llm,
  author = {Buddhi Perera and Zeng Wang and Weihua Xiao and Mohammed Nabeel and Ozgur Sinanoglu and Johann Knechtel and Ramesh Karri},
  title = {{LLM4PQC - Accurate and Efficient Synthesis of PQC Cores by Feedback-Driven LLMs}},
  year = {2026},
  eprint = {2602.09919},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.09919},
}
Figure