verigate-concordium
by beaaan
README.md
# VeriGate — Concordium Trusted Agent Gateway
**Encode Club × Concordium Trusted Agents Hackathon Submission**
> Attach Concordium's protocol-level **Zero-Knowledge Human Accountability ("Verified by Concordium")**, on-chain **CIS-8004 / ERC-8004 Agent Registry** anchoring, **`@x402/concordium` V1 Sponsored Micropayments**, and **MCP + A2A** interoperability onto any cross-chain AI agent (Ethereum, Base, Solana, or Bittensor).
---
## Why VeriGate?
Autonomous AI agents already transact across Base, Solana, and Bittensor—but standard ERC-8004 agent cards only describe *what* an agent does, not *who* is legally accountable for it or how to settle gasless, compliance-aware micropayments.
**VeriGate** bridges any existing cross-chain AI agent into Concordium's trust stack in four layers:
1. **Live CIS-8004 Agent Registry Verification (`@concordium/web-sdk`)**
- Connects directly via gRPC-Web to Concordium's official deployed `init_CIS-8004` smart contracts on **Testnet (`<12802,0>`)** and **Mainnet (`<10082,0>`)**.
- Encodes/decodes native CIS-2 / CIS-8004 binary parameters (`CIS-8004.getAdmin`, `CIS-8004.tokenMetadata`, `CIS-8004.getAgentWallet`) to resolve live registered agent metadata URLs, SHA-256 content-hash commitments, and payment wallets.
- Generates canonical **CIS-8 External Key Registry** bindings (`caip10` <-> `did:ccd`) linking EVM (`eip155:8453`), Solana, or Bittensor agent wallets to a Concordium human accountability anchor.
2. **"Verified by Concordium" ZK Identity Badge (`Web3 ID AtomicStatementV2`)**
- Builds zero-knowledge attribute statements (`dob` age >= 18 range proof, non-sanctioned `countryOfResidence` exclusion set, valid `idDocType` set) with **zero PII disclosed**.
- Verifies Ed25519 operator attestations and grants **VERIFIED_GOLD** agents an automatic **50% (`5000 bps`) x402 fee discount** on protected API endpoints.
3. **`@x402/concordium` Sponsored V1 Payment Gateway (`@x402/concordium@2.33.0`)**
- Uses the official `@x402/concordium/exact/server` (`ExactConcordiumScheme`) to generate HTTP `402 Payment Required` challenges (`PAYMENT-REQUIRED` header) supporting native **CCD** and **PLT** (`USDR`) pricing.
- Implements a client builder + full **9-Rule Facilitator Verifier** (V1 format, sender match, sponsor match, CIS-8004 `payTo` match, exact amount, asset type, `<= 600s` expiry window, Ed25519 signature verification, and sponsor isolation) returning signed `PAYMENT-RESPONSE` receipts.
4. **Full MCP (Model Context Protocol) + A2A (Agent-to-Agent v0.3) Interoperability**
- Exposes **5 live MCP tools** over both Streamable HTTP (`POST /mcp`) and standalone stdio (`npm run mcp`) for Claude Desktop, Cursor, and autonomous agent harnesses.
- Serves canonical **`/.well-known/agent-card.json`** (ERC-8004 + A2A + MCP + CIS-8004 + x402) and **`POST /a2a`** (`tasks/send`).
---
## Architecture
```
Cross-Chain AI Agent (Base / Solana / Bittensor)
│
├── 1. CIS-8 External Key Binding ──▶ did:ccd:<network>:<account>
├── 2. Web3 ID ZK Proof (Zero PII) ──▶ "Verified by Concordium" Badge (50% x402 discount)
├── 3. ERC-8004 / CIS-8004 Card ──▶ SHA-256 Commitment on Concordium <12802,0> / <10082,0>
└── 4. HTTP 402 Resource Call ──▶ @x402/concordium V1 Sponsored Tx
├─ Client sender-signs V1 tx (zero user gas)
├─ Facilitator enforces all 9 security rules
└─ 200 OK + PAYMENT-RESPONSE + Protected Intelligence
```
---
## Quick Start
**Requirements:** Node.js `>= 22.x`
```bash
npm install
npm run build
npm test
npm run dev
```
Open **`http://localhost:3402`** to launch the **VeriGate Control Plane**:
- **Panel 1:** Inspect live Concordium Testnet (`<12802,0>`) & Mainnet (`<10082,0>`) `init_CIS-8004` contracts and query real on-chain agents (e.g., Agent `#1`).
- **Panel 2:** Execute end-to-end `@x402/concordium` HTTP 402 -> V1 Sponsored Tx -> 9-Rule Verification -> 200 OK flows (with ZK discount toggle and adversarial attack injections).
- **Panel 3:** Generate canonical ERC-8004 + CIS-8 cross-chain Agent Cards with SHA-256 commitments and verify zero-PII ZK badges.
- **Panel 4:** Invoke live MCP (`POST /mcp`) and A2A (`POST /a2a`) JSON-RPC 2.0 endpoints.
### Running as a Standalone MCP Server (Claude Desktop / Cursor)
```json
{
"mcpServers": {
"verigate-concordium": {
"command": "npx",
"args": ["tsx", "src/mcp-stdio.ts"],
"cwd": "/path/to/concordium-agent"
}
}
}
```
---
## Verification & Automated Tests
```bash
npm test
```
The Vitest suite verifies:
- CIS-2 / CIS-8004 binary parameter encoding & metadata response decoding
- ERC-8004 Agent Card SHA-256 commitment matching & CIS-8 cross-chain binding
- Zero-PII "Verified by Concordium" ZK badge verification & tamper rejection
- All **9 `@x402/concordium` facilitator rules** (including underpayment, spoofed `payTo`, expired transaction, and tampered Ed25519 signature attacks)
- End-to-end HTTP `402 -> 200 OK` Express middleware handshake with 50% ZK badge discount
- `/.well-known/agent-card.json`, MCP JSON-RPC 2.0 (`tools/list`, `tools/call`), and A2A `tasks/send`
- **Live on-chain Concordium Testnet `<12802,0>` gRPC-Web query** resolving real registered Agent `#1`
---
## Production Path & Mainnet Deployment Roadmap
See [docs/MAINNET_ROADMAP.md](docs/MAINNET_ROADMAP.md) for the full 4-phase production rollout plan covering:
- **Phase 1 (Testnet Live — Completed):** Live gRPC-Web reads against `<12802,0>`, `@x402/concordium` server & 9-rule facilitator verifier, zero-PII Web3 ID statement verification, MCP/A2A endpoints.
- **Phase 2 (Sponsored Testnet Settlement & CIS-8004 Minting — Weeks 1–2):** Fund a dedicated Concordium Testnet sponsor wallet via Concordium Wallet for Web, mint VeriGate's `CIS-8004.register` NFT, pin `/.well-known/agent-card.json` hash on-chain, and enable `toConcordiumFacilitatorSigner` live broadcast with ConcordiumBFT `waitForFinalization`.
- **Phase 3 (Mainnet `<10082,0>` Launch & PLT Stablecoin Support — Weeks 3–6):** Switch CAIP-2 target to `ccd:9dd9ca4d19e9393877d2c44b70f89acb`, anchor production operator identity via Concordium Mainnet Identity Provider + Web3 ID Groth16/Bulletproof verification, integrate StablR `USDR` / `EURR` PLT settlement, and deploy HSM/YubiKey-backed facilitator signing via `@ccd-agent-kit/ccd-signer`.
- **Phase 4 (Ecosystem SDK & Grant Scale — Months 2–4):** Publish `@verigate/concordium-middleware` npm package so any Express/Fastify/Next.js AI agent on Ethereum, Solana, or Bittensor can add `"Verified by Concordium"` + `x402` monetization in 5 lines of code.
---
## Demo Video
See `demo/verigate-demo.mp4` (`< 3 min` end-to-end walkthrough of live Testnet `<12802,0>` inspection, ZK-discounted x402 settlement, attack blocking, ERC-8004 card generation, and MCP/A2A calls).
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues