DEV Community

RESK
RESK

Posted on

Cryptographic Watermarking for LLM Outputs with resk-mark

resk-mark demo

How to Detect AI-Generated Text with Cryptographic Watermarking

LLM outputs look indistinguishable from human writing. Thats a problem for trust, attribution, and content verification.

resk-mark embeds a cryptographic watermark into every token an LLM generates. Its invisible to readers, unremovable by adversaries, and verifiable with a secret key.

How It Works

The watermark operates at the logits level during generation. A cryptographic function biases the token sampling distribution in a way that embeds a statistical signature. Only someone holding the secret key can detect it.

pip install reskmark
Enter fullscreen mode Exit fullscreen mode

Key Features

  • Cryptographic security — the watermark is embedded via a pseudorandom function keyed with a secret. Without the key, detection is computationally infeasible.
  • Zero quality loss — the watermark is statistical, not structural. Perplexity, fluency, and coherence are preserved.
  • Drop-in integration — works with any OpenAI-compatible API via a middleware wrapper. Compatible with vLLM, TGI, llama.cpp, and custom pipelines.
  • GPU accelerated — the watermarking step adds under 1ms per generation on consumer hardware.
  • MIT licensed — fully open source, auditable, transparent.

Links

Quick Start

from reskmark import RMarkConfig, RMarkLM

watermark = RMarkLM(
    model="gpt-4o-mini",
    config=RMarkConfig(secret_key="your-secret-key")
)

response = watermark.generate("Generate a blog post about AI safety")
Enter fullscreen mode Exit fullscreen mode

Why This Matters

As LLMs become ubiquitous, being able to attribute text to a specific model run is critical for academic integrity, content moderation, and intellectual property protection.

Try it and let me know what you think. PRs welcome.


Built with Resk Security — making AI deployment safer, one token at a time.

Top comments (0)