Skip to content

CAP-SRP: Cryptographic audit trails proving AI systems refused harmful content. EU AI Act Article 12 compliant.

License

Notifications You must be signed in to change notification settings

veritaschain/cap-srp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

CAP-SRP: Refusal Provenance Dashboard

License: Apache 2.0 Python 3.10+ IETF Draft

Cryptographic proof that AI systems refused to generate harmful content.

"When regulators ask for evidence that your AI's safety filters worked, 'trust us' is no longer an acceptable answer."


🎯 What This Solves

The Problem

In January 2026, the EU Commission opened a formal investigation into X/Grok after the AI generated millions of non-consensual intimate images. When asked for evidence that safety systems worked, X could only offer internal logsβ€”self-reported, unverifiable, and potentially modified.

Current AI systems face a fundamental accountability gap:

Question Current State With CAP-SRP
"Did your AI refuse this request?" "Trust our logs" Cryptographic proof
"Were all dangerous requests blocked?" "We think so" Completeness Invariant verification
"Can we independently verify?" No Yes, via Merkle proofs + external anchoring
"Has the log been modified?" Unknown Mathematically impossible without detection

The Solution

CAP-SRP (Content Authenticity Protocol - Safe Refusal Provenance) creates tamper-evident, externally verifiable records of every AI generation request and its outcomeβ€”whether approved, denied, or failed.

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚         COMPLETENESS INVARIANT          β”‚
                    β”‚                                         β”‚
                    β”‚   Ξ£ ATTEMPTS = Ξ£ GEN + Ξ£ DENY + Ξ£ ERROR β”‚
                    β”‚                                         β”‚
                    β”‚   If this equation fails, fraud detectedβ”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Features

  • πŸ” Cryptographic Signing: Every event signed with Ed25519
  • ⛓️ Hash Chain Integrity: Tamper-evident linked records
  • 🌳 Merkle Tree Proofs: O(log n) verification of any event
  • ⏰ External Anchoring: RFC 3161 timestamp authority support
  • βœ… Completeness Verification: Mathematical proof that no events are missing
  • πŸ“Š Real-time Dashboard: Visual compliance monitoring
  • πŸ” Audit Trail Explorer: Drill down into any decision
  • πŸ“‹ Regulatory Reports: One-click compliance documentation

πŸš€ Quick Start

1. Install

git clone https://github.com/veritaschain/cap-srp-dashboard.git
cd cap-srp-dashboard

python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

pip install -e ".[dev]"   # includes test/lint tools

2. Run Dashboard

streamlit run cap_srp/dashboard/app.py
# Open http://localhost:8501

3. Validate Schema

pytest -k schema          # schema validity + example validation

4. Generate Demo

python examples/demo_generate_events.py --events 1000 --output data/demo_events.json

5. Verify Completeness

python examples/demo_verify_completeness.py --input data/demo_events.json

# Or via CLI
cap-srp verify data/demo_events.json

πŸ“ Architecture

Event Types

class EventType(Enum):
    GEN_ATTEMPT = "GEN_ATTEMPT"  # Request received (logged BEFORE evaluation)
    GEN = "GEN"                  # Generation completed successfully
    GEN_DENY = "GEN_DENY"        # Generation refused (safety filter triggered)
    GEN_ERROR = "GEN_ERROR"      # Generation failed (technical error)

Risk Categories (for GEN_DENY events)

class RiskCategory(Enum):
    NCII_RISK = "NCII_RISK"                    # Non-consensual intimate imagery
    CSAM_RISK = "CSAM_RISK"                    # Child sexual abuse material
    REAL_PERSON_DEEPFAKE = "REAL_PERSON_DEEPFAKE"  # Deepfakes of real people
    VIOLENCE_GRAPHIC = "VIOLENCE_GRAPHIC"      # Graphic violence
    HATE_CONTENT = "HATE_CONTENT"              # Hate speech/imagery
    SELF_HARM = "SELF_HARM"                    # Self-harm promotion
    ILLEGAL_ACTIVITY = "ILLEGAL_ACTIVITY"      # Illegal activities
    OTHER = "OTHER"                            # Other policy violations

Event Structure

{
  "event_id": "019478a1-b2c3-7def-8901-234567890abc",
  "event_type": "GEN_DENY",
  "timestamp": "2026-01-28T14:23:45.123456Z",
  "prompt_hash": "sha256:a1b2c3d4e5f6...",
  "user_context_hash": "sha256:f6e5d4c3b2a1...",
  "session_id": "sess_abc123",
  "risk_category": "NCII_RISK",
  "risk_score": 0.94,
  "policy_version": "v2.3.1",
  "model_id": "image-gen-v3",
  "previous_hash": "sha256:9876543210...",
  "signature": "ed25519:MEUCIQDx..."
}

System Flow

User Request
     β”‚
     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    CAP-SRP SIDECAR                          β”‚
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Step 1: Log GEN_ATTEMPT                             β”‚   β”‚
β”‚  β”‚         (Commitment Point - BEFORE evaluation)      β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                         β”‚                                   β”‚
β”‚                         β–Ό                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Step 2: Safety Evaluation                           β”‚   β”‚
β”‚  β”‚         β”œβ”€β”€ SAFE ────► Log GEN (output_hash)       β”‚   β”‚
β”‚  β”‚         β”œβ”€β”€ UNSAFE ──► Log GEN_DENY (risk_info)    β”‚   β”‚
β”‚  β”‚         └── ERROR ───► Log GEN_ERROR (error_info)  β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                         β”‚                                   β”‚
β”‚                         β–Ό                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Step 3: Chain Linking                               β”‚   β”‚
β”‚  β”‚         current_hash = SHA256(event + prev_hash)    β”‚   β”‚
β”‚  β”‚         signature = Ed25519.sign(current_hash)      β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                         β”‚                                   β”‚
β”‚                         β–Ό                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Step 4: Merkle Tree Update (periodic)               β”‚   β”‚
β”‚  β”‚         β€’ Compute new Merkle root                   β”‚   β”‚
β”‚  β”‚         β€’ Anchor to external TSA (RFC 3161)         β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”¬ Completeness Invariant

The Completeness Invariant is the mathematical guarantee that no events have been added, removed, or modified:

For any time window [tβ‚€, t₁]:

    COUNT(GEN_ATTEMPT) = COUNT(GEN) + COUNT(GEN_DENY) + COUNT(GEN_ERROR)

Why This Matters

  1. No Hidden Generations: Every GEN must have a corresponding GEN_ATTEMPT
  2. No Hidden Approvals: Can't add fake "approvals" without the attempt record
  3. No Deleted Denials: Can't remove denial records without breaking the equation
  4. Fraud Detection: Any manipulation breaks the invariant

Verification

from cap_srp.core.verifier import CompletenessVerifier

verifier = CompletenessVerifier()
result = verifier.verify(events)

if result.is_valid:
    print(f"βœ… Completeness verified: {result.total_attempts} events")
else:
    print(f"❌ Completeness violation detected!")
    print(f"   Expected: {result.expected_count}")
    print(f"   Actual: {result.actual_count}")
    print(f"   Missing: {result.missing_events}")

πŸ“Š Dashboard Screenshots

Compliance Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  REFUSAL PROVENANCE DASHBOARD                                       β”‚
β”‚  ═══════════════════════════════════════════════════════════════    β”‚
β”‚                                                                     β”‚
β”‚  System: ImageGenAI-v3.2       Status: βœ… COMPLIANT                 β”‚
β”‚  Provider: Example Corp         Last Event: 2026-01-28 14:23:45    β”‚
β”‚                                                                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                     β”‚
β”‚  COMPLETENESS VERIFICATION                                          β”‚
β”‚  ─────────────────────────────────────────────────────────────────  β”‚
β”‚                                                                     β”‚
β”‚  Total Attempts: 1,247,893    [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ] 100%          β”‚
β”‚  β”œβ”€β”€ Generated:    823,456    [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘]  66%          β”‚
β”‚  β”œβ”€β”€ Denied:       419,234    [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘]  34%          β”‚
β”‚  └── Errors:         5,203    [β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘]  <1%          β”‚
β”‚                                                                     β”‚
β”‚  Invariant Status: βœ… VERIFIED (Ξ£ = 1,247,893)                      β”‚
β”‚  Hash Chain: βœ… INTACT (2,847 blocks verified)                      β”‚
β”‚  External Anchor: βœ… TSA + 3 Witnesses                              β”‚
β”‚                                                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Denial Breakdown

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  DENIAL BREAKDOWN BY RISK CATEGORY                                  β”‚
β”‚  ═══════════════════════════════════════════════════════════════    β”‚
β”‚                                                                     β”‚
β”‚  NCII_RISK            [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘]  187,234  45%          β”‚
β”‚  CSAM_RISK            [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘]   92,108  22%          β”‚
β”‚  REAL_PERSON_DEEPFAKE [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘]   71,456  17%          β”‚
β”‚  VIOLENCE_GRAPHIC     [β–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘]   43,234  10%          β”‚
β”‚  OTHER                [β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘]   25,202   6%          β”‚
β”‚                                                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‹ Regulatory Mapping

EU AI Act Article 12

Requirement CAP-SRP Implementation
Automatic event recording All events logged automatically via sidecar
Risk situation identification risk_category + risk_score fields
Post-market monitoring Continuous event stream + periodic reports
Deployer monitoring Dashboard + API access for oversight
Tamper-evident storage Hash chain + Ed25519 signatures
6+ month retention External TSA anchoring for long-term proof

EU Digital Services Act (DSA)

Requirement CAP-SRP Implementation
Systemic risk assessment Denial pattern analysis + anomaly detection
Content moderation transparency Public denial statistics (aggregated)
Audit access Merkle proof export for independent verification
Documentation for enforcement One-click regulatory report generation

California AI Transparency Act (AB 853)

Requirement CAP-SRP Implementation
AI-generated content disclosure output_hash + C2PA integration ready
Safety measure documentation policy_version + denial reasoning
Audit trail maintenance Complete event history with proofs

πŸ§ͺ Testing

# Run all tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=cap_srp --cov-report=html

# Run specific test file
pytest tests/test_completeness.py -v

πŸ“ Project Structure

cap-srp-dashboard/
β”œβ”€β”€ README.md                 # This file
β”œβ”€β”€ LICENSE                   # Apache 2.0 License
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ setup.py                  # Package installation
β”œβ”€β”€ pyproject.toml           # Modern Python packaging
β”œβ”€β”€ .gitignore               # Git ignore rules
β”‚
β”œβ”€β”€ cap_srp/                  # Main package
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ core/                 # Core functionality
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ events.py        # Event type definitions
β”‚   β”‚   β”œβ”€β”€ logger.py        # Event logging with signatures
β”‚   β”‚   β”œβ”€β”€ signer.py        # Ed25519 cryptographic signing
β”‚   β”‚   β”œβ”€β”€ merkle.py        # Merkle tree implementation
β”‚   β”‚   └── verifier.py      # Completeness verification
β”‚   β”‚
β”‚   β”œβ”€β”€ dashboard/            # Web dashboard
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── app.py           # Streamlit dashboard
β”‚   β”‚
β”‚   └── utils/                # Utilities
β”‚       β”œβ”€β”€ __init__.py
β”‚       └── helpers.py       # Helper functions
β”‚
β”œβ”€β”€ tests/                    # Test suite
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ test_events.py
β”‚   β”œβ”€β”€ test_logger.py
β”‚   β”œβ”€β”€ test_merkle.py
β”‚   └── test_verifier.py
β”‚
β”œβ”€β”€ examples/                 # Example scripts
β”‚   β”œβ”€β”€ demo_generate_events.py
β”‚   └── demo_verify_completeness.py
β”‚
β”œβ”€β”€ docs/                     # Documentation
β”‚   β”œβ”€β”€ ARCHITECTURE.md
β”‚   β”œβ”€β”€ API.md
β”‚   └── REGULATORY_MAPPING.md
β”‚
└── data/                     # Sample data
    └── .gitkeep

πŸ”— Related Projects

  • VCP Specification: VeritasChain Protocol for algorithmic trading
  • IETF SCITT: Supply Chain Integrity, Transparency and Trust
  • C2PA: Coalition for Content Provenance and Authenticity

πŸ“„ Standards Alignment

  • IETF draft-kamimura-scitt-vcp: VCP as SCITT Profile
  • RFC 6962: Certificate Transparency (Merkle tree inspiration)
  • RFC 3161: Time-Stamp Protocol (external anchoring)
  • ISO/IEC 24970:2025: AI System Logging (complementary standard)

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Clone with SSH
git clone git@github.com:veritaschain/cap-srp-dashboard.git

# Install development dependencies
pip install -e ".[dev]"

# Run pre-commit hooks
pre-commit install

πŸ“œ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


πŸ“§ Contact


πŸ™ Acknowledgments

This project builds upon:

  • The IETF SCITT Working Group's foundational work on supply chain transparency
  • Certificate Transparency (RFC 6962) concepts
  • The broader AI safety and accountability community

"Verify, Don't Trust" β€” VeritasChain Standards Organization