AI Security
New ML-Crypto Framework Protects AI-Generated Code with Invisible Watermarks
Researchers introduce RoSeMary, a watermarking system that embeds undetectable marks in code created by large language models while preserving functionality and enabling secure verification.
Researchers have developed a novel watermarking approach for code generated by large language models, addressing growing concerns over intellectual property protection and misuse in software development. The system, called RoSeMary, combines machine learning and cryptography techniques to embed hidden markers in LLM-produced code without compromising its functionality.
The Challenge of Code Watermarking#
Watermarking digital content typically involves embedding ownership signals that are difficult to remove. However, code presents unique obstacles: its structured, low-entropy nature leaves little room for traditional watermarking approaches. Additionally, most existing verification methods require exposing the watermark signature itself—a security risk that undermines the system's practical use, especially when code is reused or modified.
How RoSeMary Works#
The framework takes an integrated approach that trains both watermark insertion and detection modules together from the ground up. By leveraging CodeT5, a pre-trained language model specialized in code, RoSeMary expands the space of syntactic and variable renaming transformations available for embedding marks. This dual training ensures the watermarks remain detectable while keeping code behavior intact.
The key innovation lies in deployment: RoSeMary employs zero-knowledge proofs—a cryptographic technique that verifies a watermark's presence without ever revealing the underlying signature. This allows ownership to be confirmed securely without compromising the mark's secrecy.
Evaluation Results#
Testing demonstrated that RoSeMary achieves strong detection accuracy across scenarios while maintaining the original functionality of watermarked code. The system also withstands adversarial attempts to remove or obscure the watermarks, and performs efficient verification without excessive computational overhead.
This work represents a step forward in protecting developer intellectual property in an era where LLM-generated code is increasingly common in software development workflows.

