TFHE-Coder: Evaluating LLM Agents for secure Fully Homomorphic Encryption Code Generation

ICLR 2026 Conference Submission21267 Authors

19 Sept 2025 (modified: 08 Oct 2025)ICLR 2026 Conference SubmissionEveryoneRevisionsBibTeXCC BY 4.0
Keywords: Large Language Models, Agents, Code generation, Fully Homomorphic Encryption, Retrieval Augmented Generation
TL;DR: We built a three-phase agentic framework that enables Large Language Models to automatically generate secure and functional TFHE code, bridging the expertise gap that currently limits the adoption of privacy-preserving computation.
Abstract: Fully Homomorphic Encryption over the Torus (TFHE) is a cornerstone of confidential computing, yet its adoption is severely limited by a steep learning curve and the need for specialized cryptographic expertise. To bridge this skills gap, we explore if Large Language Models (LLMs) Agents can translate natural language specifications into secure TFHE code. We introduce a novel, three-phase agentic framework designed to overcome the primary failure points in this process. First, in the Instruction Phase, we automatically refine user queries into a structured Formal Prompt. Second, during the Generation Phase, a specialized Retrieval-Augmented Generation (RAG) tool provides the agent with accurate API knowledge from TFHE documentation. Finally, in the Feedback Phase, an automated Security Check module analyzes the output for cryptographic flaws and provides targeted feedback for iterative correction. We comprehensively evaluate our framework by testing four LLMs across five programming tasks of increasing difficulty. Our results demonstrate that baseline framework often produce functional but insecure code, while our framework is uniquely superior, consistently generating solutions that are simultaneously compilable, functionally correct, and secure. This work establishes a robust methodology and benchmark for TFHE code generation, demonstrating a viable path toward democratizing secure computation.
Primary Area: alignment, fairness, safety, privacy, and societal considerations
Submission Number: 21267
Loading