Skip to main content

ZTDS (Zero-Trust Data Sanitization)

IETF Draft PyPI version License: MIT ZTDS Verified

Canonical Python Reference Implementation of the Zero-Trust Data Sanitization (ZTDS) Protocol (IETF draft-sibiryakov-ztds-protocol-02, RFC v1.0).

ZTDS physically prevents PII, PHI, API tokens, and corporate secrets from crossing WAN sockets unmasked. It operates 100% in local process RAM with zero external network egress, sub-millisecond execution (<0.05ms), and verifiable memory zeroization.


🏛️ Invariants Enforced (RFC v1.0)

  1. Invariant 1: Zero External Egress Prior to Sanitization Every byte of prompt data is inspected and sanitized locally in volatile memory. Zero unmasked data touches network interfaces.
  2. Invariant 2: Deterministic Reversible Bijective Tokenization Syntactic bracketed surrogates ([NAME_1], [EMAIL_1], [API_SECRET_1]) preserve entity coreference and LLM reasoning semantics while enabling exact bijective restoration ($f^{-1}(f(x)) = x$).
  3. Invariant 3: Ephemeral In-RAM Session Isolation & Zeroization (Theorem 2) Cryptographic mapping tables reside strictly in volatile RAM, isolated per session, and are destructively overwritten upon session completion.
  4. Invariant 4: Zero Subprocessors & Zero Telemetry No SaaS calls, no cloud APIs, and no telemetry side-channels. Eliminates GDPR Article 28 data processing agreements and vendor risk reviews.

⚡ Quickstart

Install the zero-dependency Python package:

pip install ztds

1. In-Memory Sanitization & Restoration

import ztds

prompt = "Deploy microservice with key sk-ant-api03-0123456789abcdef0123456789abcdef and email dev@corp.internal"

# Use context manager for automatic Invariant 3 RAM zeroization
with ztds.session() as s:
    # Phase 1: Local In-Memory Sanitization (<0.05ms)
    sanitized, minted_tokens = s.sanitize(prompt)
    print(sanitized)
    # Output: "Deploy microservice with key [API_SECRET_1] and email [EMAIL_1]"

    # Phase 2: Send sanitized string safely to any frontier model
    # ai_raw_response = client.chat.completions.create(messages=[{"role": "user", "content": sanitized}])
    ai_raw_response = "Confirmed. Credentials for [EMAIL_1] are stored."

    # Phase 3: Bijective Restoration in Local RAM
    clean_response = s.reveal(ai_raw_response)
    print(clean_response)
    # Output: "Confirmed. Credentials for dev@corp.internal are stored."

# Memory mapping is completely wiped upon context exit (Theorem 2)

🔌 Framework Integrations

LiteLLM Proxy / SDK

Install with LiteLLM extras:

pip install "ztds[litellm]"
import litellm
from ztds.integrations import ZTDSGuardrail

# Intercept all calls locally before WAN socket dispatch
litellm.input_callbacks = [ZTDSGuardrail()]
litellm.output_callbacks = [ZTDSGuardrail()]

response = litellm.completion(
    model="gpt-4o",
    messages=[{"role": "user", "content": "My AWS key is AKIAIOSFODNN7EXAMPLE"}]
)
# Upstream OpenAI receives only "[API_SECRET_1]"
# Your application receives restored output automatically

LangChain

from langchain_openai import ChatOpenAI
from ztds.integrations import ZTDSSanitizingCallbackHandler

llm = ChatOpenAI(
    callbacks=[ZTDSSanitizingCallbackHandler()]
)

CrewAI Multi-Agent Workflows

from crewai import Agent
from ztds.integrations import ZTDSSanitizerTool

security_agent = Agent(
    role="Data Officer",
    goal="Sanitize customer logs before delegation",
    tools=[ZTDSSanitizerTool()]
)

LlamaIndex RAG Node Postprocessor

from llama_index.core import VectorStoreIndex
from ztds.integrations import ZTDSNodePostprocessor

query_engine = index.as_query_engine(
    node_postprocessors=[ZTDSNodePostprocessor()]
)

🛠️ CLI Tools

# Verify compliance with RFC v1.0 canonical test vectors
ztds conformance

# Output JSON for CI/CD pipelines
ztds conformance --json

# Audit local codebase for unmasked secrets and telemetry side-channels
ztds audit --dir ./src --strict

# Quick in-memory sanitization from command line
ztds sanitize "Contact alice@example.com with key sk-proj-12345678901234567890"

📊 Conformance & Performance

All 8 canonical RFC v1.0 test vectors pass with 100% Invariant fidelity:

Test Vector ID Category Status Latency
VEC-CORE-001 Universal Consumer PII PASS 0.04ms
VEC-CORE-002 Coreference Determinism PASS 0.02ms
VEC-HEALTH-001 Healthcare PHI & HIPAA Safe Harbor PASS 0.04ms
VEC-FIN-001 Financial & Banking (ISO 20022) PASS 0.03ms
VEC-SEC-001 Developer Secrets & Cloud Tokens PASS 0.03ms
VEC-MULTI-001 Multi-Lingual Global Entities PASS 0.04ms
VEC-REDOS-001 ReDoS Stress & Catastrophic Backtracking PASS 0.03ms
VEC-UNICODE-001 Unicode Normalization & Homoglyphs PASS 0.03ms

Average latency per prompt: ~0.031 ms (31 microseconds).


📜 Intellectual Property & Standards

  • IETF Specification: draft-sibiryakov-ztds-protocol-02
  • Consortium & RFC Registry: https://ztds.ai
  • IPR Disclosure: Filed under IETF RFC 8179 rules (Royalty-Free grant for Open-Source implementations with Defensive Termination).
  • Commercial Certified Reference Implementation: PrivacyScrubber (30 specialized industry profiles, HIPAA/FRE 502/SOC 2 compliance packs, enterprise air-gapped on-premise engines).

📄 License

MIT License. Copyright (c) 2026 Ilya Sibiryakov & ZTDS AI Consortium.

Metadata

Release files for ztds 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ztds 1.1.0
File Size Uploaded
ztds-1.1.0.tar.gz 19.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ztds 1.1.0
File Interpreter ABI Platform
ztds-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 41.4 kB

Release files / ztds-1.1.0.tar.gz

Download URL ztds-1.1.0.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
367de44819bd1006e1e249737050f85d534d183a036a349a68ddbac493784c32
BLAKE2b-256 checksum
How to use checksums
fcc8679edefe5b4da590ae6bd1017f630d9d338ddbfa4a2e4f8eaedbf7a55eeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / ztds-1.1.0-py3-none-any.whl

Download URL ztds-1.1.0-py3-none-any.whl
Size 22.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10a7293fa8ef2d5667df44ea2db40b5c78a25a513499ef07cc906fbcf6664088
BLAKE2b-256 checksum
How to use checksums
8cdc6c525a2f69cf2b3b10ad51404a7ab1a396181610be1b811c52c7618abc32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

1.1.1

2 release files

This release

1.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page