Publicly-Detectable Watermarking for Language Models

Jaiden Fairoze, Sanjam Garg, Somesh Jha, Saeed Mahloujifar, Mohammad Mahmoody, Mingyuan Wang

TL;DR

This paper introduces the first publicly-detectable, distortion-free watermarking scheme for large language models (LLMs). By leveraging public-key cryptography and error-correcting codes, the method allows anyone to verify a watermark using a public key, while ensuring that only the model provider can embed it.

What Problem Does This Paper Address?

As generative AI text becomes ubiquitous, distinguishing machine-generated text from human-written content is critical to preventing misinformation, academic dishonesty, and fraud. Current watermarking techniques typically rely on symmetric cryptography, meaning the model provider and the detector must share a secret key.

This creates significant real-world bottlenecks:

  1. Privacy Concerns: Users must share their sensitive text with a third-party detector to verify it.
  2. Conflicts of Interest: Model providers are often the sole gatekeepers of detection APIs, creating trust issues in legal or regulatory settings.

If a provider tries to solve this by making the secret key public, malicious actors can easily reverse-engineer it to forge watermarks on human-written text. This paper tackles the challenge of building an asymmetric watermarking system: anyone can verify the watermark publicly, but no one can forge it or detect it without the public key, all while maintaining the original text quality.

Methods

The authors propose a Publicly-Detectable Watermarking Scheme (PDWS) based on a three-step "core gadget" process that utilizes public-key signatures (such as BLS signatures) and rejection sampling:

  1. Extract: The model generates an initial block of tokens natively. These tokens are hashed twice using two different cryptographic hash functions to produce two values, $h_1$ and $h_2$.
  2. Sign, Encode, and Randomize: The value $h_1$ is signed using the provider's private key ($sk$). To prevent the signature from distorting the natural text distribution, it is passed through an error-correcting code (ECC) and masked (XORed) with $h_2$, acting as a one-time pad to ensure pseudorandomness. This creates a codeword $c$.
  3. Plant: The bits of the codeword $c$ are embedded into subsequent token blocks via rejection sampling. The system ensures that the hash of each token block matches the corresponding bit of the codeword.
The three-step embedding process of the core watermarking gadget.

A major innovation here is the handling of low-entropy sequences (highly predictable text like "Rex" following "Tyrannosaurus"). In such cases, rejection sampling normally fails because alternative token choices are unnatural. The authors introduce Error-Correcting Codes (ECC) to allow the generator to intentionally plant "errors" (arbitrary tokens) during low-entropy periods, which the public detector seamlessly fixes and filters out during verification.

Datasets

The authors evaluated their scheme using prompts sampled from the news-like subset of the C4 dataset (Colossal Clean Crawled Corpus).

They tested the generation quality and runtimes across several open and semi-open language models:

  • Mistral 7B (primarily used for text quality analysis)
  • Llama 2 (13B and 70B) (used to verify scaling behavior)
  • OPT 2.7B (used for runtime performance benchmarks)

Key Insights and Ideas

  • The One-Time Pad Solution for Distortion-Freeness: Directly embedding a cryptographic signature alters token distributions, ruining text quality. Masking the signature with a message-derived hash ($h_2$) preserves the statistical properties of the text, making it mathematically indistinguishable from unwatermarked text to anyone without the public key.
  • ECC as an Entropy Buffer: Previous watermarking schemes break down when text becomes highly deterministic. Treating low-entropy token blocks as "noisy channels" and applying standard error-correction principles elegantly bypasses this fundamental limitation.
  • Asymmetric Efficiency: Because the public key defines a clear starting index for verification, asymmetric watermark detection runs in constant or linear time, vastly outperforming symmetric alternatives that scale quadratically due to exhaustive sliding-window searches.

Key Results

  • Zero Quality Degradation: Using GPT-4 Turbo as an automated judge to score text quality from 0 to 100, the authors found no statistically significant difference between plain text and watermarked text across all tested configurations.
  • Blazing Fast Detection: Asymmetric detection consistently executed in approximately 0.01 seconds for Mistral 7B text, whereas symmetric baseline detection varied wildly between 10 and 10,000 seconds.
  • Reduced Runtime Variance: Integrating error correction ($\gamma = 2$) successfully mitigated the massive generation delays typically caused by rejection sampling loops in low-entropy text segments.

Limitations and Future Work

The authors identify two primary limitations to their current framework:

  1. Embedding Compactness: The scheme requires a relatively large footprint to embed a secure digital signature, typically requiring over 1,000 tokens of generated text to fit a single message-signature pair.
  2. Weak Robustness: While the watermark is cryptographically secure against forgery, it only possesses "weak robustness." An adversary can easily scrub the watermark by heavily editing, shuffling, or paraphrasing the text.

Future research directions include optimizing the scheme to reduce the token overhead and exploring advanced error-correcting codes designed specifically to withstand text insertions and deletions (edit-distance robustness).

Summary updated

BibTeX
@article{fairoze2024publicly,
  author = {Jaiden Fairoze and Sanjam Garg and Somesh Jha and Saeed Mahloujifar and Mohammad Mahmoody and Mingyuan Wang},
  title = {{Publicly-Detectable Watermarking for Language Models}},
  journal = {IACR Commun. Cryptol.},
  year = {2024},
  doi = {10.62056/ahmpdkp10},
}
Figure