Skip to content

Compliledger/CompliGuard

Repository files navigation

πŸ›‘οΈ CompliGuard

Privacy-Preserving Compliance Enforcement with Chainlink CRE

License: MIT Chainlink CRE TypeScript

Continuous compliance enforcement for financial systems β€” privacy-preserving, deterministic, and automated.

Features β€’ Architecture β€’ Quick Start β€’ Compliance Controls β€’ Documentation


πŸ“‹ Overview

CompliGuard is a production-grade compliance enforcement engine that continuously evaluates and enforces financial safety controls using deterministic rules, private offchain data, and Chainlink's Runtime Environment (CRE).

Unlike traditional compliance tools that rely on periodic reporting and trust, CompliGuard treats compliance as a runtime system property β€” evaluated continuously and enforced automatically.

The Problem

Modern financial systems (stablecoins, tokenized assets, treasuries, custodians) rely on sensitive, non-public data to meet regulatory expectations:

  • Are reserves still covering liabilities?
  • Is proof of backing recent and reliable?
  • Are reserves held in acceptable, diversified assets?
  • What happens immediately when those conditions fail?

Existing approaches are: periodic, manual, document-driven, and slow to react.

CompliGuard provides: continuous, automated enforcement β€” without exposing sensitive data.


✨ Features

Feature Description
πŸ”„ Continuous Monitoring Real-time evaluation of compliance controls
πŸ” Privacy-Preserving Sensitive data never exposed on-chain
⚑ Deterministic Rules Machine-readable, auditable policy engine
πŸ”— Chainlink CRE Secure offchain orchestration
πŸ€– AI-Enhanced Human-readable explanations (non-decisional)
πŸ“Š Multi-Control Reserve ratio, freshness, asset quality

What CompliGuard Is

βœ… A compliance enforcement engine
βœ… A Chainlink CRE workflow
βœ… A deterministic control plane
βœ… A privacy-preserving architecture
βœ… A foundation for automated safeguards

What CompliGuard Is Not

❌ A legal opinion
❌ A regulatory certification
❌ A sanctions adjudication engine
❌ A dashboard or reporting tool
❌ A replacement for auditors or regulators

CompliGuard enforces controls β€” it does not encode laws.


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     External Regulated APIs         β”‚
β”‚  (reserves, liabilities, signals)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚ Confidential HTTP
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Chainlink Runtime Environment     β”‚
β”‚            (CRE)                    β”‚
β”‚      Offchain Execution Layer       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Deterministic Policy Engine      β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚ Reserve β”‚  Proof  β”‚  Asset  β”‚   β”‚
β”‚   β”‚  Ratio  β”‚Freshnessβ”‚ Quality β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Compliance Status + Evidence    β”‚
β”‚       🟒 GREEN β”‚ 🟑 YELLOW β”‚ πŸ”΄ RED  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

CRE acts as the orchestration and reliability layer, coordinating private data ingestion, policy execution, and output propagation.


πŸš€ Quick Start

Prerequisites

  • Node.js >= 18.0.0
  • npm or yarn
  • Chainlink CRE access (for production)

Installation

# Clone the repository
git clone https://github.com/Compliledger/CompliGuard.git
cd CompliGuard

# Install dependencies
npm install

# Copy environment variables
cp .env.example .env

# Run in development mode
npm run dev

πŸ”— Chainlink CRE Files (Required for Submission)

CRE Workflow (Production β€” compiled to WASM, runs on DON)

File Purpose
cre-workflow/compliance-monitor/main.ts Primary CRE workflow β€” EVMClient reads Chainlink PoR + BTC/USD feeds, deterministic policy evaluation, writeReport() to Sepolia
cre-workflow/compliance-monitor/config.staging.json Feed addresses (WBTC PoR, BTC/USD, WBTC ERC20), Sepolia report contract, cron schedule
cre-workflow/compliance-monitor/workflow.yaml CRE workflow metadata (name, entry point, config paths, secrets path)
cre-workflow/project.yaml Global CRE project config β€” RPC endpoints for mainnet + Sepolia
cre-workflow/secrets.yaml CRE Vault secret declarations (RESERVE_API_KEY, LIABILITY_API_KEY)
cre-workflow/contracts/abi/AggregatorV3.ts Chainlink AggregatorV3Interface ABI (latestRoundData, decimals)
cre-workflow/contracts/abi/ERC20.ts ERC20 ABI subset (totalSupply) for WBTC circulating supply
cre-workflow/README.md CRE setup, simulation, and deployment guide

Backend Integration (Node.js β€” live Chainlink data)

File Purpose
src/api/chainlink-por-reader.ts Reads WBTC PoR + BTC/USD feeds via viem β€” live reserve & liability data
src/api/server.ts API server with live/simulation mode toggle, compliance endpoints
src/cre/workflow.ts Local CRE workflow executor (orchestrates engine + API clients)
src/cre/http.ts HTTP adapter (Node ↔ CRE mode switching)
src/cre/confidential-http.ts Confidential HTTP bridge (local fallback; CRE uses SDK directly)
docs/privacy-boundary.md Privacy boundary architecture and data classification

πŸ§ͺ Run with CRE (Simulation / Deployment)

# Navigate to CRE project
cd cre-workflow

# Install workflow dependencies
cd compliance-monitor && bun install && cd ..

# Simulate the CRE workflow via CLI
cre workflow simulate compliance-monitor --target staging-settings

# Deploy to CRE network (Early Access β€” requires approval)
cre workflow deploy compliance-monitor --target production-settings

Local workflow run (without CRE CLI):

npm install

# Terminal 1 β€” Start API server
npm run server

# Terminal 2 β€” Run local workflow
npm run workflow

Demo scenarios (for video recording):

# Switch to healthy (GREEN)
curl -X POST http://localhost:3001/api/simulate/scenario -H 'Content-Type: application/json' -d '{"scenario":"healthy"}'

# Switch to at-risk (YELLOW)
curl -X POST http://localhost:3001/api/simulate/scenario -H 'Content-Type: application/json' -d '{"scenario":"at_risk"}'

# Switch to non-compliant (RED)
curl -X POST http://localhost:3001/api/simulate/scenario -H 'Content-Type: application/json' -d '{"scenario":"non_compliant"}'

# Get current compliance status
curl http://localhost:3001/api/compliance/status

Running Tests

# Unit tests
npm test

# Integration tests
npm run test:integration

# Coverage report
npm run test:coverage

πŸ“ Compliance Controls

CompliGuard enforces explicit, machine-readable financial safety controls.

1️⃣ Asset Coverage (Reserve Ratio)

reserve_ratio = reserves / liabilities
Condition Status
β‰₯ 1.02 🟒 GREEN
1.00–1.019 🟑 YELLOW
< 1.00 πŸ”΄ RED

2️⃣ Proof Freshness

Attestation Age Status
≀ 6 hours 🟒 GREEN
6–24 hours 🟑 YELLOW
> 24 hours πŸ”΄ RED

3️⃣ Asset Quality & Concentration

Condition Status
Disallowed assets present πŸ”΄ RED
Risky assets > 30% πŸ”΄ RED
Single-asset concentration > 75% 🟑 YELLOW

Aggregation Rule

Worst-of wins. If any required control fails, the system is non-compliant.

This mirrors real-world prudential logic used by regulators and auditors.


πŸ” Privacy Architecture

CompliGuard is privacy-preserving by design, using Chainlink CRE's Confidential HTTP capability to securely integrate sensitive Web2 data into decentralized workflows.

Data Classification

Never Exposed Safely Exposed
API keys and credentials Compliance status (GREEN/YELLOW/RED)
Raw reserve values Policy version
Liability values Cryptographic evidence hash
Detailed asset composition Evaluation timestamp
Internal evaluation logic Human-readable explanation

Privacy Flow

[Confidential HTTP Fetch] β†’ [Offchain Policy Evaluation] β†’ [Status + Evidence Emission]

See Privacy Boundary Architecture for the complete data flow diagram, classification matrix, and verification steps.


πŸ” Regulatory Alignment

CompliGuard is policy-agnostic and designed to operationalize regulatory requirements without hardcoding statutory language.

Alignment with Modern Regulation

Modern regulation (GENIUS, CLARITY, etc.) emphasizes:

  • βœ… Continuous monitoring
  • βœ… Verified reserve backing
  • βœ… Clear, enforceable controls
  • βœ… Immediate response to breaches
  • βœ… Use of non-public, regulated data

Laws define obligations. Risk systems detect exposure. CompliGuard enforces consequences.


πŸ€– AI Usage

AI is used only to generate human-readable explanations of deterministic outcomes.

  • AI does not decide compliance
  • AI cannot override rules
  • AI failure does not affect enforcement

This ensures: auditability, determinism, and explainability without risk.


βš™οΈ Chainlink CRE Integration

CompliGuard uses Chainlink CRE to:

  • πŸ”„ Orchestrate offchain workflows
  • πŸ” Securely integrate external APIs
  • πŸ” Manage retries and failures
  • πŸ–₯️ Execute confidential computation
  • βœ… Produce verifiable execution outcomes

CRE is the control plane that makes CompliGuard production-ready.


πŸ§ͺ Demo Flow

A typical demonstration (3–5 minutes):

  1. System starts 🟒 GREEN
  2. Confidential reserve data is ingested
  3. Policy rules are evaluated offchain
  4. A control threshold is violated
  5. Status flips to πŸ”΄ RED
  6. Explanation is generated
  7. Sensitive data remains private throughout

πŸ“ Project Structure

CompliGuard/
β”œβ”€β”€ cre-workflow/                       # Chainlink CRE project (compiled to WASM)
β”‚   β”œβ”€β”€ compliance-monitor/             # CRE workflow subdirectory
β”‚   β”‚   β”œβ”€β”€ main.ts                     # Workflow: EVM reads + policy eval + Sepolia write
β”‚   β”‚   β”œβ”€β”€ config.staging.json         # Feed addresses, API URLs, cron schedule
β”‚   β”‚   β”œβ”€β”€ config.production.json      # Production config
β”‚   β”‚   β”œβ”€β”€ workflow.yaml               # CRE workflow metadata
β”‚   β”‚   β”œβ”€β”€ package.json                # CRE SDK + viem + zod
β”‚   β”‚   └── tsconfig.json               # TypeScript config
β”‚   β”œβ”€β”€ contracts/abi/                  # On-chain ABI definitions
β”‚   β”‚   β”œβ”€β”€ AggregatorV3.ts             # Chainlink AggregatorV3Interface
β”‚   β”‚   β”œβ”€β”€ ERC20.ts                    # ERC20 totalSupply
β”‚   β”‚   └── index.ts                    # Barrel export
β”‚   β”œβ”€β”€ project.yaml                    # Global CRE config (RPCs)
β”‚   β”œβ”€β”€ secrets.yaml                    # CRE Vault secret declarations
β”‚   └── .env.example                    # Environment template
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ core/                           # Core policy engine
β”‚   β”‚   β”œβ”€β”€ engine.ts                   # Deterministic compliance engine
β”‚   β”‚   β”œβ”€β”€ ai-reasoning.ts             # AI reasoning agent (advisory only)
β”‚   β”‚   β”œβ”€β”€ audit.ts                    # Tamper-proof audit logger
β”‚   β”‚   β”œβ”€β”€ validation.ts               # Zod schema validation
β”‚   β”‚   β”œβ”€β”€ rules/                      # 4 compliance rules
β”‚   β”‚   β”‚   β”œβ”€β”€ reserve-ratio.rule.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ proof-freshness.rule.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ asset-quality.rule.ts
β”‚   β”‚   β”‚   └── asset-concentration.rule.ts
β”‚   β”‚   └── types.ts                    # Type definitions
β”‚   β”œβ”€β”€ api/                            # API layer
β”‚   β”‚   β”œβ”€β”€ server.ts                   # API server + live Chainlink data
β”‚   β”‚   β”œβ”€β”€ chainlink-por-reader.ts     # On-chain PoR + BTC/USD + WBTC supply reader
β”‚   β”‚   └── clients.ts                  # Reserve/liability API clients
β”‚   β”œβ”€β”€ cre/                            # CRE integration (local mode)
β”‚   β”‚   β”œβ”€β”€ workflow.ts                 # Local CRE workflow executor
β”‚   β”‚   β”œβ”€β”€ http.ts                     # HTTP adapter (Node/CRE mode)
β”‚   β”‚   β”œβ”€β”€ confidential-http.ts        # Confidential HTTP bridge
β”‚   β”‚   └── run.ts                      # CLI runner
β”‚   └── utils/                          # Utilities (hash, logger)
β”œβ”€β”€ frontend/                           # React dashboard (Vercel)
β”œβ”€β”€ contracts/                          # Solidity compliance contract (Sepolia)
β”œβ”€β”€ tests/                              # Unit + integration tests
β”œβ”€β”€ docs/
β”‚   └── privacy-boundary.md             # Privacy boundary architecture
└── progress.md                         # Milestone tracker

🏁 Hackathon Tracks

Track Status Key Evidence
Best Use of CRE βœ… Primary Full CRE workflow: EVM reads + HTTP + cron trigger + EVM write
Best Use of Chainlink Data βœ… Primary Reads WBTC PoR + BTC/USD price feeds on Ethereum mainnet
Privacy Track βœ… Primary Confidential HTTP ready; raw values never leave DON
DeFi Track βœ… Primary Automated compliance monitoring for wrapped-asset reserves
AI βž• Supporting Human-readable explanations (non-decisional)

🧩 Why This Matters

Compliance cannot be slower than risk.

CompliGuard turns compliance from a periodic promise into a continuously enforced system property β€” while preserving privacy, auditability, and institutional trust.


πŸ“„ License

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


CompliGuard β€” Privacy-preserving compliance enforcement, powered by Chainlink CRE.

About

CompliGuard is a privacy-preserving compliance enforcement engine that operationalizes GENIUS, CLARITY, and sanctions-aligned controls using deterministic rules orchestrated by Chainlink CRE.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors