EncGPT: A Multi-Agent Workflow for Dynamic Encryption Algorithms

Donghe Li, Zuchen Li, Ye Yang, Li Sun, Dou An, Qingyu YangarXiv 2025

TL;DR

EncGPT introduces a novel multi-agent workflow that leverages Large Language Models (LLMs) to dynamically generate and execute encryption algorithms on the fly. By shifting from static cryptographic keys to dynamically changing rules, it provides a lightweight, cost-effective layer of communication security specifically tailored for LLM multi-agent systems (LLM-MA).

What Problem Does This Paper Address?

As Large Language Model Multi-Agent (LLM-MA) systems become more popular for solving complex tasks, agents must constantly communicate and collaborate. However, this open dialogue introduces a massive security risk: if an attacker intercepts the agent communication flow, sensitive data can be easily exposed.

Traditional cryptographic methods present a difficult trade-off. Symmetric encryption is fast but vulnerable if a key is intercepted. Asymmetric encryption is highly secure but introduces significant time and space complexity, making it too heavy for rapid, multi-round agent dialogues. Furthermore, relying on a single static encryption algorithm leaves the system vulnerable to pattern and frequency analysis.

The authors address this gap by proposing dynamic algorithm generation. Instead of just changing the keys, EncGPT changes the entire encryption algorithm every round, making it incredibly difficult for attackers to break, while keeping the computational cost low enough for real-time agent communication.

Methods

The authors introduce EncGPT, a decentralized framework consisting of three primary LLM-based agents that manage the security workflow without exposing plaintext in the main communication channel:

  • Rule Agent: Automatically designs a classical encryption scheme (such as a substitution cipher) for each round of dialogue. To prevent the LLM's natural "contextual bias" (the tendency to repeatedly choose the same numbers), the Rule Agent uses a multi-round prompt. It first creates a masked rule, defines a valid range for the variables, and then injects randomly generated numbers to finalize the key.
  • Encryption Agent: Uses Chain-of-Thought (CoT) reasoning to apply the dynamically generated rules and encrypt the input plaintext into ciphertext.
  • Decryption Agent: Reverses the process, using CoT to safely restore the ciphertext back into plaintext for the user or external environment.
Figure 1: The architecture diagram of our workflow is shown. Green lines and the matrix represent the encrypted communication flow. On the left, the Recipient Agent interacts with the external environment, while on the right, agents communicate with each other. Red lines indicate the transmission of ciphertext, and blue lines indicate the transmission of plaintext.

To maintain strict security and prevent "prompt contamination" (where old encryption rules interfere with new ones), all historical records within the agents are completely cleared after each communication round.

Datasets

The paper does not utilize standard external datasets. Instead, the evaluation was conducted using custom-generated natural language inputs and prompts designed to test GPT-4o’s capability to generate rules, encrypt text, and decrypt text across various classical algorithms.

Key Insights and Ideas

  • Security Through Algorithmic Variety: By keeping both the algorithm type and the keys confidential and changing them dynamically each round, simple and computationally cheap classical ciphers become remarkably robust against traditional cryptanalysis like frequency analysis.
  • Mitigating LLM Randomness Issues: LLMs are notoriously bad at being truly random. The authors' multi-round masking technique successfully forces the model to generate a wider variety of keys and rules.
  • LLM Homomorphism: The authors demonstrated that LLMs can preserve homomorphic properties. A recipient agent can successfully perform operations on encrypted data (e.g., counting letter frequencies) and output an encrypted result without ever seeing or decrypting the underlying plaintext.
  • The Mathematical Bottleneck: While LLMs excel at character substitution, they fail completely at complex, matrix-based, or geometric ciphers (like Playfair or Rail Fence) due to inherent limitations in spatial and advanced mathematical reasoning.

Key Results

The framework was evaluated using GPT-4o as the core engine.

  • Algorithm Preferences: When prompted to creatively generate encryption rules, GPT-4o heavily favored well-known substitution ciphers, selecting the Caesar cipher 45.6% of the time and the Vigenère cipher 33.3% of the time.
Figure 2: GPT-4o’s Preferences in Encryption Rule Generation
  • Success Rate: EncGPT achieved a 100% success rate in encryption, decryption, and homomorphic communication (E-R-D) when utilizing character substitution algorithms (Caesar, Vigenère, Atbash). However, it failed on more complex algorithms like Playfair and Rail Fence due to model hallucinations and limited mathematical capabilities.
Table showing the success and failure of encryption/decryption across different algorithms.
  • Execution Time: The average total workflow execution time across the successful substitution algorithms was 15.99 seconds (Caesar took 27.23s, Vigenère took 30.89s, and Atbash took 24.33s).

Limitations and Future Work

Despite its promise, EncGPT faces several hurdles:

  1. LLM Hallucinations: GPT-4o occasionally generates flawed or mathematically incorrect encryption rules.
  2. Symmetric Encryption Failure: Current LLMs are unable to achieve satisfactory results when attempting to process modern symmetric encryption algorithms natively.
  3. Lack of Identity Verification: The current framework does not explore communication signatures or receiver identification, leaving it open to potential impersonation risks within a decentralized network.

To address these limitations, the authors plan to explore the integration of external cryptographic tools, model fine-tuning specifically for security tasks, and the implementation of Retrieval-Augmented Generation (RAG) to improve accuracy and reduce latency.

Summary updated

BibTeX
@misc{li2025encgpt,
  author = {Donghe Li and Zuchen Li and Ye Yang and Li Sun and Dou An and Qingyu Yang},
  title = {{EncGPT: A Multi-Agent Workflow for Dynamic Encryption Algorithms}},
  year = {2025},
  eprint = {2503.23138},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.23138},
}
Figure